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->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
379 aFilter->RegisterCellsWithType(VTK_VERTEX);
381 //Definition 0D device of the actor (ball elements)
382 //-----------------------------------------------
383 myBallProp = vtkProperty::New();
384 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
385 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
386 myBallProp->SetPointSize(aBallElemSize);
388 myBallActor = SMESH_CellLabelActor::New();
389 myBallActor->SetUserMatrix(aMatrix);
390 myBallActor->SetStoreGemetryMapping(true);
391 myBallActor->PickableOff();
392 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
393 myBallActor->SetVisibility(false);
394 myBallActor->SetProperty(myBallProp);
395 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
396 myBallActor->SetBallEnabled(true);
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 myOutLineProp = vtkProperty::New();
478 myOutLineProp->SetAmbient(1.0);
479 myOutLineProp->SetDiffuse(0.0);
480 myOutLineProp->SetSpecular(0.0);
481 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
482 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
483 myOutLineProp->SetLineWidth(aOutlineWidth);
484 myOutLineProp->SetRepresentation(1);
486 myPreselectProp = vtkProperty::New();
487 myPreselectProp->SetAmbient(1.0);
488 myPreselectProp->SetDiffuse(0.0);
489 myPreselectProp->SetSpecular(0.0);
490 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
491 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
492 myPreselectProp->SetPointSize(aElem0DSize); // ??
493 myPreselectProp->SetLineWidth(aLineWidth);
494 myPreselectProp->SetRepresentation(1);
496 myHighlitableActor = SMESH_DeviceActor::New();
497 myHighlitableActor->SetUserMatrix(aMatrix);
498 myHighlitableActor->PickableOff();
499 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
500 myHighlitableActor->SetCoincident3DAllowed(true);
507 myControlMode = eNone;
508 myControlActor = my2DActor;
510 //Definition of myScalarBarActor
511 //------------------------------
512 myLookupTable = vtkLookupTable::New();
513 //Fix for Bug PAL5195 - SMESH764:
514 //Controls - Aspect Ratio: incorrect colors of the best and worst values
515 myLookupTable->SetHueRange(0.667,0.0);
517 myScalarBarActor = SMESH_ScalarBarActor::New();
518 myScalarBarActor->SetVisibility(false);
519 myScalarBarActor->SetLookupTable(myLookupTable);
522 //Incorrect "Min value" in Scalar Bar in Mesh:
523 // myScalarBarActor->SetLabelFormat("%.4g");
524 // changes was commented because of regression bug IPAL 19981
526 mgr = SUIT_Session::session()->resourceMgr();
530 myEntityMode = eAllEntity;
531 myEntityModeCache = eAllEntity;
534 myImplicitBoolean = vtkImplicitBoolean::New();
535 myImplicitBoolean->SetOperationTypeToIntersection();
537 //Quadratic 2D elements representation
538 //-----------------------------------------------------------------------------
539 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
540 if(aQuadratic2DMode == 0){
541 myHighlitableActor->SetQuadraticArcMode(false);
542 my2DActor->SetQuadraticArcMode(false);
543 my1DActor->SetQuadraticArcMode(false);
545 else if(aQuadratic2DMode == 1){
546 myHighlitableActor->SetQuadraticArcMode(true);
547 my2DActor->SetQuadraticArcMode(true);
548 my1DActor->SetQuadraticArcMode(true);
551 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
552 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
553 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
555 // Set colors of the name actor
556 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
557 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
558 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
559 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
561 #ifndef DISABLE_PLOT2DVIEWER
565 SetBallSize(aBallElemSize);
566 Set0DSize(aElem0DSize);
570 SMESH_ActorDef::~SMESH_ActorDef()
572 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
574 // Please keep the order same as one in the header file
576 myTimeStamp->Delete();
578 myScalarBarActor->Delete();
579 myLookupTable->Delete();
581 mySurfaceProp->Delete();
582 myBackSurfaceProp->Delete();
583 myNormalVProp->Delete();
584 myReversedVProp->Delete();
585 myEdgeProp->Delete();
586 myNodeProp->Delete();
588 myNodeActor->Delete();
589 myBaseActor->Delete();
590 //myPickableActor->Delete(); myPickableActor == myBaseActor
592 myHighlightProp->Delete();
593 myOutLineProp->Delete();
594 myPreselectProp->Delete();
596 myHighlitableActor->Delete();
598 my2DExtProp->Delete();
599 my3DExtProp->Delete();
601 my2DExtActor->Delete();
603 my3DExtActor->Delete();
604 // myControlActor->Delete(); myControlActor == my2DActor
606 myNodeExtProp->Delete();
607 myNodeExtActor->Delete();
611 my1DExtProp->Delete();
612 my1DExtActor->Delete();
616 myBallProp->Delete();
617 myBallActor->Delete();
618 //my0DExtProp->Delete();
619 //my0DExtActor->Delete();
621 myImplicitBoolean->Delete();
623 #ifndef DISABLE_PLOT2DVIEWER
625 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
626 delete my2dHistogram;
631 void SMESH_ActorDef::Delete()
633 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
634 // from the actor's destructor) will be thrown before removing the actor's observers,
635 // that is done inside the Superclass::Delete() method but before the destructor itself
636 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
637 // The event is caught by SMESHGUI::ProcessEvents() static method.
638 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
640 Superclass::Delete();
643 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
646 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
647 SetRepresentation(GetRepresentation());
648 myTimeStamp->Modified();
652 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
653 bool theBold, bool theItalic, bool theShadow,
654 double r, double g, double b )
657 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
658 SetRepresentation( GetRepresentation() );
659 myTimeStamp->Modified();
663 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
664 bool theBold, bool theItalic, bool theShadow,
665 double r, double g, double b )
668 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
671 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
672 SetRepresentation( GetRepresentation() );
673 myTimeStamp->Modified();
676 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
677 SetRepresentation( GetRepresentation() );
678 myTimeStamp->Modified();
681 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
682 SetRepresentation( GetRepresentation() );
683 myTimeStamp->Modified();
686 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
687 SetRepresentation( GetRepresentation() );
688 myTimeStamp->Modified();
692 bool SMESH_ActorDef::GetPointsLabeled() {
693 return myNodeActor && myNodeActor->GetPointsLabeled();
696 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
699 my3DActor->SetCellsLabeled(theIsCellsLabeled);
702 my2DActor->SetCellsLabeled(theIsCellsLabeled);
705 my1DActor->SetCellsLabeled(theIsCellsLabeled);
708 my0DActor->SetCellsLabeled(theIsCellsLabeled);
711 myBallActor->SetCellsLabeled(theIsCellsLabeled);
713 myTimeStamp->Modified();
717 bool SMESH_ActorDef::GetCellsLabeled() {
720 result = result || my3DActor->GetCellsLabeled();
723 result = result || my2DActor->GetCellsLabeled();
726 result = result || my1DActor->GetCellsLabeled();
729 result = result || my0DActor->GetCellsLabeled();
732 result = result || myBallActor->GetCellsLabeled();
738 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
740 myIsFacesOriented = theIsFacesOriented;
742 my2DActor->SetFacesOriented(theIsFacesOriented);
743 my3DActor->SetFacesOriented(theIsFacesOriented);
745 myTimeStamp->Modified();
748 bool SMESH_ActorDef::GetFacesOriented()
750 return myIsFacesOriented;
753 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
755 my2DActor->SetFacesOrientationColor( r, g, b );
756 my3DActor->SetFacesOrientationColor( r, g, b );
759 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
761 my3DActor->GetFacesOrientationColor( r, g, b );
764 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
766 my2DActor->SetFacesOrientationScale( theScale );
767 my3DActor->SetFacesOrientationScale( theScale );
770 double SMESH_ActorDef::GetFacesOrientationScale()
772 return my3DActor->GetFacesOrientationScale();
775 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
777 my2DActor->SetFacesOrientation3DVectors( theState );
778 my3DActor->SetFacesOrientation3DVectors( theState );
781 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
783 return my3DActor->GetFacesOrientation3DVectors();
789 SetControlMode(eControl theMode)
791 SetControlMode(theMode,true);
797 SetControlMode(eControl theMode,
798 bool theCheckEntityMode)
800 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
801 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
802 lookupTable->SetScale(VTK_SCALE_LINEAR);
804 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
808 myControlMode = eNone;
809 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
811 my0DActor->GetMapper()->SetScalarVisibility(false);
812 my1DActor->GetMapper()->SetScalarVisibility(false);
813 my2DActor->GetMapper()->SetScalarVisibility(false);
814 my3DActor->GetMapper()->SetScalarVisibility(false);
815 myBallActor->GetMapper()->SetScalarVisibility(false);
816 myScalarBarActor->SetVisibility(false);
818 bool anIsScalarVisible = theMode > eNone;
820 if(anIsScalarVisible) {
824 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
825 aControl->SetPrecision( myControlsPrecision );
826 myFunctor.reset( aControl );
827 myControlActor = my1DActor;
832 myFunctor.reset(new SMESH::Controls::Length2D());
833 myControlActor = my2DActor;
837 myFunctor.reset(new SMESH::Controls::FreeBorders());
838 myControlActor = my1DActor;
841 myFunctor.reset(new SMESH::Controls::FreeEdges());
842 myControlActor = my2DActor;
845 myFunctor.reset(new SMESH::Controls::FreeNodes());
846 myControlActor = myNodeActor;
849 myFunctor.reset(new SMESH::Controls::FreeFaces());
850 myControlActor = my2DActor;
852 case eCoincidentNodes:
854 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
855 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
856 cn->SetTolerance( tol );
858 myControlActor = myNodeActor;
861 case eCoincidentElems1D:
862 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
863 myControlActor = my1DActor;
865 case eCoincidentElems2D:
866 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
867 myControlActor = my2DActor;
869 case eCoincidentElems3D:
870 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
871 myControlActor = my3DActor;
873 case eBareBorderFace:
874 myFunctor.reset(new SMESH::Controls::BareBorderFace());
875 myControlActor = my2DActor;
877 case eOverConstrainedFace:
878 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
879 myControlActor = my2DActor;
881 case eMultiConnection:
882 myFunctor.reset(new SMESH::Controls::MultiConnection());
883 myControlActor = my1DActor;
885 case eMultiConnection2D:
886 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
887 myControlActor = my2DActor;
891 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
892 aControl->SetPrecision( myControlsPrecision );
893 myFunctor.reset( aControl );
894 myControlActor = my2DActor;
899 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
900 aControl->SetPrecision( myControlsPrecision );
901 myFunctor.reset( aControl );
902 myControlActor = my2DActor;
907 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
908 aControl->SetPrecision( myControlsPrecision );
909 myFunctor.reset( aControl );
910 myControlActor = my2DActor;
915 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
916 aControl->SetPrecision( myControlsPrecision );
917 myFunctor.reset( aControl );
918 myControlActor = my3DActor;
923 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
924 aControl->SetPrecision( myControlsPrecision );
925 myFunctor.reset( aControl );
926 myControlActor = my3DActor;
929 case eMaxElementLength2D:
931 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
932 aControl->SetPrecision( myControlsPrecision );
933 myFunctor.reset( aControl );
934 myControlActor = my2DActor;
937 case eMaxElementLength3D:
939 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
940 aControl->SetPrecision( myControlsPrecision );
941 myFunctor.reset( aControl );
942 myControlActor = my3DActor;
945 case eBareBorderVolume:
947 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
948 myControlActor = my3DActor;
951 case eOverConstrainedVolume:
953 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
954 myControlActor = my3DActor;
959 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
960 aControl->SetPrecision( myControlsPrecision );
961 myFunctor.reset( aControl );
962 myControlActor = my2DActor;
967 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
968 aControl->SetPrecision( myControlsPrecision );
969 myFunctor.reset( aControl );
970 myControlActor = my2DActor;
975 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
976 aControl->SetPrecision( myControlsPrecision );
977 myFunctor.reset( aControl );
978 myControlActor = my2DActor;
985 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
986 vtkIdType aNbCells = aGrid->GetNumberOfCells();
988 myControlMode = theMode;
989 switch(myControlMode){
991 case eCoincidentNodes:
992 myNodeExtActor->SetExtControlMode(myFunctor);
996 case eCoincidentElems1D:
997 my1DExtActor->SetExtControlMode(myFunctor);
1000 case eBareBorderFace:
1001 case eOverConstrainedFace:
1002 case eCoincidentElems2D:
1003 my2DExtActor->SetExtControlMode(myFunctor);
1005 case eBareBorderVolume:
1006 case eOverConstrainedVolume:
1007 case eCoincidentElems3D:
1008 my3DExtActor->SetExtControlMode(myFunctor);
1011 case eMultiConnection2D:
1012 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1013 UpdateDistribution();
1016 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1017 UpdateDistribution();
1021 if(theCheckEntityMode) {
1022 if(myControlActor == my1DActor) {
1023 if (!myIsEntityModeCache){
1024 myEntityModeCache = GetEntityMode();
1025 myIsEntityModeCache=true;
1027 SetEntityMode(eEdges);
1029 else if(myControlActor == my2DActor) {
1030 switch(myControlMode) {
1034 case eMultiConnection2D:
1035 if (!myIsEntityModeCache){
1036 myEntityModeCache = GetEntityMode();
1037 myIsEntityModeCache=true;
1039 SetEntityMode(eFaces);
1042 if (!myIsEntityModeCache){
1043 myEntityModeCache = GetEntityMode();
1044 myIsEntityModeCache=true;
1046 SetEntityMode(eFaces);
1048 }else if(myControlActor == my3DActor) {
1049 if (!myIsEntityModeCache){
1050 myEntityModeCache = GetEntityMode();
1051 myIsEntityModeCache=true;
1053 SetEntityMode(eVolumes);
1059 if(theCheckEntityMode){
1060 myEntityMode = myEntityModeCache;
1061 myIsEntityModeCache = false;
1066 SetRepresentation(GetRepresentation());
1068 myTimeStamp->Modified();
1071 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1072 double * range = lookupTable->GetRange();
1074 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1075 lookupTable->SetScale(VTK_SCALE_LOG10);
1081 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
1083 theRenderer->AddActor(myBaseActor);
1084 theRenderer->AddActor(myNodeExtActor);
1085 theRenderer->AddActor(my1DExtActor);
1087 my3DActor ->AddToRender(theRenderer);
1088 my3DExtActor->AddToRender(theRenderer);
1089 my2DActor ->AddToRender(theRenderer);
1090 my2DExtActor->AddToRender(theRenderer);
1091 myNodeActor ->AddToRender(theRenderer);
1092 my1DActor ->AddToRender(theRenderer);
1093 my0DActor ->AddToRender(theRenderer);
1094 myBallActor ->AddToRender(theRenderer);
1096 theRenderer->AddActor(myHighlitableActor);
1098 theRenderer->AddActor2D(myScalarBarActor);
1100 // the superclass' method should be called at the end
1101 // (in particular, for correct work of selection)
1102 SALOME_Actor::AddToRender(theRenderer);
1105 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1106 SALOME_Actor::RemoveFromRender(theRenderer);
1108 theRenderer->RemoveActor(myBaseActor);
1110 theRenderer->RemoveActor(myNodeExtActor);
1112 theRenderer->RemoveActor(myHighlitableActor);
1114 //theRenderer->RemoveActor(my0DExtActor);
1116 theRenderer->RemoveActor(my1DExtActor);
1118 my2DActor->RemoveFromRender(theRenderer);
1119 my2DExtActor->RemoveFromRender(theRenderer);
1120 my3DActor->RemoveFromRender(theRenderer);
1121 my3DExtActor->RemoveFromRender(theRenderer);
1122 myNodeActor->RemoveFromRender(theRenderer);
1123 my0DActor->RemoveFromRender(theRenderer);
1124 myBallActor->RemoveFromRender(theRenderer);
1125 my1DActor->RemoveFromRender(theRenderer);
1127 theRenderer->RemoveActor(myScalarBarActor);
1131 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1132 const char* theEntry,
1133 const char* theName,
1136 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1140 myVisualObj = theVisualObj;
1141 myVisualObj->Update(theIsClear);
1143 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1144 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1146 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1147 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1149 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1151 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1153 my0DActor->Init(myVisualObj,myImplicitBoolean);
1154 myBallActor->Init(myVisualObj,myImplicitBoolean);
1155 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1157 my1DActor->Init(myVisualObj,myImplicitBoolean);
1158 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1160 my2DActor->Init(myVisualObj,myImplicitBoolean);
1161 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1162 my3DActor->Init(myVisualObj,myImplicitBoolean);
1163 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1165 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1166 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1167 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1169 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1170 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1172 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1173 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1174 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1175 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1177 double aFactor, aUnits;
1178 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1179 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1180 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1181 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1183 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1187 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1188 SetIsShrunkable(true);
1190 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1192 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1193 SetRepresentation(-1);
1196 SetRepresentation(eEdge);
1197 }else if(aMode == 1){
1198 SetRepresentation(eSurface);
1199 }else if(aMode == 2){
1200 SetRepresentation(ePoint);
1207 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1208 SetIsDisplayNameActor( true );
1210 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1211 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1212 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1214 myTimeStamp->Modified();
1220 double* SMESH_ActorDef::GetBounds(){
1221 return myNodeActor->GetBounds();
1225 vtkDataSet* SMESH_ActorDef::GetInput(){
1226 return GetUnstructuredGrid();
1230 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1231 Superclass::SetTransform(theTransform);
1233 myNodeActor->SetTransform(theTransform);
1234 myBaseActor->SetTransform(theTransform);
1236 myHighlitableActor->SetTransform(theTransform);
1238 myNodeExtActor->SetTransform(theTransform);
1240 my0DActor->SetTransform(theTransform);
1241 myBallActor->SetTransform(theTransform);
1242 //my0DExtActor->SetTransform(theTransform);
1244 my1DActor->SetTransform(theTransform);
1245 my1DExtActor->SetTransform(theTransform);
1247 my2DActor->SetTransform(theTransform);
1248 my2DExtActor->SetTransform(theTransform);
1249 my3DActor->SetTransform(theTransform);
1250 my3DExtActor->SetTransform(theTransform);
1256 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1257 vtkLODActor::SetMapper(theMapper);
1261 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1262 SALOME_Actor::ShallowCopy(prop);
1266 vtkMapper* SMESH_ActorDef::GetMapper(){
1267 return myPickableActor->GetMapper();
1271 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1272 return myVisualObj->GetUnstructuredGrid();
1276 bool SMESH_ActorDef::IsInfinitive(){
1277 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1278 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1279 ( aDataSet->GetNumberOfCells() == 1 &&
1280 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1281 return SALOME_Actor::IsInfinitive();
1285 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1286 if ( myIsShrinkable == theShrunkable )
1288 myIsShrinkable = theShrunkable;
1292 double SMESH_ActorDef::GetShrinkFactor(){
1293 return myBaseActor->GetShrinkFactor();
1296 void SMESH_ActorDef::SetShrinkFactor(double theValue){
1297 myBaseActor->SetShrinkFactor(theValue);
1299 my1DActor->SetShrinkFactor(theValue);
1300 my1DExtActor->SetShrinkFactor(theValue);
1302 my2DActor->SetShrinkFactor(theValue);
1303 my2DExtActor->SetShrinkFactor(theValue);
1304 my3DActor->SetShrinkFactor(theValue);
1305 my3DExtActor->SetShrinkFactor(theValue);
1306 my3DExtActor->SetShrinkFactor(theValue);
1307 myHighlitableActor->SetShrinkFactor(theValue);
1312 void SMESH_ActorDef::SetShrink(){
1313 if(!myIsShrinkable) return;
1315 myBaseActor->SetShrink();
1317 my1DActor->SetShrink();
1318 my1DExtActor->SetShrink();
1320 my2DActor->SetShrink();
1321 my2DExtActor->SetShrink();
1322 my3DActor->SetShrink();
1323 my3DExtActor->SetShrink();
1324 myHighlitableActor->SetShrink();
1330 void SMESH_ActorDef::UnShrink(){
1331 if(!myIsShrunk) return;
1333 myBaseActor->UnShrink();
1335 my1DActor->UnShrink();
1336 my1DExtActor->UnShrink();
1338 my2DActor->UnShrink();
1339 my2DExtActor->UnShrink();
1340 my3DActor->UnShrink();
1341 my3DExtActor->UnShrink();
1342 myHighlitableActor->UnShrink();
1349 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1350 return myPickableActor->GetNodeObjId(theVtkID);
1353 double* SMESH_ActorDef::GetNodeCoord(int theObjID){
1354 return myPickableActor->GetNodeCoord(theObjID);
1358 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1359 return myPickableActor->GetElemObjId(theVtkID);
1362 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1363 return myPickableActor->GetElemCell(theObjID);
1367 void SMESH_ActorDef::SetVisibility(int theMode){
1368 SetVisibility(theMode,true);
1372 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1373 SALOME_Actor::SetVisibility(theMode);
1375 myNodeActor->VisibilityOff();
1376 myBaseActor->VisibilityOff();
1378 myNodeExtActor->VisibilityOff();
1380 my0DActor->VisibilityOff();
1381 myBallActor->VisibilityOff();
1382 //my0DExtActor->VisibilityOff();
1384 my1DActor->VisibilityOff();
1385 my1DExtActor->VisibilityOff();
1387 my2DActor->VisibilityOff();
1388 my2DExtActor->VisibilityOff();
1389 my3DActor->VisibilityOff();
1390 my3DExtActor->VisibilityOff();
1392 myScalarBarActor->VisibilityOff();
1394 if(GetVisibility()){
1395 if(theIsUpdateRepersentation)
1396 SetRepresentation(GetRepresentation());
1398 if(myControlMode != eNone){
1399 switch(myControlMode){
1401 case eCoincidentNodes:
1402 myNodeExtActor->VisibilityOn();
1406 case eCoincidentElems1D:
1407 my1DExtActor->VisibilityOn();
1410 case eBareBorderFace:
1411 case eOverConstrainedFace:
1412 case eCoincidentElems2D:
1413 my2DExtActor->VisibilityOn();
1415 case eBareBorderVolume:
1416 case eOverConstrainedVolume:
1417 case eCoincidentElems3D:
1418 my3DExtActor->VisibilityOn();
1421 case eMultiConnection2D:
1422 my1DExtActor->VisibilityOn();
1424 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1425 myScalarBarActor->VisibilityOn();
1429 if(myRepresentation != ePoint)
1430 myPickableActor->VisibilityOn();
1432 myNodeActor->VisibilityOn();
1435 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1436 my0DActor->VisibilityOn();
1438 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1439 myBallActor->VisibilityOn();
1442 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1443 my1DActor->VisibilityOn();
1446 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1447 my2DActor->VisibilityOn();
1450 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1451 my3DActor->VisibilityOn();
1454 if(myNodeActor->GetPointsLabeled()){
1455 myNodeActor->VisibilityOn();
1459 my0DActor->UpdateLabels();
1462 myBallActor->UpdateLabels();
1465 my1DActor->UpdateLabels();
1468 my2DActor->UpdateLabels();
1471 my3DActor->UpdateLabels();
1473 #ifndef DISABLE_PLOT2DVIEWER
1475 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1482 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1484 myEntityState = eAllEntity;
1486 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1487 myEntityState &= ~e0DElements;
1488 theMode &= ~e0DElements;
1491 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1492 myEntityState &= ~eBallElem;
1493 theMode &= ~eBallElem;
1496 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1497 myEntityState &= ~eEdges;
1501 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1502 myEntityState &= ~eFaces;
1506 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1507 myEntityState &= ~eVolumes;
1508 theMode &= ~eVolumes;
1512 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1513 theMode |= e0DElements;
1515 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1516 theMode |= eBallElem;
1518 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1521 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1524 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1525 theMode |= eVolumes;
1528 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1530 myEntityMode = theMode;
1531 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1532 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1533 aFilter->ClearRegisteredCellsWithType();
1534 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1536 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1537 aHightFilter->ClearRegisteredCellsWithType();
1538 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1540 if (myEntityMode & e0DElements) {
1541 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1542 aFilter->RegisterCellsWithType(VTK_VERTEX);
1543 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1546 if (myEntityMode & eBallElem) {
1547 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1550 if (myEntityMode & eEdges) {
1551 if (MYDEBUG) MESSAGE("EDGES");
1552 aFilter->RegisterCellsWithType(VTK_LINE);
1553 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1555 aHightFilter->RegisterCellsWithType(VTK_LINE);
1556 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1559 if (myEntityMode & eFaces) {
1560 if (MYDEBUG) MESSAGE("FACES");
1561 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1562 aFilter->RegisterCellsWithType(VTK_POLYGON);
1563 aFilter->RegisterCellsWithType(VTK_QUAD);
1564 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1565 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1566 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1567 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1569 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1570 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1571 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1572 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1573 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1574 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1575 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1578 if (myEntityMode & eVolumes) {
1579 if (MYDEBUG) MESSAGE("VOLUMES");
1580 aFilter->RegisterCellsWithType(VTK_TETRA);
1581 aFilter->RegisterCellsWithType(VTK_VOXEL);
1582 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1583 aFilter->RegisterCellsWithType(VTK_WEDGE);
1584 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1585 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1586 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1587 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1588 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1589 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1590 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1591 //#ifdef VTK_HAVE_POLYHEDRON
1592 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1595 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1596 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1597 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1598 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1599 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1600 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1601 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1602 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1603 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1604 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1605 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1606 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1607 //#ifdef VTK_HAVE_POLYHEDRON
1608 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1612 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1613 SetVisibility(GetVisibility(),false);
1616 void SMESH_ActorDef::SetRepresentation (int theMode)
1618 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1619 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1620 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1621 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1622 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1625 myRepresentation = eSurface;
1626 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1627 myRepresentation = eEdge;
1628 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1629 myRepresentation = ePoint;
1634 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1637 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1640 myRepresentation = theMode;
1643 if (!GetUnstructuredGrid()->GetNumberOfCells())
1644 myRepresentation = ePoint;
1647 if (myRepresentation == ePoint) {
1655 myPickableActor = myBaseActor;
1656 myNodeActor->SetVisibility(false);
1657 myNodeExtActor->SetVisibility(false);
1658 vtkProperty *aProp = NULL, *aBackProp = NULL;
1659 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1660 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1661 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1662 switch (myRepresentation) {
1664 myPickableActor = myNodeActor;
1665 myNodeActor->SetVisibility(true);
1666 aQuadraticMode = SMESH_Actor::eLines;
1667 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1668 aReperesent = SMESH_DeviceActor::ePoint;
1671 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1672 aReperesent = SMESH_DeviceActor::eInsideframe;
1675 aProp = mySurfaceProp;
1676 aBackProp = myBackSurfaceProp;
1677 aPropVN = myNormalVProp;
1678 aPropVR = myReversedVProp;
1679 aReperesent = SMESH_DeviceActor::eSurface;
1683 my2DActor->SetProperty(aProp);
1684 my2DActor->SetBackfaceProperty(aBackProp);
1685 my2DActor->SetRepresentation(aReperesent);
1687 if(aQuadraticMode == SMESH_Actor::eLines)
1688 my2DActor->SetQuadraticArcMode(false);
1689 else if(aQuadraticMode == SMESH_Actor::eArcs)
1690 my2DActor->SetQuadraticArcMode(true);
1692 my2DExtActor->SetRepresentation(aReperesent);
1694 my3DActor->SetProperty(aPropVN);
1695 my3DActor->SetBackfaceProperty(aPropVR);
1696 my3DActor->SetRepresentation(aReperesent);
1699 my1DExtActor->SetVisibility(false);
1700 my2DExtActor->SetVisibility(false);
1701 my3DExtActor->SetVisibility(false);
1703 my0DActor->SetRepresentation(aReperesent);
1704 myBallActor->SetRepresentation(aReperesent);
1706 switch(myControlMode){
1708 case eMultiConnection:
1709 aProp = aBackProp = my1DProp;
1710 if(myRepresentation != ePoint)
1711 aReperesent = SMESH_DeviceActor::eInsideframe;
1715 if(aQuadraticMode == SMESH_Actor::eLines)
1716 my1DActor->SetQuadraticArcMode(false);
1717 else if(aQuadraticMode == SMESH_Actor::eArcs)
1718 my1DActor->SetQuadraticArcMode(true);
1720 my1DActor->SetProperty(aProp);
1721 my1DActor->SetBackfaceProperty(aBackProp);
1722 my1DActor->SetRepresentation(aReperesent);
1724 my1DExtActor->SetRepresentation(aReperesent);
1726 if(myIsPointsVisible)
1727 myPickableActor = myNodeActor;
1728 if(GetPointRepresentation())
1729 myNodeActor->SetVisibility(true);
1731 SetMapper(myPickableActor->GetMapper());
1733 SetVisibility(GetVisibility(),false);
1739 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1740 if ( myIsPointsVisible == theIsPointsVisible )
1742 myIsPointsVisible = theIsPointsVisible;
1743 SetRepresentation(GetRepresentation());
1746 bool SMESH_ActorDef::GetPointRepresentation(){
1747 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1751 void SMESH_ActorDef::UpdateHighlight(){
1752 myHighlitableActor->SetHighlited(false);
1753 myHighlitableActor->SetVisibility(false);
1754 bool anIsVisible = GetVisibility();
1756 switch(myRepresentation){
1757 case SMESH_DeviceActor::eSurface:
1758 case SMESH_DeviceActor::eWireframe:
1760 if(myIsHighlighted) {
1761 myHighlitableActor->SetProperty(myHighlightProp);
1762 }else if(myIsPreselected){
1763 myHighlitableActor->SetProperty(myPreselectProp);
1764 } else if(anIsVisible){
1765 (myRepresentation == eSurface) ?
1766 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1768 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1769 myHighlitableActor->SetHighlited(anIsVisible);
1770 myHighlitableActor->GetExtractUnstructuredGrid()->
1771 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1772 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1774 myHighlitableActor->SetVisibility(anIsVisible);
1777 case SMESH_DeviceActor::ePoint:
1779 if(myIsHighlighted) {
1780 myNodeActor->SetProperty(myHighlightProp);
1781 }else if(myIsPreselected) {
1782 myNodeActor->SetProperty(myPreselectProp);
1783 } else if(anIsVisible) {
1784 myNodeActor->SetProperty(myNodeProp);
1786 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1787 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1794 void SMESH_ActorDef::highlight(bool theHighlight){
1795 if ( myIsHighlighted == theHighlight )
1797 myIsHighlighted = theHighlight;
1802 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1803 if ( myIsPreselected == thePreselect )
1805 myIsPreselected = thePreselect;
1811 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1813 if (myPickableActor->GetIsOpaque())
1815 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1823 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1825 if (!myPickableActor->GetIsOpaque())
1827 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1835 void SMESH_ActorDef::Render(vtkRenderer *ren){
1836 unsigned long aTime = myTimeStamp->GetMTime();
1837 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1838 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1839 if(anObjTime > aTime || aClippingTime > aTime)
1844 void SMESH_ActorDef::Update(){
1845 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1847 if(GetControlMode() != eNone) {
1848 unsigned long aTime = myTimeStamp->GetMTime();
1849 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1850 if (anObjTime > aTime)
1851 SetControlMode(GetControlMode(),false);
1855 myNodeActor->UpdateLabels();
1858 my0DActor->UpdateLabels();
1861 myBallActor->UpdateLabels();
1864 my1DActor->UpdateLabels();
1867 my2DActor->UpdateLabels();
1870 my3DActor->UpdateLabels();
1872 if(myIsFacesOriented){
1873 SetFacesOriented(myIsFacesOriented);
1876 if(myVisualObj->GetEntitiesFlag()) {
1877 myEntityMode |= myVisualObj->GetEntitiesState();
1880 SetEntityMode(GetEntityMode());
1881 SetVisibility(GetVisibility());
1883 myTimeStamp->Modified();
1888 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1889 SALOME_Actor::ReleaseGraphicsResources(renWin);
1891 myPickableActor->ReleaseGraphicsResources(renWin);
1895 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b){
1896 double* aColor = theProperty->GetColor();
1903 void SMESH_ActorDef::SetOpacity(double theValue){
1904 mySurfaceProp->SetOpacity(theValue);
1905 myBackSurfaceProp->SetOpacity(theValue);
1906 myNormalVProp->SetOpacity(theValue);
1907 myReversedVProp->SetOpacity(theValue);
1908 myEdgeProp->SetOpacity(theValue);
1909 myOutLineProp->SetOpacity(theValue);
1910 myNodeProp->SetOpacity(theValue);
1912 my1DProp->SetOpacity(theValue);
1913 my0DProp->SetOpacity(theValue);
1914 myBallProp->SetOpacity(theValue);
1918 double SMESH_ActorDef::GetOpacity(){
1919 return mySurfaceProp->GetOpacity();
1923 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta){
1924 mySurfaceProp->SetColor(r,g,b);
1925 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1926 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1927 if( aGroupObj->GetElementType() == SMDSAbs_Face )
1928 myNameActor->SetBackgroundColor(r,g,b);
1930 myDeltaBrightness = delta;
1931 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1932 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1936 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta){
1937 ::GetColor(mySurfaceProp,r,g,b);
1938 delta = myDeltaBrightness;
1941 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta){
1942 myNormalVProp->SetColor(r,g,b);
1943 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1944 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1945 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
1946 myNameActor->SetBackgroundColor(r,g,b);
1948 myDeltaVBrightness = delta;
1949 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1950 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1954 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta){
1955 ::GetColor(myNormalVProp,r,g,b);
1956 delta = myDeltaVBrightness;
1959 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b){
1960 myEdgeProp->SetColor(r,g,b);
1961 my1DProp->SetColor(r,g,b);
1962 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1963 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1964 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1965 myNameActor->SetBackgroundColor(r,g,b);
1969 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b){
1970 ::GetColor(myEdgeProp,r,g,b);
1973 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b){
1974 myOutLineProp->SetColor(r,g,b);
1978 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b){
1979 ::GetColor(myOutLineProp,r,g,b);
1983 void SMESH_ActorDef::SetNodeColor(double r,double g,double b){
1984 myNodeProp->SetColor(r,g,b);
1985 myNodeExtProp->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_Node )
1988 myNameActor->SetBackgroundColor(r,g,b);
1992 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b){
1993 ::GetColor(myNodeProp,r,g,b);
1996 void SMESH_ActorDef::Set0DColor(double r,double g,double b){
1997 my0DProp->SetColor(r,g,b);
1998 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1999 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2000 myNameActor->SetBackgroundColor(r,g,b);
2004 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b){
2005 ::GetColor(my0DProp,r,g,b);
2008 void SMESH_ActorDef::SetBallColor(double r,double g,double b){
2009 myBallProp->SetColor(r,g,b);
2010 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2011 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2012 myNameActor->SetBackgroundColor(r,g,b);
2016 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b){
2017 ::GetColor(myBallProp,r,g,b);
2020 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b){
2021 myHighlightProp->SetColor(r,g,b);
2025 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b){
2026 ::GetColor(myHighlightProp,r,g,b);
2029 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b){
2030 myPreselectProp->SetColor(r,g,b);
2034 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b){
2035 ::GetColor(myPreselectProp,r,g,b);
2039 double SMESH_ActorDef::GetLineWidth(){
2040 return myEdgeProp->GetLineWidth();
2044 void SMESH_ActorDef::SetLineWidth(double theVal){
2045 myEdgeProp->SetLineWidth(theVal);
2047 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2048 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2049 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2050 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2051 myOutLineProp->SetLineWidth(theVal);
2052 myHighlightProp->SetLineWidth(theVal);
2053 myPreselectProp->SetLineWidth(theVal);
2057 double SMESH_ActorDef::GetOutlineWidth()
2059 return myOutLineProp->GetLineWidth();
2062 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2064 myOutLineProp->SetLineWidth(theVal);
2068 void SMESH_ActorDef::Set0DSize(double theVal){
2069 my0DProp->SetPointSize(theVal);
2070 myHighlightProp->SetPointSize(theVal);
2071 myPreselectProp->SetPointSize(theVal);
2073 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2074 aCustom->Set0DSize(theVal);
2076 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2077 aCustom->Set0DSize(theVal);
2083 double SMESH_ActorDef::Get0DSize(){
2084 return my0DProp->GetPointSize();
2087 void SMESH_ActorDef::SetBallSize(double theVal){
2088 myBallProp->SetPointSize(theVal);
2090 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2091 aCustom->SetBallSize(theVal);
2093 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2094 aCustom->SetBallSize(theVal);
2100 double SMESH_ActorDef::GetBallSize(){
2101 return myBallProp->GetPointSize();
2104 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2106 return myVisualObj->GetElemDimension( theObjId );
2111 IsImplicitFunctionUsed() const
2113 return myBaseActor->IsImplicitFunctionUsed();
2117 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2119 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2120 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2122 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2124 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2126 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2127 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2128 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2130 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2131 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2133 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2134 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2135 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2136 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2140 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2143 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2144 myCippingPlaneCont.push_back(thePlane);
2145 if(!IsImplicitFunctionUsed())
2146 SetImplicitFunctionUsed(true);
2147 myNodeActor->UpdateLabels();
2149 return myCippingPlaneCont.size();
2154 RemoveAllClippingPlanes()
2156 myImplicitBoolean->GetFunction()->RemoveAllItems();
2157 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2158 myCippingPlaneCont.clear();
2159 SetImplicitFunctionUsed(false);
2160 myNodeActor->UpdateLabels();
2165 GetNumberOfClippingPlanes()
2167 return myCippingPlaneCont.size();
2172 GetClippingPlane(vtkIdType theID)
2174 if(theID >= myCippingPlaneCont.size())
2176 return myCippingPlaneCont[theID].Get();
2179 void SMESH_ActorDef::UpdateScalarBar()
2181 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2185 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2187 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2188 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2190 aScalarBarTitleProp->SetFontFamilyToArial();
2192 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2194 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2195 if ( f.family() == "Arial" )
2196 aScalarBarTitleProp->SetFontFamilyToArial();
2197 else if ( f.family() == "Courier" )
2198 aScalarBarTitleProp->SetFontFamilyToCourier();
2199 else if ( f.family() == "Times" )
2200 aScalarBarTitleProp->SetFontFamilyToTimes();
2203 aScalarBarTitleProp->BoldOn();
2205 aScalarBarTitleProp->BoldOff();
2208 aScalarBarTitleProp->ItalicOn();
2210 aScalarBarTitleProp->ItalicOff();
2213 aScalarBarTitleProp->ShadowOn();
2215 aScalarBarTitleProp->ShadowOff();
2218 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2219 aScalarBarTitleProp->Delete();
2221 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2223 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2224 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2226 aScalarBarLabelProp->SetFontFamilyToArial();
2227 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2229 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2230 if( f.family() == "Arial" )
2231 aScalarBarLabelProp->SetFontFamilyToArial();
2232 else if( f.family() == "Courier" )
2233 aScalarBarLabelProp->SetFontFamilyToCourier();
2234 else if( f.family() == "Times" )
2235 aScalarBarLabelProp->SetFontFamilyToTimes();
2238 aScalarBarLabelProp->BoldOn();
2240 aScalarBarLabelProp->BoldOff();
2243 aScalarBarLabelProp->ItalicOn();
2245 aScalarBarLabelProp->ItalicOff();
2248 aScalarBarLabelProp->ShadowOn();
2250 aScalarBarLabelProp->ShadowOff();
2253 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2254 aScalarBarLabelProp->Delete();
2256 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2257 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2259 myScalarBarActor->SetOrientationToHorizontal();
2261 myScalarBarActor->SetOrientationToVertical();
2264 double aXVal = horiz ? 0.20 : 0.01;
2265 if( mgr->hasValue( "SMESH", name + "x" ) )
2266 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2268 double aYVal = horiz ? 0.01 : 0.1;
2269 if( mgr->hasValue( "SMESH", name + "y" ) )
2270 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2271 myScalarBarActor->SetPosition( aXVal, aYVal );
2273 double aWVal = horiz ? 0.60 : 0.10;
2274 if( mgr->hasValue( "SMESH", name + "width" ) )
2275 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2276 myScalarBarActor->SetWidth( aWVal );
2278 double aHVal = horiz ? 0.12 : 0.80;
2279 if( mgr->hasValue( "SMESH", name + "height" ) )
2280 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2281 myScalarBarActor->SetHeight( aHVal );
2284 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2285 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2286 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2289 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2290 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2291 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2293 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2294 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2296 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2297 myScalarBarActor->SetDistributionColoringType(coloringType);
2299 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2300 QColor(255, 255, 255));
2302 rgb[0]= distributionColor.red()/255.;
2303 rgb[1]= distributionColor.green()/255.;
2304 rgb[2]= distributionColor.blue()/255.;
2305 myScalarBarActor->SetDistributionColor(rgb);
2310 void SMESH_ActorDef::UpdateDistribution()
2312 if(SMESH::Controls::NumericalFunctor* fun =
2313 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2315 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2316 std::vector<int> nbEvents;
2317 std::vector<double> funValues;
2318 SMESH_VisualObjDef::TEntityList elems;
2319 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2320 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2321 std::vector<int> elemIds;
2322 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2323 elemIds.push_back( (*e)->GetID());
2324 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2325 double * range = lookupTable->GetRange();
2326 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2327 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2328 myScalarBarActor->SetDistribution(nbEvents);
2332 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2335 case SMESH_Actor::eLines :
2336 myHighlitableActor->SetQuadraticArcMode(false);
2337 my2DActor->SetQuadraticArcMode(false);
2338 my1DActor->SetQuadraticArcMode(false);
2340 case SMESH_Actor::eArcs :
2341 myHighlitableActor->SetQuadraticArcMode(true);
2342 if(GetRepresentation() != SMESH_Actor::ePoint) {
2343 my2DActor->SetQuadraticArcMode(true);
2344 my1DActor->SetQuadraticArcMode(true);
2353 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2355 if(myHighlitableActor->GetQuadraticArcMode())
2356 return SMESH_Actor::eArcs;
2358 return SMESH_Actor::eLines;
2361 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2363 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2364 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2365 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2368 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2370 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2371 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2372 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2373 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2376 #ifndef DISABLE_PLOT2DVIEWER
2377 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2380 my2dHistogram->clearAllPoints();
2382 if(SMESH::Controls::NumericalFunctor* fun =
2383 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2386 if(!my2dHistogram) {
2387 my2dHistogram = new SPlot2d_Histogram();
2388 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2389 my2dHistogram->setIO(anIO);
2392 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2393 std::vector<int> nbEvents;
2394 std::vector<double> funValues;
2395 SMESH_VisualObjDef::TEntityList elems;
2396 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2397 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2398 std::vector<int> elemIds;
2400 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2401 elemIds.push_back( (*e)->GetID());
2403 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2404 double * range = lookupTable->GetRange();
2405 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2406 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2408 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2409 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2411 if(funValues.size() >= 2)
2412 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2416 //Color of the histogram
2417 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2418 my2dHistogram->setAutoAssign(true);
2421 myScalarBarActor->GetDistributionColor(rgb);
2422 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2423 my2dHistogram->setColor(aColor);
2427 return my2dHistogram;