Go to the documentation of this file.
35 #include "vtkCoordinate.h"
36 #include "vtkRenderer.h"
37 #include "vtkSmartPointer.h"
38 #include "vtkTextActor.h"
39 #include "vtkTextProperty.h"
49 { halignType::LEFT,
"left" },
50 { halignType::CENTER,
"center" },
51 { halignType::CENTER,
"centre" },
52 { halignType::RIGHT,
"right" },
66 string_(
dict.get<
string>(
"string")),
68 size_(
dict.get<scalar>(
"size")),
72 halignTypeNames.getOrDefault(
"halign",
dict, halignType::LEFT)
74 bold_(
dict.get<
bool>(
"bold")),
75 italic_(
dict.getOrDefault(
"italic",
false)),
76 shadow_(
dict.getOrDefault(
"shadow",
false)),
77 timeStamp_(
dict.getOrDefault(
"timeStamp",
false))
79 if (!
dict.readIfPresent(
"positions", positions_))
82 dict.readEntry(
"position", positions_.first());
86 if (positions_.empty())
89 positions_.first() = {0, 0};
94 if (
dict.found(
"colour"))
100 colour_.reset(colours[
"text"]->clone().ptr());
115 const scalar position,
116 vtkRenderer* renderer
128 string str = string_;
134 const vector textColour = colour_->value(position);
136 const scalar textOpacity = opacity(position);
138 for (
const auto& textPosition : positions_)
142 actor->SetInput(str.c_str());
144 vtkTextProperty* prop = actor->GetTextProperty();
146 prop->SetFontFamilyToArial();
147 prop->SetFontSize(size_);
148 prop->SetJustification(
int(halign_));
149 prop->SetVerticalJustificationToBottom();
150 prop->SetBold(bold_);
151 prop->SetItalic(italic_);
152 prop->SetShadow(shadow_);
154 prop->SetColor(textColour[0], textColour[1], textColour[2]);
155 prop->SetOpacity(textOpacity);
159 vtkCoordinate* coord = actor->GetPositionCoordinate();
161 coord->SetCoordinateSystemToNormalizedViewport();
162 coord->SetValue(textPosition.first(), textPosition.second());
165 renderer->AddActor2D(actor);
172 const scalar position
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
static const Enum< halignType > halignTypeNames
Horizontal alignment names (includes "center" and "centre")
static word timeName(const scalar t, const int precision=precision_)
virtual void updateActors(const scalar position)
Update actors.
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Generate images during run-time.
void inplaceExpand(std::string &s, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
text(const text &)=delete
No copy construct.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual ~text()
Destructor.
static bool master(const label communicator=0)
Am I the master process.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
virtual bool clear()
Clear files used to create the object(s) - no-op.
Base class for surface, text handling etc.
#define DebugInfo
Report an information message using Foam::Info.
A HashTable of pointers to objects of type <T>.
halignType
Horizontal alignment type. Values to match VTK definitions.
const Time & time() const
Return the top-level database.
virtual void addGeometryToScene(const scalar position, vtkRenderer *renderer)
Add text to scene.
const runTimePostProcessing & parent_
Reference to the parent function object.
const fvMesh & mesh() const
Reference to the underlying OpenFOAM mesh.