]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fix for Bug GVIEW10260
authorapo <apo@opencascade.com>
Thu, 19 Jan 2006 08:19:02 +0000 (08:19 +0000)
committerapo <apo@opencascade.com>
Thu, 19 Jan 2006 08:19:02 +0000 (08:19 +0000)
   Scaling is applied incorrectly on selection box

src/OBJECT/VISU_Actor.cxx
src/OBJECT/VISU_VectorsAct.cxx
src/OBJECT/VISU_VectorsAct.h
src/PIPELINE/VISU_PipeLine.cxx
src/PIPELINE/VISU_PipeLine.hxx
src/PIPELINE/VISU_PipeLineUtils.hxx
src/PIPELINE/VISU_VectorsPL.cxx
src/PIPELINE/VISU_VectorsPL.hxx

index 2004b9c280e78743f41e50b73da8cd968d9468af..90e3009f12aa22ebe0801b711da8352c92b6b8c8 100644 (file)
@@ -412,7 +412,7 @@ VISU_Actor
   if(myIsVTKMapping)
     return Superclass::GetInput();
 
-  return GetCurrentPL()->GetMapper()->GetInput();
+  return GetCurrentPL()->GetOutput();
 }
 
 //----------------------------------------------------------------------------
index 143350d8b1626f7a10c1688a1114286f69ec0099..e568a9d419874d49ab4196aea539971945346946 100644 (file)
 #include <vtkPolyDataMapper.h>
 #include <vtkPolyData.h>
 
-using namespace std;
-
-//=======================================================================
 
+//----------------------------------------------------------------------------
 vtkStandardNewMacro(VISU_VectorsAct);
 
 
