From: apo Date: Fri, 3 Feb 2006 11:53:59 +0000 (+0000) Subject: To sinchronize VTKViewer_Actor and SALOME_Actor X-Git-Tag: T_merge_to_HEAD_20060207~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9760074c25e9b968d0a7ab3ff2b70b47d84e3c78;p=modules%2Fgui.git To sinchronize VTKViewer_Actor and SALOME_Actor --- diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index e8afb6604..9b1b7937d 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -132,28 +132,11 @@ SALOME_Actor myRenderer(NULL), myInteractor(NULL), mySelectionMode(ActorSelection), - myIsHighlighted(false), - myIsPreselected(false), - myRepresentation(VTK_SURFACE), - myDisplayMode(1), - myProperty(vtkProperty::New()), - PreviewProperty(NULL), - myIsInfinite(false), - myIsResolveCoincidentTopology(true), - myStoreMapping(false), - myGeomFilter(VTKViewer_GeometryFilter::New()), - myTransformFilter(VTKViewer_TransformFilter::New()), myPreHighlightActor(SVTK_Actor::New()), myHighlightActor(SVTK_Actor::New()), myOutline(vtkOutlineSource::New()), myOutlineActor(VTKViewer_Actor::New()) { - vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, - myPolygonOffsetUnits); - - for(int i = 0; i < 6; i++) - myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); - myPreHighlightActor->Delete(); myPreHighlightActor->Initialize(); myPreHighlightActor->PickableOff(); @@ -185,24 +168,7 @@ SALOME_Actor //---------------------------------------------------------------------------- SALOME_Actor ::~SALOME_Actor() -{ - SetPreviewProperty(NULL); - - myGeomFilter->UnRegisterAllOutputs(); - myGeomFilter->Delete(); - - myTransformFilter->UnRegisterAllOutputs(); - myTransformFilter->Delete(); - - for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){ - if(myPassFilter[i]){ - myPassFilter[i]->UnRegisterAllOutputs(); - myPassFilter[i]->Delete(); - } - } - - myProperty->Delete(); -} +{} //---------------------------------------------------------------------------- @@ -227,20 +193,13 @@ SALOME_Actor myIO = theIO; } -const char* -SALOME_Actor -::getName() -{ - return myName.c_str(); -} - void SALOME_Actor ::setName(const char* theName) { if(hasIO()) myIO->setName(theName); - myName = theName; + Superclass::setName(theName); } @@ -249,9 +208,9 @@ void SALOME_Actor ::AddToRender(vtkRenderer* theRenderer) { - myRenderer = theRenderer; + Superclass::AddToRender(theRenderer); - theRenderer->AddActor(this); + myRenderer = theRenderer; theRenderer->AddActor( myPreHighlightActor.GetPointer() ); theRenderer->AddActor( myHighlightActor.GetPointer() ); @@ -262,7 +221,7 @@ void SALOME_Actor ::RemoveFromRender(vtkRenderer* theRenderer) { - theRenderer->RemoveActor(this); + Superclass::RemoveFromRender(theRenderer); theRenderer->RemoveActor( myPreHighlightActor.GetPointer() ); theRenderer->RemoveActor( myHighlightActor.GetPointer() ); @@ -276,11 +235,6 @@ SALOME_Actor return myRenderer; } -void -SALOME_Actor -::GetChildActors(vtkActorCollection*) -{} - //---------------------------------------------------------------------------- void @@ -331,368 +285,6 @@ SALOME_Actor } -void -SALOME_Actor -::SetMapper(vtkMapper* theMapper) -{ - InitPipeLine(theMapper); -} - -void -SALOME_Actor -::InitPipeLine(vtkMapper* theMapper) -{ - if(theMapper){ - int anId = 0; - myPassFilter[ anId ]->SetInput( theMapper->GetInput() ); - myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() ); - - anId++; // 1 - myGeomFilter->SetStoreMapping( myStoreMapping ); - myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() ); - - anId++; // 2 - myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() ); - myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() ); - - anId++; // 3 - myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() ); - - anId++; // 4 - myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() ); - myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() ); - - anId++; // 5 - if(vtkDataSetMapper* aMapper = dynamic_cast(theMapper)){ - aMapper->SetInput(myPassFilter[anId]->GetOutput()); - }else if(vtkPolyDataMapper* aMapper = dynamic_cast(theMapper)){ - aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput()); - } - } - Superclass::SetMapper(theMapper); -} - - -//---------------------------------------------------------------------------- -void -SALOME_Actor -::Render(vtkRenderer *ren, vtkMapper* m) -{ - if(myIsResolveCoincidentTopology){ - int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology(); - float aFactor, aUnit; - vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit); - - vtkMapper::SetResolveCoincidentTopologyToPolygonOffset(); - vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, - myPolygonOffsetUnits); - Superclass::Render(ren,m); - - vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit); - vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology); - }else{ - Superclass::Render(ren,m); - } -} - - -void -SALOME_Actor -::SetResolveCoincidentTopology(bool theIsResolve) -{ - myIsResolveCoincidentTopology = theIsResolve; -} - -void -SALOME_Actor -::SetPolygonOffsetParameters(float factor, float units) -{ - myPolygonOffsetFactor = factor; - myPolygonOffsetUnits = units; -} - -void -SALOME_Actor -::GetPolygonOffsetParameters(float& factor, float& units) -{ - factor = myPolygonOffsetFactor; - units = myPolygonOffsetUnits; -} - - -//---------------------------------------------------------------------------- -float -SALOME_Actor -::GetShrinkFactor() -{ - return 1.0; -} - -bool -SALOME_Actor -::IsShrunkable() -{ - return false; -} - -bool -SALOME_Actor -::IsShrunk() -{ - return false; -} - -void -SALOME_Actor -::SetShrink() -{} - -void -SALOME_Actor -::UnShrink() -{} - - -//---------------------------------------------------------------------------- -vtkDataSet* -SALOME_Actor -::GetInput() -{ - return myPassFilter.front()->GetOutput(); -} - - -unsigned long int -SALOME_Actor -::GetMTime() -{ - unsigned long mTime = this->Superclass::GetMTime(); - unsigned long time = myTransformFilter->GetMTime(); - mTime = ( time > mTime ? time : mTime ); - if(vtkDataSet *aDataSet = myPassFilter[0]->GetInput()){ - time = aDataSet->GetMTime(); - mTime = ( time > mTime ? time : mTime ); - } - return mTime; -} - - -//---------------------------------------------------------------------------- -void -SALOME_Actor -::SetRepresentation(int theMode) -{ - switch(myRepresentation){ - case VTK_POINTS : - case VTK_SURFACE : - myProperty->DeepCopy(GetProperty()); - } - switch(theMode){ - case VTK_POINTS : - case VTK_SURFACE : - GetProperty()->DeepCopy(myProperty); - break; - default: - GetProperty()->SetAmbient(1.0); - GetProperty()->SetDiffuse(0.0); - GetProperty()->SetSpecular(0.0); - } - switch(theMode){ - case 3 : - myGeomFilter->SetInside(true); - myGeomFilter->SetWireframeMode(true); - GetProperty()->SetRepresentation(1); - break; - case VTK_POINTS : - GetProperty()->SetPointSize(SALOME_POINT_SIZE); - GetProperty()->SetRepresentation(theMode); - myGeomFilter->SetWireframeMode(false); - myGeomFilter->SetInside(false); - break; - case VTK_WIREFRAME : - GetProperty()->SetRepresentation(theMode); - myGeomFilter->SetWireframeMode(true); - myGeomFilter->SetInside(false); - break; - case VTK_SURFACE : - GetProperty()->SetRepresentation(theMode); - myGeomFilter->SetWireframeMode(false); - myGeomFilter->SetInside(false); - break; - } - myRepresentation = theMode; -} - -int -SALOME_Actor -::GetRepresentation() -{ - return myRepresentation; -} - - -//---------------------------------------------------------------------------- -int -SALOME_Actor -::GetNodeObjId(int theVtkID) -{ - return theVtkID; -} - -float* -SALOME_Actor -::GetNodeCoord(int theObjID) -{ - return GetInput()->GetPoint(theObjID); -} - -vtkCell* -SALOME_Actor -::GetElemCell(int theObjID) -{ - return GetInput()->GetCell(theObjID); -} - -int -SALOME_Actor -::GetElemObjId(int theVtkID) -{ - return theVtkID; -} - - -//================================================================================= -// function : GetObjDimension -// purpose : Return object dimension. -// Virtual method shoulb be redifined by derived classes -//================================================================================= -int -SALOME_Actor -::GetObjDimension( const int theObjId ) -{ - if ( vtkCell* aCell = GetElemCell(theObjId) ) - return aCell->GetCellDimension(); - return 0; -} - - -void -SALOME_Actor -::SetInfinitive(bool theIsInfinite) -{ - myIsInfinite = theIsInfinite; -} - - -bool -SALOME_Actor -::IsInfinitive() -{ - return myIsInfinite; -} - - -float* -SALOME_Actor -::GetBounds() -{ - return Superclass::GetBounds(); -} - - -void -SALOME_Actor -::GetBounds(float theBounds[6]) -{ - Superclass::GetBounds(theBounds); -} - - -//---------------------------------------------------------------------------- -bool -SALOME_Actor -::IsSetCamera() const -{ - return false; -} - -bool -SALOME_Actor -::IsResizable() const -{ - return false; -} - -void -SALOME_Actor -::SetSize( const float ) -{} - - -void -SALOME_Actor -::SetCamera( vtkCamera* ) -{} - -//---------------------------------------------------------------------------- -void -SALOME_Actor -::SetOpacity(float theOpacity) -{ - myOpacity = theOpacity; - GetProperty()->SetOpacity(theOpacity); -} - -float -SALOME_Actor -::GetOpacity() -{ - return myOpacity; -} - - -void -SALOME_Actor -::SetColor(float r,float g,float b) -{ - GetProperty()->SetColor(r,g,b); -} - -void -SALOME_Actor -::SetColor(const float theRGB[3]) -{ - SetColor(theRGB[0],theRGB[1],theRGB[2]); -} - -void -SALOME_Actor -::GetColor(float& r,float& g,float& b) -{ - float aColor[3]; - GetProperty()->GetColor(aColor); - r = aColor[0]; - g = aColor[1]; - b = aColor[2]; -} - - -//---------------------------------------------------------------------------- -int -SALOME_Actor -::getDisplayMode() -{ - return myDisplayMode; -} - -void -SALOME_Actor::setDisplayMode(int theMode) -{ - SetRepresentation(theMode+1); - myDisplayMode = GetRepresentation() - 1; -} - - //---------------------------------------------------------------- void SALOME_Actor @@ -713,29 +305,6 @@ SALOME_Actor } -//---------------------------------------------------------------------------- -bool -SALOME_Actor -::hasHighlight() -{ - return false; -} - -bool -SALOME_Actor -::isHighlighted() -{ - return myIsHighlighted; -} - -void -SALOME_Actor -::SetPreSelected(bool thePreselect) -{ - myIsPreselected = thePreselect; -} - - //---------------------------------------------------------------- void SALOME_Actor @@ -788,7 +357,8 @@ SALOME_Actor GetInput()->GetBounds(aBounds); myOutline->SetBounds(aBounds); myOutlineActor->SetVisibility( GetVisibility() && theIsHighlight ); - myIsHighlighted = theIsHighlight; + + Superclass::highlight(theIsHighlight); } diff --git a/src/SVTK/SALOME_Actor.h b/src/SVTK/SALOME_Actor.h index de4b00b25..d377ff633 100644 --- a/src/SVTK/SALOME_Actor.h +++ b/src/SVTK/SALOME_Actor.h @@ -42,29 +42,14 @@ #include "VTKViewer_Actor.h" -#include -#include - #include -class vtkCell; -class vtkPicker; class vtkPointPicker; class vtkCellPicker; -class vtkDataSet; -class vtkPolyData; -class vtkCamera; -class vtkProperty; class vtkOutlineSource; -class vtkRenderer; class vtkInteractorStyle; class vtkRenderWindowInteractor; -class VTKViewer_Transform; -class VTKViewer_GeometryFilter; -class VTKViewer_TransformFilter; -class VTKViewer_PassThroughFilter; - class SVTK_Actor; class SVTK_RectPicker; class SVTK_InteractorStyle; @@ -72,8 +57,6 @@ class SVTK_InteractorStyle; extern int SALOME_POINT_SIZE; extern int SALOME_LINE_WIDTH; -class SALOME_Actor; - //! The class is a basic one for all SALOME VTK presentation. /*! It provide highlight and prehighlight capabilites, @@ -103,80 +86,12 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor void setIO(const Handle(SALOME_InteractiveObject)& theIO); - //! Get its name - virtual - const char* - getName(); - //! Name the #SALOME_Actor virtual void setName(const char* theName); //---------------------------------------------------------------------------- - //! Change opacity - virtual - void - SetOpacity(float theOpacity); - - //! Get current opacity - virtual - float - GetOpacity(); - - //! Change color - virtual - void - SetColor(float r,float g,float b); - - //! Get current color - virtual - void - GetColor(float& r,float& g,float& b); - - //! Change color - virtual - void - SetColor(const float theRGB[3]); - - //---------------------------------------------------------------------------- - // For selection mapping purpose - //! Maps VTK index of a node to corresponding object index - virtual - int - GetNodeObjId(int theVtkID); - - //! Get coordinates of a node for given object index - virtual - float* - GetNodeCoord(int theObjID); - - //! Maps VTK index of a cell to corresponding object index - virtual - int - GetElemObjId(int theVtkID); - - //! Get corresponding #vtkCell for given object index - virtual - vtkCell* - GetElemCell(int theObjID); - - //---------------------------------------------------------------------------- - //! Get dimension of corresponding mesh element - virtual - int - GetObjDimension( const int theObjId ); - - //! To insert some additional filters and then sets the given #vtkMapper - virtual - void - SetMapper(vtkMapper* theMapper); - - //! Allows to get initial #vtkDataSet - virtual - vtkDataSet* - GetInput(); - //! Apply view transformation virtual void @@ -192,115 +107,6 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor void SetPosition(float _arg[3]); - //! To calculatate last modified time - virtual - unsigned long int - GetMTime(); - - //---------------------------------------------------------------------------- - //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on) - virtual - void - SetRepresentation(int theMode); - - //! Get current representation mode - virtual - int - GetRepresentation(); - - //! Get current display mode (obsolete) - virtual - int - getDisplayMode(); - - //! Set display mode (obsolete) - virtual - void - setDisplayMode(int theMode); - - //---------------------------------------------------------------------------- - //! Set infinive flag - /*! - Infinitive means actor without size (point for example), - which is not taken into account in calculation of boundaries of the scene - */ - void - SetInfinitive(bool theIsInfinite); - - //! Get infinive flag - virtual - bool - IsInfinitive(); - - //! To calcualte current bounding box - virtual - float* - GetBounds(); - - //! To calcualte current bounding box - void - GetBounds(float bounds[6]); - - //---------------------------------------------------------------------------- - virtual - bool - IsSetCamera() const; - - virtual - bool - IsResizable() const; - - virtual - void - SetSize( const float ); - - virtual - void - SetCamera( vtkCamera* ); - - //---------------------------------------------------------------------------- - //! Set ResolveCoincidentTopology flag - void - SetResolveCoincidentTopology(bool theIsResolve); - - //! Set ResolveCoincidentTopology parameters - void - SetPolygonOffsetParameters(float factor, float units); - - //! Get current ResolveCoincidentTopology parameters - void - GetPolygonOffsetParameters(float& factor, float& units); - - virtual - void - Render(vtkRenderer *, vtkMapper *); - - //---------------------------------------------------------------------------- - //! Get current shrink factor - virtual - float - GetShrinkFactor(); - - //! Is the actor is shrunkable - virtual - bool - IsShrunkable(); - - //! Is the actor is shrunk - virtual - bool - IsShrunk(); - - //! Insert shrink filter into pipeline - virtual - void - SetShrink(); - - //! Remove shrink filter from pipeline - virtual - void - UnShrink(); - //---------------------------------------------------------------------------- //! Visibility management virtual @@ -322,11 +128,6 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor vtkRenderer* GetRenderer(); - //! Used to obtain all dependent actors - virtual - void - GetChildActors(vtkActorCollection*); - //---------------------------------------------------------------------------- //! To set interactor in order to use #vtkInteractorObserver devices virtual @@ -338,22 +139,6 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor void Update(); - //---------------------------------------------------------------------------- - //! Ask, if the descendant of the SALOME_Actor will implement its own highlight or not - virtual - bool - hasHighlight(); - - //! Ask, if the SALOME_Actor is already highlighted - virtual - bool - isHighlighted(); - - //! Set preselection mode - virtual - void - SetPreSelected(bool thePreselect = false); - //---------------------------------------------------------------------------- //! Set selector in order to the actor at any time can restore current selection virtual @@ -411,42 +196,17 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor void SetHighlightProperty(vtkProperty* theProperty); - vtkSetObjectMacro(PreviewProperty,vtkProperty); - protected: //---------------------------------------------------------------------------- vtkRenderWindowInteractor* myInteractor; vtkRenderer* myRenderer; - bool myIsResolveCoincidentTopology; - float myPolygonOffsetFactor; - float myPolygonOffsetUnits; - Handle(SALOME_InteractiveObject) myIO; - std::string myName; - - float myOpacity; - int myDisplayMode; - bool myIsInfinite; - - bool myStoreMapping; - VTKViewer_GeometryFilter *myGeomFilter; - VTKViewer_TransformFilter *myTransformFilter; - std::vector myPassFilter; - - int myRepresentation; - vtkProperty *myProperty; - - void - InitPipeLine(vtkMapper* theMapper); SALOME_Actor(); ~SALOME_Actor(); protected: - vtkProperty *PreviewProperty; - bool myIsPreselected; - bool myIsHighlighted; Selection_Mode mySelectionMode; vtkSmartPointer mySelector; diff --git a/src/VTKViewer/Makefile.in b/src/VTKViewer/Makefile.in index f36e73620..dd5f7ea29 100755 --- a/src/VTKViewer/Makefile.in +++ b/src/VTKViewer/Makefile.in @@ -67,7 +67,6 @@ LIB_SRC= VTKViewer_Actor.cxx \ VTKViewer_ViewModel.cxx \ VTKViewer_ConvexTool.cxx \ VTKViewer_ViewWindow.cxx - LIB_MOC = \ VTKViewer_RenderWindow.h \ @@ -76,10 +75,12 @@ LIB_MOC = \ VTKViewer_ViewModel.h \ VTKViewer_ViewWindow.h -CPPFLAGS+=$(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) +BIN = VTKViewer -LDFLAGS+=$(VTK_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL) -lsuit +CPPFLAGS+=$(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) -@CONCLUDE@ +LDFLAGS+=$(VTK_LIBS) $(QT_MT_LIBS) $(CAS_KERNEL) +LDFLAGSFORBIN=$(LDFLAGS) -lqtx -lsuit +@CONCLUDE@ \ No newline at end of file diff --git a/src/VTKViewer/VTKViewer.cxx b/src/VTKViewer/VTKViewer.cxx new file mode 100644 index 000000000..9755466c0 --- /dev/null +++ b/src/VTKViewer/VTKViewer.cxx @@ -0,0 +1,57 @@ +// SALOME VTKViewer : build VTK viewer into Salome desktop +// +// 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 +// +// +// +// File : +// Author : +// Module : +// $Header$ + +#include "VTKViewer_Actor.h" +#include "VTKViewer_CellRectPicker.h" +#include "VTKViewer_ExtractUnstructuredGrid.h" +#include "VTKViewer_ConvexTool.h" +#include "VTKViewer_Filter.h" +#include "VTKViewer_GeometryFilter.h" +#include "VTKViewer_AppendFilter.h" +#include "VTKViewer_Algorithm.h" +#include "VTKViewer_InteractorStyle.h" +#include "VTKViewer_PassThroughFilter.h" +#include "VTKViewer_RectPicker.h" +#include "VTKViewer_RenderWindow.h" +#include "VTKViewer_RenderWindowInteractor.h" +#include "VTKViewer_ShrinkFilter.h" +#include "VTKViewer_TransformFilter.h" +#include "VTKViewer_Transform.h" +#include "VTKViewer_Trihedron.h" +#include "VTKViewer_Utilities.h" +#include "VTKViewer_VectorText.h" +#include "VTKViewer_ViewManager.h" +#include "VTKViewer_ViewModel.h" +#include "VTKViewer_ViewWindow.h" +#include "VTKViewer_Functor.h" + +int +main(int argc, char** argv) +{ + return 0; +} diff --git a/src/VTKViewer/VTKViewer_Actor.cxx b/src/VTKViewer/VTKViewer_Actor.cxx index 7b9e00353..da05fc98d 100755 --- a/src/VTKViewer/VTKViewer_Actor.cxx +++ b/src/VTKViewer/VTKViewer_Actor.cxx @@ -1,134 +1,167 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers +// +// 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 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. // -// 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 // -// 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/ // +// File : SALOME_Actor.cxx +// Author : Nicolas REJNERI +// Module : SALOME +// $Header$ + +/*! + \class SALOME_Actor SALOME_Actor.h + \brief Abstract class of SALOME Objects in VTK. +*/ + + #include "VTKViewer_Actor.h" + #include "VTKViewer_Transform.h" -#include "VTKViewer_GeometryFilter.h" #include "VTKViewer_TransformFilter.h" #include "VTKViewer_PassThroughFilter.h" +#include "VTKViewer_GeometryFilter.h" // VTK Includes +#include +#include #include #include #include +#include #include -#include -#include -#include +using namespace std; -/* -static void CopyPoints(vtkUnstructuredGrid* theGrid, vtkDataSet *theSourceDataSet){ - vtkPoints *aPoints = vtkPoints::New(); - vtkIdType iEnd = theSourceDataSet->GetNumberOfPoints(); - aPoints->SetNumberOfPoints(iEnd); - for(vtkIdType i = 0; i < iEnd; i++){ - aPoints->SetPoint(i,theSourceDataSet->GetPoint(i)); - } - theGrid->SetPoints(aPoints); - aPoints->Delete(); -} -*/ +#if defined __GNUC__ + #if __GNUC__ == 2 + #define __GNUC_2__ + #endif +#endif +int VTKViewer_POINT_SIZE = 5; +int VTKViewer_LINE_WIDTH = 3; +//---------------------------------------------------------------------------- vtkStandardNewMacro(VTKViewer_Actor); -/*!Constructor.Initialize default parameters.*/ -VTKViewer_Actor::VTKViewer_Actor(){ - myIsHighlighted = myIsPreselected = false; - - myRepresentation = 1; - myDisplayMode = myRepresentation - 1; - - myProperty = vtkProperty::New(); - PreviewProperty = NULL; - - myIsInfinite = false; - myIsResolveCoincidentTopology = true; - +//---------------------------------------------------------------------------- +VTKViewer_Actor +::VTKViewer_Actor(): + myIsHighlighted(false), + myIsPreselected(false), + myRepresentation(VTK_SURFACE), + myDisplayMode(1), + myProperty(vtkProperty::New()), + PreviewProperty(NULL), + myIsInfinite(false), + myIsResolveCoincidentTopology(true), + myStoreMapping(false), + myGeomFilter(VTKViewer_GeometryFilter::New()), + myTransformFilter(VTKViewer_TransformFilter::New()) +{ vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, myPolygonOffsetUnits); - myStoreMapping = false; - myGeomFilter = VTKViewer_GeometryFilter::New(); - - myTransformFilter = VTKViewer_TransformFilter::New(); for(int i = 0; i < 6; i++) myPassFilter.push_back(VTKViewer_PassThroughFilter::New()); - - Visibility = Pickable = true; } -/*!Destructor.*/ -VTKViewer_Actor::~VTKViewer_Actor(){ +//---------------------------------------------------------------------------- +VTKViewer_Actor +::~VTKViewer_Actor() +{ SetPreviewProperty(NULL); - myGeomFilter->UnRegisterAllOutputs(); myGeomFilter->Delete(); - myTransformFilter->UnRegisterAllOutputs(); myTransformFilter->Delete(); - for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){ - if(myPassFilter[i]){ - myPassFilter[i]->UnRegisterAllOutputs(); + for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++) + if(myPassFilter[i]) myPassFilter[i]->Delete(); - } - } + myProperty->Delete(); } -/*!Add VTKViewer_Actor to renderer. - *\param theRenderer - vtkRenderer - */ -void VTKViewer_Actor::AddToRender(vtkRenderer* theRenderer){ + +//---------------------------------------------------------------------------- +const char* +VTKViewer_Actor +::getName() +{ + return myName.c_str(); +} + +void +VTKViewer_Actor +::setName(const char* theName) +{ + myName = theName; +} + + +//---------------------------------------------------------------------------- +void +VTKViewer_Actor +::AddToRender(vtkRenderer* theRenderer) +{ theRenderer->AddActor(this); } -/*!Remove VTKViewer_Actor from renderer. - *\param theRenderer - vtkRenderer - */ -void VTKViewer_Actor::RemoveFromRender(vtkRenderer* theRenderer){ +void +VTKViewer_Actor +::RemoveFromRender(vtkRenderer* theRenderer) +{ theRenderer->RemoveActor(this); } -/*!Add transformation to transform filter. - *\param theTransform - transformation. - */ -void VTKViewer_Actor::SetTransform(VTKViewer_Transform* theTransform){ +void +VTKViewer_Actor +::GetChildActors(vtkActorCollection*) +{} + + +//---------------------------------------------------------------------------- +void +VTKViewer_Actor +::SetTransform(VTKViewer_Transform* theTransform) +{ myTransformFilter->SetTransform(theTransform); } -/*!Set mapper to pipeline.\n - *Call method for pipeline initialization. - *\param theMapper - mapper - */ -void VTKViewer_Actor::SetMapper(vtkMapper* theMapper){ + +void +VTKViewer_Actor +::SetMapper(vtkMapper* theMapper) +{ InitPipeLine(theMapper); } -/*!Initialize sequence of filters for mapper, if \a theMapper is not null. - *\param theMapper - mapper - */ -void VTKViewer_Actor::InitPipeLine(vtkMapper* theMapper){ +void +VTKViewer_Actor +::InitPipeLine(vtkMapper* theMapper) +{ if(theMapper){ int anId = 0; myPassFilter[ anId ]->SetInput( theMapper->GetInput() ); @@ -156,11 +189,15 @@ void VTKViewer_Actor::InitPipeLine(vtkMapper* theMapper){ aMapper->SetInput(myPassFilter[anId]->GetPolyDataOutput()); } } - vtkLODActor::SetMapper(theMapper); + Superclass::SetMapper(theMapper); } -/*!*/ -void VTKViewer_Actor::Render(vtkRenderer *ren, vtkMapper* m){ + +//---------------------------------------------------------------------------- +void +VTKViewer_Actor +::Render(vtkRenderer *ren, vtkMapper* m) +{ if(myIsResolveCoincidentTopology){ int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology(); float aFactor, aUnit; @@ -169,52 +206,86 @@ void VTKViewer_Actor::Render(vtkRenderer *ren, vtkMapper* m){ vtkMapper::SetResolveCoincidentTopologyToPolygonOffset(); vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, myPolygonOffsetUnits); - vtkLODActor::Render(ren,m); + Superclass::Render(ren,m); vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnit); vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology); }else{ - vtkLODActor::Render(ren,m); + Superclass::Render(ren,m); } } -/*!Set flag myIsResolveCoincidentTopology to \a theIsResolve. - *\param theIsResolve - bool flag. - */ -void VTKViewer_Actor::SetResolveCoincidentTopology(bool theIsResolve) { + +void +VTKViewer_Actor +::SetResolveCoincidentTopology(bool theIsResolve) +{ myIsResolveCoincidentTopology = theIsResolve; } -/*!Sets polygon offset factor and polygon offset units. - *\param factor - float factor - *\param units - float units - */ -void VTKViewer_Actor::SetPolygonOffsetParameters(float factor, float units){ +void +VTKViewer_Actor +::SetPolygonOffsetParameters(float factor, float units) +{ myPolygonOffsetFactor = factor; myPolygonOffsetUnits = units; } -/*!Gets polygon offset factor and polygon offset units. - *\param factor - output float - *\param units - output float - */ -void VTKViewer_Actor::GetPolygonOffsetParameters(float& factor, float& units){ +void +VTKViewer_Actor +::GetPolygonOffsetParameters(float& factor, float& units) +{ factor = myPolygonOffsetFactor; units = myPolygonOffsetUnits; } -/*!Get input data set. - *\retval vtkDataSet pointer. - */ -vtkDataSet* VTKViewer_Actor::GetInput(){ +//---------------------------------------------------------------------------- +float +VTKViewer_Actor +::GetShrinkFactor() +{ + return 1.0; +} + +bool +VTKViewer_Actor +::IsShrunkable() +{ + return false; +} + +bool +VTKViewer_Actor +::IsShrunk() +{ + return false; +} + +void +VTKViewer_Actor +::SetShrink() +{} + +void +VTKViewer_Actor +::UnShrink() +{} + + +//---------------------------------------------------------------------------- +vtkDataSet* +VTKViewer_Actor +::GetInput() +{ return myPassFilter.front()->GetOutput(); } -/*!Get modification time. - *\retval time - unsigned long. - */ -unsigned long int VTKViewer_Actor::GetMTime(){ + +unsigned long int +VTKViewer_Actor +::GetMTime() +{ unsigned long mTime = this->Superclass::GetMTime(); unsigned long time = myTransformFilter->GetMTime(); mTime = ( time > mTime ? time : mTime ); @@ -225,10 +296,12 @@ unsigned long int VTKViewer_Actor::GetMTime(){ return mTime; } -/*!Set representation mode. - *\param theMode - int. - */ -void VTKViewer_Actor::SetRepresentation(int theMode) { + +//---------------------------------------------------------------------------- +void +VTKViewer_Actor +::SetRepresentation(int theMode) +{ switch(myRepresentation){ case VTK_POINTS : case VTK_SURFACE : @@ -240,7 +313,6 @@ void VTKViewer_Actor::SetRepresentation(int theMode) { GetProperty()->DeepCopy(myProperty); break; default: - break; GetProperty()->SetAmbient(1.0); GetProperty()->SetDiffuse(0.0); GetProperty()->SetSpecular(0.0); @@ -248,93 +320,175 @@ void VTKViewer_Actor::SetRepresentation(int theMode) { switch(theMode){ case 3 : myGeomFilter->SetInside(true); - GetProperty()->SetRepresentation(1); + myGeomFilter->SetWireframeMode(true); + GetProperty()->SetRepresentation(VTK_WIREFRAME); break; case VTK_POINTS : GetProperty()->SetPointSize(VTKViewer_POINT_SIZE); - default : GetProperty()->SetRepresentation(theMode); + myGeomFilter->SetWireframeMode(false); + myGeomFilter->SetInside(false); + break; + case VTK_WIREFRAME : + GetProperty()->SetRepresentation(theMode); + myGeomFilter->SetWireframeMode(true); myGeomFilter->SetInside(false); + break; + case VTK_SURFACE : + GetProperty()->SetRepresentation(theMode); + myGeomFilter->SetWireframeMode(false); + myGeomFilter->SetInside(false); + break; } myRepresentation = theMode; } -/*!Get representation. - *\retval representation mode. - */ -int VTKViewer_Actor::GetRepresentation(){ +int +VTKViewer_Actor +::GetRepresentation() +{ return myRepresentation; } -/*!Get VTK cell by object ID. - *\param theObjID - object ID. - *\retval vtkCell pointer. - */ -vtkCell* VTKViewer_Actor::GetElemCell(int theObjID){ - return GetInput()->GetCell(theObjID); + +//---------------------------------------------------------------------------- +int +VTKViewer_Actor +::GetNodeObjId(int theVtkID) +{ + return theVtkID; } -/*!Get node coordinates by node ID. - *\param theObjID - node ID. - *\retval float array of coordinates. - * \li array[0] - X coordinate. - * \li array[1] - Y coordinate. - * \li array[2] - Z coordinate. - */ -float* VTKViewer_Actor::GetNodeCoord(int theObjID){ +float* +VTKViewer_Actor +::GetNodeCoord(int theObjID) +{ return GetInput()->GetPoint(theObjID); } +vtkCell* +VTKViewer_Actor +::GetElemCell(int theObjID) +{ + return GetInput()->GetCell(theObjID); +} + +int +VTKViewer_Actor +::GetElemObjId(int theVtkID) +{ + return theVtkID; +} + //================================================================================= // function : GetObjDimension -/*! purpose : Return object dimension.\n - * Virtual method shoulb be redifined by derived classes - *\param theObjId - object ID. - */ +// purpose : Return object dimension. +// Virtual method shoulb be redifined by derived classes //================================================================================= -int VTKViewer_Actor::GetObjDimension( const int theObjId ) +int +VTKViewer_Actor +::GetObjDimension( const int theObjId ) { if ( vtkCell* aCell = GetElemCell(theObjId) ) return aCell->GetCellDimension(); return 0; } -/*!Get infinite flag*/ -bool VTKViewer_Actor::IsInfinitive(){ + +void +VTKViewer_Actor +::SetInfinitive(bool theIsInfinite) +{ + myIsInfinite = theIsInfinite; +} + + +bool +VTKViewer_Actor +::IsInfinitive() +{ return myIsInfinite; } -/*!Set property - opacity. - *\param theOpacity - new apacity - */ -void VTKViewer_Actor::SetOpacity(float theOpacity){ + +float* +VTKViewer_Actor +::GetBounds() +{ + return Superclass::GetBounds(); +} + + +void +VTKViewer_Actor +::GetBounds(float theBounds[6]) +{ + Superclass::GetBounds(theBounds); +} + + +//---------------------------------------------------------------------------- +bool +VTKViewer_Actor +::IsSetCamera() const +{ + return false; +} + +bool +VTKViewer_Actor +::IsResizable() const +{ + return false; +} + +void +VTKViewer_Actor +::SetSize( const float ) +{} + + +void +VTKViewer_Actor +::SetCamera( vtkCamera* ) +{} + +//---------------------------------------------------------------------------- +void +VTKViewer_Actor +::SetOpacity(float theOpacity) +{ myOpacity = theOpacity; GetProperty()->SetOpacity(theOpacity); } -/*!Get property - opacity. - *\retval float value. - */ -float VTKViewer_Actor::GetOpacity(){ +float +VTKViewer_Actor +::GetOpacity() +{ return myOpacity; } -/*!Set property - color - *\param r - float Red value - *\param g - float Green value - *\param b - float Blue value - */ -void VTKViewer_Actor::SetColor(float r,float g,float b){ + +void +VTKViewer_Actor +::SetColor(float r,float g,float b) +{ GetProperty()->SetColor(r,g,b); } -/*!Get property - color - *\param r - output float Red value - *\param g - output float Green value - *\param b - output float Blue value - */ -void VTKViewer_Actor::GetColor(float& r,float& g,float& b){ +void +VTKViewer_Actor +::SetColor(const float theRGB[3]) +{ + SetColor(theRGB[0],theRGB[1],theRGB[2]); +} + +void +VTKViewer_Actor +::GetColor(float& r,float& g,float& b) +{ float aColor[3]; GetProperty()->GetColor(aColor); r = aColor[0]; @@ -342,18 +496,53 @@ void VTKViewer_Actor::GetColor(float& r,float& g,float& b){ b = aColor[2]; } -/*!Get display mode. - *\retval int value - */ -int VTKViewer_Actor::getDisplayMode(){ + +//---------------------------------------------------------------------------- +int +VTKViewer_Actor +::getDisplayMode() +{ return myDisplayMode; } -/*!Set display mode - *\param theMode - integer value. - */ -void VTKViewer_Actor::setDisplayMode(int theMode){ - SetRepresentation(theMode+1); +void +VTKViewer_Actor +::setDisplayMode(int theMode) +{ + SetRepresentation(theMode + 1); myDisplayMode = GetRepresentation() - 1; } + +//---------------------------------------------------------------------------- +bool +VTKViewer_Actor +::hasHighlight() +{ + return false; +} + +bool +VTKViewer_Actor +::isHighlighted() +{ + return myIsHighlighted; +} + +void +VTKViewer_Actor +::SetPreSelected(bool thePreselect) +{ + myIsPreselected = thePreselect; +} + + +//---------------------------------------------------------------- +void +VTKViewer_Actor +::highlight(bool theIsHighlight) +{ + myIsHighlighted = theIsHighlight; +} + +vtkCxxSetObjectMacro(VTKViewer_Actor,PreviewProperty,vtkProperty); diff --git a/src/VTKViewer/VTKViewer_Actor.h b/src/VTKViewer/VTKViewer_Actor.h index 2a4371200..55711a8c0 100755 --- a/src/VTKViewer/VTKViewer_Actor.h +++ b/src/VTKViewer/VTKViewer_Actor.h @@ -1,164 +1,327 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D +// SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers +// +// 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. // -// 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. +// 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 // -// 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. +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // -// 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/ // +// File : SALOME_Actor.h +// Author : Nicolas REJNERI +// Module : SALOME +// $Header$ + #ifndef VTKVIEVER_ACTOR_H #define VTKVIEVER_ACTOR_H #include "VTKViewer.h" -#include -#include -#include -#include -#include - +#include #include +#include + class vtkCell; +class vtkPointPicker; +class vtkCellPicker; class vtkDataSet; -class vtkPolyData; +class vtkCamera; +class vtkProperty; +class vtkRenderer; class VTKViewer_Transform; class VTKViewer_GeometryFilter; class VTKViewer_TransformFilter; class VTKViewer_PassThroughFilter; -#define VTKViewer_POINT_SIZE 3 +extern int VTKViewer_POINT_SIZE; +extern int VTKViewer_LINE_WIDTH; + /*! \class vtkLODActor * \brief For more information see VTK documentation */ -class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor +class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor { -public: - /*!Create new instance of actor.*/ + public: static VTKViewer_Actor* New(); - - vtkTypeMacro( VTKViewer_Actor, vtkLODActor ); - - /*!Get name of the actor*/ - virtual const char* getName() { return myName.c_str(); } - /*!Set name of the actor*/ - virtual void setName(const char* theName){ myName = theName;} - - //! To generate highlight automaticaly - virtual bool hasHighlight() { return false; } - //! Sets highlight. - virtual void highlight(bool theHighlight) { myIsHighlighted = theHighlight; } - //! Check highlight. - virtual bool isHighlighted() { return myIsHighlighted; } - virtual void SetOpacity(float theOpacity); - virtual float GetOpacity(); - - virtual void SetColor(float r,float g,float b); - virtual void GetColor(float& r,float& g,float& b); - void SetColor(const float theRGB[3]){ SetColor(theRGB[0],theRGB[1],theRGB[2]); } - - vtkSetObjectMacro(PreviewProperty,vtkProperty); - - virtual void SetPreSelected(bool thePreselect = false) { myIsPreselected = thePreselect;} - - //! Used to obtain all dependent actors - virtual void GetChildActors(vtkActorCollection*) {}; - - virtual void AddToRender(vtkRenderer* theRenderer); - virtual void RemoveFromRender(vtkRenderer* theRenderer); - - - /** @name For selection mapping purpose */ - //@{ - virtual int GetNodeObjId(int theVtkID) { return theVtkID;} - virtual float* GetNodeCoord(int theObjID); - - virtual int GetElemObjId(int theVtkID) { return theVtkID;} - virtual vtkCell* GetElemCell(int theObjID); - //@} - - virtual int GetObjDimension( const int theObjId ); - - virtual void SetMapper(vtkMapper* theMapper); - virtual vtkDataSet* GetInput(); - - virtual void SetTransform(VTKViewer_Transform* theTransform); - virtual unsigned long int GetMTime(); - - virtual void SetRepresentation(int theMode); - virtual int GetRepresentation(); - - virtual int getDisplayMode(); - virtual void setDisplayMode(int theMode); - - /*! Infinitive means actor without size (point for example), \n - * which is not taken into account in calculation of boundaries of the scene - */ - void SetInfinitive(bool theIsInfinite) { myIsInfinite = theIsInfinite; } - virtual bool IsInfinitive(); + vtkTypeMacro(VTKViewer_Actor,vtkLODActor); + + //---------------------------------------------------------------------------- + //! Get its name + virtual + const char* + getName(); + + //! Name the #VTKViewer_Actor + virtual + void + setName(const char* theName); + + //---------------------------------------------------------------------------- + //! Change opacity + virtual + void + SetOpacity(float theOpacity); + + //! Get current opacity + virtual + float + GetOpacity(); + + //! Change color + virtual + void + SetColor(float r,float g,float b); + + //! Get current color + virtual + void + GetColor(float& r,float& g,float& b); + + //! Change color + virtual + void + SetColor(const float theRGB[3]); + + //---------------------------------------------------------------------------- + // For selection mapping purpose + //! Maps VTK index of a node to corresponding object index + virtual + int + GetNodeObjId(int theVtkID); + + //! Get coordinates of a node for given object index + virtual + float* + GetNodeCoord(int theObjID); + + //! Maps VTK index of a cell to corresponding object index + virtual + int + GetElemObjId(int theVtkID); + + //! Get corresponding #vtkCell for given object index + virtual + vtkCell* + GetElemCell(int theObjID); + + //---------------------------------------------------------------------------- + //! Get dimension of corresponding mesh element + virtual + int + GetObjDimension( const int theObjId ); + + //! To insert some additional filters and then sets the given #vtkMapper + virtual + void + SetMapper(vtkMapper* theMapper); + + //! Allows to get initial #vtkDataSet + virtual + vtkDataSet* + GetInput(); + + //! Apply view transformation + virtual + void + SetTransform(VTKViewer_Transform* theTransform); + + //! To calculatate last modified time + virtual + unsigned long int + GetMTime(); + + //---------------------------------------------------------------------------- + //! Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on) + virtual + void + SetRepresentation(int theMode); + + //! Get current representation mode + virtual + int + GetRepresentation(); + + //! Get current display mode (obsolete) + virtual + int + getDisplayMode(); + + //! Set display mode (obsolete) + virtual + void + setDisplayMode(int theMode); + + //---------------------------------------------------------------------------- + //! Set infinive flag + /*! + Infinitive means actor without size (point for example), + which is not taken into account in calculation of boundaries of the scene + */ + void + SetInfinitive(bool theIsInfinite); + + //! Get infinive flag + virtual + bool + IsInfinitive(); - void SetResolveCoincidentTopology(bool theIsResolve); - void SetPolygonOffsetParameters(float factor, float units); - void GetPolygonOffsetParameters(float& factor, float& units); - - virtual void Render(vtkRenderer *, vtkMapper *); + //! To calcualte current bounding box + virtual + float* + GetBounds(); + + //! To calcualte current bounding box + void + GetBounds(float bounds[6]); + + //---------------------------------------------------------------------------- + virtual + bool + IsSetCamera() const; + + virtual + bool + IsResizable() const; + + virtual + void + SetSize( const float ); + + virtual + void + SetCamera( vtkCamera* ); + + //---------------------------------------------------------------------------- + //! Set ResolveCoincidentTopology flag + void + SetResolveCoincidentTopology(bool theIsResolve); + + //! Set ResolveCoincidentTopology parameters + void + SetPolygonOffsetParameters(float factor, float units); + + //! Get current ResolveCoincidentTopology parameters + void + GetPolygonOffsetParameters(float& factor, float& units); + + virtual + void + Render(vtkRenderer *, vtkMapper *); + + //---------------------------------------------------------------------------- + //! Get current shrink factor + virtual + float + GetShrinkFactor(); + + //! Is the actor is shrunkable + virtual + bool + IsShrunkable(); + + //! Is the actor is shrunk + virtual + bool + IsShrunk(); + + //! Insert shrink filter into pipeline + virtual + void + SetShrink(); + + //! Remove shrink filter from pipeline + virtual + void + UnShrink(); + + //---------------------------------------------------------------------------- + //! To publish the actor an all its internal devices + virtual + void + AddToRender(vtkRenderer* theRendere); + + //! To remove the actor an all its internal devices + virtual + void + RemoveFromRender(vtkRenderer* theRendere); -protected: - /*!resolve coincedent topology flag*/ + //! Used to obtain all dependent actors + virtual + void + GetChildActors(vtkActorCollection*); + + //---------------------------------------------------------------------------- + //! Ask, if the descendant of the VTKViewer_Actor will implement its own highlight or not + virtual + bool + hasHighlight(); + + //! Ask, if the VTKViewer_Actor is already highlighted + virtual + bool + isHighlighted(); + + //! Set preselection mode + virtual + void + SetPreSelected(bool thePreselect = false); + + //---------------------------------------------------------------------------- + //! Just to update visibility of the highlight devices + virtual + void + highlight(bool theHighlight); + + void + SetPreviewProperty(vtkProperty* theProperty); + + protected: + //---------------------------------------------------------------------------- bool myIsResolveCoincidentTopology; - /*!polygon offset factor*/ float myPolygonOffsetFactor; - /*!polygon offset units*/ float myPolygonOffsetUnits; - /*!Actor name.*/ std::string myName; - /*!preview property*/ - vtkProperty *PreviewProperty; - /*!preselected flag*/ - bool myIsPreselected; - - /*!opacity*/ float myOpacity; - /*!highlighted flag*/ - bool myIsHighlighted; - /*!display mode*/ int myDisplayMode; - /*!infinite flag*/ bool myIsInfinite; - /*!store mapping flag*/ bool myStoreMapping; - /*!geometry filter*/ VTKViewer_GeometryFilter *myGeomFilter; - /*!transform filter*/ VTKViewer_TransformFilter *myTransformFilter; - /*!vector of passive filters(siz filters used)*/ std::vector myPassFilter; - /*!presentation mode*/ int myRepresentation; - /*!property*/ vtkProperty *myProperty; - //! Main method, which calculate output. - void InitPipeLine(vtkMapper* theMapper); + void + InitPipeLine(vtkMapper* theMapper); VTKViewer_Actor(); ~VTKViewer_Actor(); + + protected: + vtkProperty *PreviewProperty; + bool myIsPreselected; + bool myIsHighlighted; }; -#endif +#endif // VTKVIEVER_ACTOR_H