From: apo Date: Thu, 19 Jan 2006 08:19:02 +0000 (+0000) Subject: Fix for Bug GVIEW10260 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1da718dadc8428ad861c5f9f4f79317248a0839e;p=modules%2Fvisu.git Fix for Bug GVIEW10260 Scaling is applied incorrectly on selection box --- diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 2004b9c2..90e3009f 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -412,7 +412,7 @@ VISU_Actor if(myIsVTKMapping) return Superclass::GetInput(); - return GetCurrentPL()->GetMapper()->GetInput(); + return GetCurrentPL()->GetOutput(); } //---------------------------------------------------------------------------- diff --git a/src/OBJECT/VISU_VectorsAct.cxx b/src/OBJECT/VISU_VectorsAct.cxx index 143350d8..e568a9d4 100644 --- a/src/OBJECT/VISU_VectorsAct.cxx +++ b/src/OBJECT/VISU_VectorsAct.cxx @@ -36,36 +36,62 @@ #include #include -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(thePipeLine); - VISU_Actor::SetPipeLine(myPipeLine); - myPipeLine->Delete(); +//---------------------------------------------------------------------------- +void +VISU_VectorsAct +::SetPipeLine(VISU_PipeLine* thePipeLine) +{ + myVectorsPL = dynamic_cast(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()); diff --git a/src/OBJECT/VISU_VectorsAct.h b/src/OBJECT/VISU_VectorsAct.h index ae5bc694..921b0fc6 100644 --- a/src/OBJECT/VISU_VectorsAct.h +++ b/src/OBJECT/VISU_VectorsAct.h @@ -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 diff --git a/src/PIPELINE/VISU_PipeLine.cxx b/src/PIPELINE/VISU_PipeLine.cxx index 69958b26..9fcd66fd 100644 --- a/src/PIPELINE/VISU_PipeLine.cxx +++ b/src/PIPELINE/VISU_PipeLine.cxx @@ -129,6 +129,13 @@ VISU_PipeLine return myInput.GetPointer(); } +vtkDataSet* +VISU_PipeLine +::GetOutput() +{ + return GetMapper()->GetInput(); +} + TInput* VISU_PipeLine ::GetInput2() const diff --git a/src/PIPELINE/VISU_PipeLine.hxx b/src/PIPELINE/VISU_PipeLine.hxx index 6109c2a9..5e2a1ed8 100644 --- a/src/PIPELINE/VISU_PipeLine.hxx +++ b/src/PIPELINE/VISU_PipeLine.hxx @@ -34,6 +34,7 @@ #include "VISU_IDMapper.hxx" class vtkCell; +class vtkDataSet; class vtkImplicitFunction; template @@ -111,6 +112,10 @@ public: TInput* GetInput() const; + virtual + vtkDataSet* + GetOutput(); + bool IsPlanarInput() const; diff --git a/src/PIPELINE/VISU_PipeLineUtils.hxx b/src/PIPELINE/VISU_PipeLineUtils.hxx index df7c8219..7b252350 100644 --- a/src/PIPELINE/VISU_PipeLineUtils.hxx +++ b/src/PIPELINE/VISU_PipeLineUtils.hxx @@ -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 void CellDataToPoint(TItem* theTItem, - vtkCellDataToPointData *theFilter, - vtkDataSet* theDataSet, - VISU_FieldTransform *theFieldTransform) + template + 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 void ToCellCenters(TItem* theTItem, - vtkCellCenters *theFilter, - vtkDataSet* theDataSet, - VISU_FieldTransform *theFieldTransform) + template + void + ToCellCenters(TItem* theTItem, + vtkCellCenters *theFilter, + vtkDataSet* theDataSet, + VISU_FieldTransform *theFieldTransform) { if(theDataSet->GetCellData()->GetNumberOfArrays()){ theFilter->SetInput(theFieldTransform->GetUnstructuredGridOutput()); diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 9ffb775a..92a5e575 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -34,11 +34,15 @@ #include #include #include +#include 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(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(); } diff --git a/src/PIPELINE/VISU_VectorsPL.hxx b/src/PIPELINE/VISU_VectorsPL.hxx index 8b24ece6..312d56fc 100644 --- a/src/PIPELINE/VISU_VectorsPL.hxx +++ b/src/PIPELINE/VISU_VectorsPL.hxx @@ -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;