Salome HOME
Freshly added file
[modules/smesh.git] / src / OBJECT / SMESH_Actor.h
1 //  SMESH OBJECT : interactive object for SMESH visualization
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SMESH_Actor.h
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #ifndef SMESH_ACTOR_H
30 #define SMESH_ACTOR_H
31
32 #include "SALOME_Actor.h"
33
34 // VTK Includes
35 #include <vtkActor.h>
36 #include <vtkDataSetMapper.h>
37 #include <vtkUnstructuredGridReader.h>
38
39 // Open CASCADE Includes
40 #include <TColStd_IndexedMapOfInteger.hxx>
41 #include <TColStd_DataMapOfIntegerInteger.hxx>
42
43 typedef struct rgbStruct
44 {
45   float r;
46   float g;
47   float b;
48 } RGBStruct;
49
50 class SMESH_Actor : public SALOME_Actor {
51
52  public:
53   vtkTypeMacro(SMESH_Actor,SALOME_Actor);
54
55   static SMESH_Actor* New();
56
57   // Description:
58   // This causes the actor to be rendered. It, in turn, will render the actor`s
59   // property and then mapper.
60   virtual void Render(vtkRenderer *, vtkMapper *);
61
62   // Description:
63   // This method is used internally by the rendering process.
64   // We overide the superclass method to properly set the estimated render time.
65   int RenderOpaqueGeometry(vtkViewport *viewport);
66
67   void ShallowCopy(vtkProp *prop);
68
69   void setReader(vtkUnstructuredGridReader* r) ;
70   vtkUnstructuredGridReader* getReader();
71
72   // Highlight
73   virtual bool hasHighlight() { return true; }  
74
75   vtkMapper* getMapper();
76
77   void setDisplayMode(int);
78
79   void SetColor(float r,float g,float b);
80   void GetColor(float& r,float& g,float& b);
81   void SetHighlightColor(float r,float g,float b);
82   void GetHighlightColor(float& r,float& g,float& b);
83   void SetPreselectedColor(float r,float g,float b);
84   void GetPreselectedColor(float& r,float& g,float& b);
85
86   void SetEdgeColor(float r,float g,float b);
87   void GetEdgeColor(float& r,float& g,float& b);
88   void SetEdgeHighlightColor(float r,float g,float b);
89   void GetEdgeHighlightColor(float& r,float& g,float& b);
90   void SetEdgePreselectedColor(float r,float g,float b);
91   void GetEdgePreselectedColor(float& r,float& g,float& b);
92
93   void SetNodeColor(float r,float g,float b);
94   void GetNodeColor(float& r,float& g,float& b);
95  
96   void SetNodeSize(int size) ;
97   int  GetNodeSize() ;
98
99
100   void ClearNode();
101   void ClearElement();
102
103   void RemoveNode(int idSMESHDSnode);
104   void RemoveElement(int idSMESHDSelement);
105
106   void AddNode(int idSMESHDSnode, int idVTKnode);
107   void AddElement(int idSMESHDSelement, int idVTKelement);
108
109   int GetIdVTKNode(int idSMESHDSnode);
110   int GetIdVTKElement(int idSMESHDSelement);
111
112   int GetIdSMESHDSNode(int idVTKnode);
113   int GetIdSMESHDSElement(int idVTKelement);
114
115   void SetIdsVTKNode(const TColStd_DataMapOfIntegerInteger& mapVTK);
116   void SetIdsSMESHDSNode(const TColStd_DataMapOfIntegerInteger& mapSMESHDS);
117
118   void SetIdsVTKElement(const TColStd_DataMapOfIntegerInteger& mapVTK);
119   void SetIdsSMESHDSElement(const TColStd_DataMapOfIntegerInteger& mapSMESHDS);
120
121   vtkDataSet* DataSource;
122   vtkActor*   EdgeDevice;
123   vtkActor*   EdgeShrinkDevice;
124
125   float GetShrinkFactor();
126   void  SetShrinkFactor(float value );
127
128   void GetChildActors(vtkActorCollection*);
129
130   void SetVisibility(bool visibility);
131
132  protected:
133
134   SMESH_Actor();
135   ~SMESH_Actor();
136   SMESH_Actor(const SMESH_Actor&) {};
137   void operator=(const SMESH_Actor&) {};
138
139   vtkUnstructuredGridReader* myReader;
140
141   float myShrinkFactor;
142
143   RGBStruct edgeColor;
144   RGBStruct edgeHighlightColor;
145   RGBStruct edgePreselectedColor;
146
147   RGBStruct actorColor;
148   RGBStruct actorHighlightColor;
149   RGBStruct actorPreselectedColor;
150
151   RGBStruct actorNodeColor; // LPN
152   int       actorNodeSize;  // LPN
153
154 };
155 #endif //SMESH_ACTOR_H