1 // Copyright (C) 2007-2011 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_ObjectDef.h"
32 #include "SMESH_ControlsDef.hxx"
33 #include "SMDS_UnstructuredGrid.hxx"
34 #include "SMESH_ScalarBarActor.h"
35 #include "VTKViewer_CellCenters.h"
36 #include "VTKViewer_DataSetMapper.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"
44 #ifndef DISABLE_PLOT2DVIEWER
45 #include <SPlot2d_Histogram.h>
48 #include <vtkProperty.h>
49 #include <vtkTimeStamp.h>
50 #include <vtkObjectFactory.h>
51 #include <vtkShrinkPolyData.h>
52 #include <vtkMergeFilter.h>
54 #include <vtkMatrix4x4.h>
55 #include <vtkUnstructuredGrid.h>
56 #include <vtkPointData.h>
57 #include <vtkCellData.h>
59 #include <vtkMapper.h>
60 #include <vtkRenderer.h>
63 #include <vtkIdList.h>
64 #include <vtkIntArray.h>
66 #include <vtkActor2D.h>
67 #include <vtkProperty2D.h>
68 #include <vtkPolyData.h>
69 #include <vtkMaskPoints.h>
70 #include <vtkTextProperty.h>
71 #include <vtkLabeledDataMapper.h>
72 #include <vtkSelectVisiblePoints.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);
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
129 myIsShrinkable = false;
132 myIsFacesOriented = false;
134 myControlsPrecision = -1;
135 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
137 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
138 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
140 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
141 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
143 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
144 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
146 //Definition 2D and 3D devices of the actor
147 //-----------------------------------------
148 vtkFloatingPointType anRGB[3] = {1,1,1};
149 mySurfaceProp = vtkProperty::New();
150 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
151 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
153 myBackSurfaceProp = vtkProperty::New();
154 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
155 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
157 my2DActor = SMESH_DeviceActor::New();
158 my2DActor->SetUserMatrix(aMatrix);
159 my2DActor->PickableOff();
160 my2DActor->SetProperty(mySurfaceProp);
161 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
162 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
163 aFilter = my2DActor->GetExtractUnstructuredGrid();
164 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
165 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
166 aFilter->RegisterCellsWithType(VTK_POLYGON);
167 aFilter->RegisterCellsWithType(VTK_QUAD);
168 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
169 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
171 my2DExtProp = vtkProperty::New();
172 my2DExtProp->DeepCopy(mySurfaceProp);
173 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
174 anRGB[0] = 1 - anRGB[0];
175 anRGB[1] = 1 - anRGB[1];
176 anRGB[2] = 1 - anRGB[2];
177 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
179 my2DExtActor = SMESH_DeviceActor::New();
180 my2DExtActor->SetUserMatrix(aMatrix);
181 my2DExtActor->PickableOff();
182 my2DExtActor->SetProperty(my2DExtProp);
183 my2DExtActor->SetBackfaceProperty(my2DExtProp);
184 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
185 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
186 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
187 aFilter->RegisterCellsWithType(VTK_POLYGON);
188 aFilter->RegisterCellsWithType(VTK_QUAD);
189 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
190 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
192 my3DActor = SMESH_DeviceActor::New();
193 my3DActor->SetUserMatrix(aMatrix);
194 my3DActor->PickableOff();
195 my3DActor->SetProperty(mySurfaceProp);
196 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
197 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
198 aFilter = my3DActor->GetExtractUnstructuredGrid();
199 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
200 aFilter->RegisterCellsWithType(VTK_TETRA);
201 aFilter->RegisterCellsWithType(VTK_VOXEL);
202 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
203 aFilter->RegisterCellsWithType(VTK_WEDGE);
204 aFilter->RegisterCellsWithType(VTK_PYRAMID);
205 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
206 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
207 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
208 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
209 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
210 //#ifdef VTK_HAVE_POLYHEDRON
211 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
212 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
215 my3DExtActor = SMESH_DeviceActor::New();
216 my3DExtActor->SetUserMatrix(aMatrix);
217 my3DExtActor->PickableOff();
218 my3DExtActor->SetProperty(my2DExtProp);
219 my3DExtActor->SetBackfaceProperty(my2DExtProp);
220 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
221 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
222 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
223 aFilter->RegisterCellsWithType(VTK_TETRA);
224 aFilter->RegisterCellsWithType(VTK_VOXEL);
225 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
226 aFilter->RegisterCellsWithType(VTK_WEDGE);
227 aFilter->RegisterCellsWithType(VTK_PYRAMID);
228 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
229 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
231 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
232 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
233 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
235 //Definition 1D device of the actor
236 //---------------------------------
237 myEdgeProp = vtkProperty::New();
238 myEdgeProp->SetAmbient(1.0);
239 myEdgeProp->SetDiffuse(0.0);
240 myEdgeProp->SetSpecular(0.0);
241 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
242 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
243 myEdgeProp->SetLineWidth(aLineWidth);
245 my1DActor = SMESH_DeviceActor::New();
246 my1DActor->SetUserMatrix(aMatrix);
247 my1DActor->PickableOff();
248 my1DActor->SetHighlited(true);
249 my1DActor->SetProperty(myEdgeProp);
250 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
251 aFilter = my1DActor->GetExtractUnstructuredGrid();
252 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
253 aFilter->RegisterCellsWithType(VTK_LINE);
254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
256 my1DProp = vtkProperty::New();
257 my1DProp->DeepCopy(myEdgeProp);
258 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
259 my1DProp->SetPointSize(aElem0DSize);
261 my1DExtProp = vtkProperty::New();
262 my1DExtProp->DeepCopy(myEdgeProp);
263 anRGB[0] = 1 - anRGB[0];
264 anRGB[1] = 1 - anRGB[1];
265 anRGB[2] = 1 - anRGB[2];
266 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
267 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
268 my1DExtProp->SetPointSize(aElem0DSize);
270 my1DExtActor = SMESH_DeviceActor::New();
271 my1DExtActor->SetUserMatrix(aMatrix);
272 my1DExtActor->PickableOff();
273 my1DExtActor->SetHighlited(true);
274 my1DExtActor->SetVisibility(false);
275 my1DExtActor->SetProperty(my1DExtProp);
276 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
277 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
278 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
279 aFilter->RegisterCellsWithType(VTK_LINE);
280 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
283 //Definition 0D device of the actor (0d elements)
284 //-----------------------------------------------
285 my0DProp = vtkProperty::New();
286 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
287 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
288 my0DProp->SetPointSize(aElem0DSize);
290 my0DActor = SMESH_DeviceActor::New();
291 my0DActor->SetUserMatrix(aMatrix);
292 my0DActor->SetStoreClippingMapping(true);
293 my0DActor->PickableOff();
294 my0DActor->SetVisibility(false);
295 my0DActor->SetProperty(my0DProp);
296 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
297 aFilter = my0DActor->GetExtractUnstructuredGrid();
298 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
299 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
300 aFilter->RegisterCellsWithType(VTK_VERTEX);
302 //my0DExtProp = vtkProperty::New();
303 //my0DExtProp->DeepCopy(my0DProp);
304 //anRGB[0] = 1 - anRGB[0];
305 //anRGB[1] = 1 - anRGB[1];
306 //anRGB[2] = 1 - anRGB[2];
307 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
308 //my0DExtProp->SetPointSize(aElem0DSize);
310 //my0DExtActor = SMESH_DeviceActor::New();
311 //my0DExtActor->SetUserMatrix(aMatrix);
312 //my0DExtActor->SetStoreClippingMapping(true);
313 //my0DExtActor->PickableOff();
314 //my0DExtActor->SetHighlited(true);
315 //my0DExtActor->SetVisibility(false);
316 //my0DExtActor->SetProperty(my0DExtProp);
317 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
318 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
319 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
320 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
321 //aFilter->RegisterCellsWithType(VTK_VERTEX);
324 //Definition 0D device of the actor (nodes)
325 //-----------------------------------------
326 myNodeProp = vtkProperty::New();
327 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
328 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
330 myNodeActor = SMESH_DeviceActor::New();
331 myNodeActor->SetUserMatrix(aMatrix);
332 myNodeActor->SetStoreClippingMapping(true);
333 myNodeActor->PickableOff();
334 myNodeActor->SetVisibility(false);
335 myNodeActor->SetProperty(myNodeProp);
336 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
337 aFilter = myNodeActor->GetExtractUnstructuredGrid();
338 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
340 myNodeExtProp = vtkProperty::New();
341 myNodeExtProp->DeepCopy(myNodeProp);
342 anRGB[0] = 1 - anRGB[0];
343 anRGB[1] = 1 - anRGB[1];
344 anRGB[2] = 1 - anRGB[2];
345 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
347 myNodeExtActor = SMESH_DeviceActor::New();
348 myNodeExtActor->SetUserMatrix(aMatrix);
349 myNodeExtActor->SetStoreClippingMapping(true);
350 myNodeExtActor->PickableOff();
351 myNodeExtActor->SetHighlited(true);
352 myNodeExtActor->SetVisibility(false);
353 myNodeExtActor->SetProperty(myNodeExtProp);
354 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
355 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
356 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
357 aFilter->RegisterCellsWithType(VTK_VERTEX);
359 //Definition of Pickable and Highlitable engines
360 //----------------------------------------------
362 myBaseActor = SMESH_DeviceActor::New();
363 myBaseActor->SetUserMatrix(aMatrix);
364 myBaseActor->SetStoreGemetryMapping(true);
365 myBaseActor->GetProperty()->SetOpacity(0.0);
367 myPickableActor = myBaseActor;
369 // VSR 13/07/2011: Revert back previous fix for issue 0020749 since it causes regressions, see issues 0021322, 0021323
370 // To be removed later or fix to be improved
371 //myMapper = VTKViewer_DataSetMapper::New();
372 //myMapper->SetInput( myPickableActor->GetUnstructuredGrid() );
374 myHighlightProp = vtkProperty::New();
375 myHighlightProp->SetAmbient(1.0);
376 myHighlightProp->SetDiffuse(0.0);
377 myHighlightProp->SetSpecular(0.0);
378 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
379 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
380 myHighlightProp->SetPointSize(aElem0DSize); // ??
381 myHighlightProp->SetRepresentation(1);
383 myPreselectProp = vtkProperty::New();
384 myPreselectProp->SetAmbient(1.0);
385 myPreselectProp->SetDiffuse(0.0);
386 myPreselectProp->SetSpecular(0.0);
387 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
388 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
389 myPreselectProp->SetPointSize(aElem0DSize); // ??
390 myPreselectProp->SetRepresentation(1);
392 myHighlitableActor = SMESH_DeviceActor::New();
393 myHighlitableActor->SetUserMatrix(aMatrix);
394 myHighlitableActor->PickableOff();
395 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
402 myControlMode = eNone;
403 myControlActor = my2DActor;
405 //Definition of myScalarBarActor
406 //------------------------------
407 myLookupTable = vtkLookupTable::New();
408 //Fix for Bug PAL5195 - SMESH764:
409 //Controls - Aspect Ratio: incorrect colors of the best and worst values
410 myLookupTable->SetHueRange(0.667,0.0);
412 myScalarBarActor = SMESH_ScalarBarActor::New();
413 myScalarBarActor->SetVisibility(false);
414 myScalarBarActor->SetLookupTable(myLookupTable);
417 //Incorrect "Min value" in Scalar Bar in Mesh:
418 // myScalarBarActor->SetLabelFormat("%.4g");
419 // changes was commented because of regression bug IPAL 19981
421 mgr = SUIT_Session::session()->resourceMgr();
425 //Definition of points numbering pipeline
426 //---------------------------------------
427 myPointsNumDataSet = vtkUnstructuredGrid::New();
429 myPtsMaskPoints = vtkMaskPoints::New();
430 myPtsMaskPoints->SetInput(myPointsNumDataSet);
431 myPtsMaskPoints->SetOnRatio(1);
433 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
434 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
435 myPtsSelectVisiblePoints->SelectInvisibleOff();
436 myPtsSelectVisiblePoints->SetTolerance(0.1);
438 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
439 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
440 #if (VTK_XVERSION < 0x050200)
441 myPtsLabeledDataMapper->SetLabelFormat("%g");
443 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
445 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
446 aPtsTextProp->SetFontFamilyToTimes();
447 static int aPointsFontSize = 10;
448 aPtsTextProp->SetFontSize(aPointsFontSize);
449 aPtsTextProp->SetBold(1);
450 aPtsTextProp->SetItalic(0);
451 aPtsTextProp->SetShadow(0);
452 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
453 aPtsTextProp->Delete();
455 myEntityMode = eAllEntity;
457 myIsPointsLabeled = false;
459 myPointLabels = vtkActor2D::New();
460 myPointLabels->SetMapper(myPtsLabeledDataMapper);
461 myPointLabels->GetProperty()->SetColor(1,1,1);
462 myPointLabels->SetVisibility(myIsPointsLabeled);
465 //Definition of cells numbering pipeline
466 //---------------------------------------
467 myCellsNumDataSet = vtkUnstructuredGrid::New();
469 myCellCenters = VTKViewer_CellCenters::New();
470 myCellCenters->SetInput(myCellsNumDataSet);
472 myClsMaskPoints = vtkMaskPoints::New();
473 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
474 myClsMaskPoints->SetOnRatio(1);
476 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
477 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
478 myClsSelectVisiblePoints->SelectInvisibleOff();
479 myClsSelectVisiblePoints->SetTolerance(0.1);
481 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
482 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
483 #if (VTK_XVERSION < 0x050200)
484 myClsLabeledDataMapper->SetLabelFormat("%g");
486 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
488 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
489 aClsTextProp->SetFontFamilyToTimes();
490 static int aCellsFontSize = 12;
491 aClsTextProp->SetFontSize(aCellsFontSize);
492 aClsTextProp->SetBold(1);
493 aClsTextProp->SetItalic(0);
494 aClsTextProp->SetShadow(0);
495 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
496 aClsTextProp->Delete();
498 myIsCellsLabeled = false;
500 myCellsLabels = vtkActor2D::New();
501 myCellsLabels->SetMapper(myClsLabeledDataMapper);
502 myCellsLabels->GetProperty()->SetColor(0,1,0);
503 myCellsLabels->SetVisibility(myIsCellsLabeled);
506 myImplicitBoolean = vtkImplicitBoolean::New();
507 myImplicitBoolean->SetOperationTypeToIntersection();
511 //Quadratic 2D elements representation
512 //-----------------------------------------------------------------------------
513 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
514 if(aQuadratic2DMode == 0){
515 myHighlitableActor->SetQuadraticArcMode(false);
516 my2DActor->SetQuadraticArcMode(false);
517 my1DActor->SetQuadraticArcMode(false);
519 else if(aQuadratic2DMode == 1){
520 myHighlitableActor->SetQuadraticArcMode(true);
521 my2DActor->SetQuadraticArcMode(true);
522 my1DActor->SetQuadraticArcMode(true);
525 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
526 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
527 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
529 // Set colors of the name actor
530 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
531 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
532 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
533 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
535 #ifndef DISABLE_PLOT2DVIEWER
542 SMESH_ActorDef::~SMESH_ActorDef()
544 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
546 #ifndef DISABLE_PLOT2DVIEWER
548 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
549 delete my2dHistogram;
553 // caught by SMESHGUI::ProcessEvents() static method
554 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
556 myScalarBarActor->Delete();
557 myLookupTable->Delete();
559 mySurfaceProp->Delete();
560 myBackSurfaceProp->Delete();
562 myEdgeProp->Delete();
563 myHighlightProp->Delete();
564 myPreselectProp->Delete();
566 myNodeProp->Delete();
567 myNodeExtProp->Delete();
572 //my0DExtProp->Delete();
573 //my0DExtActor->Delete();
578 my1DExtProp->Delete();
579 my1DExtActor->Delete();
582 my2DExtProp->Delete();
583 my2DExtActor->Delete();
585 my3DExtActor->Delete();
587 myNodeActor->Delete();
588 myBaseActor->Delete();
590 myNodeExtActor->Delete();
592 myHighlitableActor->Delete();
594 //Deleting of points numbering pipeline
595 //---------------------------------------
596 myPointsNumDataSet->Delete();
598 // commented: porting to vtk 5.0
599 // myPtsLabeledDataMapper->RemoveAllInputs();
600 myPtsLabeledDataMapper->Delete();
602 // commented: porting to vtk 5.0
603 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
604 myPtsSelectVisiblePoints->Delete();
606 // commented: porting to vtk 5.0
607 // myPtsMaskPoints->UnRegisterAllOutputs();
608 myPtsMaskPoints->Delete();
610 myPointLabels->Delete();
613 //Deleting of cells numbering pipeline
614 //---------------------------------------
615 myCellsNumDataSet->Delete();
617 myClsLabeledDataMapper->RemoveAllInputs();
618 myClsLabeledDataMapper->Delete();
620 // commented: porting to vtk 5.0
621 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
622 myClsSelectVisiblePoints->Delete();
624 // commented: porting to vtk 5.0
625 // myClsMaskPoints->UnRegisterAllOutputs();
626 myClsMaskPoints->Delete();
628 // commented: porting to vtk 5.0
629 // myCellCenters->UnRegisterAllOutputs();
630 myCellCenters->Delete();
632 myCellsLabels->Delete();
634 myImplicitBoolean->Delete();
636 // VSR 13/07/2011: Revert back previous fix for issue 0020749 since it causes regressions, see issues 0021322, 0021323
637 // To be removed later or fix to be improved
638 //myMapper->Delete();
640 myTimeStamp->Delete();
644 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
646 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
648 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
650 if ( myIsPointsLabeled )
652 myPointsNumDataSet->ShallowCopy(aGrid);
653 vtkDataSet *aDataSet = myPointsNumDataSet;
655 int aNbElem = aDataSet->GetNumberOfPoints();
657 vtkIntArray *anArray = vtkIntArray::New();
658 anArray->SetNumberOfValues( aNbElem );
660 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
662 int aSMDSId = myVisualObj->GetNodeObjId( anId );
663 anArray->SetValue( anId, aSMDSId );
666 aDataSet->GetPointData()->SetScalars( anArray );
668 myPtsMaskPoints->SetInput( aDataSet );
669 myPointLabels->SetVisibility( GetVisibility() );
673 myPointLabels->SetVisibility( false );
675 SetRepresentation(GetRepresentation());
676 myTimeStamp->Modified();
680 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
682 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
683 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
684 if(myIsCellsLabeled){
685 myCellsNumDataSet->ShallowCopy(aGrid);
686 vtkDataSet *aDataSet = myCellsNumDataSet;
687 int aNbElem = aDataSet->GetNumberOfCells();
688 vtkIntArray *anArray = vtkIntArray::New();
689 anArray->SetNumberOfValues(aNbElem);
690 for(int anId = 0; anId < aNbElem; anId++){
691 int aSMDSId = myVisualObj->GetElemObjId(anId);
692 anArray->SetValue(anId,aSMDSId);
694 aDataSet->GetCellData()->SetScalars(anArray);
695 myCellCenters->SetInput(aDataSet);
696 myCellsLabels->SetVisibility(GetVisibility());
698 myCellsLabels->SetVisibility(false);
700 myTimeStamp->Modified();
704 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
706 myIsFacesOriented = theIsFacesOriented;
708 my2DActor->SetFacesOriented(theIsFacesOriented);
709 my3DActor->SetFacesOriented(theIsFacesOriented);
711 myTimeStamp->Modified();
714 bool SMESH_ActorDef::GetFacesOriented()
716 return myIsFacesOriented;
719 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
721 my2DActor->SetFacesOrientationColor( theColor );
722 my3DActor->SetFacesOrientationColor( theColor );
725 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
727 my3DActor->GetFacesOrientationColor( theColor );
730 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
732 my2DActor->SetFacesOrientationScale( theScale );
733 my3DActor->SetFacesOrientationScale( theScale );
736 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
738 return my3DActor->GetFacesOrientationScale();
741 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
743 my2DActor->SetFacesOrientation3DVectors( theState );
744 my3DActor->SetFacesOrientation3DVectors( theState );
747 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
749 return my3DActor->GetFacesOrientation3DVectors();
755 SetControlMode(eControl theMode)
757 SetControlMode(theMode,true);
763 SetControlMode(eControl theMode,
764 bool theCheckEntityMode)
766 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
770 myControlMode = eNone;
771 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
773 my0DActor->GetMapper()->SetScalarVisibility(false);
774 my1DActor->GetMapper()->SetScalarVisibility(false);
775 my2DActor->GetMapper()->SetScalarVisibility(false);
776 my3DActor->GetMapper()->SetScalarVisibility(false);
777 myScalarBarActor->SetVisibility(false);
779 bool anIsScalarVisible = theMode > eNone;
781 if(anIsScalarVisible) {
785 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
786 aControl->SetPrecision( myControlsPrecision );
787 myFunctor.reset( aControl );
788 myControlActor = my1DActor;
793 myFunctor.reset(new SMESH::Controls::Length2D());
794 myControlActor = my2DActor;
798 myFunctor.reset(new SMESH::Controls::FreeBorders());
799 myControlActor = my1DActor;
802 myFunctor.reset(new SMESH::Controls::FreeEdges());
803 myControlActor = my2DActor;
806 myFunctor.reset(new SMESH::Controls::FreeNodes());
807 myControlActor = myNodeActor;
810 myFunctor.reset(new SMESH::Controls::FreeFaces());
811 myControlActor = my2DActor;
813 case eBareBorderFace:
814 myFunctor.reset(new SMESH::Controls::BareBorderFace());
815 myControlActor = my2DActor;
817 case eOverConstrainedFace:
818 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
819 myControlActor = my2DActor;
821 case eMultiConnection:
822 myFunctor.reset(new SMESH::Controls::MultiConnection());
823 myControlActor = my1DActor;
825 case eMultiConnection2D:
826 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
827 myControlActor = my2DActor;
831 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
832 aControl->SetPrecision( myControlsPrecision );
833 myFunctor.reset( aControl );
834 myControlActor = my2DActor;
839 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
840 aControl->SetPrecision( myControlsPrecision );
841 myFunctor.reset( aControl );
842 myControlActor = my2DActor;
847 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
848 aControl->SetPrecision( myControlsPrecision );
849 myFunctor.reset( aControl );
850 myControlActor = my2DActor;
855 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
856 aControl->SetPrecision( myControlsPrecision );
857 myFunctor.reset( aControl );
858 myControlActor = my3DActor;
863 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
864 aControl->SetPrecision( myControlsPrecision );
865 myFunctor.reset( aControl );
866 myControlActor = my3DActor;
869 case eMaxElementLength2D:
871 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
872 aControl->SetPrecision( myControlsPrecision );
873 myFunctor.reset( aControl );
874 myControlActor = my2DActor;
877 case eMaxElementLength3D:
879 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
880 aControl->SetPrecision( myControlsPrecision );
881 myFunctor.reset( aControl );
882 myControlActor = my3DActor;
885 case eBareBorderVolume:
887 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
888 myControlActor = my3DActor;
891 case eOverConstrainedVolume:
893 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
894 myControlActor = my3DActor;
899 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
900 aControl->SetPrecision( myControlsPrecision );
901 myFunctor.reset( aControl );
902 myControlActor = my2DActor;
907 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
908 aControl->SetPrecision( myControlsPrecision );
909 myFunctor.reset( aControl );
910 myControlActor = my2DActor;
915 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
916 aControl->SetPrecision( myControlsPrecision );
917 myFunctor.reset( aControl );
918 myControlActor = my2DActor;
925 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
926 vtkIdType aNbCells = aGrid->GetNumberOfCells();
928 myControlMode = theMode;
929 switch(myControlMode){
931 myNodeExtActor->SetExtControlMode(myFunctor);
935 my1DExtActor->SetExtControlMode(myFunctor);
938 case eBareBorderFace:
939 case eOverConstrainedFace:
940 my2DExtActor->SetExtControlMode(myFunctor);
942 case eBareBorderVolume:
943 case eOverConstrainedVolume:
944 my3DExtActor->SetExtControlMode(myFunctor);
947 case eMultiConnection2D:
948 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
949 UpdateDistribution();
952 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
953 UpdateDistribution();
957 if(theCheckEntityMode){
958 if(myControlActor == my1DActor)
959 SetEntityMode(eEdges);
960 else if(myControlActor == my2DActor){
961 switch(myControlMode){
965 case eMultiConnection2D:
966 //SetEntityMode(eEdges);
967 SetEntityMode(eFaces);
970 SetEntityMode(eFaces);
972 }else if(myControlActor == my3DActor)
973 SetEntityMode(eVolumes);
978 if(theCheckEntityMode)
979 myEntityMode = eAllEntity;
983 SetRepresentation(GetRepresentation());
985 myTimeStamp->Modified();
990 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
991 theRenderer->AddActor(myNodeActor);
992 theRenderer->AddActor(myBaseActor);
994 theRenderer->AddActor(myNodeExtActor);
996 my3DActor->AddToRender(theRenderer);
997 my3DExtActor->AddToRender(theRenderer);
998 my2DActor->AddToRender(theRenderer);
999 my2DExtActor->AddToRender(theRenderer);
1001 theRenderer->AddActor(my1DActor);
1002 theRenderer->AddActor(my1DExtActor);
1004 theRenderer->AddActor(my0DActor);
1005 //theRenderer->AddActor(my0DExtActor);
1007 theRenderer->AddActor(myHighlitableActor);
1009 theRenderer->AddActor2D(myScalarBarActor);
1011 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
1012 myClsSelectVisiblePoints->SetRenderer(theRenderer);
1014 theRenderer->AddActor2D(myPointLabels);
1015 theRenderer->AddActor2D(myCellsLabels);
1017 // the superclass' method should be called at the end
1018 // (in particular, for correct work of selection)
1019 SALOME_Actor::AddToRender(theRenderer);
1022 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1023 SALOME_Actor::RemoveFromRender(theRenderer);
1025 theRenderer->RemoveActor(myNodeActor);
1026 theRenderer->RemoveActor(myBaseActor);
1028 theRenderer->RemoveActor(myNodeExtActor);
1030 theRenderer->RemoveActor(myHighlitableActor);
1032 theRenderer->RemoveActor(my0DActor);
1033 //theRenderer->RemoveActor(my0DExtActor);
1035 theRenderer->RemoveActor(my1DActor);
1036 theRenderer->RemoveActor(my1DExtActor);
1038 my2DActor->RemoveFromRender(theRenderer);
1039 my2DExtActor->RemoveFromRender(theRenderer);
1040 my3DActor->RemoveFromRender(theRenderer);
1041 my3DExtActor->RemoveFromRender(theRenderer);
1043 theRenderer->RemoveActor(myScalarBarActor);
1044 theRenderer->RemoveActor(myPointLabels);
1045 theRenderer->RemoveActor(myCellsLabels);
1049 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1050 const char* theEntry,
1051 const char* theName,
1054 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1058 myVisualObj = theVisualObj;
1059 myVisualObj->Update(theIsClear);
1061 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1062 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1064 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1066 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1068 my0DActor->Init(myVisualObj,myImplicitBoolean);
1069 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1071 my1DActor->Init(myVisualObj,myImplicitBoolean);
1072 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1074 my2DActor->Init(myVisualObj,myImplicitBoolean);
1075 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1076 my3DActor->Init(myVisualObj,myImplicitBoolean);
1077 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1079 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1080 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1082 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1083 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1085 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1086 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1087 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1088 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1090 vtkFloatingPointType aFactor, aUnits;
1091 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1092 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1093 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1095 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1099 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1100 SetIsShrunkable(true);
1102 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1104 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1105 SetRepresentation(-1);
1108 SetRepresentation(eEdge);
1109 }else if(aMode == 1){
1110 SetRepresentation(eSurface);
1111 }else if(aMode == 2){
1112 SetRepresentation(ePoint);
1119 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1120 SetIsDisplayNameActor( true );
1122 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1123 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1124 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1126 myTimeStamp->Modified();
1132 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1133 return myNodeActor->GetBounds();
1137 vtkDataSet* SMESH_ActorDef::GetInput(){
1138 return GetUnstructuredGrid();
1142 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1143 Superclass::SetTransform(theTransform);
1145 myNodeActor->SetTransform(theTransform);
1146 myBaseActor->SetTransform(theTransform);
1148 myHighlitableActor->SetTransform(theTransform);
1150 myNodeExtActor->SetTransform(theTransform);
1152 my0DActor->SetTransform(theTransform);
1153 //my0DExtActor->SetTransform(theTransform);
1155 my1DActor->SetTransform(theTransform);
1156 my1DExtActor->SetTransform(theTransform);
1158 my2DActor->SetTransform(theTransform);
1159 my2DExtActor->SetTransform(theTransform);
1160 my3DActor->SetTransform(theTransform);
1161 my3DExtActor->SetTransform(theTransform);
1167 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1168 vtkLODActor::SetMapper(theMapper);
1172 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1173 SALOME_Actor::ShallowCopy(prop);
1177 vtkMapper* SMESH_ActorDef::GetMapper(){
1178 // VSR 13/07/2011: Revert back previous fix for issue 0020749 since it causes regressions, see issues 0021322, 0021323
1179 // To be removed later or fix to be improved
1181 return myPickableActor->GetMapper();
1185 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1186 return myVisualObj->GetUnstructuredGrid();
1190 bool SMESH_ActorDef::IsInfinitive(){
1191 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1193 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1194 ( aDataSet->GetNumberOfCells() == 1 &&
1195 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1196 return SALOME_Actor::IsInfinitive();
1200 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1201 if ( myIsShrinkable == theShrunkable )
1203 myIsShrinkable = theShrunkable;
1207 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1208 return myBaseActor->GetShrinkFactor();
1211 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1212 myBaseActor->SetShrinkFactor(theValue);
1214 my1DActor->SetShrinkFactor(theValue);
1215 my1DExtActor->SetShrinkFactor(theValue);
1217 my2DActor->SetShrinkFactor(theValue);
1218 my2DExtActor->SetShrinkFactor(theValue);
1219 my3DActor->SetShrinkFactor(theValue);
1220 my3DExtActor->SetShrinkFactor(theValue);
1225 void SMESH_ActorDef::SetShrink(){
1226 if(!myIsShrinkable) return;
1228 myBaseActor->SetShrink();
1230 my1DActor->SetShrink();
1231 my1DExtActor->SetShrink();
1233 my2DActor->SetShrink();
1234 my2DExtActor->SetShrink();
1235 my3DActor->SetShrink();
1236 my3DExtActor->SetShrink();
1242 void SMESH_ActorDef::UnShrink(){
1243 if(!myIsShrunk) return;
1245 myBaseActor->UnShrink();
1247 my1DActor->UnShrink();
1248 my1DExtActor->UnShrink();
1250 my2DActor->UnShrink();
1251 my2DExtActor->UnShrink();
1252 my3DActor->UnShrink();
1253 my3DExtActor->UnShrink();
1260 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1261 return myPickableActor->GetNodeObjId(theVtkID);
1264 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1265 return myPickableActor->GetNodeCoord(theObjID);
1269 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1270 return myPickableActor->GetElemObjId(theVtkID);
1273 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1274 return myPickableActor->GetElemCell(theObjID);
1278 void SMESH_ActorDef::SetVisibility(int theMode){
1279 SetVisibility(theMode,true);
1283 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1284 SALOME_Actor::SetVisibility(theMode);
1286 myNodeActor->VisibilityOff();
1287 myBaseActor->VisibilityOff();
1289 myNodeExtActor->VisibilityOff();
1291 my0DActor->VisibilityOff();
1292 //my0DExtActor->VisibilityOff();
1294 my1DActor->VisibilityOff();
1295 my1DExtActor->VisibilityOff();
1297 my2DActor->VisibilityOff();
1298 my2DExtActor->VisibilityOff();
1299 my3DActor->VisibilityOff();
1300 my3DExtActor->VisibilityOff();
1302 myScalarBarActor->VisibilityOff();
1303 myPointLabels->VisibilityOff();
1304 myCellsLabels->VisibilityOff();
1306 if(GetVisibility()){
1307 if(theIsUpdateRepersentation)
1308 SetRepresentation(GetRepresentation());
1310 if(myControlMode != eNone){
1311 switch(myControlMode){
1313 myNodeExtActor->VisibilityOn();
1317 my1DExtActor->VisibilityOn();
1320 case eBareBorderFace:
1321 case eOverConstrainedFace:
1322 my2DExtActor->VisibilityOn();
1324 case eBareBorderVolume:
1325 case eOverConstrainedVolume:
1326 my3DExtActor->VisibilityOn();
1329 case eMultiConnection2D:
1330 my1DExtActor->VisibilityOn();
1332 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1333 myScalarBarActor->VisibilityOn();
1337 if(myRepresentation != ePoint)
1338 myPickableActor->VisibilityOn();
1340 myNodeActor->VisibilityOn();
1343 if(myEntityMode & e0DElements){
1344 my0DActor->VisibilityOn();
1347 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1348 my1DActor->VisibilityOn();
1351 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1352 my2DActor->VisibilityOn();
1355 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1356 my3DActor->VisibilityOn();
1359 if(myIsPointsLabeled){
1360 myPointLabels->VisibilityOn();
1361 myNodeActor->VisibilityOn();
1364 if(myIsCellsLabeled)
1365 myCellsLabels->VisibilityOn();
1367 #ifndef DISABLE_PLOT2DVIEWER
1369 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1376 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1378 myEntityState = eAllEntity;
1380 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1381 myEntityState &= ~e0DElements;
1382 theMode &= ~e0DElements;
1385 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1386 myEntityState &= ~eEdges;
1390 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1391 myEntityState &= ~eFaces;
1395 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1396 myEntityState &= ~eVolumes;
1397 theMode &= ~eVolumes;
1401 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1402 theMode |= e0DElements;
1404 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1407 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1410 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1411 theMode |= eVolumes;
1414 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1416 myEntityMode = theMode;
1417 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1418 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1419 aFilter->ClearRegisteredCellsWithType();
1420 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1422 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1423 aHightFilter->ClearRegisteredCellsWithType();
1424 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1426 if (myEntityMode & e0DElements) {
1427 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1428 aFilter->RegisterCellsWithType(VTK_VERTEX);
1429 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1432 if (myEntityMode & eEdges) {
1433 if (MYDEBUG) MESSAGE("EDGES");
1434 aFilter->RegisterCellsWithType(VTK_LINE);
1435 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1437 aHightFilter->RegisterCellsWithType(VTK_LINE);
1438 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1441 if (myEntityMode & eFaces) {
1442 if (MYDEBUG) MESSAGE("FACES");
1443 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1444 aFilter->RegisterCellsWithType(VTK_POLYGON);
1445 aFilter->RegisterCellsWithType(VTK_QUAD);
1446 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1447 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1449 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1450 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1451 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1452 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1453 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1456 if (myEntityMode & eVolumes) {
1457 if (MYDEBUG) MESSAGE("VOLUMES");
1458 aFilter->RegisterCellsWithType(VTK_TETRA);
1459 aFilter->RegisterCellsWithType(VTK_VOXEL);
1460 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1461 aFilter->RegisterCellsWithType(VTK_WEDGE);
1462 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1463 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1464 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1465 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1466 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1467 //#ifdef VTK_HAVE_POLYHEDRON
1468 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1471 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1472 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1473 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1474 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1475 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1476 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1477 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_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 //my0DExtActor->SetRepresentation(aReperesent);
1578 switch(myControlMode){
1580 case eMultiConnection:
1581 aProp = aBackProp = my1DProp;
1582 if(myRepresentation != ePoint)
1583 aReperesent = SMESH_DeviceActor::eInsideframe;
1587 if(aQuadraticMode == SMESH_Actor::eLines)
1588 my1DActor->SetQuadraticArcMode(false);
1589 else if(aQuadraticMode == SMESH_Actor::eArcs)
1590 my1DActor->SetQuadraticArcMode(true);
1592 my1DActor->SetProperty(aProp);
1593 my1DActor->SetBackfaceProperty(aBackProp);
1594 my1DActor->SetRepresentation(aReperesent);
1596 my1DExtActor->SetRepresentation(aReperesent);
1598 if(myIsPointsVisible)
1599 myPickableActor = myNodeActor;
1600 if(GetPointRepresentation())
1601 myNodeActor->SetVisibility(true);
1603 SetMapper(myPickableActor->GetMapper());
1605 SetVisibility(GetVisibility(),false);
1611 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1612 if ( myIsPointsVisible == theIsPointsVisible )
1614 myIsPointsVisible = theIsPointsVisible;
1615 SetRepresentation(GetRepresentation());
1618 bool SMESH_ActorDef::GetPointRepresentation(){
1619 return myIsPointsVisible || myIsPointsLabeled;
1623 void SMESH_ActorDef::UpdateHighlight(){
1624 myHighlitableActor->SetVisibility(false);
1625 myHighlitableActor->SetHighlited(false);
1627 if(myIsHighlighted){
1628 myHighlitableActor->SetProperty(myHighlightProp);
1629 }else if(myIsPreselected){
1630 myHighlitableActor->SetProperty(myPreselectProp);
1633 bool anIsVisible = GetVisibility();
1635 if(myIsHighlighted || myIsPreselected){
1636 if(GetUnstructuredGrid()->GetNumberOfCells()){
1637 myHighlitableActor->SetHighlited(anIsVisible);
1638 myHighlitableActor->SetVisibility(anIsVisible);
1639 myHighlitableActor->GetExtractUnstructuredGrid()->
1640 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1641 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1642 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1643 myHighlitableActor->SetHighlited(anIsVisible);
1644 myHighlitableActor->GetExtractUnstructuredGrid()->
1645 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1646 myHighlitableActor->SetVisibility(anIsVisible);
1647 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1649 VTK::MarkerType aMarkerType = GetMarkerType();
1650 if(aMarkerType != VTK::MT_USER)
1651 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1653 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1659 void SMESH_ActorDef::highlight(bool theHighlight){
1660 if ( myIsHighlighted == theHighlight )
1662 myIsHighlighted = theHighlight;
1667 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1668 if ( myIsPreselected == thePreselect )
1670 myIsPreselected = thePreselect;
1676 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1678 if (myPickableActor->GetIsOpaque())
1680 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1688 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1690 if (!myPickableActor->GetIsOpaque())
1692 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1700 void SMESH_ActorDef::Render(vtkRenderer *ren){
1701 unsigned long aTime = myTimeStamp->GetMTime();
1702 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1703 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1704 if(anObjTime > aTime || aClippingTime > aTime)
1709 void SMESH_ActorDef::Update(){
1710 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1712 if(GetControlMode() != eNone) {
1713 unsigned long aTime = myTimeStamp->GetMTime();
1714 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1715 if (anObjTime > aTime)
1716 SetControlMode(GetControlMode(),false);
1718 if(myIsPointsLabeled){
1719 SetPointsLabeled(myIsPointsLabeled);
1721 if(myIsCellsLabeled){
1722 SetCellsLabeled(myIsCellsLabeled);
1724 if(myIsFacesOriented){
1725 SetFacesOriented(myIsFacesOriented);
1727 SetEntityMode(GetEntityMode());
1728 SetVisibility(GetVisibility());
1730 myTimeStamp->Modified();
1735 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1736 SALOME_Actor::ReleaseGraphicsResources(renWin);
1738 myPickableActor->ReleaseGraphicsResources(renWin);
1742 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1743 vtkFloatingPointType* aColor = theProperty->GetColor();
1750 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1751 mySurfaceProp->SetOpacity(theValue);
1752 myBackSurfaceProp->SetOpacity(theValue);
1753 myEdgeProp->SetOpacity(theValue);
1754 myNodeProp->SetOpacity(theValue);
1756 my1DProp->SetOpacity(theValue);
1760 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1761 return mySurfaceProp->GetOpacity();
1765 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1766 mySurfaceProp->SetColor(r,g,b);
1767 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1768 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1769 aGroupObj->GetElementType() == SMDSAbs_Volume )
1770 myNameActor->SetBackgroundColor(r,g,b);
1774 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1775 ::GetColor(mySurfaceProp,r,g,b);
1776 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1779 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1780 myBackSurfaceProp->SetColor(r,g,b);
1784 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1785 ::GetColor(myBackSurfaceProp,r,g,b);
1788 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1789 myEdgeProp->SetColor(r,g,b);
1790 my1DProp->SetColor(r,g,b);
1791 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1792 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1793 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1794 myNameActor->SetBackgroundColor(r,g,b);
1798 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1799 ::GetColor(myEdgeProp,r,g,b);
1802 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1803 myNodeProp->SetColor(r,g,b);
1804 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1805 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1806 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1807 myNameActor->SetBackgroundColor(r,g,b);
1811 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1812 ::GetColor(myNodeProp,r,g,b);
1815 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1816 my0DProp->SetColor(r,g,b);
1817 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1818 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1819 myNameActor->SetBackgroundColor(r,g,b);
1823 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1824 ::GetColor(my0DProp,r,g,b);
1827 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1828 myHighlightProp->SetColor(r,g,b);
1832 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1833 ::GetColor(myHighlightProp,r,g,b);
1836 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1837 myPreselectProp->SetColor(r,g,b);
1841 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1842 ::GetColor(myPreselectProp,r,g,b);
1846 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1847 return myEdgeProp->GetLineWidth();
1851 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1852 myEdgeProp->SetLineWidth(theVal);
1854 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1855 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1861 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1862 my0DProp->SetPointSize(theVal);
1866 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1867 return my0DProp->GetPointSize();
1870 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1872 return myVisualObj->GetElemDimension( theObjId );
1877 IsImplicitFunctionUsed() const
1879 return myBaseActor->IsImplicitFunctionUsed();
1883 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1885 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1886 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1888 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1890 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1892 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1893 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1895 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1896 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1898 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1899 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1900 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1901 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1905 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1908 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1909 myCippingPlaneCont.push_back(thePlane);
1910 if(!IsImplicitFunctionUsed())
1911 SetImplicitFunctionUsed(true);
1913 return myCippingPlaneCont.size();
1918 RemoveAllClippingPlanes()
1920 myImplicitBoolean->GetFunction()->RemoveAllItems();
1921 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1922 myCippingPlaneCont.clear();
1923 SetImplicitFunctionUsed(false);
1928 GetNumberOfClippingPlanes()
1930 return myCippingPlaneCont.size();
1935 GetClippingPlane(vtkIdType theID)
1937 if(theID >= myCippingPlaneCont.size())
1939 return myCippingPlaneCont[theID].Get();
1942 void SMESH_ActorDef::UpdateScalarBar()
1944 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1948 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1950 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1951 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1953 aScalarBarTitleProp->SetFontFamilyToArial();
1955 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1957 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1958 if ( f.family() == "Arial" )
1959 aScalarBarTitleProp->SetFontFamilyToArial();
1960 else if ( f.family() == "Courier" )
1961 aScalarBarTitleProp->SetFontFamilyToCourier();
1962 else if ( f.family() == "Times" )
1963 aScalarBarTitleProp->SetFontFamilyToTimes();
1966 aScalarBarTitleProp->BoldOn();
1968 aScalarBarTitleProp->BoldOff();
1971 aScalarBarTitleProp->ItalicOn();
1973 aScalarBarTitleProp->ItalicOff();
1976 aScalarBarTitleProp->ShadowOn();
1978 aScalarBarTitleProp->ShadowOff();
1981 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1982 aScalarBarTitleProp->Delete();
1984 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1986 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1987 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1989 aScalarBarLabelProp->SetFontFamilyToArial();
1990 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1992 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1993 if( f.family() == "Arial" )
1994 aScalarBarLabelProp->SetFontFamilyToArial();
1995 else if( f.family() == "Courier" )
1996 aScalarBarLabelProp->SetFontFamilyToCourier();
1997 else if( f.family() == "Times" )
1998 aScalarBarLabelProp->SetFontFamilyToTimes();
2001 aScalarBarLabelProp->BoldOn();
2003 aScalarBarLabelProp->BoldOff();
2006 aScalarBarLabelProp->ItalicOn();
2008 aScalarBarLabelProp->ItalicOff();
2011 aScalarBarLabelProp->ShadowOn();
2013 aScalarBarLabelProp->ShadowOff();
2016 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2017 aScalarBarLabelProp->Delete();
2019 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2020 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2022 myScalarBarActor->SetOrientationToHorizontal();
2024 myScalarBarActor->SetOrientationToVertical();
2027 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2028 if( mgr->hasValue( "SMESH", name + "x" ) )
2029 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2031 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2032 if( mgr->hasValue( "SMESH", name + "y" ) )
2033 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2034 myScalarBarActor->SetPosition( aXVal, aYVal );
2036 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2037 if( mgr->hasValue( "SMESH", name + "width" ) )
2038 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2039 myScalarBarActor->SetWidth( aWVal );
2041 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2042 if( mgr->hasValue( "SMESH", name + "height" ) )
2043 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2044 myScalarBarActor->SetHeight( aHVal );
2047 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2048 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2049 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2052 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2053 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2054 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2056 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2057 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2059 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2060 myScalarBarActor->SetDistributionColoringType(coloringType);
2062 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2063 QColor(255, 255, 255));
2065 rgb[0]= distributionColor.red()/255.;
2066 rgb[1]= distributionColor.green()/255.;
2067 rgb[2]= distributionColor.blue()/255.;
2068 myScalarBarActor->SetDistributionColor(rgb);
2073 void SMESH_ActorDef::UpdateDistribution()
2075 if(SMESH::Controls::NumericalFunctor* fun =
2076 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2078 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2079 std::vector<int> nbEvents;
2080 std::vector<double> funValues;
2081 SMESH_VisualObjDef::TEntityList elems;
2082 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2083 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2084 std::vector<int> elemIds;
2085 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2086 elemIds.push_back( (*e)->GetID());
2087 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2088 double * range = lookupTable->GetRange();
2089 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2090 myScalarBarActor->SetDistribution(nbEvents);
2094 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2097 case SMESH_Actor::eLines :
2098 myHighlitableActor->SetQuadraticArcMode(false);
2099 my2DActor->SetQuadraticArcMode(false);
2100 my1DActor->SetQuadraticArcMode(false);
2102 case SMESH_Actor::eArcs :
2103 myHighlitableActor->SetQuadraticArcMode(true);
2104 if(GetRepresentation() != SMESH_Actor::ePoint) {
2105 my2DActor->SetQuadraticArcMode(true);
2106 my1DActor->SetQuadraticArcMode(true);
2115 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2117 if(myHighlitableActor->GetQuadraticArcMode())
2118 return SMESH_Actor::eArcs;
2120 return SMESH_Actor::eLines;
2123 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2125 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2126 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2127 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2130 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2132 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2133 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2134 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2135 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2138 #ifndef DISABLE_PLOT2DVIEWER
2139 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2142 my2dHistogram->clearAllPoints();
2144 if(SMESH::Controls::NumericalFunctor* fun =
2145 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2148 if(!my2dHistogram) {
2149 my2dHistogram = new SPlot2d_Histogram();
2150 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2151 my2dHistogram->setIO(anIO);
2154 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2155 std::vector<int> nbEvents;
2156 std::vector<double> funValues;
2157 SMESH_VisualObjDef::TEntityList elems;
2158 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2159 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2160 std::vector<int> elemIds;
2162 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2163 elemIds.push_back( (*e)->GetID());
2165 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2166 double * range = lookupTable->GetRange();
2167 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2169 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2170 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2172 if(funValues.size() >= 2)
2173 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2177 //Color of the histogram
2178 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2179 my2dHistogram->setAutoAssign(true);
2182 myScalarBarActor->GetDistributionColor(rgb);
2183 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2184 my2dHistogram->setColor(aColor);
2188 return my2dHistogram;