X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPIPELINE%2FVISU_VectorsPL.cxx;h=3fa4bd6654f27e2da0eabc70a57075e9111950a6;hb=e967b0415406f4f86ca2c9489abc8554b4c15dae;hp=786f7ec069a39870981bad7f1501f6a25ef0225f;hpb=17b175ff4b710fc93421509ffa7583edd1678a5d;p=modules%2Fvisu.git diff --git a/src/PIPELINE/VISU_VectorsPL.cxx b/src/PIPELINE/VISU_VectorsPL.cxx index 786f7ec0..3fa4bd66 100644 --- a/src/PIPELINE/VISU_VectorsPL.cxx +++ b/src/PIPELINE/VISU_VectorsPL.cxx @@ -1,23 +1,23 @@ // VISU OBJECT : interactive object for VISU entities implementation // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // File: VISU_PipeLine.cxx @@ -27,125 +27,204 @@ #include "VISU_VectorsPL.hxx" #include "VISU_PipeLineUtils.hxx" -#include "SALOME_TransformFilter.h" -#include "SALOME_Transform.h" +#include "VTKViewer_TransformFilter.h" +#include "VTKViewer_Transform.h" #include #include #include #include +#include vtkStandardNewMacro(VISU_VectorsPL); -VISU_VectorsPL::VISU_VectorsPL(){ - myGlyph = vtkGlyph3D::New(); - myTransformFilter = SALOME_TransformFilter::New(); +VISU_VectorsPL +::VISU_VectorsPL() +{ + myBaseGlyph = vtkGlyph3D::New(); + myTransformedGlyph = vtkGlyph3D::New(); + + myGlyphSource = vtkGlyphSource2D::New(); + myConeSource = vtkConeSource::New(); + myLineSource = vtkLineSource::New(); + + myCenters = vtkCellCenters::New(); + myTransformFilter = VTKViewer_TransformFilter::New(); + myIsShrinkable = false; } -VISU_VectorsPL::~VISU_VectorsPL(){ - myGlyph->Delete(); +VISU_VectorsPL +::~VISU_VectorsPL() +{ + myBaseGlyph->Delete(); + myTransformedGlyph->Delete(); + + myCenters->Delete(); + + myGlyphSource->Delete(); + + myConeSource->Delete(); + + myLineSource->Delete(); + myTransformFilter->Delete(); } -void VISU_VectorsPL::ShallowCopy(VISU_PipeLine *thePipeLine){ - VISU_DeformedShapePL::ShallowCopy(thePipeLine); +void +VISU_VectorsPL +::ShallowCopy(VISU_PipeLine *thePipeLine) +{ if(VISU_VectorsPL *aPipeLine = dynamic_cast(thePipeLine)){ SetGlyphType(aPipeLine->GetGlyphType()); SetGlyphPos(aPipeLine->GetGlyphPos()); } + Superclass::ShallowCopy(thePipeLine); } -void VISU_VectorsPL::SetTransform(SALOME_Transform* theTransform){ +void +VISU_VectorsPL +::SetTransform(VTKViewer_Transform* theTransform) +{ myFieldTransform->SetSpaceTransform(theTransform); myTransformFilter->SetTransform(theTransform); myTransformFilter->Modified(); } -SALOME_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(vtkFloatingPointType theScale) +{ + if(myScaleFactor == theScale) + return; + myScaleFactor = theScale; - myGlyph->SetScaleFactor(myScaleFactor); + + myBaseGlyph->SetScaleFactor(myScaleFactor); + myTransformedGlyph->SetScaleFactor(myScaleFactor); + Modified(); } -float VISU_VectorsPL::GetScale() { - return myGlyph->GetScaleFactor(); + +vtkFloatingPointType +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(){ - VISU::ToCellCenters(myTransformFilter,myInput,myFieldTransform); - myGlyph->SetInput(myTransformFilter->GetOutput()); - myGlyph->SetVectorModeToUseVector(); - myGlyph->SetScaleModeToScaleByVector(); - myGlyph->SetColorModeToColorByScalar(); - return myGlyph->GetOutput(); +vtkDataSet* +VISU_VectorsPL +::GetOutput() +{ + myBaseGlyph->Update(); + return myBaseGlyph->GetOutput(); } -void VISU_VectorsPL::Update(){ +VISU_ScalarMapPL::THook* +VISU_VectorsPL +::DoHook() +{ + VISU::ToCellCenters(myBaseGlyph,myCenters,GetInput2(),myFieldTransform); + myBaseGlyph->SetVectorModeToUseVector(); + myBaseGlyph->SetScaleModeToScaleByVector(); + myBaseGlyph->SetColorModeToColorByScalar(); + + VISU::ToCellCenters(myTransformFilter,myCenters,GetInput2(),myFieldTransform); + myTransformedGlyph->SetInput(myTransformFilter->GetOutput()); + myTransformedGlyph->SetVectorModeToUseVector(); + myTransformedGlyph->SetScaleModeToScaleByVector(); + myTransformedGlyph->SetColorModeToColorByScalar(); + + return myTransformedGlyph->GetOutput(); +} + + +void +VISU_VectorsPL +::Update() +{ switch (myTypeGlyph) { case ARROW: { - vtkGlyphSource2D *aGlyphSource = vtkGlyphSource2D::New(); - aGlyphSource->SetGlyphTypeToArrow(); - aGlyphSource->SetFilled(0); - if(myPosGlyph == TAIL) - aGlyphSource->SetCenter(0.5, 0.0, 0.0); - else if(myPosGlyph == HEAD) - aGlyphSource->SetCenter(-0.5, 0.0, 0.0); - myGlyph->SetSource(aGlyphSource->GetOutput()); - aGlyphSource->Register(myGlyph); - aGlyphSource->Delete(); + myGlyphSource->SetGlyphTypeToArrow(); + myGlyphSource->SetFilled(0); + switch (myPosGlyph) { + case TAIL: + myGlyphSource->SetCenter(0.5, 0.0, 0.0); + break; + case HEAD: + myGlyphSource->SetCenter(-0.5, 0.0, 0.0); + break; + case CENTER: + myGlyphSource->SetCenter(0.0, 0.0, 0.0); + } + myBaseGlyph->SetSource(myGlyphSource->GetOutput()); + myTransformedGlyph->SetSource(myGlyphSource->GetOutput()); } break; case CONE2: case CONE6: { - vtkConeSource *aGlyphSource = vtkConeSource::New(); //by default if (myTypeGlyph == CONE2) - aGlyphSource->SetResolution(3); + myConeSource->SetResolution(3); else - aGlyphSource->SetResolution(7); - aGlyphSource->SetHeight(1.0); - aGlyphSource->SetRadius(.1); - - if(myPosGlyph == TAIL) - aGlyphSource->SetCenter(0.5, 0.0, 0.0); - else if(myPosGlyph == HEAD) - aGlyphSource->SetCenter(-0.5, 0.0, 0.0); - - myGlyph->SetSource(aGlyphSource->GetOutput()); - aGlyphSource->Register(myGlyph); - aGlyphSource->Delete(); + myConeSource->SetResolution(7); + myConeSource->SetHeight(1.0); + myConeSource->SetRadius(.1); + + switch (myPosGlyph) { + case TAIL: + myConeSource->SetCenter(0.5, 0.0, 0.0); + break; + case HEAD: + myConeSource->SetCenter(-0.5, 0.0, 0.0); + break; + case CENTER: + myConeSource->SetCenter(0.0, 0.0, 0.0); + } + myBaseGlyph->SetSource(myConeSource->GetOutput()); + myTransformedGlyph->SetSource(myConeSource->GetOutput()); } break; case NONE: default: { - vtkLineSource *aGlyphSource = vtkLineSource::New(); - myGlyph->SetSource(aGlyphSource->GetOutput()); - aGlyphSource->Register(myGlyph); - aGlyphSource->Delete(); + myBaseGlyph->SetSource(myLineSource->GetOutput()); + myTransformedGlyph->SetSource(myLineSource->GetOutput()); } } - VISU_DeformedShapePL::Update(); + Superclass::Update(); } -void VISU_VectorsPL::SetMapScale(float theMapScale){ +void +VISU_VectorsPL +::SetMapScale(vtkFloatingPointType theMapScale) +{ VISU_ScalarMapPL::SetMapScale(theMapScale); - myGlyph->SetScaleFactor(myScaleFactor*theMapScale); - myGlyph->Modified(); + myBaseGlyph->SetScaleFactor(myScaleFactor*theMapScale); + myTransformedGlyph->SetScaleFactor(myScaleFactor*theMapScale); + + Modified(); }