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
22 // SMESH OBJECT : interactive object for SMESH visualization
23 // File : SMESH_Actor.cxx
24 // Author : Nicolas REJNERI
27 #include "SMESH_ActorDef.h"
28 #include "SMESH_ActorUtils.h"
29 #include "SMESH_DeviceActor.h"
30 #include "SMESH_NodeLabelActor.h"
31 #include "SMESH_CellLabelActor.h"
32 #include "SMESH_ObjectDef.h"
33 #include "SMESH_ControlsDef.hxx"
34 #include "SMDS_UnstructuredGrid.hxx"
35 #include "SMESH_ScalarBarActor.h"
36 #include "VTKViewer_ExtractUnstructuredGrid.h"
37 #include "VTKViewer_FramedTextActor.h"
38 #include "SALOME_InteractiveObject.hxx"
39 #include "SMESH_SVTKActor.h"
41 #include "SUIT_Session.h"
42 #include "SUIT_ResourceMgr.h"
46 #ifndef DISABLE_PLOT2DVIEWER
47 #include <SPlot2d_Histogram.h>
50 #include <vtkProperty.h>
51 #include <vtkTimeStamp.h>
52 #include <vtkObjectFactory.h>
53 #include <vtkShrinkPolyData.h>
54 #include <vtkMergeFilter.h>
56 #include <vtkMatrix4x4.h>
57 #include <vtkUnstructuredGrid.h>
58 #include <vtkPointData.h>
59 #include <vtkCellData.h>
61 #include <vtkMapper.h>
62 #include <vtkRenderer.h>
65 #include <vtkIdList.h>
66 #include <vtkIntArray.h>
68 #include <vtkActor2D.h>
69 #include <vtkProperty2D.h>
70 #include <vtkPolyData.h>
71 #include <vtkTextProperty.h>
73 #include <vtkLookupTable.h>
77 #include <vtkImplicitBoolean.h>
78 #include <vtkImplicitFunctionCollection.h>
80 #include <vtkConfigure.h>
81 #if !defined(VTK_XVERSION)
82 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
85 #include "utilities.h"
88 static int MYDEBUG = 1;
90 static int MYDEBUG = 1;
93 static int aLineWidthInc = 2;
96 SMESH_ActorDef* SMESH_ActorDef::New(){
97 return new SMESH_ActorDef();
101 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 const char* theEntry,
106 SMESH_ActorDef* anActor = NULL;
107 if(theVisualObj->IsValid() ) {
108 anActor = SMESH_ActorDef::New();
109 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
114 anActor->UpdateScalarBar();
120 SMESH_ActorDef::SMESH_ActorDef()
122 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
123 myBaseActor = SMESH_DeviceActor::New();
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
128 myIsEntityModeCache = false;
130 myHighlightActor = SMESH_SVTKActor::New();
131 myHighlightActor->Delete(); // vtkSmartPointer!
132 myHighlightActor->Initialize();
134 myPreHighlightActor = SMESH_SVTKActor::New();
135 myPreHighlightActor->Delete();
136 myPreHighlightActor->Initialize();
138 myIsShrinkable = false;
141 myIsFacesOriented = false;
143 myControlsPrecision = -1;
144 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
146 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
147 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
149 double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
150 double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
151 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
152 double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
154 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
156 bool anItalicNd = false;
157 bool aShadowNd = false;
159 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
160 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
161 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
162 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
163 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
165 anItalicNd = f.italic();
166 aShadowNd = f.overline();
167 aSizeNd = f.pointSize();
169 double anRGBNd[3] = {1,1,1};
170 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
172 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
174 bool anItalicEl = false;
175 bool aShadowEl = false;
177 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
178 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
179 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
180 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
181 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
183 anItalicEl = f.italic();
184 aShadowEl = f.overline();
185 aSizeEl = f.pointSize();
187 double anRGBEl[3] = {0,1,0};
188 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
190 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
191 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
193 //Definition 2D and 3D devices of the actor
194 //-----------------------------------------
195 double anRGB[3] = {1,1,1};
196 mySurfaceProp = vtkProperty::New();
199 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
200 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
201 myDeltaBrightness = delta;
203 myBackSurfaceProp = vtkProperty::New();
204 bfc = Qtx::mainColorToSecondary(ffc, delta);
205 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
207 myNormalVProp = vtkProperty::New();
208 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
209 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
210 myDeltaVBrightness = delta;
212 myReversedVProp = vtkProperty::New();
213 bfc = Qtx::mainColorToSecondary(ffc, delta);
214 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
216 my2DActor = SMESH_CellLabelActor::New();
217 my2DActor->SetStoreGemetryMapping(true);
218 my2DActor->SetUserMatrix(aMatrix);
219 my2DActor->PickableOff();
220 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
221 my2DActor->SetProperty(mySurfaceProp);
222 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
223 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
224 aFilter = my2DActor->GetExtractUnstructuredGrid();
225 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
226 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
227 aFilter->RegisterCellsWithType(VTK_POLYGON);
228 aFilter->RegisterCellsWithType(VTK_QUAD);
229 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
231 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
233 my2DExtProp = vtkProperty::New();
234 my2DExtProp->DeepCopy(mySurfaceProp);
235 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
236 anRGB[0] = 1 - anRGB[0];
237 anRGB[1] = 1 - anRGB[1];
238 anRGB[2] = 1 - anRGB[2];
239 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
241 my2DExtActor = SMESH_DeviceActor::New();
242 my2DExtActor->SetUserMatrix(aMatrix);
243 my2DExtActor->PickableOff();
244 my2DExtActor->SetProperty(my2DExtProp);
245 my2DExtActor->SetBackfaceProperty(my2DExtProp);
246 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
247 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
248 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
249 aFilter->RegisterCellsWithType(VTK_POLYGON);
250 aFilter->RegisterCellsWithType(VTK_QUAD);
251 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
252 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
253 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
255 my3DActor = SMESH_CellLabelActor::New();
256 my3DActor->SetStoreGemetryMapping(true);
257 my3DActor->SetUserMatrix(aMatrix);
258 my3DActor->PickableOff();
259 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
260 my3DActor->SetProperty(myNormalVProp);
261 my3DActor->SetBackfaceProperty(myReversedVProp);
262 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
263 my3DActor->SetCoincident3DAllowed(true);
264 aFilter = my3DActor->GetExtractUnstructuredGrid();
265 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
266 aFilter->RegisterCellsWithType(VTK_TETRA);
267 aFilter->RegisterCellsWithType(VTK_VOXEL);
268 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
269 aFilter->RegisterCellsWithType(VTK_WEDGE);
270 aFilter->RegisterCellsWithType(VTK_PYRAMID);
271 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
272 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
273 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
274 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
275 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
276 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
277 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
278 //#ifdef VTK_HAVE_POLYHEDRON
279 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
280 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
283 my3DExtProp = vtkProperty::New();
284 my3DExtProp->DeepCopy(myNormalVProp);
285 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
286 anRGB[0] = 1 - anRGB[0];
287 anRGB[1] = 1 - anRGB[1];
288 anRGB[2] = 1 - anRGB[2];
289 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
291 my3DExtActor = SMESH_DeviceActor::New();
292 my3DExtActor->SetUserMatrix(aMatrix);
293 my3DExtActor->PickableOff();
294 my3DExtActor->SetProperty(my3DExtProp);
295 my3DExtActor->SetBackfaceProperty(my3DExtProp);
296 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
297 my3DExtActor->SetCoincident3DAllowed(true);
298 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
299 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
300 aFilter->RegisterCellsWithType(VTK_TETRA);
301 aFilter->RegisterCellsWithType(VTK_VOXEL);
302 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
303 aFilter->RegisterCellsWithType(VTK_WEDGE);
304 aFilter->RegisterCellsWithType(VTK_PYRAMID);
305 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
306 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
307 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
308 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
309 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
310 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
311 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
312 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
314 //Definition 1D device of the actor
315 //---------------------------------
316 myEdgeProp = vtkProperty::New();
317 myEdgeProp->SetAmbient(1.0);
318 myEdgeProp->SetDiffuse(0.0);
319 myEdgeProp->SetSpecular(0.0);
320 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
321 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
322 myEdgeProp->SetLineWidth(aLineWidth);
324 my1DActor = SMESH_CellLabelActor::New();
325 my1DActor->SetStoreGemetryMapping(true);
326 my1DActor->SetUserMatrix(aMatrix);
327 my1DActor->PickableOff();
328 my1DActor->SetHighlited(true);
329 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
330 my1DActor->SetProperty(myEdgeProp);
331 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
332 aFilter = my1DActor->GetExtractUnstructuredGrid();
333 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
334 aFilter->RegisterCellsWithType(VTK_LINE);
335 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
337 my1DProp = vtkProperty::New();
338 my1DProp->DeepCopy(myEdgeProp);
339 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
340 my1DProp->SetPointSize(aElem0DSize);
342 my1DExtProp = vtkProperty::New();
343 my1DExtProp->DeepCopy(myEdgeProp);
344 anRGB[0] = 1 - anRGB[0];
345 anRGB[1] = 1 - anRGB[1];
346 anRGB[2] = 1 - anRGB[2];
347 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
348 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
349 my1DExtProp->SetPointSize(aElem0DSize);
351 my1DExtActor = SMESH_DeviceActor::New();
352 my1DExtActor->SetUserMatrix(aMatrix);
353 my1DExtActor->PickableOff();
354 my1DExtActor->SetHighlited(true);
355 my1DExtActor->SetVisibility(false);
356 my1DExtActor->SetProperty(my1DExtProp);
357 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
358 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
359 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
360 aFilter->RegisterCellsWithType(VTK_LINE);
361 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
364 //Definition 0D device of the actor (0d elements)
365 //-----------------------------------------------
366 my0DProp = vtkProperty::New();
367 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
368 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
369 my0DProp->SetPointSize(aElem0DSize);
371 my0DActor = SMESH_CellLabelActor::New();
372 my0DActor->SetUserMatrix(aMatrix);
373 my0DActor->SetStoreGemetryMapping(true);
374 my0DActor->PickableOff();
375 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
376 my0DActor->SetVisibility(false);
377 my0DActor->SetProperty(my0DProp);
378 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
379 aFilter = my0DActor->GetExtractUnstructuredGrid();
380 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
381 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
382 aFilter->RegisterCellsWithType(VTK_VERTEX);
384 //Definition 0D device of the actor (ball elements)
385 //-----------------------------------------------
386 myBallProp = vtkProperty::New();
387 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
388 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
389 myBallProp->SetPointSize(aBallElemSize);
391 myBallActor = SMESH_CellLabelActor::New();
392 myBallActor->SetUserMatrix(aMatrix);
393 myBallActor->SetStoreGemetryMapping(true);
394 myBallActor->PickableOff();
395 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
396 myBallActor->SetVisibility(false);
397 myBallActor->SetProperty(myBallProp);
398 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
399 aFilter = myBallActor->GetExtractUnstructuredGrid();
400 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
401 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
403 //my0DExtProp = vtkProperty::New();
404 //my0DExtProp->DeepCopy(my0DProp);
405 //anRGB[0] = 1 - anRGB[0];
406 //anRGB[1] = 1 - anRGB[1];
407 //anRGB[2] = 1 - anRGB[2];
408 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
409 //my0DExtProp->SetPointSize(aElem0DSize);
411 //my0DExtActor = SMESH_DeviceActor::New();
412 //my0DExtActor->SetUserMatrix(aMatrix);
413 //my0DExtActor->SetStoreClippingMapping(true);
414 //my0DExtActor->PickableOff();
415 //my0DExtActor->SetHighlited(true);
416 //my0DExtActor->SetVisibility(false);
417 //my0DExtActor->SetProperty(my0DExtProp);
418 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
419 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
420 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
421 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
422 //aFilter->RegisterCellsWithType(VTK_VERTEX);
425 //Definition 0D device of the actor (nodes)
426 //-----------------------------------------
427 myNodeProp = vtkProperty::New();
428 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
429 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
431 myNodeActor = SMESH_NodeLabelActor::New();
432 myNodeActor->SetUserMatrix(aMatrix);
433 myNodeActor->SetStoreClippingMapping(true);
434 myNodeActor->PickableOff();
435 myNodeActor->SetVisibility(false);
436 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
437 myNodeActor->SetProperty(myNodeProp);
438 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
439 aFilter = myNodeActor->GetExtractUnstructuredGrid();
440 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
442 myNodeExtProp = vtkProperty::New();
443 myNodeExtProp->DeepCopy(myNodeProp);
444 anRGB[0] = 1 - anRGB[0];
445 anRGB[1] = 1 - anRGB[1];
446 anRGB[2] = 1 - anRGB[2];
447 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
449 myNodeExtActor = SMESH_DeviceActor::New();
450 myNodeExtActor->SetUserMatrix(aMatrix);
451 myNodeExtActor->SetStoreClippingMapping(true);
452 myNodeExtActor->PickableOff();
453 myNodeExtActor->SetHighlited(true);
454 myNodeExtActor->SetVisibility(false);
455 myNodeExtActor->SetProperty(myNodeExtProp);
456 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
457 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
458 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
459 aFilter->RegisterCellsWithType(VTK_VERTEX);
461 //Definition of Pickable and Highlitable engines
462 //----------------------------------------------
464 myBaseActor->SetUserMatrix(aMatrix);
465 myBaseActor->SetStoreGemetryMapping(true);
466 myBaseActor->GetProperty()->SetOpacity(0.0);
467 myPickableActor = myBaseActor;
469 myHighlightProp = vtkProperty::New();
470 myHighlightProp->SetAmbient(1.0);
471 myHighlightProp->SetDiffuse(0.0);
472 myHighlightProp->SetSpecular(0.0);
473 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
474 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
475 myHighlightProp->SetPointSize(aElem0DSize); // ??
476 myHighlightProp->SetLineWidth(aLineWidth);
477 myHighlightProp->SetRepresentation(1);
479 myBallHighlightProp = vtkProperty::New();
480 myBallHighlightProp->DeepCopy(myHighlightProp);
481 myBallHighlightProp->SetPointSize(aBallElemSize);
484 myOutLineProp = vtkProperty::New();
485 myOutLineProp->SetAmbient(1.0);
486 myOutLineProp->SetDiffuse(0.0);
487 myOutLineProp->SetSpecular(0.0);
488 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
489 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
490 myOutLineProp->SetLineWidth(aOutlineWidth);
491 myOutLineProp->SetRepresentation(1);
493 myPreselectProp = vtkProperty::New();
494 myPreselectProp->SetAmbient(1.0);
495 myPreselectProp->SetDiffuse(0.0);
496 myPreselectProp->SetSpecular(0.0);
497 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
498 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
499 myPreselectProp->SetPointSize(aElem0DSize); // ??
500 myPreselectProp->SetLineWidth(aLineWidth);
501 myPreselectProp->SetRepresentation(1);
503 myBallPreselectProp = vtkProperty::New();
504 myBallPreselectProp->DeepCopy(myPreselectProp);
505 myBallPreselectProp->SetPointSize(aBallElemSize);
507 myHighlitableActor = SMESH_DeviceActor::New();
508 myHighlitableActor->SetUserMatrix(aMatrix);
509 myHighlitableActor->PickableOff();
510 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
511 myHighlitableActor->SetCoincident3DAllowed(true);
518 myControlMode = eNone;
519 myControlActor = my2DActor;
521 //Definition of myScalarBarActor
522 //------------------------------
523 myLookupTable = vtkLookupTable::New();
524 //Fix for Bug PAL5195 - SMESH764:
525 //Controls - Aspect Ratio: incorrect colors of the best and worst values
526 myLookupTable->SetHueRange(0.667,0.0);
528 myScalarBarActor = SMESH_ScalarBarActor::New();
529 myScalarBarActor->SetVisibility(false);
530 myScalarBarActor->SetLookupTable(myLookupTable);
533 //Incorrect "Min value" in Scalar Bar in Mesh:
534 // myScalarBarActor->SetLabelFormat("%.4g");
535 // changes was commented because of regression bug IPAL 19981
537 mgr = SUIT_Session::session()->resourceMgr();
541 myEntityMode = eAllEntity;
542 myEntityModeCache = eAllEntity;
545 myImplicitBoolean = vtkImplicitBoolean::New();
546 myImplicitBoolean->SetOperationTypeToIntersection();
548 //Quadratic 2D elements representation
549 //-----------------------------------------------------------------------------
550 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
551 if(aQuadratic2DMode == 0){
552 myHighlitableActor->SetQuadraticArcMode(false);
553 my2DActor->SetQuadraticArcMode(false);
554 my1DActor->SetQuadraticArcMode(false);
556 else if(aQuadratic2DMode == 1){
557 myHighlitableActor->SetQuadraticArcMode(true);
558 my2DActor->SetQuadraticArcMode(true);
559 my1DActor->SetQuadraticArcMode(true);
562 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
563 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
564 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
566 // Set colors of the name actor
567 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
568 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
569 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
570 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
572 #ifndef DISABLE_PLOT2DVIEWER
576 SetBallSize(aBallElemSize);
577 Set0DSize(aElem0DSize);
581 SMESH_ActorDef::~SMESH_ActorDef()
583 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
585 // Please keep the order same as one in the header file
587 myTimeStamp->Delete();
589 myScalarBarActor->Delete();
590 myLookupTable->Delete();
592 mySurfaceProp->Delete();
593 myBackSurfaceProp->Delete();
594 myNormalVProp->Delete();
595 myReversedVProp->Delete();
596 myEdgeProp->Delete();
597 myNodeProp->Delete();
599 myNodeActor->Delete();
600 myBaseActor->Delete();
601 //myPickableActor->Delete(); myPickableActor == myBaseActor
603 myHighlightProp->Delete();
604 myOutLineProp->Delete();
605 myPreselectProp->Delete();
607 myBallHighlightProp->Delete();
608 myBallPreselectProp->Delete();
610 myHighlitableActor->Delete();
612 my2DExtProp->Delete();
613 my3DExtProp->Delete();
615 my2DExtActor->Delete();
617 my3DExtActor->Delete();
618 // myControlActor->Delete(); myControlActor == my2DActor
620 myNodeExtProp->Delete();
621 myNodeExtActor->Delete();
625 my1DExtProp->Delete();
626 my1DExtActor->Delete();
630 myBallProp->Delete();
631 myBallActor->Delete();
632 //my0DExtProp->Delete();
633 //my0DExtActor->Delete();
635 myImplicitBoolean->Delete();
637 #ifndef DISABLE_PLOT2DVIEWER
639 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
640 delete my2dHistogram;
645 void SMESH_ActorDef::Delete()
647 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
648 // from the actor's destructor) will be thrown before removing the actor's observers,
649 // that is done inside the Superclass::Delete() method but before the destructor itself
650 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
651 // The event is caught by SMESHGUI::ProcessEvents() static method.
652 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
654 Superclass::Delete();
657 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
660 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
661 SetRepresentation(GetRepresentation());
662 myTimeStamp->Modified();
666 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
667 bool theBold, bool theItalic, bool theShadow,
668 double r, double g, double b )
671 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
672 SetRepresentation( GetRepresentation() );
673 myTimeStamp->Modified();
677 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
678 bool theBold, bool theItalic, bool theShadow,
679 double r, double g, double b )
682 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
683 SetRepresentation( GetRepresentation() );
684 myTimeStamp->Modified();
687 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
688 SetRepresentation( GetRepresentation() );
689 myTimeStamp->Modified();
692 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
693 SetRepresentation( GetRepresentation() );
694 myTimeStamp->Modified();
697 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
698 SetRepresentation( GetRepresentation() );
699 myTimeStamp->Modified();
702 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
703 SetRepresentation( GetRepresentation() );
704 myTimeStamp->Modified();
708 bool SMESH_ActorDef::GetPointsLabeled() {
709 return myNodeActor && myNodeActor->GetPointsLabeled();
712 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
715 my3DActor->SetCellsLabeled(theIsCellsLabeled);
718 my2DActor->SetCellsLabeled(theIsCellsLabeled);
721 my1DActor->SetCellsLabeled(theIsCellsLabeled);
724 my0DActor->SetCellsLabeled(theIsCellsLabeled);
727 myBallActor->SetCellsLabeled(theIsCellsLabeled);
729 myTimeStamp->Modified();
733 bool SMESH_ActorDef::GetCellsLabeled() {
736 result = result || my3DActor->GetCellsLabeled();
739 result = result || my2DActor->GetCellsLabeled();
742 result = result || my1DActor->GetCellsLabeled();
745 result = result || my0DActor->GetCellsLabeled();
748 result = result || myBallActor->GetCellsLabeled();
754 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
756 myIsFacesOriented = theIsFacesOriented;
758 my2DActor->SetFacesOriented(theIsFacesOriented);
759 my3DActor->SetFacesOriented(theIsFacesOriented);
761 myTimeStamp->Modified();
764 bool SMESH_ActorDef::GetFacesOriented()
766 return myIsFacesOriented;
769 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
771 my2DActor->SetFacesOrientationColor( r, g, b );
772 my3DActor->SetFacesOrientationColor( r, g, b );
775 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
777 my3DActor->GetFacesOrientationColor( r, g, b );
780 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
782 my2DActor->SetFacesOrientationScale( theScale );
783 my3DActor->SetFacesOrientationScale( theScale );
786 double SMESH_ActorDef::GetFacesOrientationScale()
788 return my3DActor->GetFacesOrientationScale();
791 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
793 my2DActor->SetFacesOrientation3DVectors( theState );
794 my3DActor->SetFacesOrientation3DVectors( theState );
797 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
799 return my3DActor->GetFacesOrientation3DVectors();
805 SetControlMode(eControl theMode)
807 SetControlMode(theMode,true);
813 SetControlMode(eControl theMode,
814 bool theCheckEntityMode)
816 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
817 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
818 lookupTable->SetScale(VTK_SCALE_LINEAR);
820 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
824 myControlMode = eNone;
825 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
827 my0DActor->GetMapper()->SetScalarVisibility(false);
828 my1DActor->GetMapper()->SetScalarVisibility(false);
829 my2DActor->GetMapper()->SetScalarVisibility(false);
830 my3DActor->GetMapper()->SetScalarVisibility(false);
831 myBallActor->GetMapper()->SetScalarVisibility(false);
832 myScalarBarActor->SetVisibility(false);
834 bool anIsScalarVisible = theMode > eNone;
836 if(anIsScalarVisible) {
840 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
841 aControl->SetPrecision( myControlsPrecision );
842 myFunctor.reset( aControl );
843 myControlActor = my1DActor;
848 myFunctor.reset(new SMESH::Controls::Length2D());
849 myControlActor = my2DActor;
853 myFunctor.reset(new SMESH::Controls::FreeBorders());
854 myControlActor = my1DActor;
857 myFunctor.reset(new SMESH::Controls::FreeEdges());
858 myControlActor = my2DActor;
861 myFunctor.reset(new SMESH::Controls::FreeNodes());
862 myControlActor = myNodeActor;
865 myFunctor.reset(new SMESH::Controls::FreeFaces());
866 myControlActor = my2DActor;
868 case eCoincidentNodes:
870 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
871 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
872 cn->SetTolerance( tol );
874 myControlActor = myNodeActor;
877 case eCoincidentElems1D:
878 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
879 myControlActor = my1DActor;
881 case eCoincidentElems2D:
882 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
883 myControlActor = my2DActor;
885 case eCoincidentElems3D:
886 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
887 myControlActor = my3DActor;
889 case eBareBorderFace:
890 myFunctor.reset(new SMESH::Controls::BareBorderFace());
891 myControlActor = my2DActor;
893 case eOverConstrainedFace:
894 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
895 myControlActor = my2DActor;
897 case eMultiConnection:
898 myFunctor.reset(new SMESH::Controls::MultiConnection());
899 myControlActor = my1DActor;
901 case eMultiConnection2D:
902 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
903 myControlActor = my2DActor;
907 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
908 aControl->SetPrecision( myControlsPrecision );
909 myFunctor.reset( aControl );
910 myControlActor = my2DActor;
915 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
916 aControl->SetPrecision( myControlsPrecision );
917 myFunctor.reset( aControl );
918 myControlActor = my2DActor;
923 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
924 aControl->SetPrecision( myControlsPrecision );
925 myFunctor.reset( aControl );
926 myControlActor = my2DActor;
931 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
932 aControl->SetPrecision( myControlsPrecision );
933 myFunctor.reset( aControl );
934 myControlActor = my3DActor;
939 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
940 aControl->SetPrecision( myControlsPrecision );
941 myFunctor.reset( aControl );
942 myControlActor = my3DActor;
945 case eMaxElementLength2D:
947 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
948 aControl->SetPrecision( myControlsPrecision );
949 myFunctor.reset( aControl );
950 myControlActor = my2DActor;
953 case eMaxElementLength3D:
955 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
956 aControl->SetPrecision( myControlsPrecision );
957 myFunctor.reset( aControl );
958 myControlActor = my3DActor;
961 case eBareBorderVolume:
963 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
964 myControlActor = my3DActor;
967 case eOverConstrainedVolume:
969 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
970 myControlActor = my3DActor;
975 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
976 aControl->SetPrecision( myControlsPrecision );
977 myFunctor.reset( aControl );
978 myControlActor = my2DActor;
983 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
984 aControl->SetPrecision( myControlsPrecision );
985 myFunctor.reset( aControl );
986 myControlActor = my2DActor;
991 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
992 aControl->SetPrecision( myControlsPrecision );
993 myFunctor.reset( aControl );
994 myControlActor = my2DActor;
1001 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
1002 vtkIdType aNbCells = aGrid->GetNumberOfCells();
1004 myControlMode = theMode;
1005 switch(myControlMode){
1007 case eCoincidentNodes:
1008 myNodeExtActor->SetExtControlMode(myFunctor);
1012 case eCoincidentElems1D:
1013 my1DExtActor->SetExtControlMode(myFunctor);
1016 case eBareBorderFace:
1017 case eOverConstrainedFace:
1018 case eCoincidentElems2D:
1019 my2DExtActor->SetExtControlMode(myFunctor);
1021 case eBareBorderVolume:
1022 case eOverConstrainedVolume:
1023 case eCoincidentElems3D:
1024 my3DExtActor->SetExtControlMode(myFunctor);
1027 case eMultiConnection2D:
1028 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1029 UpdateDistribution();
1032 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1033 UpdateDistribution();
1037 if(theCheckEntityMode) {
1038 if(myControlActor == my1DActor) {
1039 if (!myIsEntityModeCache){
1040 myEntityModeCache = GetEntityMode();
1041 myIsEntityModeCache=true;
1043 SetEntityMode(eEdges);
1045 else if(myControlActor == my2DActor) {
1046 switch(myControlMode) {
1050 case eMultiConnection2D:
1051 if (!myIsEntityModeCache){
1052 myEntityModeCache = GetEntityMode();
1053 myIsEntityModeCache=true;
1055 SetEntityMode(eFaces);
1058 if (!myIsEntityModeCache){
1059 myEntityModeCache = GetEntityMode();
1060 myIsEntityModeCache=true;
1062 SetEntityMode(eFaces);
1064 }else if(myControlActor == my3DActor) {
1065 if (!myIsEntityModeCache){
1066 myEntityModeCache = GetEntityMode();
1067 myIsEntityModeCache=true;
1069 SetEntityMode(eVolumes);
1075 if(theCheckEntityMode){
1076 myEntityMode = myEntityModeCache;
1077 myIsEntityModeCache = false;
1082 SetRepresentation(GetRepresentation());
1084 myTimeStamp->Modified();
1087 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1088 double * range = lookupTable->GetRange();
1090 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1091 lookupTable->SetScale(VTK_SCALE_LOG10);
1097 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
1099 //myHighlightActor->AddToRender(theRenderer);
1101 theRenderer->AddActor(myBaseActor);
1102 theRenderer->AddActor(myNodeExtActor);
1103 theRenderer->AddActor(my1DExtActor);
1105 my3DActor ->AddToRender(theRenderer);
1106 my3DExtActor->AddToRender(theRenderer);
1107 my2DActor ->AddToRender(theRenderer);
1108 my2DExtActor->AddToRender(theRenderer);
1109 myNodeActor ->AddToRender(theRenderer);
1110 my1DActor ->AddToRender(theRenderer);
1111 my0DActor ->AddToRender(theRenderer);
1112 myBallActor ->AddToRender(theRenderer);
1113 //theRenderer->AddActor(my0DExtActor);
1115 theRenderer->AddActor(myHighlitableActor);
1117 theRenderer->AddActor2D(myScalarBarActor);
1119 // the superclass' method should be called at the end
1120 // (in particular, for correct work of selection)
1121 SALOME_Actor::AddToRender(theRenderer);
1124 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1125 SALOME_Actor::RemoveFromRender(theRenderer);
1127 theRenderer->RemoveActor(myBaseActor);
1129 theRenderer->RemoveActor(myNodeExtActor);
1131 theRenderer->RemoveActor(myHighlitableActor);
1133 //theRenderer->RemoveActor(my0DExtActor);
1135 theRenderer->RemoveActor(my1DExtActor);
1137 my2DActor->RemoveFromRender(theRenderer);
1138 my2DExtActor->RemoveFromRender(theRenderer);
1139 my3DActor->RemoveFromRender(theRenderer);
1140 my3DExtActor->RemoveFromRender(theRenderer);
1141 myNodeActor->RemoveFromRender(theRenderer);
1142 my0DActor->RemoveFromRender(theRenderer);
1143 myBallActor->RemoveFromRender(theRenderer);
1144 my1DActor->RemoveFromRender(theRenderer);
1146 theRenderer->RemoveActor(myScalarBarActor);
1150 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1151 const char* theEntry,
1152 const char* theName,
1155 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1159 myVisualObj = theVisualObj;
1160 myVisualObj->Update(theIsClear);
1162 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1163 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1165 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1167 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1169 my0DActor->Init(myVisualObj,myImplicitBoolean);
1170 myBallActor->Init(myVisualObj,myImplicitBoolean);
1171 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1173 my1DActor->Init(myVisualObj,myImplicitBoolean);
1174 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1176 my2DActor->Init(myVisualObj,myImplicitBoolean);
1177 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1178 my3DActor->Init(myVisualObj,myImplicitBoolean);
1179 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1181 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1182 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1183 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1185 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1186 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1188 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1189 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1190 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1191 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1193 double aFactor, aUnits;
1194 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1195 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1196 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1197 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1199 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1203 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1204 SetIsShrunkable(true);
1206 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1208 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1209 SetRepresentation(-1);
1212 SetRepresentation(eEdge);
1213 }else if(aMode == 1){
1214 SetRepresentation(eSurface);
1215 }else if(aMode == 2){
1216 SetRepresentation(ePoint);
1223 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1224 SetIsDisplayNameActor( true );
1226 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1227 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1228 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1230 myTimeStamp->Modified();
1236 double* SMESH_ActorDef::GetBounds(){
1237 return myNodeActor->GetBounds();
1241 vtkDataSet* SMESH_ActorDef::GetInput(){
1242 return GetUnstructuredGrid();
1246 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1247 Superclass::SetTransform(theTransform);
1249 myNodeActor->SetTransform(theTransform);
1250 myBaseActor->SetTransform(theTransform);
1252 myHighlitableActor->SetTransform(theTransform);
1254 myNodeExtActor->SetTransform(theTransform);
1256 my0DActor->SetTransform(theTransform);
1257 myBallActor->SetTransform(theTransform);
1258 //my0DExtActor->SetTransform(theTransform);
1260 my1DActor->SetTransform(theTransform);
1261 my1DExtActor->SetTransform(theTransform);
1263 my2DActor->SetTransform(theTransform);
1264 my2DExtActor->SetTransform(theTransform);
1265 my3DActor->SetTransform(theTransform);
1266 my3DExtActor->SetTransform(theTransform);
1272 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1273 vtkLODActor::SetMapper(theMapper);
1277 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1278 SALOME_Actor::ShallowCopy(prop);
1282 vtkMapper* SMESH_ActorDef::GetMapper(){
1283 return myPickableActor->GetMapper();
1287 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1288 return myVisualObj->GetUnstructuredGrid();
1292 bool SMESH_ActorDef::IsInfinitive(){
1293 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1294 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1295 ( aDataSet->GetNumberOfCells() == 1 &&
1296 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1297 return SALOME_Actor::IsInfinitive();
1301 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1302 if ( myIsShrinkable == theShrunkable )
1304 myIsShrinkable = theShrunkable;
1308 double SMESH_ActorDef::GetShrinkFactor(){
1309 return myBaseActor->GetShrinkFactor();
1312 void SMESH_ActorDef::SetShrinkFactor(double theValue){
1313 myBaseActor->SetShrinkFactor(theValue);
1315 my1DActor->SetShrinkFactor(theValue);
1316 my1DExtActor->SetShrinkFactor(theValue);
1318 my2DActor->SetShrinkFactor(theValue);
1319 my2DExtActor->SetShrinkFactor(theValue);
1320 my3DActor->SetShrinkFactor(theValue);
1321 my3DExtActor->SetShrinkFactor(theValue);
1322 my3DExtActor->SetShrinkFactor(theValue);
1323 myHighlitableActor->SetShrinkFactor(theValue);
1328 void SMESH_ActorDef::SetShrink(){
1329 if(!myIsShrinkable) return;
1331 myBaseActor->SetShrink();
1333 my1DActor->SetShrink();
1334 my1DExtActor->SetShrink();
1336 my2DActor->SetShrink();
1337 my2DExtActor->SetShrink();
1338 my3DActor->SetShrink();
1339 my3DExtActor->SetShrink();
1340 myHighlitableActor->SetShrink();
1346 void SMESH_ActorDef::UnShrink(){
1347 if(!myIsShrunk) return;
1349 myBaseActor->UnShrink();
1351 my1DActor->UnShrink();
1352 my1DExtActor->UnShrink();
1354 my2DActor->UnShrink();
1355 my2DExtActor->UnShrink();
1356 my3DActor->UnShrink();
1357 my3DExtActor->UnShrink();
1358 myHighlitableActor->UnShrink();
1365 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1366 return myPickableActor->GetNodeObjId(theVtkID);
1369 double* SMESH_ActorDef::GetNodeCoord(int theObjID){
1370 return myPickableActor->GetNodeCoord(theObjID);
1374 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1375 return myPickableActor->GetElemObjId(theVtkID);
1378 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1379 return myPickableActor->GetElemCell(theObjID);
1383 void SMESH_ActorDef::SetVisibility(int theMode){
1384 SetVisibility(theMode,true);
1388 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1389 SALOME_Actor::SetVisibility(theMode);
1391 myNodeActor->VisibilityOff();
1392 myBaseActor->VisibilityOff();
1394 myNodeExtActor->VisibilityOff();
1396 my0DActor->VisibilityOff();
1397 myBallActor->VisibilityOff();
1398 //my0DExtActor->VisibilityOff();
1400 my1DActor->VisibilityOff();
1401 my1DExtActor->VisibilityOff();
1403 my2DActor->VisibilityOff();
1404 my2DExtActor->VisibilityOff();
1405 my3DActor->VisibilityOff();
1406 my3DExtActor->VisibilityOff();
1408 myScalarBarActor->VisibilityOff();
1410 if(GetVisibility()){
1411 if(theIsUpdateRepersentation)
1412 SetRepresentation(GetRepresentation());
1414 if(myControlMode != eNone){
1415 switch(myControlMode){
1417 case eCoincidentNodes:
1418 myNodeExtActor->VisibilityOn();
1422 case eCoincidentElems1D:
1423 my1DExtActor->VisibilityOn();
1426 case eBareBorderFace:
1427 case eOverConstrainedFace:
1428 case eCoincidentElems2D:
1429 my2DExtActor->VisibilityOn();
1431 case eBareBorderVolume:
1432 case eOverConstrainedVolume:
1433 case eCoincidentElems3D:
1434 my3DExtActor->VisibilityOn();
1437 case eMultiConnection2D:
1438 my1DExtActor->VisibilityOn();
1440 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1441 myScalarBarActor->VisibilityOn();
1445 if(myRepresentation != ePoint)
1446 myPickableActor->VisibilityOn();
1448 myNodeActor->VisibilityOn();
1451 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1452 my0DActor->VisibilityOn();
1454 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1455 myBallActor->VisibilityOn();
1458 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1459 my1DActor->VisibilityOn();
1462 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1463 my2DActor->VisibilityOn();
1466 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1467 my3DActor->VisibilityOn();
1470 if(myNodeActor->GetPointsLabeled()){
1471 myNodeActor->VisibilityOn();
1475 my0DActor->UpdateLabels();
1478 myBallActor->UpdateLabels();
1481 my1DActor->UpdateLabels();
1484 my2DActor->UpdateLabels();
1487 my3DActor->UpdateLabels();
1489 #ifndef DISABLE_PLOT2DVIEWER
1491 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1498 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1500 myEntityState = eAllEntity;
1502 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1503 myEntityState &= ~e0DElements;
1504 theMode &= ~e0DElements;
1507 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1508 myEntityState &= ~eBallElem;
1509 theMode &= ~eBallElem;
1512 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1513 myEntityState &= ~eEdges;
1517 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1518 myEntityState &= ~eFaces;
1522 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1523 myEntityState &= ~eVolumes;
1524 theMode &= ~eVolumes;
1528 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1529 theMode |= e0DElements;
1531 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1532 theMode |= eBallElem;
1534 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1537 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1540 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1541 theMode |= eVolumes;
1544 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1546 myEntityMode = theMode;
1547 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1548 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1549 aFilter->ClearRegisteredCellsWithType();
1550 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1552 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1553 aHightFilter->ClearRegisteredCellsWithType();
1554 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1556 if (myEntityMode & e0DElements) {
1557 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1558 aFilter->RegisterCellsWithType(VTK_VERTEX);
1559 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1562 if (myEntityMode & eBallElem) {
1563 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1564 aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1567 if (myEntityMode & eEdges) {
1568 if (MYDEBUG) MESSAGE("EDGES");
1569 aFilter->RegisterCellsWithType(VTK_LINE);
1570 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1572 aHightFilter->RegisterCellsWithType(VTK_LINE);
1573 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1576 if (myEntityMode & eFaces) {
1577 if (MYDEBUG) MESSAGE("FACES");
1578 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1579 aFilter->RegisterCellsWithType(VTK_POLYGON);
1580 aFilter->RegisterCellsWithType(VTK_QUAD);
1581 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1582 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1583 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1585 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1586 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1587 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1588 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1589 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1590 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
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;