Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Modules
Visualization
Commits
85cfbd8b
Commit
85cfbd8b
authored
Dec 16, 2018
by
Mark Olesen
Browse files
ENH: support text shadow, italic, opacity in runTimePostProcessing
parent
4d15bc6e
Pipeline
#139
failed with stages
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/runTimePostProcessing/geometryBase.H
View file @
85cfbd8b
...
...
@@ -25,7 +25,15 @@ Class
Foam::functionObjects::runTimePostPro::geometryBase
Description
Base class for surface handling
Base class for surface, text handling
Dictionary controls
\table
Property | Description | Required | Default
visible | Display the object | yes |
renderMode | Shading (flat/gouraud/phong) | no | gouraud
opacity | Object opacity | no | 1.0
\endtable
SourceFiles
geometryBase.C
...
...
src/runTimePostProcessing/text.C
View file @
85cfbd8b
...
...
@@ -34,6 +34,21 @@ License
#include "vtkTextActor.h"
#include "vtkTextProperty.h"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
const
Foam
::
Enum
<
Foam
::
functionObjects
::
runTimePostPro
::
text
::
halignType
>
Foam
::
functionObjects
::
runTimePostPro
::
text
::
halignTypeNames
({
{
halignType
::
LEFT
,
"left"
},
{
halignType
::
CENTER
,
"center"
},
{
halignType
::
CENTER
,
"centre"
},
{
halignType
::
RIGHT
,
"right"
},
});
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam
::
functionObjects
::
runTimePostPro
::
text
::
text
...
...
@@ -48,7 +63,13 @@ Foam::functionObjects::runTimePostPro::text::text
position_
(),
size_
(
dict
.
get
<
scalar
>
(
"size"
)),
colour_
(
nullptr
),
halign_
(
halignTypeNames
.
lookupOrDefault
(
"halign"
,
dict
,
halignType
::
LEFT
)
),
bold_
(
dict
.
get
<
bool
>
(
"bold"
)),
italic_
(
dict
.
lookupOrDefault
(
"italic"
,
false
)),
shadow_
(
dict
.
lookupOrDefault
(
"shadow"
,
false
)),
timeStamp_
(
dict
.
lookupOrDefault
(
"timeStamp"
,
false
))
{
dict
.
readEntry
(
"position"
,
position_
);
...
...
@@ -86,21 +107,28 @@ void Foam::functionObjects::runTimePostPro::text::addGeometryToScene
auto
actor
=
vtkSmartPointer
<
vtkTextActor
>::
New
();
// Concatenate string with timeStamp if true
string
textAndTime
=
string_
;
string
str
=
string_
;
if
(
timeStamp_
)
{
textAndTime
=
textAndTime
+
" "
+
geometryBase
::
parent_
.
mesh
().
time
().
timeName
();
str
+=
" "
+
geometryBase
::
parent_
.
mesh
().
time
().
timeName
();
}
actor
->
SetInput
(
textAndTime
.
c_str
());
actor
->
GetTextProperty
()
->
SetFontFamilyToArial
();
actor
->
GetTextProperty
()
->
SetFontSize
(
size_
);
actor
->
GetTextProperty
()
->
SetJustificationToLeft
();
actor
->
GetTextProperty
()
->
SetVerticalJustificationToBottom
();
actor
->
GetTextProperty
()
->
SetBold
(
bold_
);
actor
->
SetInput
(
str
.
c_str
());
vtkTextProperty
*
prop
=
actor
->
GetTextProperty
();
prop
->
SetFontFamilyToArial
();
prop
->
SetFontSize
(
size_
);
prop
->
SetJustification
(
int
(
halign_
));
prop
->
SetVerticalJustificationToBottom
();
prop
->
SetBold
(
bold_
);
prop
->
SetItalic
(
italic_
);
prop
->
SetShadow
(
shadow_
);
const
vector
colour
=
colour_
->
value
(
position
);
actor
->
GetTextProperty
()
->
SetColor
(
colour
[
0
],
colour
[
1
],
colour
[
2
]);
prop
->
SetColor
(
colour
[
0
],
colour
[
1
],
colour
[
2
]);
prop
->
SetOpacity
(
opacity
(
position
));
actor
->
GetPositionCoordinate
()
->
SetCoordinateSystemToNormalizedViewport
();
actor
->
GetPositionCoordinate
()
->
SetValue
(
...
...
src/runTimePostProcessing/text.H
View file @
85cfbd8b
...
...
@@ -34,7 +34,11 @@ Description
string "text to display";
position (0.1 0.05);
size 18;
// halign left; // (left | centre | right)
bold yes;
// Optional entry
shadow false;
visible yes;
// Optionally override default colour
...
...
@@ -48,15 +52,24 @@ Description
Dictionary controls
\table
Property | Description | Required | Default
visible | Display the text | yes |
string | Text to display | yes |
position | The (x y) viewport position | yes |
size | The font size in points | yes |
halign | Text justification (left/centre/ right) | no | left
bold | Use bold font | yes |
italic | Use italic font | no | false
shadow | Add text shadow | no | false
colour | Override default text colour | no |
timeStamp | Append solution timeName to string | no | false
\endtable
Inherited controls
\table
Property | Description | Required | Default
visible | Display the object | yes |
opacity | Object opacity | no | 1.0
\endtable
SourceFiles
text.C
...
...
@@ -88,6 +101,22 @@ class text
:
public
geometryBase
{
public:
// Public enumerations
//- Horizontal alignment type
enum
halignType
{
LEFT
=
0
,
//!< Left-justified text - default ("left")
CENTER
=
1
,
//!< Centred text ("center", "centre")
RIGHT
=
2
//!< Right-justified text ("right")
};
//- Horizontal alignment names (includes "center" and "centre")
static
const
Enum
<
halignType
>
halignTypeNames
;
protected:
// Protected Data
...
...
@@ -104,9 +133,18 @@ protected:
//- Colour
autoPtr
<
Function1
<
vector
>>
colour_
;
//- Horizontal alignment
halignType
halign_
;
//- Bold flag
bool
bold_
;
//- Italic flag
bool
italic_
;
//- Shadow flag
bool
shadow_
;
//- Time stamp flag
bool
timeStamp_
;
...
...
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