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 <vtkConfigure.h>
82 #if !defined(VTK_XVERSION)
83 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
86 #include "utilities.h"
89 static int MYDEBUG = 1;
91 static int MYDEBUG = 1;
94 static int aLineWidthInc = 2;
97 SMESH_ActorDef* SMESH_ActorDef::New(){
98 return new SMESH_ActorDef();
102 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
103 const char* theEntry,
107 SMESH_ActorDef* anActor = NULL;
108 if(theVisualObj->IsValid() ) {
109 anActor = SMESH_ActorDef::New();
110 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
115 anActor->UpdateScalarBar();
121 SMESH_ActorDef::SMESH_ActorDef()
123 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
124 myBaseActor = SMESH_DeviceActor::New();
126 myTimeStamp = vtkTimeStamp::New();
128 myIsPointsVisible = false;
129 myIsEntityModeCache = false;
131 myHighlightActor = SMESH_SVTKActor::New();
132 myHighlightActor->Delete(); // vtkSmartPointer!
133 myHighlightActor->Initialize();
135 myPreHighlightActor = SMESH_SVTKActor::New();
136 myPreHighlightActor->Delete();
137 myPreHighlightActor->Initialize();
139 myIsShrinkable = false;
142 myIsFacesOriented = false;
144 myControlsPrecision = -1;
145 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
147 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
148 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
150 double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
151 double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
152 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
153 double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
155 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
157 bool anItalicNd = false;
158 bool aShadowNd = false;
160 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
161 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
162 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
163 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
164 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
166 anItalicNd = f.italic();
167 aShadowNd = f.overline();
168 aSizeNd = f.pointSize();
170 double anRGBNd[3] = {1,1,1};
171 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
173 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
175 bool anItalicEl = false;
176 bool aShadowEl = false;
178 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
179 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
180 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
181 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
182 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
184 anItalicEl = f.italic();
185 aShadowEl = f.overline();
186 aSizeEl = f.pointSize();
188 double anRGBEl[3] = {0,1,0};
189 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
191 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
192 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
194 //Definition 2D and 3D devices of the actor
195 //-----------------------------------------
196 double anRGB[3] = {1,1,1};
197 mySurfaceProp = vtkProperty::New();
200 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
201 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
202 myDeltaBrightness = delta;
204 myBackSurfaceProp = vtkProperty::New();
205 bfc = Qtx::mainColorToSecondary(ffc, delta);
206 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
208 myNormalVProp = vtkProperty::New();
209 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
210 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
211 myDeltaVBrightness = delta;
213 myReversedVProp = vtkProperty::New();
214 bfc = Qtx::mainColorToSecondary(ffc, delta);
215 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
217 my2DActor = SMESH_CellLabelActor::New();
218 my2DActor->SetStoreGemetryMapping(true);
219 my2DActor->SetUserMatrix(aMatrix);
220 my2DActor->PickableOff();
221 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
222 my2DActor->SetProperty(mySurfaceProp);
223 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
224 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
225 aFilter = my2DActor->GetExtractUnstructuredGrid();
226 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
227 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
228 aFilter->RegisterCellsWithType(VTK_POLYGON);
229 aFilter->RegisterCellsWithType(VTK_QUAD);
230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
231 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
232 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
233 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
235 my2DExtProp = vtkProperty::New();
236 my2DExtProp->DeepCopy(mySurfaceProp);
237 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
238 anRGB[0] = 1 - anRGB[0];
239 anRGB[1] = 1 - anRGB[1];
240 anRGB[2] = 1 - anRGB[2];
241 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
243 my2DExtActor = SMESH_DeviceActor::New();
244 my2DExtActor->SetUserMatrix(aMatrix);
245 my2DExtActor->PickableOff();
246 my2DExtActor->SetProperty(my2DExtProp);
247 my2DExtActor->SetBackfaceProperty(my2DExtProp);
248 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
249 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
250 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
251 aFilter->RegisterCellsWithType(VTK_POLYGON);
252 aFilter->RegisterCellsWithType(VTK_QUAD);
253 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
255 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
256 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
258 my3DActor = SMESH_CellLabelActor::New();
259 my3DActor->SetStoreGemetryMapping(true);
260 my3DActor->SetUserMatrix(aMatrix);
261 my3DActor->PickableOff();
262 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
263 my3DActor->SetProperty(myNormalVProp);
264 my3DActor->SetBackfaceProperty(myReversedVProp);
265 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
266 my3DActor->SetCoincident3DAllowed(true);
267 aFilter = my3DActor->GetExtractUnstructuredGrid();
268 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
269 aFilter->RegisterCellsWithType(VTK_TETRA);
270 aFilter->RegisterCellsWithType(VTK_VOXEL);
271 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
272 aFilter->RegisterCellsWithType(VTK_WEDGE);
273 aFilter->RegisterCellsWithType(VTK_PYRAMID);
274 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
275 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
276 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
277 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
278 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
279 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
280 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
281 //#ifdef VTK_HAVE_POLYHEDRON
282 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
283 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
286 my3DExtProp = vtkProperty::New();
287 my3DExtProp->DeepCopy(myNormalVProp);
288 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
289 anRGB[0] = 1 - anRGB[0];
290 anRGB[1] = 1 - anRGB[1];
291 anRGB[2] = 1 - anRGB[2];
292 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
294 my3DExtActor = SMESH_DeviceActor::New();
295 my3DExtActor->SetUserMatrix(aMatrix);
296 my3DExtActor->PickableOff();
297 my3DExtActor->SetProperty(my3DExtProp);
298 my3DExtActor->SetBackfaceProperty(my3DExtProp);
299 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
300 my3DExtActor->SetCoincident3DAllowed(true);
301 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
302 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
303 aFilter->RegisterCellsWithType(VTK_TETRA);
304 aFilter->RegisterCellsWithType(VTK_VOXEL);
305 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
306 aFilter->RegisterCellsWithType(VTK_WEDGE);
307 aFilter->RegisterCellsWithType(VTK_PYRAMID);
308 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
309 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
310 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
311 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
312 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
313 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
314 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
315 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
317 //Definition 1D device of the actor
318 //---------------------------------
319 myEdgeProp = vtkProperty::New();
320 myEdgeProp->SetAmbient(1.0);
321 myEdgeProp->SetDiffuse(0.0);
322 myEdgeProp->SetSpecular(0.0);
323 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
324 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
325 myEdgeProp->SetLineWidth(aLineWidth);
327 my1DActor = SMESH_CellLabelActor::New();
328 my1DActor->SetStoreGemetryMapping(true);
329 my1DActor->SetUserMatrix(aMatrix);
330 my1DActor->PickableOff();
331 my1DActor->SetHighlited(true);
332 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
333 my1DActor->SetProperty(myEdgeProp);
334 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
335 aFilter = my1DActor->GetExtractUnstructuredGrid();
336 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
337 aFilter->RegisterCellsWithType(VTK_LINE);
338 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
340 my1DProp = vtkProperty::New();
341 my1DProp->DeepCopy(myEdgeProp);
342 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
343 my1DProp->SetPointSize(aElem0DSize);
345 my1DExtProp = vtkProperty::New();
346 my1DExtProp->DeepCopy(myEdgeProp);
347 anRGB[0] = 1 - anRGB[0];
348 anRGB[1] = 1 - anRGB[1];
349 anRGB[2] = 1 - anRGB[2];
350 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
351 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
352 my1DExtProp->SetPointSize(aElem0DSize);
354 my1DExtActor = SMESH_DeviceActor::New();
355 my1DExtActor->SetUserMatrix(aMatrix);
356 my1DExtActor->PickableOff();
357 my1DExtActor->SetHighlited(true);
358 my1DExtActor->SetVisibility(false);
359 my1DExtActor->SetProperty(my1DExtProp);
360 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
361 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
362 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
363 aFilter->RegisterCellsWithType(VTK_LINE);
364 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
367 //Definition 0D device of the actor (0d elements)
368 //-----------------------------------------------
369 my0DProp = vtkProperty::New();
370 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
371 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
372 my0DProp->SetPointSize(aElem0DSize);
374 my0DActor = SMESH_CellLabelActor::New();
375 my0DActor->SetUserMatrix(aMatrix);
376 my0DActor->SetStoreGemetryMapping(true);
377 my0DActor->PickableOff();
378 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
379 my0DActor->SetVisibility(false);
380 my0DActor->SetProperty(my0DProp);
381 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
382 aFilter = my0DActor->GetExtractUnstructuredGrid();
383 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
384 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
385 aFilter->RegisterCellsWithType(VTK_VERTEX);
387 //Definition 0D device of the actor (ball elements)
388 //-----------------------------------------------
389 myBallProp = vtkProperty::New();
390 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
391 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
392 myBallProp->SetPointSize(aBallElemSize);
394 myBallActor = SMESH_CellLabelActor::New();
395 myBallActor->SetUserMatrix(aMatrix);
396 myBallActor->SetStoreGemetryMapping(true);
397 myBallActor->PickableOff();
398 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
399 myBallActor->SetVisibility(false);
400 myBallActor->SetProperty(myBallProp);
401 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
402 aFilter = myBallActor->GetExtractUnstructuredGrid();
403 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
404 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
406 //my0DExtProp = vtkProperty::New();
407 //my0DExtProp->DeepCopy(my0DProp);
408 //anRGB[0] = 1 - anRGB[0];
409 //anRGB[1] = 1 - anRGB[1];
410 //anRGB[2] = 1 - anRGB[2];
411 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
412 //my0DExtProp->SetPointSize(aElem0DSize);
414 //my0DExtActor = SMESH_DeviceActor::New();
415 //my0DExtActor->SetUserMatrix(aMatrix);
416 //my0DExtActor->SetStoreClippingMapping(true);
417 //my0DExtActor->PickableOff();
418 //my0DExtActor->SetHighlited(true);
419 //my0DExtActor->SetVisibility(false);
420 //my0DExtActor->SetProperty(my0DExtProp);
421 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
422 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
423 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
424 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
425 //aFilter->RegisterCellsWithType(VTK_VERTEX);
428 //Definition 0D device of the actor (nodes)
429 //-----------------------------------------
430 myNodeProp = vtkProperty::New();
431 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
432 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
434 myNodeActor = SMESH_NodeLabelActor::New();
435 myNodeActor->SetUserMatrix(aMatrix);
436 myNodeActor->SetStoreClippingMapping(true);
437 myNodeActor->PickableOff();
438 myNodeActor->SetVisibility(false);
439 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
440 myNodeActor->SetProperty(myNodeProp);
441 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
442 aFilter = myNodeActor->GetExtractUnstructuredGrid();
443 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
445 myNodeExtProp = vtkProperty::New();
446 myNodeExtProp->DeepCopy(myNodeProp);
447 anRGB[0] = 1 - anRGB[0];
448 anRGB[1] = 1 - anRGB[1];
449 anRGB[2] = 1 - anRGB[2];
450 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
452 myNodeExtActor = SMESH_DeviceActor::New();
453 myNodeExtActor->SetUserMatrix(aMatrix);
454 myNodeExtActor->SetStoreClippingMapping(true);
455 myNodeExtActor->PickableOff();
456 myNodeExtActor->SetHighlited(true);
457 myNodeExtActor->SetVisibility(false);
458 myNodeExtActor->SetProperty(myNodeExtProp);
459 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
460 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
461 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
462 aFilter->RegisterCellsWithType(VTK_VERTEX);
464 //Definition of Pickable and Highlitable engines
465 //----------------------------------------------
467 myBaseActor->SetUserMatrix(aMatrix);
468 myBaseActor->SetStoreGemetryMapping(true);
469 myBaseActor->GetProperty()->SetOpacity(0.0);
470 myPickableActor = myBaseActor;
472 myHighlightProp = vtkProperty::New();
473 myHighlightProp->SetAmbient(1.0);
474 myHighlightProp->SetDiffuse(0.0);
475 myHighlightProp->SetSpecular(0.0);
476 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
477 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
478 myHighlightProp->SetPointSize(aElem0DSize); // ??
479 myHighlightProp->SetLineWidth(aLineWidth);
480 myHighlightProp->SetRepresentation(1);
482 myBallHighlightProp = vtkProperty::New();
483 myBallHighlightProp->DeepCopy(myHighlightProp);
484 myBallHighlightProp->SetPointSize(aBallElemSize);
487 myOutLineProp = vtkProperty::New();
488 myOutLineProp->SetAmbient(1.0);
489 myOutLineProp->SetDiffuse(0.0);
490 myOutLineProp->SetSpecular(0.0);
491 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
492 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
493 myOutLineProp->SetLineWidth(aOutlineWidth);
494 myOutLineProp->SetRepresentation(1);
496 myPreselectProp = vtkProperty::New();
497 myPreselectProp->SetAmbient(1.0);
498 myPreselectProp->SetDiffuse(0.0);
499 myPreselectProp->SetSpecular(0.0);
500 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
501 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
502 myPreselectProp->SetPointSize(aElem0DSize); // ??
503 myPreselectProp->SetLineWidth(aLineWidth);
504 myPreselectProp->SetRepresentation(1);
506 myBallPreselectProp = vtkProperty::New();
507 myBallPreselectProp->DeepCopy(myPreselectProp);
508 myBallPreselectProp->SetPointSize(aBallElemSize);
510 myHighlitableActor = SMESH_DeviceActor::New();
511 myHighlitableActor->SetUserMatrix(aMatrix);
512 myHighlitableActor->PickableOff();
513 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
514 myHighlitableActor->SetCoincident3DAllowed(true);
521 myControlMode = eNone;
522 myControlActor = my2DActor;
524 //Definition of myScalarBarActor
525 //------------------------------
526 myLookupTable = vtkLookupTable::New();
527 //Fix for Bug PAL5195 - SMESH764:
528 //Controls - Aspect Ratio: incorrect colors of the best and worst values
529 myLookupTable->SetHueRange(0.667,0.0);
531 myScalarBarActor = SMESH_ScalarBarActor::New();
532 myScalarBarActor->SetVisibility(false);
533 myScalarBarActor->SetLookupTable(myLookupTable);
536 //Incorrect "Min value" in Scalar Bar in Mesh:
537 // myScalarBarActor->SetLabelFormat("%.4g");
538 // changes was commented because of regression bug IPAL 19981
540 mgr = SUIT_Session::session()->resourceMgr();
544 myEntityMode = eAllEntity;
545 myEntityModeCache = eAllEntity;
548 myImplicitBoolean = vtkImplicitBoolean::New();
549 myImplicitBoolean->SetOperationTypeToIntersection();
551 //Quadratic 2D elements representation
552 //-----------------------------------------------------------------------------
553 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
554 if(aQuadratic2DMode == 0){
555 myHighlitableActor->SetQuadraticArcMode(false);
556 my2DActor->SetQuadraticArcMode(false);
557 my1DActor->SetQuadraticArcMode(false);
559 else if(aQuadratic2DMode == 1){
560 myHighlitableActor->SetQuadraticArcMode(true);
561 my2DActor->SetQuadraticArcMode(true);
562 my1DActor->SetQuadraticArcMode(true);
565 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
566 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
567 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
569 // Set colors of the name actor
570 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
571 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
572 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
573 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
575 #ifndef DISABLE_PLOT2DVIEWER
579 SetBallSize(aBallElemSize);
580 Set0DSize(aElem0DSize);
584 SMESH_ActorDef::~SMESH_ActorDef()
586 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
588 // Please keep the order same as one in the header file
590 myTimeStamp->Delete();
592 myScalarBarActor->Delete();
593 myLookupTable->Delete();
595 mySurfaceProp->Delete();
596 myBackSurfaceProp->Delete();
597 myNormalVProp->Delete();
598 myReversedVProp->Delete();
599 myEdgeProp->Delete();
600 myNodeProp->Delete();
602 myNodeActor->Delete();
603 myBaseActor->Delete();
604 //myPickableActor->Delete(); myPickableActor == myBaseActor
606 myHighlightProp->Delete();
607 myOutLineProp->Delete();
608 myPreselectProp->Delete();
610 myBallHighlightProp->Delete();
611 myBallPreselectProp->Delete();
613 myHighlitableActor->Delete();
615 my2DExtProp->Delete();
616 my3DExtProp->Delete();
618 my2DExtActor->Delete();
620 my3DExtActor->Delete();
621 // myControlActor->Delete(); myControlActor == my2DActor
623 myNodeExtProp->Delete();
624 myNodeExtActor->Delete();
628 my1DExtProp->Delete();
629 my1DExtActor->Delete();
633 myBallProp->Delete();
634 myBallActor->Delete();
635 //my0DExtProp->Delete();
636 //my0DExtActor->Delete();
638 myImplicitBoolean->Delete();
640 #ifndef DISABLE_PLOT2DVIEWER
642 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
643 delete my2dHistogram;
648 void SMESH_ActorDef::Delete()
650 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
651 // from the actor's destructor) will be thrown before removing the actor's observers,
652 // that is done inside the Superclass::Delete() method but before the destructor itself
653 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
654 // The event is caught by SMESHGUI::ProcessEvents() static method.
655 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
657 Superclass::Delete();
660 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
663 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
664 SetRepresentation(GetRepresentation());
665 myTimeStamp->Modified();
669 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
670 bool theBold, bool theItalic, bool theShadow,
671 double r, double g, double b )
674 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
675 SetRepresentation( GetRepresentation() );
676 myTimeStamp->Modified();
680 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
681 bool theBold, bool theItalic, bool theShadow,
682 double r, double g, double b )
685 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
686 SetRepresentation( GetRepresentation() );
687 myTimeStamp->Modified();
690 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
691 SetRepresentation( GetRepresentation() );
692 myTimeStamp->Modified();
695 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
696 SetRepresentation( GetRepresentation() );
697 myTimeStamp->Modified();
700 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
701 SetRepresentation( GetRepresentation() );
702 myTimeStamp->Modified();
705 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
706 SetRepresentation( GetRepresentation() );
707 myTimeStamp->Modified();
711 bool SMESH_ActorDef::GetPointsLabeled() {
712 return myNodeActor && myNodeActor->GetPointsLabeled();
715 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
718 my3DActor->SetCellsLabeled(theIsCellsLabeled);
721 my2DActor->SetCellsLabeled(theIsCellsLabeled);
724 my1DActor->SetCellsLabeled(theIsCellsLabeled);
727 my0DActor->SetCellsLabeled(theIsCellsLabeled);
730 myBallActor->SetCellsLabeled(theIsCellsLabeled);
732 myTimeStamp->Modified();
736 bool SMESH_ActorDef::GetCellsLabeled() {
739 result = result || my3DActor->GetCellsLabeled();
742 result = result || my2DActor->GetCellsLabeled();
745 result = result || my1DActor->GetCellsLabeled();
748 result = result || my0DActor->GetCellsLabeled();
751 result = result || myBallActor->GetCellsLabeled();
757 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
759 myIsFacesOriented = theIsFacesOriented;
761 my2DActor->SetFacesOriented(theIsFacesOriented);
762 my3DActor->SetFacesOriented(theIsFacesOriented);
764 myTimeStamp->Modified();
767 bool SMESH_ActorDef::GetFacesOriented()
769 return myIsFacesOriented;
772 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
774 my2DActor->SetFacesOrientationColor( r, g, b );
775 my3DActor->SetFacesOrientationColor( r, g, b );
778 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
780 my3DActor->GetFacesOrientationColor( r, g, b );
783 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
785 my2DActor->SetFacesOrientationScale( theScale );
786 my3DActor->SetFacesOrientationScale( theScale );
789 double SMESH_ActorDef::GetFacesOrientationScale()
791 return my3DActor->GetFacesOrientationScale();
794 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
796 my2DActor->SetFacesOrientation3DVectors( theState );
797 my3DActor->SetFacesOrientation3DVectors( theState );
800 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
802 return my3DActor->GetFacesOrientation3DVectors();
808 SetControlMode(eControl theMode)
810 SetControlMode(theMode,true);
816 SetControlMode(eControl theMode,
817 bool theCheckEntityMode)
819 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
820 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
821 lookupTable->SetScale(VTK_SCALE_LINEAR);
823 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
827 myControlMode = eNone;
828 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
830 my0DActor->GetMapper()->SetScalarVisibility(false);
831 my1DActor->GetMapper()->SetScalarVisibility(false);
832 my2DActor->GetMapper()->SetScalarVisibility(false);
833 my3DActor->GetMapper()->SetScalarVisibility(false);
834 myBallActor->GetMapper()->SetScalarVisibility(false);
835 myScalarBarActor->SetVisibility(false);
837 bool anIsScalarVisible = theMode > eNone;
839 if(anIsScalarVisible) {
843 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
844 aControl->SetPrecision( myControlsPrecision );
845 myFunctor.reset( aControl );
846 myControlActor = my1DActor;
851 myFunctor.reset(new SMESH::Controls::Length2D());
852 myControlActor = my2DActor;
856 myFunctor.reset(new SMESH::Controls::FreeBorders());
857 myControlActor = my1DActor;
860 myFunctor.reset(new SMESH::Controls::FreeEdges());
861 myControlActor = my2DActor;
864 myFunctor.reset(new SMESH::Controls::FreeNodes());
865 myControlActor = myNodeActor;
868 myFunctor.reset(new SMESH::Controls::FreeFaces());
869 myControlActor = my2DActor;
871 case eCoincidentNodes:
873 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
874 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
875 cn->SetTolerance( tol );
877 myControlActor = myNodeActor;
880 case eCoincidentElems1D:
881 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
882 myControlActor = my1DActor;
884 case eCoincidentElems2D:
885 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
886 myControlActor = my2DActor;
888 case eCoincidentElems3D:
889 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
890 myControlActor = my3DActor;
892 case eBareBorderFace:
893 myFunctor.reset(new SMESH::Controls::BareBorderFace());
894 myControlActor = my2DActor;
896 case eOverConstrainedFace:
897 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
898 myControlActor = my2DActor;
900 case eMultiConnection:
901 myFunctor.reset(new SMESH::Controls::MultiConnection());
902 myControlActor = my1DActor;
904 case eMultiConnection2D:
905 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
906 myControlActor = my2DActor;
910 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
911 aControl->SetPrecision( myControlsPrecision );
912 myFunctor.reset( aControl );
913 myControlActor = my2DActor;
918 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
919 aControl->SetPrecision( myControlsPrecision );
920 myFunctor.reset( aControl );
921 myControlActor = my2DActor;
926 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
927 aControl->SetPrecision( myControlsPrecision );
928 myFunctor.reset( aControl );
929 myControlActor = my2DActor;
934 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
935 aControl->SetPrecision( myControlsPrecision );
936 myFunctor.reset( aControl );
937 myControlActor = my3DActor;
942 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
943 aControl->SetPrecision( myControlsPrecision );
944 myFunctor.reset( aControl );
945 myControlActor = my3DActor;
948 case eMaxElementLength2D:
950 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
951 aControl->SetPrecision( myControlsPrecision );
952 myFunctor.reset( aControl );
953 myControlActor = my2DActor;
956 case eMaxElementLength3D:
958 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
959 aControl->SetPrecision( myControlsPrecision );
960 myFunctor.reset( aControl );
961 myControlActor = my3DActor;
964 case eBareBorderVolume:
966 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
967 myControlActor = my3DActor;
970 case eOverConstrainedVolume:
972 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
973 myControlActor = my3DActor;
978 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
979 aControl->SetPrecision( myControlsPrecision );
980 myFunctor.reset( aControl );
981 myControlActor = my2DActor;
986 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
987 aControl->SetPrecision( myControlsPrecision );
988 myFunctor.reset( aControl );
989 myControlActor = my2DActor;
994 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
995 aControl->SetPrecision( myControlsPrecision );
996 myFunctor.reset( aControl );
997 myControlActor = my2DActor;
1004 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
1005 vtkIdType aNbCells = aGrid->GetNumberOfCells();
1007 myControlMode = theMode;
1008 switch(myControlMode){
1010 case eCoincidentNodes:
1011 myNodeExtActor->SetExtControlMode(myFunctor);
1015 case eCoincidentElems1D:
1016 my1DExtActor->SetExtControlMode(myFunctor);
1019 case eBareBorderFace:
1020 case eOverConstrainedFace:
1021 case eCoincidentElems2D:
1022 my2DExtActor->SetExtControlMode(myFunctor);
1024 case eBareBorderVolume:
1025 case eOverConstrainedVolume:
1026 case eCoincidentElems3D:
1027 my3DExtActor->SetExtControlMode(myFunctor);
1030 case eMultiConnection2D:
1031 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1032 UpdateDistribution();
1035 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1036 UpdateDistribution();
1040 if(theCheckEntityMode) {
1041 if(myControlActor == my1DActor) {
1042 if (!myIsEntityModeCache){
1043 myEntityModeCache = GetEntityMode();
1044 myIsEntityModeCache=true;
1046 SetEntityMode(eEdges);
1048 else if(myControlActor == my2DActor) {
1049 switch(myControlMode) {
1053 case eMultiConnection2D:
1054 if (!myIsEntityModeCache){
1055 myEntityModeCache = GetEntityMode();
1056 myIsEntityModeCache=true;
1058 SetEntityMode(eFaces);
1061 if (!myIsEntityModeCache){
1062 myEntityModeCache = GetEntityMode();
1063 myIsEntityModeCache=true;
1065 SetEntityMode(eFaces);
1067 }else if(myControlActor == my3DActor) {
1068 if (!myIsEntityModeCache){
1069 myEntityModeCache = GetEntityMode();
1070 myIsEntityModeCache=true;
1072 SetEntityMode(eVolumes);
1078 if(theCheckEntityMode){
1079 myEntityMode = myEntityModeCache;
1080 myIsEntityModeCache = false;
1085 SetRepresentation(GetRepresentation());
1087 myTimeStamp->Modified();
1090 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1091 double * range = lookupTable->GetRange();
1093 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1094 lookupTable->SetScale(VTK_SCALE_LOG10);
1100 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
1102 //myHighlightActor->AddToRender(theRenderer);
1104 theRenderer->AddActor(myBaseActor);
1105 theRenderer->AddActor(myNodeExtActor);
1106 theRenderer->AddActor(my1DExtActor);
1108 my3DActor ->AddToRender(theRenderer);
1109 my3DExtActor->AddToRender(theRenderer);
1110 my2DActor ->AddToRender(theRenderer);
1111 my2DExtActor->AddToRender(theRenderer);
1112 myNodeActor ->AddToRender(theRenderer);
1113 my1DActor ->AddToRender(theRenderer);
1114 my0DActor ->AddToRender(theRenderer);
1115 myBallActor ->AddToRender(theRenderer);
1116 //theRenderer->AddActor(my0DExtActor);
1118 theRenderer->AddActor(myHighlitableActor);
1120 theRenderer->AddActor2D(myScalarBarActor);
1122 // the superclass' method should be called at the end
1123 // (in particular, for correct work of selection)
1124 SALOME_Actor::AddToRender(theRenderer);
1127 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1128 SALOME_Actor::RemoveFromRender(theRenderer);
1130 theRenderer->RemoveActor(myBaseActor);
1132 theRenderer->RemoveActor(myNodeExtActor);
1134 theRenderer->RemoveActor(myHighlitableActor);
1136 //theRenderer->RemoveActor(my0DExtActor);
1138 theRenderer->RemoveActor(my1DExtActor);
1140 my2DActor->RemoveFromRender(theRenderer);
1141 my2DExtActor->RemoveFromRender(theRenderer);
1142 my3DActor->RemoveFromRender(theRenderer);
1143 my3DExtActor->RemoveFromRender(theRenderer);
1144 myNodeActor->RemoveFromRender(theRenderer);
1145 my0DActor->RemoveFromRender(theRenderer);
1146 myBallActor->RemoveFromRender(theRenderer);
1147 my1DActor->RemoveFromRender(theRenderer);
1149 theRenderer->RemoveActor(myScalarBarActor);
1153 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1154 const char* theEntry,
1155 const char* theName,
1158 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1162 myVisualObj = theVisualObj;
1163 myVisualObj->Update(theIsClear);
1165 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1166 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1168 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1170 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1172 my0DActor->Init(myVisualObj,myImplicitBoolean);
1173 myBallActor->Init(myVisualObj,myImplicitBoolean);
1174 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1176 my1DActor->Init(myVisualObj,myImplicitBoolean);
1177 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1179 my2DActor->Init(myVisualObj,myImplicitBoolean);
1180 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1181 my3DActor->Init(myVisualObj,myImplicitBoolean);
1182 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1184 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1185 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1186 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1188 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1189 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1191 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1192 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1193 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1194 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1196 double aFactor, aUnits;
1197 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1198 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1199 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1200 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1202 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1206 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1207 SetIsShrunkable(true);
1209 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1211 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1212 SetRepresentation(-1);
1215 SetRepresentation(eEdge);
1216 }else if(aMode == 1){
1217 SetRepresentation(eSurface);
1218 }else if(aMode == 2){
1219 SetRepresentation(ePoint);
1226 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1227 SetIsDisplayNameActor( true );
1229 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1230 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1231 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1233 myTimeStamp->Modified();
1239 double* SMESH_ActorDef::GetBounds(){
1240 return myNodeActor->GetBounds();
1244 vtkDataSet* SMESH_ActorDef::GetInput(){
1245 return GetUnstructuredGrid();
1249 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1250 Superclass::SetTransform(theTransform);
1252 myNodeActor->SetTransform(theTransform);
1253 myBaseActor->SetTransform(theTransform);
1255 myHighlitableActor->SetTransform(theTransform);
1257 myNodeExtActor->SetTransform(theTransform);
1259 my0DActor->SetTransform(theTransform);
1260 myBallActor->SetTransform(theTransform);
1261 //my0DExtActor->SetTransform(theTransform);
1263 my1DActor->SetTransform(theTransform);
1264 my1DExtActor->SetTransform(theTransform);
1266 my2DActor->SetTransform(theTransform);
1267 my2DExtActor->SetTransform(theTransform);
1268 my3DActor->SetTransform(theTransform);
1269 my3DExtActor->SetTransform(theTransform);
1275 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1276 vtkLODActor::SetMapper(theMapper);
1280 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1281 SALOME_Actor::ShallowCopy(prop);
1285 vtkMapper* SMESH_ActorDef::GetMapper(){
1286 return myPickableActor->GetMapper();
1290 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1291 return myVisualObj->GetUnstructuredGrid();
1295 bool SMESH_ActorDef::IsInfinitive(){
1296 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1297 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1298 ( aDataSet->GetNumberOfCells() == 1 &&
1299 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1300 return SALOME_Actor::IsInfinitive();
1304 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1305 if ( myIsShrinkable == theShrunkable )
1307 myIsShrinkable = theShrunkable;
1311 double SMESH_ActorDef::GetShrinkFactor(){
1312 return myBaseActor->GetShrinkFactor();
1315 void SMESH_ActorDef::SetShrinkFactor(double theValue){
1316 myBaseActor->SetShrinkFactor(theValue);
1318 my1DActor->SetShrinkFactor(theValue);
1319 my1DExtActor->SetShrinkFactor(theValue);
1321 my2DActor->SetShrinkFactor(theValue);
1322 my2DExtActor->SetShrinkFactor(theValue);
1323 my3DActor->SetShrinkFactor(theValue);
1324 my3DExtActor->SetShrinkFactor(theValue);
1325 my3DExtActor->SetShrinkFactor(theValue);
1326 myHighlitableActor->SetShrinkFactor(theValue);
1331 void SMESH_ActorDef::SetShrink(){
1332 if(!myIsShrinkable) return;
1334 myBaseActor->SetShrink();
1336 my1DActor->SetShrink();
1337 my1DExtActor->SetShrink();
1339 my2DActor->SetShrink();
1340 my2DExtActor->SetShrink();
1341 my3DActor->SetShrink();
1342 my3DExtActor->SetShrink();
1343 myHighlitableActor->SetShrink();
1349 void SMESH_ActorDef::UnShrink(){
1350 if(!myIsShrunk) return;
1352 myBaseActor->UnShrink();
1354 my1DActor->UnShrink();
1355 my1DExtActor->UnShrink();
1357 my2DActor->UnShrink();
1358 my2DExtActor->UnShrink();
1359 my3DActor->UnShrink();
1360 my3DExtActor->UnShrink();
1361 myHighlitableActor->UnShrink();
1368 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1369 return myPickableActor->GetNodeObjId(theVtkID);
1372 double* SMESH_ActorDef::GetNodeCoord(int theObjID){
1373 return myPickableActor->GetNodeCoord(theObjID);
1377 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1378 return myPickableActor->GetElemObjId(theVtkID);
1381 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1382 return myPickableActor->GetElemCell(theObjID);
1386 void SMESH_ActorDef::SetVisibility(int theMode){
1387 SetVisibility(theMode,true);
1391 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1392 SALOME_Actor::SetVisibility(theMode);
1394 myNodeActor->VisibilityOff();
1395 myBaseActor->VisibilityOff();
1397 myNodeExtActor->VisibilityOff();
1399 my0DActor->VisibilityOff();
1400 myBallActor->VisibilityOff();
1401 //my0DExtActor->VisibilityOff();
1403 my1DActor->VisibilityOff();
1404 my1DExtActor->VisibilityOff();
1406 my2DActor->VisibilityOff();
1407 my2DExtActor->VisibilityOff();
1408 my3DActor->VisibilityOff();
1409 my3DExtActor->VisibilityOff();
1411 myScalarBarActor->VisibilityOff();
1413 if(GetVisibility()){
1414 if(theIsUpdateRepersentation)
1415 SetRepresentation(GetRepresentation());
1417 if(myControlMode != eNone){
1418 switch(myControlMode){
1420 case eCoincidentNodes:
1421 myNodeExtActor->VisibilityOn();
1425 case eCoincidentElems1D:
1426 my1DExtActor->VisibilityOn();
1429 case eBareBorderFace:
1430 case eOverConstrainedFace:
1431 case eCoincidentElems2D:
1432 my2DExtActor->VisibilityOn();
1434 case eBareBorderVolume:
1435 case eOverConstrainedVolume:
1436 case eCoincidentElems3D:
1437 my3DExtActor->VisibilityOn();
1440 case eMultiConnection2D:
1441 my1DExtActor->VisibilityOn();
1443 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1444 myScalarBarActor->VisibilityOn();
1448 if(myRepresentation != ePoint)
1449 myPickableActor->VisibilityOn();
1451 myNodeActor->VisibilityOn();
1454 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1455 my0DActor->VisibilityOn();
1457 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1458 myBallActor->VisibilityOn();
1461 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1462 my1DActor->VisibilityOn();
1465 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1466 my2DActor->VisibilityOn();
1469 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1470 my3DActor->VisibilityOn();
1473 if(myNodeActor->GetPointsLabeled()){
1474 myNodeActor->VisibilityOn();
1478 my0DActor->UpdateLabels();
1481 myBallActor->UpdateLabels();
1484 my1DActor->UpdateLabels();
1487 my2DActor->UpdateLabels();
1490 my3DActor->UpdateLabels();
1492 #ifndef DISABLE_PLOT2DVIEWER
1494 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1501 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1503 myEntityState = eAllEntity;
1505 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1506 myEntityState &= ~e0DElements;
1507 theMode &= ~e0DElements;
1510 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1511 myEntityState &= ~eBallElem;
1512 theMode &= ~eBallElem;
1515 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1516 myEntityState &= ~eEdges;
1520 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1521 myEntityState &= ~eFaces;
1525 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1526 myEntityState &= ~eVolumes;
1527 theMode &= ~eVolumes;
1531 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1532 theMode |= e0DElements;
1534 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1535 theMode |= eBallElem;
1537 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1540 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1543 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1544 theMode |= eVolumes;
1547 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1549 myEntityMode = theMode;
1550 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1551 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1552 aFilter->ClearRegisteredCellsWithType();
1553 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1555 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1556 aHightFilter->ClearRegisteredCellsWithType();
1557 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1559 if (myEntityMode & e0DElements) {
1560 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1561 aFilter->RegisterCellsWithType(VTK_VERTEX);
1562 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1565 if (myEntityMode & eBallElem) {
1566 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1567 aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1570 if (myEntityMode & eEdges) {
1571 if (MYDEBUG) MESSAGE("EDGES");
1572 aFilter->RegisterCellsWithType(VTK_LINE);
1573 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1575 aHightFilter->RegisterCellsWithType(VTK_LINE);
1576 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1579 if (myEntityMode & eFaces) {
1580 if (MYDEBUG) MESSAGE("FACES");
1581 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1582 aFilter->RegisterCellsWithType(VTK_POLYGON);
1583 aFilter->RegisterCellsWithType(VTK_QUAD);
1584 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1585 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1586 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1587 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1589 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1590 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1591 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1592 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1593 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1594 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1595 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1598 if (myEntityMode & eVolumes) {
1599 if (MYDEBUG) MESSAGE("VOLUMES");
1600 aFilter->RegisterCellsWithType(VTK_TETRA);
1601 aFilter->RegisterCellsWithType(VTK_VOXEL);
1602 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1603 aFilter->RegisterCellsWithType(VTK_WEDGE);
1604 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1605 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1606 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1607 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1608 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1609 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1610 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1611 //#ifdef VTK_HAVE_POLYHEDRON
1612 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1615 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1616 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1617 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1618 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1619 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1620 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1621 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1622 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1623 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1624 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1625 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1626 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1627 //#ifdef VTK_HAVE_POLYHEDRON
1628 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1632 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1633 SetVisibility(GetVisibility(),false);
1636 void SMESH_ActorDef::SetRepresentation (int theMode)
1638 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1639 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1640 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1641 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1642 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1645 myRepresentation = eSurface;
1646 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1647 myRepresentation = eEdge;
1648 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1649 myRepresentation = ePoint;
1654 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1657 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1660 myRepresentation = theMode;
1663 if (!GetUnstructuredGrid()->GetNumberOfCells())
1664 myRepresentation = ePoint;
1667 if (myRepresentation == ePoint) {
1675 myPickableActor = myBaseActor;
1676 myNodeActor->SetVisibility(false);
1677 myNodeExtActor->SetVisibility(false);
1678 vtkProperty *aProp = NULL, *aBackProp = NULL;
1679 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1680 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1681 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1682 switch (myRepresentation) {
1684 myPickableActor = myNodeActor;
1685 myNodeActor->SetVisibility(true);
1686 aQuadraticMode = SMESH_Actor::eLines;
1687 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1688 aReperesent = SMESH_DeviceActor::ePoint;
1691 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1692 aReperesent = SMESH_DeviceActor::eInsideframe;
1695 aProp = mySurfaceProp;
1696 aBackProp = myBackSurfaceProp;
1697 aPropVN = myNormalVProp;
1698 aPropVR = myReversedVProp;
1699 aReperesent = SMESH_DeviceActor::eSurface;
1703 my2DActor->SetProperty(aProp);
1704 my2DActor->SetBackfaceProperty(aBackProp);
1705 my2DActor->SetRepresentation(aReperesent);
1707 if(aQuadraticMode == SMESH_Actor::eLines)
1708 my2DActor->SetQuadraticArcMode(false);
1709 else if(aQuadraticMode == SMESH_Actor::eArcs)
1710 my2DActor->SetQuadraticArcMode(true);
1712 my2DExtActor->SetRepresentation(aReperesent);
1714 my3DActor->SetProperty(aPropVN);
1715 my3DActor->SetBackfaceProperty(aPropVR);
1716 my3DActor->SetRepresentation(aReperesent);
1718 //my0DExtActor->SetVisibility(false);
1719 my1DExtActor->SetVisibility(false);
1720 my2DExtActor->SetVisibility(false);
1721 my3DExtActor->SetVisibility(false);
1724 //my0DActor->SetProperty(aProp);
1725 //my0DActor->SetBackfaceProperty(aBackProp);
1726 my0DActor->SetRepresentation(aReperesent);
1727 myBallActor->SetRepresentation(aReperesent);
1728 //my0DExtActor->SetRepresentation(aReperesent);
1730 switch(myControlMode){
1732 case eMultiConnection:
1733 aProp = aBackProp = my1DProp;
1734 if(myRepresentation != ePoint)
1735 aReperesent = SMESH_DeviceActor::eInsideframe;
1739 if(aQuadraticMode == SMESH_Actor::eLines)
1740 my1DActor->SetQuadraticArcMode(false);
1741 else if(aQuadraticMode == SMESH_Actor::eArcs)
1742 my1DActor->SetQuadraticArcMode(true);
1744 my1DActor->SetProperty(aProp);
1745 my1DActor->SetBackfaceProperty(aBackProp);
1746 my1DActor->SetRepresentation(aReperesent);
1748 my1DExtActor->SetRepresentation(aReperesent);
1750 if(myIsPointsVisible)
1751 myPickableActor = myNodeActor;
1752 if(GetPointRepresentation())
1753 myNodeActor->SetVisibility(true);
1755 SetMapper(myPickableActor->GetMapper());
1757 SetVisibility(GetVisibility(),false);
1763 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1764 if ( myIsPointsVisible == theIsPointsVisible )
1766 myIsPointsVisible = theIsPointsVisible;
1767 SetRepresentation(GetRepresentation());
1770 bool SMESH_ActorDef::GetPointRepresentation(){
1771 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1775 void SMESH_ActorDef::UpdateHighlight(){
1776 myHighlitableActor->SetHighlited(false);
1777 myHighlitableActor->SetVisibility(false);
1779 bool anIsVisible = GetVisibility();
1781 switch(myRepresentation){
1782 case SMESH_DeviceActor::eSurface:
1783 case SMESH_DeviceActor::eWireframe:
1785 if(myIsHighlighted) {
1786 myHighlitableActor->SetProperty(myHighlightProp);
1787 myBallActor->SetProperty(myBallHighlightProp);
1788 }else if(myIsPreselected){
1789 myHighlitableActor->SetProperty(myPreselectProp);
1790 myBallActor->SetProperty(myBallPreselectProp);
1791 } else if(anIsVisible){
1792 myBallActor->SetProperty(myBallProp);
1793 (myRepresentation == eSurface) ?
1794 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1796 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1797 myHighlitableActor->SetHighlited(anIsVisible);
1798 myHighlitableActor->GetExtractUnstructuredGrid()->
1799 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1800 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1802 myHighlitableActor->SetVisibility(anIsVisible);
1805 case SMESH_DeviceActor::ePoint:
1807 if(myIsHighlighted) {
1808 myNodeActor->SetProperty(myHighlightProp);
1809 }else if(myIsPreselected) {
1810 myNodeActor->SetProperty(myPreselectProp);
1811 } else if(anIsVisible) {
1812 myNodeActor->SetProperty(myNodeProp);
1814 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1815 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1822 void SMESH_ActorDef::highlight(bool theHighlight){
1823 if ( myIsHighlighted == theHighlight )
1825 myIsHighlighted = theHighlight;
1830 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1831 if ( myIsPreselected == thePreselect )
1833 myIsPreselected = thePreselect;
1839 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1841 if (myPickableActor->GetIsOpaque())
1843 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1851 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1853 if (!myPickableActor->GetIsOpaque())
1855 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1863 void SMESH_ActorDef::Render(vtkRenderer *ren){
1864 unsigned long aTime = myTimeStamp->GetMTime();
1865 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1866 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1867 if(anObjTime > aTime || aClippingTime > aTime)
1872 void SMESH_ActorDef::Update(){
1873 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1875 if(GetControlMode() != eNone) {
1876 unsigned long aTime = myTimeStamp->GetMTime();
1877 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1878 if (anObjTime > aTime)
1879 SetControlMode(GetControlMode(),false);
1883 myNodeActor->UpdateLabels();
1886 my0DActor->UpdateLabels();
1889 myBallActor->UpdateLabels();
1892 my1DActor->UpdateLabels();
1895 my2DActor->UpdateLabels();
1898 my3DActor->UpdateLabels();
1900 if(myIsFacesOriented){
1901 SetFacesOriented(myIsFacesOriented);
1904 if(myVisualObj->GetEntitiesFlag()) {
1905 myEntityMode |= myVisualObj->GetEntitiesState();
1908 SetEntityMode(GetEntityMode());
1909 SetVisibility(GetVisibility());
1911 myTimeStamp->Modified();
1916 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1917 SALOME_Actor::ReleaseGraphicsResources(renWin);
1919 myPickableActor->ReleaseGraphicsResources(renWin);
1923 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b){
1924 double* aColor = theProperty->GetColor();
1931 void SMESH_ActorDef::SetOpacity(double theValue){
1932 mySurfaceProp->SetOpacity(theValue);
1933 myBackSurfaceProp->SetOpacity(theValue);
1934 myNormalVProp->SetOpacity(theValue);
1935 myReversedVProp->SetOpacity(theValue);
1936 myEdgeProp->SetOpacity(theValue);
1937 myOutLineProp->SetOpacity(theValue);
1938 myNodeProp->SetOpacity(theValue);
1940 my1DProp->SetOpacity(theValue);
1941 my0DProp->SetOpacity(theValue);
1942 myBallProp->SetOpacity(theValue);
1946 double SMESH_ActorDef::GetOpacity(){
1947 return mySurfaceProp->GetOpacity();
1951 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta){
1952 mySurfaceProp->SetColor(r,g,b);
1953 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1954 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1955 if( aGroupObj->GetElementType() == SMDSAbs_Face )
1956 myNameActor->SetBackgroundColor(r,g,b);
1958 myDeltaBrightness = delta;
1959 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1960 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1964 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta){
1965 ::GetColor(mySurfaceProp,r,g,b);
1966 delta = myDeltaBrightness;
1969 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta){
1970 myNormalVProp->SetColor(r,g,b);
1971 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1972 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1973 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
1974 myNameActor->SetBackgroundColor(r,g,b);
1976 myDeltaVBrightness = delta;
1977 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1978 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1982 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta){
1983 ::GetColor(myNormalVProp,r,g,b);
1984 delta = myDeltaVBrightness;
1987 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b){
1988 myEdgeProp->SetColor(r,g,b);
1989 my1DProp->SetColor(r,g,b);
1990 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1991 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1992 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1993 myNameActor->SetBackgroundColor(r,g,b);
1997 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b){
1998 ::GetColor(myEdgeProp,r,g,b);
2001 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b){
2002 myOutLineProp->SetColor(r,g,b);
2006 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b){
2007 ::GetColor(myOutLineProp,r,g,b);
2011 void SMESH_ActorDef::SetNodeColor(double r,double g,double b){
2012 myNodeProp->SetColor(r,g,b);
2013 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2014 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2015 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2016 myNameActor->SetBackgroundColor(r,g,b);
2020 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b){
2021 ::GetColor(myNodeProp,r,g,b);
2024 void SMESH_ActorDef::Set0DColor(double r,double g,double b){
2025 my0DProp->SetColor(r,g,b);
2026 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2027 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2028 myNameActor->SetBackgroundColor(r,g,b);
2032 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b){
2033 ::GetColor(my0DProp,r,g,b);
2036 void SMESH_ActorDef::SetBallColor(double r,double g,double b){
2037 myBallProp->SetColor(r,g,b);
2038 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2039 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2040 myNameActor->SetBackgroundColor(r,g,b);
2044 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b){
2045 ::GetColor(myBallProp,r,g,b);
2048 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b){
2049 myHighlightProp->SetColor(r,g,b);
2050 myBallHighlightProp->SetColor(r,g,b);
2054 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b){
2055 ::GetColor(myHighlightProp,r,g,b);
2058 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b){
2059 myPreselectProp->SetColor(r,g,b);
2060 myBallPreselectProp->SetColor(r,g,b);
2064 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b){
2065 ::GetColor(myPreselectProp,r,g,b);
2069 double SMESH_ActorDef::GetLineWidth(){
2070 return myEdgeProp->GetLineWidth();
2074 void SMESH_ActorDef::SetLineWidth(double theVal){
2075 myEdgeProp->SetLineWidth(theVal);
2077 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2078 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2079 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2080 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2081 myOutLineProp->SetLineWidth(theVal);
2082 myHighlightProp->SetLineWidth(theVal);
2083 myPreselectProp->SetLineWidth(theVal);
2087 double SMESH_ActorDef::GetOutlineWidth()
2089 return myOutLineProp->GetLineWidth();
2092 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2094 myOutLineProp->SetLineWidth(theVal);
2098 void SMESH_ActorDef::Set0DSize(double theVal){
2099 my0DProp->SetPointSize(theVal);
2100 myHighlightProp->SetPointSize(theVal);
2101 myPreselectProp->SetPointSize(theVal);
2103 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2104 aCustom->Set0DSize(theVal);
2106 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2107 aCustom->Set0DSize(theVal);
2113 double SMESH_ActorDef::Get0DSize(){
2114 return my0DProp->GetPointSize();
2117 void SMESH_ActorDef::SetBallSize(double theVal){
2118 myBallProp->SetPointSize(theVal);
2119 myBallHighlightProp->SetPointSize(theVal);
2120 myBallPreselectProp->SetPointSize(theVal);
2121 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2122 aCustom->SetBallSize(theVal);
2124 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2125 aCustom->SetBallSize(theVal);
2131 double SMESH_ActorDef::GetBallSize(){
2132 return myBallProp->GetPointSize();
2135 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2137 return myVisualObj->GetElemDimension( theObjId );
2142 IsImplicitFunctionUsed() const
2144 return myBaseActor->IsImplicitFunctionUsed();
2148 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2150 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2151 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2153 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2155 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2157 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2158 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2159 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2161 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2162 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2164 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2165 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2166 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2167 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2171 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2174 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2175 myCippingPlaneCont.push_back(thePlane);
2176 if(!IsImplicitFunctionUsed())
2177 SetImplicitFunctionUsed(true);
2178 myNodeActor->UpdateLabels();
2180 return myCippingPlaneCont.size();
2185 RemoveAllClippingPlanes()
2187 myImplicitBoolean->GetFunction()->RemoveAllItems();
2188 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2189 myCippingPlaneCont.clear();
2190 SetImplicitFunctionUsed(false);
2191 myNodeActor->UpdateLabels();
2196 GetNumberOfClippingPlanes()
2198 return myCippingPlaneCont.size();
2203 GetClippingPlane(vtkIdType theID)
2205 if(theID >= myCippingPlaneCont.size())
2207 return myCippingPlaneCont[theID].Get();
2210 void SMESH_ActorDef::UpdateScalarBar()
2212 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2216 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2218 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2219 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2221 aScalarBarTitleProp->SetFontFamilyToArial();
2223 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2225 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2226 if ( f.family() == "Arial" )
2227 aScalarBarTitleProp->SetFontFamilyToArial();
2228 else if ( f.family() == "Courier" )
2229 aScalarBarTitleProp->SetFontFamilyToCourier();
2230 else if ( f.family() == "Times" )
2231 aScalarBarTitleProp->SetFontFamilyToTimes();
2234 aScalarBarTitleProp->BoldOn();
2236 aScalarBarTitleProp->BoldOff();
2239 aScalarBarTitleProp->ItalicOn();
2241 aScalarBarTitleProp->ItalicOff();
2244 aScalarBarTitleProp->ShadowOn();
2246 aScalarBarTitleProp->ShadowOff();
2249 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2250 aScalarBarTitleProp->Delete();
2252 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2254 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2255 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2257 aScalarBarLabelProp->SetFontFamilyToArial();
2258 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2260 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2261 if( f.family() == "Arial" )
2262 aScalarBarLabelProp->SetFontFamilyToArial();
2263 else if( f.family() == "Courier" )
2264 aScalarBarLabelProp->SetFontFamilyToCourier();
2265 else if( f.family() == "Times" )
2266 aScalarBarLabelProp->SetFontFamilyToTimes();
2269 aScalarBarLabelProp->BoldOn();
2271 aScalarBarLabelProp->BoldOff();
2274 aScalarBarLabelProp->ItalicOn();
2276 aScalarBarLabelProp->ItalicOff();
2279 aScalarBarLabelProp->ShadowOn();
2281 aScalarBarLabelProp->ShadowOff();
2284 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2285 aScalarBarLabelProp->Delete();
2287 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2288 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2290 myScalarBarActor->SetOrientationToHorizontal();
2292 myScalarBarActor->SetOrientationToVertical();
2295 double aXVal = horiz ? 0.20 : 0.01;
2296 if( mgr->hasValue( "SMESH", name + "x" ) )
2297 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2299 double aYVal = horiz ? 0.01 : 0.1;
2300 if( mgr->hasValue( "SMESH", name + "y" ) )
2301 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2302 myScalarBarActor->SetPosition( aXVal, aYVal );
2304 double aWVal = horiz ? 0.60 : 0.10;
2305 if( mgr->hasValue( "SMESH", name + "width" ) )
2306 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2307 myScalarBarActor->SetWidth( aWVal );
2309 double aHVal = horiz ? 0.12 : 0.80;
2310 if( mgr->hasValue( "SMESH", name + "height" ) )
2311 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2312 myScalarBarActor->SetHeight( aHVal );
2315 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2316 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2317 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2320 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2321 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2322 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2324 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2325 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2327 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2328 myScalarBarActor->SetDistributionColoringType(coloringType);
2330 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2331 QColor(255, 255, 255));
2333 rgb[0]= distributionColor.red()/255.;
2334 rgb[1]= distributionColor.green()/255.;
2335 rgb[2]= distributionColor.blue()/255.;
2336 myScalarBarActor->SetDistributionColor(rgb);
2341 void SMESH_ActorDef::UpdateDistribution()
2343 if(SMESH::Controls::NumericalFunctor* fun =
2344 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2346 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2347 std::vector<int> nbEvents;
2348 std::vector<double> funValues;
2349 SMESH_VisualObjDef::TEntityList elems;
2350 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2351 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2352 std::vector<int> elemIds;
2353 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2354 elemIds.push_back( (*e)->GetID());
2355 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2356 double * range = lookupTable->GetRange();
2357 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2358 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2359 myScalarBarActor->SetDistribution(nbEvents);
2363 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2366 case SMESH_Actor::eLines :
2367 myHighlitableActor->SetQuadraticArcMode(false);
2368 my2DActor->SetQuadraticArcMode(false);
2369 my1DActor->SetQuadraticArcMode(false);
2371 case SMESH_Actor::eArcs :
2372 myHighlitableActor->SetQuadraticArcMode(true);
2373 if(GetRepresentation() != SMESH_Actor::ePoint) {
2374 my2DActor->SetQuadraticArcMode(true);
2375 my1DActor->SetQuadraticArcMode(true);
2384 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2386 if(myHighlitableActor->GetQuadraticArcMode())
2387 return SMESH_Actor::eArcs;
2389 return SMESH_Actor::eLines;
2392 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2394 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2395 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2396 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2399 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2401 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2402 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2403 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2404 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2407 #ifndef DISABLE_PLOT2DVIEWER
2408 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2411 my2dHistogram->clearAllPoints();
2413 if(SMESH::Controls::NumericalFunctor* fun =
2414 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2417 if(!my2dHistogram) {
2418 my2dHistogram = new SPlot2d_Histogram();
2419 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2420 my2dHistogram->setIO(anIO);
2423 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2424 std::vector<int> nbEvents;
2425 std::vector<double> funValues;
2426 SMESH_VisualObjDef::TEntityList elems;
2427 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2428 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2429 std::vector<int> elemIds;
2431 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2432 elemIds.push_back( (*e)->GetID());
2434 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2435 double * range = lookupTable->GetRange();
2436 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2437 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2439 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2440 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2442 if(funValues.size() >= 2)
2443 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2447 //Color of the histogram
2448 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2449 my2dHistogram->setAutoAssign(true);
2452 myScalarBarActor->GetDistributionColor(rgb);
2453 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2454 my2dHistogram->setColor(aColor);
2458 return my2dHistogram;