diff --git a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.H b/src/functionObjects/graphics/runTimePostProcessing/geometryBase.H index 24ac7026f54789c4c402974064aa331ed9da305b..9badcb09c3cdd226002ad269f85a642f65e6fee5 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/geometryBase.H +++ b/src/functionObjects/graphics/runTimePostProcessing/geometryBase.H @@ -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 diff --git a/src/functionObjects/graphics/runTimePostProcessing/text.C b/src/functionObjects/graphics/runTimePostProcessing/text.C index 8c57916f5a3a9e2b63bb06967cc9947a913cc913..bc083420a97ed7a1e20549195a336549958512ca 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/text.C +++ b/src/functionObjects/graphics/runTimePostProcessing/text.C @@ -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 ( diff --git a/src/functionObjects/graphics/runTimePostProcessing/text.H b/src/functionObjects/graphics/runTimePostProcessing/text.H index fd8835db52eb3a137b644c2ed157a63944135517..5e5e12a9591e44ee5240e130977f820f70b0d5a4 100644 --- a/src/functionObjects/graphics/runTimePostProcessing/text.H +++ b/src/functionObjects/graphics/runTimePostProcessing/text.H @@ -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_; diff --git a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/decomposeParDict b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..19b066617b970eee5d103150206b3083e2d6e4f5 --- /dev/null +++ b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/decomposeParDict @@ -0,0 +1,28 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1806 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 8; + +method simple; + +coeffs +{ + n (4 2 1); +} + + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/runTimePostProcessing b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/runTimePostProcessing index 47fd9e977abc46fea0267530f2bb2094e8475c0e..8094b1ba5d497cc5fc67c87abe4b88a66983d397 100644 --- a/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/runTimePostProcessing +++ b/tutorials/incompressible/pimpleFoam/RAS/elipsekkLOmega/system/runTimePostProcessing @@ -131,9 +131,13 @@ postPro1 text1 { string "ellipse kkLOmega"; - position (0.6 0.05); + position (0.5 0.15); + halign centre; size 18; + opacity 0.4; bold yes; + italic yes; + shadow yes; visible yes; } }