Skip to content
Snippets Groups Projects
Commit 9b14a948 authored by Prashant Sonakar's avatar Prashant Sonakar
Browse files

Fixes #99 #127 #128 #138

parent 15192e73
Branches
Tags
No related merge requests found
......@@ -177,14 +177,20 @@ void Foam::runTimePostProcessing::write()
surfaces_[i].addGeometryToScene(0, renderer);
}
// Add the text
forAll(text_, i)
{
text_[i].addGeometryToScene(0, renderer);
}
while (scene_.loop(renderer))
{
scalar position = scene_.position();
// Add the text
// Update the text
forAll(text_, i)
{
text_[i].addGeometryToScene(position, renderer);
text_[i].updateActors(position);
}
// Update the points
......
......@@ -67,14 +67,18 @@ void Foam::scene::readCamera(const dictionary& dict)
}
}
if (dict.readIfPresent("startPosition", position_))
if (dict.readIfPresent("startPosition", startPosition_))
{
if ((position_ < 0) || (position_ > 1))
if ((startPosition_ < 0) || (startPosition_ > 1))
{
FatalIOErrorInFunction(dict)
<< "startPosition must be in the range 0-1"
<< exit(FatalIOError);
}
else
{
position_ = startPosition_;
}
}
......@@ -89,7 +93,7 @@ void Foam::scene::readCamera(const dictionary& dict)
<< "endPosition must be in the range 0-1"
<< exit(FatalIOError);
}
dPosition_ = (endPosition - position_)/scalar(nFrameTotal_ - 1);
dPosition_ = (endPosition - startPosition_)/scalar(nFrameTotal_ - 1);
}
mode_ = modeTypeNames_.read(dict.lookup("mode"));
......@@ -111,12 +115,6 @@ void Foam::scene::readCamera(const dictionary& dict)
);
const vector up(coeffs.lookup("up"));
cameraUp_.reset(new Constant<point>("up", up));
if (nFrameTotal_ > 1)
{
WarningInFunction
<< "Static mode with nFrames > 1 - please check your setup"
<< endl;
}
break;
}
case mtFlightPath:
......@@ -296,6 +294,7 @@ Foam::scene::scene(const objectRegistry& obr, const word& name)
clipBox_(),
parallelProjection_(true),
nFrameTotal_(1),
startPosition_(0),
position_(0),
dPosition_(0),
currentFrameI_(0),
......@@ -354,14 +353,15 @@ bool Foam::scene::loop(vtkRenderer* renderer)
currentFrameI_++;
if (position_ > (1 + 0.5*dPosition_))
// Warning only if camera is in flight mode
if ((mode_ == mtFlightPath) && (position_ > (1 + 0.5*dPosition_)))
{
WarningInFunction
<< "Current position exceeded 1 - please check your setup"
<< "Current position "<< position_ <<" exceeded 1 - please check your setup"
<< endl;
}
position_ += dPosition_;
position_ = startPosition_ + currentFrameI_*dPosition_;
if (currentFrameI_ < nFrameTotal_)
{
......
......@@ -134,6 +134,9 @@ protected:
//- Number of frames
label nFrameTotal_;
//- startPosition [0-1]
scalar startPosition_;
//- Position [0-1]
scalar position_;
......
......@@ -47,7 +47,8 @@ Foam::text::text
position_(dict.lookup("position")),
size_(readScalar(dict.lookup("size"))),
colour_(NULL),
bold_(readBool(dict.lookup("bold")))
bold_(readBool(dict.lookup("bold"))),
timeStamp_(dict.lookupOrDefault<bool>("timeStamp", false))
{
if (dict.found("colour"))
{
......@@ -81,7 +82,13 @@ void Foam::text::addGeometryToScene
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
actor->SetInput(string_.c_str());
// Concatenate string with timeStamp if true
string textAndTime = string_;
if (timeStamp_)
{
textAndTime = textAndTime + " " + geometryBase::parent_.obr().time().timeName();
}
actor->SetInput(textAndTime.c_str());
actor->GetTextProperty()->SetFontFamilyToArial();
actor->GetTextProperty()->SetFontSize(size_);
actor->GetTextProperty()->SetJustificationToLeft();
......
......@@ -25,6 +25,23 @@ Class
Foam::text
Description
Example of text object specification:
\verbatim
text1
{
string "text to display";
position (0.1 0.05);
size 18;
bold yes;
visible yes;
// Optionally override default colour
// colour (0 1 1);
// Optional entry
timeStamp yes; //Append solution time to string
}
\endverbatim
SourceFiles
text.C
......@@ -82,6 +99,9 @@ protected:
//- Bold flag
bool bold_;
//- Time stamp flag
bool timeStamp_;
public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment