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"
41 #include "SUIT_Session.h"
42 #include "SUIT_ResourceMgr.h"
46 #ifndef DISABLE_PLOT2DVIEWER
47 #include <SPlot2d_Histogram.h>
50 #include <vtkProperty.h>
51 #include <vtkTimeStamp.h>
52 #include <vtkObjectFactory.h>
53 #include <vtkShrinkPolyData.h>
54 #include <vtkMergeFilter.h>
56 #include <vtkMatrix4x4.h>
57 #include <vtkUnstructuredGrid.h>
58 #include <vtkPointData.h>
59 #include <vtkCellData.h>
61 #include <vtkMapper.h>
62 #include <vtkRenderer.h>
65 #include <vtkIdList.h>
66 #include <vtkIntArray.h>
68 #include <vtkActor2D.h>
69 #include <vtkProperty2D.h>
70 #include <vtkPolyData.h>
71 #include <vtkTextProperty.h>
73 #include <vtkLookupTable.h>
77 #include <vtkImplicitBoolean.h>
78 #include <vtkImplicitFunctionCollection.h>
80 #include <vtkConfigure.h>
81 #if !defined(VTK_XVERSION)
82 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
85 #include "utilities.h"
88 static int MYDEBUG = 1;
90 static int MYDEBUG = 1;
93 static int aLineWidthInc = 2;
96 SMESH_ActorDef* SMESH_ActorDef::New(){
97 return new SMESH_ActorDef();
101 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 const char* theEntry,
106 SMESH_ActorDef* anActor = NULL;
107 if(theVisualObj->IsValid() ) {
108 anActor = SMESH_ActorDef::New();
109 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
114 anActor->UpdateScalarBar();
120 SMESH_ActorDef::SMESH_ActorDef()
122 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
123 myBaseActor = SMESH_DeviceActor::New();
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
128 myIsEntityModeCache = false;
130 myIsShrinkable = false;
133 myIsFacesOriented = false;
135 myControlsPrecision = -1;
136 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
138 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
139 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
141 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
142 vtkFloatingPointType aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
143 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
145 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
146 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
148 //Definition 2D and 3D devices of the actor
149 //-----------------------------------------
150 vtkFloatingPointType anRGB[3] = {1,1,1};
151 mySurfaceProp = vtkProperty::New();
154 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
155 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
156 myDeltaBrightness = delta;
158 myBackSurfaceProp = vtkProperty::New();
159 bfc = Qtx::mainColorToSecondary(ffc, delta);
160 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
162 my2DActor = SMESH_CellLabelActor::New();
163 my2DActor->SetStoreGemetryMapping(true);
164 my2DActor->SetUserMatrix(aMatrix);
165 my2DActor->PickableOff();
166 my2DActor->SetProperty(mySurfaceProp);
167 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
168 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
169 aFilter = my2DActor->GetExtractUnstructuredGrid();
170 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
171 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
172 aFilter->RegisterCellsWithType(VTK_POLYGON);
173 aFilter->RegisterCellsWithType(VTK_QUAD);
174 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
175 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
176 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
178 my2DExtProp = vtkProperty::New();
179 my2DExtProp->DeepCopy(mySurfaceProp);
180 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
181 anRGB[0] = 1 - anRGB[0];
182 anRGB[1] = 1 - anRGB[1];
183 anRGB[2] = 1 - anRGB[2];
184 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
186 my2DExtActor = SMESH_DeviceActor::New();
187 my2DExtActor->SetUserMatrix(aMatrix);
188 my2DExtActor->PickableOff();
189 my2DExtActor->SetProperty(my2DExtProp);
190 my2DExtActor->SetBackfaceProperty(my2DExtProp);
191 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
192 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
193 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
194 aFilter->RegisterCellsWithType(VTK_POLYGON);
195 aFilter->RegisterCellsWithType(VTK_QUAD);
196 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
197 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
198 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
200 my3DActor = SMESH_CellLabelActor::New();
201 my3DActor->SetStoreGemetryMapping(true);
202 my3DActor->SetUserMatrix(aMatrix);
203 my3DActor->PickableOff();
204 my3DActor->SetProperty(mySurfaceProp);
205 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
206 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
207 my3DActor->SetCoincident3DAllowed(true);
208 aFilter = my3DActor->GetExtractUnstructuredGrid();
209 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
210 aFilter->RegisterCellsWithType(VTK_TETRA);
211 aFilter->RegisterCellsWithType(VTK_VOXEL);
212 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
213 aFilter->RegisterCellsWithType(VTK_WEDGE);
214 aFilter->RegisterCellsWithType(VTK_PYRAMID);
215 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
216 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
217 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
218 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
219 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
220 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
221 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
222 //#ifdef VTK_HAVE_POLYHEDRON
223 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
224 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
227 my3DExtActor = SMESH_DeviceActor::New();
228 my3DExtActor->SetUserMatrix(aMatrix);
229 my3DExtActor->PickableOff();
230 my3DExtActor->SetProperty(my2DExtProp);
231 my3DExtActor->SetBackfaceProperty(my2DExtProp);
232 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
233 my3DExtActor->SetCoincident3DAllowed(true);
234 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
235 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
236 aFilter->RegisterCellsWithType(VTK_TETRA);
237 aFilter->RegisterCellsWithType(VTK_VOXEL);
238 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
239 aFilter->RegisterCellsWithType(VTK_WEDGE);
240 aFilter->RegisterCellsWithType(VTK_PYRAMID);
241 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
242 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
243 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
244 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
245 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
246 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
247 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
248 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
250 //Definition 1D device of the actor
251 //---------------------------------
252 myEdgeProp = vtkProperty::New();
253 myEdgeProp->SetAmbient(1.0);
254 myEdgeProp->SetDiffuse(0.0);
255 myEdgeProp->SetSpecular(0.0);
256 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
257 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
258 myEdgeProp->SetLineWidth(aLineWidth);
260 my1DActor = SMESH_CellLabelActor::New();
261 my1DActor->SetStoreGemetryMapping(true);
262 my1DActor->SetUserMatrix(aMatrix);
263 my1DActor->PickableOff();
264 my1DActor->SetHighlited(true);
265 my1DActor->SetProperty(myEdgeProp);
266 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
267 aFilter = my1DActor->GetExtractUnstructuredGrid();
268 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
269 aFilter->RegisterCellsWithType(VTK_LINE);
270 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
272 my1DProp = vtkProperty::New();
273 my1DProp->DeepCopy(myEdgeProp);
274 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
275 my1DProp->SetPointSize(aElem0DSize);
277 my1DExtProp = vtkProperty::New();
278 my1DExtProp->DeepCopy(myEdgeProp);
279 anRGB[0] = 1 - anRGB[0];
280 anRGB[1] = 1 - anRGB[1];
281 anRGB[2] = 1 - anRGB[2];
282 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
283 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
284 my1DExtProp->SetPointSize(aElem0DSize);
286 my1DExtActor = SMESH_DeviceActor::New();
287 my1DExtActor->SetUserMatrix(aMatrix);
288 my1DExtActor->PickableOff();
289 my1DExtActor->SetHighlited(true);
290 my1DExtActor->SetVisibility(false);
291 my1DExtActor->SetProperty(my1DExtProp);
292 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
293 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
294 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
295 aFilter->RegisterCellsWithType(VTK_LINE);
296 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
299 //Definition 0D device of the actor (0d elements)
300 //-----------------------------------------------
301 my0DProp = vtkProperty::New();
302 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
303 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
304 my0DProp->SetPointSize(aElem0DSize);
306 my0DActor = SMESH_CellLabelActor::New();
307 my0DActor->SetUserMatrix(aMatrix);
308 my0DActor->SetStoreGemetryMapping(true);
309 my0DActor->PickableOff();
310 my0DActor->SetVisibility(false);
311 my0DActor->SetProperty(my0DProp);
312 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
313 aFilter = my0DActor->GetExtractUnstructuredGrid();
314 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
315 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
316 aFilter->RegisterCellsWithType(VTK_VERTEX);
318 //Definition 0D device of the actor (ball elements)
319 //-----------------------------------------------
320 myBallProp = vtkProperty::New();
321 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
322 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
323 myBallProp->SetPointSize(aBallElemSize);
325 myBallActor = SMESH_CellLabelActor::New();
326 myBallActor->SetUserMatrix(aMatrix);
327 myBallActor->SetStoreGemetryMapping(true);
328 myBallActor->PickableOff();
329 myBallActor->SetVisibility(false);
330 myBallActor->SetProperty(myBallProp);
331 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
332 aFilter = myBallActor->GetExtractUnstructuredGrid();
333 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
334 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
335 aFilter->RegisterCellsWithType(VTK_VERTEX);
336 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
338 //my0DExtProp = vtkProperty::New();
339 //my0DExtProp->DeepCopy(my0DProp);
340 //anRGB[0] = 1 - anRGB[0];
341 //anRGB[1] = 1 - anRGB[1];
342 //anRGB[2] = 1 - anRGB[2];
343 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
344 //my0DExtProp->SetPointSize(aElem0DSize);
346 //my0DExtActor = SMESH_DeviceActor::New();
347 //my0DExtActor->SetUserMatrix(aMatrix);
348 //my0DExtActor->SetStoreClippingMapping(true);
349 //my0DExtActor->PickableOff();
350 //my0DExtActor->SetHighlited(true);
351 //my0DExtActor->SetVisibility(false);
352 //my0DExtActor->SetProperty(my0DExtProp);
353 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
354 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
355 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
356 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
357 //aFilter->RegisterCellsWithType(VTK_VERTEX);
360 //Definition 0D device of the actor (nodes)
361 //-----------------------------------------
362 myNodeProp = vtkProperty::New();
363 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
364 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
366 myNodeActor = SMESH_NodeLabelActor::New();
367 myNodeActor->SetUserMatrix(aMatrix);
368 myNodeActor->SetStoreClippingMapping(true);
369 myNodeActor->PickableOff();
370 myNodeActor->SetVisibility(false);
371 myNodeActor->SetProperty(myNodeProp);
372 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
373 aFilter = myNodeActor->GetExtractUnstructuredGrid();
374 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
376 myNodeExtProp = vtkProperty::New();
377 myNodeExtProp->DeepCopy(myNodeProp);
378 anRGB[0] = 1 - anRGB[0];
379 anRGB[1] = 1 - anRGB[1];
380 anRGB[2] = 1 - anRGB[2];
381 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
383 myNodeExtActor = SMESH_DeviceActor::New();
384 myNodeExtActor->SetUserMatrix(aMatrix);
385 myNodeExtActor->SetStoreClippingMapping(true);
386 myNodeExtActor->PickableOff();
387 myNodeExtActor->SetHighlited(true);
388 myNodeExtActor->SetVisibility(false);
389 myNodeExtActor->SetProperty(myNodeExtProp);
390 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
391 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
392 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
393 aFilter->RegisterCellsWithType(VTK_VERTEX);
395 //Definition of Pickable and Highlitable engines
396 //----------------------------------------------
398 myBaseActor->SetUserMatrix(aMatrix);
399 myBaseActor->SetStoreGemetryMapping(true);
400 myBaseActor->GetProperty()->SetOpacity(0.0);
401 myPickableActor = myBaseActor;
403 myHighlightProp = vtkProperty::New();
404 myHighlightProp->SetAmbient(1.0);
405 myHighlightProp->SetDiffuse(0.0);
406 myHighlightProp->SetSpecular(0.0);
407 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
408 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
409 myHighlightProp->SetPointSize(aElem0DSize); // ??
410 myHighlightProp->SetLineWidth(aLineWidth);
411 myHighlightProp->SetRepresentation(1);
413 myOutLineProp = vtkProperty::New();
414 myOutLineProp->SetAmbient(1.0);
415 myOutLineProp->SetDiffuse(0.0);
416 myOutLineProp->SetSpecular(0.0);
417 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
418 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
419 myOutLineProp->SetPointSize(aElem0DSize); // ??
420 myOutLineProp->SetLineWidth(aLineWidth);
421 myOutLineProp->SetRepresentation(1);
423 myPreselectProp = vtkProperty::New();
424 myPreselectProp->SetAmbient(1.0);
425 myPreselectProp->SetDiffuse(0.0);
426 myPreselectProp->SetSpecular(0.0);
427 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
428 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
429 myPreselectProp->SetPointSize(aElem0DSize); // ??
430 myPreselectProp->SetLineWidth(aLineWidth);
431 myPreselectProp->SetRepresentation(1);
433 myHighlitableActor = SMESH_DeviceActor::New();
434 myHighlitableActor->SetUserMatrix(aMatrix);
435 myHighlitableActor->PickableOff();
436 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
437 myHighlitableActor->SetCoincident3DAllowed(true);
444 myControlMode = eNone;
445 myControlActor = my2DActor;
447 //Definition of myScalarBarActor
448 //------------------------------
449 myLookupTable = vtkLookupTable::New();
450 //Fix for Bug PAL5195 - SMESH764:
451 //Controls - Aspect Ratio: incorrect colors of the best and worst values
452 myLookupTable->SetHueRange(0.667,0.0);
454 myScalarBarActor = SMESH_ScalarBarActor::New();
455 myScalarBarActor->SetVisibility(false);
456 myScalarBarActor->SetLookupTable(myLookupTable);
459 //Incorrect "Min value" in Scalar Bar in Mesh:
460 // myScalarBarActor->SetLabelFormat("%.4g");
461 // changes was commented because of regression bug IPAL 19981
463 mgr = SUIT_Session::session()->resourceMgr();
467 myEntityMode = eAllEntity;
468 myEntityModeCache = eAllEntity;
471 myImplicitBoolean = vtkImplicitBoolean::New();
472 myImplicitBoolean->SetOperationTypeToIntersection();
474 //Quadratic 2D elements representation
475 //-----------------------------------------------------------------------------
476 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
477 if(aQuadratic2DMode == 0){
478 myHighlitableActor->SetQuadraticArcMode(false);
479 my2DActor->SetQuadraticArcMode(false);
480 my1DActor->SetQuadraticArcMode(false);
482 else if(aQuadratic2DMode == 1){
483 myHighlitableActor->SetQuadraticArcMode(true);
484 my2DActor->SetQuadraticArcMode(true);
485 my1DActor->SetQuadraticArcMode(true);
488 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
489 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
490 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
492 // Set colors of the name actor
493 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
494 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
495 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
496 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
498 #ifndef DISABLE_PLOT2DVIEWER
505 SMESH_ActorDef::~SMESH_ActorDef()
507 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
509 #ifndef DISABLE_PLOT2DVIEWER
511 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
512 delete my2dHistogram;
516 myScalarBarActor->Delete();
517 myLookupTable->Delete();
519 mySurfaceProp->Delete();
520 myBackSurfaceProp->Delete();
521 myOutLineProp->Delete();
523 myEdgeProp->Delete();
524 myHighlightProp->Delete();
525 myPreselectProp->Delete();
527 myNodeProp->Delete();
528 myNodeExtProp->Delete();
532 myBallActor->Delete();
534 //my0DExtProp->Delete();
535 //my0DExtActor->Delete();
540 my1DExtProp->Delete();
541 my1DExtActor->Delete();
544 my2DExtProp->Delete();
545 my2DExtActor->Delete();
547 my3DExtActor->Delete();
549 myNodeActor->Delete();
550 myBaseActor->Delete();
552 myNodeExtActor->Delete();
553 myHighlitableActor->Delete();
555 myImplicitBoolean->Delete();
557 myTimeStamp->Delete();
560 void SMESH_ActorDef::Delete()
562 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
563 // from the actor's destructor) will be thrown before removing the actor's observers,
564 // that is done inside the Superclass::Delete() method but before the destructor itself
565 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
566 // The event is caught by SMESHGUI::ProcessEvents() static method.
567 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
569 Superclass::Delete();
572 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
575 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
576 SetRepresentation(GetRepresentation());
577 myTimeStamp->Modified();
581 bool SMESH_ActorDef::GetPointsLabeled() {
582 return myNodeActor && myNodeActor->GetPointsLabeled();
585 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
588 my3DActor->SetCellsLabeled(theIsCellsLabeled);
591 my2DActor->SetCellsLabeled(theIsCellsLabeled);
594 my1DActor->SetCellsLabeled(theIsCellsLabeled);
597 my0DActor->SetCellsLabeled(theIsCellsLabeled);
600 myBallActor->SetCellsLabeled(theIsCellsLabeled);
602 myTimeStamp->Modified();
606 bool SMESH_ActorDef::GetCellsLabeled() {
609 result = result || my3DActor->GetCellsLabeled();
612 result = result || my2DActor->GetCellsLabeled();
615 result = result || my1DActor->GetCellsLabeled();
618 result = result || my0DActor->GetCellsLabeled();
621 result = result || myBallActor->GetCellsLabeled();
627 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
629 myIsFacesOriented = theIsFacesOriented;
631 my2DActor->SetFacesOriented(theIsFacesOriented);
632 my3DActor->SetFacesOriented(theIsFacesOriented);
634 myTimeStamp->Modified();
637 bool SMESH_ActorDef::GetFacesOriented()
639 return myIsFacesOriented;
642 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
644 my2DActor->SetFacesOrientationColor( theColor );
645 my3DActor->SetFacesOrientationColor( theColor );
648 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
650 my3DActor->GetFacesOrientationColor( theColor );
653 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
655 my2DActor->SetFacesOrientationScale( theScale );
656 my3DActor->SetFacesOrientationScale( theScale );
659 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
661 return my3DActor->GetFacesOrientationScale();
664 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
666 my2DActor->SetFacesOrientation3DVectors( theState );
667 my3DActor->SetFacesOrientation3DVectors( theState );
670 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
672 return my3DActor->GetFacesOrientation3DVectors();
678 SetControlMode(eControl theMode)
680 SetControlMode(theMode,true);
686 SetControlMode(eControl theMode,
687 bool theCheckEntityMode)
689 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
693 myControlMode = eNone;
694 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
696 my0DActor->GetMapper()->SetScalarVisibility(false);
697 my1DActor->GetMapper()->SetScalarVisibility(false);
698 my2DActor->GetMapper()->SetScalarVisibility(false);
699 my3DActor->GetMapper()->SetScalarVisibility(false);
700 myBallActor->GetMapper()->SetScalarVisibility(false);
701 myScalarBarActor->SetVisibility(false);
703 bool anIsScalarVisible = theMode > eNone;
705 if(anIsScalarVisible) {
709 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
710 aControl->SetPrecision( myControlsPrecision );
711 myFunctor.reset( aControl );
712 myControlActor = my1DActor;
717 myFunctor.reset(new SMESH::Controls::Length2D());
718 myControlActor = my2DActor;
722 myFunctor.reset(new SMESH::Controls::FreeBorders());
723 myControlActor = my1DActor;
726 myFunctor.reset(new SMESH::Controls::FreeEdges());
727 myControlActor = my2DActor;
730 myFunctor.reset(new SMESH::Controls::FreeNodes());
731 myControlActor = myNodeActor;
734 myFunctor.reset(new SMESH::Controls::FreeFaces());
735 myControlActor = my2DActor;
737 case eCoincidentNodes:
739 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
740 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
741 cn->SetTolerance( tol );
743 myControlActor = myNodeActor;
746 case eCoincidentElems1D:
747 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
748 myControlActor = my1DActor;
750 case eCoincidentElems2D:
751 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
752 myControlActor = my2DActor;
754 case eCoincidentElems3D:
755 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
756 myControlActor = my3DActor;
758 case eBareBorderFace:
759 myFunctor.reset(new SMESH::Controls::BareBorderFace());
760 myControlActor = my2DActor;
762 case eOverConstrainedFace:
763 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
764 myControlActor = my2DActor;
766 case eMultiConnection:
767 myFunctor.reset(new SMESH::Controls::MultiConnection());
768 myControlActor = my1DActor;
770 case eMultiConnection2D:
771 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
772 myControlActor = my2DActor;
776 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
777 aControl->SetPrecision( myControlsPrecision );
778 myFunctor.reset( aControl );
779 myControlActor = my2DActor;
784 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
785 aControl->SetPrecision( myControlsPrecision );
786 myFunctor.reset( aControl );
787 myControlActor = my2DActor;
792 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
793 aControl->SetPrecision( myControlsPrecision );
794 myFunctor.reset( aControl );
795 myControlActor = my2DActor;
800 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
801 aControl->SetPrecision( myControlsPrecision );
802 myFunctor.reset( aControl );
803 myControlActor = my3DActor;
808 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
809 aControl->SetPrecision( myControlsPrecision );
810 myFunctor.reset( aControl );
811 myControlActor = my3DActor;
814 case eMaxElementLength2D:
816 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
817 aControl->SetPrecision( myControlsPrecision );
818 myFunctor.reset( aControl );
819 myControlActor = my2DActor;
822 case eMaxElementLength3D:
824 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
825 aControl->SetPrecision( myControlsPrecision );
826 myFunctor.reset( aControl );
827 myControlActor = my3DActor;
830 case eBareBorderVolume:
832 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
833 myControlActor = my3DActor;
836 case eOverConstrainedVolume:
838 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
839 myControlActor = my3DActor;
844 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
845 aControl->SetPrecision( myControlsPrecision );
846 myFunctor.reset( aControl );
847 myControlActor = my2DActor;
852 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
853 aControl->SetPrecision( myControlsPrecision );
854 myFunctor.reset( aControl );
855 myControlActor = my2DActor;
860 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
861 aControl->SetPrecision( myControlsPrecision );
862 myFunctor.reset( aControl );
863 myControlActor = my2DActor;
870 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
871 vtkIdType aNbCells = aGrid->GetNumberOfCells();
873 myControlMode = theMode;
874 switch(myControlMode){
876 case eCoincidentNodes:
877 myNodeExtActor->SetExtControlMode(myFunctor);
881 case eCoincidentElems1D:
882 my1DExtActor->SetExtControlMode(myFunctor);
885 case eBareBorderFace:
886 case eOverConstrainedFace:
887 case eCoincidentElems2D:
888 my2DExtActor->SetExtControlMode(myFunctor);
890 case eBareBorderVolume:
891 case eOverConstrainedVolume:
892 case eCoincidentElems3D:
893 my3DExtActor->SetExtControlMode(myFunctor);
896 case eMultiConnection2D:
897 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
898 UpdateDistribution();
901 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
902 UpdateDistribution();
906 if(theCheckEntityMode) {
907 if(myControlActor == my1DActor) {
908 if (!myIsEntityModeCache){
909 myEntityModeCache = GetEntityMode();
910 myIsEntityModeCache=true;
912 SetEntityMode(eEdges);
914 else if(myControlActor == my2DActor) {
915 switch(myControlMode) {
919 case eMultiConnection2D:
920 if (!myIsEntityModeCache){
921 myEntityModeCache = GetEntityMode();
922 myIsEntityModeCache=true;
924 SetEntityMode(eFaces);
927 if (!myIsEntityModeCache){
928 myEntityModeCache = GetEntityMode();
929 myIsEntityModeCache=true;
931 SetEntityMode(eFaces);
933 }else if(myControlActor == my3DActor) {
934 if (!myIsEntityModeCache){
935 myEntityModeCache = GetEntityMode();
936 myIsEntityModeCache=true;
938 SetEntityMode(eVolumes);
944 if(theCheckEntityMode){
945 myEntityMode = myEntityModeCache;
946 myIsEntityModeCache = false;
951 SetRepresentation(GetRepresentation());
953 myTimeStamp->Modified();
959 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
960 theRenderer->AddActor(myBaseActor);
961 theRenderer->AddActor(myNodeExtActor);
962 theRenderer->AddActor(my1DExtActor);
964 my3DActor ->AddToRender(theRenderer);
965 my3DExtActor->AddToRender(theRenderer);
966 my2DActor ->AddToRender(theRenderer);
967 my2DExtActor->AddToRender(theRenderer);
968 myNodeActor ->AddToRender(theRenderer);
969 my1DActor ->AddToRender(theRenderer);
970 my0DActor ->AddToRender(theRenderer);
971 myBallActor ->AddToRender(theRenderer);
972 //theRenderer->AddActor(my0DExtActor);
974 theRenderer->AddActor(myHighlitableActor);
976 theRenderer->AddActor2D(myScalarBarActor);
978 // the superclass' method should be called at the end
979 // (in particular, for correct work of selection)
980 SALOME_Actor::AddToRender(theRenderer);
983 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
984 SALOME_Actor::RemoveFromRender(theRenderer);
986 theRenderer->RemoveActor(myBaseActor);
988 theRenderer->RemoveActor(myNodeExtActor);
990 theRenderer->RemoveActor(myHighlitableActor);
992 //theRenderer->RemoveActor(my0DExtActor);
994 theRenderer->RemoveActor(my1DExtActor);
996 my2DActor->RemoveFromRender(theRenderer);
997 my2DExtActor->RemoveFromRender(theRenderer);
998 my3DActor->RemoveFromRender(theRenderer);
999 my3DExtActor->RemoveFromRender(theRenderer);
1000 myNodeActor->RemoveFromRender(theRenderer);
1001 my0DActor->RemoveFromRender(theRenderer);
1002 myBallActor->RemoveFromRender(theRenderer);
1003 my1DActor->RemoveFromRender(theRenderer);
1005 theRenderer->RemoveActor(myScalarBarActor);
1009 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1010 const char* theEntry,
1011 const char* theName,
1014 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1018 myVisualObj = theVisualObj;
1019 myVisualObj->Update(theIsClear);
1021 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1022 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1024 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1026 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1028 my0DActor->Init(myVisualObj,myImplicitBoolean);
1029 myBallActor->Init(myVisualObj,myImplicitBoolean);
1030 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1032 my1DActor->Init(myVisualObj,myImplicitBoolean);
1033 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1035 my2DActor->Init(myVisualObj,myImplicitBoolean);
1036 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1037 my3DActor->Init(myVisualObj,myImplicitBoolean);
1038 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1040 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1041 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1042 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1044 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1045 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1047 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1048 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1049 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1050 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1052 vtkFloatingPointType aFactor, aUnits;
1053 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1054 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1055 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1057 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1061 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1062 SetIsShrunkable(true);
1064 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1066 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1067 SetRepresentation(-1);
1070 SetRepresentation(eEdge);
1071 }else if(aMode == 1){
1072 SetRepresentation(eSurface);
1073 }else if(aMode == 2){
1074 SetRepresentation(ePoint);
1081 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1082 SetIsDisplayNameActor( true );
1084 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1085 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1086 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1088 myTimeStamp->Modified();
1094 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1095 return myNodeActor->GetBounds();
1099 vtkDataSet* SMESH_ActorDef::GetInput(){
1100 return GetUnstructuredGrid();
1104 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1105 Superclass::SetTransform(theTransform);
1107 myNodeActor->SetTransform(theTransform);
1108 myBaseActor->SetTransform(theTransform);
1110 myHighlitableActor->SetTransform(theTransform);
1112 myNodeExtActor->SetTransform(theTransform);
1114 my0DActor->SetTransform(theTransform);
1115 myBallActor->SetTransform(theTransform);
1116 //my0DExtActor->SetTransform(theTransform);
1118 my1DActor->SetTransform(theTransform);
1119 my1DExtActor->SetTransform(theTransform);
1121 my2DActor->SetTransform(theTransform);
1122 my2DExtActor->SetTransform(theTransform);
1123 my3DActor->SetTransform(theTransform);
1124 my3DExtActor->SetTransform(theTransform);
1130 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1131 vtkLODActor::SetMapper(theMapper);
1135 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1136 SALOME_Actor::ShallowCopy(prop);
1140 vtkMapper* SMESH_ActorDef::GetMapper(){
1141 return myPickableActor->GetMapper();
1145 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1146 return myVisualObj->GetUnstructuredGrid();
1150 bool SMESH_ActorDef::IsInfinitive(){
1151 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1153 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1154 ( aDataSet->GetNumberOfCells() == 1 &&
1155 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1156 return SALOME_Actor::IsInfinitive();
1160 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1161 if ( myIsShrinkable == theShrunkable )
1163 myIsShrinkable = theShrunkable;
1167 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1168 return myBaseActor->GetShrinkFactor();
1171 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1172 myBaseActor->SetShrinkFactor(theValue);
1174 my1DActor->SetShrinkFactor(theValue);
1175 my1DExtActor->SetShrinkFactor(theValue);
1177 my2DActor->SetShrinkFactor(theValue);
1178 my2DExtActor->SetShrinkFactor(theValue);
1179 my3DActor->SetShrinkFactor(theValue);
1180 my3DExtActor->SetShrinkFactor(theValue);
1181 my3DExtActor->SetShrinkFactor(theValue);
1182 myHighlitableActor->SetShrinkFactor(theValue);
1187 void SMESH_ActorDef::SetShrink(){
1188 if(!myIsShrinkable) return;
1190 myBaseActor->SetShrink();
1192 my1DActor->SetShrink();
1193 my1DExtActor->SetShrink();
1195 my2DActor->SetShrink();
1196 my2DExtActor->SetShrink();
1197 my3DActor->SetShrink();
1198 my3DExtActor->SetShrink();
1199 myHighlitableActor->SetShrink();
1205 void SMESH_ActorDef::UnShrink(){
1206 if(!myIsShrunk) return;
1208 myBaseActor->UnShrink();
1210 my1DActor->UnShrink();
1211 my1DExtActor->UnShrink();
1213 my2DActor->UnShrink();
1214 my2DExtActor->UnShrink();
1215 my3DActor->UnShrink();
1216 my3DExtActor->UnShrink();
1217 myHighlitableActor->UnShrink();
1224 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1225 return myPickableActor->GetNodeObjId(theVtkID);
1228 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1229 return myPickableActor->GetNodeCoord(theObjID);
1233 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1234 return myPickableActor->GetElemObjId(theVtkID);
1237 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1238 return myPickableActor->GetElemCell(theObjID);
1242 void SMESH_ActorDef::SetVisibility(int theMode){
1243 SetVisibility(theMode,true);
1247 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1248 SALOME_Actor::SetVisibility(theMode);
1250 myNodeActor->VisibilityOff();
1251 myBaseActor->VisibilityOff();
1253 myNodeExtActor->VisibilityOff();
1255 my0DActor->VisibilityOff();
1256 myBallActor->VisibilityOff();
1257 //my0DExtActor->VisibilityOff();
1259 my1DActor->VisibilityOff();
1260 my1DExtActor->VisibilityOff();
1262 my2DActor->VisibilityOff();
1263 my2DExtActor->VisibilityOff();
1264 my3DActor->VisibilityOff();
1265 my3DExtActor->VisibilityOff();
1267 myScalarBarActor->VisibilityOff();
1269 if(GetVisibility()){
1270 if(theIsUpdateRepersentation)
1271 SetRepresentation(GetRepresentation());
1273 if(myControlMode != eNone){
1274 switch(myControlMode){
1276 case eCoincidentNodes:
1277 myNodeExtActor->VisibilityOn();
1281 case eCoincidentElems1D:
1282 my1DExtActor->VisibilityOn();
1285 case eBareBorderFace:
1286 case eOverConstrainedFace:
1287 case eCoincidentElems2D:
1288 my2DExtActor->VisibilityOn();
1290 case eBareBorderVolume:
1291 case eOverConstrainedVolume:
1292 case eCoincidentElems3D:
1293 my3DExtActor->VisibilityOn();
1296 case eMultiConnection2D:
1297 my1DExtActor->VisibilityOn();
1299 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1300 myScalarBarActor->VisibilityOn();
1304 if(myRepresentation != ePoint)
1305 myPickableActor->VisibilityOn();
1307 myNodeActor->VisibilityOn();
1310 if(myEntityMode & e0DElements){
1311 my0DActor->VisibilityOn();
1313 if(myEntityMode & eBallElem){
1314 myBallActor->VisibilityOn();
1317 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1318 my1DActor->VisibilityOn();
1321 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1322 my2DActor->VisibilityOn();
1325 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1326 my3DActor->VisibilityOn();
1329 if(myNodeActor->GetPointsLabeled()){
1330 myNodeActor->VisibilityOn();
1334 my0DActor->UpdateLabels();
1337 myBallActor->UpdateLabels();
1340 my1DActor->UpdateLabels();
1343 my2DActor->UpdateLabels();
1346 my3DActor->UpdateLabels();
1348 #ifndef DISABLE_PLOT2DVIEWER
1350 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1357 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1359 myEntityState = eAllEntity;
1361 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1362 myEntityState &= ~e0DElements;
1363 theMode &= ~e0DElements;
1366 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1367 myEntityState &= ~eBallElem;
1368 theMode &= ~eBallElem;
1371 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1372 myEntityState &= ~eEdges;
1376 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1377 myEntityState &= ~eFaces;
1381 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1382 myEntityState &= ~eVolumes;
1383 theMode &= ~eVolumes;
1387 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1388 theMode |= e0DElements;
1390 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1391 theMode |= eBallElem;
1393 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1396 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1399 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1400 theMode |= eVolumes;
1403 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1405 myEntityMode = theMode;
1406 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1407 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1408 aFilter->ClearRegisteredCellsWithType();
1409 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1411 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1412 aHightFilter->ClearRegisteredCellsWithType();
1413 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1415 if (myEntityMode & e0DElements) {
1416 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1417 aFilter->RegisterCellsWithType(VTK_VERTEX);
1418 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1421 if (myEntityMode & eBallElem) {
1422 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1423 aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1426 if (myEntityMode & eEdges) {
1427 if (MYDEBUG) MESSAGE("EDGES");
1428 aFilter->RegisterCellsWithType(VTK_LINE);
1429 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1431 aHightFilter->RegisterCellsWithType(VTK_LINE);
1432 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1435 if (myEntityMode & eFaces) {
1436 if (MYDEBUG) MESSAGE("FACES");
1437 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1438 aFilter->RegisterCellsWithType(VTK_POLYGON);
1439 aFilter->RegisterCellsWithType(VTK_QUAD);
1440 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1441 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1442 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1444 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1445 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1446 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1447 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1448 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1449 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1452 if (myEntityMode & eVolumes) {
1453 if (MYDEBUG) MESSAGE("VOLUMES");
1454 aFilter->RegisterCellsWithType(VTK_TETRA);
1455 aFilter->RegisterCellsWithType(VTK_VOXEL);
1456 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1457 aFilter->RegisterCellsWithType(VTK_WEDGE);
1458 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1459 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1460 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1461 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1462 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1463 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1464 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1465 //#ifdef VTK_HAVE_POLYHEDRON
1466 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1469 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1470 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1471 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1472 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1473 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1474 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1475 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1476 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1477 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1478 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1479 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1480 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1481 //#ifdef VTK_HAVE_POLYHEDRON
1482 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1486 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1487 SetVisibility(GetVisibility(),false);
1490 void SMESH_ActorDef::SetRepresentation (int theMode)
1492 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1493 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1494 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1497 myRepresentation = eSurface;
1498 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1499 myRepresentation = eEdge;
1500 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1501 myRepresentation = ePoint;
1506 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1509 if (!aNbFaces && !aNbVolumes) return;
1512 myRepresentation = theMode;
1515 if (!GetUnstructuredGrid()->GetNumberOfCells())
1516 myRepresentation = ePoint;
1519 if (myRepresentation == ePoint) {
1527 myPickableActor = myBaseActor;
1528 myNodeActor->SetVisibility(false);
1529 myNodeExtActor->SetVisibility(false);
1530 vtkProperty *aProp = NULL, *aBackProp = NULL;
1531 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1532 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1533 switch (myRepresentation) {
1535 myPickableActor = myNodeActor;
1536 myNodeActor->SetVisibility(true);
1537 aQuadraticMode = SMESH_Actor::eLines;
1538 aProp = aBackProp = myNodeProp;
1539 aReperesent = SMESH_DeviceActor::ePoint;
1542 aProp = aBackProp = myEdgeProp;
1543 aReperesent = SMESH_DeviceActor::eInsideframe;
1546 aProp = mySurfaceProp;
1547 aBackProp = myBackSurfaceProp;
1548 aReperesent = SMESH_DeviceActor::eSurface;
1552 my2DActor->SetProperty(aProp);
1553 my2DActor->SetBackfaceProperty(aBackProp);
1554 my2DActor->SetRepresentation(aReperesent);
1556 if(aQuadraticMode == SMESH_Actor::eLines)
1557 my2DActor->SetQuadraticArcMode(false);
1558 else if(aQuadraticMode == SMESH_Actor::eArcs)
1559 my2DActor->SetQuadraticArcMode(true);
1561 my2DExtActor->SetRepresentation(aReperesent);
1563 my3DActor->SetProperty(aProp);
1564 my3DActor->SetBackfaceProperty(aBackProp);
1565 my3DActor->SetRepresentation(aReperesent);
1567 //my0DExtActor->SetVisibility(false);
1568 my1DExtActor->SetVisibility(false);
1569 my2DExtActor->SetVisibility(false);
1570 my3DExtActor->SetVisibility(false);
1573 //my0DActor->SetProperty(aProp);
1574 //my0DActor->SetBackfaceProperty(aBackProp);
1575 my0DActor->SetRepresentation(aReperesent);
1576 myBallActor->SetRepresentation(aReperesent);
1577 //my0DExtActor->SetRepresentation(aReperesent);
1579 switch(myControlMode){
1581 case eMultiConnection:
1582 aProp = aBackProp = my1DProp;
1583 if(myRepresentation != ePoint)
1584 aReperesent = SMESH_DeviceActor::eInsideframe;
1588 if(aQuadraticMode == SMESH_Actor::eLines)
1589 my1DActor->SetQuadraticArcMode(false);
1590 else if(aQuadraticMode == SMESH_Actor::eArcs)
1591 my1DActor->SetQuadraticArcMode(true);
1593 my1DActor->SetProperty(aProp);
1594 my1DActor->SetBackfaceProperty(aBackProp);
1595 my1DActor->SetRepresentation(aReperesent);
1597 my1DExtActor->SetRepresentation(aReperesent);
1599 if(myIsPointsVisible)
1600 myPickableActor = myNodeActor;
1601 if(GetPointRepresentation())
1602 myNodeActor->SetVisibility(true);
1604 SetMapper(myPickableActor->GetMapper());
1606 SetVisibility(GetVisibility(),false);
1612 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1613 if ( myIsPointsVisible == theIsPointsVisible )
1615 myIsPointsVisible = theIsPointsVisible;
1616 SetRepresentation(GetRepresentation());
1619 bool SMESH_ActorDef::GetPointRepresentation(){
1620 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1624 void SMESH_ActorDef::UpdateHighlight(){
1625 myHighlitableActor->SetHighlited(false);
1626 myHighlitableActor->SetVisibility(false);
1628 bool anIsVisible = GetVisibility();
1630 switch(myRepresentation){
1631 case SMESH_DeviceActor::eSurface:
1632 case SMESH_DeviceActor::eWireframe:
1634 if(myIsHighlighted) {
1635 myHighlitableActor->SetProperty(myHighlightProp);
1636 }else if(myIsPreselected){
1637 myHighlitableActor->SetProperty(myPreselectProp);
1638 } else if(anIsVisible){
1639 (myRepresentation == eSurface) ?
1640 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1642 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1643 myHighlitableActor->SetHighlited(anIsVisible);
1644 myHighlitableActor->GetExtractUnstructuredGrid()->
1645 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1646 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1648 myHighlitableActor->SetVisibility(anIsVisible);
1651 case SMESH_DeviceActor::ePoint:
1653 if(myIsHighlighted) {
1654 myNodeActor->SetProperty(myHighlightProp);
1655 }else if(myIsPreselected) {
1656 myNodeActor->SetProperty(myPreselectProp);
1657 } else if(anIsVisible) {
1658 myNodeActor->SetProperty(myNodeProp);
1660 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1661 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1668 void SMESH_ActorDef::highlight(bool theHighlight){
1669 if ( myIsHighlighted == theHighlight )
1671 myIsHighlighted = theHighlight;
1676 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1677 if ( myIsPreselected == thePreselect )
1679 myIsPreselected = thePreselect;
1685 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1687 if (myPickableActor->GetIsOpaque())
1689 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1697 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1699 if (!myPickableActor->GetIsOpaque())
1701 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1709 void SMESH_ActorDef::Render(vtkRenderer *ren){
1710 unsigned long aTime = myTimeStamp->GetMTime();
1711 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1712 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1713 if(anObjTime > aTime || aClippingTime > aTime)
1718 void SMESH_ActorDef::Update(){
1719 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1721 if(GetControlMode() != eNone) {
1722 unsigned long aTime = myTimeStamp->GetMTime();
1723 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1724 if (anObjTime > aTime)
1725 SetControlMode(GetControlMode(),false);
1729 myNodeActor->UpdateLabels();
1732 my0DActor->UpdateLabels();
1735 myBallActor->UpdateLabels();
1738 my1DActor->UpdateLabels();
1741 my2DActor->UpdateLabels();
1744 my3DActor->UpdateLabels();
1746 if(myIsFacesOriented){
1747 SetFacesOriented(myIsFacesOriented);
1750 if(myVisualObj->GetEntitiesFlag()) {
1751 myEntityMode |= myVisualObj->GetEntitiesState();
1754 SetEntityMode(GetEntityMode());
1755 SetVisibility(GetVisibility());
1757 myTimeStamp->Modified();
1762 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1763 SALOME_Actor::ReleaseGraphicsResources(renWin);
1765 myPickableActor->ReleaseGraphicsResources(renWin);
1769 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1770 vtkFloatingPointType* aColor = theProperty->GetColor();
1777 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1778 mySurfaceProp->SetOpacity(theValue);
1779 myBackSurfaceProp->SetOpacity(theValue);
1780 myEdgeProp->SetOpacity(theValue);
1781 myNodeProp->SetOpacity(theValue);
1783 my1DProp->SetOpacity(theValue);
1787 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1788 return mySurfaceProp->GetOpacity();
1792 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1793 mySurfaceProp->SetColor(r,g,b);
1794 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1795 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1796 aGroupObj->GetElementType() == SMDSAbs_Volume )
1797 myNameActor->SetBackgroundColor(r,g,b);
1799 myDeltaBrightness = delta;
1800 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1801 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1805 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1806 ::GetColor(mySurfaceProp,r,g,b);
1807 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1808 delta = myDeltaBrightness;
1811 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1812 myEdgeProp->SetColor(r,g,b);
1813 my1DProp->SetColor(r,g,b);
1814 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1815 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1816 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1817 myNameActor->SetBackgroundColor(r,g,b);
1821 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1822 ::GetColor(myEdgeProp,r,g,b);
1825 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1826 myOutLineProp->SetColor(r,g,b);
1830 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1831 ::GetColor(myOutLineProp,r,g,b);
1835 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1836 myNodeProp->SetColor(r,g,b);
1837 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1838 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1839 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1840 myNameActor->SetBackgroundColor(r,g,b);
1844 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1845 ::GetColor(myNodeProp,r,g,b);
1848 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1849 my0DProp->SetColor(r,g,b);
1850 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1851 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1852 myNameActor->SetBackgroundColor(r,g,b);
1856 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1857 ::GetColor(my0DProp,r,g,b);
1860 void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1861 myBallProp->SetColor(r,g,b);
1862 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1863 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
1864 myNameActor->SetBackgroundColor(r,g,b);
1868 void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1869 ::GetColor(myBallProp,r,g,b);
1872 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1873 myHighlightProp->SetColor(r,g,b);
1877 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1878 ::GetColor(myHighlightProp,r,g,b);
1881 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1882 myPreselectProp->SetColor(r,g,b);
1886 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1887 ::GetColor(myPreselectProp,r,g,b);
1891 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1892 return myEdgeProp->GetLineWidth();
1896 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1897 myEdgeProp->SetLineWidth(theVal);
1899 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1900 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1901 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
1902 myOutLineProp->SetLineWidth(theVal);
1903 myHighlightProp->SetLineWidth(theVal);
1904 myPreselectProp->SetLineWidth(theVal);
1909 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1910 my0DProp->SetPointSize(theVal);
1914 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1915 return my0DProp->GetPointSize();
1918 void SMESH_ActorDef::SetBallSize(vtkFloatingPointType theVal){
1919 myBallProp->SetPointSize(theVal);
1923 vtkFloatingPointType SMESH_ActorDef::GetBallSize(){
1924 return myBallProp->GetPointSize();
1927 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1929 return myVisualObj->GetElemDimension( theObjId );
1934 IsImplicitFunctionUsed() const
1936 return myBaseActor->IsImplicitFunctionUsed();
1940 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1942 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1943 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1945 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1947 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1949 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1950 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1951 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1953 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1954 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1956 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1957 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1958 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1959 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1963 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1966 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1967 myCippingPlaneCont.push_back(thePlane);
1968 if(!IsImplicitFunctionUsed())
1969 SetImplicitFunctionUsed(true);
1970 myNodeActor->UpdateLabels();
1972 return myCippingPlaneCont.size();
1977 RemoveAllClippingPlanes()
1979 myImplicitBoolean->GetFunction()->RemoveAllItems();
1980 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1981 myCippingPlaneCont.clear();
1982 SetImplicitFunctionUsed(false);
1983 myNodeActor->UpdateLabels();
1988 GetNumberOfClippingPlanes()
1990 return myCippingPlaneCont.size();
1995 GetClippingPlane(vtkIdType theID)
1997 if(theID >= myCippingPlaneCont.size())
1999 return myCippingPlaneCont[theID].Get();
2002 void SMESH_ActorDef::UpdateScalarBar()
2004 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2008 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2010 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2011 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2013 aScalarBarTitleProp->SetFontFamilyToArial();
2015 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2017 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2018 if ( f.family() == "Arial" )
2019 aScalarBarTitleProp->SetFontFamilyToArial();
2020 else if ( f.family() == "Courier" )
2021 aScalarBarTitleProp->SetFontFamilyToCourier();
2022 else if ( f.family() == "Times" )
2023 aScalarBarTitleProp->SetFontFamilyToTimes();
2026 aScalarBarTitleProp->BoldOn();
2028 aScalarBarTitleProp->BoldOff();
2031 aScalarBarTitleProp->ItalicOn();
2033 aScalarBarTitleProp->ItalicOff();
2036 aScalarBarTitleProp->ShadowOn();
2038 aScalarBarTitleProp->ShadowOff();
2041 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2042 aScalarBarTitleProp->Delete();
2044 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2046 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2047 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2049 aScalarBarLabelProp->SetFontFamilyToArial();
2050 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2052 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2053 if( f.family() == "Arial" )
2054 aScalarBarLabelProp->SetFontFamilyToArial();
2055 else if( f.family() == "Courier" )
2056 aScalarBarLabelProp->SetFontFamilyToCourier();
2057 else if( f.family() == "Times" )
2058 aScalarBarLabelProp->SetFontFamilyToTimes();
2061 aScalarBarLabelProp->BoldOn();
2063 aScalarBarLabelProp->BoldOff();
2066 aScalarBarLabelProp->ItalicOn();
2068 aScalarBarLabelProp->ItalicOff();
2071 aScalarBarLabelProp->ShadowOn();
2073 aScalarBarLabelProp->ShadowOff();
2076 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2077 aScalarBarLabelProp->Delete();
2079 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2080 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2082 myScalarBarActor->SetOrientationToHorizontal();
2084 myScalarBarActor->SetOrientationToVertical();
2087 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2088 if( mgr->hasValue( "SMESH", name + "x" ) )
2089 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2091 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2092 if( mgr->hasValue( "SMESH", name + "y" ) )
2093 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2094 myScalarBarActor->SetPosition( aXVal, aYVal );
2096 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2097 if( mgr->hasValue( "SMESH", name + "width" ) )
2098 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2099 myScalarBarActor->SetWidth( aWVal );
2101 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2102 if( mgr->hasValue( "SMESH", name + "height" ) )
2103 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2104 myScalarBarActor->SetHeight( aHVal );
2107 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2108 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2109 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2112 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2113 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2114 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2116 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2117 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2119 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2120 myScalarBarActor->SetDistributionColoringType(coloringType);
2122 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2123 QColor(255, 255, 255));
2125 rgb[0]= distributionColor.red()/255.;
2126 rgb[1]= distributionColor.green()/255.;
2127 rgb[2]= distributionColor.blue()/255.;
2128 myScalarBarActor->SetDistributionColor(rgb);
2133 void SMESH_ActorDef::UpdateDistribution()
2135 if(SMESH::Controls::NumericalFunctor* fun =
2136 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2138 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2139 std::vector<int> nbEvents;
2140 std::vector<double> funValues;
2141 SMESH_VisualObjDef::TEntityList elems;
2142 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2143 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2144 std::vector<int> elemIds;
2145 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2146 elemIds.push_back( (*e)->GetID());
2147 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2148 double * range = lookupTable->GetRange();
2149 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2150 myScalarBarActor->SetDistribution(nbEvents);
2154 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2157 case SMESH_Actor::eLines :
2158 myHighlitableActor->SetQuadraticArcMode(false);
2159 my2DActor->SetQuadraticArcMode(false);
2160 my1DActor->SetQuadraticArcMode(false);
2162 case SMESH_Actor::eArcs :
2163 myHighlitableActor->SetQuadraticArcMode(true);
2164 if(GetRepresentation() != SMESH_Actor::ePoint) {
2165 my2DActor->SetQuadraticArcMode(true);
2166 my1DActor->SetQuadraticArcMode(true);
2175 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2177 if(myHighlitableActor->GetQuadraticArcMode())
2178 return SMESH_Actor::eArcs;
2180 return SMESH_Actor::eLines;
2183 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2185 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2186 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2187 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2190 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2192 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2193 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2194 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2195 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2198 #ifndef DISABLE_PLOT2DVIEWER
2199 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2202 my2dHistogram->clearAllPoints();
2204 if(SMESH::Controls::NumericalFunctor* fun =
2205 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2208 if(!my2dHistogram) {
2209 my2dHistogram = new SPlot2d_Histogram();
2210 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2211 my2dHistogram->setIO(anIO);
2214 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2215 std::vector<int> nbEvents;
2216 std::vector<double> funValues;
2217 SMESH_VisualObjDef::TEntityList elems;
2218 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2219 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2220 std::vector<int> elemIds;
2222 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2223 elemIds.push_back( (*e)->GetID());
2225 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2226 double * range = lookupTable->GetRange();
2227 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2229 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2230 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2232 if(funValues.size() >= 2)
2233 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2237 //Color of the histogram
2238 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2239 my2dHistogram->setAutoAssign(true);
2242 myScalarBarActor->GetDistributionColor(rgb);
2243 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2244 my2dHistogram->setColor(aColor);
2248 return my2dHistogram;