X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOBJECT%2FGEOM_Actor.h;h=b8c38bd9e0de3050c9332efa2d78fbd46f54a1a8;hb=b6f0965afb72083a5234f9b4fb0b233adaaf8d9d;hp=f2236aea1f763e1af9ceac7e8f9d0de0f815da73;hpb=9499b99fe2dcb53e1ea364f97986f8f432b04600;p=modules%2Fgeom.git diff --git a/src/OBJECT/GEOM_Actor.h b/src/OBJECT/GEOM_Actor.h index f2236aea1..b8c38bd9e 100644 --- a/src/OBJECT/GEOM_Actor.h +++ b/src/OBJECT/GEOM_Actor.h @@ -1,78 +1,118 @@ -// GEOM OBJECT : interactive object for Geometry entities visualization +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// Copyright (C) 2003-2007 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, or (at your option) any later version. // +// 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 // + +// GEOM OBJECT : interactive object for Geometry entities visualization // File : GEOM_Actor.h // Author : Christophe ATTANASIO // Module : GEOM -// $Header$ - +// #ifndef GEOM_ACTOR_H #define GEOM_ACTOR_H -#include "SALOME_Actor.h" +#include "GEOM_OBJECT_defs.hxx" +#include "GEOM_SmartPtr.h" + +#include -//OpenCASCADE #include -#include +#include class vtkCamera; -class TopoDS_Shape; -#ifdef WNT -#include -#else -#define SALOME_WNT_EXPORT -#endif +class GEOM_VertexSource; +typedef GEOM_SmartPtr PVertexSource; -class SALOME_WNT_EXPORT GEOM_Actor : public SALOME_Actor { - public: - vtkTypeMacro(GEOM_Actor,SALOME_Actor); +class GEOM_EdgeSource; +typedef GEOM_SmartPtr PEdgeSource; +class GEOM_WireframeFace; +typedef GEOM_SmartPtr PWFaceSource; + +class GEOM_ShadingFace; +typedef GEOM_SmartPtr PSFaceSource; + +class vtkRenderer; +class vtkTextActor; + +class vtkAppendPolyData; +typedef GEOM_SmartPtr PAppendFilter; + +class GEOM_OBJECT_EXPORT GEOM_Actor: public SALOME_Actor +{ +public: + vtkTypeMacro(GEOM_Actor,SALOME_Actor) static GEOM_Actor* New(); + void SetShape(const TopoDS_Shape& theShape, + double theDeflection, + bool theIsVector = false); + + void SetDeflection(double theDeflection); + double GetDeflection() const{ return myDeflection;} + + void AddToRender(vtkRenderer* theRenderer); + void RemoveFromRender(vtkRenderer* theRenderer); + + enum EDisplayMode{ eWireframe, eShading, eShadingWithEdges = eShading + 2 }; + +/* void SetDisplayMode(EDisplayMode theMode); */ +/* EDisplayMode GetDisplayMode() const { return myDisplayMode;} */ + + void SetSelected(bool theIsSelected); + bool IsSelected() const { return myIsSelected;} + + // OLD METHODS + // Properties + void SetHighlightProperty(vtkProperty* Prop); + void SetWireframeProperty(vtkProperty* Prop); + void SetShadingProperty(vtkProperty* Prop); + + vtkProperty* GetWireframeProperty(); + vtkProperty* GetShadingProperty(); + vtkProperty* GetIsolatedEdgeProperty(); + vtkProperty* GetVertexProperty(); + vtkProperty* GetStandaloneVertexProperty(); + vtkProperty* GetSharedEdgeProperty(); + vtkProperty* GetFaceEdgeProperty(); + + virtual void setDisplayMode(int thenewmode); + // Description: // This causes the actor to be rendered. It, in turn, will render the actor's // property and then mapper. virtual void Render(vtkRenderer *, vtkMapper *); - // Description: // Release any graphics resources that are being consumed by this actor. // The parameter window could be used to determine which graphic // resources to release. void ReleaseGraphicsResources(vtkWindow *); - const TopoDS_Shape& getTopo(); - void setInputShape(const TopoDS_Shape& ashape,double adef1,int imode); - - double getDeflection(); - void setDeflection(double adefl); + void setInputShape(const TopoDS_Shape& ashape, double adef1, + int imode, bool isVector = false); + double isVector(); // SubShape void SubShapeOn(); void SubShapeOff(); - - // Display Mode - virtual void setDisplayMode(int); // Highlight virtual void highlight(bool theHighlight); @@ -80,49 +120,180 @@ class SALOME_WNT_EXPORT GEOM_Actor : public SALOME_Actor { void ShallowCopy(vtkProp *prop); - // Properties - void SetHighlightProperty(vtkProperty* Prop); - void SetWireframeProperty(vtkProperty* Prop); - void SetShadingProperty(vtkProperty* Prop); - // Opacity - void SetOpacity(vtkFloatingPointType opa); - vtkFloatingPointType GetOpacity(); + void SetOpacity(double opa); + double GetOpacity(); + + // Color (same to all sub-actors/display modes) + void SetColor(double r, double g, double b); + void GetColor(double& r, double& g, double& b); + // Color of points + void SetPointColor(double r, double g, double b); + // Color of standalone edges, wires, vectors + void SetIsolatedEdgeColor(double r, double g, double b); + // Color of shared edges + void SetSharedEdgeColor(double r, double g, double b); + // Color of free edges + void SetFreeEdgeColor(double r, double g, double b); + // Color of edges in shading+edges display mode + void SetEdgesInShadingColor(double r, double g, double b); + // Color of iso-lines + void SetIsosColor(double r, double g, double b); + // Color of labels + void SetLabelColor(double r, double g, double b); - // Color - void SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b); - void GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b); - virtual bool IsInfinite() {return myIsInfinite;} - protected: + // Material + void SetMaterial(std::vector theProps); + vtkProperty* GetFrontMaterial(); + vtkProperty* GetBackMaterial(); + virtual bool IsInfinitive(); + + // overloaded functions + //! To map current selection to VTK representation + virtual + void + Highlight(bool theHighlight); + + //---------------------------------------------------------------------------- + //! To process prehighlight (called from #SVTK_InteractorStyle) + virtual + bool + PreHighlight(vtkInteractorStyle* theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight); + + //! To process highlight (called from #SVTK_InteractorStyle) + virtual + bool + Highlight(vtkInteractorStyle* theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight); + + //! Visibility management + virtual + void + SetVisibility( int ); + + //! IsoLines management + // theNb[0] - number of U lines + // theNb[1] - number of V lines + virtual + void + SetNbIsos(const int theNb[2]); + + virtual + void + GetNbIsos(int &theNbU,int &theNbV); + + virtual + void SetIsosWidth(const int width); + + int GetIsosWidth() const; + + virtual void SetWidth(const int width); + + int GetWidth() const; + + //! Vector mode management + virtual + void + SetVectorMode(const bool theMode); + + virtual + bool + GetVectorMode(); + + //! Vertices mode management + virtual + void + SetVerticesMode(const bool theMode); + + virtual + bool + GetVerticesMode(); + + //! Name mode management + virtual + void + SetNameMode(const bool theMode); + + virtual + bool + GetNameMode(); + + virtual + void + SetTransform(VTKViewer_Transform* theTransform); + + +protected: + void SetModified(); + + void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result); + void SetShapeName(); GEOM_Actor(); ~GEOM_Actor(); - GEOM_Actor(const GEOM_Actor&) {}; - void operator=(const GEOM_Actor&) {}; - void CreateWireframeMapper(); - void CreateShadingMapper(); - void CreateMapper(int theMode); - void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result); +private: + TopoDS_Shape myShape; + bool isOnlyVertex; + double myDeflection; + bool myIsForced; - private: + // EDisplayMode myDisplayMode; + bool myIsSelected; + bool myVectorMode; + bool myVerticesMode; + bool myNameMode; - bool subshape; - bool myIsInfinite; + PDeviceActor myVertexActor; + PVertexSource myVertexSource; - TopoDS_Shape myShape; - double deflection; + PDeviceActor myStandaloneVertexActor; + PVertexSource myStandaloneVertexSource; - vtkMapper* ShadingMapper; - vtkMapper* WireframeMapper; + PDeviceActor myIsolatedEdgeActor; + PEdgeSource myIsolatedEdgeSource; - vtkProperty* ShadingProperty; - vtkProperty* WireframeProperty; - vtkProperty* HighlightProperty; -}; + PDeviceActor myOneFaceEdgeActor; + PEdgeSource myOneFaceEdgeSource; + + PDeviceActor mySharedEdgeActor; + PEdgeSource mySharedEdgeSource; + + PDeviceActor myWireframeFaceActor; + PWFaceSource myWireframeFaceSource; + PDeviceActor myShadingFaceActor; + PSFaceSource myShadingFaceSource; + + PDeviceActor myHighlightActor; + + vtkTextActor* myTextActor; + + vtkSmartPointer myHighlightProp; + vtkSmartPointer myPreHighlightProp; + vtkSmartPointer myShadingFaceProp; + vtkSmartPointer myShadingBackFaceProp; + + PAppendFilter myAppendFilter; + PPolyGeomPainterDataMapper myPolyDataMapper; + + virtual void SetMapper(vtkMapper*); + + GEOM_Actor(const GEOM_Actor&); + void operator=(const GEOM_Actor&); + + double myEdgesInWireframeColor[3]; + double myEdgesInShadingColor[3]; + double myIsolatedEdgeColor[3]; + double mySharedEdgeColor[3]; + double myOneFaceEdgeColor[3]; +}; #endif //GEOM_ACTOR_H +