-VISU_VectorsAct::VISU_VectorsAct(){}
+//----------------------------------------------------------------------------
+VISU_VectorsAct
+::VISU_VectorsAct():
+  myVectorsPL(NULL)
+{}
 
 
-VISU_VectorsAct::~VISU_VectorsAct(){}
+//----------------------------------------------------------------------------
+VISU_VectorsAct
+::~VISU_VectorsAct()
+{}
 
 
-void VISU_VectorsAct::SetPipeLine(VISU_PipeLine* thePipeLine) {
-  myPipeLine = dynamic_cast<VISU_VectorsPL*>(thePipeLine);
-  VISU_Actor::SetPipeLine(myPipeLine);
-  myPipeLine->Delete();
+//----------------------------------------------------------------------------
+void 
+VISU_VectorsAct
+::SetPipeLine(VISU_PipeLine* thePipeLine) 
+{
+  myVectorsPL = dynamic_cast<VISU_VectorsPL*>(thePipeLine);
+  VISU_Actor::SetPipeLine(myVectorsPL);
+  myVectorsPL->Delete();
 }
 
 
-void VISU_VectorsAct::SetTransform(VTKViewer_Transform* theTransform){
+//----------------------------------------------------------------------------
+vtkDataSet* 
+VISU_VectorsAct
+::GetInput()
+{
+  return GetCurrentPL()->GetOutput();
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_VectorsAct
+::SetTransform(VTKViewer_Transform* theTransform)
+{
   Superclass::SetTransform(theTransform);
-  myPipeLine->SetTransform(theTransform);
+  myVectorsPL->SetTransform(theTransform);
 }
 
 
-void VISU_VectorsAct::SetMapper(vtkMapper* theMapper){
+//----------------------------------------------------------------------------
+void
+VISU_VectorsAct
+::SetMapper(vtkMapper* theMapper)
+{
   if(theMapper){
     myPassFilter[0]->SetInput(theMapper->GetInput());
-
+    
     myPassFilter[1]->SetInput(myPassFilter[0]->GetPolyDataOutput());
 
     myPassFilter[2]->SetInput(myPassFilter[1]->GetPolyDataOutput());
index ae5bc694695ad67e6d9c18eeb17adb1e674f34a3..921b0fc6ba1972caa1f6f023f67976df454e81a2 100644 (file)
@@ -37,19 +37,32 @@ class VISU_VectorsPL;
 class VTKOCC_EXPORT VISU_VectorsAct : public VISU_ScalarMapAct {
  public:
   vtkTypeMacro(VISU_VectorsAct,VISU_ScalarMapAct);
-  static VISU_VectorsAct* New();
-  ~VISU_VectorsAct();
 
-  virtual void SetPipeLine(VISU_PipeLine* thePipeLine);
+  static
+  VISU_VectorsAct*  
+  New();
+
+  virtual
+  void
+  SetPipeLine(VISU_PipeLine* thePipeLine);
 
-  virtual void SetTransform(VTKViewer_Transform* theTransform); 
+  virtual
+  vtkDataSet* 
+  GetInput(); 
 
-  virtual void SetMapper(vtkMapper* theMapper); 
+  virtual
+  void
+  SetTransform(VTKViewer_Transform* theTransform); 
+
+  virtual
+  void
+  SetMapper(vtkMapper* theMapper); 
 
  protected:
   VISU_VectorsAct();
+  ~VISU_VectorsAct();
 
-  VISU_VectorsPL* myPipeLine;
+  VISU_VectorsPL* myVectorsPL;
 };
 
 #endif
index 69958b267860425b22359ce4e9d430ecea5db012..9fcd66fdc9a6fec787350d49acd4c93a8a69ceb3 100644 (file)
@@ -129,6 +129,13 @@ VISU_PipeLine
   return myInput.GetPointer();
 }
 
+vtkDataSet* 
+VISU_PipeLine
+::GetOutput()
+{
+  return GetMapper()->GetInput();
+}
+
 TInput* 
 VISU_PipeLine
 ::GetInput2() const
index 6109c2a9362f9d4f3dee361e8b74440e782e185f..5e2a1ed8bf8bb85694140c757ef8ffdb2845a112 100644 (file)
@@ -34,6 +34,7 @@
 #include "VISU_IDMapper.hxx"
 
 class vtkCell;
+class vtkDataSet;
 class vtkImplicitFunction;
 
 template <class T>
@@ -111,6 +112,10 @@ public:
   TInput* 
   GetInput() const;
 
+  virtual
+  vtkDataSet* 
+  GetOutput();
+
   bool
   IsPlanarInput() const;
 
index df7c8219ec87a2b871fb97f06b51f06749939fac..7b2523506501a1ffc50665c16906e6843b7ba61f 100644 (file)
@@ -59,10 +59,12 @@ namespace VISU{
   void Mul(const float A[3], float b, float C[3]); // C = A * b
   void Sub(const float A[3], const float B[3], float C[3]); // C = A - B
 
-  template<class TItem> void CellDataToPoint(TItem* theTItem, 
-                                            vtkCellDataToPointData *theFilter,
-                                            vtkDataSet* theDataSet,
-                                            VISU_FieldTransform *theFieldTransform)
+  template<class TItem> 
+  void
+  CellDataToPoint(TItem* theTItem, 
+                 vtkCellDataToPointData *theFilter,
+                 vtkDataSet* theDataSet,
+                 VISU_FieldTransform *theFieldTransform)
   {
     if(theDataSet->GetCellData()->GetNumberOfArrays()){
       theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
@@ -72,10 +74,12 @@ namespace VISU{
       theTItem->SetInput(theFieldTransform->GetUnstructuredGridOutput());
   }
 
-  template<class TItem> void ToCellCenters(TItem* theTItem, 
-                                          vtkCellCenters *theFilter,
-                                          vtkDataSet* theDataSet,
-                                          VISU_FieldTransform *theFieldTransform)
+  template<class TItem> 
+  void
+  ToCellCenters(TItem* theTItem, 
+               vtkCellCenters *theFilter,
+               vtkDataSet* theDataSet,
+               VISU_FieldTransform *theFieldTransform)
   {
     if(theDataSet->GetCellData()->GetNumberOfArrays()){
       theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput());
index 9ffb775a68cc914bd8a38fb312f826d81086932f..92a5e57591f621e2630166c5afd44252110c2384 100644 (file)
 #include <vtkConeSource.h>
 #include <vtkLineSource.h>
 #include <vtkGlyphSource2D.h>
+#include <vtkPolyData.h>
 
 vtkStandardNewMacro(VISU_VectorsPL);
 
-VISU_VectorsPL::VISU_VectorsPL(){
-  myGlyph = vtkGlyph3D::New();
+VISU_VectorsPL
+::VISU_VectorsPL()
+{
+  myBaseGlyph = vtkGlyph3D::New();
+  myTransformedGlyph = vtkGlyph3D::New();
 
   myGlyphSource = vtkGlyphSource2D::New();
   myConeSource = vtkConeSource::New();
@@ -49,75 +53,118 @@ VISU_VectorsPL::VISU_VectorsPL(){
   myIsShrinkable = false;
 }
 
-VISU_VectorsPL::~VISU_VectorsPL(){
-  myGlyph->UnRegisterAllOutputs();
-  myGlyph->Delete();
+VISU_VectorsPL
+::~VISU_VectorsPL()
+{
+  myBaseGlyph->Delete();
+  myTransformedGlyph->Delete();
 
-  myCenters->UnRegisterAllOutputs();
   myCenters->Delete();
 
-  myGlyphSource->UnRegisterAllOutputs();
   myGlyphSource->Delete();
 
-  myConeSource->UnRegisterAllOutputs();
   myConeSource->Delete();
 
-  myLineSource->UnRegisterAllOutputs();
   myLineSource->Delete();
 
-  myTransformFilter->UnRegisterAllOutputs();
   myTransformFilter->Delete();
 }
 
-void VISU_VectorsPL::ShallowCopy(VISU_PipeLine *thePipeLine){
+void
+VISU_VectorsPL
+::ShallowCopy(VISU_PipeLine *thePipeLine)
+{
   if(VISU_VectorsPL *aPipeLine = dynamic_cast<VISU_VectorsPL*>(thePipeLine)){
     SetGlyphType(aPipeLine->GetGlyphType());
     SetGlyphPos(aPipeLine->GetGlyphPos());
   }
-  VISU_DeformedShapePL::ShallowCopy(thePipeLine);
+  Superclass::ShallowCopy(thePipeLine);
 }
 
 
-void VISU_VectorsPL::SetTransform(VTKViewer_Transform* theTransform){
+void
+VISU_VectorsPL
+::SetTransform(VTKViewer_Transform* theTransform)
+{
   myFieldTransform->SetSpaceTransform(theTransform);
   myTransformFilter->SetTransform(theTransform);
   myTransformFilter->Modified();
 }
-VTKViewer_Transform* VISU_VectorsPL::GetTransform(){
+
+VTKViewer_Transform* 
+VISU_VectorsPL
+::GetTransform()
+{
   return myFieldTransform->GetSpaceTransform();
 }
 
 
-void VISU_VectorsPL::SetScale(float theScale) {
-  if(myScaleFactor == theScale) return;
+void
+VISU_VectorsPL
+::SetScale(float theScale) 
+{
+  if(myScaleFactor == theScale) 
+    return;
+
   myScaleFactor = theScale;
-  myGlyph->SetScaleFactor(myScaleFactor);
+
+  myBaseGlyph->SetScaleFactor(myScaleFactor);
+  myTransformedGlyph->SetScaleFactor(myScaleFactor);
+
   Modified();
 }
-float VISU_VectorsPL::GetScale() {
-  return myGlyph->GetScaleFactor();
+
+float
+VISU_VectorsPL
+::GetScale() 
+{
+  return myTransformedGlyph->GetScaleFactor();
 }
 
 
-void VISU_VectorsPL::Init(){
-  VISU_DeformedShapePL::Init();
+void
+VISU_VectorsPL
+::Init()
+{
+  Superclass::Init();
 
   myTypeGlyph = ARROW;
   myPosGlyph = TAIL;
 }
 
 
-VISU_ScalarMapPL::THook* VISU_VectorsPL::DoHook(){
+vtkDataSet* 
+VISU_VectorsPL
+::GetOutput()
+{
+  myBaseGlyph->Update();
+  return myBaseGlyph->GetOutput();
+}
+
+
+VISU_ScalarMapPL::THook* 
+VISU_VectorsPL
+::DoHook()
+{
+  VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform);
+  myBaseGlyph->SetVectorModeToUseVector();
+  myBaseGlyph->SetScaleModeToScaleByVector();
+  myBaseGlyph->SetColorModeToColorByScalar();
+
   VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform);
-  myGlyph->SetInput(myTransformFilter->GetOutput());
-  myGlyph->SetVectorModeToUseVector();
-  myGlyph->SetScaleModeToScaleByVector();
-  myGlyph->SetColorModeToColorByScalar();
-  return myGlyph->GetOutput();
+  myTransformedGlyph->SetInput(myTransformFilter->GetOutput());
+  myTransformedGlyph->SetVectorModeToUseVector();
+  myTransformedGlyph->SetScaleModeToScaleByVector();
+  myTransformedGlyph->SetColorModeToColorByScalar();
+
+  return myTransformedGlyph->GetOutput();
 }
 
 
-void VISU_VectorsPL::Update(){
+void
+VISU_VectorsPL
+::Update()
+{
   switch (myTypeGlyph) {
   case ARROW: {
     myGlyphSource->SetGlyphTypeToArrow();
@@ -132,11 +179,8 @@ void VISU_VectorsPL::Update(){
     case CENTER:
       myGlyphSource->SetCenter(0.0, 0.0, 0.0);
     }
-//     if(myPosGlyph == TAIL)
-//       myGlyphSource->SetCenter(0.5, 0.0, 0.0);
-//     else if(myPosGlyph == HEAD)
-//       myGlyphSource->SetCenter(-0.5, 0.0, 0.0);
-    myGlyph->SetSource(myGlyphSource->GetOutput());
+    myBaseGlyph->SetSource(myGlyphSource->GetOutput());
+    myTransformedGlyph->SetSource(myGlyphSource->GetOutput());
   }
     break;
   case CONE2:
@@ -158,26 +202,29 @@ void VISU_VectorsPL::Update(){
     case CENTER:
       myConeSource->SetCenter(0.0, 0.0, 0.0);
     }
-//     if(myPosGlyph == TAIL)
-//       myConeSource->SetCenter(0.5, 0.0, 0.0);
-//     else if(myPosGlyph == HEAD)
-//       myConeSource->SetCenter(-0.5, 0.0, 0.0);
-    myGlyph->SetSource(myConeSource->GetOutput());
+    myBaseGlyph->SetSource(myConeSource->GetOutput());
+    myTransformedGlyph->SetSource(myConeSource->GetOutput());
   }
     break;
   case NONE:
   default: {
-    myGlyph->SetSource(myLineSource->GetOutput());
+    myBaseGlyph->SetSource(myLineSource->GetOutput());
+    myTransformedGlyph->SetSource(myLineSource->GetOutput());
   }
   }
 
-  VISU_DeformedShapePL::Update();
+  Superclass::Update();
 }
 
 
-void VISU_VectorsPL::SetMapScale(float theMapScale){
+void
+VISU_VectorsPL
+::SetMapScale(float theMapScale)
+{
   VISU_ScalarMapPL::SetMapScale(theMapScale);
 
-  myGlyph->SetScaleFactor(myScaleFactor*theMapScale);
-  myGlyph->Modified();
+  myBaseGlyph->SetScaleFactor(myScaleFactor*theMapScale);
+  myTransformedGlyph->SetScaleFactor(myScaleFactor*theMapScale);
+
+  Modified();
 }
index 8b24ece62e44a2967794f8edbd25fccd6b454d07..312d56fc989a28362980c66a4054484da6ad7f5b 100644 (file)
@@ -61,19 +61,24 @@ public:
   virtual GlyphPos GetGlyphPos() { return myPosGlyph;}
 
 public:
-  virtual THook* DoHook();
   virtual void Init();
   virtual void Update();
 
+  vtkDataSet* 
+  GetOutput();
+
   virtual void SetTransform(VTKViewer_Transform* theTransform); 
   virtual VTKViewer_Transform* GetTransform();
   
   virtual void SetMapScale(float theMapScale = 1.0);
 
 protected:
+  virtual THook* DoHook();
+
   GlyphType myTypeGlyph;
   GlyphPos myPosGlyph;
-  vtkGlyph3D *myGlyph;
+  vtkGlyph3D *myBaseGlyph;
+  vtkGlyph3D *myTransformedGlyph;
 
   vtkGlyphSource2D *myGlyphSource;
   vtkLineSource *myLineSource;