1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VISU_MeshAct.cxx
25 // Author : Laurent CORNABE with the help of Nicolas REJNERI
29 #include "VISU_MeshAct.h"
30 #include "SALOME_PassThroughFilter.h"
32 #include <vtkFeatureEdges.h>
33 #include <vtkDataSetMapper.h>
34 #include <vtkDataSet.h>
36 vtkStandardNewMacro(VISU_MeshAct);
38 VISU_MeshAct::VISU_MeshAct(){
39 mySurfaceActor = VISU_Actor::New();
40 mySurfaceActor->SetParent(this);
41 mySurfaceActor->GetProperty()->FrontfaceCullingOff();
42 mySurfaceActor->GetProperty()->BackfaceCullingOff();
43 mySurfaceActor->SetRepresentation(2); //SURFACE
45 myEdgeActor = VISU_Actor::New();
46 myEdgeActor->SetParent(this);
47 myEdgeActor->PickableOff();
48 myEdgeActor->GetProperty()->FrontfaceCullingOff();
49 myEdgeActor->GetProperty()->BackfaceCullingOff();
50 myEdgeActor->SetRepresentation(1); //WIREFRAME
52 myNodeActor = VISU_Actor::New();
53 myNodeActor->SetParent(this);
54 myNodeActor->PickableOff();
55 myNodeActor->GetProperty()->SetPointSize(SALOME_POINT_SIZE);
56 myNodeActor->GetProperty()->FrontfaceCullingOff();
57 myNodeActor->GetProperty()->BackfaceCullingOff();
58 myNodeActor->SetRepresentation(0); //POINT
60 SetRepresentation(2); //SURFACE
63 VISU_MeshAct::~VISU_MeshAct(){
64 mySurfaceActor->Delete();
65 myEdgeActor->Delete();
66 myNodeActor->Delete();
69 void VISU_MeshAct::setIO(const Handle(SALOME_InteractiveObject)& theIO){
70 mySurfaceActor->setIO(theIO);
71 myEdgeActor->setIO(theIO);
72 myNodeActor->setIO(theIO);
75 void VISU_MeshAct::SetPrs3d(VISU::Prs3d_i* thePrs3d){
77 VISU_Actor::SetPrs3d(thePrs3d);
78 mySurfaceActor->SetPrs3d(thePrs3d);
79 myEdgeActor->SetPrs3d(thePrs3d);
80 myNodeActor->SetPrs3d(thePrs3d);
84 void VISU_MeshAct::AddToRender(vtkRenderer* theRenderer){
85 theRenderer->AddActor(mySurfaceActor);
86 theRenderer->AddActor(myEdgeActor);
87 theRenderer->AddActor(myNodeActor);
90 void VISU_MeshAct::RemoveFromRender(vtkRenderer* theRenderer){
91 theRenderer->RemoveActor(mySurfaceActor);
92 theRenderer->RemoveActor(myEdgeActor);
93 theRenderer->RemoveActor(myNodeActor);
96 void VISU_MeshAct::SetPipeLine(VISU_PipeLine* thePipeLine) throw(std::runtime_error&){
97 VISU_Actor::SetPipeLine(thePipeLine);
98 mySurfaceActor->SetPipeLine(thePipeLine);
99 myEdgeActor->SetPipeLine(thePipeLine);
100 myNodeActor->SetPipeLine(thePipeLine);
103 void VISU_MeshAct::SetTransform(SALOME_Transform* theTransform){
104 mySurfaceActor->SetTransform(theTransform);
105 myEdgeActor->SetTransform(theTransform);
106 myNodeActor->SetTransform(theTransform);
109 void VISU_MeshAct::SetShrinkable(bool theIsShrinkable){
110 VISU_Actor::SetShrinkable(theIsShrinkable);
111 mySurfaceActor->SetShrinkable(theIsShrinkable);
112 myEdgeActor->SetShrinkable(theIsShrinkable);
113 myNodeActor->SetShrinkable(theIsShrinkable);
116 vtkProperty* VISU_MeshAct::GetProperty(){
117 mySurfaceActor->GetProperty();
120 void VISU_MeshAct::SetProperty(vtkProperty* theProperty){
121 mySurfaceActor->SetProperty(theProperty);
124 vtkProperty* VISU_MeshAct::GetEdgeProperty(){
125 myEdgeActor->GetProperty();
128 void VISU_MeshAct::SetEdgeProperty(vtkProperty* theProperty){
129 myEdgeActor->SetProperty(theProperty);
132 vtkProperty* VISU_MeshAct::GetNodeProperty(){
133 myNodeActor->GetProperty();
136 void VISU_MeshAct::SetNodeProperty(vtkProperty* theProperty){
137 myNodeActor->SetProperty(theProperty);
140 void VISU_MeshAct::SetLineWidth(float theLineWidth){
141 GetEdgeProperty()->SetLineWidth(theLineWidth);
144 float VISU_MeshAct::GetLineWidth(){
145 return GetEdgeProperty()->GetLineWidth();
148 void VISU_MeshAct::SetShrink(float theFactor){
149 VISU_Actor::SetShrink(theFactor);
150 mySurfaceActor->SetShrink(theFactor);
151 myEdgeActor->SetShrink(theFactor);
152 SetRepresentation(GetRepresentation());
155 void VISU_MeshAct::UnShrink(){
156 VISU_Actor::UnShrink();
157 mySurfaceActor->UnShrink();
158 myEdgeActor->UnShrink();
159 SetRepresentation(GetRepresentation());
162 void VISU_MeshAct::SetRepresentation(int theMode){
163 SALOME_Actor::SetRepresentation(theMode);
164 mySurfaceActor->VisibilityOff();
165 myEdgeActor->VisibilityOff();
166 myNodeActor->VisibilityOff();
169 myNodeActor->VisibilityOn();
172 myEdgeActor->VisibilityOn();
173 myEdgeActor->SetRepresentation(1);
176 mySurfaceActor->VisibilityOn();
178 case 3: //INSIDEFRAME
179 myEdgeActor->VisibilityOn();
180 myEdgeActor->SetRepresentation(3);
182 case 4: //SURFACEFRAME
183 myEdgeActor->VisibilityOn();
184 myEdgeActor->SetRepresentation(1);
185 mySurfaceActor->VisibilityOn();
190 void VISU_MeshAct::SetVisibility(int theMode){
191 VISU_Actor::SetVisibility(theMode);
193 SetRepresentation(GetRepresentation());
195 myNodeActor->VisibilityOff();
196 myEdgeActor->VisibilityOff();
197 mySurfaceActor->VisibilityOff();