Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
a2906d43
Commit
a2906d43
authored
Jun 05, 2019
by
Mark OLESEN
Committed by
Andrew Heather
Jun 05, 2019
Browse files
ENH: improve handling of font sizes for scalarBar
parent
4c257552
Changes
5
Hide whitespace changes
Inline
Side-by-side
etc/caseDicts/annotated/runTimePostProcessingDict
View file @
a2906d43
...
...
@@ -173,8 +173,8 @@ surfaces
visible no;
position (0.8 0.1);
vertical yes;
fontSize
16;
titleSize
18;
//
fontSize
0; // automatic sizing
//
titleSize
0; // automatic sizing
title "velocity [m/s]";
labelFormat "%6.2f";
numberOfLabels 5;
...
...
etc/caseDicts/postProcessing/visualization/runTimePostPro.cfg
View file @
a2906d43
...
...
@@ -80,7 +80,7 @@ scalarBar
vertical true;
position (0.8 0.1);
size (0.1 0.75);
fontSize
16;
fontSize
0; // auto
labelFormat "%f";
numberOfLabels 5;
bold yes;
...
...
@@ -94,7 +94,7 @@ scalarBar
vertical false;
position (0.2 0.1);
size (0.6 0.1);
fontSize
16;
fontSize
0; // auto
labelFormat "%f";
numberOfLabels 5;
bold yes;
...
...
src/functionObjects/graphics/runTimePostProcessing/scalarBar.C
View file @
a2906d43
...
...
@@ -57,8 +57,8 @@ void Foam::functionObjects::runTimePostPro::scalarBar::clear()
position_
=
{
0
.
8
,
0
.
1
};
size_
=
{
0
.
1
,
0
.
5
};
title_
=
""
;
fontSize_
=
12
;
titleSize_
=
0
;
// 0 == Auto-sizing (
f
actor
3
)
fontSize_
=
0
;
// 0 == Auto-sizing (defaultFontSize)
titleSize_
=
0
;
// 0 == Auto-sizing (
defaultTitleSizeF
actor)
nLabels_
=
5
;
labelFormat_
=
"%f"
;
}
...
...
@@ -121,6 +121,8 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
return
false
;
}
const
label
fontSizeValue
=
(
fontSize_
?
fontSize_
:
defaultFontSize
);
auto
sbar
=
vtkSmartPointer
<
vtkScalarBarActor
>::
New
();
sbar
->
SetLookupTable
(
lut
);
sbar
->
SetNumberOfLabels
(
nLabels_
);
...
...
@@ -139,6 +141,8 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
if
(
titleHack_
)
{
// Place the scalar bar title ourselves
sbar
->
SetUnconstrainedFontSize
(
true
);
titleActor
=
vtkSmartPointer
<
vtkTextActor
>::
New
();
titleActor
->
SetInput
(
title_
.
c_str
());
...
...
@@ -148,6 +152,7 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
else
{
// Use the standard scalar bar title
sbar
->
SetUnconstrainedFontSize
(
fontSize_
!=
0
);
sbar
->
SetTitle
(
title_
.
c_str
());
titleProp
=
sbar
->
GetTitleTextProperty
();
}
...
...
@@ -163,11 +168,11 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
}
else
{
// Auto
= Factor 3 of fontSize
titleProp
->
SetFontSize
(
3
*
fontSize
_
);
// Auto
titleProp
->
SetFontSize
(
defaultTitleSizeFactor
*
fontSize
Value
);
// Or this??
// if (!titleHack_) titleProp->SetFontSize(fontSize
_
);
// if (!titleHack_) titleProp->SetFontSize(fontSize
Value
);
}
titleProp
->
SetJustificationToCentered
();
...
...
@@ -178,14 +183,16 @@ bool Foam::functionObjects::runTimePostPro::scalarBar::add
titleProp
->
SetColor
(
textColour
[
0
],
textColour
[
1
],
textColour
[
2
]);
auto
labProp
=
sbar
->
GetLabelTextProperty
();
labProp
->
SetColor
(
textColour
[
0
],
textColour
[
1
],
textColour
[
2
]);
labProp
->
SetFontSize
(
fontSize_
);
if
(
titleHack_
||
fontSize_
)
{
labProp
->
SetFontSize
(
fontSizeValue
);
}
labProp
->
ShadowOff
();
labProp
->
BoldOff
();
labProp
->
BoldOff
();
// or: labProp->SetBold(bold_);
labProp
->
ItalicOff
();
// Positioning
...
...
src/functionObjects/graphics/runTimePostProcessing/scalarBar.H
View file @
a2906d43
...
...
@@ -35,7 +35,7 @@ Description
position | Viewport position (x y) of scalar bar | yes |
vertical | Vertical scalar bar | no | true
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
labelFormat | Label format string (eg, "%f") | no | "%f"
numberOfLabels | Total number of labels | no | 5
...
...
@@ -45,6 +45,19 @@ Description
titleHack | Alternative placement strategy | no | yes
\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
scalarBar.C
...
...
@@ -77,6 +90,12 @@ namespace runTimePostPro
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
vertical_
;
bool
bold_
;
...
...
tutorials/incompressible/simpleFoam/windAroundBuildings/system/runTimePostProcessing
View file @
a2906d43
...
...
@@ -112,11 +112,11 @@ postPro1
visible yes;
vertical false;
titleHack false;
position (0.
8
0);
size (0.2 0.1);
position (0.
75
0);
size (0.2
2
0.1);
fontSize
8
;
titleSize
24
;
//
fontSize
0
;
//
titleSize
0
;
title "velocity [m/s]";
labelFormat "%.0f";
numberOfLabels 5;
...
...
Write
Preview
Supports
Markdown
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