1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_NodeLabelActor.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ObjectDef.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMDS_UnstructuredGrid.hxx"
36 #include "SMESH_ScalarBarActor.h"
37 #include "VTKViewer_ExtractUnstructuredGrid.h"
38 #include "VTKViewer_FramedTextActor.h"
39 #include "SALOME_InteractiveObject.hxx"
40 #include "SMESH_SVTKActor.h"
42 #include "SUIT_Session.h"
43 #include "SUIT_ResourceMgr.h"
47 #ifndef DISABLE_PLOT2DVIEWER
48 #include <SPlot2d_Histogram.h>
51 #include <vtkProperty.h>
52 #include <vtkTimeStamp.h>
53 #include <vtkObjectFactory.h>
54 #include <vtkShrinkPolyData.h>
55 #include <vtkMergeFilter.h>
57 #include <vtkMatrix4x4.h>
58 #include <vtkUnstructuredGrid.h>
59 #include <vtkPointData.h>
60 #include <vtkCellData.h>
62 #include <vtkMapper.h>
63 #include <vtkRenderer.h>
66 #include <vtkIdList.h>
67 #include <vtkIntArray.h>
69 #include <vtkActor2D.h>
70 #include <vtkProperty2D.h>
71 #include <vtkPolyData.h>
72 #include <vtkTextProperty.h>
74 #include <vtkLookupTable.h>
78 #include <vtkImplicitBoolean.h>
79 #include <vtkImplicitFunctionCollection.h>
81 #include <vtkConfigure.h>
82 #if !defined(VTK_XVERSION)
83 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
86 #include "utilities.h"
89 static int MYDEBUG = 1;
91 static int MYDEBUG = 1;
94 static int aLineWidthInc = 2;
97 SMESH_ActorDef* SMESH_ActorDef::New(){
98 return new SMESH_ActorDef();
102 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
103 const char* theEntry,
107 SMESH_ActorDef* anActor = NULL;
108 if(theVisualObj->IsValid() ) {
109 anActor = SMESH_ActorDef::New();
110 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
115 anActor->UpdateScalarBar();
121 SMESH_ActorDef::SMESH_ActorDef()
123 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
124 myBaseActor = SMESH_DeviceActor::New();
126 myTimeStamp = vtkTimeStamp::New();
128 myIsPointsVisible = false;
129 myIsEntityModeCache = false;
131 myHighlightActor = SMESH_SVTKActor::New();
132 myHighlightActor->Initialize();
134 myPreHighlightActor = SMESH_SVTKActor::New();
135 myPreHighlightActor->Initialize();
137 myIsShrinkable = false;
140 myIsFacesOriented = false;
142 myControlsPrecision = -1;
143 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
145 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
146 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
148 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
149 vtkFloatingPointType aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
150 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
152 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
153 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
155 //Definition 2D and 3D devices of the actor
156 //-----------------------------------------
157 vtkFloatingPointType anRGB[3] = {1,1,1};
158 mySurfaceProp = vtkProperty::New();
161 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
162 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
163 myDeltaBrightness = delta;
165 myBackSurfaceProp = vtkProperty::New();
166 bfc = Qtx::mainColorToSecondary(ffc, delta);
167 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
169 my2DActor = SMESH_CellLabelActor::New();
170 my2DActor->SetStoreGemetryMapping(true);
171 my2DActor->SetUserMatrix(aMatrix);
172 my2DActor->PickableOff();
173 my2DActor->SetProperty(mySurfaceProp);
174 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
175 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
176 aFilter = my2DActor->GetExtractUnstructuredGrid();
177 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
178 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
179 aFilter->RegisterCellsWithType(VTK_POLYGON);
180 aFilter->RegisterCellsWithType(VTK_QUAD);
181 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
182 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
183 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
185 my2DExtProp = vtkProperty::New();
186 my2DExtProp->DeepCopy(mySurfaceProp);
187 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
188 anRGB[0] = 1 - anRGB[0];
189 anRGB[1] = 1 - anRGB[1];
190 anRGB[2] = 1 - anRGB[2];
191 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
193 my2DExtActor = SMESH_DeviceActor::New();
194 my2DExtActor->SetUserMatrix(aMatrix);
195 my2DExtActor->PickableOff();
196 my2DExtActor->SetProperty(my2DExtProp);
197 my2DExtActor->SetBackfaceProperty(my2DExtProp);
198 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
199 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
200 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
201 aFilter->RegisterCellsWithType(VTK_POLYGON);
202 aFilter->RegisterCellsWithType(VTK_QUAD);
203 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
204 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
205 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
207 my3DActor = SMESH_CellLabelActor::New();
208 my3DActor->SetStoreGemetryMapping(true);
209 my3DActor->SetUserMatrix(aMatrix);
210 my3DActor->PickableOff();
211 my3DActor->SetProperty(mySurfaceProp);
212 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
213 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
214 my3DActor->SetCoincident3DAllowed(true);
215 aFilter = my3DActor->GetExtractUnstructuredGrid();
216 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
217 aFilter->RegisterCellsWithType(VTK_TETRA);
218 aFilter->RegisterCellsWithType(VTK_VOXEL);
219 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
220 aFilter->RegisterCellsWithType(VTK_WEDGE);
221 aFilter->RegisterCellsWithType(VTK_PYRAMID);
222 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
223 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
224 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
225 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
226 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
227 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
228 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
229 //#ifdef VTK_HAVE_POLYHEDRON
230 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
231 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
234 my3DExtActor = SMESH_DeviceActor::New();
235 my3DExtActor->SetUserMatrix(aMatrix);
236 my3DExtActor->PickableOff();
237 my3DExtActor->SetProperty(my2DExtProp);
238 my3DExtActor->SetBackfaceProperty(my2DExtProp);
239 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
240 my3DExtActor->SetCoincident3DAllowed(true);
241 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
242 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
243 aFilter->RegisterCellsWithType(VTK_TETRA);
244 aFilter->RegisterCellsWithType(VTK_VOXEL);
245 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
246 aFilter->RegisterCellsWithType(VTK_WEDGE);
247 aFilter->RegisterCellsWithType(VTK_PYRAMID);
248 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
249 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
250 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
251 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
252 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
253 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
254 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
255 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
257 //Definition 1D device of the actor
258 //---------------------------------
259 myEdgeProp = vtkProperty::New();
260 myEdgeProp->SetAmbient(1.0);
261 myEdgeProp->SetDiffuse(0.0);
262 myEdgeProp->SetSpecular(0.0);
263 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
264 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
265 myEdgeProp->SetLineWidth(aLineWidth);
267 my1DActor = SMESH_CellLabelActor::New();
268 my1DActor->SetStoreGemetryMapping(true);
269 my1DActor->SetUserMatrix(aMatrix);
270 my1DActor->PickableOff();
271 my1DActor->SetHighlited(true);
272 my1DActor->SetProperty(myEdgeProp);
273 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
274 aFilter = my1DActor->GetExtractUnstructuredGrid();
275 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
276 aFilter->RegisterCellsWithType(VTK_LINE);
277 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
279 my1DProp = vtkProperty::New();
280 my1DProp->DeepCopy(myEdgeProp);
281 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
282 my1DProp->SetPointSize(aElem0DSize);
284 my1DExtProp = vtkProperty::New();
285 my1DExtProp->DeepCopy(myEdgeProp);
286 anRGB[0] = 1 - anRGB[0];
287 anRGB[1] = 1 - anRGB[1];
288 anRGB[2] = 1 - anRGB[2];
289 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
290 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
291 my1DExtProp->SetPointSize(aElem0DSize);
293 my1DExtActor = SMESH_DeviceActor::New();
294 my1DExtActor->SetUserMatrix(aMatrix);
295 my1DExtActor->PickableOff();
296 my1DExtActor->SetHighlited(true);
297 my1DExtActor->SetVisibility(false);
298 my1DExtActor->SetProperty(my1DExtProp);
299 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
300 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
301 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
302 aFilter->RegisterCellsWithType(VTK_LINE);
303 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
306 //Definition 0D device of the actor (0d elements)
307 //-----------------------------------------------
308 my0DProp = vtkProperty::New();
309 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
310 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
311 my0DProp->SetPointSize(aElem0DSize);
313 my0DActor = SMESH_CellLabelActor::New();
314 my0DActor->SetUserMatrix(aMatrix);
315 my0DActor->SetStoreGemetryMapping(true);
316 my0DActor->PickableOff();
317 my0DActor->SetVisibility(false);
318 my0DActor->SetProperty(my0DProp);
319 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
320 aFilter = my0DActor->GetExtractUnstructuredGrid();
321 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
322 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
323 aFilter->RegisterCellsWithType(VTK_VERTEX);
325 //Definition 0D device of the actor (ball elements)
326 //-----------------------------------------------
327 myBallProp = vtkProperty::New();
328 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
329 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
330 myBallProp->SetPointSize(aBallElemSize);
332 myBallActor = SMESH_CellLabelActor::New();
333 myBallActor->SetUserMatrix(aMatrix);
334 myBallActor->SetStoreGemetryMapping(true);
335 myBallActor->PickableOff();
336 myBallActor->SetVisibility(false);
337 myBallActor->SetProperty(myBallProp);
338 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
339 aFilter = myBallActor->GetExtractUnstructuredGrid();
340 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
341 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
343 //my0DExtProp = vtkProperty::New();
344 //my0DExtProp->DeepCopy(my0DProp);
345 //anRGB[0] = 1 - anRGB[0];
346 //anRGB[1] = 1 - anRGB[1];
347 //anRGB[2] = 1 - anRGB[2];
348 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
349 //my0DExtProp->SetPointSize(aElem0DSize);
351 //my0DExtActor = SMESH_DeviceActor::New();
352 //my0DExtActor->SetUserMatrix(aMatrix);
353 //my0DExtActor->SetStoreClippingMapping(true);
354 //my0DExtActor->PickableOff();
355 //my0DExtActor->SetHighlited(true);
356 //my0DExtActor->SetVisibility(false);
357 //my0DExtActor->SetProperty(my0DExtProp);
358 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
359 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
360 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
361 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
362 //aFilter->RegisterCellsWithType(VTK_VERTEX);
365 //Definition 0D device of the actor (nodes)
366 //-----------------------------------------
367 myNodeProp = vtkProperty::New();
368 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
369 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
371 myNodeActor = SMESH_NodeLabelActor::New();
372 myNodeActor->SetUserMatrix(aMatrix);
373 myNodeActor->SetStoreClippingMapping(true);
374 myNodeActor->PickableOff();
375 myNodeActor->SetVisibility(false);
376 myNodeActor->SetProperty(myNodeProp);
377 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
378 aFilter = myNodeActor->GetExtractUnstructuredGrid();
379 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
381 myNodeExtProp = vtkProperty::New();
382 myNodeExtProp->DeepCopy(myNodeProp);
383 anRGB[0] = 1 - anRGB[0];
384 anRGB[1] = 1 - anRGB[1];
385 anRGB[2] = 1 - anRGB[2];
386 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
388 myNodeExtActor = SMESH_DeviceActor::New();
389 myNodeExtActor->SetUserMatrix(aMatrix);
390 myNodeExtActor->SetStoreClippingMapping(true);
391 myNodeExtActor->PickableOff();
392 myNodeExtActor->SetHighlited(true);
393 myNodeExtActor->SetVisibility(false);
394 myNodeExtActor->SetProperty(myNodeExtProp);
395 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
396 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
397 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
398 aFilter->RegisterCellsWithType(VTK_VERTEX);
400 //Definition of Pickable and Highlitable engines
401 //----------------------------------------------
403 myBaseActor->SetUserMatrix(aMatrix);
404 myBaseActor->SetStoreGemetryMapping(true);
405 myBaseActor->GetProperty()->SetOpacity(0.0);
406 myPickableActor = myBaseActor;
408 myHighlightProp = vtkProperty::New();
409 myHighlightProp->SetAmbient(1.0);
410 myHighlightProp->SetDiffuse(0.0);
411 myHighlightProp->SetSpecular(0.0);
412 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
413 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
414 myHighlightProp->SetPointSize(aElem0DSize); // ??
415 myHighlightProp->SetLineWidth(aLineWidth);
416 myHighlightProp->SetRepresentation(1);
418 myBallHighlightProp = vtkProperty::New();
419 myBallHighlightProp->DeepCopy(myHighlightProp);
420 myBallHighlightProp->SetPointSize(aBallElemSize);
423 myOutLineProp = vtkProperty::New();
424 myOutLineProp->SetAmbient(1.0);
425 myOutLineProp->SetDiffuse(0.0);
426 myOutLineProp->SetSpecular(0.0);
427 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
428 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
429 myOutLineProp->SetLineWidth(aLineWidth);
430 myOutLineProp->SetRepresentation(1);
432 myPreselectProp = vtkProperty::New();
433 myPreselectProp->SetAmbient(1.0);
434 myPreselectProp->SetDiffuse(0.0);
435 myPreselectProp->SetSpecular(0.0);
436 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
437 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
438 myPreselectProp->SetPointSize(aElem0DSize); // ??
439 myPreselectProp->SetLineWidth(aLineWidth);
440 myPreselectProp->SetRepresentation(1);
442 myBallPreselectProp = vtkProperty::New();
443 myBallPreselectProp->DeepCopy(myPreselectProp);
444 myBallPreselectProp->SetPointSize(aBallElemSize);
446 myHighlitableActor = SMESH_DeviceActor::New();
447 myHighlitableActor->SetUserMatrix(aMatrix);
448 myHighlitableActor->PickableOff();
449 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
450 myHighlitableActor->SetCoincident3DAllowed(true);
457 myControlMode = eNone;
458 myControlActor = my2DActor;
460 //Definition of myScalarBarActor
461 //------------------------------
462 myLookupTable = vtkLookupTable::New();
463 //Fix for Bug PAL5195 - SMESH764:
464 //Controls - Aspect Ratio: incorrect colors of the best and worst values
465 myLookupTable->SetHueRange(0.667,0.0);
467 myScalarBarActor = SMESH_ScalarBarActor::New();
468 myScalarBarActor->SetVisibility(false);
469 myScalarBarActor->SetLookupTable(myLookupTable);
472 //Incorrect "Min value" in Scalar Bar in Mesh:
473 // myScalarBarActor->SetLabelFormat("%.4g");
474 // changes was commented because of regression bug IPAL 19981
476 mgr = SUIT_Session::session()->resourceMgr();
480 myEntityMode = eAllEntity;
481 myEntityModeCache = eAllEntity;
484 myImplicitBoolean = vtkImplicitBoolean::New();
485 myImplicitBoolean->SetOperationTypeToIntersection();
487 //Quadratic 2D elements representation
488 //-----------------------------------------------------------------------------
489 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
490 if(aQuadratic2DMode == 0){
491 myHighlitableActor->SetQuadraticArcMode(false);
492 my2DActor->SetQuadraticArcMode(false);
493 my1DActor->SetQuadraticArcMode(false);
495 else if(aQuadratic2DMode == 1){
496 myHighlitableActor->SetQuadraticArcMode(true);
497 my2DActor->SetQuadraticArcMode(true);
498 my1DActor->SetQuadraticArcMode(true);
501 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
502 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
503 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
505 // Set colors of the name actor
506 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
507 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
508 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
509 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
511 #ifndef DISABLE_PLOT2DVIEWER
515 SetBallSize(aBallElemSize);
516 Set0DSize(aElem0DSize);
520 SMESH_ActorDef::~SMESH_ActorDef()
522 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
524 #ifndef DISABLE_PLOT2DVIEWER
526 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
527 delete my2dHistogram;
531 myScalarBarActor->Delete();
532 myLookupTable->Delete();
534 mySurfaceProp->Delete();
535 myBackSurfaceProp->Delete();
536 myOutLineProp->Delete();
538 myEdgeProp->Delete();
539 myHighlightProp->Delete();
540 myPreselectProp->Delete();
542 myNodeProp->Delete();
543 myNodeExtProp->Delete();
547 myBallActor->Delete();
549 //my0DExtProp->Delete();
550 //my0DExtActor->Delete();
555 my1DExtProp->Delete();
556 my1DExtActor->Delete();
559 my2DExtProp->Delete();
560 my2DExtActor->Delete();
562 my3DExtActor->Delete();
564 myNodeActor->Delete();
565 myBaseActor->Delete();
567 myNodeExtActor->Delete();
568 myHighlitableActor->Delete();
570 myImplicitBoolean->Delete();
572 myTimeStamp->Delete();
573 myBallHighlightProp->Delete();
574 myBallPreselectProp->Delete();
578 void SMESH_ActorDef::Delete()
580 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
581 // from the actor's destructor) will be thrown before removing the actor's observers,
582 // that is done inside the Superclass::Delete() method but before the destructor itself
583 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
584 // The event is caught by SMESHGUI::ProcessEvents() static method.
585 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
587 Superclass::Delete();
590 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
593 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
594 SetRepresentation(GetRepresentation());
595 myTimeStamp->Modified();
599 bool SMESH_ActorDef::GetPointsLabeled() {
600 return myNodeActor && myNodeActor->GetPointsLabeled();
603 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
606 my3DActor->SetCellsLabeled(theIsCellsLabeled);
609 my2DActor->SetCellsLabeled(theIsCellsLabeled);
612 my1DActor->SetCellsLabeled(theIsCellsLabeled);
615 my0DActor->SetCellsLabeled(theIsCellsLabeled);
618 myBallActor->SetCellsLabeled(theIsCellsLabeled);
620 myTimeStamp->Modified();
624 bool SMESH_ActorDef::GetCellsLabeled() {
627 result = result || my3DActor->GetCellsLabeled();
630 result = result || my2DActor->GetCellsLabeled();
633 result = result || my1DActor->GetCellsLabeled();
636 result = result || my0DActor->GetCellsLabeled();
639 result = result || myBallActor->GetCellsLabeled();
645 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
647 myIsFacesOriented = theIsFacesOriented;
649 my2DActor->SetFacesOriented(theIsFacesOriented);
650 my3DActor->SetFacesOriented(theIsFacesOriented);
652 myTimeStamp->Modified();
655 bool SMESH_ActorDef::GetFacesOriented()
657 return myIsFacesOriented;
660 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
662 my2DActor->SetFacesOrientationColor( theColor );
663 my3DActor->SetFacesOrientationColor( theColor );
666 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
668 my3DActor->GetFacesOrientationColor( theColor );
671 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
673 my2DActor->SetFacesOrientationScale( theScale );
674 my3DActor->SetFacesOrientationScale( theScale );
677 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
679 return my3DActor->GetFacesOrientationScale();
682 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
684 my2DActor->SetFacesOrientation3DVectors( theState );
685 my3DActor->SetFacesOrientation3DVectors( theState );
688 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
690 return my3DActor->GetFacesOrientation3DVectors();
696 SetControlMode(eControl theMode)
698 SetControlMode(theMode,true);
704 SetControlMode(eControl theMode,
705 bool theCheckEntityMode)
707 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
711 myControlMode = eNone;
712 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
714 my0DActor->GetMapper()->SetScalarVisibility(false);
715 my1DActor->GetMapper()->SetScalarVisibility(false);
716 my2DActor->GetMapper()->SetScalarVisibility(false);
717 my3DActor->GetMapper()->SetScalarVisibility(false);
718 myBallActor->GetMapper()->SetScalarVisibility(false);
719 myScalarBarActor->SetVisibility(false);
721 bool anIsScalarVisible = theMode > eNone;
723 if(anIsScalarVisible) {
727 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
728 aControl->SetPrecision( myControlsPrecision );
729 myFunctor.reset( aControl );
730 myControlActor = my1DActor;
735 myFunctor.reset(new SMESH::Controls::Length2D());
736 myControlActor = my2DActor;
740 myFunctor.reset(new SMESH::Controls::FreeBorders());
741 myControlActor = my1DActor;
744 myFunctor.reset(new SMESH::Controls::FreeEdges());
745 myControlActor = my2DActor;
748 myFunctor.reset(new SMESH::Controls::FreeNodes());
749 myControlActor = myNodeActor;
752 myFunctor.reset(new SMESH::Controls::FreeFaces());
753 myControlActor = my2DActor;
755 case eCoincidentNodes:
757 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
758 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
759 cn->SetTolerance( tol );
761 myControlActor = myNodeActor;
764 case eCoincidentElems1D:
765 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
766 myControlActor = my1DActor;
768 case eCoincidentElems2D:
769 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
770 myControlActor = my2DActor;
772 case eCoincidentElems3D:
773 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
774 myControlActor = my3DActor;
776 case eBareBorderFace:
777 myFunctor.reset(new SMESH::Controls::BareBorderFace());
778 myControlActor = my2DActor;
780 case eOverConstrainedFace:
781 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
782 myControlActor = my2DActor;
784 case eMultiConnection:
785 myFunctor.reset(new SMESH::Controls::MultiConnection());
786 myControlActor = my1DActor;
788 case eMultiConnection2D:
789 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
790 myControlActor = my2DActor;
794 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
795 aControl->SetPrecision( myControlsPrecision );
796 myFunctor.reset( aControl );
797 myControlActor = my2DActor;
802 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
803 aControl->SetPrecision( myControlsPrecision );
804 myFunctor.reset( aControl );
805 myControlActor = my2DActor;
810 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
811 aControl->SetPrecision( myControlsPrecision );
812 myFunctor.reset( aControl );
813 myControlActor = my2DActor;
818 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
819 aControl->SetPrecision( myControlsPrecision );
820 myFunctor.reset( aControl );
821 myControlActor = my3DActor;
826 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
827 aControl->SetPrecision( myControlsPrecision );
828 myFunctor.reset( aControl );
829 myControlActor = my3DActor;
832 case eMaxElementLength2D:
834 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
835 aControl->SetPrecision( myControlsPrecision );
836 myFunctor.reset( aControl );
837 myControlActor = my2DActor;
840 case eMaxElementLength3D:
842 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
843 aControl->SetPrecision( myControlsPrecision );
844 myFunctor.reset( aControl );
845 myControlActor = my3DActor;
848 case eBareBorderVolume:
850 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
851 myControlActor = my3DActor;
854 case eOverConstrainedVolume:
856 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
857 myControlActor = my3DActor;
862 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
863 aControl->SetPrecision( myControlsPrecision );
864 myFunctor.reset( aControl );
865 myControlActor = my2DActor;
870 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
871 aControl->SetPrecision( myControlsPrecision );
872 myFunctor.reset( aControl );
873 myControlActor = my2DActor;
878 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
879 aControl->SetPrecision( myControlsPrecision );
880 myFunctor.reset( aControl );
881 myControlActor = my2DActor;
888 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
889 vtkIdType aNbCells = aGrid->GetNumberOfCells();
891 myControlMode = theMode;
892 switch(myControlMode){
894 case eCoincidentNodes:
895 myNodeExtActor->SetExtControlMode(myFunctor);
899 case eCoincidentElems1D:
900 my1DExtActor->SetExtControlMode(myFunctor);
903 case eBareBorderFace:
904 case eOverConstrainedFace:
905 case eCoincidentElems2D:
906 my2DExtActor->SetExtControlMode(myFunctor);
908 case eBareBorderVolume:
909 case eOverConstrainedVolume:
910 case eCoincidentElems3D:
911 my3DExtActor->SetExtControlMode(myFunctor);
914 case eMultiConnection2D:
915 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
916 UpdateDistribution();
919 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
920 UpdateDistribution();
924 if(theCheckEntityMode) {
925 if(myControlActor == my1DActor) {
926 if (!myIsEntityModeCache){
927 myEntityModeCache = GetEntityMode();
928 myIsEntityModeCache=true;
930 SetEntityMode(eEdges);
932 else if(myControlActor == my2DActor) {
933 switch(myControlMode) {
937 case eMultiConnection2D:
938 if (!myIsEntityModeCache){
939 myEntityModeCache = GetEntityMode();
940 myIsEntityModeCache=true;
942 SetEntityMode(eFaces);
945 if (!myIsEntityModeCache){
946 myEntityModeCache = GetEntityMode();
947 myIsEntityModeCache=true;
949 SetEntityMode(eFaces);
951 }else if(myControlActor == my3DActor) {
952 if (!myIsEntityModeCache){
953 myEntityModeCache = GetEntityMode();
954 myIsEntityModeCache=true;
956 SetEntityMode(eVolumes);
962 if(theCheckEntityMode){
963 myEntityMode = myEntityModeCache;
964 myIsEntityModeCache = false;
969 SetRepresentation(GetRepresentation());
971 myTimeStamp->Modified();
977 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
979 //myHighlightActor->AddToRender(theRenderer);
981 theRenderer->AddActor(myBaseActor);
982 theRenderer->AddActor(myNodeExtActor);
983 theRenderer->AddActor(my1DExtActor);
985 my3DActor ->AddToRender(theRenderer);
986 my3DExtActor->AddToRender(theRenderer);
987 my2DActor ->AddToRender(theRenderer);
988 my2DExtActor->AddToRender(theRenderer);
989 myNodeActor ->AddToRender(theRenderer);
990 my1DActor ->AddToRender(theRenderer);
991 my0DActor ->AddToRender(theRenderer);
992 myBallActor ->AddToRender(theRenderer);
993 //theRenderer->AddActor(my0DExtActor);
995 theRenderer->AddActor(myHighlitableActor);
997 theRenderer->AddActor2D(myScalarBarActor);
999 // the superclass' method should be called at the end
1000 // (in particular, for correct work of selection)
1001 SALOME_Actor::AddToRender(theRenderer);
1004 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1005 SALOME_Actor::RemoveFromRender(theRenderer);
1007 theRenderer->RemoveActor(myBaseActor);
1009 theRenderer->RemoveActor(myNodeExtActor);
1011 theRenderer->RemoveActor(myHighlitableActor);
1013 //theRenderer->RemoveActor(my0DExtActor);
1015 theRenderer->RemoveActor(my1DExtActor);
1017 my2DActor->RemoveFromRender(theRenderer);
1018 my2DExtActor->RemoveFromRender(theRenderer);
1019 my3DActor->RemoveFromRender(theRenderer);
1020 my3DExtActor->RemoveFromRender(theRenderer);
1021 myNodeActor->RemoveFromRender(theRenderer);
1022 my0DActor->RemoveFromRender(theRenderer);
1023 myBallActor->RemoveFromRender(theRenderer);
1024 my1DActor->RemoveFromRender(theRenderer);
1026 theRenderer->RemoveActor(myScalarBarActor);
1030 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1031 const char* theEntry,
1032 const char* theName,
1035 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1039 myVisualObj = theVisualObj;
1040 myVisualObj->Update(theIsClear);
1042 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1043 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1045 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1047 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1049 my0DActor->Init(myVisualObj,myImplicitBoolean);
1050 myBallActor->Init(myVisualObj,myImplicitBoolean);
1051 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1053 my1DActor->Init(myVisualObj,myImplicitBoolean);
1054 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1056 my2DActor->Init(myVisualObj,myImplicitBoolean);
1057 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1058 my3DActor->Init(myVisualObj,myImplicitBoolean);
1059 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1061 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1062 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1063 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1065 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1066 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1068 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1069 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1070 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1071 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1073 vtkFloatingPointType aFactor, aUnits;
1074 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1075 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1076 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1078 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1082 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1083 SetIsShrunkable(true);
1085 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1087 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1088 SetRepresentation(-1);
1091 SetRepresentation(eEdge);
1092 }else if(aMode == 1){
1093 SetRepresentation(eSurface);
1094 }else if(aMode == 2){
1095 SetRepresentation(ePoint);
1102 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1103 SetIsDisplayNameActor( true );
1105 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1106 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1107 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1109 myTimeStamp->Modified();
1115 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1116 return myNodeActor->GetBounds();
1120 vtkDataSet* SMESH_ActorDef::GetInput(){
1121 return GetUnstructuredGrid();
1125 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1126 Superclass::SetTransform(theTransform);
1128 myNodeActor->SetTransform(theTransform);
1129 myBaseActor->SetTransform(theTransform);
1131 myHighlitableActor->SetTransform(theTransform);
1133 myNodeExtActor->SetTransform(theTransform);
1135 my0DActor->SetTransform(theTransform);
1136 myBallActor->SetTransform(theTransform);
1137 //my0DExtActor->SetTransform(theTransform);
1139 my1DActor->SetTransform(theTransform);
1140 my1DExtActor->SetTransform(theTransform);
1142 my2DActor->SetTransform(theTransform);
1143 my2DExtActor->SetTransform(theTransform);
1144 my3DActor->SetTransform(theTransform);
1145 my3DExtActor->SetTransform(theTransform);
1151 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1152 vtkLODActor::SetMapper(theMapper);
1156 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1157 SALOME_Actor::ShallowCopy(prop);
1161 vtkMapper* SMESH_ActorDef::GetMapper(){
1162 return myPickableActor->GetMapper();
1166 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1167 return myVisualObj->GetUnstructuredGrid();
1171 bool SMESH_ActorDef::IsInfinitive(){
1172 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1174 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1175 ( aDataSet->GetNumberOfCells() == 1 &&
1176 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1177 return SALOME_Actor::IsInfinitive();
1181 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1182 if ( myIsShrinkable == theShrunkable )
1184 myIsShrinkable = theShrunkable;
1188 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1189 return myBaseActor->GetShrinkFactor();
1192 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1193 myBaseActor->SetShrinkFactor(theValue);
1195 my1DActor->SetShrinkFactor(theValue);
1196 my1DExtActor->SetShrinkFactor(theValue);
1198 my2DActor->SetShrinkFactor(theValue);
1199 my2DExtActor->SetShrinkFactor(theValue);
1200 my3DActor->SetShrinkFactor(theValue);
1201 my3DExtActor->SetShrinkFactor(theValue);
1202 my3DExtActor->SetShrinkFactor(theValue);
1203 myHighlitableActor->SetShrinkFactor(theValue);
1208 void SMESH_ActorDef::SetShrink(){
1209 if(!myIsShrinkable) return;
1211 myBaseActor->SetShrink();
1213 my1DActor->SetShrink();
1214 my1DExtActor->SetShrink();
1216 my2DActor->SetShrink();
1217 my2DExtActor->SetShrink();
1218 my3DActor->SetShrink();
1219 my3DExtActor->SetShrink();
1220 myHighlitableActor->SetShrink();
1226 void SMESH_ActorDef::UnShrink(){
1227 if(!myIsShrunk) return;
1229 myBaseActor->UnShrink();
1231 my1DActor->UnShrink();
1232 my1DExtActor->UnShrink();
1234 my2DActor->UnShrink();
1235 my2DExtActor->UnShrink();
1236 my3DActor->UnShrink();
1237 my3DExtActor->UnShrink();
1238 myHighlitableActor->UnShrink();
1245 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1246 return myPickableActor->GetNodeObjId(theVtkID);
1249 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1250 return myPickableActor->GetNodeCoord(theObjID);
1254 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1255 return myPickableActor->GetElemObjId(theVtkID);
1258 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1259 return myPickableActor->GetElemCell(theObjID);
1263 void SMESH_ActorDef::SetVisibility(int theMode){
1264 SetVisibility(theMode,true);
1268 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1269 SALOME_Actor::SetVisibility(theMode);
1271 myNodeActor->VisibilityOff();
1272 myBaseActor->VisibilityOff();
1274 myNodeExtActor->VisibilityOff();
1276 my0DActor->VisibilityOff();
1277 myBallActor->VisibilityOff();
1278 //my0DExtActor->VisibilityOff();
1280 my1DActor->VisibilityOff();
1281 my1DExtActor->VisibilityOff();
1283 my2DActor->VisibilityOff();
1284 my2DExtActor->VisibilityOff();
1285 my3DActor->VisibilityOff();
1286 my3DExtActor->VisibilityOff();
1288 myScalarBarActor->VisibilityOff();
1290 if(GetVisibility()){
1291 if(theIsUpdateRepersentation)
1292 SetRepresentation(GetRepresentation());
1294 if(myControlMode != eNone){
1295 switch(myControlMode){
1297 case eCoincidentNodes:
1298 myNodeExtActor->VisibilityOn();
1302 case eCoincidentElems1D:
1303 my1DExtActor->VisibilityOn();
1306 case eBareBorderFace:
1307 case eOverConstrainedFace:
1308 case eCoincidentElems2D:
1309 my2DExtActor->VisibilityOn();
1311 case eBareBorderVolume:
1312 case eOverConstrainedVolume:
1313 case eCoincidentElems3D:
1314 my3DExtActor->VisibilityOn();
1317 case eMultiConnection2D:
1318 my1DExtActor->VisibilityOn();
1320 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1321 myScalarBarActor->VisibilityOn();
1325 if(myRepresentation != ePoint)
1326 myPickableActor->VisibilityOn();
1328 myNodeActor->VisibilityOn();
1331 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1332 my0DActor->VisibilityOn();
1334 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1335 myBallActor->VisibilityOn();
1338 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1339 my1DActor->VisibilityOn();
1342 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1343 my2DActor->VisibilityOn();
1346 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1347 my3DActor->VisibilityOn();
1350 if(myNodeActor->GetPointsLabeled()){
1351 myNodeActor->VisibilityOn();
1355 my0DActor->UpdateLabels();
1358 myBallActor->UpdateLabels();
1361 my1DActor->UpdateLabels();
1364 my2DActor->UpdateLabels();
1367 my3DActor->UpdateLabels();
1369 #ifndef DISABLE_PLOT2DVIEWER
1371 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1378 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1380 myEntityState = eAllEntity;
1382 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1383 myEntityState &= ~e0DElements;
1384 theMode &= ~e0DElements;
1387 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1388 myEntityState &= ~eBallElem;
1389 theMode &= ~eBallElem;
1392 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1393 myEntityState &= ~eEdges;
1397 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1398 myEntityState &= ~eFaces;
1402 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1403 myEntityState &= ~eVolumes;
1404 theMode &= ~eVolumes;
1408 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1409 theMode |= e0DElements;
1411 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1412 theMode |= eBallElem;
1414 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1417 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1420 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1421 theMode |= eVolumes;
1424 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1426 myEntityMode = theMode;
1427 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1428 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1429 aFilter->ClearRegisteredCellsWithType();
1430 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1432 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1433 aHightFilter->ClearRegisteredCellsWithType();
1434 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1436 if (myEntityMode & e0DElements) {
1437 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1438 aFilter->RegisterCellsWithType(VTK_VERTEX);
1439 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1442 if (myEntityMode & eBallElem) {
1443 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1444 aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1447 if (myEntityMode & eEdges) {
1448 if (MYDEBUG) MESSAGE("EDGES");
1449 aFilter->RegisterCellsWithType(VTK_LINE);
1450 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1452 aHightFilter->RegisterCellsWithType(VTK_LINE);
1453 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1456 if (myEntityMode & eFaces) {
1457 if (MYDEBUG) MESSAGE("FACES");
1458 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1459 aFilter->RegisterCellsWithType(VTK_POLYGON);
1460 aFilter->RegisterCellsWithType(VTK_QUAD);
1461 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1462 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1463 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1465 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1466 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1467 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1468 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1469 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1470 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1473 if (myEntityMode & eVolumes) {
1474 if (MYDEBUG) MESSAGE("VOLUMES");
1475 aFilter->RegisterCellsWithType(VTK_TETRA);
1476 aFilter->RegisterCellsWithType(VTK_VOXEL);
1477 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1478 aFilter->RegisterCellsWithType(VTK_WEDGE);
1479 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1480 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1481 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1482 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1483 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1484 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1485 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1486 //#ifdef VTK_HAVE_POLYHEDRON
1487 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1490 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1491 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1492 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1493 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1494 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1495 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1496 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1497 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1498 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1499 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1500 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1501 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1502 //#ifdef VTK_HAVE_POLYHEDRON
1503 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1507 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1508 SetVisibility(GetVisibility(),false);
1511 void SMESH_ActorDef::SetRepresentation (int theMode)
1513 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1514 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1515 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1516 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1517 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1520 myRepresentation = eSurface;
1521 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1522 myRepresentation = eEdge;
1523 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1524 myRepresentation = ePoint;
1529 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1532 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1535 myRepresentation = theMode;
1538 if (!GetUnstructuredGrid()->GetNumberOfCells())
1539 myRepresentation = ePoint;
1542 if (myRepresentation == ePoint) {
1550 myPickableActor = myBaseActor;
1551 myNodeActor->SetVisibility(false);
1552 myNodeExtActor->SetVisibility(false);
1553 vtkProperty *aProp = NULL, *aBackProp = NULL;
1554 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1555 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1556 switch (myRepresentation) {
1558 myPickableActor = myNodeActor;
1559 myNodeActor->SetVisibility(true);
1560 aQuadraticMode = SMESH_Actor::eLines;
1561 aProp = aBackProp = myNodeProp;
1562 aReperesent = SMESH_DeviceActor::ePoint;
1565 aProp = aBackProp = myEdgeProp;
1566 aReperesent = SMESH_DeviceActor::eInsideframe;
1569 aProp = mySurfaceProp;
1570 aBackProp = myBackSurfaceProp;
1571 aReperesent = SMESH_DeviceActor::eSurface;
1575 my2DActor->SetProperty(aProp);
1576 my2DActor->SetBackfaceProperty(aBackProp);
1577 my2DActor->SetRepresentation(aReperesent);
1579 if(aQuadraticMode == SMESH_Actor::eLines)
1580 my2DActor->SetQuadraticArcMode(false);
1581 else if(aQuadraticMode == SMESH_Actor::eArcs)
1582 my2DActor->SetQuadraticArcMode(true);
1584 my2DExtActor->SetRepresentation(aReperesent);
1586 my3DActor->SetProperty(aProp);
1587 my3DActor->SetBackfaceProperty(aBackProp);
1588 my3DActor->SetRepresentation(aReperesent);
1590 //my0DExtActor->SetVisibility(false);
1591 my1DExtActor->SetVisibility(false);
1592 my2DExtActor->SetVisibility(false);
1593 my3DExtActor->SetVisibility(false);
1596 //my0DActor->SetProperty(aProp);
1597 //my0DActor->SetBackfaceProperty(aBackProp);
1598 my0DActor->SetRepresentation(aReperesent);
1599 myBallActor->SetRepresentation(aReperesent);
1600 //my0DExtActor->SetRepresentation(aReperesent);
1602 switch(myControlMode){
1604 case eMultiConnection:
1605 aProp = aBackProp = my1DProp;
1606 if(myRepresentation != ePoint)
1607 aReperesent = SMESH_DeviceActor::eInsideframe;
1611 if(aQuadraticMode == SMESH_Actor::eLines)
1612 my1DActor->SetQuadraticArcMode(false);
1613 else if(aQuadraticMode == SMESH_Actor::eArcs)
1614 my1DActor->SetQuadraticArcMode(true);
1616 my1DActor->SetProperty(aProp);
1617 my1DActor->SetBackfaceProperty(aBackProp);
1618 my1DActor->SetRepresentation(aReperesent);
1620 my1DExtActor->SetRepresentation(aReperesent);
1622 if(myIsPointsVisible)
1623 myPickableActor = myNodeActor;
1624 if(GetPointRepresentation())
1625 myNodeActor->SetVisibility(true);
1627 SetMapper(myPickableActor->GetMapper());
1629 SetVisibility(GetVisibility(),false);
1635 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1636 if ( myIsPointsVisible == theIsPointsVisible )
1638 myIsPointsVisible = theIsPointsVisible;
1639 SetRepresentation(GetRepresentation());
1642 bool SMESH_ActorDef::GetPointRepresentation(){
1643 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1647 void SMESH_ActorDef::UpdateHighlight(){
1648 myHighlitableActor->SetHighlited(false);
1649 myHighlitableActor->SetVisibility(false);
1651 bool anIsVisible = GetVisibility();
1653 switch(myRepresentation){
1654 case SMESH_DeviceActor::eSurface:
1655 case SMESH_DeviceActor::eWireframe:
1657 if(myIsHighlighted) {
1658 myHighlitableActor->SetProperty(myHighlightProp);
1659 myBallActor->SetProperty(myBallHighlightProp);
1660 }else if(myIsPreselected){
1661 myHighlitableActor->SetProperty(myPreselectProp);
1662 myBallActor->SetProperty(myBallPreselectProp);
1663 } else if(anIsVisible){
1664 myBallActor->SetProperty(myBallProp);
1665 (myRepresentation == eSurface) ?
1666 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1668 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1669 myHighlitableActor->SetHighlited(anIsVisible);
1670 myHighlitableActor->GetExtractUnstructuredGrid()->
1671 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1672 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1674 myHighlitableActor->SetVisibility(anIsVisible);
1677 case SMESH_DeviceActor::ePoint:
1679 if(myIsHighlighted) {
1680 myNodeActor->SetProperty(myHighlightProp);
1681 }else if(myIsPreselected) {
1682 myNodeActor->SetProperty(myPreselectProp);
1683 } else if(anIsVisible) {
1684 myNodeActor->SetProperty(myNodeProp);
1686 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1687 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1694 void SMESH_ActorDef::highlight(bool theHighlight){
1695 if ( myIsHighlighted == theHighlight )
1697 myIsHighlighted = theHighlight;
1702 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1703 if ( myIsPreselected == thePreselect )
1705 myIsPreselected = thePreselect;
1711 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1713 if (myPickableActor->GetIsOpaque())
1715 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1723 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1725 if (!myPickableActor->GetIsOpaque())
1727 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1735 void SMESH_ActorDef::Render(vtkRenderer *ren){
1736 unsigned long aTime = myTimeStamp->GetMTime();
1737 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1738 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1739 if(anObjTime > aTime || aClippingTime > aTime)
1744 void SMESH_ActorDef::Update(){
1745 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1747 if(GetControlMode() != eNone) {
1748 unsigned long aTime = myTimeStamp->GetMTime();
1749 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1750 if (anObjTime > aTime)
1751 SetControlMode(GetControlMode(),false);
1755 myNodeActor->UpdateLabels();
1758 my0DActor->UpdateLabels();
1761 myBallActor->UpdateLabels();
1764 my1DActor->UpdateLabels();
1767 my2DActor->UpdateLabels();
1770 my3DActor->UpdateLabels();
1772 if(myIsFacesOriented){
1773 SetFacesOriented(myIsFacesOriented);
1776 if(myVisualObj->GetEntitiesFlag()) {
1777 myEntityMode |= myVisualObj->GetEntitiesState();
1780 SetEntityMode(GetEntityMode());
1781 SetVisibility(GetVisibility());
1783 myTimeStamp->Modified();
1788 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1789 SALOME_Actor::ReleaseGraphicsResources(renWin);
1791 myPickableActor->ReleaseGraphicsResources(renWin);
1795 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1796 vtkFloatingPointType* aColor = theProperty->GetColor();
1803 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1804 mySurfaceProp->SetOpacity(theValue);
1805 myBackSurfaceProp->SetOpacity(theValue);
1806 myEdgeProp->SetOpacity(theValue);
1807 myNodeProp->SetOpacity(theValue);
1809 my1DProp->SetOpacity(theValue);
1810 my0DProp->SetOpacity(theValue);
1811 myBallProp->SetOpacity(theValue);
1815 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1816 return mySurfaceProp->GetOpacity();
1820 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1821 mySurfaceProp->SetColor(r,g,b);
1822 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1823 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1824 aGroupObj->GetElementType() == SMDSAbs_Volume )
1825 myNameActor->SetBackgroundColor(r,g,b);
1827 myDeltaBrightness = delta;
1828 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1829 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1833 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1834 ::GetColor(mySurfaceProp,r,g,b);
1835 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1836 delta = myDeltaBrightness;
1839 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1840 myEdgeProp->SetColor(r,g,b);
1841 my1DProp->SetColor(r,g,b);
1842 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1843 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1844 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1845 myNameActor->SetBackgroundColor(r,g,b);
1849 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1850 ::GetColor(myEdgeProp,r,g,b);
1853 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1854 myOutLineProp->SetColor(r,g,b);
1858 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1859 ::GetColor(myOutLineProp,r,g,b);
1863 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1864 myNodeProp->SetColor(r,g,b);
1865 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1866 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1867 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1868 myNameActor->SetBackgroundColor(r,g,b);
1872 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1873 ::GetColor(myNodeProp,r,g,b);
1876 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1877 my0DProp->SetColor(r,g,b);
1878 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1879 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1880 myNameActor->SetBackgroundColor(r,g,b);
1884 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1885 ::GetColor(my0DProp,r,g,b);
1888 void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1889 myBallProp->SetColor(r,g,b);
1890 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1891 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
1892 myNameActor->SetBackgroundColor(r,g,b);
1896 void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1897 ::GetColor(myBallProp,r,g,b);
1900 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1901 myHighlightProp->SetColor(r,g,b);
1902 myBallHighlightProp->SetColor(r,g,b);
1906 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1907 ::GetColor(myHighlightProp,r,g,b);
1910 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1911 myPreselectProp->SetColor(r,g,b);
1912 myBallPreselectProp->SetColor(r,g,b);
1916 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1917 ::GetColor(myPreselectProp,r,g,b);
1921 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1922 return myEdgeProp->GetLineWidth();
1926 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1927 myEdgeProp->SetLineWidth(theVal);
1929 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1930 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1931 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
1932 myOutLineProp->SetLineWidth(theVal);
1933 myHighlightProp->SetLineWidth(theVal);
1934 myPreselectProp->SetLineWidth(theVal);
1939 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1940 my0DProp->SetPointSize(theVal);
1941 myHighlightProp->SetPointSize(theVal);
1942 myPreselectProp->SetPointSize(theVal);
1944 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
1945 aCustom->Set0DSize(theVal);
1947 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
1948 aCustom->Set0DSize(theVal);
1954 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1955 return my0DProp->GetPointSize();
1958 void SMESH_ActorDef::SetBallSize(vtkFloatingPointType theVal){
1959 myBallProp->SetPointSize(theVal);
1960 myBallHighlightProp->SetPointSize(theVal);
1961 myBallPreselectProp->SetPointSize(theVal);
1962 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
1963 aCustom->SetBallSize(theVal);
1965 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
1966 aCustom->SetBallSize(theVal);
1972 vtkFloatingPointType SMESH_ActorDef::GetBallSize(){
1973 return myBallProp->GetPointSize();
1976 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1978 return myVisualObj->GetElemDimension( theObjId );
1983 IsImplicitFunctionUsed() const
1985 return myBaseActor->IsImplicitFunctionUsed();
1989 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1991 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1992 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1994 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1996 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1998 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1999 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2000 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2002 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2003 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2005 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2006 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2007 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2008 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2012 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2015 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2016 myCippingPlaneCont.push_back(thePlane);
2017 if(!IsImplicitFunctionUsed())
2018 SetImplicitFunctionUsed(true);
2019 myNodeActor->UpdateLabels();
2021 return myCippingPlaneCont.size();
2026 RemoveAllClippingPlanes()
2028 myImplicitBoolean->GetFunction()->RemoveAllItems();
2029 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2030 myCippingPlaneCont.clear();
2031 SetImplicitFunctionUsed(false);
2032 myNodeActor->UpdateLabels();
2037 GetNumberOfClippingPlanes()
2039 return myCippingPlaneCont.size();
2044 GetClippingPlane(vtkIdType theID)
2046 if(theID >= myCippingPlaneCont.size())
2048 return myCippingPlaneCont[theID].Get();
2051 void SMESH_ActorDef::UpdateScalarBar()
2053 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2057 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2059 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2060 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2062 aScalarBarTitleProp->SetFontFamilyToArial();
2064 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2066 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2067 if ( f.family() == "Arial" )
2068 aScalarBarTitleProp->SetFontFamilyToArial();
2069 else if ( f.family() == "Courier" )
2070 aScalarBarTitleProp->SetFontFamilyToCourier();
2071 else if ( f.family() == "Times" )
2072 aScalarBarTitleProp->SetFontFamilyToTimes();
2075 aScalarBarTitleProp->BoldOn();
2077 aScalarBarTitleProp->BoldOff();
2080 aScalarBarTitleProp->ItalicOn();
2082 aScalarBarTitleProp->ItalicOff();
2085 aScalarBarTitleProp->ShadowOn();
2087 aScalarBarTitleProp->ShadowOff();
2090 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2091 aScalarBarTitleProp->Delete();
2093 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2095 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2096 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2098 aScalarBarLabelProp->SetFontFamilyToArial();
2099 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2101 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2102 if( f.family() == "Arial" )
2103 aScalarBarLabelProp->SetFontFamilyToArial();
2104 else if( f.family() == "Courier" )
2105 aScalarBarLabelProp->SetFontFamilyToCourier();
2106 else if( f.family() == "Times" )
2107 aScalarBarLabelProp->SetFontFamilyToTimes();
2110 aScalarBarLabelProp->BoldOn();
2112 aScalarBarLabelProp->BoldOff();
2115 aScalarBarLabelProp->ItalicOn();
2117 aScalarBarLabelProp->ItalicOff();
2120 aScalarBarLabelProp->ShadowOn();
2122 aScalarBarLabelProp->ShadowOff();
2125 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2126 aScalarBarLabelProp->Delete();
2128 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2129 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2131 myScalarBarActor->SetOrientationToHorizontal();
2133 myScalarBarActor->SetOrientationToVertical();
2136 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2137 if( mgr->hasValue( "SMESH", name + "x" ) )
2138 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2140 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2141 if( mgr->hasValue( "SMESH", name + "y" ) )
2142 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2143 myScalarBarActor->SetPosition( aXVal, aYVal );
2145 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2146 if( mgr->hasValue( "SMESH", name + "width" ) )
2147 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2148 myScalarBarActor->SetWidth( aWVal );
2150 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2151 if( mgr->hasValue( "SMESH", name + "height" ) )
2152 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2153 myScalarBarActor->SetHeight( aHVal );
2156 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2157 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2158 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2161 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2162 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2163 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2165 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2166 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2168 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2169 myScalarBarActor->SetDistributionColoringType(coloringType);
2171 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2172 QColor(255, 255, 255));
2174 rgb[0]= distributionColor.red()/255.;
2175 rgb[1]= distributionColor.green()/255.;
2176 rgb[2]= distributionColor.blue()/255.;
2177 myScalarBarActor->SetDistributionColor(rgb);
2182 void SMESH_ActorDef::UpdateDistribution()
2184 if(SMESH::Controls::NumericalFunctor* fun =
2185 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2187 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2188 std::vector<int> nbEvents;
2189 std::vector<double> funValues;
2190 SMESH_VisualObjDef::TEntityList elems;
2191 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2192 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2193 std::vector<int> elemIds;
2194 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2195 elemIds.push_back( (*e)->GetID());
2196 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2197 double * range = lookupTable->GetRange();
2198 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2199 myScalarBarActor->SetDistribution(nbEvents);
2203 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2206 case SMESH_Actor::eLines :
2207 myHighlitableActor->SetQuadraticArcMode(false);
2208 my2DActor->SetQuadraticArcMode(false);
2209 my1DActor->SetQuadraticArcMode(false);
2211 case SMESH_Actor::eArcs :
2212 myHighlitableActor->SetQuadraticArcMode(true);
2213 if(GetRepresentation() != SMESH_Actor::ePoint) {
2214 my2DActor->SetQuadraticArcMode(true);
2215 my1DActor->SetQuadraticArcMode(true);
2224 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2226 if(myHighlitableActor->GetQuadraticArcMode())
2227 return SMESH_Actor::eArcs;
2229 return SMESH_Actor::eLines;
2232 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2234 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2235 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2236 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2239 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2241 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2242 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2243 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2244 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2247 #ifndef DISABLE_PLOT2DVIEWER
2248 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2251 my2dHistogram->clearAllPoints();
2253 if(SMESH::Controls::NumericalFunctor* fun =
2254 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2257 if(!my2dHistogram) {
2258 my2dHistogram = new SPlot2d_Histogram();
2259 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2260 my2dHistogram->setIO(anIO);
2263 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2264 std::vector<int> nbEvents;
2265 std::vector<double> funValues;
2266 SMESH_VisualObjDef::TEntityList elems;
2267 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2268 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2269 std::vector<int> elemIds;
2271 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2272 elemIds.push_back( (*e)->GetID());
2274 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2275 double * range = lookupTable->GetRange();
2276 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2278 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2279 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2281 if(funValues.size() >= 2)
2282 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2286 //Color of the histogram
2287 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2288 my2dHistogram->setAutoAssign(true);
2291 myScalarBarActor->GetDistributionColor(rgb);
2292 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2293 my2dHistogram->setColor(aColor);
2297 return my2dHistogram;