Commit 00f65d5f authored by Aashish Chaudhary's avatar Aashish Chaudhary
Browse files

Screen size affects screen offset as well

Change-Id: Icf427910dd14b2f4f12baecd4194136cb174f034
parent 91edcaf7
......@@ -104,7 +104,7 @@ int TestCubeAxes3( int argc, char * argv [] )
axes2->SetYLabelFormat("%6.1f");
axes2->SetZLabelFormat("%6.1f");
axes2->SetFlyModeToClosestTriad();
axes2->SetScreenSize(25.0);
axes2->SetScreenSize(40.0);
ren2->AddViewProp(axes2.GetPointer());
renWin->Render();
......
......@@ -114,9 +114,9 @@ vtkCubeAxesActor::vtkCubeAxesActor() : vtkActor()
this->ScreenSize = 10.0;
this->LabelScreenOffset = 20.0;
this->LabelScreenOffset = 20.0 + this->ScreenSize * 0.5;
this->TitleScreenOffset =
this->LabelScreenOffset * 2.0 + this->ScreenSize;
this->LabelScreenOffset * 2.0 + this->ScreenSize * 0.5;
// Pass information to axes followers.
this->XAxes[i]->GetTitleActor()->SetAxes(this->XAxes[i],
......@@ -542,6 +542,48 @@ void vtkCubeAxesActor::AdjustAxes(double bounds[6],
}
}
// *************************************************************************
// Screen size affects the screen offset as well.
// *************************************************************************
void vtkCubeAxesActor::SetScreenSize(double screenSize)
{
this->ScreenSize = screenSize;
// Considering pivot point at center of the geometry hence (this->ScreenSize * 0.5).
this->LabelScreenOffset = 20.0 + this->ScreenSize * 0.5;
this->TitleScreenOffset = this->LabelScreenOffset * 2.0 +
this->ScreenSize * 0.5;
for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++)
{
this->XAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
this->YAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
this->ZAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
int numberOfLabelsBuild = this->XAxes[i]->GetNumberOfLabelsBuilt();
vtkAxesFollower **labelActors = this->XAxes[i]->GetLabelActors();
for(int k=0; k < numberOfLabelsBuild; ++k)
{
labelActors[k]->SetScreenOffset(this->LabelScreenOffset);
}
numberOfLabelsBuild = this->YAxes[i]->GetNumberOfLabelsBuilt();
labelActors = this->YAxes[i]->GetLabelActors();
for(int k=0; k < numberOfLabelsBuild; ++k)
{
labelActors[k]->SetScreenOffset(this->LabelScreenOffset);
}
numberOfLabelsBuild = this->ZAxes[i]->GetNumberOfLabelsBuilt();
labelActors = this->ZAxes[i]->GetLabelActors();
for(int k=0; k < numberOfLabelsBuild; ++k)
{
labelActors[k]->SetScreenOffset(this->LabelScreenOffset);
}
}
this->Modified();
}
// Release any graphics resources that are being consumed by this actor.
// The parameter window could be used to determine which graphic
// resources to release.
......
......@@ -109,7 +109,7 @@ public:
// Explicitly specify the screen size of title and label text.
// ScreenSize detemines the size of the text in terms of screen
// pixels. Default is 10.0.
vtkSetMacro(ScreenSize, double);
void SetScreenSize(double screenSize);
vtkGetMacro(ScreenSize, double);
// Description:
......
......@@ -31,9 +31,16 @@ public:
vtkAxisActor *yAxis,
vtkAxisActor *zAxis)
{
if(!xAxis || !yAxis || !zAxis)
{
vtkErrorMacro("One of the axis is invalid or null\n");
return;
}
this->XAxis = xAxis;
this->YAxis = yAxis;
this->ZAxis = zAxis;
this->Modified();
}
//ETX
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment