Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
V
Visualization
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Modules
Visualization
Commits
0cad21f3
Commit
0cad21f3
authored
Jun 05, 2019
by
Mark Olesen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ENH: improve handling of font sizes for scalarBar
parent
93a1853d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
9 deletions
+35
-9
src/runTimePostProcessing/scalarBar.C
src/runTimePostProcessing/scalarBar.C
+15
-8
src/runTimePostProcessing/scalarBar.H
src/runTimePostProcessing/scalarBar.H
+20
-1
No files found.
src/runTimePostProcessing/scalarBar.C
View file @
0cad21f3
...
@@ -57,8 +57,8 @@ void Foam::functionObjects::runTimePostPro::scalarBar::clear()
...
@@ -57,8 +57,8 @@ void Foam::functionObjects::runTimePostPro::scalarBar::clear()
position_
=
{
0
.
8
,
0
.
1
};
position_
=
{
0
.
8
,
0
.
1
};
size_
=
{
0
.
1
,
0
.
5
};
size_
=
{
0
.
1
,
0
.
5
};
title_
=
""
;
title_
=
""
;
fontSize_
=
12
;
fontSize_
=
0
;
// 0 == Auto-sizing (defaultFontSize)
titleSize_
=
0
;
// 0 == Auto-sizing (
factor 3
)
titleSize_
=
0
;
// 0 == Auto-sizing (
defaultTitleSizeFactor
)
nLabels_
=
5
;
nLabels_
=
5
;
labelFormat_
=
"%f"
;
labelFormat_
=
"%f"
;
}
}
...
@@ -121,6 +121,8 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
...
@@ -121,6 +121,8 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
return
false
;
return
false
;
}
}
const
label
fontSizeValue
=
(
fontSize_
?
fontSize_
:
defaultFontSize
);
auto
sbar
=
vtkSmartPointer
<
vtkScalarBarActor
>::
New
();
auto
sbar
=
vtkSmartPointer
<
vtkScalarBarActor
>::
New
();
sbar
->
SetLookupTable
(
lut
);
sbar
->
SetLookupTable
(
lut
);
sbar
->
SetNumberOfLabels
(
nLabels_
);
sbar
->
SetNumberOfLabels
(
nLabels_
);
...
@@ -139,6 +141,8 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
...
@@ -139,6 +141,8 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
if
(
titleHack_
)
if
(
titleHack_
)
{
{
// Place the scalar bar title ourselves
// Place the scalar bar title ourselves
sbar
->
SetUnconstrainedFontSize
(
true
);
titleActor
=
vtkSmartPointer
<
vtkTextActor
>::
New
();
titleActor
=
vtkSmartPointer
<
vtkTextActor
>::
New
();
titleActor
->
SetInput
(
title_
.
c_str
());
titleActor
->
SetInput
(
title_
.
c_str
());
...
@@ -148,6 +152,7 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
...
@@ -148,6 +152,7 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
else
else
{
{
// Use the standard scalar bar title
// Use the standard scalar bar title
sbar
->
SetUnconstrainedFontSize
(
fontSize_
!=
0
);
sbar
->
SetTitle
(
title_
.
c_str
());
sbar
->
SetTitle
(
title_
.
c_str
());
titleProp
=
sbar
->
GetTitleTextProperty
();
titleProp
=
sbar
->
GetTitleTextProperty
();
}
}
...
@@ -163,11 +168,11 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
...
@@ -163,11 +168,11 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
}
}
else
else
{
{
// Auto
= Factor 3 of fontSize
// Auto
titleProp
->
SetFontSize
(
3
*
fontSize_
);
titleProp
->
SetFontSize
(
defaultTitleSizeFactor
*
fontSizeValue
);
// Or this??
// Or this??
// if (!titleHack_) titleProp->SetFontSize(fontSize
_
);
// if (!titleHack_) titleProp->SetFontSize(fontSize
Value
);
}
}
titleProp
->
SetJustificationToCentered
();
titleProp
->
SetJustificationToCentered
();
...
@@ -178,14 +183,16 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
...
@@ -178,14 +183,16 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
titleProp
->
SetColor
(
textColour
[
0
],
textColour
[
1
],
textColour
[
2
]);
titleProp
->
SetColor
(
textColour
[
0
],
textColour
[
1
],
textColour
[
2
]);
auto
labProp
=
sbar
->
GetLabelTextProperty
();
auto
labProp
=
sbar
->
GetLabelTextProperty
();
labProp
->
SetColor
(
textColour
[
0
],
textColour
[
1
],
textColour
[
2
]);
labProp
->
SetColor
(
textColour
[
0
],
textColour
[
1
],
textColour
[
2
]);
labProp
->
SetFontSize
(
fontSize_
);
if
(
titleHack_
||
fontSize_
)
{
labProp
->
SetFontSize
(
fontSizeValue
);
}
labProp
->
ShadowOff
();
labProp
->
ShadowOff
();
labProp
->
BoldOff
();
labProp
->
BoldOff
();
// or: labProp->SetBold(bold_);
labProp
->
ItalicOff
();
labProp
->
ItalicOff
();
// Positioning
// Positioning
...
...
src/runTimePostProcessing/scalarBar.H
View file @
0cad21f3
...
@@ -35,7 +35,7 @@ Description
...
@@ -35,7 +35,7 @@ Description
position | Viewport position (x y) of scalar bar | yes |
position | Viewport position (x y) of scalar bar | yes |
vertical | Vertical scalar bar | no | true
vertical | Vertical scalar bar | no | true
size | Viewport size (x y) of scalar bar | no | auto
size | Viewport size (x y) of scalar bar | no | auto
fontSize | Label size | no |
12
fontSize | Label size | no |
0 == auto
titleSize | Title font size | no | 0 == auto
titleSize | Title font size | no | 0 == auto
labelFormat | Label format string (eg, "%f") | no | "%f"
labelFormat | Label format string (eg, "%f") | no | "%f"
numberOfLabels | Total number of labels | no | 5
numberOfLabels | Total number of labels | no | 5
...
@@ -45,6 +45,19 @@ Description
...
@@ -45,6 +45,19 @@ Description
titleHack | Alternative placement strategy | no | yes
titleHack | Alternative placement strategy | no | yes
\endtable
\endtable
Note
The \c titleHack option is a leftover from much older VTK versions
that had poor handling of the scalar bar text. When this is active,
the normal scalar bar title is suppressed and placed manually
(with a predefined ratio of the base font-size).
When the titleHack is off, the label and title font sizes are
automatically defined by the scalar bar size but can be overridden with
provided values.
The effect of fontSize and titleSize is unfortunately not consistent
between titleHack on/off.
SourceFiles
SourceFiles
scalarBar.C
scalarBar.C
...
@@ -77,6 +90,12 @@ namespace runTimePostPro
...
@@ -77,6 +90,12 @@ namespace runTimePostPro
class
scalarBar
class
scalarBar
{
{
//- The default font size when titleHack is on
static
constexpr
const
label
defaultFontSize
=
18
;
//- The auto title/label ratio when titleHack is on
static
constexpr
const
float
defaultTitleSizeFactor
=
1.5
;
bool
visible_
;
bool
visible_
;
bool
vertical_
;
bool
vertical_
;
bool
bold_
;
bool
bold_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment