1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_NodeLabelActor.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ObjectDef.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMDS_UnstructuredGrid.hxx"
36 #include "SMESH_ScalarBarActor.h"
37 #include "VTKViewer_ExtractUnstructuredGrid.h"
38 #include "VTKViewer_FramedTextActor.h"
39 #include "SALOME_InteractiveObject.hxx"
40 #include "SMESH_SVTKActor.h"
42 #include "SUIT_Session.h"
43 #include "SUIT_ResourceMgr.h"
47 #ifndef DISABLE_PLOT2DVIEWER
48 #include <SPlot2d_Histogram.h>
51 #include <vtkProperty.h>
52 #include <vtkTimeStamp.h>
53 #include <vtkObjectFactory.h>
54 #include <vtkShrinkPolyData.h>
55 #include <vtkMergeFilter.h>
57 #include <vtkMatrix4x4.h>
58 #include <vtkUnstructuredGrid.h>
59 #include <vtkPointData.h>
60 #include <vtkCellData.h>
62 #include <vtkMapper.h>
63 #include <vtkRenderer.h>
66 #include <vtkIdList.h>
67 #include <vtkIntArray.h>
69 #include <vtkActor2D.h>
70 #include <vtkProperty2D.h>
71 #include <vtkPolyData.h>
72 #include <vtkTextProperty.h>
74 #include <vtkLookupTable.h>
78 #include <vtkImplicitBoolean.h>
79 #include <vtkImplicitFunctionCollection.h>
81 #include <vtkConfigure.h>
82 #if !defined(VTK_XVERSION)
83 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
86 #include "utilities.h"
89 static int MYDEBUG = 1;
91 static int MYDEBUG = 1;
94 static int aLineWidthInc = 2;
97 SMESH_ActorDef* SMESH_ActorDef::New(){
98 return new SMESH_ActorDef();
102 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
103 const char* theEntry,
107 SMESH_ActorDef* anActor = NULL;
108 if(theVisualObj->IsValid() ) {
109 anActor = SMESH_ActorDef::New();
110 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
115 anActor->UpdateScalarBar();
121 SMESH_ActorDef::SMESH_ActorDef()
123 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
124 myBaseActor = SMESH_DeviceActor::New();
126 myTimeStamp = vtkTimeStamp::New();
128 myIsPointsVisible = false;
129 myIsEntityModeCache = false;
131 myHighlightActor = SMESH_SVTKActor::New();
132 myHighlightActor->Delete(); // vtkSmartPointer!
133 myHighlightActor->Initialize();
135 myPreHighlightActor = SMESH_SVTKActor::New();
136 myPreHighlightActor->Delete();
137 myPreHighlightActor->Initialize();
139 myIsShrinkable = false;
142 myIsFacesOriented = false;
144 myControlsPrecision = -1;
145 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
147 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
148 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
150 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
151 vtkFloatingPointType aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
152 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
153 vtkFloatingPointType aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
155 int aSizeNd = mgr->integerValue( "SMESH", "numbering_node_size", 10 );
156 SMESH::LabelFont aFamilyNd = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_node_font", 2 ) );
157 bool aBoldNd = mgr->booleanValue( "SMESH", "numbering_node_bold", true );
158 bool anItalicNd = mgr->booleanValue( "SMESH", "numbering_node_italic", false );
159 bool aShadowNd = mgr->booleanValue( "SMESH", "numbering_node_shadow", false );
160 vtkFloatingPointType anRGBNd[3] = {1,1,1};
161 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
163 int aSizeEl = mgr->integerValue( "SMESH", "numbering_elem_size", 12 );
164 SMESH::LabelFont aFamilyEl = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_elem_font", 2 ) );
165 bool aBoldEl = mgr->booleanValue( "SMESH", "numbering_elem_bold", true );
166 bool anItalicEl = mgr->booleanValue( "SMESH", "numbering_elem_italic", false );
167 bool aShadowEl = mgr->booleanValue( "SMESH", "numbering_elem_shadow", false );
168 vtkFloatingPointType anRGBEl[3] = {0,1,0};
169 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
171 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
172 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
174 //Definition 2D and 3D devices of the actor
175 //-----------------------------------------
176 vtkFloatingPointType anRGB[3] = {1,1,1};
177 mySurfaceProp = vtkProperty::New();
180 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
181 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
182 myDeltaBrightness = delta;
184 myBackSurfaceProp = vtkProperty::New();
185 bfc = Qtx::mainColorToSecondary(ffc, delta);
186 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
188 myNormalVProp = vtkProperty::New();
189 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
190 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
191 myDeltaVBrightness = delta;
193 myReversedVProp = vtkProperty::New();
194 bfc = Qtx::mainColorToSecondary(ffc, delta);
195 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
197 my2DActor = SMESH_CellLabelActor::New();
198 my2DActor->SetStoreGemetryMapping(true);
199 my2DActor->SetUserMatrix(aMatrix);
200 my2DActor->PickableOff();
201 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
202 my2DActor->SetProperty(mySurfaceProp);
203 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
204 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
205 aFilter = my2DActor->GetExtractUnstructuredGrid();
206 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
207 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
208 aFilter->RegisterCellsWithType(VTK_POLYGON);
209 aFilter->RegisterCellsWithType(VTK_QUAD);
210 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
211 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
212 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
214 my2DExtProp = vtkProperty::New();
215 my2DExtProp->DeepCopy(mySurfaceProp);
216 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
217 anRGB[0] = 1 - anRGB[0];
218 anRGB[1] = 1 - anRGB[1];
219 anRGB[2] = 1 - anRGB[2];
220 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
222 my2DExtActor = SMESH_DeviceActor::New();
223 my2DExtActor->SetUserMatrix(aMatrix);
224 my2DExtActor->PickableOff();
225 my2DExtActor->SetProperty(my2DExtProp);
226 my2DExtActor->SetBackfaceProperty(my2DExtProp);
227 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
228 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
229 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
230 aFilter->RegisterCellsWithType(VTK_POLYGON);
231 aFilter->RegisterCellsWithType(VTK_QUAD);
232 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
233 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
234 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
236 my3DActor = SMESH_CellLabelActor::New();
237 my3DActor->SetStoreGemetryMapping(true);
238 my3DActor->SetUserMatrix(aMatrix);
239 my3DActor->PickableOff();
240 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
241 my3DActor->SetProperty(myNormalVProp);
242 my3DActor->SetBackfaceProperty(myReversedVProp);
243 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
244 my3DActor->SetCoincident3DAllowed(true);
245 aFilter = my3DActor->GetExtractUnstructuredGrid();
246 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
247 aFilter->RegisterCellsWithType(VTK_TETRA);
248 aFilter->RegisterCellsWithType(VTK_VOXEL);
249 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
250 aFilter->RegisterCellsWithType(VTK_WEDGE);
251 aFilter->RegisterCellsWithType(VTK_PYRAMID);
252 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
253 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
255 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
256 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
257 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
258 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
259 //#ifdef VTK_HAVE_POLYHEDRON
260 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
261 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
264 my3DExtProp = vtkProperty::New();
265 my3DExtProp->DeepCopy(myNormalVProp);
266 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
267 anRGB[0] = 1 - anRGB[0];
268 anRGB[1] = 1 - anRGB[1];
269 anRGB[2] = 1 - anRGB[2];
270 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
272 my3DExtActor = SMESH_DeviceActor::New();
273 my3DExtActor->SetUserMatrix(aMatrix);
274 my3DExtActor->PickableOff();
275 my3DExtActor->SetProperty(my3DExtProp);
276 my3DExtActor->SetBackfaceProperty(my3DExtProp);
277 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
278 my3DExtActor->SetCoincident3DAllowed(true);
279 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
280 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
281 aFilter->RegisterCellsWithType(VTK_TETRA);
282 aFilter->RegisterCellsWithType(VTK_VOXEL);
283 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
284 aFilter->RegisterCellsWithType(VTK_WEDGE);
285 aFilter->RegisterCellsWithType(VTK_PYRAMID);
286 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
287 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
288 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
289 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
290 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
291 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
292 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
293 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
295 //Definition 1D device of the actor
296 //---------------------------------
297 myEdgeProp = vtkProperty::New();
298 myEdgeProp->SetAmbient(1.0);
299 myEdgeProp->SetDiffuse(0.0);
300 myEdgeProp->SetSpecular(0.0);
301 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
302 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
303 myEdgeProp->SetLineWidth(aLineWidth);
305 my1DActor = SMESH_CellLabelActor::New();
306 my1DActor->SetStoreGemetryMapping(true);
307 my1DActor->SetUserMatrix(aMatrix);
308 my1DActor->PickableOff();
309 my1DActor->SetHighlited(true);
310 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
311 my1DActor->SetProperty(myEdgeProp);
312 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
313 aFilter = my1DActor->GetExtractUnstructuredGrid();
314 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
315 aFilter->RegisterCellsWithType(VTK_LINE);
316 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
318 my1DProp = vtkProperty::New();
319 my1DProp->DeepCopy(myEdgeProp);
320 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
321 my1DProp->SetPointSize(aElem0DSize);
323 my1DExtProp = vtkProperty::New();
324 my1DExtProp->DeepCopy(myEdgeProp);
325 anRGB[0] = 1 - anRGB[0];
326 anRGB[1] = 1 - anRGB[1];
327 anRGB[2] = 1 - anRGB[2];
328 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
329 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
330 my1DExtProp->SetPointSize(aElem0DSize);
332 my1DExtActor = SMESH_DeviceActor::New();
333 my1DExtActor->SetUserMatrix(aMatrix);
334 my1DExtActor->PickableOff();
335 my1DExtActor->SetHighlited(true);
336 my1DExtActor->SetVisibility(false);
337 my1DExtActor->SetProperty(my1DExtProp);
338 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
339 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
340 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
341 aFilter->RegisterCellsWithType(VTK_LINE);
342 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
345 //Definition 0D device of the actor (0d elements)
346 //-----------------------------------------------
347 my0DProp = vtkProperty::New();
348 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
349 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
350 my0DProp->SetPointSize(aElem0DSize);
352 my0DActor = SMESH_CellLabelActor::New();
353 my0DActor->SetUserMatrix(aMatrix);
354 my0DActor->SetStoreGemetryMapping(true);
355 my0DActor->PickableOff();
356 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
357 my0DActor->SetVisibility(false);
358 my0DActor->SetProperty(my0DProp);
359 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
360 aFilter = my0DActor->GetExtractUnstructuredGrid();
361 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
362 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
363 aFilter->RegisterCellsWithType(VTK_VERTEX);
365 //Definition 0D device of the actor (ball elements)
366 //-----------------------------------------------
367 myBallProp = vtkProperty::New();
368 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
369 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
370 myBallProp->SetPointSize(aBallElemSize);
372 myBallActor = SMESH_CellLabelActor::New();
373 myBallActor->SetUserMatrix(aMatrix);
374 myBallActor->SetStoreGemetryMapping(true);
375 myBallActor->PickableOff();
376 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
377 myBallActor->SetVisibility(false);
378 myBallActor->SetProperty(myBallProp);
379 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
380 aFilter = myBallActor->GetExtractUnstructuredGrid();
381 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
382 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
384 //my0DExtProp = vtkProperty::New();
385 //my0DExtProp->DeepCopy(my0DProp);
386 //anRGB[0] = 1 - anRGB[0];
387 //anRGB[1] = 1 - anRGB[1];
388 //anRGB[2] = 1 - anRGB[2];
389 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
390 //my0DExtProp->SetPointSize(aElem0DSize);
392 //my0DExtActor = SMESH_DeviceActor::New();
393 //my0DExtActor->SetUserMatrix(aMatrix);
394 //my0DExtActor->SetStoreClippingMapping(true);
395 //my0DExtActor->PickableOff();
396 //my0DExtActor->SetHighlited(true);
397 //my0DExtActor->SetVisibility(false);
398 //my0DExtActor->SetProperty(my0DExtProp);
399 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
400 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
401 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
402 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
403 //aFilter->RegisterCellsWithType(VTK_VERTEX);
406 //Definition 0D device of the actor (nodes)
407 //-----------------------------------------
408 myNodeProp = vtkProperty::New();
409 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
410 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
412 myNodeActor = SMESH_NodeLabelActor::New();
413 myNodeActor->SetUserMatrix(aMatrix);
414 myNodeActor->SetStoreClippingMapping(true);
415 myNodeActor->PickableOff();
416 myNodeActor->SetVisibility(false);
417 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
418 myNodeActor->SetProperty(myNodeProp);
419 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
420 aFilter = myNodeActor->GetExtractUnstructuredGrid();
421 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
423 myNodeExtProp = vtkProperty::New();
424 myNodeExtProp->DeepCopy(myNodeProp);
425 anRGB[0] = 1 - anRGB[0];
426 anRGB[1] = 1 - anRGB[1];
427 anRGB[2] = 1 - anRGB[2];
428 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
430 myNodeExtActor = SMESH_DeviceActor::New();
431 myNodeExtActor->SetUserMatrix(aMatrix);
432 myNodeExtActor->SetStoreClippingMapping(true);
433 myNodeExtActor->PickableOff();
434 myNodeExtActor->SetHighlited(true);
435 myNodeExtActor->SetVisibility(false);
436 myNodeExtActor->SetProperty(myNodeExtProp);
437 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
438 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
439 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
440 aFilter->RegisterCellsWithType(VTK_VERTEX);
442 //Definition of Pickable and Highlitable engines
443 //----------------------------------------------
445 myBaseActor->SetUserMatrix(aMatrix);
446 myBaseActor->SetStoreGemetryMapping(true);
447 myBaseActor->GetProperty()->SetOpacity(0.0);
448 myPickableActor = myBaseActor;
450 myHighlightProp = vtkProperty::New();
451 myHighlightProp->SetAmbient(1.0);
452 myHighlightProp->SetDiffuse(0.0);
453 myHighlightProp->SetSpecular(0.0);
454 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
455 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
456 myHighlightProp->SetPointSize(aElem0DSize); // ??
457 myHighlightProp->SetLineWidth(aLineWidth);
458 myHighlightProp->SetRepresentation(1);
460 myBallHighlightProp = vtkProperty::New();
461 myBallHighlightProp->DeepCopy(myHighlightProp);
462 myBallHighlightProp->SetPointSize(aBallElemSize);
465 myOutLineProp = vtkProperty::New();
466 myOutLineProp->SetAmbient(1.0);
467 myOutLineProp->SetDiffuse(0.0);
468 myOutLineProp->SetSpecular(0.0);
469 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
470 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
471 myOutLineProp->SetLineWidth(aOutlineWidth);
472 myOutLineProp->SetRepresentation(1);
474 myPreselectProp = vtkProperty::New();
475 myPreselectProp->SetAmbient(1.0);
476 myPreselectProp->SetDiffuse(0.0);
477 myPreselectProp->SetSpecular(0.0);
478 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
479 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
480 myPreselectProp->SetPointSize(aElem0DSize); // ??
481 myPreselectProp->SetLineWidth(aLineWidth);
482 myPreselectProp->SetRepresentation(1);
484 myBallPreselectProp = vtkProperty::New();
485 myBallPreselectProp->DeepCopy(myPreselectProp);
486 myBallPreselectProp->SetPointSize(aBallElemSize);
488 myHighlitableActor = SMESH_DeviceActor::New();
489 myHighlitableActor->SetUserMatrix(aMatrix);
490 myHighlitableActor->PickableOff();
491 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
492 myHighlitableActor->SetCoincident3DAllowed(true);
499 myControlMode = eNone;
500 myControlActor = my2DActor;
502 //Definition of myScalarBarActor
503 //------------------------------
504 myLookupTable = vtkLookupTable::New();
505 //Fix for Bug PAL5195 - SMESH764:
506 //Controls - Aspect Ratio: incorrect colors of the best and worst values
507 myLookupTable->SetHueRange(0.667,0.0);
509 myScalarBarActor = SMESH_ScalarBarActor::New();
510 myScalarBarActor->SetVisibility(false);
511 myScalarBarActor->SetLookupTable(myLookupTable);
514 //Incorrect "Min value" in Scalar Bar in Mesh:
515 // myScalarBarActor->SetLabelFormat("%.4g");
516 // changes was commented because of regression bug IPAL 19981
518 mgr = SUIT_Session::session()->resourceMgr();
522 myEntityMode = eAllEntity;
523 myEntityModeCache = eAllEntity;
526 myImplicitBoolean = vtkImplicitBoolean::New();
527 myImplicitBoolean->SetOperationTypeToIntersection();
529 //Quadratic 2D elements representation
530 //-----------------------------------------------------------------------------
531 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
532 if(aQuadratic2DMode == 0){
533 myHighlitableActor->SetQuadraticArcMode(false);
534 my2DActor->SetQuadraticArcMode(false);
535 my1DActor->SetQuadraticArcMode(false);
537 else if(aQuadratic2DMode == 1){
538 myHighlitableActor->SetQuadraticArcMode(true);
539 my2DActor->SetQuadraticArcMode(true);
540 my1DActor->SetQuadraticArcMode(true);
543 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
544 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
545 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
547 // Set colors of the name actor
548 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
549 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
550 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
551 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
553 #ifndef DISABLE_PLOT2DVIEWER
557 SetBallSize(aBallElemSize);
558 Set0DSize(aElem0DSize);
562 SMESH_ActorDef::~SMESH_ActorDef()
564 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
566 // Please keep the order same as one in the header file
568 myTimeStamp->Delete();
570 myScalarBarActor->Delete();
571 myLookupTable->Delete();
573 mySurfaceProp->Delete();
574 myBackSurfaceProp->Delete();
575 myNormalVProp->Delete();
576 myReversedVProp->Delete();
577 myEdgeProp->Delete();
578 myNodeProp->Delete();
580 myNodeActor->Delete();
581 myBaseActor->Delete();
582 //myPickableActor->Delete(); myPickableActor == myBaseActor
584 myHighlightProp->Delete();
585 myOutLineProp->Delete();
586 myPreselectProp->Delete();
588 myBallHighlightProp->Delete();
589 myBallPreselectProp->Delete();
591 myHighlitableActor->Delete();
593 my2DExtProp->Delete();
594 my3DExtProp->Delete();
596 my2DExtActor->Delete();
598 my3DExtActor->Delete();
599 // myControlActor->Delete(); myControlActor == my2DActor
601 myNodeExtProp->Delete();
602 myNodeExtActor->Delete();
606 my1DExtProp->Delete();
607 my1DExtActor->Delete();
611 myBallProp->Delete();
612 myBallActor->Delete();
613 //my0DExtProp->Delete();
614 //my0DExtActor->Delete();
616 myImplicitBoolean->Delete();
618 #ifndef DISABLE_PLOT2DVIEWER
620 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
621 delete my2dHistogram;
626 void SMESH_ActorDef::Delete()
628 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
629 // from the actor's destructor) will be thrown before removing the actor's observers,
630 // that is done inside the Superclass::Delete() method but before the destructor itself
631 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
632 // The event is caught by SMESHGUI::ProcessEvents() static method.
633 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
635 Superclass::Delete();
638 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
641 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
642 SetRepresentation(GetRepresentation());
643 myTimeStamp->Modified();
647 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
648 bool theBold, bool theItalic, bool theShadow,
649 vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
652 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
653 SetRepresentation( GetRepresentation() );
654 myTimeStamp->Modified();
658 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
659 bool theBold, bool theItalic, bool theShadow,
660 vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
663 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
664 SetRepresentation( GetRepresentation() );
665 myTimeStamp->Modified();
668 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
669 SetRepresentation( GetRepresentation() );
670 myTimeStamp->Modified();
673 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
674 SetRepresentation( GetRepresentation() );
675 myTimeStamp->Modified();
678 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
679 SetRepresentation( GetRepresentation() );
680 myTimeStamp->Modified();
683 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
684 SetRepresentation( GetRepresentation() );
685 myTimeStamp->Modified();
689 bool SMESH_ActorDef::GetPointsLabeled() {
690 return myNodeActor && myNodeActor->GetPointsLabeled();
693 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
696 my3DActor->SetCellsLabeled(theIsCellsLabeled);
699 my2DActor->SetCellsLabeled(theIsCellsLabeled);
702 my1DActor->SetCellsLabeled(theIsCellsLabeled);
705 my0DActor->SetCellsLabeled(theIsCellsLabeled);
708 myBallActor->SetCellsLabeled(theIsCellsLabeled);
710 myTimeStamp->Modified();
714 bool SMESH_ActorDef::GetCellsLabeled() {
717 result = result || my3DActor->GetCellsLabeled();
720 result = result || my2DActor->GetCellsLabeled();
723 result = result || my1DActor->GetCellsLabeled();
726 result = result || my0DActor->GetCellsLabeled();
729 result = result || myBallActor->GetCellsLabeled();
735 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
737 myIsFacesOriented = theIsFacesOriented;
739 my2DActor->SetFacesOriented(theIsFacesOriented);
740 my3DActor->SetFacesOriented(theIsFacesOriented);
742 myTimeStamp->Modified();
745 bool SMESH_ActorDef::GetFacesOriented()
747 return myIsFacesOriented;
750 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
752 my2DActor->SetFacesOrientationColor( r, g, b );
753 my3DActor->SetFacesOrientationColor( r, g, b );
756 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
758 my3DActor->GetFacesOrientationColor( r, g, b );
761 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
763 my2DActor->SetFacesOrientationScale( theScale );
764 my3DActor->SetFacesOrientationScale( theScale );
767 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
769 return my3DActor->GetFacesOrientationScale();
772 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
774 my2DActor->SetFacesOrientation3DVectors( theState );
775 my3DActor->SetFacesOrientation3DVectors( theState );
778 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
780 return my3DActor->GetFacesOrientation3DVectors();
786 SetControlMode(eControl theMode)
788 SetControlMode(theMode,true);
794 SetControlMode(eControl theMode,
795 bool theCheckEntityMode)
797 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
801 myControlMode = eNone;
802 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
804 my0DActor->GetMapper()->SetScalarVisibility(false);
805 my1DActor->GetMapper()->SetScalarVisibility(false);
806 my2DActor->GetMapper()->SetScalarVisibility(false);
807 my3DActor->GetMapper()->SetScalarVisibility(false);
808 myBallActor->GetMapper()->SetScalarVisibility(false);
809 myScalarBarActor->SetVisibility(false);
811 bool anIsScalarVisible = theMode > eNone;
813 if(anIsScalarVisible) {
817 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
818 aControl->SetPrecision( myControlsPrecision );
819 myFunctor.reset( aControl );
820 myControlActor = my1DActor;
825 myFunctor.reset(new SMESH::Controls::Length2D());
826 myControlActor = my2DActor;
830 myFunctor.reset(new SMESH::Controls::FreeBorders());
831 myControlActor = my1DActor;
834 myFunctor.reset(new SMESH::Controls::FreeEdges());
835 myControlActor = my2DActor;
838 myFunctor.reset(new SMESH::Controls::FreeNodes());
839 myControlActor = myNodeActor;
842 myFunctor.reset(new SMESH::Controls::FreeFaces());
843 myControlActor = my2DActor;
845 case eCoincidentNodes:
847 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
848 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
849 cn->SetTolerance( tol );
851 myControlActor = myNodeActor;
854 case eCoincidentElems1D:
855 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
856 myControlActor = my1DActor;
858 case eCoincidentElems2D:
859 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
860 myControlActor = my2DActor;
862 case eCoincidentElems3D:
863 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
864 myControlActor = my3DActor;
866 case eBareBorderFace:
867 myFunctor.reset(new SMESH::Controls::BareBorderFace());
868 myControlActor = my2DActor;
870 case eOverConstrainedFace:
871 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
872 myControlActor = my2DActor;
874 case eMultiConnection:
875 myFunctor.reset(new SMESH::Controls::MultiConnection());
876 myControlActor = my1DActor;
878 case eMultiConnection2D:
879 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
880 myControlActor = my2DActor;
884 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
885 aControl->SetPrecision( myControlsPrecision );
886 myFunctor.reset( aControl );
887 myControlActor = my2DActor;
892 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
893 aControl->SetPrecision( myControlsPrecision );
894 myFunctor.reset( aControl );
895 myControlActor = my2DActor;
900 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
901 aControl->SetPrecision( myControlsPrecision );
902 myFunctor.reset( aControl );
903 myControlActor = my2DActor;
908 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
909 aControl->SetPrecision( myControlsPrecision );
910 myFunctor.reset( aControl );
911 myControlActor = my3DActor;
916 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
917 aControl->SetPrecision( myControlsPrecision );
918 myFunctor.reset( aControl );
919 myControlActor = my3DActor;
922 case eMaxElementLength2D:
924 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
925 aControl->SetPrecision( myControlsPrecision );
926 myFunctor.reset( aControl );
927 myControlActor = my2DActor;
930 case eMaxElementLength3D:
932 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
933 aControl->SetPrecision( myControlsPrecision );
934 myFunctor.reset( aControl );
935 myControlActor = my3DActor;
938 case eBareBorderVolume:
940 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
941 myControlActor = my3DActor;
944 case eOverConstrainedVolume:
946 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
947 myControlActor = my3DActor;
952 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
953 aControl->SetPrecision( myControlsPrecision );
954 myFunctor.reset( aControl );
955 myControlActor = my2DActor;
960 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
961 aControl->SetPrecision( myControlsPrecision );
962 myFunctor.reset( aControl );
963 myControlActor = my2DActor;
968 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
969 aControl->SetPrecision( myControlsPrecision );
970 myFunctor.reset( aControl );
971 myControlActor = my2DActor;
978 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
979 vtkIdType aNbCells = aGrid->GetNumberOfCells();
981 myControlMode = theMode;
982 switch(myControlMode){
984 case eCoincidentNodes:
985 myNodeExtActor->SetExtControlMode(myFunctor);
989 case eCoincidentElems1D:
990 my1DExtActor->SetExtControlMode(myFunctor);
993 case eBareBorderFace:
994 case eOverConstrainedFace:
995 case eCoincidentElems2D:
996 my2DExtActor->SetExtControlMode(myFunctor);
998 case eBareBorderVolume:
999 case eOverConstrainedVolume:
1000 case eCoincidentElems3D:
1001 my3DExtActor->SetExtControlMode(myFunctor);
1004 case eMultiConnection2D:
1005 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1006 UpdateDistribution();
1009 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1010 UpdateDistribution();
1014 if(theCheckEntityMode) {
1015 if(myControlActor == my1DActor) {
1016 if (!myIsEntityModeCache){
1017 myEntityModeCache = GetEntityMode();
1018 myIsEntityModeCache=true;
1020 SetEntityMode(eEdges);
1022 else if(myControlActor == my2DActor) {
1023 switch(myControlMode) {
1027 case eMultiConnection2D:
1028 if (!myIsEntityModeCache){
1029 myEntityModeCache = GetEntityMode();
1030 myIsEntityModeCache=true;
1032 SetEntityMode(eFaces);
1035 if (!myIsEntityModeCache){
1036 myEntityModeCache = GetEntityMode();
1037 myIsEntityModeCache=true;
1039 SetEntityMode(eFaces);
1041 }else if(myControlActor == my3DActor) {
1042 if (!myIsEntityModeCache){
1043 myEntityModeCache = GetEntityMode();
1044 myIsEntityModeCache=true;
1046 SetEntityMode(eVolumes);
1052 if(theCheckEntityMode){
1053 myEntityMode = myEntityModeCache;
1054 myIsEntityModeCache = false;
1059 SetRepresentation(GetRepresentation());
1061 myTimeStamp->Modified();
1067 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
1069 //myHighlightActor->AddToRender(theRenderer);
1071 theRenderer->AddActor(myBaseActor);
1072 theRenderer->AddActor(myNodeExtActor);
1073 theRenderer->AddActor(my1DExtActor);
1075 my3DActor ->AddToRender(theRenderer);
1076 my3DExtActor->AddToRender(theRenderer);
1077 my2DActor ->AddToRender(theRenderer);
1078 my2DExtActor->AddToRender(theRenderer);
1079 myNodeActor ->AddToRender(theRenderer);
1080 my1DActor ->AddToRender(theRenderer);
1081 my0DActor ->AddToRender(theRenderer);
1082 myBallActor ->AddToRender(theRenderer);
1083 //theRenderer->AddActor(my0DExtActor);
1085 theRenderer->AddActor(myHighlitableActor);
1087 theRenderer->AddActor2D(myScalarBarActor);
1089 // the superclass' method should be called at the end
1090 // (in particular, for correct work of selection)
1091 SALOME_Actor::AddToRender(theRenderer);
1094 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1095 SALOME_Actor::RemoveFromRender(theRenderer);
1097 theRenderer->RemoveActor(myBaseActor);
1099 theRenderer->RemoveActor(myNodeExtActor);
1101 theRenderer->RemoveActor(myHighlitableActor);
1103 //theRenderer->RemoveActor(my0DExtActor);
1105 theRenderer->RemoveActor(my1DExtActor);
1107 my2DActor->RemoveFromRender(theRenderer);
1108 my2DExtActor->RemoveFromRender(theRenderer);
1109 my3DActor->RemoveFromRender(theRenderer);
1110 my3DExtActor->RemoveFromRender(theRenderer);
1111 myNodeActor->RemoveFromRender(theRenderer);
1112 my0DActor->RemoveFromRender(theRenderer);
1113 myBallActor->RemoveFromRender(theRenderer);
1114 my1DActor->RemoveFromRender(theRenderer);
1116 theRenderer->RemoveActor(myScalarBarActor);
1120 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1121 const char* theEntry,
1122 const char* theName,
1125 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1129 myVisualObj = theVisualObj;
1130 myVisualObj->Update(theIsClear);
1132 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1133 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1135 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1137 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1139 my0DActor->Init(myVisualObj,myImplicitBoolean);
1140 myBallActor->Init(myVisualObj,myImplicitBoolean);
1141 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1143 my1DActor->Init(myVisualObj,myImplicitBoolean);
1144 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1146 my2DActor->Init(myVisualObj,myImplicitBoolean);
1147 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1148 my3DActor->Init(myVisualObj,myImplicitBoolean);
1149 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1151 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1152 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1153 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1155 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1156 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1158 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1159 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1160 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1161 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1163 vtkFloatingPointType aFactor, aUnits;
1164 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1165 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1166 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1167 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1169 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1173 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1174 SetIsShrunkable(true);
1176 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1178 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1179 SetRepresentation(-1);
1182 SetRepresentation(eEdge);
1183 }else if(aMode == 1){
1184 SetRepresentation(eSurface);
1185 }else if(aMode == 2){
1186 SetRepresentation(ePoint);
1193 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1194 SetIsDisplayNameActor( true );
1196 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1197 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1198 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1200 myTimeStamp->Modified();
1206 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1207 return myNodeActor->GetBounds();
1211 vtkDataSet* SMESH_ActorDef::GetInput(){
1212 return GetUnstructuredGrid();
1216 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1217 Superclass::SetTransform(theTransform);
1219 myNodeActor->SetTransform(theTransform);
1220 myBaseActor->SetTransform(theTransform);
1222 myHighlitableActor->SetTransform(theTransform);
1224 myNodeExtActor->SetTransform(theTransform);
1226 my0DActor->SetTransform(theTransform);
1227 myBallActor->SetTransform(theTransform);
1228 //my0DExtActor->SetTransform(theTransform);
1230 my1DActor->SetTransform(theTransform);
1231 my1DExtActor->SetTransform(theTransform);
1233 my2DActor->SetTransform(theTransform);
1234 my2DExtActor->SetTransform(theTransform);
1235 my3DActor->SetTransform(theTransform);
1236 my3DExtActor->SetTransform(theTransform);
1242 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1243 vtkLODActor::SetMapper(theMapper);
1247 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1248 SALOME_Actor::ShallowCopy(prop);
1252 vtkMapper* SMESH_ActorDef::GetMapper(){
1253 return myPickableActor->GetMapper();
1257 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1258 return myVisualObj->GetUnstructuredGrid();
1262 bool SMESH_ActorDef::IsInfinitive(){
1263 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1265 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1266 ( aDataSet->GetNumberOfCells() == 1 &&
1267 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1268 return SALOME_Actor::IsInfinitive();
1272 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1273 if ( myIsShrinkable == theShrunkable )
1275 myIsShrinkable = theShrunkable;
1279 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1280 return myBaseActor->GetShrinkFactor();
1283 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1284 myBaseActor->SetShrinkFactor(theValue);
1286 my1DActor->SetShrinkFactor(theValue);
1287 my1DExtActor->SetShrinkFactor(theValue);
1289 my2DActor->SetShrinkFactor(theValue);
1290 my2DExtActor->SetShrinkFactor(theValue);
1291 my3DActor->SetShrinkFactor(theValue);
1292 my3DExtActor->SetShrinkFactor(theValue);
1293 my3DExtActor->SetShrinkFactor(theValue);
1294 myHighlitableActor->SetShrinkFactor(theValue);
1299 void SMESH_ActorDef::SetShrink(){
1300 if(!myIsShrinkable) return;
1302 myBaseActor->SetShrink();
1304 my1DActor->SetShrink();
1305 my1DExtActor->SetShrink();
1307 my2DActor->SetShrink();
1308 my2DExtActor->SetShrink();
1309 my3DActor->SetShrink();
1310 my3DExtActor->SetShrink();
1311 myHighlitableActor->SetShrink();
1317 void SMESH_ActorDef::UnShrink(){
1318 if(!myIsShrunk) return;
1320 myBaseActor->UnShrink();
1322 my1DActor->UnShrink();
1323 my1DExtActor->UnShrink();
1325 my2DActor->UnShrink();
1326 my2DExtActor->UnShrink();
1327 my3DActor->UnShrink();
1328 my3DExtActor->UnShrink();
1329 myHighlitableActor->UnShrink();
1336 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1337 return myPickableActor->GetNodeObjId(theVtkID);
1340 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1341 return myPickableActor->GetNodeCoord(theObjID);
1345 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1346 return myPickableActor->GetElemObjId(theVtkID);
1349 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1350 return myPickableActor->GetElemCell(theObjID);
1354 void SMESH_ActorDef::SetVisibility(int theMode){
1355 SetVisibility(theMode,true);
1359 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1360 SALOME_Actor::SetVisibility(theMode);
1362 myNodeActor->VisibilityOff();
1363 myBaseActor->VisibilityOff();
1365 myNodeExtActor->VisibilityOff();
1367 my0DActor->VisibilityOff();
1368 myBallActor->VisibilityOff();
1369 //my0DExtActor->VisibilityOff();
1371 my1DActor->VisibilityOff();
1372 my1DExtActor->VisibilityOff();
1374 my2DActor->VisibilityOff();
1375 my2DExtActor->VisibilityOff();
1376 my3DActor->VisibilityOff();
1377 my3DExtActor->VisibilityOff();
1379 myScalarBarActor->VisibilityOff();
1381 if(GetVisibility()){
1382 if(theIsUpdateRepersentation)
1383 SetRepresentation(GetRepresentation());
1385 if(myControlMode != eNone){
1386 switch(myControlMode){
1388 case eCoincidentNodes:
1389 myNodeExtActor->VisibilityOn();
1393 case eCoincidentElems1D:
1394 my1DExtActor->VisibilityOn();
1397 case eBareBorderFace:
1398 case eOverConstrainedFace:
1399 case eCoincidentElems2D:
1400 my2DExtActor->VisibilityOn();
1402 case eBareBorderVolume:
1403 case eOverConstrainedVolume:
1404 case eCoincidentElems3D:
1405 my3DExtActor->VisibilityOn();
1408 case eMultiConnection2D:
1409 my1DExtActor->VisibilityOn();
1411 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1412 myScalarBarActor->VisibilityOn();
1416 if(myRepresentation != ePoint)
1417 myPickableActor->VisibilityOn();
1419 myNodeActor->VisibilityOn();
1422 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1423 my0DActor->VisibilityOn();
1425 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1426 myBallActor->VisibilityOn();
1429 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1430 my1DActor->VisibilityOn();
1433 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1434 my2DActor->VisibilityOn();
1437 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1438 my3DActor->VisibilityOn();
1441 if(myNodeActor->GetPointsLabeled()){
1442 myNodeActor->VisibilityOn();
1446 my0DActor->UpdateLabels();
1449 myBallActor->UpdateLabels();
1452 my1DActor->UpdateLabels();
1455 my2DActor->UpdateLabels();
1458 my3DActor->UpdateLabels();
1460 #ifndef DISABLE_PLOT2DVIEWER
1462 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1469 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1471 myEntityState = eAllEntity;
1473 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1474 myEntityState &= ~e0DElements;
1475 theMode &= ~e0DElements;
1478 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1479 myEntityState &= ~eBallElem;
1480 theMode &= ~eBallElem;
1483 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1484 myEntityState &= ~eEdges;
1488 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1489 myEntityState &= ~eFaces;
1493 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1494 myEntityState &= ~eVolumes;
1495 theMode &= ~eVolumes;
1499 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1500 theMode |= e0DElements;
1502 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1503 theMode |= eBallElem;
1505 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1508 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1511 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1512 theMode |= eVolumes;
1515 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1517 myEntityMode = theMode;
1518 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1519 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1520 aFilter->ClearRegisteredCellsWithType();
1521 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1523 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1524 aHightFilter->ClearRegisteredCellsWithType();
1525 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1527 if (myEntityMode & e0DElements) {
1528 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1529 aFilter->RegisterCellsWithType(VTK_VERTEX);
1530 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1533 if (myEntityMode & eBallElem) {
1534 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1535 aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1538 if (myEntityMode & eEdges) {
1539 if (MYDEBUG) MESSAGE("EDGES");
1540 aFilter->RegisterCellsWithType(VTK_LINE);
1541 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1543 aHightFilter->RegisterCellsWithType(VTK_LINE);
1544 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1547 if (myEntityMode & eFaces) {
1548 if (MYDEBUG) MESSAGE("FACES");
1549 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1550 aFilter->RegisterCellsWithType(VTK_POLYGON);
1551 aFilter->RegisterCellsWithType(VTK_QUAD);
1552 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1553 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1554 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1556 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1557 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1558 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1559 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1560 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1561 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1564 if (myEntityMode & eVolumes) {
1565 if (MYDEBUG) MESSAGE("VOLUMES");
1566 aFilter->RegisterCellsWithType(VTK_TETRA);
1567 aFilter->RegisterCellsWithType(VTK_VOXEL);
1568 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1569 aFilter->RegisterCellsWithType(VTK_WEDGE);
1570 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1571 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1572 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1573 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1574 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1575 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1576 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1577 //#ifdef VTK_HAVE_POLYHEDRON
1578 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1581 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1582 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1583 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1584 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1585 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1586 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1587 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1588 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1589 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1590 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1591 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1592 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1593 //#ifdef VTK_HAVE_POLYHEDRON
1594 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1598 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1599 SetVisibility(GetVisibility(),false);
1602 void SMESH_ActorDef::SetRepresentation (int theMode)
1604 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1605 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1606 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1607 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1608 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1611 myRepresentation = eSurface;
1612 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1613 myRepresentation = eEdge;
1614 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1615 myRepresentation = ePoint;
1620 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1623 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1626 myRepresentation = theMode;
1629 if (!GetUnstructuredGrid()->GetNumberOfCells())
1630 myRepresentation = ePoint;
1633 if (myRepresentation == ePoint) {
1641 myPickableActor = myBaseActor;
1642 myNodeActor->SetVisibility(false);
1643 myNodeExtActor->SetVisibility(false);
1644 vtkProperty *aProp = NULL, *aBackProp = NULL;
1645 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1646 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1647 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1648 switch (myRepresentation) {
1650 myPickableActor = myNodeActor;
1651 myNodeActor->SetVisibility(true);
1652 aQuadraticMode = SMESH_Actor::eLines;
1653 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1654 aReperesent = SMESH_DeviceActor::ePoint;
1657 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1658 aReperesent = SMESH_DeviceActor::eInsideframe;
1661 aProp = mySurfaceProp;
1662 aBackProp = myBackSurfaceProp;
1663 aPropVN = myNormalVProp;
1664 aPropVR = myReversedVProp;
1665 aReperesent = SMESH_DeviceActor::eSurface;
1669 my2DActor->SetProperty(aProp);
1670 my2DActor->SetBackfaceProperty(aBackProp);
1671 my2DActor->SetRepresentation(aReperesent);
1673 if(aQuadraticMode == SMESH_Actor::eLines)
1674 my2DActor->SetQuadraticArcMode(false);
1675 else if(aQuadraticMode == SMESH_Actor::eArcs)
1676 my2DActor->SetQuadraticArcMode(true);
1678 my2DExtActor->SetRepresentation(aReperesent);
1680 my3DActor->SetProperty(aPropVN);
1681 my3DActor->SetBackfaceProperty(aPropVR);
1682 my3DActor->SetRepresentation(aReperesent);
1684 //my0DExtActor->SetVisibility(false);
1685 my1DExtActor->SetVisibility(false);
1686 my2DExtActor->SetVisibility(false);
1687 my3DExtActor->SetVisibility(false);
1690 //my0DActor->SetProperty(aProp);
1691 //my0DActor->SetBackfaceProperty(aBackProp);
1692 my0DActor->SetRepresentation(aReperesent);
1693 myBallActor->SetRepresentation(aReperesent);
1694 //my0DExtActor->SetRepresentation(aReperesent);
1696 switch(myControlMode){
1698 case eMultiConnection:
1699 aProp = aBackProp = my1DProp;
1700 if(myRepresentation != ePoint)
1701 aReperesent = SMESH_DeviceActor::eInsideframe;
1705 if(aQuadraticMode == SMESH_Actor::eLines)
1706 my1DActor->SetQuadraticArcMode(false);
1707 else if(aQuadraticMode == SMESH_Actor::eArcs)
1708 my1DActor->SetQuadraticArcMode(true);
1710 my1DActor->SetProperty(aProp);
1711 my1DActor->SetBackfaceProperty(aBackProp);
1712 my1DActor->SetRepresentation(aReperesent);
1714 my1DExtActor->SetRepresentation(aReperesent);
1716 if(myIsPointsVisible)
1717 myPickableActor = myNodeActor;
1718 if(GetPointRepresentation())
1719 myNodeActor->SetVisibility(true);
1721 SetMapper(myPickableActor->GetMapper());
1723 SetVisibility(GetVisibility(),false);
1729 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1730 if ( myIsPointsVisible == theIsPointsVisible )
1732 myIsPointsVisible = theIsPointsVisible;
1733 SetRepresentation(GetRepresentation());
1736 bool SMESH_ActorDef::GetPointRepresentation(){
1737 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1741 void SMESH_ActorDef::UpdateHighlight(){
1742 myHighlitableActor->SetHighlited(false);
1743 myHighlitableActor->SetVisibility(false);
1745 bool anIsVisible = GetVisibility();
1747 switch(myRepresentation){
1748 case SMESH_DeviceActor::eSurface:
1749 case SMESH_DeviceActor::eWireframe:
1751 if(myIsHighlighted) {
1752 myHighlitableActor->SetProperty(myHighlightProp);
1753 myBallActor->SetProperty(myBallHighlightProp);
1754 }else if(myIsPreselected){
1755 myHighlitableActor->SetProperty(myPreselectProp);
1756 myBallActor->SetProperty(myBallPreselectProp);
1757 } else if(anIsVisible){
1758 myBallActor->SetProperty(myBallProp);
1759 (myRepresentation == eSurface) ?
1760 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1762 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1763 myHighlitableActor->SetHighlited(anIsVisible);
1764 myHighlitableActor->GetExtractUnstructuredGrid()->
1765 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1766 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1768 myHighlitableActor->SetVisibility(anIsVisible);
1771 case SMESH_DeviceActor::ePoint:
1773 if(myIsHighlighted) {
1774 myNodeActor->SetProperty(myHighlightProp);
1775 }else if(myIsPreselected) {
1776 myNodeActor->SetProperty(myPreselectProp);
1777 } else if(anIsVisible) {
1778 myNodeActor->SetProperty(myNodeProp);
1780 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1781 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1788 void SMESH_ActorDef::highlight(bool theHighlight){
1789 if ( myIsHighlighted == theHighlight )
1791 myIsHighlighted = theHighlight;
1796 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1797 if ( myIsPreselected == thePreselect )
1799 myIsPreselected = thePreselect;
1805 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1807 if (myPickableActor->GetIsOpaque())
1809 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1817 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1819 if (!myPickableActor->GetIsOpaque())
1821 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1829 void SMESH_ActorDef::Render(vtkRenderer *ren){
1830 unsigned long aTime = myTimeStamp->GetMTime();
1831 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1832 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1833 if(anObjTime > aTime || aClippingTime > aTime)
1838 void SMESH_ActorDef::Update(){
1839 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1841 if(GetControlMode() != eNone) {
1842 unsigned long aTime = myTimeStamp->GetMTime();
1843 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1844 if (anObjTime > aTime)
1845 SetControlMode(GetControlMode(),false);
1849 myNodeActor->UpdateLabels();
1852 my0DActor->UpdateLabels();
1855 myBallActor->UpdateLabels();
1858 my1DActor->UpdateLabels();
1861 my2DActor->UpdateLabels();
1864 my3DActor->UpdateLabels();
1866 if(myIsFacesOriented){
1867 SetFacesOriented(myIsFacesOriented);
1870 if(myVisualObj->GetEntitiesFlag()) {
1871 myEntityMode |= myVisualObj->GetEntitiesState();
1874 SetEntityMode(GetEntityMode());
1875 SetVisibility(GetVisibility());
1877 myTimeStamp->Modified();
1882 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1883 SALOME_Actor::ReleaseGraphicsResources(renWin);
1885 myPickableActor->ReleaseGraphicsResources(renWin);
1889 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1890 vtkFloatingPointType* aColor = theProperty->GetColor();
1897 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1898 mySurfaceProp->SetOpacity(theValue);
1899 myBackSurfaceProp->SetOpacity(theValue);
1900 myNormalVProp->SetOpacity(theValue);
1901 myReversedVProp->SetOpacity(theValue);
1902 myEdgeProp->SetOpacity(theValue);
1903 myOutLineProp->SetOpacity(theValue);
1904 myNodeProp->SetOpacity(theValue);
1906 my1DProp->SetOpacity(theValue);
1907 my0DProp->SetOpacity(theValue);
1908 myBallProp->SetOpacity(theValue);
1912 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1913 return mySurfaceProp->GetOpacity();
1917 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1918 mySurfaceProp->SetColor(r,g,b);
1919 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1920 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1921 if( aGroupObj->GetElementType() == SMDSAbs_Face )
1922 myNameActor->SetBackgroundColor(r,g,b);
1924 myDeltaBrightness = delta;
1925 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1926 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1930 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1931 ::GetColor(mySurfaceProp,r,g,b);
1932 delta = myDeltaBrightness;
1935 void SMESH_ActorDef::SetVolumeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1936 myNormalVProp->SetColor(r,g,b);
1937 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1938 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1939 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
1940 myNameActor->SetBackgroundColor(r,g,b);
1942 myDeltaVBrightness = delta;
1943 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1944 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1948 void SMESH_ActorDef::GetVolumeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1949 ::GetColor(myNormalVProp,r,g,b);
1950 delta = myDeltaVBrightness;
1953 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1954 myEdgeProp->SetColor(r,g,b);
1955 my1DProp->SetColor(r,g,b);
1956 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1957 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1958 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1959 myNameActor->SetBackgroundColor(r,g,b);
1963 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1964 ::GetColor(myEdgeProp,r,g,b);
1967 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1968 myOutLineProp->SetColor(r,g,b);
1972 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1973 ::GetColor(myOutLineProp,r,g,b);
1977 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1978 myNodeProp->SetColor(r,g,b);
1979 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1980 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1981 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1982 myNameActor->SetBackgroundColor(r,g,b);
1986 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1987 ::GetColor(myNodeProp,r,g,b);
1990 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1991 my0DProp->SetColor(r,g,b);
1992 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1993 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1994 myNameActor->SetBackgroundColor(r,g,b);
1998 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1999 ::GetColor(my0DProp,r,g,b);
2002 void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
2003 myBallProp->SetColor(r,g,b);
2004 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2005 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2006 myNameActor->SetBackgroundColor(r,g,b);
2010 void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
2011 ::GetColor(myBallProp,r,g,b);
2014 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
2015 myHighlightProp->SetColor(r,g,b);
2016 myBallHighlightProp->SetColor(r,g,b);
2020 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
2021 ::GetColor(myHighlightProp,r,g,b);
2024 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
2025 myPreselectProp->SetColor(r,g,b);
2026 myBallPreselectProp->SetColor(r,g,b);
2030 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
2031 ::GetColor(myPreselectProp,r,g,b);
2035 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
2036 return myEdgeProp->GetLineWidth();
2040 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
2041 myEdgeProp->SetLineWidth(theVal);
2043 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2044 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2045 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2046 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2047 myOutLineProp->SetLineWidth(theVal);
2048 myHighlightProp->SetLineWidth(theVal);
2049 myPreselectProp->SetLineWidth(theVal);
2053 vtkFloatingPointType SMESH_ActorDef::GetOutlineWidth()
2055 return myOutLineProp->GetLineWidth();
2058 void SMESH_ActorDef::SetOutlineWidth(vtkFloatingPointType theVal)
2060 myOutLineProp->SetLineWidth(theVal);
2064 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
2065 my0DProp->SetPointSize(theVal);
2066 myHighlightProp->SetPointSize(theVal);
2067 myPreselectProp->SetPointSize(theVal);
2069 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2070 aCustom->Set0DSize(theVal);
2072 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2073 aCustom->Set0DSize(theVal);
2079 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
2080 return my0DProp->GetPointSize();
2083 void SMESH_ActorDef::SetBallSize(vtkFloatingPointType theVal){
2084 myBallProp->SetPointSize(theVal);
2085 myBallHighlightProp->SetPointSize(theVal);
2086 myBallPreselectProp->SetPointSize(theVal);
2087 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2088 aCustom->SetBallSize(theVal);
2090 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2091 aCustom->SetBallSize(theVal);
2097 vtkFloatingPointType SMESH_ActorDef::GetBallSize(){
2098 return myBallProp->GetPointSize();
2101 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2103 return myVisualObj->GetElemDimension( theObjId );
2108 IsImplicitFunctionUsed() const
2110 return myBaseActor->IsImplicitFunctionUsed();
2114 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2116 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2117 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2119 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2121 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2123 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2124 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2125 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2127 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2128 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2130 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2131 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2132 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2133 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2137 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2140 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2141 myCippingPlaneCont.push_back(thePlane);
2142 if(!IsImplicitFunctionUsed())
2143 SetImplicitFunctionUsed(true);
2144 myNodeActor->UpdateLabels();
2146 return myCippingPlaneCont.size();
2151 RemoveAllClippingPlanes()
2153 myImplicitBoolean->GetFunction()->RemoveAllItems();
2154 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2155 myCippingPlaneCont.clear();
2156 SetImplicitFunctionUsed(false);
2157 myNodeActor->UpdateLabels();
2162 GetNumberOfClippingPlanes()
2164 return myCippingPlaneCont.size();
2169 GetClippingPlane(vtkIdType theID)
2171 if(theID >= myCippingPlaneCont.size())
2173 return myCippingPlaneCont[theID].Get();
2176 void SMESH_ActorDef::UpdateScalarBar()
2178 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2182 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2184 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2185 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2187 aScalarBarTitleProp->SetFontFamilyToArial();
2189 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2191 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2192 if ( f.family() == "Arial" )
2193 aScalarBarTitleProp->SetFontFamilyToArial();
2194 else if ( f.family() == "Courier" )
2195 aScalarBarTitleProp->SetFontFamilyToCourier();
2196 else if ( f.family() == "Times" )
2197 aScalarBarTitleProp->SetFontFamilyToTimes();
2200 aScalarBarTitleProp->BoldOn();
2202 aScalarBarTitleProp->BoldOff();
2205 aScalarBarTitleProp->ItalicOn();
2207 aScalarBarTitleProp->ItalicOff();
2210 aScalarBarTitleProp->ShadowOn();
2212 aScalarBarTitleProp->ShadowOff();
2215 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2216 aScalarBarTitleProp->Delete();
2218 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2220 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2221 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2223 aScalarBarLabelProp->SetFontFamilyToArial();
2224 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2226 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2227 if( f.family() == "Arial" )
2228 aScalarBarLabelProp->SetFontFamilyToArial();
2229 else if( f.family() == "Courier" )
2230 aScalarBarLabelProp->SetFontFamilyToCourier();
2231 else if( f.family() == "Times" )
2232 aScalarBarLabelProp->SetFontFamilyToTimes();
2235 aScalarBarLabelProp->BoldOn();
2237 aScalarBarLabelProp->BoldOff();
2240 aScalarBarLabelProp->ItalicOn();
2242 aScalarBarLabelProp->ItalicOff();
2245 aScalarBarLabelProp->ShadowOn();
2247 aScalarBarLabelProp->ShadowOff();
2250 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2251 aScalarBarLabelProp->Delete();
2253 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2254 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2256 myScalarBarActor->SetOrientationToHorizontal();
2258 myScalarBarActor->SetOrientationToVertical();
2261 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2262 if( mgr->hasValue( "SMESH", name + "x" ) )
2263 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2265 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2266 if( mgr->hasValue( "SMESH", name + "y" ) )
2267 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2268 myScalarBarActor->SetPosition( aXVal, aYVal );
2270 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2271 if( mgr->hasValue( "SMESH", name + "width" ) )
2272 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2273 myScalarBarActor->SetWidth( aWVal );
2275 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2276 if( mgr->hasValue( "SMESH", name + "height" ) )
2277 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2278 myScalarBarActor->SetHeight( aHVal );
2281 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2282 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2283 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2286 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2287 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2288 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2290 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2291 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2293 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2294 myScalarBarActor->SetDistributionColoringType(coloringType);
2296 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2297 QColor(255, 255, 255));
2299 rgb[0]= distributionColor.red()/255.;
2300 rgb[1]= distributionColor.green()/255.;
2301 rgb[2]= distributionColor.blue()/255.;
2302 myScalarBarActor->SetDistributionColor(rgb);
2307 void SMESH_ActorDef::UpdateDistribution()
2309 if(SMESH::Controls::NumericalFunctor* fun =
2310 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2312 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2313 std::vector<int> nbEvents;
2314 std::vector<double> funValues;
2315 SMESH_VisualObjDef::TEntityList elems;
2316 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2317 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2318 std::vector<int> elemIds;
2319 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2320 elemIds.push_back( (*e)->GetID());
2321 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2322 double * range = lookupTable->GetRange();
2323 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2324 myScalarBarActor->SetDistribution(nbEvents);
2328 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2331 case SMESH_Actor::eLines :
2332 myHighlitableActor->SetQuadraticArcMode(false);
2333 my2DActor->SetQuadraticArcMode(false);
2334 my1DActor->SetQuadraticArcMode(false);
2336 case SMESH_Actor::eArcs :
2337 myHighlitableActor->SetQuadraticArcMode(true);
2338 if(GetRepresentation() != SMESH_Actor::ePoint) {
2339 my2DActor->SetQuadraticArcMode(true);
2340 my1DActor->SetQuadraticArcMode(true);
2349 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2351 if(myHighlitableActor->GetQuadraticArcMode())
2352 return SMESH_Actor::eArcs;
2354 return SMESH_Actor::eLines;
2357 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2359 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2360 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2361 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2364 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2366 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2367 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2368 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2369 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2372 #ifndef DISABLE_PLOT2DVIEWER
2373 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2376 my2dHistogram->clearAllPoints();
2378 if(SMESH::Controls::NumericalFunctor* fun =
2379 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2382 if(!my2dHistogram) {
2383 my2dHistogram = new SPlot2d_Histogram();
2384 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2385 my2dHistogram->setIO(anIO);
2388 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2389 std::vector<int> nbEvents;
2390 std::vector<double> funValues;
2391 SMESH_VisualObjDef::TEntityList elems;
2392 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2393 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2394 std::vector<int> elemIds;
2396 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2397 elemIds.push_back( (*e)->GetID());
2399 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2400 double * range = lookupTable->GetRange();
2401 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2403 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2404 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2406 if(funValues.size() >= 2)
2407 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2411 //Color of the histogram
2412 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2413 my2dHistogram->setAutoAssign(true);
2416 myScalarBarActor->GetDistributionColor(rgb);
2417 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2418 my2dHistogram->setColor(aColor);
2422 return my2dHistogram;