From 090649639c1d312f1fd90b0cd19920ca0ec21886 Mon Sep 17 00:00:00 2001 From: rnv Date: Mon, 13 Jul 2020 14:45:26 +0300 Subject: [PATCH] Fix for '#17888 [CEA 17919] VTK Viewer - Scaling'. --- src/OBJECT/GEOM_Actor.cxx | 16 +++++++++++++ src/OBJECT/GEOM_Actor.h | 5 ++++ src/OBJECT/GEOM_DeviceActor.cxx | 41 ++++++++++++++++++++++----------- src/OBJECT/GEOM_DeviceActor.h | 8 ++++++- 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/src/OBJECT/GEOM_Actor.cxx b/src/OBJECT/GEOM_Actor.cxx index ce8b852a4..1b782df45 100644 --- a/src/OBJECT/GEOM_Actor.cxx +++ b/src/OBJECT/GEOM_Actor.cxx @@ -1166,3 +1166,19 @@ void GEOM_Actor::SetWidth(const int width) { int GEOM_Actor::GetWidth() const { return (int)myIsolatedEdgeActor->GetProperty()->GetLineWidth(); } + +void GEOM_Actor::SetTransform(VTKViewer_Transform* theTransform) +{ + Superclass::SetTransform(theTransform); + + myStandaloneVertexActor->SetTransform(theTransform); + myStandaloneVertexActor->SetTransform(theTransform); + myIsolatedEdgeActor->SetTransform(theTransform); + myOneFaceEdgeActor->SetTransform(theTransform); + mySharedEdgeActor->SetTransform(theTransform); + myWireframeFaceActor->SetTransform(theTransform); + myShadingFaceActor->SetTransform(theTransform); + myHighlightActor->SetTransform(theTransform); + + Modified(); +} diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h index 48ec07bb5..810483a45 100644 --- a/src/OBJECT/GEOM_Actor.h +++ b/src/OBJECT/GEOM_Actor.h @@ -222,6 +222,11 @@ public: bool GetNameMode(); + virtual + void + SetTransform(VTKViewer_Transform* theTransform); + + protected: void SetModified(); diff --git a/src/OBJECT/GEOM_DeviceActor.cxx b/src/OBJECT/GEOM_DeviceActor.cxx index b23eb04bc..72a65ae5d 100644 --- a/src/OBJECT/GEOM_DeviceActor.cxx +++ b/src/OBJECT/GEOM_DeviceActor.cxx @@ -26,20 +26,26 @@ #include #include #include -#include -#include +#include #include + +#include +#include +#include + vtkStandardNewMacro(GEOM_DeviceActor); -GEOM_DeviceActor::GEOM_DeviceActor(): - myStripper(vtkStripper::New(),true), - myPolyDataMapper(vtkPolyDataMapper::New(),true), - myPolyDataNormals(vtkPolyDataNormals::New(),true), - myActor(VTKViewer_Actor::New(),true) +GEOM_DeviceActor::GEOM_DeviceActor() : + myStripper(vtkStripper::New(), true), + myPolyDataMapper(vtkPolyDataMapper::New(), true), + myPolyDataNormals(vtkPolyDataNormals::New(), true), + myActor(VTKViewer_Actor::New(), true), + myTransformFilter(VTKViewer_TransformFilter::New()) { - myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort()); - myPolyDataMapper->SetInputConnection(myStripper->GetOutputPort()); + myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort()); + myTransformFilter->SetInputConnection(myStripper->GetOutputPort()); + myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort()); myActor->SetMapper(myPolyDataMapper.Get()); myActor->PickableOff(); @@ -56,11 +62,13 @@ SetInput(vtkAlgorithmOutput* thePolyData, bool theUseStripper) if(theUseStripper) { myPolyDataNormals->SetInputConnection(thePolyData); - myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort()); - myPolyDataMapper->SetInputConnection(myStripper->GetOutputPort()); + myStripper->SetInputConnection(myPolyDataNormals->GetOutputPort()); + myTransformFilter->SetInputConnection(myStripper->GetOutputPort()); + myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort()); } - else - myPolyDataMapper->SetInputConnection(thePolyData); + else + myTransformFilter->SetInputConnection(thePolyData); + myPolyDataMapper->SetInputConnection(myTransformFilter->GetOutputPort()); } void @@ -118,3 +126,10 @@ RemoveFromRender(vtkRenderer* theRenderer) { theRenderer->RemoveActor(myActor.GetPointer()); } + +void +GEOM_DeviceActor +::SetTransform(VTKViewer_Transform* theTransform) +{ + myTransformFilter->SetTransform(theTransform); +} diff --git a/src/OBJECT/GEOM_DeviceActor.h b/src/OBJECT/GEOM_DeviceActor.h index a5562421a..6d576c825 100644 --- a/src/OBJECT/GEOM_DeviceActor.h +++ b/src/OBJECT/GEOM_DeviceActor.h @@ -36,7 +36,10 @@ typedef GEOM_SmartPtr PPolyDataNormals; //class vtkActor; class VTKViewer_Actor; +class VTKViewer_Transform; +class VTKViewer_TransformFilter; typedef GEOM_SmartPtr PActor; +typedef GEOM_SmartPtr PTransformFilter; class vtkProperty; class vtkRenderer; @@ -66,12 +69,15 @@ public: void RemoveFromRender(vtkRenderer* theRenderer); PActor GetDeviceActor() {return myActor;} + + virtual void SetTransform(VTKViewer_Transform* theTransform); protected: PPolyDataNormals myPolyDataNormals; PPolyDataMapper myPolyDataMapper; PStripper myStripper; - PActor myActor; + PActor myActor; + PTransformFilter myTransformFilter; GEOM_DeviceActor(); ~GEOM_DeviceActor();