Commit ddc3a06f authored by Karthik Krishnan's avatar Karthik Krishnan
Browse files

ENH: Method to get the world label position, so as serialize the widget.

parent b2f02296
......@@ -34,7 +34,7 @@
#include <vtksys/ios/sstream>
vtkCxxRevisionMacro(vtkBiDimensionalRepresentation2D, "1.23");
vtkCxxRevisionMacro(vtkBiDimensionalRepresentation2D, "1.24");
vtkStandardNewMacro(vtkBiDimensionalRepresentation2D);
......@@ -956,6 +956,22 @@ void vtkBiDimensionalRepresentation2D::GetLabelPosition(double pos[3])
this->TextActor->GetPositionCoordinate()->GetValue(pos);
}
//----------------------------------------------------------------------
void vtkBiDimensionalRepresentation2D::GetWorldLabelPosition(double pos[3])
{
double viewportPos[3], worldPos[4];
this->TextActor->GetPositionCoordinate()->GetValue(viewportPos);
this->Renderer->ViewportToNormalizedViewport(viewportPos[0], viewportPos[1]);
this->Renderer->NormalizedViewportToView(viewportPos[0], viewportPos[1], viewportPos[2]);
this->Renderer->SetViewPoint(viewportPos);
this->Renderer->ViewToWorld();
this->Renderer->GetWorldPoint(worldPos);
pos[0] = worldPos[0]/worldPos[3];
pos[1] = worldPos[1]/worldPos[3];
pos[2] = worldPos[2]/worldPos[3];
}
//----------------------------------------------------------------------
double vtkBiDimensionalRepresentation2D::GetLength1()
{
......
......@@ -194,6 +194,7 @@ public:
// Get the position of the widget's label in display coordinates.
double* GetLabelPosition();
void GetLabelPosition(double pos[3]);
void GetWorldLabelPosition(double pos[3]);
protected:
vtkBiDimensionalRepresentation2D();
......
Markdown is supported
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