Commit a8b09249 authored by Philippe Pébay's avatar Philippe Pébay
Browse files

Adding LOD ivars and parameters; setting them correctly for cube axes

Change-Id: Icd912bc308af1578bb24e41840f0dd73033556d6
parent bdb471c2
......@@ -46,6 +46,14 @@ vtkCubeAxesActor::vtkCubeAxesActor() : vtkActor()
this->FlyMode = VTK_FLY_CLOSEST_TRIAD;
// By default enable distance based LOD
this->EnableDistanceLOD = 1;
this->DistanceLODThreshold = .8;
// By default enable view angle based LOD
this->EnableViewAngleLOD = 1;
this->ViewAngleLODThreshold = .2;
// Title and label text properties
for (int i = 0; i < 3; i++)
{
......@@ -137,14 +145,29 @@ vtkCubeAxesActor::vtkCubeAxesActor() : vtkActor()
this->LabelScreenOffset * 2.0 + this->ScreenSize * 0.5;
// Pass information to axes followers.
this->XAxes[i]->GetTitleActor()->SetAxis(this->XAxes[i]);
this->XAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
this->YAxes[i]->GetTitleActor()->SetAxis(this->YAxes[i]);
this->YAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
this->ZAxes[i]->GetTitleActor()->SetAxis(this->ZAxes[i]);
this->ZAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
vtkAxisFollower* follower = this->XAxes[i]->GetTitleActor();
follower->SetAxis(this->XAxes[i]);
follower->SetScreenOffset(this->TitleScreenOffset);
follower->SetEnableDistanceLOD( this->EnableDistanceLOD );
follower->SetDistanceLODThreshold( this->DistanceLODThreshold );
follower->SetEnableViewAngleLOD( this->EnableViewAngleLOD );
follower->SetViewAngleLODThreshold( this->ViewAngleLODThreshold );
follower = this->YAxes[i]->GetTitleActor();
follower->SetAxis(this->YAxes[i]);
follower->SetScreenOffset(this->TitleScreenOffset);
follower->SetEnableDistanceLOD( this->EnableDistanceLOD );
follower->SetDistanceLODThreshold( this->DistanceLODThreshold );
follower->SetEnableViewAngleLOD( this->EnableViewAngleLOD );
follower->SetViewAngleLODThreshold( this->ViewAngleLODThreshold );
follower = this->ZAxes[i]->GetTitleActor();
follower->SetAxis(this->ZAxes[i]);
follower->SetScreenOffset(this->TitleScreenOffset);
follower->SetEnableDistanceLOD( this->EnableDistanceLOD );
follower->SetDistanceLODThreshold( this->DistanceLODThreshold );
follower->SetEnableViewAngleLOD( this->EnableViewAngleLOD );
follower->SetViewAngleLODThreshold( this->ViewAngleLODThreshold );
}
this->XTitle = new char[7];
......@@ -779,41 +802,41 @@ void vtkCubeAxesActor::AdjustAxes(double bounds[6],
// *************************************************************************
void vtkCubeAxesActor::SetScreenSize(double screenSize)
{
this->ScreenSize = 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);
this->LabelScreenOffset = 20.0 + this->ScreenSize * 0.5;
this->TitleScreenOffset = this->LabelScreenOffset * 2.0 +
this->ScreenSize * 0.5;
int numberOfLabelsBuild = this->XAxes[i]->GetNumberOfLabelsBuilt();
vtkAxisFollower **labelActors = this->XAxes[i]->GetLabelActors();
for(int k=0; k < numberOfLabelsBuild; ++k)
for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++)
{
labelActors[k]->SetScreenOffset(this->LabelScreenOffset);
}
this->XAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
this->YAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
this->ZAxes[i]->GetTitleActor()->SetScreenOffset(this->TitleScreenOffset);
numberOfLabelsBuild = this->YAxes[i]->GetNumberOfLabelsBuilt();
labelActors = this->YAxes[i]->GetLabelActors();
for(int k=0; k < numberOfLabelsBuild; ++k)
{
labelActors[k]->SetScreenOffset(this->LabelScreenOffset);
}
int numberOfLabelsBuild = this->XAxes[i]->GetNumberOfLabelsBuilt();
vtkAxisFollower **labelActors = this->XAxes[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);
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();
this->Modified();
}
// *************************************************************************
......@@ -917,6 +940,14 @@ void vtkCubeAxesActor::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "Fly Mode: OUTER_EDGES\n";
}
os << indent << "EnableDistanceLOD: "
<< ( this->EnableDistanceLOD ? "On" : "Off" ) << endl;
os << indent << "DistanceLODThreshold: " << this->DistanceLODThreshold << "\n";
os << indent << "EnableViewAngleLOD: "
<< ( this->EnableViewAngleLOD ? "On" : "Off" ) << endl;
os << indent << "ViewAngleLODThreshold: " << this->ViewAngleLODThreshold << "\n";
os << indent << "X Axis Title: " << this->XTitle << "\n";
os << indent << "Y Axis Title: " << this->YTitle << "\n";
os << indent << "Z Axis Title: " << this->ZTitle << "\n";
......@@ -2419,6 +2450,10 @@ void vtkCubeAxesActor::UpdateLabels(vtkAxisActor **axis, int index)
}
labelActors[k]->SetScreenOffset(this->LabelScreenOffset);
labelActors[k]->SetEnableDistanceLOD( this->EnableDistanceLOD );
labelActors[k]->SetDistanceLODThreshold( this->DistanceLODThreshold );
labelActors[k]->SetEnableViewAngleLOD( this->EnableViewAngleLOD );
labelActors[k]->SetViewAngleLODThreshold( this->ViewAngleLODThreshold );
}
}
}
......
......@@ -198,6 +198,26 @@ public:
// resources to release.
void ReleaseGraphicsResources(vtkWindow *);
// Description:
// Enable and disable the use of distance based LOD for titles and labels.
vtkSetMacro( EnableDistanceLOD, int );
vtkGetMacro( EnableDistanceLOD, int );
// Description:a
// Set distance LOD threshold [0.0 - 1.0] for titles and labels.
vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 );
vtkGetMacro( DistanceLODThreshold, double);
// Description:
// Enable and disable the use of view angle based LOD for titles and labels.
vtkSetMacro( EnableViewAngleLOD, int );
vtkGetMacro( EnableViewAngleLOD, int );
// Description:
// Set view angle LOD threshold [0.0 - 1.0] for titles and labels.
vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. );
vtkGetMacro( ViewAngleLODThreshold, double );
// Description:
// Turn on and off the visibility of each axis.
vtkSetMacro(XAxisVisibility,int);
......@@ -375,6 +395,26 @@ protected:
int FlyMode;
// Description:
// If enabled the actor will not be visible at a certain distance from the camera.
// Default is true
int EnableDistanceLOD;
// Description:
// Default is 0.80
// This determines at what fraction of camera far clip range, actor is not visible.
double DistanceLODThreshold;
// Description:
// If enabled the actor will not be visible at a certain view angle.
// Default is true.
int EnableViewAngleLOD;
// Description:
// This determines at what view angle to geometry will make the geometry not visibile.
// Default is 0.3.
double ViewAngleLODThreshold;
// Description:
// Control variables for all axes
// NB: [0] always for 'Major' axis during non-static fly modes.
......
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