Commit 4383a49e authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

BUG #13466. Adding support for UserTranform on representations.

Added a mechanism to specify a 4x4 matrix as the UserTranform for a geometry
representation. Python scripts can now set the UserTranform (results in calling
vtkActor::SetUserTransform()), using the UserTranform property which is expected
to be a 16 element double corresponding to the 4x4 matrix.

Along with vtkGeometryRepresentation, updating vtkSelectionRepresentation and
vtkDataLabelRepresentation to accept UserTransform so that selections and labels
on selections show up correctly when a UserTransform set on the
vtkGeometryRepresentation.
parent 5f490998
......@@ -22,6 +22,7 @@
#include "vtkInformationVector.h"
#include "vtkLabeledDataMapper.h"
#include "vtkMPIMoveData.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPVCacheKeeper.h"
#include "vtkPVRenderView.h"
......@@ -406,3 +407,12 @@ void vtkDataLabelRepresentation::SetScale(double x, double y, double z)
this->TransformHelperProp->SetScale(x, y, z);
this->UpdateTransform();
}
//----------------------------------------------------------------------------
void vtkDataLabelRepresentation::SetUserTransform(const double matrix[16])
{
vtkNew<vtkTransform> transform;
transform->SetMatrix(matrix);
this->TransformHelperProp->SetUserTransform(transform.GetPointer());
this->UpdateTransform();
}
......@@ -91,6 +91,7 @@ public:
void SetOrigin(double, double, double);
void SetPosition(double, double, double);
void SetScale(double, double, double);
void SetUserTransform(const double[16]);
// Description:
// vtkAlgorithm::ProcessRequest() equivalent for rendering passes. This is
......
......@@ -19,6 +19,7 @@
#include "vtkCommand.h"
#include "vtkCompositeDataIterator.h"
#include "vtkCompositePolyDataMapper2.h"
#include "vtkHardwareSelectionPolyDataPainter.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkMath.h"
......@@ -42,8 +43,8 @@
#include "vtkSelectionNode.h"
#include "vtkShadowMapBakerPass.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkTransform.h"
#include "vtkUnstructuredGrid.h"
#include "vtkHardwareSelectionPolyDataPainter.h"
#include <vtksys/SystemTools.hxx>
......@@ -735,6 +736,14 @@ void vtkGeometryRepresentation::SetScale(double x, double y, double z)
this->Actor->SetScale(x, y, z);
}
//----------------------------------------------------------------------------
void vtkGeometryRepresentation::SetUserTransform(const double matrix[16])
{
vtkNew<vtkTransform> transform;
transform->SetMatrix(matrix);
this->Actor->SetUserTransform(transform.GetPointer());
}
//----------------------------------------------------------------------------
void vtkGeometryRepresentation::SetTexture(vtkTexture* val)
{
......
......@@ -161,6 +161,7 @@ public:
virtual void SetPosition(double, double, double);
virtual void SetScale(double, double, double);
virtual void SetTexture(vtkTexture*);
virtual void SetUserTransform(const double[16]);
//***************************************************************************
// Forwarded to Mapper and LODMapper.
......
......@@ -268,6 +268,13 @@ void vtkSelectionRepresentation::SetScale(double x, double y, double z)
this->LabelRepresentation->SetScale(x, y, z);
}
//----------------------------------------------------------------------------
void vtkSelectionRepresentation::SetUserTransform(const double matrix[16])
{
this->GeometryRepresentation->SetUserTransform(matrix);
this->LabelRepresentation->SetUserTransform(matrix);
}
//----------------------------------------------------------------------------
void vtkSelectionRepresentation::SetPointFieldDataArrayName(const char* val)
{
......
......@@ -86,6 +86,7 @@ public:
void SetOrigin(double, double, double);
void SetPosition(double, double, double);
void SetScale(double, double, double);
void SetUserTransform(const double[16]);
// Description:
// Forwarded to vtkDataLabelRepresentation.
......
......@@ -119,6 +119,7 @@ ENDIF ()
SET (PVBATCH_TESTS
Simple
UserTransformOnRepresentation
ParallelImageWriter
ParallelSerialWriter
)
......
# Tests support for UserTransform on representations.
# There's no UI to set UserTransform and only mechanism is to use Python.
import SMPythonTesting
from paraview.simple import *
SMPythonTesting.ProcessCommandLineArguments()
data = Sphere()
display = Show()
transform = servermanager.vtk.vtkTransform()
transform.Scale(2, 1, 1)
matrix = transform.GetMatrix()
print "-------------------------------"
print "Transformation Matrix: "
print matrix
flattened_trasform = []
for j in range(4):
for i in range(4):
flattened_trasform.append(matrix.GetElement(i, j))
display.UserTransform = flattened_trasform
view = Render()
if not SMPythonTesting.DoRegressionTesting(view.SMProxy):
raise SMPythonTesting.TestError, 'Test failed.'
......@@ -1159,6 +1159,8 @@
panel_visibility="advanced" />
<Property name="NonlinearSubdivisionLevel"
panel_visibility="advanced" />
<Property name="UserTransform"
panel_visibility="never" />
</ExposedProperties>
</SubProxy>
<SubProxy>
......@@ -2594,6 +2596,22 @@
number_of_elements="3">
<DoubleRangeDomain name="range" />
</DoubleVectorProperty>
<DoubleVectorProperty argument_is_array="1"
command="SetUserTransform"
default_values="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"
name="UserTransform"
number_of_elements="16">
<Documentation>
In addition to the instance variables such as position and
orientation, you can add an additional transformation for your own
use. This transformation is concatenated with the actor's internal
transformation, which you implicitly create through the use of
Position, Origin, Orientation. The value is 4x4 matrix for the linear
tranform to use.
</Documentation>
</DoubleVectorProperty>
<IntVectorProperty command="SetPickable"
default_values="1"
name="Pickable"
......@@ -3490,6 +3508,22 @@
number_of_elements="3">
<DoubleRangeDomain name="range" />
</DoubleVectorProperty>
<DoubleVectorProperty argument_is_array="1"
command="SetUserTransform"
default_values="1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"
name="UserTransform"
number_of_elements="16">
<Documentation>
In addition to the instance variables such as position and
orientation, you can add an additional transformation for your own
use. This transformation is concatenated with the actor's internal
transformation, which you implicitly create through the use of
Position, Origin, Orientation. The value is 4x4 matrix for the linear
tranform to use.
</Documentation>
</DoubleVectorProperty>
<SubProxy>
<Proxy name="LabelRepresentation"
proxygroup="representations"
......
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