1 // Copyright (C) 2007-2013 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 "utilities.h"
84 static int MYDEBUG = 1;
86 static int MYDEBUG = 1;
89 static int aLineWidthInc = 2;
92 SMESH_ActorDef* SMESH_ActorDef::New(){
93 return new SMESH_ActorDef();
97 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 SMESH_ActorDef* anActor = NULL;
103 if(theVisualObj->IsValid() ) {
104 anActor = SMESH_ActorDef::New();
105 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
110 anActor->UpdateScalarBar();
116 SMESH_ActorDef::SMESH_ActorDef()
118 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
119 myBaseActor = SMESH_DeviceActor::New();
121 myTimeStamp = vtkTimeStamp::New();
123 myIsPointsVisible = false;
124 myIsEntityModeCache = false;
126 myHighlightActor = SMESH_SVTKActor::New();
127 myHighlightActor->Delete(); // vtkSmartPointer!
128 myHighlightActor->Initialize();
130 myPreHighlightActor = SMESH_SVTKActor::New();
131 myPreHighlightActor->Delete();
132 myPreHighlightActor->Initialize();
134 myIsShrinkable = false;
137 myIsFacesOriented = false;
139 myControlsPrecision = -1;
140 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
142 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
143 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
145 double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
146 double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
147 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
148 double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
150 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
152 bool anItalicNd = false;
153 bool aShadowNd = false;
155 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
156 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
157 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
158 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
159 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
161 anItalicNd = f.italic();
162 aShadowNd = f.overline();
163 aSizeNd = f.pointSize();
165 double anRGBNd[3] = {1,1,1};
166 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
168 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
170 bool anItalicEl = false;
171 bool aShadowEl = false;
173 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
174 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
175 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
176 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
177 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
179 anItalicEl = f.italic();
180 aShadowEl = f.overline();
181 aSizeEl = f.pointSize();
183 double anRGBEl[3] = {0,1,0};
184 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
186 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
187 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
189 //Definition 2D and 3D devices of the actor
190 //-----------------------------------------
191 double anRGB[3] = {1,1,1};
192 mySurfaceProp = vtkProperty::New();
195 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
196 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
197 myDeltaBrightness = delta;
199 myBackSurfaceProp = vtkProperty::New();
200 bfc = Qtx::mainColorToSecondary(ffc, delta);
201 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
203 myNormalVProp = vtkProperty::New();
204 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
205 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
206 myDeltaVBrightness = delta;
208 myReversedVProp = vtkProperty::New();
209 bfc = Qtx::mainColorToSecondary(ffc, delta);
210 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
212 my2DActor = SMESH_CellLabelActor::New();
213 my2DActor->SetStoreGemetryMapping(true);
214 my2DActor->SetUserMatrix(aMatrix);
215 my2DActor->PickableOff();
216 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
217 my2DActor->SetProperty(mySurfaceProp);
218 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
219 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
220 aFilter = my2DActor->GetExtractUnstructuredGrid();
221 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
222 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
223 aFilter->RegisterCellsWithType(VTK_POLYGON);
224 aFilter->RegisterCellsWithType(VTK_QUAD);
225 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
226 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
227 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
228 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
230 my2DExtProp = vtkProperty::New();
231 my2DExtProp->DeepCopy(mySurfaceProp);
232 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
233 anRGB[0] = 1 - anRGB[0];
234 anRGB[1] = 1 - anRGB[1];
235 anRGB[2] = 1 - anRGB[2];
236 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
238 my2DExtActor = SMESH_DeviceActor::New();
239 my2DExtActor->SetUserMatrix(aMatrix);
240 my2DExtActor->PickableOff();
241 my2DExtActor->SetProperty(my2DExtProp);
242 my2DExtActor->SetBackfaceProperty(my2DExtProp);
243 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
244 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
245 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
246 aFilter->RegisterCellsWithType(VTK_POLYGON);
247 aFilter->RegisterCellsWithType(VTK_QUAD);
248 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
249 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
250 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
251 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
253 my3DActor = SMESH_CellLabelActor::New();
254 my3DActor->SetStoreGemetryMapping(true);
255 my3DActor->SetUserMatrix(aMatrix);
256 my3DActor->PickableOff();
257 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
258 my3DActor->SetProperty(myNormalVProp);
259 my3DActor->SetBackfaceProperty(myReversedVProp);
260 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
261 my3DActor->SetCoincident3DAllowed(true);
262 aFilter = my3DActor->GetExtractUnstructuredGrid();
263 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
264 aFilter->RegisterCellsWithType(VTK_TETRA);
265 aFilter->RegisterCellsWithType(VTK_VOXEL);
266 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
267 aFilter->RegisterCellsWithType(VTK_WEDGE);
268 aFilter->RegisterCellsWithType(VTK_PYRAMID);
269 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
270 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
271 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
272 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
273 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
274 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
275 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
276 //#ifdef VTK_HAVE_POLYHEDRON
277 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
278 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
281 my3DExtProp = vtkProperty::New();
282 my3DExtProp->DeepCopy(myNormalVProp);
283 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
284 anRGB[0] = 1 - anRGB[0];
285 anRGB[1] = 1 - anRGB[1];
286 anRGB[2] = 1 - anRGB[2];
287 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
289 my3DExtActor = SMESH_DeviceActor::New();
290 my3DExtActor->SetUserMatrix(aMatrix);
291 my3DExtActor->PickableOff();
292 my3DExtActor->SetProperty(my3DExtProp);
293 my3DExtActor->SetBackfaceProperty(my3DExtProp);
294 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
295 my3DExtActor->SetCoincident3DAllowed(true);
296 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
297 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
298 aFilter->RegisterCellsWithType(VTK_TETRA);
299 aFilter->RegisterCellsWithType(VTK_VOXEL);
300 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
301 aFilter->RegisterCellsWithType(VTK_WEDGE);
302 aFilter->RegisterCellsWithType(VTK_PYRAMID);
303 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
304 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
305 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
306 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
307 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
308 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
309 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
310 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
312 //Definition 1D device of the actor
313 //---------------------------------
314 myEdgeProp = vtkProperty::New();
315 myEdgeProp->SetAmbient(1.0);
316 myEdgeProp->SetDiffuse(0.0);
317 myEdgeProp->SetSpecular(0.0);
318 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
319 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
320 myEdgeProp->SetLineWidth(aLineWidth);
322 my1DActor = SMESH_CellLabelActor::New();
323 my1DActor->SetStoreGemetryMapping(true);
324 my1DActor->SetUserMatrix(aMatrix);
325 my1DActor->PickableOff();
326 my1DActor->SetHighlited(true);
327 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
328 my1DActor->SetProperty(myEdgeProp);
329 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
330 aFilter = my1DActor->GetExtractUnstructuredGrid();
331 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
332 aFilter->RegisterCellsWithType(VTK_LINE);
333 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
335 my1DProp = vtkProperty::New();
336 my1DProp->DeepCopy(myEdgeProp);
337 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
338 my1DProp->SetPointSize(aElem0DSize);
340 my1DExtProp = vtkProperty::New();
341 my1DExtProp->DeepCopy(myEdgeProp);
342 anRGB[0] = 1 - anRGB[0];
343 anRGB[1] = 1 - anRGB[1];
344 anRGB[2] = 1 - anRGB[2];
345 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
346 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
347 my1DExtProp->SetPointSize(aElem0DSize);
349 my1DExtActor = SMESH_DeviceActor::New();
350 my1DExtActor->SetUserMatrix(aMatrix);
351 my1DExtActor->PickableOff();
352 my1DExtActor->SetHighlited(true);
353 my1DExtActor->SetVisibility(false);
354 my1DExtActor->SetProperty(my1DExtProp);
355 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
356 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
357 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
358 aFilter->RegisterCellsWithType(VTK_LINE);
359 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
362 //Definition 0D device of the actor (0d elements)
363 //-----------------------------------------------
364 my0DProp = vtkProperty::New();
365 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
366 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
367 my0DProp->SetPointSize(aElem0DSize);
369 my0DActor = SMESH_CellLabelActor::New();
370 my0DActor->SetUserMatrix(aMatrix);
371 my0DActor->SetStoreGemetryMapping(true);
372 my0DActor->PickableOff();
373 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
374 my0DActor->SetVisibility(false);
375 my0DActor->SetProperty(my0DProp);
376 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
377 aFilter = my0DActor->GetExtractUnstructuredGrid();
378 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
379 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
380 aFilter->RegisterCellsWithType(VTK_VERTEX);
382 //Definition 0D device of the actor (ball elements)
383 //-----------------------------------------------
384 myBallProp = vtkProperty::New();
385 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
386 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
387 myBallProp->SetPointSize(aBallElemSize);
389 myBallActor = SMESH_CellLabelActor::New();
390 myBallActor->SetUserMatrix(aMatrix);
391 myBallActor->SetStoreGemetryMapping(true);
392 myBallActor->PickableOff();
393 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
394 myBallActor->SetVisibility(false);
395 myBallActor->SetProperty(myBallProp);
396 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
397 aFilter = myBallActor->GetExtractUnstructuredGrid();
398 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
399 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
401 //my0DExtProp = vtkProperty::New();
402 //my0DExtProp->DeepCopy(my0DProp);
403 //anRGB[0] = 1 - anRGB[0];
404 //anRGB[1] = 1 - anRGB[1];
405 //anRGB[2] = 1 - anRGB[2];
406 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
407 //my0DExtProp->SetPointSize(aElem0DSize);
409 //my0DExtActor = SMESH_DeviceActor::New();
410 //my0DExtActor->SetUserMatrix(aMatrix);
411 //my0DExtActor->SetStoreClippingMapping(true);
412 //my0DExtActor->PickableOff();
413 //my0DExtActor->SetHighlited(true);
414 //my0DExtActor->SetVisibility(false);
415 //my0DExtActor->SetProperty(my0DExtProp);
416 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
417 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
418 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
419 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
420 //aFilter->RegisterCellsWithType(VTK_VERTEX);
423 //Definition 0D device of the actor (nodes)
424 //-----------------------------------------
425 myNodeProp = vtkProperty::New();
426 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
427 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
429 myNodeActor = SMESH_NodeLabelActor::New();
430 myNodeActor->SetUserMatrix(aMatrix);
431 myNodeActor->SetStoreClippingMapping(true);
432 myNodeActor->PickableOff();
433 myNodeActor->SetVisibility(false);
434 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
435 myNodeActor->SetProperty(myNodeProp);
436 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
437 aFilter = myNodeActor->GetExtractUnstructuredGrid();
438 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
440 myNodeExtProp = vtkProperty::New();
441 myNodeExtProp->DeepCopy(myNodeProp);
442 anRGB[0] = 1 - anRGB[0];
443 anRGB[1] = 1 - anRGB[1];
444 anRGB[2] = 1 - anRGB[2];
445 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
447 myNodeExtActor = SMESH_DeviceActor::New();
448 myNodeExtActor->SetUserMatrix(aMatrix);
449 myNodeExtActor->SetStoreClippingMapping(true);
450 myNodeExtActor->PickableOff();
451 myNodeExtActor->SetHighlited(true);
452 myNodeExtActor->SetVisibility(false);
453 myNodeExtActor->SetProperty(myNodeExtProp);
454 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
455 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
456 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
457 aFilter->RegisterCellsWithType(VTK_VERTEX);
459 //Definition of Pickable and Highlitable engines
460 //----------------------------------------------
462 myBaseActor->SetUserMatrix(aMatrix);
463 myBaseActor->SetStoreGemetryMapping(true);
464 myBaseActor->GetProperty()->SetOpacity(0.0);
465 myPickableActor = myBaseActor;
467 myHighlightProp = vtkProperty::New();
468 myHighlightProp->SetAmbient(1.0);
469 myHighlightProp->SetDiffuse(0.0);
470 myHighlightProp->SetSpecular(0.0);
471 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
472 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
473 myHighlightProp->SetPointSize(aElem0DSize); // ??
474 myHighlightProp->SetLineWidth(aLineWidth);
475 myHighlightProp->SetRepresentation(1);
477 myBallHighlightProp = vtkProperty::New();
478 myBallHighlightProp->DeepCopy(myHighlightProp);
479 myBallHighlightProp->SetPointSize(aBallElemSize);
482 myOutLineProp = vtkProperty::New();
483 myOutLineProp->SetAmbient(1.0);
484 myOutLineProp->SetDiffuse(0.0);
485 myOutLineProp->SetSpecular(0.0);
486 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
487 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
488 myOutLineProp->SetLineWidth(aOutlineWidth);
489 myOutLineProp->SetRepresentation(1);
491 myPreselectProp = vtkProperty::New();
492 myPreselectProp->SetAmbient(1.0);
493 myPreselectProp->SetDiffuse(0.0);
494 myPreselectProp->SetSpecular(0.0);
495 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
496 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
497 myPreselectProp->SetPointSize(aElem0DSize); // ??
498 myPreselectProp->SetLineWidth(aLineWidth);
499 myPreselectProp->SetRepresentation(1);
501 myBallPreselectProp = vtkProperty::New();
502 myBallPreselectProp->DeepCopy(myPreselectProp);
503 myBallPreselectProp->SetPointSize(aBallElemSize);
505 myHighlitableActor = SMESH_DeviceActor::New();
506 myHighlitableActor->SetUserMatrix(aMatrix);
507 myHighlitableActor->PickableOff();
508 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
509 myHighlitableActor->SetCoincident3DAllowed(true);
516 myControlMode = eNone;
517 myControlActor = my2DActor;
519 //Definition of myScalarBarActor
520 //------------------------------
521 myLookupTable = vtkLookupTable::New();
522 //Fix for Bug PAL5195 - SMESH764:
523 //Controls - Aspect Ratio: incorrect colors of the best and worst values
524 myLookupTable->SetHueRange(0.667,0.0);
526 myScalarBarActor = SMESH_ScalarBarActor::New();
527 myScalarBarActor->SetVisibility(false);
528 myScalarBarActor->SetLookupTable(myLookupTable);
531 //Incorrect "Min value" in Scalar Bar in Mesh:
532 // myScalarBarActor->SetLabelFormat("%.4g");
533 // changes was commented because of regression bug IPAL 19981
535 mgr = SUIT_Session::session()->resourceMgr();
539 myEntityMode = eAllEntity;
540 myEntityModeCache = eAllEntity;
543 myImplicitBoolean = vtkImplicitBoolean::New();
544 myImplicitBoolean->SetOperationTypeToIntersection();
546 //Quadratic 2D elements representation
547 //-----------------------------------------------------------------------------
548 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
549 if(aQuadratic2DMode == 0){
550 myHighlitableActor->SetQuadraticArcMode(false);
551 my2DActor->SetQuadraticArcMode(false);
552 my1DActor->SetQuadraticArcMode(false);
554 else if(aQuadratic2DMode == 1){
555 myHighlitableActor->SetQuadraticArcMode(true);
556 my2DActor->SetQuadraticArcMode(true);
557 my1DActor->SetQuadraticArcMode(true);
560 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
561 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
562 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
564 // Set colors of the name actor
565 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
566 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
567 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
568 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
570 #ifndef DISABLE_PLOT2DVIEWER
574 SetBallSize(aBallElemSize);
575 Set0DSize(aElem0DSize);
579 SMESH_ActorDef::~SMESH_ActorDef()
581 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
583 // Please keep the order same as one in the header file
585 myTimeStamp->Delete();
587 myScalarBarActor->Delete();
588 myLookupTable->Delete();
590 mySurfaceProp->Delete();
591 myBackSurfaceProp->Delete();
592 myNormalVProp->Delete();
593 myReversedVProp->Delete();
594 myEdgeProp->Delete();
595 myNodeProp->Delete();
597 myNodeActor->Delete();
598 myBaseActor->Delete();
599 //myPickableActor->Delete(); myPickableActor == myBaseActor
601 myHighlightProp->Delete();
602 myOutLineProp->Delete();
603 myPreselectProp->Delete();
605 myBallHighlightProp->Delete();
606 myBallPreselectProp->Delete();
608 myHighlitableActor->Delete();
610 my2DExtProp->Delete();
611 my3DExtProp->Delete();
613 my2DExtActor->Delete();
615 my3DExtActor->Delete();
616 // myControlActor->Delete(); myControlActor == my2DActor
618 myNodeExtProp->Delete();
619 myNodeExtActor->Delete();
623 my1DExtProp->Delete();
624 my1DExtActor->Delete();
628 myBallProp->Delete();
629 myBallActor->Delete();
630 //my0DExtProp->Delete();
631 //my0DExtActor->Delete();
633 myImplicitBoolean->Delete();
635 #ifndef DISABLE_PLOT2DVIEWER
637 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
638 delete my2dHistogram;
643 void SMESH_ActorDef::Delete()
645 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
646 // from the actor's destructor) will be thrown before removing the actor's observers,
647 // that is done inside the Superclass::Delete() method but before the destructor itself
648 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
649 // The event is caught by SMESHGUI::ProcessEvents() static method.
650 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
652 Superclass::Delete();
655 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
658 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
659 SetRepresentation(GetRepresentation());
660 myTimeStamp->Modified();
664 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
665 bool theBold, bool theItalic, bool theShadow,
666 double r, double g, double b )
669 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
670 SetRepresentation( GetRepresentation() );
671 myTimeStamp->Modified();
675 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
676 bool theBold, bool theItalic, bool theShadow,
677 double r, double g, double b )
680 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
681 SetRepresentation( GetRepresentation() );
682 myTimeStamp->Modified();
685 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
686 SetRepresentation( GetRepresentation() );
687 myTimeStamp->Modified();
690 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
691 SetRepresentation( GetRepresentation() );
692 myTimeStamp->Modified();
695 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
696 SetRepresentation( GetRepresentation() );
697 myTimeStamp->Modified();
700 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
701 SetRepresentation( GetRepresentation() );
702 myTimeStamp->Modified();
706 bool SMESH_ActorDef::GetPointsLabeled() {
707 return myNodeActor && myNodeActor->GetPointsLabeled();
710 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
713 my3DActor->SetCellsLabeled(theIsCellsLabeled);
716 my2DActor->SetCellsLabeled(theIsCellsLabeled);
719 my1DActor->SetCellsLabeled(theIsCellsLabeled);
722 my0DActor->SetCellsLabeled(theIsCellsLabeled);
725 myBallActor->SetCellsLabeled(theIsCellsLabeled);
727 myTimeStamp->Modified();
731 bool SMESH_ActorDef::GetCellsLabeled() {
734 result = result || my3DActor->GetCellsLabeled();
737 result = result || my2DActor->GetCellsLabeled();
740 result = result || my1DActor->GetCellsLabeled();
743 result = result || my0DActor->GetCellsLabeled();
746 result = result || myBallActor->GetCellsLabeled();
752 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
754 myIsFacesOriented = theIsFacesOriented;
756 my2DActor->SetFacesOriented(theIsFacesOriented);
757 my3DActor->SetFacesOriented(theIsFacesOriented);
759 myTimeStamp->Modified();
762 bool SMESH_ActorDef::GetFacesOriented()
764 return myIsFacesOriented;
767 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
769 my2DActor->SetFacesOrientationColor( r, g, b );
770 my3DActor->SetFacesOrientationColor( r, g, b );
773 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
775 my3DActor->GetFacesOrientationColor( r, g, b );
778 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
780 my2DActor->SetFacesOrientationScale( theScale );
781 my3DActor->SetFacesOrientationScale( theScale );
784 double SMESH_ActorDef::GetFacesOrientationScale()
786 return my3DActor->GetFacesOrientationScale();
789 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
791 my2DActor->SetFacesOrientation3DVectors( theState );
792 my3DActor->SetFacesOrientation3DVectors( theState );
795 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
797 return my3DActor->GetFacesOrientation3DVectors();
803 SetControlMode(eControl theMode)
805 SetControlMode(theMode,true);
811 SetControlMode(eControl theMode,
812 bool theCheckEntityMode)
814 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
815 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
816 lookupTable->SetScale(VTK_SCALE_LINEAR);
818 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
822 myControlMode = eNone;
823 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
825 my0DActor->GetMapper()->SetScalarVisibility(false);
826 my1DActor->GetMapper()->SetScalarVisibility(false);
827 my2DActor->GetMapper()->SetScalarVisibility(false);
828 my3DActor->GetMapper()->SetScalarVisibility(false);
829 myBallActor->GetMapper()->SetScalarVisibility(false);
830 myScalarBarActor->SetVisibility(false);
832 bool anIsScalarVisible = theMode > eNone;
834 if(anIsScalarVisible) {
838 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
839 aControl->SetPrecision( myControlsPrecision );
840 myFunctor.reset( aControl );
841 myControlActor = my1DActor;
846 myFunctor.reset(new SMESH::Controls::Length2D());
847 myControlActor = my2DActor;
851 myFunctor.reset(new SMESH::Controls::FreeBorders());
852 myControlActor = my1DActor;
855 myFunctor.reset(new SMESH::Controls::FreeEdges());
856 myControlActor = my2DActor;
859 myFunctor.reset(new SMESH::Controls::FreeNodes());
860 myControlActor = myNodeActor;
863 myFunctor.reset(new SMESH::Controls::FreeFaces());
864 myControlActor = my2DActor;
866 case eCoincidentNodes:
868 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
869 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
870 cn->SetTolerance( tol );
872 myControlActor = myNodeActor;
875 case eCoincidentElems1D:
876 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
877 myControlActor = my1DActor;
879 case eCoincidentElems2D:
880 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
881 myControlActor = my2DActor;
883 case eCoincidentElems3D:
884 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
885 myControlActor = my3DActor;
887 case eBareBorderFace:
888 myFunctor.reset(new SMESH::Controls::BareBorderFace());
889 myControlActor = my2DActor;
891 case eOverConstrainedFace:
892 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
893 myControlActor = my2DActor;
895 case eMultiConnection:
896 myFunctor.reset(new SMESH::Controls::MultiConnection());
897 myControlActor = my1DActor;
899 case eMultiConnection2D:
900 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
901 myControlActor = my2DActor;
905 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
906 aControl->SetPrecision( myControlsPrecision );
907 myFunctor.reset( aControl );
908 myControlActor = my2DActor;
913 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
914 aControl->SetPrecision( myControlsPrecision );
915 myFunctor.reset( aControl );
916 myControlActor = my2DActor;
921 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
922 aControl->SetPrecision( myControlsPrecision );
923 myFunctor.reset( aControl );
924 myControlActor = my2DActor;
929 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
930 aControl->SetPrecision( myControlsPrecision );
931 myFunctor.reset( aControl );
932 myControlActor = my3DActor;
937 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
938 aControl->SetPrecision( myControlsPrecision );
939 myFunctor.reset( aControl );
940 myControlActor = my3DActor;
943 case eMaxElementLength2D:
945 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
946 aControl->SetPrecision( myControlsPrecision );
947 myFunctor.reset( aControl );
948 myControlActor = my2DActor;
951 case eMaxElementLength3D:
953 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
954 aControl->SetPrecision( myControlsPrecision );
955 myFunctor.reset( aControl );
956 myControlActor = my3DActor;
959 case eBareBorderVolume:
961 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
962 myControlActor = my3DActor;
965 case eOverConstrainedVolume:
967 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
968 myControlActor = my3DActor;
973 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
974 aControl->SetPrecision( myControlsPrecision );
975 myFunctor.reset( aControl );
976 myControlActor = my2DActor;
981 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
982 aControl->SetPrecision( myControlsPrecision );
983 myFunctor.reset( aControl );
984 myControlActor = my2DActor;
989 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
990 aControl->SetPrecision( myControlsPrecision );
991 myFunctor.reset( aControl );
992 myControlActor = my2DActor;
999 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
1000 vtkIdType aNbCells = aGrid->GetNumberOfCells();
1002 myControlMode = theMode;
1003 switch(myControlMode){
1005 case eCoincidentNodes:
1006 myNodeExtActor->SetExtControlMode(myFunctor);
1010 case eCoincidentElems1D:
1011 my1DExtActor->SetExtControlMode(myFunctor);
1014 case eBareBorderFace:
1015 case eOverConstrainedFace:
1016 case eCoincidentElems2D:
1017 my2DExtActor->SetExtControlMode(myFunctor);
1019 case eBareBorderVolume:
1020 case eOverConstrainedVolume:
1021 case eCoincidentElems3D:
1022 my3DExtActor->SetExtControlMode(myFunctor);
1025 case eMultiConnection2D:
1026 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1027 UpdateDistribution();
1030 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1031 UpdateDistribution();
1035 if(theCheckEntityMode) {
1036 if(myControlActor == my1DActor) {
1037 if (!myIsEntityModeCache){
1038 myEntityModeCache = GetEntityMode();
1039 myIsEntityModeCache=true;
1041 SetEntityMode(eEdges);
1043 else if(myControlActor == my2DActor) {
1044 switch(myControlMode) {
1048 case eMultiConnection2D:
1049 if (!myIsEntityModeCache){
1050 myEntityModeCache = GetEntityMode();
1051 myIsEntityModeCache=true;
1053 SetEntityMode(eFaces);
1056 if (!myIsEntityModeCache){
1057 myEntityModeCache = GetEntityMode();
1058 myIsEntityModeCache=true;
1060 SetEntityMode(eFaces);
1062 }else if(myControlActor == my3DActor) {
1063 if (!myIsEntityModeCache){
1064 myEntityModeCache = GetEntityMode();
1065 myIsEntityModeCache=true;
1067 SetEntityMode(eVolumes);
1073 if(theCheckEntityMode){
1074 myEntityMode = myEntityModeCache;
1075 myIsEntityModeCache = false;
1080 SetRepresentation(GetRepresentation());
1082 myTimeStamp->Modified();
1085 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1086 double * range = lookupTable->GetRange();
1088 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1089 lookupTable->SetScale(VTK_SCALE_LOG10);
1095 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
1097 //myHighlightActor->AddToRender(theRenderer);
1099 theRenderer->AddActor(myBaseActor);
1100 theRenderer->AddActor(myNodeExtActor);
1101 theRenderer->AddActor(my1DExtActor);
1103 my3DActor ->AddToRender(theRenderer);
1104 my3DExtActor->AddToRender(theRenderer);
1105 my2DActor ->AddToRender(theRenderer);
1106 my2DExtActor->AddToRender(theRenderer);
1107 myNodeActor ->AddToRender(theRenderer);
1108 my1DActor ->AddToRender(theRenderer);
1109 my0DActor ->AddToRender(theRenderer);
1110 myBallActor ->AddToRender(theRenderer);
1111 //theRenderer->AddActor(my0DExtActor);
1113 theRenderer->AddActor(myHighlitableActor);
1115 theRenderer->AddActor2D(myScalarBarActor);
1117 // the superclass' method should be called at the end
1118 // (in particular, for correct work of selection)
1119 SALOME_Actor::AddToRender(theRenderer);
1122 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1123 SALOME_Actor::RemoveFromRender(theRenderer);
1125 theRenderer->RemoveActor(myBaseActor);
1127 theRenderer->RemoveActor(myNodeExtActor);
1129 theRenderer->RemoveActor(myHighlitableActor);
1131 //theRenderer->RemoveActor(my0DExtActor);
1133 theRenderer->RemoveActor(my1DExtActor);
1135 my2DActor->RemoveFromRender(theRenderer);
1136 my2DExtActor->RemoveFromRender(theRenderer);
1137 my3DActor->RemoveFromRender(theRenderer);
1138 my3DExtActor->RemoveFromRender(theRenderer);
1139 myNodeActor->RemoveFromRender(theRenderer);
1140 my0DActor->RemoveFromRender(theRenderer);
1141 myBallActor->RemoveFromRender(theRenderer);
1142 my1DActor->RemoveFromRender(theRenderer);
1144 theRenderer->RemoveActor(myScalarBarActor);
1148 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1149 const char* theEntry,
1150 const char* theName,
1153 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1157 myVisualObj = theVisualObj;
1158 myVisualObj->Update(theIsClear);
1160 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1161 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1163 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1165 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1167 my0DActor->Init(myVisualObj,myImplicitBoolean);
1168 myBallActor->Init(myVisualObj,myImplicitBoolean);
1169 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1171 my1DActor->Init(myVisualObj,myImplicitBoolean);
1172 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1174 my2DActor->Init(myVisualObj,myImplicitBoolean);
1175 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1176 my3DActor->Init(myVisualObj,myImplicitBoolean);
1177 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1179 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1180 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1181 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1183 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1184 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1186 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1187 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1188 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1189 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1191 double aFactor, aUnits;
1192 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1193 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1194 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1195 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1197 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1201 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1202 SetIsShrunkable(true);
1204 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1206 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1207 SetRepresentation(-1);
1210 SetRepresentation(eEdge);
1211 }else if(aMode == 1){
1212 SetRepresentation(eSurface);
1213 }else if(aMode == 2){
1214 SetRepresentation(ePoint);
1221 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1222 SetIsDisplayNameActor( true );
1224 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1225 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1226 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1228 myTimeStamp->Modified();
1234 double* SMESH_ActorDef::GetBounds(){
1235 return myNodeActor->GetBounds();
1239 vtkDataSet* SMESH_ActorDef::GetInput(){
1240 return GetUnstructuredGrid();
1244 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1245 Superclass::SetTransform(theTransform);
1247 myNodeActor->SetTransform(theTransform);
1248 myBaseActor->SetTransform(theTransform);
1250 myHighlitableActor->SetTransform(theTransform);
1252 myNodeExtActor->SetTransform(theTransform);
1254 my0DActor->SetTransform(theTransform);
1255 myBallActor->SetTransform(theTransform);
1256 //my0DExtActor->SetTransform(theTransform);
1258 my1DActor->SetTransform(theTransform);
1259 my1DExtActor->SetTransform(theTransform);
1261 my2DActor->SetTransform(theTransform);
1262 my2DExtActor->SetTransform(theTransform);
1263 my3DActor->SetTransform(theTransform);
1264 my3DExtActor->SetTransform(theTransform);
1270 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1271 vtkLODActor::SetMapper(theMapper);
1275 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1276 SALOME_Actor::ShallowCopy(prop);
1280 vtkMapper* SMESH_ActorDef::GetMapper(){
1281 return myPickableActor->GetMapper();
1285 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1286 return myVisualObj->GetUnstructuredGrid();
1290 bool SMESH_ActorDef::IsInfinitive(){
1291 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1292 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1293 ( aDataSet->GetNumberOfCells() == 1 &&
1294 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1295 return SALOME_Actor::IsInfinitive();
1299 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1300 if ( myIsShrinkable == theShrunkable )
1302 myIsShrinkable = theShrunkable;
1306 double SMESH_ActorDef::GetShrinkFactor(){
1307 return myBaseActor->GetShrinkFactor();
1310 void SMESH_ActorDef::SetShrinkFactor(double theValue){
1311 myBaseActor->SetShrinkFactor(theValue);
1313 my1DActor->SetShrinkFactor(theValue);
1314 my1DExtActor->SetShrinkFactor(theValue);
1316 my2DActor->SetShrinkFactor(theValue);
1317 my2DExtActor->SetShrinkFactor(theValue);
1318 my3DActor->SetShrinkFactor(theValue);
1319 my3DExtActor->SetShrinkFactor(theValue);
1320 my3DExtActor->SetShrinkFactor(theValue);
1321 myHighlitableActor->SetShrinkFactor(theValue);
1326 void SMESH_ActorDef::SetShrink(){
1327 if(!myIsShrinkable) return;
1329 myBaseActor->SetShrink();
1331 my1DActor->SetShrink();
1332 my1DExtActor->SetShrink();
1334 my2DActor->SetShrink();
1335 my2DExtActor->SetShrink();
1336 my3DActor->SetShrink();
1337 my3DExtActor->SetShrink();
1338 myHighlitableActor->SetShrink();
1344 void SMESH_ActorDef::UnShrink(){
1345 if(!myIsShrunk) return;
1347 myBaseActor->UnShrink();
1349 my1DActor->UnShrink();
1350 my1DExtActor->UnShrink();
1352 my2DActor->UnShrink();
1353 my2DExtActor->UnShrink();
1354 my3DActor->UnShrink();
1355 my3DExtActor->UnShrink();
1356 myHighlitableActor->UnShrink();
1363 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1364 return myPickableActor->GetNodeObjId(theVtkID);
1367 double* SMESH_ActorDef::GetNodeCoord(int theObjID){
1368 return myPickableActor->GetNodeCoord(theObjID);
1372 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1373 return myPickableActor->GetElemObjId(theVtkID);
1376 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1377 return myPickableActor->GetElemCell(theObjID);
1381 void SMESH_ActorDef::SetVisibility(int theMode){
1382 SetVisibility(theMode,true);
1386 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1387 SALOME_Actor::SetVisibility(theMode);
1389 myNodeActor->VisibilityOff();
1390 myBaseActor->VisibilityOff();
1392 myNodeExtActor->VisibilityOff();
1394 my0DActor->VisibilityOff();
1395 myBallActor->VisibilityOff();
1396 //my0DExtActor->VisibilityOff();
1398 my1DActor->VisibilityOff();
1399 my1DExtActor->VisibilityOff();
1401 my2DActor->VisibilityOff();
1402 my2DExtActor->VisibilityOff();
1403 my3DActor->VisibilityOff();
1404 my3DExtActor->VisibilityOff();
1406 myScalarBarActor->VisibilityOff();
1408 if(GetVisibility()){
1409 if(theIsUpdateRepersentation)
1410 SetRepresentation(GetRepresentation());
1412 if(myControlMode != eNone){
1413 switch(myControlMode){
1415 case eCoincidentNodes:
1416 myNodeExtActor->VisibilityOn();
1420 case eCoincidentElems1D:
1421 my1DExtActor->VisibilityOn();
1424 case eBareBorderFace:
1425 case eOverConstrainedFace:
1426 case eCoincidentElems2D:
1427 my2DExtActor->VisibilityOn();
1429 case eBareBorderVolume:
1430 case eOverConstrainedVolume:
1431 case eCoincidentElems3D:
1432 my3DExtActor->VisibilityOn();
1435 case eMultiConnection2D:
1436 my1DExtActor->VisibilityOn();
1438 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1439 myScalarBarActor->VisibilityOn();
1443 if(myRepresentation != ePoint)
1444 myPickableActor->VisibilityOn();
1446 myNodeActor->VisibilityOn();
1449 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1450 my0DActor->VisibilityOn();
1452 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1453 myBallActor->VisibilityOn();
1456 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1457 my1DActor->VisibilityOn();
1460 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1461 my2DActor->VisibilityOn();
1464 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1465 my3DActor->VisibilityOn();
1468 if(myNodeActor->GetPointsLabeled()){
1469 myNodeActor->VisibilityOn();
1473 my0DActor->UpdateLabels();
1476 myBallActor->UpdateLabels();
1479 my1DActor->UpdateLabels();
1482 my2DActor->UpdateLabels();
1485 my3DActor->UpdateLabels();
1487 #ifndef DISABLE_PLOT2DVIEWER
1489 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1496 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1498 myEntityState = eAllEntity;
1500 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1501 myEntityState &= ~e0DElements;
1502 theMode &= ~e0DElements;
1505 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1506 myEntityState &= ~eBallElem;
1507 theMode &= ~eBallElem;
1510 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1511 myEntityState &= ~eEdges;
1515 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1516 myEntityState &= ~eFaces;
1520 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1521 myEntityState &= ~eVolumes;
1522 theMode &= ~eVolumes;
1526 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1527 theMode |= e0DElements;
1529 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1530 theMode |= eBallElem;
1532 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1535 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1538 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1539 theMode |= eVolumes;
1542 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1544 myEntityMode = theMode;
1545 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1546 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1547 aFilter->ClearRegisteredCellsWithType();
1548 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1550 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1551 aHightFilter->ClearRegisteredCellsWithType();
1552 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1554 if (myEntityMode & e0DElements) {
1555 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1556 aFilter->RegisterCellsWithType(VTK_VERTEX);
1557 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1560 if (myEntityMode & eBallElem) {
1561 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1562 aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1565 if (myEntityMode & eEdges) {
1566 if (MYDEBUG) MESSAGE("EDGES");
1567 aFilter->RegisterCellsWithType(VTK_LINE);
1568 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1570 aHightFilter->RegisterCellsWithType(VTK_LINE);
1571 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1574 if (myEntityMode & eFaces) {
1575 if (MYDEBUG) MESSAGE("FACES");
1576 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1577 aFilter->RegisterCellsWithType(VTK_POLYGON);
1578 aFilter->RegisterCellsWithType(VTK_QUAD);
1579 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1580 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1581 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1582 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1584 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1585 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1586 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1587 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1588 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1589 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1590 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1593 if (myEntityMode & eVolumes) {
1594 if (MYDEBUG) MESSAGE("VOLUMES");
1595 aFilter->RegisterCellsWithType(VTK_TETRA);
1596 aFilter->RegisterCellsWithType(VTK_VOXEL);
1597 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1598 aFilter->RegisterCellsWithType(VTK_WEDGE);
1599 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1600 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1601 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1602 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1603 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1604 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1605 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1606 //#ifdef VTK_HAVE_POLYHEDRON
1607 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1610 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1611 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1612 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1613 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1614 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1615 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1616 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1617 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1618 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1619 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1620 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1621 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1622 //#ifdef VTK_HAVE_POLYHEDRON
1623 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1627 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1628 SetVisibility(GetVisibility(),false);
1631 void SMESH_ActorDef::SetRepresentation (int theMode)
1633 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1634 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1635 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1636 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1637 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1640 myRepresentation = eSurface;
1641 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1642 myRepresentation = eEdge;
1643 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1644 myRepresentation = ePoint;
1649 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1652 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1655 myRepresentation = theMode;
1658 if (!GetUnstructuredGrid()->GetNumberOfCells())
1659 myRepresentation = ePoint;
1662 if (myRepresentation == ePoint) {
1670 myPickableActor = myBaseActor;
1671 myNodeActor->SetVisibility(false);
1672 myNodeExtActor->SetVisibility(false);
1673 vtkProperty *aProp = NULL, *aBackProp = NULL;
1674 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1675 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1676 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1677 switch (myRepresentation) {
1679 myPickableActor = myNodeActor;
1680 myNodeActor->SetVisibility(true);
1681 aQuadraticMode = SMESH_Actor::eLines;
1682 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1683 aReperesent = SMESH_DeviceActor::ePoint;
1686 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1687 aReperesent = SMESH_DeviceActor::eInsideframe;
1690 aProp = mySurfaceProp;
1691 aBackProp = myBackSurfaceProp;
1692 aPropVN = myNormalVProp;
1693 aPropVR = myReversedVProp;
1694 aReperesent = SMESH_DeviceActor::eSurface;
1698 my2DActor->SetProperty(aProp);
1699 my2DActor->SetBackfaceProperty(aBackProp);
1700 my2DActor->SetRepresentation(aReperesent);
1702 if(aQuadraticMode == SMESH_Actor::eLines)
1703 my2DActor->SetQuadraticArcMode(false);
1704 else if(aQuadraticMode == SMESH_Actor::eArcs)
1705 my2DActor->SetQuadraticArcMode(true);
1707 my2DExtActor->SetRepresentation(aReperesent);
1709 my3DActor->SetProperty(aPropVN);
1710 my3DActor->SetBackfaceProperty(aPropVR);
1711 my3DActor->SetRepresentation(aReperesent);
1713 //my0DExtActor->SetVisibility(false);
1714 my1DExtActor->SetVisibility(false);
1715 my2DExtActor->SetVisibility(false);
1716 my3DExtActor->SetVisibility(false);
1719 //my0DActor->SetProperty(aProp);
1720 //my0DActor->SetBackfaceProperty(aBackProp);
1721 my0DActor->SetRepresentation(aReperesent);
1722 myBallActor->SetRepresentation(aReperesent);
1723 //my0DExtActor->SetRepresentation(aReperesent);
1725 switch(myControlMode){
1727 case eMultiConnection:
1728 aProp = aBackProp = my1DProp;
1729 if(myRepresentation != ePoint)
1730 aReperesent = SMESH_DeviceActor::eInsideframe;
1734 if(aQuadraticMode == SMESH_Actor::eLines)
1735 my1DActor->SetQuadraticArcMode(false);
1736 else if(aQuadraticMode == SMESH_Actor::eArcs)
1737 my1DActor->SetQuadraticArcMode(true);
1739 my1DActor->SetProperty(aProp);
1740 my1DActor->SetBackfaceProperty(aBackProp);
1741 my1DActor->SetRepresentation(aReperesent);
1743 my1DExtActor->SetRepresentation(aReperesent);
1745 if(myIsPointsVisible)
1746 myPickableActor = myNodeActor;
1747 if(GetPointRepresentation())
1748 myNodeActor->SetVisibility(true);
1750 SetMapper(myPickableActor->GetMapper());
1752 SetVisibility(GetVisibility(),false);
1758 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1759 if ( myIsPointsVisible == theIsPointsVisible )
1761 myIsPointsVisible = theIsPointsVisible;
1762 SetRepresentation(GetRepresentation());
1765 bool SMESH_ActorDef::GetPointRepresentation(){
1766 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1770 void SMESH_ActorDef::UpdateHighlight(){
1771 myHighlitableActor->SetHighlited(false);
1772 myHighlitableActor->SetVisibility(false);
1774 bool anIsVisible = GetVisibility();
1776 switch(myRepresentation){
1777 case SMESH_DeviceActor::eSurface:
1778 case SMESH_DeviceActor::eWireframe:
1780 if(myIsHighlighted) {
1781 myHighlitableActor->SetProperty(myHighlightProp);
1782 myBallActor->SetProperty(myBallHighlightProp);
1783 }else if(myIsPreselected){
1784 myHighlitableActor->SetProperty(myPreselectProp);
1785 myBallActor->SetProperty(myBallPreselectProp);
1786 } else if(anIsVisible){
1787 myBallActor->SetProperty(myBallProp);
1788 (myRepresentation == eSurface) ?
1789 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1791 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1792 myHighlitableActor->SetHighlited(anIsVisible);
1793 myHighlitableActor->GetExtractUnstructuredGrid()->
1794 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1795 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1797 myHighlitableActor->SetVisibility(anIsVisible);
1800 case SMESH_DeviceActor::ePoint:
1802 if(myIsHighlighted) {
1803 myNodeActor->SetProperty(myHighlightProp);
1804 }else if(myIsPreselected) {
1805 myNodeActor->SetProperty(myPreselectProp);
1806 } else if(anIsVisible) {
1807 myNodeActor->SetProperty(myNodeProp);
1809 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1810 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1817 void SMESH_ActorDef::highlight(bool theHighlight){
1818 if ( myIsHighlighted == theHighlight )
1820 myIsHighlighted = theHighlight;
1825 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1826 if ( myIsPreselected == thePreselect )
1828 myIsPreselected = thePreselect;
1834 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1836 if (myPickableActor->GetIsOpaque())
1838 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1846 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1848 if (!myPickableActor->GetIsOpaque())
1850 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1858 void SMESH_ActorDef::Render(vtkRenderer *ren){
1859 unsigned long aTime = myTimeStamp->GetMTime();
1860 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1861 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1862 if(anObjTime > aTime || aClippingTime > aTime)
1867 void SMESH_ActorDef::Update(){
1868 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1870 if(GetControlMode() != eNone) {
1871 unsigned long aTime = myTimeStamp->GetMTime();
1872 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1873 if (anObjTime > aTime)
1874 SetControlMode(GetControlMode(),false);
1878 myNodeActor->UpdateLabels();
1881 my0DActor->UpdateLabels();
1884 myBallActor->UpdateLabels();
1887 my1DActor->UpdateLabels();
1890 my2DActor->UpdateLabels();
1893 my3DActor->UpdateLabels();
1895 if(myIsFacesOriented){
1896 SetFacesOriented(myIsFacesOriented);
1899 if(myVisualObj->GetEntitiesFlag()) {
1900 myEntityMode |= myVisualObj->GetEntitiesState();
1903 SetEntityMode(GetEntityMode());
1904 SetVisibility(GetVisibility());
1906 myTimeStamp->Modified();
1911 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1912 SALOME_Actor::ReleaseGraphicsResources(renWin);
1914 myPickableActor->ReleaseGraphicsResources(renWin);
1918 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b){
1919 double* aColor = theProperty->GetColor();
1926 void SMESH_ActorDef::SetOpacity(double theValue){
1927 mySurfaceProp->SetOpacity(theValue);
1928 myBackSurfaceProp->SetOpacity(theValue);
1929 myNormalVProp->SetOpacity(theValue);
1930 myReversedVProp->SetOpacity(theValue);
1931 myEdgeProp->SetOpacity(theValue);
1932 myOutLineProp->SetOpacity(theValue);
1933 myNodeProp->SetOpacity(theValue);
1935 my1DProp->SetOpacity(theValue);
1936 my0DProp->SetOpacity(theValue);
1937 myBallProp->SetOpacity(theValue);
1941 double SMESH_ActorDef::GetOpacity(){
1942 return mySurfaceProp->GetOpacity();
1946 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta){
1947 mySurfaceProp->SetColor(r,g,b);
1948 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1949 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1950 if( aGroupObj->GetElementType() == SMDSAbs_Face )
1951 myNameActor->SetBackgroundColor(r,g,b);
1953 myDeltaBrightness = delta;
1954 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1955 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1959 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta){
1960 ::GetColor(mySurfaceProp,r,g,b);
1961 delta = myDeltaBrightness;
1964 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta){
1965 myNormalVProp->SetColor(r,g,b);
1966 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1967 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1968 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
1969 myNameActor->SetBackgroundColor(r,g,b);
1971 myDeltaVBrightness = delta;
1972 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1973 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1977 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta){
1978 ::GetColor(myNormalVProp,r,g,b);
1979 delta = myDeltaVBrightness;
1982 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b){
1983 myEdgeProp->SetColor(r,g,b);
1984 my1DProp->SetColor(r,g,b);
1985 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1986 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1987 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1988 myNameActor->SetBackgroundColor(r,g,b);
1992 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b){
1993 ::GetColor(myEdgeProp,r,g,b);
1996 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b){
1997 myOutLineProp->SetColor(r,g,b);
2001 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b){
2002 ::GetColor(myOutLineProp,r,g,b);
2006 void SMESH_ActorDef::SetNodeColor(double r,double g,double b){
2007 myNodeProp->SetColor(r,g,b);
2008 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2009 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2010 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2011 myNameActor->SetBackgroundColor(r,g,b);
2015 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b){
2016 ::GetColor(myNodeProp,r,g,b);
2019 void SMESH_ActorDef::Set0DColor(double r,double g,double b){
2020 my0DProp->SetColor(r,g,b);
2021 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2022 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2023 myNameActor->SetBackgroundColor(r,g,b);
2027 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b){
2028 ::GetColor(my0DProp,r,g,b);
2031 void SMESH_ActorDef::SetBallColor(double r,double g,double b){
2032 myBallProp->SetColor(r,g,b);
2033 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2034 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2035 myNameActor->SetBackgroundColor(r,g,b);
2039 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b){
2040 ::GetColor(myBallProp,r,g,b);
2043 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b){
2044 myHighlightProp->SetColor(r,g,b);
2045 myBallHighlightProp->SetColor(r,g,b);
2049 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b){
2050 ::GetColor(myHighlightProp,r,g,b);
2053 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b){
2054 myPreselectProp->SetColor(r,g,b);
2055 myBallPreselectProp->SetColor(r,g,b);
2059 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b){
2060 ::GetColor(myPreselectProp,r,g,b);
2064 double SMESH_ActorDef::GetLineWidth(){
2065 return myEdgeProp->GetLineWidth();
2069 void SMESH_ActorDef::SetLineWidth(double theVal){
2070 myEdgeProp->SetLineWidth(theVal);
2072 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2073 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2074 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2075 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2076 myOutLineProp->SetLineWidth(theVal);
2077 myHighlightProp->SetLineWidth(theVal);
2078 myPreselectProp->SetLineWidth(theVal);
2082 double SMESH_ActorDef::GetOutlineWidth()
2084 return myOutLineProp->GetLineWidth();
2087 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2089 myOutLineProp->SetLineWidth(theVal);
2093 void SMESH_ActorDef::Set0DSize(double theVal){
2094 my0DProp->SetPointSize(theVal);
2095 myHighlightProp->SetPointSize(theVal);
2096 myPreselectProp->SetPointSize(theVal);
2098 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2099 aCustom->Set0DSize(theVal);
2101 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2102 aCustom->Set0DSize(theVal);
2108 double SMESH_ActorDef::Get0DSize(){
2109 return my0DProp->GetPointSize();
2112 void SMESH_ActorDef::SetBallSize(double theVal){
2113 myBallProp->SetPointSize(theVal);
2114 myBallHighlightProp->SetPointSize(theVal);
2115 myBallPreselectProp->SetPointSize(theVal);
2116 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2117 aCustom->SetBallSize(theVal);
2119 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2120 aCustom->SetBallSize(theVal);
2126 double SMESH_ActorDef::GetBallSize(){
2127 return myBallProp->GetPointSize();
2130 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2132 return myVisualObj->GetElemDimension( theObjId );
2137 IsImplicitFunctionUsed() const
2139 return myBaseActor->IsImplicitFunctionUsed();
2143 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2145 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2146 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2148 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2150 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2152 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2153 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2154 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2156 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2157 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2159 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2160 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2161 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2162 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2166 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2169 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2170 myCippingPlaneCont.push_back(thePlane);
2171 if(!IsImplicitFunctionUsed())
2172 SetImplicitFunctionUsed(true);
2173 myNodeActor->UpdateLabels();
2175 return myCippingPlaneCont.size();
2180 RemoveAllClippingPlanes()
2182 myImplicitBoolean->GetFunction()->RemoveAllItems();
2183 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2184 myCippingPlaneCont.clear();
2185 SetImplicitFunctionUsed(false);
2186 myNodeActor->UpdateLabels();
2191 GetNumberOfClippingPlanes()
2193 return myCippingPlaneCont.size();
2198 GetClippingPlane(vtkIdType theID)
2200 if(theID >= myCippingPlaneCont.size())
2202 return myCippingPlaneCont[theID].Get();
2205 void SMESH_ActorDef::UpdateScalarBar()
2207 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2211 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2213 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2214 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2216 aScalarBarTitleProp->SetFontFamilyToArial();
2218 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2220 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2221 if ( f.family() == "Arial" )
2222 aScalarBarTitleProp->SetFontFamilyToArial();
2223 else if ( f.family() == "Courier" )
2224 aScalarBarTitleProp->SetFontFamilyToCourier();
2225 else if ( f.family() == "Times" )
2226 aScalarBarTitleProp->SetFontFamilyToTimes();
2229 aScalarBarTitleProp->BoldOn();
2231 aScalarBarTitleProp->BoldOff();
2234 aScalarBarTitleProp->ItalicOn();
2236 aScalarBarTitleProp->ItalicOff();
2239 aScalarBarTitleProp->ShadowOn();
2241 aScalarBarTitleProp->ShadowOff();
2244 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2245 aScalarBarTitleProp->Delete();
2247 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2249 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2250 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2252 aScalarBarLabelProp->SetFontFamilyToArial();
2253 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2255 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2256 if( f.family() == "Arial" )
2257 aScalarBarLabelProp->SetFontFamilyToArial();
2258 else if( f.family() == "Courier" )
2259 aScalarBarLabelProp->SetFontFamilyToCourier();
2260 else if( f.family() == "Times" )
2261 aScalarBarLabelProp->SetFontFamilyToTimes();
2264 aScalarBarLabelProp->BoldOn();
2266 aScalarBarLabelProp->BoldOff();
2269 aScalarBarLabelProp->ItalicOn();
2271 aScalarBarLabelProp->ItalicOff();
2274 aScalarBarLabelProp->ShadowOn();
2276 aScalarBarLabelProp->ShadowOff();
2279 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2280 aScalarBarLabelProp->Delete();
2282 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2283 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2285 myScalarBarActor->SetOrientationToHorizontal();
2287 myScalarBarActor->SetOrientationToVertical();
2290 double aXVal = horiz ? 0.20 : 0.01;
2291 if( mgr->hasValue( "SMESH", name + "x" ) )
2292 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2294 double aYVal = horiz ? 0.01 : 0.1;
2295 if( mgr->hasValue( "SMESH", name + "y" ) )
2296 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2297 myScalarBarActor->SetPosition( aXVal, aYVal );
2299 double aWVal = horiz ? 0.60 : 0.10;
2300 if( mgr->hasValue( "SMESH", name + "width" ) )
2301 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2302 myScalarBarActor->SetWidth( aWVal );
2304 double aHVal = horiz ? 0.12 : 0.80;
2305 if( mgr->hasValue( "SMESH", name + "height" ) )
2306 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2307 myScalarBarActor->SetHeight( aHVal );
2310 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2311 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2312 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2315 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2316 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2317 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2319 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2320 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2322 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2323 myScalarBarActor->SetDistributionColoringType(coloringType);
2325 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2326 QColor(255, 255, 255));
2328 rgb[0]= distributionColor.red()/255.;
2329 rgb[1]= distributionColor.green()/255.;
2330 rgb[2]= distributionColor.blue()/255.;
2331 myScalarBarActor->SetDistributionColor(rgb);
2336 void SMESH_ActorDef::UpdateDistribution()
2338 if(SMESH::Controls::NumericalFunctor* fun =
2339 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2341 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2342 std::vector<int> nbEvents;
2343 std::vector<double> funValues;
2344 SMESH_VisualObjDef::TEntityList elems;
2345 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2346 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2347 std::vector<int> elemIds;
2348 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2349 elemIds.push_back( (*e)->GetID());
2350 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2351 double * range = lookupTable->GetRange();
2352 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2353 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2354 myScalarBarActor->SetDistribution(nbEvents);
2358 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2361 case SMESH_Actor::eLines :
2362 myHighlitableActor->SetQuadraticArcMode(false);
2363 my2DActor->SetQuadraticArcMode(false);
2364 my1DActor->SetQuadraticArcMode(false);
2366 case SMESH_Actor::eArcs :
2367 myHighlitableActor->SetQuadraticArcMode(true);
2368 if(GetRepresentation() != SMESH_Actor::ePoint) {
2369 my2DActor->SetQuadraticArcMode(true);
2370 my1DActor->SetQuadraticArcMode(true);
2379 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2381 if(myHighlitableActor->GetQuadraticArcMode())
2382 return SMESH_Actor::eArcs;
2384 return SMESH_Actor::eLines;
2387 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2389 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2390 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2391 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2394 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2396 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2397 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2398 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2399 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2402 #ifndef DISABLE_PLOT2DVIEWER
2403 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2406 my2dHistogram->clearAllPoints();
2408 if(SMESH::Controls::NumericalFunctor* fun =
2409 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2412 if(!my2dHistogram) {
2413 my2dHistogram = new SPlot2d_Histogram();
2414 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2415 my2dHistogram->setIO(anIO);
2418 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2419 std::vector<int> nbEvents;
2420 std::vector<double> funValues;
2421 SMESH_VisualObjDef::TEntityList elems;
2422 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2423 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2424 std::vector<int> elemIds;
2426 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2427 elemIds.push_back( (*e)->GetID());
2429 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2430 double * range = lookupTable->GetRange();
2431 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2432 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2434 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2435 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2437 if(funValues.size() >= 2)
2438 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2442 //Color of the histogram
2443 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2444 my2dHistogram->setAutoAssign(true);
2447 myScalarBarActor->GetDistributionColor(rgb);
2448 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2449 my2dHistogram->setColor(aColor);
2453 return my2dHistogram;