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_ExtractUnstructuredGrid.h"
37 #include "VTKViewer_FramedTextActor.h"
38 #include "SALOME_InteractiveObject.hxx"
40 #include "SUIT_Session.h"
41 #include "SUIT_ResourceMgr.h"
45 #ifndef DISABLE_PLOT2DVIEWER
46 #include <SPlot2d_Histogram.h>
49 #include <vtkProperty.h>
50 #include <vtkTimeStamp.h>
51 #include <vtkObjectFactory.h>
52 #include <vtkShrinkPolyData.h>
53 #include <vtkMergeFilter.h>
55 #include <vtkMatrix4x4.h>
56 #include <vtkUnstructuredGrid.h>
57 #include <vtkPointData.h>
58 #include <vtkCellData.h>
60 #include <vtkMapper.h>
61 #include <vtkRenderer.h>
64 #include <vtkIdList.h>
65 #include <vtkIntArray.h>
67 #include <vtkActor2D.h>
68 #include <vtkProperty2D.h>
69 #include <vtkPolyData.h>
70 #include <vtkMaskPoints.h>
71 #include <vtkTextProperty.h>
72 #include <vtkLabeledDataMapper.h>
73 #include <vtkSelectVisiblePoints.h>
75 #include <vtkLookupTable.h>
79 #include <vtkImplicitBoolean.h>
80 #include <vtkImplicitFunctionCollection.h>
82 #include <vtkConfigure.h>
83 #if !defined(VTK_XVERSION)
84 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
87 #include "utilities.h"
90 static int MYDEBUG = 1;
92 static int MYDEBUG = 1;
95 static int aLineWidthInc = 2;
98 SMESH_ActorDef* SMESH_ActorDef::New(){
99 return new SMESH_ActorDef();
103 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
104 const char* theEntry,
108 SMESH_ActorDef* anActor = NULL;
109 if(theVisualObj->IsValid() ) {
110 anActor = SMESH_ActorDef::New();
111 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
116 anActor->UpdateScalarBar();
122 SMESH_ActorDef::SMESH_ActorDef()
124 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
126 myTimeStamp = vtkTimeStamp::New();
128 myIsPointsVisible = 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 aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
144 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
145 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
147 //Definition 2D and 3D devices of the actor
148 //-----------------------------------------
149 vtkFloatingPointType anRGB[3] = {1,1,1};
150 mySurfaceProp = vtkProperty::New();
153 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
154 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
155 myDeltaBrightness = delta;
157 myBackSurfaceProp = vtkProperty::New();
158 bfc = Qtx::mainColorToSecondary(ffc, delta);
159 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
161 my2DActor = SMESH_DeviceActor::New();
162 my2DActor->SetUserMatrix(aMatrix);
163 my2DActor->PickableOff();
164 my2DActor->SetProperty(mySurfaceProp);
165 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
166 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
167 aFilter = my2DActor->GetExtractUnstructuredGrid();
168 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
169 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
170 aFilter->RegisterCellsWithType(VTK_POLYGON);
171 aFilter->RegisterCellsWithType(VTK_QUAD);
172 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
173 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
175 my2DExtProp = vtkProperty::New();
176 my2DExtProp->DeepCopy(mySurfaceProp);
177 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
178 anRGB[0] = 1 - anRGB[0];
179 anRGB[1] = 1 - anRGB[1];
180 anRGB[2] = 1 - anRGB[2];
181 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
183 my2DExtActor = SMESH_DeviceActor::New();
184 my2DExtActor->SetUserMatrix(aMatrix);
185 my2DExtActor->PickableOff();
186 my2DExtActor->SetProperty(my2DExtProp);
187 my2DExtActor->SetBackfaceProperty(my2DExtProp);
188 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
189 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
190 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
191 aFilter->RegisterCellsWithType(VTK_POLYGON);
192 aFilter->RegisterCellsWithType(VTK_QUAD);
193 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
194 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
196 my3DActor = SMESH_DeviceActor::New();
197 my3DActor->SetUserMatrix(aMatrix);
198 my3DActor->PickableOff();
199 my3DActor->SetProperty(mySurfaceProp);
200 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
201 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
202 aFilter = my3DActor->GetExtractUnstructuredGrid();
203 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
204 aFilter->RegisterCellsWithType(VTK_TETRA);
205 aFilter->RegisterCellsWithType(VTK_VOXEL);
206 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
207 aFilter->RegisterCellsWithType(VTK_WEDGE);
208 aFilter->RegisterCellsWithType(VTK_PYRAMID);
209 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
210 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
211 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
212 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
213 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
214 //#ifdef VTK_HAVE_POLYHEDRON
215 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
216 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
219 my3DExtActor = SMESH_DeviceActor::New();
220 my3DExtActor->SetUserMatrix(aMatrix);
221 my3DExtActor->PickableOff();
222 my3DExtActor->SetProperty(my2DExtProp);
223 my3DExtActor->SetBackfaceProperty(my2DExtProp);
224 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
225 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
226 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
227 aFilter->RegisterCellsWithType(VTK_TETRA);
228 aFilter->RegisterCellsWithType(VTK_VOXEL);
229 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
230 aFilter->RegisterCellsWithType(VTK_WEDGE);
231 aFilter->RegisterCellsWithType(VTK_PYRAMID);
232 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
233 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
234 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
235 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
236 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
237 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
239 //Definition 1D device of the actor
240 //---------------------------------
241 myEdgeProp = vtkProperty::New();
242 myEdgeProp->SetAmbient(1.0);
243 myEdgeProp->SetDiffuse(0.0);
244 myEdgeProp->SetSpecular(0.0);
245 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
246 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
247 myEdgeProp->SetLineWidth(aLineWidth);
249 my1DActor = SMESH_DeviceActor::New();
250 my1DActor->SetUserMatrix(aMatrix);
251 my1DActor->PickableOff();
252 my1DActor->SetHighlited(true);
253 my1DActor->SetProperty(myEdgeProp);
254 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
255 aFilter = my1DActor->GetExtractUnstructuredGrid();
256 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
257 aFilter->RegisterCellsWithType(VTK_LINE);
258 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
260 my1DProp = vtkProperty::New();
261 my1DProp->DeepCopy(myEdgeProp);
262 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
263 my1DProp->SetPointSize(aElem0DSize);
265 my1DExtProp = vtkProperty::New();
266 my1DExtProp->DeepCopy(myEdgeProp);
267 anRGB[0] = 1 - anRGB[0];
268 anRGB[1] = 1 - anRGB[1];
269 anRGB[2] = 1 - anRGB[2];
270 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
271 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
272 my1DExtProp->SetPointSize(aElem0DSize);
274 my1DExtActor = SMESH_DeviceActor::New();
275 my1DExtActor->SetUserMatrix(aMatrix);
276 my1DExtActor->PickableOff();
277 my1DExtActor->SetHighlited(true);
278 my1DExtActor->SetVisibility(false);
279 my1DExtActor->SetProperty(my1DExtProp);
280 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
281 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
282 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
283 aFilter->RegisterCellsWithType(VTK_LINE);
284 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
287 //Definition 0D device of the actor (0d elements)
288 //-----------------------------------------------
289 my0DProp = vtkProperty::New();
290 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
291 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
292 my0DProp->SetPointSize(aElem0DSize);
294 my0DActor = SMESH_DeviceActor::New();
295 my0DActor->SetUserMatrix(aMatrix);
296 my0DActor->SetStoreClippingMapping(true);
297 my0DActor->PickableOff();
298 my0DActor->SetVisibility(false);
299 my0DActor->SetProperty(my0DProp);
300 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
301 aFilter = my0DActor->GetExtractUnstructuredGrid();
302 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
303 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
304 aFilter->RegisterCellsWithType(VTK_VERTEX);
306 //my0DExtProp = vtkProperty::New();
307 //my0DExtProp->DeepCopy(my0DProp);
308 //anRGB[0] = 1 - anRGB[0];
309 //anRGB[1] = 1 - anRGB[1];
310 //anRGB[2] = 1 - anRGB[2];
311 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
312 //my0DExtProp->SetPointSize(aElem0DSize);
314 //my0DExtActor = SMESH_DeviceActor::New();
315 //my0DExtActor->SetUserMatrix(aMatrix);
316 //my0DExtActor->SetStoreClippingMapping(true);
317 //my0DExtActor->PickableOff();
318 //my0DExtActor->SetHighlited(true);
319 //my0DExtActor->SetVisibility(false);
320 //my0DExtActor->SetProperty(my0DExtProp);
321 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
322 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
323 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
324 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
325 //aFilter->RegisterCellsWithType(VTK_VERTEX);
328 //Definition 0D device of the actor (nodes)
329 //-----------------------------------------
330 myNodeProp = vtkProperty::New();
331 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
332 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
334 myNodeActor = SMESH_DeviceActor::New();
335 myNodeActor->SetUserMatrix(aMatrix);
336 myNodeActor->SetStoreClippingMapping(true);
337 myNodeActor->PickableOff();
338 myNodeActor->SetVisibility(false);
339 myNodeActor->SetProperty(myNodeProp);
340 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
341 aFilter = myNodeActor->GetExtractUnstructuredGrid();
342 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
344 myNodeExtProp = vtkProperty::New();
345 myNodeExtProp->DeepCopy(myNodeProp);
346 anRGB[0] = 1 - anRGB[0];
347 anRGB[1] = 1 - anRGB[1];
348 anRGB[2] = 1 - anRGB[2];
349 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
351 myNodeExtActor = SMESH_DeviceActor::New();
352 myNodeExtActor->SetUserMatrix(aMatrix);
353 myNodeExtActor->SetStoreClippingMapping(true);
354 myNodeExtActor->PickableOff();
355 myNodeExtActor->SetHighlited(true);
356 myNodeExtActor->SetVisibility(false);
357 myNodeExtActor->SetProperty(myNodeExtProp);
358 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
359 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
360 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
361 aFilter->RegisterCellsWithType(VTK_VERTEX);
363 //Definition of Pickable and Highlitable engines
364 //----------------------------------------------
366 myBaseActor = SMESH_DeviceActor::New();
367 myBaseActor->SetUserMatrix(aMatrix);
368 myBaseActor->SetStoreGemetryMapping(true);
369 myBaseActor->GetProperty()->SetOpacity(0.0);
371 myPickableActor = myBaseActor;
373 myHighlightProp = vtkProperty::New();
374 myHighlightProp->SetAmbient(1.0);
375 myHighlightProp->SetDiffuse(0.0);
376 myHighlightProp->SetSpecular(0.0);
377 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
378 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
379 myHighlightProp->SetPointSize(aElem0DSize); // ??
380 myHighlightProp->SetRepresentation(1);
382 myOutLineProp = vtkProperty::New();
383 myOutLineProp->SetAmbient(1.0);
384 myOutLineProp->SetDiffuse(0.0);
385 myOutLineProp->SetSpecular(0.0);
386 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
387 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
388 myOutLineProp->SetPointSize(aElem0DSize); // ??
389 myOutLineProp->SetRepresentation(1);
391 myPreselectProp = vtkProperty::New();
392 myPreselectProp->SetAmbient(1.0);
393 myPreselectProp->SetDiffuse(0.0);
394 myPreselectProp->SetSpecular(0.0);
395 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
396 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
397 myPreselectProp->SetPointSize(aElem0DSize); // ??
398 myPreselectProp->SetRepresentation(1);
400 myHighlitableActor = SMESH_DeviceActor::New();
401 myHighlitableActor->SetUserMatrix(aMatrix);
402 myHighlitableActor->PickableOff();
403 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
410 myControlMode = eNone;
411 myControlActor = my2DActor;
413 //Definition of myScalarBarActor
414 //------------------------------
415 myLookupTable = vtkLookupTable::New();
416 //Fix for Bug PAL5195 - SMESH764:
417 //Controls - Aspect Ratio: incorrect colors of the best and worst values
418 myLookupTable->SetHueRange(0.667,0.0);
420 myScalarBarActor = SMESH_ScalarBarActor::New();
421 myScalarBarActor->SetVisibility(false);
422 myScalarBarActor->SetLookupTable(myLookupTable);
425 //Incorrect "Min value" in Scalar Bar in Mesh:
426 // myScalarBarActor->SetLabelFormat("%.4g");
427 // changes was commented because of regression bug IPAL 19981
429 mgr = SUIT_Session::session()->resourceMgr();
433 //Definition of points numbering pipeline
434 //---------------------------------------
435 myPointsNumDataSet = vtkUnstructuredGrid::New();
437 myPtsMaskPoints = vtkMaskPoints::New();
438 myPtsMaskPoints->SetInput(myPointsNumDataSet);
439 myPtsMaskPoints->SetOnRatio(1);
441 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
442 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
443 myPtsSelectVisiblePoints->SelectInvisibleOff();
444 myPtsSelectVisiblePoints->SetTolerance(0.1);
446 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
447 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
448 #if (VTK_XVERSION < 0x050200)
449 myPtsLabeledDataMapper->SetLabelFormat("%g");
451 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
453 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
454 aPtsTextProp->SetFontFamilyToTimes();
455 static int aPointsFontSize = 10;
456 aPtsTextProp->SetFontSize(aPointsFontSize);
457 aPtsTextProp->SetBold(1);
458 aPtsTextProp->SetItalic(0);
459 aPtsTextProp->SetShadow(0);
460 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
461 aPtsTextProp->Delete();
463 myEntityMode = eAllEntity;
465 myIsPointsLabeled = false;
467 myPointLabels = vtkActor2D::New();
468 myPointLabels->SetMapper(myPtsLabeledDataMapper);
469 myPointLabels->GetProperty()->SetColor(1,1,1);
470 myPointLabels->SetVisibility(myIsPointsLabeled);
473 //Definition of cells numbering pipeline
474 //---------------------------------------
475 myCellsNumDataSet = vtkUnstructuredGrid::New();
477 myCellCenters = VTKViewer_CellCenters::New();
478 myCellCenters->SetInput(myCellsNumDataSet);
480 myClsMaskPoints = vtkMaskPoints::New();
481 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
482 myClsMaskPoints->SetOnRatio(1);
484 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
485 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
486 myClsSelectVisiblePoints->SelectInvisibleOff();
487 myClsSelectVisiblePoints->SetTolerance(0.1);
489 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
490 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
491 #if (VTK_XVERSION < 0x050200)
492 myClsLabeledDataMapper->SetLabelFormat("%g");
494 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
496 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
497 aClsTextProp->SetFontFamilyToTimes();
498 static int aCellsFontSize = 12;
499 aClsTextProp->SetFontSize(aCellsFontSize);
500 aClsTextProp->SetBold(1);
501 aClsTextProp->SetItalic(0);
502 aClsTextProp->SetShadow(0);
503 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
504 aClsTextProp->Delete();
506 myIsCellsLabeled = false;
508 myCellsLabels = vtkActor2D::New();
509 myCellsLabels->SetMapper(myClsLabeledDataMapper);
510 myCellsLabels->GetProperty()->SetColor(0,1,0);
511 myCellsLabels->SetVisibility(myIsCellsLabeled);
514 myImplicitBoolean = vtkImplicitBoolean::New();
515 myImplicitBoolean->SetOperationTypeToIntersection();
519 //Quadratic 2D elements representation
520 //-----------------------------------------------------------------------------
521 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
522 if(aQuadratic2DMode == 0){
523 myHighlitableActor->SetQuadraticArcMode(false);
524 my2DActor->SetQuadraticArcMode(false);
525 my1DActor->SetQuadraticArcMode(false);
527 else if(aQuadratic2DMode == 1){
528 myHighlitableActor->SetQuadraticArcMode(true);
529 my2DActor->SetQuadraticArcMode(true);
530 my1DActor->SetQuadraticArcMode(true);
533 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
534 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
535 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
537 // Set colors of the name actor
538 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
539 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
540 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
541 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
543 #ifndef DISABLE_PLOT2DVIEWER
550 SMESH_ActorDef::~SMESH_ActorDef()
552 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
554 #ifndef DISABLE_PLOT2DVIEWER
556 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
557 delete my2dHistogram;
561 // caught by SMESHGUI::ProcessEvents() static method
562 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
564 myScalarBarActor->Delete();
565 myLookupTable->Delete();
567 mySurfaceProp->Delete();
568 myBackSurfaceProp->Delete();
569 myOutLineProp->Delete();
571 myEdgeProp->Delete();
572 myHighlightProp->Delete();
573 myPreselectProp->Delete();
575 myNodeProp->Delete();
576 myNodeExtProp->Delete();
581 //my0DExtProp->Delete();
582 //my0DExtActor->Delete();
587 my1DExtProp->Delete();
588 my1DExtActor->Delete();
591 my2DExtProp->Delete();
592 my2DExtActor->Delete();
594 my3DExtActor->Delete();
596 myNodeActor->Delete();
597 myBaseActor->Delete();
599 myNodeExtActor->Delete();
601 myHighlitableActor->Delete();
603 //Deleting of points numbering pipeline
604 //---------------------------------------
605 myPointsNumDataSet->Delete();
607 // commented: porting to vtk 5.0
608 // myPtsLabeledDataMapper->RemoveAllInputs();
609 myPtsLabeledDataMapper->Delete();
611 // commented: porting to vtk 5.0
612 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
613 myPtsSelectVisiblePoints->Delete();
615 // commented: porting to vtk 5.0
616 // myPtsMaskPoints->UnRegisterAllOutputs();
617 myPtsMaskPoints->Delete();
619 myPointLabels->Delete();
622 //Deleting of cells numbering pipeline
623 //---------------------------------------
624 myCellsNumDataSet->Delete();
626 myClsLabeledDataMapper->RemoveAllInputs();
627 myClsLabeledDataMapper->Delete();
629 // commented: porting to vtk 5.0
630 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
631 myClsSelectVisiblePoints->Delete();
633 // commented: porting to vtk 5.0
634 // myClsMaskPoints->UnRegisterAllOutputs();
635 myClsMaskPoints->Delete();
637 // commented: porting to vtk 5.0
638 // myCellCenters->UnRegisterAllOutputs();
639 myCellCenters->Delete();
641 myCellsLabels->Delete();
643 myImplicitBoolean->Delete();
645 myTimeStamp->Delete();
649 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
651 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
653 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
655 if ( myIsPointsLabeled )
657 myPointsNumDataSet->ShallowCopy(aGrid);
658 vtkDataSet *aDataSet = myPointsNumDataSet;
660 int aNbElem = aDataSet->GetNumberOfPoints();
662 vtkIntArray *anArray = vtkIntArray::New();
663 anArray->SetNumberOfValues( aNbElem );
665 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
667 int aSMDSId = myVisualObj->GetNodeObjId( anId );
668 anArray->SetValue( anId, aSMDSId );
671 aDataSet->GetPointData()->SetScalars( anArray );
673 myPtsMaskPoints->SetInput( aDataSet );
674 myPointLabels->SetVisibility( GetVisibility() );
678 myPointLabels->SetVisibility( false );
680 SetRepresentation(GetRepresentation());
681 myTimeStamp->Modified();
685 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
687 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
688 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
689 if(myIsCellsLabeled){
690 myCellsNumDataSet->ShallowCopy(aGrid);
691 vtkDataSet *aDataSet = myCellsNumDataSet;
692 int aNbElem = aDataSet->GetNumberOfCells();
693 vtkIntArray *anArray = vtkIntArray::New();
694 anArray->SetNumberOfValues(aNbElem);
695 for(int anId = 0; anId < aNbElem; anId++){
696 int aSMDSId = myVisualObj->GetElemObjId(anId);
697 anArray->SetValue(anId,aSMDSId);
699 aDataSet->GetCellData()->SetScalars(anArray);
700 myCellCenters->SetInput(aDataSet);
701 myCellsLabels->SetVisibility(GetVisibility());
703 myCellsLabels->SetVisibility(false);
705 myTimeStamp->Modified();
709 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
711 myIsFacesOriented = theIsFacesOriented;
713 my2DActor->SetFacesOriented(theIsFacesOriented);
714 my3DActor->SetFacesOriented(theIsFacesOriented);
716 myTimeStamp->Modified();
719 bool SMESH_ActorDef::GetFacesOriented()
721 return myIsFacesOriented;
724 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
726 my2DActor->SetFacesOrientationColor( theColor );
727 my3DActor->SetFacesOrientationColor( theColor );
730 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
732 my3DActor->GetFacesOrientationColor( theColor );
735 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
737 my2DActor->SetFacesOrientationScale( theScale );
738 my3DActor->SetFacesOrientationScale( theScale );
741 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
743 return my3DActor->GetFacesOrientationScale();
746 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
748 my2DActor->SetFacesOrientation3DVectors( theState );
749 my3DActor->SetFacesOrientation3DVectors( theState );
752 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
754 return my3DActor->GetFacesOrientation3DVectors();
760 SetControlMode(eControl theMode)
762 SetControlMode(theMode,true);
768 SetControlMode(eControl theMode,
769 bool theCheckEntityMode)
771 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
775 myControlMode = eNone;
776 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
778 my0DActor->GetMapper()->SetScalarVisibility(false);
779 my1DActor->GetMapper()->SetScalarVisibility(false);
780 my2DActor->GetMapper()->SetScalarVisibility(false);
781 my3DActor->GetMapper()->SetScalarVisibility(false);
782 myScalarBarActor->SetVisibility(false);
784 bool anIsScalarVisible = theMode > eNone;
786 if(anIsScalarVisible) {
790 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
791 aControl->SetPrecision( myControlsPrecision );
792 myFunctor.reset( aControl );
793 myControlActor = my1DActor;
798 myFunctor.reset(new SMESH::Controls::Length2D());
799 myControlActor = my2DActor;
803 myFunctor.reset(new SMESH::Controls::FreeBorders());
804 myControlActor = my1DActor;
807 myFunctor.reset(new SMESH::Controls::FreeEdges());
808 myControlActor = my2DActor;
811 myFunctor.reset(new SMESH::Controls::FreeNodes());
812 myControlActor = myNodeActor;
815 myFunctor.reset(new SMESH::Controls::FreeFaces());
816 myControlActor = my2DActor;
818 case eBareBorderFace:
819 myFunctor.reset(new SMESH::Controls::BareBorderFace());
820 myControlActor = my2DActor;
822 case eOverConstrainedFace:
823 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
824 myControlActor = my2DActor;
826 case eMultiConnection:
827 myFunctor.reset(new SMESH::Controls::MultiConnection());
828 myControlActor = my1DActor;
830 case eMultiConnection2D:
831 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
832 myControlActor = my2DActor;
836 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
837 aControl->SetPrecision( myControlsPrecision );
838 myFunctor.reset( aControl );
839 myControlActor = my2DActor;
844 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
845 aControl->SetPrecision( myControlsPrecision );
846 myFunctor.reset( aControl );
847 myControlActor = my2DActor;
852 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
853 aControl->SetPrecision( myControlsPrecision );
854 myFunctor.reset( aControl );
855 myControlActor = my2DActor;
860 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
861 aControl->SetPrecision( myControlsPrecision );
862 myFunctor.reset( aControl );
863 myControlActor = my3DActor;
868 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
869 aControl->SetPrecision( myControlsPrecision );
870 myFunctor.reset( aControl );
871 myControlActor = my3DActor;
874 case eMaxElementLength2D:
876 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
877 aControl->SetPrecision( myControlsPrecision );
878 myFunctor.reset( aControl );
879 myControlActor = my2DActor;
882 case eMaxElementLength3D:
884 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
885 aControl->SetPrecision( myControlsPrecision );
886 myFunctor.reset( aControl );
887 myControlActor = my3DActor;
890 case eBareBorderVolume:
892 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
893 myControlActor = my3DActor;
896 case eOverConstrainedVolume:
898 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
899 myControlActor = my3DActor;
904 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
905 aControl->SetPrecision( myControlsPrecision );
906 myFunctor.reset( aControl );
907 myControlActor = my2DActor;
912 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
913 aControl->SetPrecision( myControlsPrecision );
914 myFunctor.reset( aControl );
915 myControlActor = my2DActor;
920 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
921 aControl->SetPrecision( myControlsPrecision );
922 myFunctor.reset( aControl );
923 myControlActor = my2DActor;
930 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
931 vtkIdType aNbCells = aGrid->GetNumberOfCells();
933 myControlMode = theMode;
934 switch(myControlMode){
936 myNodeExtActor->SetExtControlMode(myFunctor);
940 my1DExtActor->SetExtControlMode(myFunctor);
943 case eBareBorderFace:
944 case eOverConstrainedFace:
945 my2DExtActor->SetExtControlMode(myFunctor);
947 case eBareBorderVolume:
948 case eOverConstrainedVolume:
949 my3DExtActor->SetExtControlMode(myFunctor);
952 case eMultiConnection2D:
953 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
954 UpdateDistribution();
957 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
958 UpdateDistribution();
962 if(theCheckEntityMode){
963 if(myControlActor == my1DActor)
964 SetEntityMode(eEdges);
965 else if(myControlActor == my2DActor){
966 switch(myControlMode){
970 case eMultiConnection2D:
971 //SetEntityMode(eEdges);
972 SetEntityMode(eFaces);
975 SetEntityMode(eFaces);
977 }else if(myControlActor == my3DActor)
978 SetEntityMode(eVolumes);
983 if(theCheckEntityMode)
984 myEntityMode = eAllEntity;
988 SetRepresentation(GetRepresentation());
990 myTimeStamp->Modified();
995 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
996 theRenderer->AddActor(myNodeActor);
997 theRenderer->AddActor(myBaseActor);
999 theRenderer->AddActor(myNodeExtActor);
1001 my3DActor->AddToRender(theRenderer);
1002 my3DExtActor->AddToRender(theRenderer);
1003 my2DActor->AddToRender(theRenderer);
1004 my2DExtActor->AddToRender(theRenderer);
1006 theRenderer->AddActor(my1DActor);
1007 theRenderer->AddActor(my1DExtActor);
1009 theRenderer->AddActor(my0DActor);
1010 //theRenderer->AddActor(my0DExtActor);
1012 theRenderer->AddActor(myHighlitableActor);
1014 theRenderer->AddActor2D(myScalarBarActor);
1016 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
1017 myClsSelectVisiblePoints->SetRenderer(theRenderer);
1019 theRenderer->AddActor2D(myPointLabels);
1020 theRenderer->AddActor2D(myCellsLabels);
1022 // the superclass' method should be called at the end
1023 // (in particular, for correct work of selection)
1024 SALOME_Actor::AddToRender(theRenderer);
1027 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1028 SALOME_Actor::RemoveFromRender(theRenderer);
1030 theRenderer->RemoveActor(myNodeActor);
1031 theRenderer->RemoveActor(myBaseActor);
1033 theRenderer->RemoveActor(myNodeExtActor);
1035 theRenderer->RemoveActor(myHighlitableActor);
1037 theRenderer->RemoveActor(my0DActor);
1038 //theRenderer->RemoveActor(my0DExtActor);
1040 theRenderer->RemoveActor(my1DActor);
1041 theRenderer->RemoveActor(my1DExtActor);
1043 my2DActor->RemoveFromRender(theRenderer);
1044 my2DExtActor->RemoveFromRender(theRenderer);
1045 my3DActor->RemoveFromRender(theRenderer);
1046 my3DExtActor->RemoveFromRender(theRenderer);
1048 theRenderer->RemoveActor(myScalarBarActor);
1049 theRenderer->RemoveActor(myPointLabels);
1050 theRenderer->RemoveActor(myCellsLabels);
1054 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1055 const char* theEntry,
1056 const char* theName,
1059 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1063 myVisualObj = theVisualObj;
1064 myVisualObj->Update(theIsClear);
1066 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1067 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1069 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1071 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1073 my0DActor->Init(myVisualObj,myImplicitBoolean);
1074 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1076 my1DActor->Init(myVisualObj,myImplicitBoolean);
1077 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1079 my2DActor->Init(myVisualObj,myImplicitBoolean);
1080 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1081 my3DActor->Init(myVisualObj,myImplicitBoolean);
1082 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1084 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1085 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1087 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1088 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1090 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1091 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1092 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1093 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1095 vtkFloatingPointType aFactor, aUnits;
1096 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1097 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1098 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1100 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1104 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1105 SetIsShrunkable(true);
1107 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1109 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1110 SetRepresentation(-1);
1113 SetRepresentation(eEdge);
1114 }else if(aMode == 1){
1115 SetRepresentation(eSurface);
1116 }else if(aMode == 2){
1117 SetRepresentation(ePoint);
1124 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1125 SetIsDisplayNameActor( true );
1127 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1128 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1129 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1131 myTimeStamp->Modified();
1137 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1138 return myNodeActor->GetBounds();
1142 vtkDataSet* SMESH_ActorDef::GetInput(){
1143 return GetUnstructuredGrid();
1147 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1148 Superclass::SetTransform(theTransform);
1150 myNodeActor->SetTransform(theTransform);
1151 myBaseActor->SetTransform(theTransform);
1153 myHighlitableActor->SetTransform(theTransform);
1155 myNodeExtActor->SetTransform(theTransform);
1157 my0DActor->SetTransform(theTransform);
1158 //my0DExtActor->SetTransform(theTransform);
1160 my1DActor->SetTransform(theTransform);
1161 my1DExtActor->SetTransform(theTransform);
1163 my2DActor->SetTransform(theTransform);
1164 my2DExtActor->SetTransform(theTransform);
1165 my3DActor->SetTransform(theTransform);
1166 my3DExtActor->SetTransform(theTransform);
1172 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1173 vtkLODActor::SetMapper(theMapper);
1177 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1178 SALOME_Actor::ShallowCopy(prop);
1182 vtkMapper* SMESH_ActorDef::GetMapper(){
1183 return myPickableActor->GetMapper();
1187 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1188 return myVisualObj->GetUnstructuredGrid();
1192 bool SMESH_ActorDef::IsInfinitive(){
1193 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1195 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1196 ( aDataSet->GetNumberOfCells() == 1 &&
1197 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1198 return SALOME_Actor::IsInfinitive();
1202 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1203 if ( myIsShrinkable == theShrunkable )
1205 myIsShrinkable = theShrunkable;
1209 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1210 return myBaseActor->GetShrinkFactor();
1213 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1214 myBaseActor->SetShrinkFactor(theValue);
1216 my1DActor->SetShrinkFactor(theValue);
1217 my1DExtActor->SetShrinkFactor(theValue);
1219 my2DActor->SetShrinkFactor(theValue);
1220 my2DExtActor->SetShrinkFactor(theValue);
1221 my3DActor->SetShrinkFactor(theValue);
1222 my3DExtActor->SetShrinkFactor(theValue);
1223 my3DExtActor->SetShrinkFactor(theValue);
1224 myHighlitableActor->SetShrinkFactor(theValue);
1229 void SMESH_ActorDef::SetShrink(){
1230 if(!myIsShrinkable) return;
1232 myBaseActor->SetShrink();
1234 my1DActor->SetShrink();
1235 my1DExtActor->SetShrink();
1237 my2DActor->SetShrink();
1238 my2DExtActor->SetShrink();
1239 my3DActor->SetShrink();
1240 my3DExtActor->SetShrink();
1241 myHighlitableActor->SetShrink();
1247 void SMESH_ActorDef::UnShrink(){
1248 if(!myIsShrunk) return;
1250 myBaseActor->UnShrink();
1252 my1DActor->UnShrink();
1253 my1DExtActor->UnShrink();
1255 my2DActor->UnShrink();
1256 my2DExtActor->UnShrink();
1257 my3DActor->UnShrink();
1258 my3DExtActor->UnShrink();
1259 myHighlitableActor->UnShrink();
1266 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1267 return myPickableActor->GetNodeObjId(theVtkID);
1270 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1271 return myPickableActor->GetNodeCoord(theObjID);
1275 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1276 return myPickableActor->GetElemObjId(theVtkID);
1279 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1280 return myPickableActor->GetElemCell(theObjID);
1284 void SMESH_ActorDef::SetVisibility(int theMode){
1285 SetVisibility(theMode,true);
1289 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1290 SALOME_Actor::SetVisibility(theMode);
1292 myNodeActor->VisibilityOff();
1293 myBaseActor->VisibilityOff();
1295 myNodeExtActor->VisibilityOff();
1297 my0DActor->VisibilityOff();
1298 //my0DExtActor->VisibilityOff();
1300 my1DActor->VisibilityOff();
1301 my1DExtActor->VisibilityOff();
1303 my2DActor->VisibilityOff();
1304 my2DExtActor->VisibilityOff();
1305 my3DActor->VisibilityOff();
1306 my3DExtActor->VisibilityOff();
1308 myScalarBarActor->VisibilityOff();
1309 myPointLabels->VisibilityOff();
1310 myCellsLabels->VisibilityOff();
1312 if(GetVisibility()){
1313 if(theIsUpdateRepersentation)
1314 SetRepresentation(GetRepresentation());
1316 if(myControlMode != eNone){
1317 switch(myControlMode){
1319 myNodeExtActor->VisibilityOn();
1323 my1DExtActor->VisibilityOn();
1326 case eBareBorderFace:
1327 case eOverConstrainedFace:
1328 my2DExtActor->VisibilityOn();
1330 case eBareBorderVolume:
1331 case eOverConstrainedVolume:
1332 my3DExtActor->VisibilityOn();
1335 case eMultiConnection2D:
1336 my1DExtActor->VisibilityOn();
1338 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1339 myScalarBarActor->VisibilityOn();
1343 if(myRepresentation != ePoint)
1344 myPickableActor->VisibilityOn();
1346 myNodeActor->VisibilityOn();
1349 if(myEntityMode & e0DElements){
1350 my0DActor->VisibilityOn();
1353 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1354 my1DActor->VisibilityOn();
1357 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1358 my2DActor->VisibilityOn();
1361 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1362 my3DActor->VisibilityOn();
1365 if(myIsPointsLabeled){
1366 myPointLabels->VisibilityOn();
1367 myNodeActor->VisibilityOn();
1370 if(myIsCellsLabeled)
1371 myCellsLabels->VisibilityOn();
1373 #ifndef DISABLE_PLOT2DVIEWER
1375 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1382 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1384 myEntityState = eAllEntity;
1386 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1387 myEntityState &= ~e0DElements;
1388 theMode &= ~e0DElements;
1391 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1392 myEntityState &= ~eEdges;
1396 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1397 myEntityState &= ~eFaces;
1401 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1402 myEntityState &= ~eVolumes;
1403 theMode &= ~eVolumes;
1407 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1408 theMode |= e0DElements;
1410 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1413 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1416 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1417 theMode |= eVolumes;
1420 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1422 myEntityMode = theMode;
1423 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1424 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1425 aFilter->ClearRegisteredCellsWithType();
1426 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1428 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1429 aHightFilter->ClearRegisteredCellsWithType();
1430 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1432 if (myEntityMode & e0DElements) {
1433 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1434 aFilter->RegisterCellsWithType(VTK_VERTEX);
1435 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1438 if (myEntityMode & eEdges) {
1439 if (MYDEBUG) MESSAGE("EDGES");
1440 aFilter->RegisterCellsWithType(VTK_LINE);
1441 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1443 aHightFilter->RegisterCellsWithType(VTK_LINE);
1444 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1447 if (myEntityMode & eFaces) {
1448 if (MYDEBUG) MESSAGE("FACES");
1449 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1450 aFilter->RegisterCellsWithType(VTK_POLYGON);
1451 aFilter->RegisterCellsWithType(VTK_QUAD);
1452 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1453 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1455 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1456 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1457 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1458 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1459 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1462 if (myEntityMode & eVolumes) {
1463 if (MYDEBUG) MESSAGE("VOLUMES");
1464 aFilter->RegisterCellsWithType(VTK_TETRA);
1465 aFilter->RegisterCellsWithType(VTK_VOXEL);
1466 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1467 aFilter->RegisterCellsWithType(VTK_WEDGE);
1468 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1469 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1470 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1471 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1472 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1473 //#ifdef VTK_HAVE_POLYHEDRON
1474 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1477 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1478 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1479 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1480 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1481 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1482 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1483 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1484 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1485 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1486 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1487 //#ifdef VTK_HAVE_POLYHEDRON
1488 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1492 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1493 SetVisibility(GetVisibility(),false);
1496 void SMESH_ActorDef::SetRepresentation (int theMode)
1498 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1499 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1500 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1503 myRepresentation = eSurface;
1504 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1505 myRepresentation = eEdge;
1506 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1507 myRepresentation = ePoint;
1512 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1515 if (!aNbFaces && !aNbVolumes) return;
1518 myRepresentation = theMode;
1521 if (!GetUnstructuredGrid()->GetNumberOfCells())
1522 myRepresentation = ePoint;
1525 if (myRepresentation == ePoint) {
1533 myPickableActor = myBaseActor;
1534 myNodeActor->SetVisibility(false);
1535 myNodeExtActor->SetVisibility(false);
1536 vtkProperty *aProp = NULL, *aBackProp = NULL;
1537 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1538 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1539 switch (myRepresentation) {
1541 myPickableActor = myNodeActor;
1542 myNodeActor->SetVisibility(true);
1543 aQuadraticMode = SMESH_Actor::eLines;
1544 aProp = aBackProp = myNodeProp;
1545 aReperesent = SMESH_DeviceActor::ePoint;
1548 aProp = aBackProp = myEdgeProp;
1549 aReperesent = SMESH_DeviceActor::eInsideframe;
1552 aProp = mySurfaceProp;
1553 aBackProp = myBackSurfaceProp;
1554 aReperesent = SMESH_DeviceActor::eSurface;
1558 my2DActor->SetProperty(aProp);
1559 my2DActor->SetBackfaceProperty(aBackProp);
1560 my2DActor->SetRepresentation(aReperesent);
1562 if(aQuadraticMode == SMESH_Actor::eLines)
1563 my2DActor->SetQuadraticArcMode(false);
1564 else if(aQuadraticMode == SMESH_Actor::eArcs)
1565 my2DActor->SetQuadraticArcMode(true);
1567 my2DExtActor->SetRepresentation(aReperesent);
1569 my3DActor->SetProperty(aProp);
1570 my3DActor->SetBackfaceProperty(aBackProp);
1571 my3DActor->SetRepresentation(aReperesent);
1573 //my0DExtActor->SetVisibility(false);
1574 my1DExtActor->SetVisibility(false);
1575 my2DExtActor->SetVisibility(false);
1576 my3DExtActor->SetVisibility(false);
1579 //my0DActor->SetProperty(aProp);
1580 //my0DActor->SetBackfaceProperty(aBackProp);
1581 my0DActor->SetRepresentation(aReperesent);
1582 //my0DExtActor->SetRepresentation(aReperesent);
1584 switch(myControlMode){
1586 case eMultiConnection:
1587 aProp = aBackProp = my1DProp;
1588 if(myRepresentation != ePoint)
1589 aReperesent = SMESH_DeviceActor::eInsideframe;
1593 if(aQuadraticMode == SMESH_Actor::eLines)
1594 my1DActor->SetQuadraticArcMode(false);
1595 else if(aQuadraticMode == SMESH_Actor::eArcs)
1596 my1DActor->SetQuadraticArcMode(true);
1598 my1DActor->SetProperty(aProp);
1599 my1DActor->SetBackfaceProperty(aBackProp);
1600 my1DActor->SetRepresentation(aReperesent);
1602 my1DExtActor->SetRepresentation(aReperesent);
1604 if(myIsPointsVisible)
1605 myPickableActor = myNodeActor;
1606 if(GetPointRepresentation())
1607 myNodeActor->SetVisibility(true);
1609 SetMapper(myPickableActor->GetMapper());
1611 SetVisibility(GetVisibility(),false);
1617 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1618 if ( myIsPointsVisible == theIsPointsVisible )
1620 myIsPointsVisible = theIsPointsVisible;
1621 SetRepresentation(GetRepresentation());
1624 bool SMESH_ActorDef::GetPointRepresentation(){
1625 return myIsPointsVisible || myIsPointsLabeled;
1629 void SMESH_ActorDef::UpdateHighlight(){
1630 myHighlitableActor->SetHighlited(false);
1631 myHighlitableActor->SetVisibility(false);
1633 bool anIsVisible = GetVisibility();
1635 switch(myRepresentation){
1636 case SMESH_DeviceActor::eSurface:
1637 case SMESH_DeviceActor::eWireframe:
1639 if(myIsHighlighted) {
1640 myHighlitableActor->SetProperty(myHighlightProp);
1641 }else if(myIsPreselected){
1642 myHighlitableActor->SetProperty(myPreselectProp);
1643 } else if(anIsVisible){
1644 (myRepresentation == eSurface) ?
1645 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1647 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1648 myHighlitableActor->SetHighlited(anIsVisible);
1649 myHighlitableActor->GetExtractUnstructuredGrid()->
1650 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1651 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1653 myHighlitableActor->SetVisibility(anIsVisible);
1656 case SMESH_DeviceActor::ePoint:
1658 if(myIsHighlighted) {
1659 myNodeActor->SetProperty(myHighlightProp);
1660 }else if(myIsPreselected) {
1661 myNodeActor->SetProperty(myPreselectProp);
1662 } else if(anIsVisible) {
1663 myNodeActor->SetProperty(myNodeProp);
1665 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1666 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1673 void SMESH_ActorDef::highlight(bool theHighlight){
1674 if ( myIsHighlighted == theHighlight )
1676 myIsHighlighted = theHighlight;
1681 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1682 if ( myIsPreselected == thePreselect )
1684 myIsPreselected = thePreselect;
1690 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1692 if (myPickableActor->GetIsOpaque())
1694 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1702 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1704 if (!myPickableActor->GetIsOpaque())
1706 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1714 void SMESH_ActorDef::Render(vtkRenderer *ren){
1715 unsigned long aTime = myTimeStamp->GetMTime();
1716 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1717 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1718 if(anObjTime > aTime || aClippingTime > aTime)
1723 void SMESH_ActorDef::Update(){
1724 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1726 if(GetControlMode() != eNone) {
1727 unsigned long aTime = myTimeStamp->GetMTime();
1728 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1729 if (anObjTime > aTime)
1730 SetControlMode(GetControlMode(),false);
1732 if(myIsPointsLabeled){
1733 SetPointsLabeled(myIsPointsLabeled);
1735 if(myIsCellsLabeled){
1736 SetCellsLabeled(myIsCellsLabeled);
1738 if(myIsFacesOriented){
1739 SetFacesOriented(myIsFacesOriented);
1741 SetEntityMode(GetEntityMode());
1742 SetVisibility(GetVisibility());
1744 myTimeStamp->Modified();
1749 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1750 SALOME_Actor::ReleaseGraphicsResources(renWin);
1752 myPickableActor->ReleaseGraphicsResources(renWin);
1756 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1757 vtkFloatingPointType* aColor = theProperty->GetColor();
1764 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1765 mySurfaceProp->SetOpacity(theValue);
1766 myBackSurfaceProp->SetOpacity(theValue);
1767 myEdgeProp->SetOpacity(theValue);
1768 myNodeProp->SetOpacity(theValue);
1770 my1DProp->SetOpacity(theValue);
1774 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1775 return mySurfaceProp->GetOpacity();
1779 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1780 mySurfaceProp->SetColor(r,g,b);
1781 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1782 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1783 aGroupObj->GetElementType() == SMDSAbs_Volume )
1784 myNameActor->SetBackgroundColor(r,g,b);
1786 myDeltaBrightness = delta;
1787 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1788 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1792 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1793 ::GetColor(mySurfaceProp,r,g,b);
1794 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1795 delta = myDeltaBrightness;
1798 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1799 myEdgeProp->SetColor(r,g,b);
1800 my1DProp->SetColor(r,g,b);
1801 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1802 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1803 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1804 myNameActor->SetBackgroundColor(r,g,b);
1808 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1809 ::GetColor(myEdgeProp,r,g,b);
1812 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1813 myOutLineProp->SetColor(r,g,b);
1817 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1818 ::GetColor(myOutLineProp,r,g,b);
1822 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1823 myNodeProp->SetColor(r,g,b);
1824 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1825 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1826 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1827 myNameActor->SetBackgroundColor(r,g,b);
1831 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1832 ::GetColor(myNodeProp,r,g,b);
1835 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1836 my0DProp->SetColor(r,g,b);
1837 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1838 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1839 myNameActor->SetBackgroundColor(r,g,b);
1843 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1844 ::GetColor(my0DProp,r,g,b);
1847 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1848 myHighlightProp->SetColor(r,g,b);
1852 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1853 ::GetColor(myHighlightProp,r,g,b);
1856 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1857 myPreselectProp->SetColor(r,g,b);
1861 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1862 ::GetColor(myPreselectProp,r,g,b);
1866 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1867 return myEdgeProp->GetLineWidth();
1871 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1872 myEdgeProp->SetLineWidth(theVal);
1874 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1875 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1881 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1882 my0DProp->SetPointSize(theVal);
1886 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1887 return my0DProp->GetPointSize();
1890 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1892 return myVisualObj->GetElemDimension( theObjId );
1897 IsImplicitFunctionUsed() const
1899 return myBaseActor->IsImplicitFunctionUsed();
1903 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1905 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1906 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1908 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1910 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1912 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1913 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1915 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1916 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1918 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1919 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1920 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1921 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1925 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1928 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1929 myCippingPlaneCont.push_back(thePlane);
1930 if(!IsImplicitFunctionUsed())
1931 SetImplicitFunctionUsed(true);
1933 return myCippingPlaneCont.size();
1938 RemoveAllClippingPlanes()
1940 myImplicitBoolean->GetFunction()->RemoveAllItems();
1941 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1942 myCippingPlaneCont.clear();
1943 SetImplicitFunctionUsed(false);
1948 GetNumberOfClippingPlanes()
1950 return myCippingPlaneCont.size();
1955 GetClippingPlane(vtkIdType theID)
1957 if(theID >= myCippingPlaneCont.size())
1959 return myCippingPlaneCont[theID].Get();
1962 void SMESH_ActorDef::UpdateScalarBar()
1964 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1968 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1970 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1971 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1973 aScalarBarTitleProp->SetFontFamilyToArial();
1975 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1977 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1978 if ( f.family() == "Arial" )
1979 aScalarBarTitleProp->SetFontFamilyToArial();
1980 else if ( f.family() == "Courier" )
1981 aScalarBarTitleProp->SetFontFamilyToCourier();
1982 else if ( f.family() == "Times" )
1983 aScalarBarTitleProp->SetFontFamilyToTimes();
1986 aScalarBarTitleProp->BoldOn();
1988 aScalarBarTitleProp->BoldOff();
1991 aScalarBarTitleProp->ItalicOn();
1993 aScalarBarTitleProp->ItalicOff();
1996 aScalarBarTitleProp->ShadowOn();
1998 aScalarBarTitleProp->ShadowOff();
2001 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2002 aScalarBarTitleProp->Delete();
2004 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2006 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2007 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2009 aScalarBarLabelProp->SetFontFamilyToArial();
2010 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2012 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2013 if( f.family() == "Arial" )
2014 aScalarBarLabelProp->SetFontFamilyToArial();
2015 else if( f.family() == "Courier" )
2016 aScalarBarLabelProp->SetFontFamilyToCourier();
2017 else if( f.family() == "Times" )
2018 aScalarBarLabelProp->SetFontFamilyToTimes();
2021 aScalarBarLabelProp->BoldOn();
2023 aScalarBarLabelProp->BoldOff();
2026 aScalarBarLabelProp->ItalicOn();
2028 aScalarBarLabelProp->ItalicOff();
2031 aScalarBarLabelProp->ShadowOn();
2033 aScalarBarLabelProp->ShadowOff();
2036 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2037 aScalarBarLabelProp->Delete();
2039 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2040 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2042 myScalarBarActor->SetOrientationToHorizontal();
2044 myScalarBarActor->SetOrientationToVertical();
2047 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2048 if( mgr->hasValue( "SMESH", name + "x" ) )
2049 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2051 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2052 if( mgr->hasValue( "SMESH", name + "y" ) )
2053 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2054 myScalarBarActor->SetPosition( aXVal, aYVal );
2056 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2057 if( mgr->hasValue( "SMESH", name + "width" ) )
2058 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2059 myScalarBarActor->SetWidth( aWVal );
2061 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2062 if( mgr->hasValue( "SMESH", name + "height" ) )
2063 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2064 myScalarBarActor->SetHeight( aHVal );
2067 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2068 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2069 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2072 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2073 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2074 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2076 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2077 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2079 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2080 myScalarBarActor->SetDistributionColoringType(coloringType);
2082 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2083 QColor(255, 255, 255));
2085 rgb[0]= distributionColor.red()/255.;
2086 rgb[1]= distributionColor.green()/255.;
2087 rgb[2]= distributionColor.blue()/255.;
2088 myScalarBarActor->SetDistributionColor(rgb);
2093 void SMESH_ActorDef::UpdateDistribution()
2095 if(SMESH::Controls::NumericalFunctor* fun =
2096 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2098 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2099 std::vector<int> nbEvents;
2100 std::vector<double> funValues;
2101 SMESH_VisualObjDef::TEntityList elems;
2102 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2103 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2104 std::vector<int> elemIds;
2105 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2106 elemIds.push_back( (*e)->GetID());
2107 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2108 double * range = lookupTable->GetRange();
2109 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2110 myScalarBarActor->SetDistribution(nbEvents);
2114 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2117 case SMESH_Actor::eLines :
2118 myHighlitableActor->SetQuadraticArcMode(false);
2119 my2DActor->SetQuadraticArcMode(false);
2120 my1DActor->SetQuadraticArcMode(false);
2122 case SMESH_Actor::eArcs :
2123 myHighlitableActor->SetQuadraticArcMode(true);
2124 if(GetRepresentation() != SMESH_Actor::ePoint) {
2125 my2DActor->SetQuadraticArcMode(true);
2126 my1DActor->SetQuadraticArcMode(true);
2135 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2137 if(myHighlitableActor->GetQuadraticArcMode())
2138 return SMESH_Actor::eArcs;
2140 return SMESH_Actor::eLines;
2143 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2145 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2146 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2147 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2150 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2152 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2153 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2154 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2155 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2158 #ifndef DISABLE_PLOT2DVIEWER
2159 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2162 my2dHistogram->clearAllPoints();
2164 if(SMESH::Controls::NumericalFunctor* fun =
2165 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2168 if(!my2dHistogram) {
2169 my2dHistogram = new SPlot2d_Histogram();
2170 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2171 my2dHistogram->setIO(anIO);
2174 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2175 std::vector<int> nbEvents;
2176 std::vector<double> funValues;
2177 SMESH_VisualObjDef::TEntityList elems;
2178 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2179 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2180 std::vector<int> elemIds;
2182 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2183 elemIds.push_back( (*e)->GetID());
2185 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2186 double * range = lookupTable->GetRange();
2187 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2189 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2190 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2192 if(funValues.size() >= 2)
2193 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2197 //Color of the histogram
2198 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2199 my2dHistogram->setAutoAssign(true);
2202 myScalarBarActor->GetDistributionColor(rgb);
2203 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2204 my2dHistogram->setColor(aColor);
2208 return my2dHistogram;