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->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 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
151 vtkFloatingPointType aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
152 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
153 vtkFloatingPointType aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
155 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
156 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
158 //Definition 2D and 3D devices of the actor
159 //-----------------------------------------
160 vtkFloatingPointType anRGB[3] = {1,1,1};
161 mySurfaceProp = vtkProperty::New();
164 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
165 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
166 myDeltaBrightness = delta;
168 myBackSurfaceProp = vtkProperty::New();
169 bfc = Qtx::mainColorToSecondary(ffc, delta);
170 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
172 myNormalVProp = vtkProperty::New();
173 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
174 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
175 myDeltaVBrightness = delta;
177 myReversedVProp = vtkProperty::New();
178 bfc = Qtx::mainColorToSecondary(ffc, delta);
179 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
181 my2DActor = SMESH_CellLabelActor::New();
182 my2DActor->SetStoreGemetryMapping(true);
183 my2DActor->SetUserMatrix(aMatrix);
184 my2DActor->PickableOff();
185 my2DActor->SetProperty(mySurfaceProp);
186 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
187 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
188 aFilter = my2DActor->GetExtractUnstructuredGrid();
189 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
190 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
191 aFilter->RegisterCellsWithType(VTK_POLYGON);
192 aFilter->RegisterCellsWithType(VTK_QUAD);
193 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
194 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
195 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
197 my2DExtProp = vtkProperty::New();
198 my2DExtProp->DeepCopy(mySurfaceProp);
199 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
200 anRGB[0] = 1 - anRGB[0];
201 anRGB[1] = 1 - anRGB[1];
202 anRGB[2] = 1 - anRGB[2];
203 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
205 my2DExtActor = SMESH_DeviceActor::New();
206 my2DExtActor->SetUserMatrix(aMatrix);
207 my2DExtActor->PickableOff();
208 my2DExtActor->SetProperty(my2DExtProp);
209 my2DExtActor->SetBackfaceProperty(my2DExtProp);
210 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
211 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
212 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
213 aFilter->RegisterCellsWithType(VTK_POLYGON);
214 aFilter->RegisterCellsWithType(VTK_QUAD);
215 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
216 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
217 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
219 my3DActor = SMESH_CellLabelActor::New();
220 my3DActor->SetStoreGemetryMapping(true);
221 my3DActor->SetUserMatrix(aMatrix);
222 my3DActor->PickableOff();
223 my3DActor->SetProperty(myNormalVProp);
224 my3DActor->SetBackfaceProperty(myReversedVProp);
225 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
226 my3DActor->SetCoincident3DAllowed(true);
227 aFilter = my3DActor->GetExtractUnstructuredGrid();
228 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
229 aFilter->RegisterCellsWithType(VTK_TETRA);
230 aFilter->RegisterCellsWithType(VTK_VOXEL);
231 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
232 aFilter->RegisterCellsWithType(VTK_WEDGE);
233 aFilter->RegisterCellsWithType(VTK_PYRAMID);
234 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
235 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
236 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
237 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
238 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
239 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
240 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
241 //#ifdef VTK_HAVE_POLYHEDRON
242 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
243 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
246 my3DExtProp = vtkProperty::New();
247 my3DExtProp->DeepCopy(myNormalVProp);
248 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
249 anRGB[0] = 1 - anRGB[0];
250 anRGB[1] = 1 - anRGB[1];
251 anRGB[2] = 1 - anRGB[2];
252 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
254 my3DExtActor = SMESH_DeviceActor::New();
255 my3DExtActor->SetUserMatrix(aMatrix);
256 my3DExtActor->PickableOff();
257 my3DExtActor->SetProperty(my3DExtProp);
258 my3DExtActor->SetBackfaceProperty(my3DExtProp);
259 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
260 my3DExtActor->SetCoincident3DAllowed(true);
261 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
262 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
263 aFilter->RegisterCellsWithType(VTK_TETRA);
264 aFilter->RegisterCellsWithType(VTK_VOXEL);
265 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
266 aFilter->RegisterCellsWithType(VTK_WEDGE);
267 aFilter->RegisterCellsWithType(VTK_PYRAMID);
268 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
269 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
270 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
271 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
272 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
273 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
274 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
275 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
277 //Definition 1D device of the actor
278 //---------------------------------
279 myEdgeProp = vtkProperty::New();
280 myEdgeProp->SetAmbient(1.0);
281 myEdgeProp->SetDiffuse(0.0);
282 myEdgeProp->SetSpecular(0.0);
283 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
284 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
285 myEdgeProp->SetLineWidth(aLineWidth);
287 my1DActor = SMESH_CellLabelActor::New();
288 my1DActor->SetStoreGemetryMapping(true);
289 my1DActor->SetUserMatrix(aMatrix);
290 my1DActor->PickableOff();
291 my1DActor->SetHighlited(true);
292 my1DActor->SetProperty(myEdgeProp);
293 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
294 aFilter = my1DActor->GetExtractUnstructuredGrid();
295 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
296 aFilter->RegisterCellsWithType(VTK_LINE);
297 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
299 my1DProp = vtkProperty::New();
300 my1DProp->DeepCopy(myEdgeProp);
301 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
302 my1DProp->SetPointSize(aElem0DSize);
304 my1DExtProp = vtkProperty::New();
305 my1DExtProp->DeepCopy(myEdgeProp);
306 anRGB[0] = 1 - anRGB[0];
307 anRGB[1] = 1 - anRGB[1];
308 anRGB[2] = 1 - anRGB[2];
309 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
310 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
311 my1DExtProp->SetPointSize(aElem0DSize);
313 my1DExtActor = SMESH_DeviceActor::New();
314 my1DExtActor->SetUserMatrix(aMatrix);
315 my1DExtActor->PickableOff();
316 my1DExtActor->SetHighlited(true);
317 my1DExtActor->SetVisibility(false);
318 my1DExtActor->SetProperty(my1DExtProp);
319 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
320 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
321 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
322 aFilter->RegisterCellsWithType(VTK_LINE);
323 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
326 //Definition 0D device of the actor (0d elements)
327 //-----------------------------------------------
328 my0DProp = vtkProperty::New();
329 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
330 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
331 my0DProp->SetPointSize(aElem0DSize);
333 my0DActor = SMESH_CellLabelActor::New();
334 my0DActor->SetUserMatrix(aMatrix);
335 my0DActor->SetStoreGemetryMapping(true);
336 my0DActor->PickableOff();
337 my0DActor->SetVisibility(false);
338 my0DActor->SetProperty(my0DProp);
339 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
340 aFilter = my0DActor->GetExtractUnstructuredGrid();
341 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
342 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
343 aFilter->RegisterCellsWithType(VTK_VERTEX);
345 //Definition 0D device of the actor (ball elements)
346 //-----------------------------------------------
347 myBallProp = vtkProperty::New();
348 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
349 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
350 myBallProp->SetPointSize(aBallElemSize);
352 myBallActor = SMESH_CellLabelActor::New();
353 myBallActor->SetUserMatrix(aMatrix);
354 myBallActor->SetStoreGemetryMapping(true);
355 myBallActor->PickableOff();
356 myBallActor->SetVisibility(false);
357 myBallActor->SetProperty(myBallProp);
358 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
359 aFilter = myBallActor->GetExtractUnstructuredGrid();
360 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
361 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
363 //my0DExtProp = vtkProperty::New();
364 //my0DExtProp->DeepCopy(my0DProp);
365 //anRGB[0] = 1 - anRGB[0];
366 //anRGB[1] = 1 - anRGB[1];
367 //anRGB[2] = 1 - anRGB[2];
368 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
369 //my0DExtProp->SetPointSize(aElem0DSize);
371 //my0DExtActor = SMESH_DeviceActor::New();
372 //my0DExtActor->SetUserMatrix(aMatrix);
373 //my0DExtActor->SetStoreClippingMapping(true);
374 //my0DExtActor->PickableOff();
375 //my0DExtActor->SetHighlited(true);
376 //my0DExtActor->SetVisibility(false);
377 //my0DExtActor->SetProperty(my0DExtProp);
378 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
379 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
380 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
381 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
382 //aFilter->RegisterCellsWithType(VTK_VERTEX);
385 //Definition 0D device of the actor (nodes)
386 //-----------------------------------------
387 myNodeProp = vtkProperty::New();
388 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
389 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
391 myNodeActor = SMESH_NodeLabelActor::New();
392 myNodeActor->SetUserMatrix(aMatrix);
393 myNodeActor->SetStoreClippingMapping(true);
394 myNodeActor->PickableOff();
395 myNodeActor->SetVisibility(false);
396 myNodeActor->SetProperty(myNodeProp);
397 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
398 aFilter = myNodeActor->GetExtractUnstructuredGrid();
399 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
401 myNodeExtProp = vtkProperty::New();
402 myNodeExtProp->DeepCopy(myNodeProp);
403 anRGB[0] = 1 - anRGB[0];
404 anRGB[1] = 1 - anRGB[1];
405 anRGB[2] = 1 - anRGB[2];
406 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
408 myNodeExtActor = SMESH_DeviceActor::New();
409 myNodeExtActor->SetUserMatrix(aMatrix);
410 myNodeExtActor->SetStoreClippingMapping(true);
411 myNodeExtActor->PickableOff();
412 myNodeExtActor->SetHighlited(true);
413 myNodeExtActor->SetVisibility(false);
414 myNodeExtActor->SetProperty(myNodeExtProp);
415 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
416 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
417 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
418 aFilter->RegisterCellsWithType(VTK_VERTEX);
420 //Definition of Pickable and Highlitable engines
421 //----------------------------------------------
423 myBaseActor->SetUserMatrix(aMatrix);
424 myBaseActor->SetStoreGemetryMapping(true);
425 myBaseActor->GetProperty()->SetOpacity(0.0);
426 myPickableActor = myBaseActor;
428 myHighlightProp = vtkProperty::New();
429 myHighlightProp->SetAmbient(1.0);
430 myHighlightProp->SetDiffuse(0.0);
431 myHighlightProp->SetSpecular(0.0);
432 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
433 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
434 myHighlightProp->SetPointSize(aElem0DSize); // ??
435 myHighlightProp->SetLineWidth(aLineWidth);
436 myHighlightProp->SetRepresentation(1);
438 myBallHighlightProp = vtkProperty::New();
439 myBallHighlightProp->DeepCopy(myHighlightProp);
440 myBallHighlightProp->SetPointSize(aBallElemSize);
443 myOutLineProp = vtkProperty::New();
444 myOutLineProp->SetAmbient(1.0);
445 myOutLineProp->SetDiffuse(0.0);
446 myOutLineProp->SetSpecular(0.0);
447 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
448 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
449 myOutLineProp->SetLineWidth(aOutlineWidth);
450 myOutLineProp->SetRepresentation(1);
452 myPreselectProp = vtkProperty::New();
453 myPreselectProp->SetAmbient(1.0);
454 myPreselectProp->SetDiffuse(0.0);
455 myPreselectProp->SetSpecular(0.0);
456 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
457 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
458 myPreselectProp->SetPointSize(aElem0DSize); // ??
459 myPreselectProp->SetLineWidth(aLineWidth);
460 myPreselectProp->SetRepresentation(1);
462 myBallPreselectProp = vtkProperty::New();
463 myBallPreselectProp->DeepCopy(myPreselectProp);
464 myBallPreselectProp->SetPointSize(aBallElemSize);
466 myHighlitableActor = SMESH_DeviceActor::New();
467 myHighlitableActor->SetUserMatrix(aMatrix);
468 myHighlitableActor->PickableOff();
469 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
470 myHighlitableActor->SetCoincident3DAllowed(true);
477 myControlMode = eNone;
478 myControlActor = my2DActor;
480 //Definition of myScalarBarActor
481 //------------------------------
482 myLookupTable = vtkLookupTable::New();
483 //Fix for Bug PAL5195 - SMESH764:
484 //Controls - Aspect Ratio: incorrect colors of the best and worst values
485 myLookupTable->SetHueRange(0.667,0.0);
487 myScalarBarActor = SMESH_ScalarBarActor::New();
488 myScalarBarActor->SetVisibility(false);
489 myScalarBarActor->SetLookupTable(myLookupTable);
492 //Incorrect "Min value" in Scalar Bar in Mesh:
493 // myScalarBarActor->SetLabelFormat("%.4g");
494 // changes was commented because of regression bug IPAL 19981
496 mgr = SUIT_Session::session()->resourceMgr();
500 myEntityMode = eAllEntity;
501 myEntityModeCache = eAllEntity;
504 myImplicitBoolean = vtkImplicitBoolean::New();
505 myImplicitBoolean->SetOperationTypeToIntersection();
507 //Quadratic 2D elements representation
508 //-----------------------------------------------------------------------------
509 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
510 if(aQuadratic2DMode == 0){
511 myHighlitableActor->SetQuadraticArcMode(false);
512 my2DActor->SetQuadraticArcMode(false);
513 my1DActor->SetQuadraticArcMode(false);
515 else if(aQuadratic2DMode == 1){
516 myHighlitableActor->SetQuadraticArcMode(true);
517 my2DActor->SetQuadraticArcMode(true);
518 my1DActor->SetQuadraticArcMode(true);
521 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
522 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
523 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
525 // Set colors of the name actor
526 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
527 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
528 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
529 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
531 #ifndef DISABLE_PLOT2DVIEWER
535 SetBallSize(aBallElemSize);
536 Set0DSize(aElem0DSize);
540 SMESH_ActorDef::~SMESH_ActorDef()
542 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
544 // Please keep the order same as one in the header file
546 myTimeStamp->Delete();
548 myScalarBarActor->Delete();
549 myLookupTable->Delete();
551 mySurfaceProp->Delete();
552 myBackSurfaceProp->Delete();
553 myNormalVProp->Delete();
554 myReversedVProp->Delete();
555 myEdgeProp->Delete();
556 myNodeProp->Delete();
558 myNodeActor->Delete();
559 myBaseActor->Delete();
560 //myPickableActor->Delete(); myPickableActor == myBaseActor
562 myHighlightProp->Delete();
563 myOutLineProp->Delete();
564 myPreselectProp->Delete();
566 myBallHighlightProp->Delete();
567 myBallPreselectProp->Delete();
569 myHighlitableActor->Delete();
571 my2DExtProp->Delete();
572 my3DExtProp->Delete();
574 my2DExtActor->Delete();
576 my3DExtActor->Delete();
577 // myControlActor->Delete(); myControlActor == my2DActor
579 myNodeExtProp->Delete();
580 myNodeExtActor->Delete();
584 my1DExtProp->Delete();
585 my1DExtActor->Delete();
589 myBallProp->Delete();
590 myBallActor->Delete();
591 //my0DExtProp->Delete();
592 //my0DExtActor->Delete();
594 myImplicitBoolean->Delete();
596 #ifndef DISABLE_PLOT2DVIEWER
598 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
599 delete my2dHistogram;
604 void SMESH_ActorDef::Delete()
606 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
607 // from the actor's destructor) will be thrown before removing the actor's observers,
608 // that is done inside the Superclass::Delete() method but before the destructor itself
609 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
610 // The event is caught by SMESHGUI::ProcessEvents() static method.
611 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
613 Superclass::Delete();
616 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
619 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
620 SetRepresentation(GetRepresentation());
621 myTimeStamp->Modified();
625 bool SMESH_ActorDef::GetPointsLabeled() {
626 return myNodeActor && myNodeActor->GetPointsLabeled();
629 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
632 my3DActor->SetCellsLabeled(theIsCellsLabeled);
635 my2DActor->SetCellsLabeled(theIsCellsLabeled);
638 my1DActor->SetCellsLabeled(theIsCellsLabeled);
641 my0DActor->SetCellsLabeled(theIsCellsLabeled);
644 myBallActor->SetCellsLabeled(theIsCellsLabeled);
646 myTimeStamp->Modified();
650 bool SMESH_ActorDef::GetCellsLabeled() {
653 result = result || my3DActor->GetCellsLabeled();
656 result = result || my2DActor->GetCellsLabeled();
659 result = result || my1DActor->GetCellsLabeled();
662 result = result || my0DActor->GetCellsLabeled();
665 result = result || myBallActor->GetCellsLabeled();
671 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
673 myIsFacesOriented = theIsFacesOriented;
675 my2DActor->SetFacesOriented(theIsFacesOriented);
676 my3DActor->SetFacesOriented(theIsFacesOriented);
678 myTimeStamp->Modified();
681 bool SMESH_ActorDef::GetFacesOriented()
683 return myIsFacesOriented;
686 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
688 my2DActor->SetFacesOrientationColor( r, g, b );
689 my3DActor->SetFacesOrientationColor( r, g, b );
692 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
694 my3DActor->GetFacesOrientationColor( r, g, b );
697 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
699 my2DActor->SetFacesOrientationScale( theScale );
700 my3DActor->SetFacesOrientationScale( theScale );
703 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
705 return my3DActor->GetFacesOrientationScale();
708 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
710 my2DActor->SetFacesOrientation3DVectors( theState );
711 my3DActor->SetFacesOrientation3DVectors( theState );
714 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
716 return my3DActor->GetFacesOrientation3DVectors();
722 SetControlMode(eControl theMode)
724 SetControlMode(theMode,true);
730 SetControlMode(eControl theMode,
731 bool theCheckEntityMode)
733 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
737 myControlMode = eNone;
738 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
740 my0DActor->GetMapper()->SetScalarVisibility(false);
741 my1DActor->GetMapper()->SetScalarVisibility(false);
742 my2DActor->GetMapper()->SetScalarVisibility(false);
743 my3DActor->GetMapper()->SetScalarVisibility(false);
744 myBallActor->GetMapper()->SetScalarVisibility(false);
745 myScalarBarActor->SetVisibility(false);
747 bool anIsScalarVisible = theMode > eNone;
749 if(anIsScalarVisible) {
753 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
754 aControl->SetPrecision( myControlsPrecision );
755 myFunctor.reset( aControl );
756 myControlActor = my1DActor;
761 myFunctor.reset(new SMESH::Controls::Length2D());
762 myControlActor = my2DActor;
766 myFunctor.reset(new SMESH::Controls::FreeBorders());
767 myControlActor = my1DActor;
770 myFunctor.reset(new SMESH::Controls::FreeEdges());
771 myControlActor = my2DActor;
774 myFunctor.reset(new SMESH::Controls::FreeNodes());
775 myControlActor = myNodeActor;
778 myFunctor.reset(new SMESH::Controls::FreeFaces());
779 myControlActor = my2DActor;
781 case eCoincidentNodes:
783 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
784 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
785 cn->SetTolerance( tol );
787 myControlActor = myNodeActor;
790 case eCoincidentElems1D:
791 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
792 myControlActor = my1DActor;
794 case eCoincidentElems2D:
795 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
796 myControlActor = my2DActor;
798 case eCoincidentElems3D:
799 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
800 myControlActor = my3DActor;
802 case eBareBorderFace:
803 myFunctor.reset(new SMESH::Controls::BareBorderFace());
804 myControlActor = my2DActor;
806 case eOverConstrainedFace:
807 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
808 myControlActor = my2DActor;
810 case eMultiConnection:
811 myFunctor.reset(new SMESH::Controls::MultiConnection());
812 myControlActor = my1DActor;
814 case eMultiConnection2D:
815 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
816 myControlActor = my2DActor;
820 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
821 aControl->SetPrecision( myControlsPrecision );
822 myFunctor.reset( aControl );
823 myControlActor = my2DActor;
828 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
829 aControl->SetPrecision( myControlsPrecision );
830 myFunctor.reset( aControl );
831 myControlActor = my2DActor;
836 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
837 aControl->SetPrecision( myControlsPrecision );
838 myFunctor.reset( aControl );
839 myControlActor = my2DActor;
844 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
845 aControl->SetPrecision( myControlsPrecision );
846 myFunctor.reset( aControl );
847 myControlActor = my3DActor;
852 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
853 aControl->SetPrecision( myControlsPrecision );
854 myFunctor.reset( aControl );
855 myControlActor = my3DActor;
858 case eMaxElementLength2D:
860 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
861 aControl->SetPrecision( myControlsPrecision );
862 myFunctor.reset( aControl );
863 myControlActor = my2DActor;
866 case eMaxElementLength3D:
868 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
869 aControl->SetPrecision( myControlsPrecision );
870 myFunctor.reset( aControl );
871 myControlActor = my3DActor;
874 case eBareBorderVolume:
876 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
877 myControlActor = my3DActor;
880 case eOverConstrainedVolume:
882 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
883 myControlActor = my3DActor;
888 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
889 aControl->SetPrecision( myControlsPrecision );
890 myFunctor.reset( aControl );
891 myControlActor = my2DActor;
896 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
897 aControl->SetPrecision( myControlsPrecision );
898 myFunctor.reset( aControl );
899 myControlActor = my2DActor;
904 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
905 aControl->SetPrecision( myControlsPrecision );
906 myFunctor.reset( aControl );
907 myControlActor = my2DActor;
914 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
915 vtkIdType aNbCells = aGrid->GetNumberOfCells();
917 myControlMode = theMode;
918 switch(myControlMode){
920 case eCoincidentNodes:
921 myNodeExtActor->SetExtControlMode(myFunctor);
925 case eCoincidentElems1D:
926 my1DExtActor->SetExtControlMode(myFunctor);
929 case eBareBorderFace:
930 case eOverConstrainedFace:
931 case eCoincidentElems2D:
932 my2DExtActor->SetExtControlMode(myFunctor);
934 case eBareBorderVolume:
935 case eOverConstrainedVolume:
936 case eCoincidentElems3D:
937 my3DExtActor->SetExtControlMode(myFunctor);
940 case eMultiConnection2D:
941 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
942 UpdateDistribution();
945 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
946 UpdateDistribution();
950 if(theCheckEntityMode) {
951 if(myControlActor == my1DActor) {
952 if (!myIsEntityModeCache){
953 myEntityModeCache = GetEntityMode();
954 myIsEntityModeCache=true;
956 SetEntityMode(eEdges);
958 else if(myControlActor == my2DActor) {
959 switch(myControlMode) {
963 case eMultiConnection2D:
964 if (!myIsEntityModeCache){
965 myEntityModeCache = GetEntityMode();
966 myIsEntityModeCache=true;
968 SetEntityMode(eFaces);
971 if (!myIsEntityModeCache){
972 myEntityModeCache = GetEntityMode();
973 myIsEntityModeCache=true;
975 SetEntityMode(eFaces);
977 }else if(myControlActor == my3DActor) {
978 if (!myIsEntityModeCache){
979 myEntityModeCache = GetEntityMode();
980 myIsEntityModeCache=true;
982 SetEntityMode(eVolumes);
988 if(theCheckEntityMode){
989 myEntityMode = myEntityModeCache;
990 myIsEntityModeCache = false;
995 SetRepresentation(GetRepresentation());
997 myTimeStamp->Modified();
1003 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
1005 //myHighlightActor->AddToRender(theRenderer);
1007 theRenderer->AddActor(myBaseActor);
1008 theRenderer->AddActor(myNodeExtActor);
1009 theRenderer->AddActor(my1DExtActor);
1011 my3DActor ->AddToRender(theRenderer);
1012 my3DExtActor->AddToRender(theRenderer);
1013 my2DActor ->AddToRender(theRenderer);
1014 my2DExtActor->AddToRender(theRenderer);
1015 myNodeActor ->AddToRender(theRenderer);
1016 my1DActor ->AddToRender(theRenderer);
1017 my0DActor ->AddToRender(theRenderer);
1018 myBallActor ->AddToRender(theRenderer);
1019 //theRenderer->AddActor(my0DExtActor);
1021 theRenderer->AddActor(myHighlitableActor);
1023 theRenderer->AddActor2D(myScalarBarActor);
1025 // the superclass' method should be called at the end
1026 // (in particular, for correct work of selection)
1027 SALOME_Actor::AddToRender(theRenderer);
1030 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1031 SALOME_Actor::RemoveFromRender(theRenderer);
1033 theRenderer->RemoveActor(myBaseActor);
1035 theRenderer->RemoveActor(myNodeExtActor);
1037 theRenderer->RemoveActor(myHighlitableActor);
1039 //theRenderer->RemoveActor(my0DExtActor);
1041 theRenderer->RemoveActor(my1DExtActor);
1043 my2DActor->RemoveFromRender(theRenderer);
1044 my2DExtActor->RemoveFromRender(theRenderer);
1045 my3DActor->RemoveFromRender(theRenderer);
1046 my3DExtActor->RemoveFromRender(theRenderer);
1047 myNodeActor->RemoveFromRender(theRenderer);
1048 my0DActor->RemoveFromRender(theRenderer);
1049 myBallActor->RemoveFromRender(theRenderer);
1050 my1DActor->RemoveFromRender(theRenderer);
1052 theRenderer->RemoveActor(myScalarBarActor);
1056 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1057 const char* theEntry,
1058 const char* theName,
1061 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1065 myVisualObj = theVisualObj;
1066 myVisualObj->Update(theIsClear);
1068 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1069 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1071 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1073 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1075 my0DActor->Init(myVisualObj,myImplicitBoolean);
1076 myBallActor->Init(myVisualObj,myImplicitBoolean);
1077 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1079 my1DActor->Init(myVisualObj,myImplicitBoolean);
1080 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1082 my2DActor->Init(myVisualObj,myImplicitBoolean);
1083 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1084 my3DActor->Init(myVisualObj,myImplicitBoolean);
1085 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1087 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1088 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1089 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1091 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1092 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1094 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1095 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1096 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1097 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1099 vtkFloatingPointType aFactor, aUnits;
1100 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1101 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1102 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1103 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1105 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1109 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1110 SetIsShrunkable(true);
1112 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1114 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1115 SetRepresentation(-1);
1118 SetRepresentation(eEdge);
1119 }else if(aMode == 1){
1120 SetRepresentation(eSurface);
1121 }else if(aMode == 2){
1122 SetRepresentation(ePoint);
1129 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1130 SetIsDisplayNameActor( true );
1132 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1133 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1134 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1136 myTimeStamp->Modified();
1142 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1143 return myNodeActor->GetBounds();
1147 vtkDataSet* SMESH_ActorDef::GetInput(){
1148 return GetUnstructuredGrid();
1152 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1153 Superclass::SetTransform(theTransform);
1155 myNodeActor->SetTransform(theTransform);
1156 myBaseActor->SetTransform(theTransform);
1158 myHighlitableActor->SetTransform(theTransform);
1160 myNodeExtActor->SetTransform(theTransform);
1162 my0DActor->SetTransform(theTransform);
1163 myBallActor->SetTransform(theTransform);
1164 //my0DExtActor->SetTransform(theTransform);
1166 my1DActor->SetTransform(theTransform);
1167 my1DExtActor->SetTransform(theTransform);
1169 my2DActor->SetTransform(theTransform);
1170 my2DExtActor->SetTransform(theTransform);
1171 my3DActor->SetTransform(theTransform);
1172 my3DExtActor->SetTransform(theTransform);
1178 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1179 vtkLODActor::SetMapper(theMapper);
1183 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1184 SALOME_Actor::ShallowCopy(prop);
1188 vtkMapper* SMESH_ActorDef::GetMapper(){
1189 return myPickableActor->GetMapper();
1193 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1194 return myVisualObj->GetUnstructuredGrid();
1198 bool SMESH_ActorDef::IsInfinitive(){
1199 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1201 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1202 ( aDataSet->GetNumberOfCells() == 1 &&
1203 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1204 return SALOME_Actor::IsInfinitive();
1208 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1209 if ( myIsShrinkable == theShrunkable )
1211 myIsShrinkable = theShrunkable;
1215 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1216 return myBaseActor->GetShrinkFactor();
1219 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1220 myBaseActor->SetShrinkFactor(theValue);
1222 my1DActor->SetShrinkFactor(theValue);
1223 my1DExtActor->SetShrinkFactor(theValue);
1225 my2DActor->SetShrinkFactor(theValue);
1226 my2DExtActor->SetShrinkFactor(theValue);
1227 my3DActor->SetShrinkFactor(theValue);
1228 my3DExtActor->SetShrinkFactor(theValue);
1229 my3DExtActor->SetShrinkFactor(theValue);
1230 myHighlitableActor->SetShrinkFactor(theValue);
1235 void SMESH_ActorDef::SetShrink(){
1236 if(!myIsShrinkable) return;
1238 myBaseActor->SetShrink();
1240 my1DActor->SetShrink();
1241 my1DExtActor->SetShrink();
1243 my2DActor->SetShrink();
1244 my2DExtActor->SetShrink();
1245 my3DActor->SetShrink();
1246 my3DExtActor->SetShrink();
1247 myHighlitableActor->SetShrink();
1253 void SMESH_ActorDef::UnShrink(){
1254 if(!myIsShrunk) return;
1256 myBaseActor->UnShrink();
1258 my1DActor->UnShrink();
1259 my1DExtActor->UnShrink();
1261 my2DActor->UnShrink();
1262 my2DExtActor->UnShrink();
1263 my3DActor->UnShrink();
1264 my3DExtActor->UnShrink();
1265 myHighlitableActor->UnShrink();
1272 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1273 return myPickableActor->GetNodeObjId(theVtkID);
1276 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1277 return myPickableActor->GetNodeCoord(theObjID);
1281 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1282 return myPickableActor->GetElemObjId(theVtkID);
1285 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1286 return myPickableActor->GetElemCell(theObjID);
1290 void SMESH_ActorDef::SetVisibility(int theMode){
1291 SetVisibility(theMode,true);
1295 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1296 SALOME_Actor::SetVisibility(theMode);
1298 myNodeActor->VisibilityOff();
1299 myBaseActor->VisibilityOff();
1301 myNodeExtActor->VisibilityOff();
1303 my0DActor->VisibilityOff();
1304 myBallActor->VisibilityOff();
1305 //my0DExtActor->VisibilityOff();
1307 my1DActor->VisibilityOff();
1308 my1DExtActor->VisibilityOff();
1310 my2DActor->VisibilityOff();
1311 my2DExtActor->VisibilityOff();
1312 my3DActor->VisibilityOff();
1313 my3DExtActor->VisibilityOff();
1315 myScalarBarActor->VisibilityOff();
1317 if(GetVisibility()){
1318 if(theIsUpdateRepersentation)
1319 SetRepresentation(GetRepresentation());
1321 if(myControlMode != eNone){
1322 switch(myControlMode){
1324 case eCoincidentNodes:
1325 myNodeExtActor->VisibilityOn();
1329 case eCoincidentElems1D:
1330 my1DExtActor->VisibilityOn();
1333 case eBareBorderFace:
1334 case eOverConstrainedFace:
1335 case eCoincidentElems2D:
1336 my2DExtActor->VisibilityOn();
1338 case eBareBorderVolume:
1339 case eOverConstrainedVolume:
1340 case eCoincidentElems3D:
1341 my3DExtActor->VisibilityOn();
1344 case eMultiConnection2D:
1345 my1DExtActor->VisibilityOn();
1347 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1348 myScalarBarActor->VisibilityOn();
1352 if(myRepresentation != ePoint)
1353 myPickableActor->VisibilityOn();
1355 myNodeActor->VisibilityOn();
1358 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1359 my0DActor->VisibilityOn();
1361 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1362 myBallActor->VisibilityOn();
1365 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1366 my1DActor->VisibilityOn();
1369 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1370 my2DActor->VisibilityOn();
1373 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1374 my3DActor->VisibilityOn();
1377 if(myNodeActor->GetPointsLabeled()){
1378 myNodeActor->VisibilityOn();
1382 my0DActor->UpdateLabels();
1385 myBallActor->UpdateLabels();
1388 my1DActor->UpdateLabels();
1391 my2DActor->UpdateLabels();
1394 my3DActor->UpdateLabels();
1396 #ifndef DISABLE_PLOT2DVIEWER
1398 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1405 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1407 myEntityState = eAllEntity;
1409 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1410 myEntityState &= ~e0DElements;
1411 theMode &= ~e0DElements;
1414 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1415 myEntityState &= ~eBallElem;
1416 theMode &= ~eBallElem;
1419 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1420 myEntityState &= ~eEdges;
1424 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1425 myEntityState &= ~eFaces;
1429 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1430 myEntityState &= ~eVolumes;
1431 theMode &= ~eVolumes;
1435 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1436 theMode |= e0DElements;
1438 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1439 theMode |= eBallElem;
1441 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1444 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1447 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1448 theMode |= eVolumes;
1451 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1453 myEntityMode = theMode;
1454 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1455 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1456 aFilter->ClearRegisteredCellsWithType();
1457 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1459 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1460 aHightFilter->ClearRegisteredCellsWithType();
1461 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1463 if (myEntityMode & e0DElements) {
1464 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1465 aFilter->RegisterCellsWithType(VTK_VERTEX);
1466 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1469 if (myEntityMode & eBallElem) {
1470 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1471 aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1474 if (myEntityMode & eEdges) {
1475 if (MYDEBUG) MESSAGE("EDGES");
1476 aFilter->RegisterCellsWithType(VTK_LINE);
1477 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1479 aHightFilter->RegisterCellsWithType(VTK_LINE);
1480 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1483 if (myEntityMode & eFaces) {
1484 if (MYDEBUG) MESSAGE("FACES");
1485 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1486 aFilter->RegisterCellsWithType(VTK_POLYGON);
1487 aFilter->RegisterCellsWithType(VTK_QUAD);
1488 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1489 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1490 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1492 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1493 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1494 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1495 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1496 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1497 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1500 if (myEntityMode & eVolumes) {
1501 if (MYDEBUG) MESSAGE("VOLUMES");
1502 aFilter->RegisterCellsWithType(VTK_TETRA);
1503 aFilter->RegisterCellsWithType(VTK_VOXEL);
1504 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1505 aFilter->RegisterCellsWithType(VTK_WEDGE);
1506 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1507 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1508 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1509 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1510 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1511 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1512 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1513 //#ifdef VTK_HAVE_POLYHEDRON
1514 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1517 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1518 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1519 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1520 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1521 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1522 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1523 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1524 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1525 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1526 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1527 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1528 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1529 //#ifdef VTK_HAVE_POLYHEDRON
1530 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1534 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1535 SetVisibility(GetVisibility(),false);
1538 void SMESH_ActorDef::SetRepresentation (int theMode)
1540 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1541 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1542 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1543 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1544 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1547 myRepresentation = eSurface;
1548 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1549 myRepresentation = eEdge;
1550 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1551 myRepresentation = ePoint;
1556 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1559 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1562 myRepresentation = theMode;
1565 if (!GetUnstructuredGrid()->GetNumberOfCells())
1566 myRepresentation = ePoint;
1569 if (myRepresentation == ePoint) {
1577 myPickableActor = myBaseActor;
1578 myNodeActor->SetVisibility(false);
1579 myNodeExtActor->SetVisibility(false);
1580 vtkProperty *aProp = NULL, *aBackProp = NULL;
1581 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1582 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1583 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1584 switch (myRepresentation) {
1586 myPickableActor = myNodeActor;
1587 myNodeActor->SetVisibility(true);
1588 aQuadraticMode = SMESH_Actor::eLines;
1589 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1590 aReperesent = SMESH_DeviceActor::ePoint;
1593 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1594 aReperesent = SMESH_DeviceActor::eInsideframe;
1597 aProp = mySurfaceProp;
1598 aBackProp = myBackSurfaceProp;
1599 aPropVN = myNormalVProp;
1600 aPropVR = myReversedVProp;
1601 aReperesent = SMESH_DeviceActor::eSurface;
1605 my2DActor->SetProperty(aProp);
1606 my2DActor->SetBackfaceProperty(aBackProp);
1607 my2DActor->SetRepresentation(aReperesent);
1609 if(aQuadraticMode == SMESH_Actor::eLines)
1610 my2DActor->SetQuadraticArcMode(false);
1611 else if(aQuadraticMode == SMESH_Actor::eArcs)
1612 my2DActor->SetQuadraticArcMode(true);
1614 my2DExtActor->SetRepresentation(aReperesent);
1616 my3DActor->SetProperty(aPropVN);
1617 my3DActor->SetBackfaceProperty(aPropVR);
1618 my3DActor->SetRepresentation(aReperesent);
1620 //my0DExtActor->SetVisibility(false);
1621 my1DExtActor->SetVisibility(false);
1622 my2DExtActor->SetVisibility(false);
1623 my3DExtActor->SetVisibility(false);
1626 //my0DActor->SetProperty(aProp);
1627 //my0DActor->SetBackfaceProperty(aBackProp);
1628 my0DActor->SetRepresentation(aReperesent);
1629 myBallActor->SetRepresentation(aReperesent);
1630 //my0DExtActor->SetRepresentation(aReperesent);
1632 switch(myControlMode){
1634 case eMultiConnection:
1635 aProp = aBackProp = my1DProp;
1636 if(myRepresentation != ePoint)
1637 aReperesent = SMESH_DeviceActor::eInsideframe;
1641 if(aQuadraticMode == SMESH_Actor::eLines)
1642 my1DActor->SetQuadraticArcMode(false);
1643 else if(aQuadraticMode == SMESH_Actor::eArcs)
1644 my1DActor->SetQuadraticArcMode(true);
1646 my1DActor->SetProperty(aProp);
1647 my1DActor->SetBackfaceProperty(aBackProp);
1648 my1DActor->SetRepresentation(aReperesent);
1650 my1DExtActor->SetRepresentation(aReperesent);
1652 if(myIsPointsVisible)
1653 myPickableActor = myNodeActor;
1654 if(GetPointRepresentation())
1655 myNodeActor->SetVisibility(true);
1657 SetMapper(myPickableActor->GetMapper());
1659 SetVisibility(GetVisibility(),false);
1665 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1666 if ( myIsPointsVisible == theIsPointsVisible )
1668 myIsPointsVisible = theIsPointsVisible;
1669 SetRepresentation(GetRepresentation());
1672 bool SMESH_ActorDef::GetPointRepresentation(){
1673 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1677 void SMESH_ActorDef::UpdateHighlight(){
1678 myHighlitableActor->SetHighlited(false);
1679 myHighlitableActor->SetVisibility(false);
1681 bool anIsVisible = GetVisibility();
1683 switch(myRepresentation){
1684 case SMESH_DeviceActor::eSurface:
1685 case SMESH_DeviceActor::eWireframe:
1687 if(myIsHighlighted) {
1688 myHighlitableActor->SetProperty(myHighlightProp);
1689 myBallActor->SetProperty(myBallHighlightProp);
1690 }else if(myIsPreselected){
1691 myHighlitableActor->SetProperty(myPreselectProp);
1692 myBallActor->SetProperty(myBallPreselectProp);
1693 } else if(anIsVisible){
1694 myBallActor->SetProperty(myBallProp);
1695 (myRepresentation == eSurface) ?
1696 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1698 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1699 myHighlitableActor->SetHighlited(anIsVisible);
1700 myHighlitableActor->GetExtractUnstructuredGrid()->
1701 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1702 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1704 myHighlitableActor->SetVisibility(anIsVisible);
1707 case SMESH_DeviceActor::ePoint:
1709 if(myIsHighlighted) {
1710 myNodeActor->SetProperty(myHighlightProp);
1711 }else if(myIsPreselected) {
1712 myNodeActor->SetProperty(myPreselectProp);
1713 } else if(anIsVisible) {
1714 myNodeActor->SetProperty(myNodeProp);
1716 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1717 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1724 void SMESH_ActorDef::highlight(bool theHighlight){
1725 if ( myIsHighlighted == theHighlight )
1727 myIsHighlighted = theHighlight;
1732 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1733 if ( myIsPreselected == thePreselect )
1735 myIsPreselected = thePreselect;
1741 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1743 if (myPickableActor->GetIsOpaque())
1745 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1753 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1755 if (!myPickableActor->GetIsOpaque())
1757 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1765 void SMESH_ActorDef::Render(vtkRenderer *ren){
1766 unsigned long aTime = myTimeStamp->GetMTime();
1767 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1768 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1769 if(anObjTime > aTime || aClippingTime > aTime)
1774 void SMESH_ActorDef::Update(){
1775 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1777 if(GetControlMode() != eNone) {
1778 unsigned long aTime = myTimeStamp->GetMTime();
1779 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1780 if (anObjTime > aTime)
1781 SetControlMode(GetControlMode(),false);
1785 myNodeActor->UpdateLabels();
1788 my0DActor->UpdateLabels();
1791 myBallActor->UpdateLabels();
1794 my1DActor->UpdateLabels();
1797 my2DActor->UpdateLabels();
1800 my3DActor->UpdateLabels();
1802 if(myIsFacesOriented){
1803 SetFacesOriented(myIsFacesOriented);
1806 if(myVisualObj->GetEntitiesFlag()) {
1807 myEntityMode |= myVisualObj->GetEntitiesState();
1810 SetEntityMode(GetEntityMode());
1811 SetVisibility(GetVisibility());
1813 myTimeStamp->Modified();
1818 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1819 SALOME_Actor::ReleaseGraphicsResources(renWin);
1821 myPickableActor->ReleaseGraphicsResources(renWin);
1825 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1826 vtkFloatingPointType* aColor = theProperty->GetColor();
1833 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1834 mySurfaceProp->SetOpacity(theValue);
1835 myBackSurfaceProp->SetOpacity(theValue);
1836 myNormalVProp->SetOpacity(theValue);
1837 myReversedVProp->SetOpacity(theValue);
1838 myEdgeProp->SetOpacity(theValue);
1839 myOutLineProp->SetOpacity(theValue);
1840 myNodeProp->SetOpacity(theValue);
1842 my1DProp->SetOpacity(theValue);
1843 my0DProp->SetOpacity(theValue);
1844 myBallProp->SetOpacity(theValue);
1848 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1849 return mySurfaceProp->GetOpacity();
1853 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1854 mySurfaceProp->SetColor(r,g,b);
1855 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1856 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1857 if( aGroupObj->GetElementType() == SMDSAbs_Face )
1858 myNameActor->SetBackgroundColor(r,g,b);
1860 myDeltaBrightness = delta;
1861 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1862 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1866 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1867 ::GetColor(mySurfaceProp,r,g,b);
1868 delta = myDeltaBrightness;
1871 void SMESH_ActorDef::SetVolumeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1872 myNormalVProp->SetColor(r,g,b);
1873 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1874 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1875 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
1876 myNameActor->SetBackgroundColor(r,g,b);
1878 myDeltaVBrightness = delta;
1879 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1880 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1884 void SMESH_ActorDef::GetVolumeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1885 ::GetColor(myNormalVProp,r,g,b);
1886 delta = myDeltaVBrightness;
1889 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1890 myEdgeProp->SetColor(r,g,b);
1891 my1DProp->SetColor(r,g,b);
1892 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1893 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1894 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1895 myNameActor->SetBackgroundColor(r,g,b);
1899 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1900 ::GetColor(myEdgeProp,r,g,b);
1903 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1904 myOutLineProp->SetColor(r,g,b);
1908 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1909 ::GetColor(myOutLineProp,r,g,b);
1913 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1914 myNodeProp->SetColor(r,g,b);
1915 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1916 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1917 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1918 myNameActor->SetBackgroundColor(r,g,b);
1922 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1923 ::GetColor(myNodeProp,r,g,b);
1926 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1927 my0DProp->SetColor(r,g,b);
1928 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1929 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1930 myNameActor->SetBackgroundColor(r,g,b);
1934 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1935 ::GetColor(my0DProp,r,g,b);
1938 void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1939 myBallProp->SetColor(r,g,b);
1940 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1941 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
1942 myNameActor->SetBackgroundColor(r,g,b);
1946 void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1947 ::GetColor(myBallProp,r,g,b);
1950 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1951 myHighlightProp->SetColor(r,g,b);
1952 myBallHighlightProp->SetColor(r,g,b);
1956 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1957 ::GetColor(myHighlightProp,r,g,b);
1960 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1961 myPreselectProp->SetColor(r,g,b);
1962 myBallPreselectProp->SetColor(r,g,b);
1966 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1967 ::GetColor(myPreselectProp,r,g,b);
1971 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1972 return myEdgeProp->GetLineWidth();
1976 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1977 myEdgeProp->SetLineWidth(theVal);
1979 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1980 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1981 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
1982 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
1983 myOutLineProp->SetLineWidth(theVal);
1984 myHighlightProp->SetLineWidth(theVal);
1985 myPreselectProp->SetLineWidth(theVal);
1989 vtkFloatingPointType SMESH_ActorDef::GetOutlineWidth()
1991 return myOutLineProp->GetLineWidth();
1994 void SMESH_ActorDef::SetOutlineWidth(vtkFloatingPointType theVal)
1996 myOutLineProp->SetLineWidth(theVal);
2000 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
2001 my0DProp->SetPointSize(theVal);
2002 myHighlightProp->SetPointSize(theVal);
2003 myPreselectProp->SetPointSize(theVal);
2005 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2006 aCustom->Set0DSize(theVal);
2008 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2009 aCustom->Set0DSize(theVal);
2015 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
2016 return my0DProp->GetPointSize();
2019 void SMESH_ActorDef::SetBallSize(vtkFloatingPointType theVal){
2020 myBallProp->SetPointSize(theVal);
2021 myBallHighlightProp->SetPointSize(theVal);
2022 myBallPreselectProp->SetPointSize(theVal);
2023 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2024 aCustom->SetBallSize(theVal);
2026 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2027 aCustom->SetBallSize(theVal);
2033 vtkFloatingPointType SMESH_ActorDef::GetBallSize(){
2034 return myBallProp->GetPointSize();
2037 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2039 return myVisualObj->GetElemDimension( theObjId );
2044 IsImplicitFunctionUsed() const
2046 return myBaseActor->IsImplicitFunctionUsed();
2050 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2052 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2053 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2055 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2057 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2059 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2060 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2061 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2063 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2064 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2066 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2067 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2068 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2069 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2073 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2076 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2077 myCippingPlaneCont.push_back(thePlane);
2078 if(!IsImplicitFunctionUsed())
2079 SetImplicitFunctionUsed(true);
2080 myNodeActor->UpdateLabels();
2082 return myCippingPlaneCont.size();
2087 RemoveAllClippingPlanes()
2089 myImplicitBoolean->GetFunction()->RemoveAllItems();
2090 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2091 myCippingPlaneCont.clear();
2092 SetImplicitFunctionUsed(false);
2093 myNodeActor->UpdateLabels();
2098 GetNumberOfClippingPlanes()
2100 return myCippingPlaneCont.size();
2105 GetClippingPlane(vtkIdType theID)
2107 if(theID >= myCippingPlaneCont.size())
2109 return myCippingPlaneCont[theID].Get();
2112 void SMESH_ActorDef::UpdateScalarBar()
2114 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2118 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2120 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2121 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2123 aScalarBarTitleProp->SetFontFamilyToArial();
2125 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2127 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2128 if ( f.family() == "Arial" )
2129 aScalarBarTitleProp->SetFontFamilyToArial();
2130 else if ( f.family() == "Courier" )
2131 aScalarBarTitleProp->SetFontFamilyToCourier();
2132 else if ( f.family() == "Times" )
2133 aScalarBarTitleProp->SetFontFamilyToTimes();
2136 aScalarBarTitleProp->BoldOn();
2138 aScalarBarTitleProp->BoldOff();
2141 aScalarBarTitleProp->ItalicOn();
2143 aScalarBarTitleProp->ItalicOff();
2146 aScalarBarTitleProp->ShadowOn();
2148 aScalarBarTitleProp->ShadowOff();
2151 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2152 aScalarBarTitleProp->Delete();
2154 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2156 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2157 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2159 aScalarBarLabelProp->SetFontFamilyToArial();
2160 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2162 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2163 if( f.family() == "Arial" )
2164 aScalarBarLabelProp->SetFontFamilyToArial();
2165 else if( f.family() == "Courier" )
2166 aScalarBarLabelProp->SetFontFamilyToCourier();
2167 else if( f.family() == "Times" )
2168 aScalarBarLabelProp->SetFontFamilyToTimes();
2171 aScalarBarLabelProp->BoldOn();
2173 aScalarBarLabelProp->BoldOff();
2176 aScalarBarLabelProp->ItalicOn();
2178 aScalarBarLabelProp->ItalicOff();
2181 aScalarBarLabelProp->ShadowOn();
2183 aScalarBarLabelProp->ShadowOff();
2186 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2187 aScalarBarLabelProp->Delete();
2189 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2190 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2192 myScalarBarActor->SetOrientationToHorizontal();
2194 myScalarBarActor->SetOrientationToVertical();
2197 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2198 if( mgr->hasValue( "SMESH", name + "x" ) )
2199 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2201 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2202 if( mgr->hasValue( "SMESH", name + "y" ) )
2203 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2204 myScalarBarActor->SetPosition( aXVal, aYVal );
2206 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2207 if( mgr->hasValue( "SMESH", name + "width" ) )
2208 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2209 myScalarBarActor->SetWidth( aWVal );
2211 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2212 if( mgr->hasValue( "SMESH", name + "height" ) )
2213 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2214 myScalarBarActor->SetHeight( aHVal );
2217 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2218 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2219 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2222 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2223 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2224 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2226 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2227 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2229 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2230 myScalarBarActor->SetDistributionColoringType(coloringType);
2232 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2233 QColor(255, 255, 255));
2235 rgb[0]= distributionColor.red()/255.;
2236 rgb[1]= distributionColor.green()/255.;
2237 rgb[2]= distributionColor.blue()/255.;
2238 myScalarBarActor->SetDistributionColor(rgb);
2243 void SMESH_ActorDef::UpdateDistribution()
2245 if(SMESH::Controls::NumericalFunctor* fun =
2246 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2248 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2249 std::vector<int> nbEvents;
2250 std::vector<double> funValues;
2251 SMESH_VisualObjDef::TEntityList elems;
2252 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2253 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2254 std::vector<int> elemIds;
2255 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2256 elemIds.push_back( (*e)->GetID());
2257 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2258 double * range = lookupTable->GetRange();
2259 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2260 myScalarBarActor->SetDistribution(nbEvents);
2264 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2267 case SMESH_Actor::eLines :
2268 myHighlitableActor->SetQuadraticArcMode(false);
2269 my2DActor->SetQuadraticArcMode(false);
2270 my1DActor->SetQuadraticArcMode(false);
2272 case SMESH_Actor::eArcs :
2273 myHighlitableActor->SetQuadraticArcMode(true);
2274 if(GetRepresentation() != SMESH_Actor::ePoint) {
2275 my2DActor->SetQuadraticArcMode(true);
2276 my1DActor->SetQuadraticArcMode(true);
2285 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2287 if(myHighlitableActor->GetQuadraticArcMode())
2288 return SMESH_Actor::eArcs;
2290 return SMESH_Actor::eLines;
2293 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2295 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2296 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2297 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2300 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2302 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2303 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2304 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2305 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2308 #ifndef DISABLE_PLOT2DVIEWER
2309 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2312 my2dHistogram->clearAllPoints();
2314 if(SMESH::Controls::NumericalFunctor* fun =
2315 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2318 if(!my2dHistogram) {
2319 my2dHistogram = new SPlot2d_Histogram();
2320 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2321 my2dHistogram->setIO(anIO);
2324 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2325 std::vector<int> nbEvents;
2326 std::vector<double> funValues;
2327 SMESH_VisualObjDef::TEntityList elems;
2328 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2329 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2330 std::vector<int> elemIds;
2332 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2333 elemIds.push_back( (*e)->GetID());
2335 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2336 double * range = lookupTable->GetRange();
2337 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2339 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2340 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2342 if(funValues.size() >= 2)
2343 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2347 //Color of the histogram
2348 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2349 my2dHistogram->setAutoAssign(true);
2352 myScalarBarActor->GetDistributionColor(rgb);
2353 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2354 my2dHistogram->setColor(aColor);
2358 return my2dHistogram;