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();
570 myEdgeProp->Delete();
571 myHighlightProp->Delete();
572 myPreselectProp->Delete();
574 myNodeProp->Delete();
575 myNodeExtProp->Delete();
580 //my0DExtProp->Delete();
581 //my0DExtActor->Delete();
586 my1DExtProp->Delete();
587 my1DExtActor->Delete();
590 my2DExtProp->Delete();
591 my2DExtActor->Delete();
593 my3DExtActor->Delete();
595 myNodeActor->Delete();
596 myBaseActor->Delete();
598 myNodeExtActor->Delete();
600 myHighlitableActor->Delete();
602 //Deleting of points numbering pipeline
603 //---------------------------------------
604 myPointsNumDataSet->Delete();
606 // commented: porting to vtk 5.0
607 // myPtsLabeledDataMapper->RemoveAllInputs();
608 myPtsLabeledDataMapper->Delete();
610 // commented: porting to vtk 5.0
611 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
612 myPtsSelectVisiblePoints->Delete();
614 // commented: porting to vtk 5.0
615 // myPtsMaskPoints->UnRegisterAllOutputs();
616 myPtsMaskPoints->Delete();
618 myPointLabels->Delete();
621 //Deleting of cells numbering pipeline
622 //---------------------------------------
623 myCellsNumDataSet->Delete();
625 myClsLabeledDataMapper->RemoveAllInputs();
626 myClsLabeledDataMapper->Delete();
628 // commented: porting to vtk 5.0
629 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
630 myClsSelectVisiblePoints->Delete();
632 // commented: porting to vtk 5.0
633 // myClsMaskPoints->UnRegisterAllOutputs();
634 myClsMaskPoints->Delete();
636 // commented: porting to vtk 5.0
637 // myCellCenters->UnRegisterAllOutputs();
638 myCellCenters->Delete();
640 myCellsLabels->Delete();
642 myImplicitBoolean->Delete();
644 myTimeStamp->Delete();
648 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
650 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
652 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
654 if ( myIsPointsLabeled )
656 myPointsNumDataSet->ShallowCopy(aGrid);
657 vtkDataSet *aDataSet = myPointsNumDataSet;
659 int aNbElem = aDataSet->GetNumberOfPoints();
661 vtkIntArray *anArray = vtkIntArray::New();
662 anArray->SetNumberOfValues( aNbElem );
664 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
666 int aSMDSId = myVisualObj->GetNodeObjId( anId );
667 anArray->SetValue( anId, aSMDSId );
670 aDataSet->GetPointData()->SetScalars( anArray );
672 myPtsMaskPoints->SetInput( aDataSet );
673 myPointLabels->SetVisibility( GetVisibility() );
677 myPointLabels->SetVisibility( false );
679 SetRepresentation(GetRepresentation());
680 myTimeStamp->Modified();
684 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
686 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
687 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
688 if(myIsCellsLabeled){
689 myCellsNumDataSet->ShallowCopy(aGrid);
690 vtkDataSet *aDataSet = myCellsNumDataSet;
691 int aNbElem = aDataSet->GetNumberOfCells();
692 vtkIntArray *anArray = vtkIntArray::New();
693 anArray->SetNumberOfValues(aNbElem);
694 for(int anId = 0; anId < aNbElem; anId++){
695 int aSMDSId = myVisualObj->GetElemObjId(anId);
696 anArray->SetValue(anId,aSMDSId);
698 aDataSet->GetCellData()->SetScalars(anArray);
699 myCellCenters->SetInput(aDataSet);
700 myCellsLabels->SetVisibility(GetVisibility());
702 myCellsLabels->SetVisibility(false);
704 myTimeStamp->Modified();
708 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
710 myIsFacesOriented = theIsFacesOriented;
712 my2DActor->SetFacesOriented(theIsFacesOriented);
713 my3DActor->SetFacesOriented(theIsFacesOriented);
715 myTimeStamp->Modified();
718 bool SMESH_ActorDef::GetFacesOriented()
720 return myIsFacesOriented;
723 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
725 my2DActor->SetFacesOrientationColor( theColor );
726 my3DActor->SetFacesOrientationColor( theColor );
729 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
731 my3DActor->GetFacesOrientationColor( theColor );
734 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
736 my2DActor->SetFacesOrientationScale( theScale );
737 my3DActor->SetFacesOrientationScale( theScale );
740 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
742 return my3DActor->GetFacesOrientationScale();
745 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
747 my2DActor->SetFacesOrientation3DVectors( theState );
748 my3DActor->SetFacesOrientation3DVectors( theState );
751 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
753 return my3DActor->GetFacesOrientation3DVectors();
759 SetControlMode(eControl theMode)
761 SetControlMode(theMode,true);
767 SetControlMode(eControl theMode,
768 bool theCheckEntityMode)
770 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
774 myControlMode = eNone;
775 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
777 my0DActor->GetMapper()->SetScalarVisibility(false);
778 my1DActor->GetMapper()->SetScalarVisibility(false);
779 my2DActor->GetMapper()->SetScalarVisibility(false);
780 my3DActor->GetMapper()->SetScalarVisibility(false);
781 myScalarBarActor->SetVisibility(false);
783 bool anIsScalarVisible = theMode > eNone;
785 if(anIsScalarVisible) {
789 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
790 aControl->SetPrecision( myControlsPrecision );
791 myFunctor.reset( aControl );
792 myControlActor = my1DActor;
797 myFunctor.reset(new SMESH::Controls::Length2D());
798 myControlActor = my2DActor;
802 myFunctor.reset(new SMESH::Controls::FreeBorders());
803 myControlActor = my1DActor;
806 myFunctor.reset(new SMESH::Controls::FreeEdges());
807 myControlActor = my2DActor;
810 myFunctor.reset(new SMESH::Controls::FreeNodes());
811 myControlActor = myNodeActor;
814 myFunctor.reset(new SMESH::Controls::FreeFaces());
815 myControlActor = my2DActor;
817 case eBareBorderFace:
818 myFunctor.reset(new SMESH::Controls::BareBorderFace());
819 myControlActor = my2DActor;
821 case eOverConstrainedFace:
822 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
823 myControlActor = my2DActor;
825 case eMultiConnection:
826 myFunctor.reset(new SMESH::Controls::MultiConnection());
827 myControlActor = my1DActor;
829 case eMultiConnection2D:
830 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
831 myControlActor = my2DActor;
835 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
836 aControl->SetPrecision( myControlsPrecision );
837 myFunctor.reset( aControl );
838 myControlActor = my2DActor;
843 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
844 aControl->SetPrecision( myControlsPrecision );
845 myFunctor.reset( aControl );
846 myControlActor = my2DActor;
851 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
852 aControl->SetPrecision( myControlsPrecision );
853 myFunctor.reset( aControl );
854 myControlActor = my2DActor;
859 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
860 aControl->SetPrecision( myControlsPrecision );
861 myFunctor.reset( aControl );
862 myControlActor = my3DActor;
867 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
868 aControl->SetPrecision( myControlsPrecision );
869 myFunctor.reset( aControl );
870 myControlActor = my3DActor;
873 case eMaxElementLength2D:
875 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
876 aControl->SetPrecision( myControlsPrecision );
877 myFunctor.reset( aControl );
878 myControlActor = my2DActor;
881 case eMaxElementLength3D:
883 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
884 aControl->SetPrecision( myControlsPrecision );
885 myFunctor.reset( aControl );
886 myControlActor = my3DActor;
889 case eBareBorderVolume:
891 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
892 myControlActor = my3DActor;
895 case eOverConstrainedVolume:
897 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
898 myControlActor = my3DActor;
903 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
904 aControl->SetPrecision( myControlsPrecision );
905 myFunctor.reset( aControl );
906 myControlActor = my2DActor;
911 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
912 aControl->SetPrecision( myControlsPrecision );
913 myFunctor.reset( aControl );
914 myControlActor = my2DActor;
919 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
920 aControl->SetPrecision( myControlsPrecision );
921 myFunctor.reset( aControl );
922 myControlActor = my2DActor;
929 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
930 vtkIdType aNbCells = aGrid->GetNumberOfCells();
932 myControlMode = theMode;
933 switch(myControlMode){
935 myNodeExtActor->SetExtControlMode(myFunctor);
939 my1DExtActor->SetExtControlMode(myFunctor);
942 case eBareBorderFace:
943 case eOverConstrainedFace:
944 my2DExtActor->SetExtControlMode(myFunctor);
946 case eBareBorderVolume:
947 case eOverConstrainedVolume:
948 my3DExtActor->SetExtControlMode(myFunctor);
951 case eMultiConnection2D:
952 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
953 UpdateDistribution();
956 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
957 UpdateDistribution();
961 if(theCheckEntityMode){
962 if(myControlActor == my1DActor)
963 SetEntityMode(eEdges);
964 else if(myControlActor == my2DActor){
965 switch(myControlMode){
969 case eMultiConnection2D:
970 //SetEntityMode(eEdges);
971 SetEntityMode(eFaces);
974 SetEntityMode(eFaces);
976 }else if(myControlActor == my3DActor)
977 SetEntityMode(eVolumes);
982 if(theCheckEntityMode)
983 myEntityMode = eAllEntity;
987 SetRepresentation(GetRepresentation());
989 myTimeStamp->Modified();
994 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
995 theRenderer->AddActor(myNodeActor);
996 theRenderer->AddActor(myBaseActor);
998 theRenderer->AddActor(myNodeExtActor);
1000 my3DActor->AddToRender(theRenderer);
1001 my3DExtActor->AddToRender(theRenderer);
1002 my2DActor->AddToRender(theRenderer);
1003 my2DExtActor->AddToRender(theRenderer);
1005 theRenderer->AddActor(my1DActor);
1006 theRenderer->AddActor(my1DExtActor);
1008 theRenderer->AddActor(my0DActor);
1009 //theRenderer->AddActor(my0DExtActor);
1011 theRenderer->AddActor(myHighlitableActor);
1013 theRenderer->AddActor2D(myScalarBarActor);
1015 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
1016 myClsSelectVisiblePoints->SetRenderer(theRenderer);
1018 theRenderer->AddActor2D(myPointLabels);
1019 theRenderer->AddActor2D(myCellsLabels);
1021 // the superclass' method should be called at the end
1022 // (in particular, for correct work of selection)
1023 SALOME_Actor::AddToRender(theRenderer);
1026 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1027 SALOME_Actor::RemoveFromRender(theRenderer);
1029 theRenderer->RemoveActor(myNodeActor);
1030 theRenderer->RemoveActor(myBaseActor);
1032 theRenderer->RemoveActor(myNodeExtActor);
1034 theRenderer->RemoveActor(myHighlitableActor);
1036 theRenderer->RemoveActor(my0DActor);
1037 //theRenderer->RemoveActor(my0DExtActor);
1039 theRenderer->RemoveActor(my1DActor);
1040 theRenderer->RemoveActor(my1DExtActor);
1042 my2DActor->RemoveFromRender(theRenderer);
1043 my2DExtActor->RemoveFromRender(theRenderer);
1044 my3DActor->RemoveFromRender(theRenderer);
1045 my3DExtActor->RemoveFromRender(theRenderer);
1047 theRenderer->RemoveActor(myScalarBarActor);
1048 theRenderer->RemoveActor(myPointLabels);
1049 theRenderer->RemoveActor(myCellsLabels);
1053 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1054 const char* theEntry,
1055 const char* theName,
1058 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1062 myVisualObj = theVisualObj;
1063 myVisualObj->Update(theIsClear);
1065 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1066 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1068 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1070 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1072 my0DActor->Init(myVisualObj,myImplicitBoolean);
1073 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1075 my1DActor->Init(myVisualObj,myImplicitBoolean);
1076 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1078 my2DActor->Init(myVisualObj,myImplicitBoolean);
1079 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1080 my3DActor->Init(myVisualObj,myImplicitBoolean);
1081 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1083 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1084 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1086 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1087 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1089 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1090 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1091 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1092 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1094 vtkFloatingPointType aFactor, aUnits;
1095 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1096 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1097 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1099 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1103 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1104 SetIsShrunkable(true);
1106 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1108 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1109 SetRepresentation(-1);
1112 SetRepresentation(eEdge);
1113 }else if(aMode == 1){
1114 SetRepresentation(eSurface);
1115 }else if(aMode == 2){
1116 SetRepresentation(ePoint);
1123 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1124 SetIsDisplayNameActor( true );
1126 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1127 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1128 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1130 myTimeStamp->Modified();
1136 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1137 return myNodeActor->GetBounds();
1141 vtkDataSet* SMESH_ActorDef::GetInput(){
1142 return GetUnstructuredGrid();
1146 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1147 Superclass::SetTransform(theTransform);
1149 myNodeActor->SetTransform(theTransform);
1150 myBaseActor->SetTransform(theTransform);
1152 myHighlitableActor->SetTransform(theTransform);
1154 myNodeExtActor->SetTransform(theTransform);
1156 my0DActor->SetTransform(theTransform);
1157 //my0DExtActor->SetTransform(theTransform);
1159 my1DActor->SetTransform(theTransform);
1160 my1DExtActor->SetTransform(theTransform);
1162 my2DActor->SetTransform(theTransform);
1163 my2DExtActor->SetTransform(theTransform);
1164 my3DActor->SetTransform(theTransform);
1165 my3DExtActor->SetTransform(theTransform);
1171 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1172 vtkLODActor::SetMapper(theMapper);
1176 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1177 SALOME_Actor::ShallowCopy(prop);
1181 vtkMapper* SMESH_ActorDef::GetMapper(){
1182 return myPickableActor->GetMapper();
1186 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1187 return myVisualObj->GetUnstructuredGrid();
1191 bool SMESH_ActorDef::IsInfinitive(){
1192 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1194 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1195 ( aDataSet->GetNumberOfCells() == 1 &&
1196 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1197 return SALOME_Actor::IsInfinitive();
1201 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1202 if ( myIsShrinkable == theShrunkable )
1204 myIsShrinkable = theShrunkable;
1208 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1209 return myBaseActor->GetShrinkFactor();
1212 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1213 myBaseActor->SetShrinkFactor(theValue);
1215 my1DActor->SetShrinkFactor(theValue);
1216 my1DExtActor->SetShrinkFactor(theValue);
1218 my2DActor->SetShrinkFactor(theValue);
1219 my2DExtActor->SetShrinkFactor(theValue);
1220 my3DActor->SetShrinkFactor(theValue);
1221 my3DExtActor->SetShrinkFactor(theValue);
1222 my3DExtActor->SetShrinkFactor(theValue);
1223 myHighlitableActor->SetShrinkFactor(theValue);
1228 void SMESH_ActorDef::SetShrink(){
1229 if(!myIsShrinkable) return;
1231 myBaseActor->SetShrink();
1233 my1DActor->SetShrink();
1234 my1DExtActor->SetShrink();
1236 my2DActor->SetShrink();
1237 my2DExtActor->SetShrink();
1238 my3DActor->SetShrink();
1239 my3DExtActor->SetShrink();
1240 myHighlitableActor->SetShrink();
1246 void SMESH_ActorDef::UnShrink(){
1247 if(!myIsShrunk) return;
1249 myBaseActor->UnShrink();
1251 my1DActor->UnShrink();
1252 my1DExtActor->UnShrink();
1254 my2DActor->UnShrink();
1255 my2DExtActor->UnShrink();
1256 my3DActor->UnShrink();
1257 my3DExtActor->UnShrink();
1258 myHighlitableActor->UnShrink();
1265 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1266 return myPickableActor->GetNodeObjId(theVtkID);
1269 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1270 return myPickableActor->GetNodeCoord(theObjID);
1274 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1275 return myPickableActor->GetElemObjId(theVtkID);
1278 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1279 return myPickableActor->GetElemCell(theObjID);
1283 void SMESH_ActorDef::SetVisibility(int theMode){
1284 SetVisibility(theMode,true);
1288 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1289 SALOME_Actor::SetVisibility(theMode);
1291 myNodeActor->VisibilityOff();
1292 myBaseActor->VisibilityOff();
1294 myNodeExtActor->VisibilityOff();
1296 my0DActor->VisibilityOff();
1297 //my0DExtActor->VisibilityOff();
1299 my1DActor->VisibilityOff();
1300 my1DExtActor->VisibilityOff();
1302 my2DActor->VisibilityOff();
1303 my2DExtActor->VisibilityOff();
1304 my3DActor->VisibilityOff();
1305 my3DExtActor->VisibilityOff();
1307 myScalarBarActor->VisibilityOff();
1308 myPointLabels->VisibilityOff();
1309 myCellsLabels->VisibilityOff();
1311 if(GetVisibility()){
1312 if(theIsUpdateRepersentation)
1313 SetRepresentation(GetRepresentation());
1315 if(myControlMode != eNone){
1316 switch(myControlMode){
1318 myNodeExtActor->VisibilityOn();
1322 my1DExtActor->VisibilityOn();
1325 case eBareBorderFace:
1326 case eOverConstrainedFace:
1327 my2DExtActor->VisibilityOn();
1329 case eBareBorderVolume:
1330 case eOverConstrainedVolume:
1331 my3DExtActor->VisibilityOn();
1334 case eMultiConnection2D:
1335 my1DExtActor->VisibilityOn();
1337 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1338 myScalarBarActor->VisibilityOn();
1342 if(myRepresentation != ePoint)
1343 myPickableActor->VisibilityOn();
1345 myNodeActor->VisibilityOn();
1348 if(myEntityMode & e0DElements){
1349 my0DActor->VisibilityOn();
1352 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1353 my1DActor->VisibilityOn();
1356 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1357 my2DActor->VisibilityOn();
1360 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1361 my3DActor->VisibilityOn();
1364 if(myIsPointsLabeled){
1365 myPointLabels->VisibilityOn();
1366 myNodeActor->VisibilityOn();
1369 if(myIsCellsLabeled)
1370 myCellsLabels->VisibilityOn();
1372 #ifndef DISABLE_PLOT2DVIEWER
1374 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1381 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1383 myEntityState = eAllEntity;
1385 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1386 myEntityState &= ~e0DElements;
1387 theMode &= ~e0DElements;
1390 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1391 myEntityState &= ~eEdges;
1395 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1396 myEntityState &= ~eFaces;
1400 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1401 myEntityState &= ~eVolumes;
1402 theMode &= ~eVolumes;
1406 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1407 theMode |= e0DElements;
1409 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1412 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1415 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1416 theMode |= eVolumes;
1419 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1421 myEntityMode = theMode;
1422 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1423 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1424 aFilter->ClearRegisteredCellsWithType();
1425 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1427 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1428 aHightFilter->ClearRegisteredCellsWithType();
1429 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1431 if (myEntityMode & e0DElements) {
1432 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1433 aFilter->RegisterCellsWithType(VTK_VERTEX);
1434 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1437 if (myEntityMode & eEdges) {
1438 if (MYDEBUG) MESSAGE("EDGES");
1439 aFilter->RegisterCellsWithType(VTK_LINE);
1440 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1442 aHightFilter->RegisterCellsWithType(VTK_LINE);
1443 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1446 if (myEntityMode & eFaces) {
1447 if (MYDEBUG) MESSAGE("FACES");
1448 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1449 aFilter->RegisterCellsWithType(VTK_POLYGON);
1450 aFilter->RegisterCellsWithType(VTK_QUAD);
1451 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1452 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1454 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1455 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1456 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1457 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1458 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1461 if (myEntityMode & eVolumes) {
1462 if (MYDEBUG) MESSAGE("VOLUMES");
1463 aFilter->RegisterCellsWithType(VTK_TETRA);
1464 aFilter->RegisterCellsWithType(VTK_VOXEL);
1465 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1466 aFilter->RegisterCellsWithType(VTK_WEDGE);
1467 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1468 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1469 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1470 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1471 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1472 //#ifdef VTK_HAVE_POLYHEDRON
1473 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1476 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1477 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1478 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1479 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1480 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1481 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1482 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1483 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1484 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1485 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1486 //#ifdef VTK_HAVE_POLYHEDRON
1487 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1491 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1492 SetVisibility(GetVisibility(),false);
1495 void SMESH_ActorDef::SetRepresentation (int theMode)
1497 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1498 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1499 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1502 myRepresentation = eSurface;
1503 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1504 myRepresentation = eEdge;
1505 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1506 myRepresentation = ePoint;
1511 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1514 if (!aNbFaces && !aNbVolumes) return;
1517 myRepresentation = theMode;
1520 if (!GetUnstructuredGrid()->GetNumberOfCells())
1521 myRepresentation = ePoint;
1524 if (myRepresentation == ePoint) {
1532 myPickableActor = myBaseActor;
1533 myNodeActor->SetVisibility(false);
1534 myNodeExtActor->SetVisibility(false);
1535 vtkProperty *aProp = NULL, *aBackProp = NULL;
1536 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1537 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1538 switch (myRepresentation) {
1540 myPickableActor = myNodeActor;
1541 myNodeActor->SetVisibility(true);
1542 aQuadraticMode = SMESH_Actor::eLines;
1543 aProp = aBackProp = myNodeProp;
1544 aReperesent = SMESH_DeviceActor::ePoint;
1547 aProp = aBackProp = myEdgeProp;
1548 aReperesent = SMESH_DeviceActor::eInsideframe;
1551 aProp = mySurfaceProp;
1552 aBackProp = myBackSurfaceProp;
1553 aReperesent = SMESH_DeviceActor::eSurface;
1557 my2DActor->SetProperty(aProp);
1558 my2DActor->SetBackfaceProperty(aBackProp);
1559 my2DActor->SetRepresentation(aReperesent);
1561 if(aQuadraticMode == SMESH_Actor::eLines)
1562 my2DActor->SetQuadraticArcMode(false);
1563 else if(aQuadraticMode == SMESH_Actor::eArcs)
1564 my2DActor->SetQuadraticArcMode(true);
1566 my2DExtActor->SetRepresentation(aReperesent);
1568 my3DActor->SetProperty(aProp);
1569 my3DActor->SetBackfaceProperty(aBackProp);
1570 my3DActor->SetRepresentation(aReperesent);
1572 //my0DExtActor->SetVisibility(false);
1573 my1DExtActor->SetVisibility(false);
1574 my2DExtActor->SetVisibility(false);
1575 my3DExtActor->SetVisibility(false);
1578 //my0DActor->SetProperty(aProp);
1579 //my0DActor->SetBackfaceProperty(aBackProp);
1580 my0DActor->SetRepresentation(aReperesent);
1581 //my0DExtActor->SetRepresentation(aReperesent);
1583 switch(myControlMode){
1585 case eMultiConnection:
1586 aProp = aBackProp = my1DProp;
1587 if(myRepresentation != ePoint)
1588 aReperesent = SMESH_DeviceActor::eInsideframe;
1592 if(aQuadraticMode == SMESH_Actor::eLines)
1593 my1DActor->SetQuadraticArcMode(false);
1594 else if(aQuadraticMode == SMESH_Actor::eArcs)
1595 my1DActor->SetQuadraticArcMode(true);
1597 my1DActor->SetProperty(aProp);
1598 my1DActor->SetBackfaceProperty(aBackProp);
1599 my1DActor->SetRepresentation(aReperesent);
1601 my1DExtActor->SetRepresentation(aReperesent);
1603 if(myIsPointsVisible)
1604 myPickableActor = myNodeActor;
1605 if(GetPointRepresentation())
1606 myNodeActor->SetVisibility(true);
1608 SetMapper(myPickableActor->GetMapper());
1610 SetVisibility(GetVisibility(),false);
1616 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1617 if ( myIsPointsVisible == theIsPointsVisible )
1619 myIsPointsVisible = theIsPointsVisible;
1620 SetRepresentation(GetRepresentation());
1623 bool SMESH_ActorDef::GetPointRepresentation(){
1624 return myIsPointsVisible || myIsPointsLabeled;
1628 void SMESH_ActorDef::UpdateHighlight(){
1629 myHighlitableActor->SetHighlited(false);
1630 myHighlitableActor->SetVisibility(false);
1632 bool anIsVisible = GetVisibility();
1634 switch(myRepresentation){
1635 case SMESH_DeviceActor::eSurface:
1636 case SMESH_DeviceActor::eWireframe:
1638 if(myIsHighlighted) {
1639 myHighlitableActor->SetProperty(myHighlightProp);
1640 }else if(myIsPreselected){
1641 myHighlitableActor->SetProperty(myPreselectProp);
1642 } else if(anIsVisible){
1643 (myRepresentation == eSurface) ?
1644 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1646 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1647 myHighlitableActor->SetHighlited(anIsVisible);
1648 myHighlitableActor->GetExtractUnstructuredGrid()->
1649 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1650 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1652 myHighlitableActor->SetVisibility(anIsVisible);
1655 case SMESH_DeviceActor::ePoint:
1657 if(myIsHighlighted) {
1658 myNodeActor->SetProperty(myHighlightProp);
1659 }else if(myIsPreselected) {
1660 myNodeActor->SetProperty(myPreselectProp);
1661 } else if(anIsVisible) {
1662 myNodeActor->SetProperty(myNodeProp);
1664 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1665 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1672 void SMESH_ActorDef::highlight(bool theHighlight){
1673 if ( myIsHighlighted == theHighlight )
1675 myIsHighlighted = theHighlight;
1680 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1681 if ( myIsPreselected == thePreselect )
1683 myIsPreselected = thePreselect;
1689 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1691 if (myPickableActor->GetIsOpaque())
1693 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1701 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1703 if (!myPickableActor->GetIsOpaque())
1705 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1713 void SMESH_ActorDef::Render(vtkRenderer *ren){
1714 unsigned long aTime = myTimeStamp->GetMTime();
1715 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1716 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1717 if(anObjTime > aTime || aClippingTime > aTime)
1722 void SMESH_ActorDef::Update(){
1723 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1725 if(GetControlMode() != eNone) {
1726 unsigned long aTime = myTimeStamp->GetMTime();
1727 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1728 if (anObjTime > aTime)
1729 SetControlMode(GetControlMode(),false);
1731 if(myIsPointsLabeled){
1732 SetPointsLabeled(myIsPointsLabeled);
1734 if(myIsCellsLabeled){
1735 SetCellsLabeled(myIsCellsLabeled);
1737 if(myIsFacesOriented){
1738 SetFacesOriented(myIsFacesOriented);
1740 SetEntityMode(GetEntityMode());
1741 SetVisibility(GetVisibility());
1743 myTimeStamp->Modified();
1748 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1749 SALOME_Actor::ReleaseGraphicsResources(renWin);
1751 myPickableActor->ReleaseGraphicsResources(renWin);
1755 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1756 vtkFloatingPointType* aColor = theProperty->GetColor();
1763 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1764 mySurfaceProp->SetOpacity(theValue);
1765 myBackSurfaceProp->SetOpacity(theValue);
1766 myEdgeProp->SetOpacity(theValue);
1767 myNodeProp->SetOpacity(theValue);
1769 my1DProp->SetOpacity(theValue);
1773 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1774 return mySurfaceProp->GetOpacity();
1778 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1779 mySurfaceProp->SetColor(r,g,b);
1780 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1781 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1782 aGroupObj->GetElementType() == SMDSAbs_Volume )
1783 myNameActor->SetBackgroundColor(r,g,b);
1785 myDeltaBrightness = delta;
1786 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1787 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1791 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1792 ::GetColor(mySurfaceProp,r,g,b);
1793 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1794 delta = myDeltaBrightness;
1797 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1798 myEdgeProp->SetColor(r,g,b);
1799 my1DProp->SetColor(r,g,b);
1800 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1801 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1802 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1803 myNameActor->SetBackgroundColor(r,g,b);
1807 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1808 ::GetColor(myEdgeProp,r,g,b);
1811 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1812 myOutLineProp->SetColor(r,g,b);
1816 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1817 ::GetColor(myOutLineProp,r,g,b);
1821 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1822 myNodeProp->SetColor(r,g,b);
1823 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1824 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1825 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1826 myNameActor->SetBackgroundColor(r,g,b);
1830 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1831 ::GetColor(myNodeProp,r,g,b);
1834 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1835 my0DProp->SetColor(r,g,b);
1836 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1837 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1838 myNameActor->SetBackgroundColor(r,g,b);
1842 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1843 ::GetColor(my0DProp,r,g,b);
1846 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1847 myHighlightProp->SetColor(r,g,b);
1851 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1852 ::GetColor(myHighlightProp,r,g,b);
1855 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1856 myPreselectProp->SetColor(r,g,b);
1860 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1861 ::GetColor(myPreselectProp,r,g,b);
1865 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1866 return myEdgeProp->GetLineWidth();
1870 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1871 myEdgeProp->SetLineWidth(theVal);
1873 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1874 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1880 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1881 my0DProp->SetPointSize(theVal);
1885 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1886 return my0DProp->GetPointSize();
1889 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1891 return myVisualObj->GetElemDimension( theObjId );
1896 IsImplicitFunctionUsed() const
1898 return myBaseActor->IsImplicitFunctionUsed();
1902 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1904 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1905 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1907 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1909 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1911 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1912 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1914 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1915 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1917 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1918 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1919 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1920 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1924 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1927 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1928 myCippingPlaneCont.push_back(thePlane);
1929 if(!IsImplicitFunctionUsed())
1930 SetImplicitFunctionUsed(true);
1932 return myCippingPlaneCont.size();
1937 RemoveAllClippingPlanes()
1939 myImplicitBoolean->GetFunction()->RemoveAllItems();
1940 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1941 myCippingPlaneCont.clear();
1942 SetImplicitFunctionUsed(false);
1947 GetNumberOfClippingPlanes()
1949 return myCippingPlaneCont.size();
1954 GetClippingPlane(vtkIdType theID)
1956 if(theID >= myCippingPlaneCont.size())
1958 return myCippingPlaneCont[theID].Get();
1961 void SMESH_ActorDef::UpdateScalarBar()
1963 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1967 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1969 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1970 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1972 aScalarBarTitleProp->SetFontFamilyToArial();
1974 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1976 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1977 if ( f.family() == "Arial" )
1978 aScalarBarTitleProp->SetFontFamilyToArial();
1979 else if ( f.family() == "Courier" )
1980 aScalarBarTitleProp->SetFontFamilyToCourier();
1981 else if ( f.family() == "Times" )
1982 aScalarBarTitleProp->SetFontFamilyToTimes();
1985 aScalarBarTitleProp->BoldOn();
1987 aScalarBarTitleProp->BoldOff();
1990 aScalarBarTitleProp->ItalicOn();
1992 aScalarBarTitleProp->ItalicOff();
1995 aScalarBarTitleProp->ShadowOn();
1997 aScalarBarTitleProp->ShadowOff();
2000 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2001 aScalarBarTitleProp->Delete();
2003 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2005 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2006 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2008 aScalarBarLabelProp->SetFontFamilyToArial();
2009 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2011 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2012 if( f.family() == "Arial" )
2013 aScalarBarLabelProp->SetFontFamilyToArial();
2014 else if( f.family() == "Courier" )
2015 aScalarBarLabelProp->SetFontFamilyToCourier();
2016 else if( f.family() == "Times" )
2017 aScalarBarLabelProp->SetFontFamilyToTimes();
2020 aScalarBarLabelProp->BoldOn();
2022 aScalarBarLabelProp->BoldOff();
2025 aScalarBarLabelProp->ItalicOn();
2027 aScalarBarLabelProp->ItalicOff();
2030 aScalarBarLabelProp->ShadowOn();
2032 aScalarBarLabelProp->ShadowOff();
2035 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2036 aScalarBarLabelProp->Delete();
2038 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2039 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2041 myScalarBarActor->SetOrientationToHorizontal();
2043 myScalarBarActor->SetOrientationToVertical();
2046 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2047 if( mgr->hasValue( "SMESH", name + "x" ) )
2048 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2050 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2051 if( mgr->hasValue( "SMESH", name + "y" ) )
2052 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2053 myScalarBarActor->SetPosition( aXVal, aYVal );
2055 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2056 if( mgr->hasValue( "SMESH", name + "width" ) )
2057 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2058 myScalarBarActor->SetWidth( aWVal );
2060 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2061 if( mgr->hasValue( "SMESH", name + "height" ) )
2062 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2063 myScalarBarActor->SetHeight( aHVal );
2066 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2067 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2068 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2071 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2072 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2073 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2075 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2076 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2078 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2079 myScalarBarActor->SetDistributionColoringType(coloringType);
2081 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2082 QColor(255, 255, 255));
2084 rgb[0]= distributionColor.red()/255.;
2085 rgb[1]= distributionColor.green()/255.;
2086 rgb[2]= distributionColor.blue()/255.;
2087 myScalarBarActor->SetDistributionColor(rgb);
2092 void SMESH_ActorDef::UpdateDistribution()
2094 if(SMESH::Controls::NumericalFunctor* fun =
2095 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2097 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2098 std::vector<int> nbEvents;
2099 std::vector<double> funValues;
2100 SMESH_VisualObjDef::TEntityList elems;
2101 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2102 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2103 std::vector<int> elemIds;
2104 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2105 elemIds.push_back( (*e)->GetID());
2106 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2107 double * range = lookupTable->GetRange();
2108 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2109 myScalarBarActor->SetDistribution(nbEvents);
2113 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2116 case SMESH_Actor::eLines :
2117 myHighlitableActor->SetQuadraticArcMode(false);
2118 my2DActor->SetQuadraticArcMode(false);
2119 my1DActor->SetQuadraticArcMode(false);
2121 case SMESH_Actor::eArcs :
2122 myHighlitableActor->SetQuadraticArcMode(true);
2123 if(GetRepresentation() != SMESH_Actor::ePoint) {
2124 my2DActor->SetQuadraticArcMode(true);
2125 my1DActor->SetQuadraticArcMode(true);
2134 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2136 if(myHighlitableActor->GetQuadraticArcMode())
2137 return SMESH_Actor::eArcs;
2139 return SMESH_Actor::eLines;
2142 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2144 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2145 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2146 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2149 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2151 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2152 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2153 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2154 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2157 #ifndef DISABLE_PLOT2DVIEWER
2158 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2161 my2dHistogram->clearAllPoints();
2163 if(SMESH::Controls::NumericalFunctor* fun =
2164 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2167 if(!my2dHistogram) {
2168 my2dHistogram = new SPlot2d_Histogram();
2169 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2170 my2dHistogram->setIO(anIO);
2173 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2174 std::vector<int> nbEvents;
2175 std::vector<double> funValues;
2176 SMESH_VisualObjDef::TEntityList elems;
2177 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2178 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2179 std::vector<int> elemIds;
2181 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2182 elemIds.push_back( (*e)->GetID());
2184 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2185 double * range = lookupTable->GetRange();
2186 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2188 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2189 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2191 if(funValues.size() >= 2)
2192 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2196 //Color of the histogram
2197 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2198 my2dHistogram->setAutoAssign(true);
2201 myScalarBarActor->GetDistributionColor(rgb);
2202 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2203 my2dHistogram->setColor(aColor);
2207 return my2dHistogram;