1 // Copyright (C) 2007-2010 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"
43 #ifndef DISABLE_PLOT2DVIEWER
44 #include <SPlot2d_Histogram.h>
47 #include <vtkProperty.h>
48 #include <vtkTimeStamp.h>
49 #include <vtkObjectFactory.h>
50 #include <vtkShrinkPolyData.h>
51 #include <vtkMergeFilter.h>
53 #include <vtkMatrix4x4.h>
54 #include <vtkUnstructuredGrid.h>
55 #include <vtkPointData.h>
56 #include <vtkCellData.h>
58 #include <vtkMapper.h>
59 #include <vtkRenderer.h>
62 #include <vtkIdList.h>
63 #include <vtkIntArray.h>
65 #include <vtkActor2D.h>
66 #include <vtkProperty2D.h>
67 #include <vtkPolyData.h>
68 #include <vtkMaskPoints.h>
69 #include <vtkTextProperty.h>
70 #include <vtkLabeledDataMapper.h>
71 #include <vtkSelectVisiblePoints.h>
73 #include <vtkLookupTable.h>
77 #include <vtkImplicitBoolean.h>
78 #include <vtkImplicitFunctionCollection.h>
80 #include <vtkConfigure.h>
81 #if !defined(VTK_XVERSION)
82 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
85 #include "utilities.h"
88 static int MYDEBUG = 1;
90 static int MYDEBUG = 1;
93 static int aLineWidthInc = 2;
96 SMESH_ActorDef* SMESH_ActorDef::New(){
97 return new SMESH_ActorDef();
101 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 const char* theEntry,
106 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
107 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
112 anActor->UpdateScalarBar();
117 SMESH_ActorDef::SMESH_ActorDef()
119 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
121 myTimeStamp = vtkTimeStamp::New();
123 myIsPointsVisible = false;
125 myIsShrinkable = false;
128 myIsFacesOriented = false;
130 myControlsPrecision = -1;
131 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
133 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
134 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
136 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
137 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
139 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
140 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
142 //Definition 2D and 3D devices of the actor
143 //-----------------------------------------
144 vtkFloatingPointType anRGB[3] = {1,1,1};
145 mySurfaceProp = vtkProperty::New();
146 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
147 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
149 myBackSurfaceProp = vtkProperty::New();
150 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
151 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
153 my2DActor = SMESH_DeviceActor::New();
154 my2DActor->SetUserMatrix(aMatrix);
155 my2DActor->PickableOff();
156 my2DActor->SetProperty(mySurfaceProp);
157 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
158 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
159 aFilter = my2DActor->GetExtractUnstructuredGrid();
160 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
161 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
162 aFilter->RegisterCellsWithType(VTK_POLYGON);
163 aFilter->RegisterCellsWithType(VTK_QUAD);
164 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
165 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
167 my2DExtProp = vtkProperty::New();
168 my2DExtProp->DeepCopy(mySurfaceProp);
169 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
170 anRGB[0] = 1 - anRGB[0];
171 anRGB[1] = 1 - anRGB[1];
172 anRGB[2] = 1 - anRGB[2];
173 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
175 my2DExtActor = SMESH_DeviceActor::New();
176 my2DExtActor->SetUserMatrix(aMatrix);
177 my2DExtActor->PickableOff();
178 my2DExtActor->SetProperty(my2DExtProp);
179 my2DExtActor->SetBackfaceProperty(my2DExtProp);
180 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
181 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
182 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
183 aFilter->RegisterCellsWithType(VTK_POLYGON);
184 aFilter->RegisterCellsWithType(VTK_QUAD);
185 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
186 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
188 my3DActor = SMESH_DeviceActor::New();
189 my3DActor->SetUserMatrix(aMatrix);
190 my3DActor->PickableOff();
191 my3DActor->SetProperty(mySurfaceProp);
192 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
193 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
194 aFilter = my3DActor->GetExtractUnstructuredGrid();
195 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
196 aFilter->RegisterCellsWithType(VTK_TETRA);
197 aFilter->RegisterCellsWithType(VTK_VOXEL);
198 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
199 aFilter->RegisterCellsWithType(VTK_WEDGE);
200 aFilter->RegisterCellsWithType(VTK_PYRAMID);
201 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
202 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
203 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
204 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
205 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
206 //#ifdef VTK_HAVE_POLYHEDRON
207 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
208 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
211 my3DExtActor = SMESH_DeviceActor::New();
212 my3DExtActor->SetUserMatrix(aMatrix);
213 my3DExtActor->PickableOff();
214 my3DExtActor->SetProperty(my2DExtProp);
215 my3DExtActor->SetBackfaceProperty(my2DExtProp);
216 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
217 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
218 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
219 aFilter->RegisterCellsWithType(VTK_TETRA);
220 aFilter->RegisterCellsWithType(VTK_VOXEL);
221 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
222 aFilter->RegisterCellsWithType(VTK_WEDGE);
223 aFilter->RegisterCellsWithType(VTK_PYRAMID);
224 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
225 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
226 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
227 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
228 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
229 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
231 //Definition 1D device of the actor
232 //---------------------------------
233 myEdgeProp = vtkProperty::New();
234 myEdgeProp->SetAmbient(1.0);
235 myEdgeProp->SetDiffuse(0.0);
236 myEdgeProp->SetSpecular(0.0);
237 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
238 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
239 myEdgeProp->SetLineWidth(aLineWidth);
241 my1DActor = SMESH_DeviceActor::New();
242 my1DActor->SetUserMatrix(aMatrix);
243 my1DActor->PickableOff();
244 my1DActor->SetHighlited(true);
245 my1DActor->SetProperty(myEdgeProp);
246 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
247 aFilter = my1DActor->GetExtractUnstructuredGrid();
248 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
249 aFilter->RegisterCellsWithType(VTK_LINE);
250 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
252 my1DProp = vtkProperty::New();
253 my1DProp->DeepCopy(myEdgeProp);
254 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
255 my1DProp->SetPointSize(aElem0DSize);
257 my1DExtProp = vtkProperty::New();
258 my1DExtProp->DeepCopy(myEdgeProp);
259 anRGB[0] = 1 - anRGB[0];
260 anRGB[1] = 1 - anRGB[1];
261 anRGB[2] = 1 - anRGB[2];
262 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
263 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
264 my1DExtProp->SetPointSize(aElem0DSize);
266 my1DExtActor = SMESH_DeviceActor::New();
267 my1DExtActor->SetUserMatrix(aMatrix);
268 my1DExtActor->PickableOff();
269 my1DExtActor->SetHighlited(true);
270 my1DExtActor->SetVisibility(false);
271 my1DExtActor->SetProperty(my1DExtProp);
272 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
273 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
274 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
275 aFilter->RegisterCellsWithType(VTK_LINE);
276 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
279 //Definition 0D device of the actor (0d elements)
280 //-----------------------------------------------
281 my0DProp = vtkProperty::New();
282 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
283 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
284 my0DProp->SetPointSize(aElem0DSize);
286 my0DActor = SMESH_DeviceActor::New();
287 my0DActor->SetUserMatrix(aMatrix);
288 my0DActor->SetStoreClippingMapping(true);
289 my0DActor->PickableOff();
290 my0DActor->SetVisibility(false);
291 my0DActor->SetProperty(my0DProp);
292 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
293 aFilter = my0DActor->GetExtractUnstructuredGrid();
294 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
295 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
296 aFilter->RegisterCellsWithType(VTK_VERTEX);
298 //my0DExtProp = vtkProperty::New();
299 //my0DExtProp->DeepCopy(my0DProp);
300 //anRGB[0] = 1 - anRGB[0];
301 //anRGB[1] = 1 - anRGB[1];
302 //anRGB[2] = 1 - anRGB[2];
303 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
304 //my0DExtProp->SetPointSize(aElem0DSize);
306 //my0DExtActor = SMESH_DeviceActor::New();
307 //my0DExtActor->SetUserMatrix(aMatrix);
308 //my0DExtActor->SetStoreClippingMapping(true);
309 //my0DExtActor->PickableOff();
310 //my0DExtActor->SetHighlited(true);
311 //my0DExtActor->SetVisibility(false);
312 //my0DExtActor->SetProperty(my0DExtProp);
313 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
314 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
315 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
316 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
317 //aFilter->RegisterCellsWithType(VTK_VERTEX);
320 //Definition 0D device of the actor (nodes)
321 //-----------------------------------------
322 myNodeProp = vtkProperty::New();
323 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
324 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
326 myNodeActor = SMESH_DeviceActor::New();
327 myNodeActor->SetUserMatrix(aMatrix);
328 myNodeActor->SetStoreClippingMapping(true);
329 myNodeActor->PickableOff();
330 myNodeActor->SetVisibility(false);
331 myNodeActor->SetProperty(myNodeProp);
332 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
333 aFilter = myNodeActor->GetExtractUnstructuredGrid();
334 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
336 myNodeExtProp = vtkProperty::New();
337 myNodeExtProp->DeepCopy(myNodeProp);
338 anRGB[0] = 1 - anRGB[0];
339 anRGB[1] = 1 - anRGB[1];
340 anRGB[2] = 1 - anRGB[2];
341 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
343 myNodeExtActor = SMESH_DeviceActor::New();
344 myNodeExtActor->SetUserMatrix(aMatrix);
345 myNodeExtActor->SetStoreClippingMapping(true);
346 myNodeExtActor->PickableOff();
347 myNodeExtActor->SetHighlited(true);
348 myNodeExtActor->SetVisibility(false);
349 myNodeExtActor->SetProperty(myNodeExtProp);
350 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
351 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
352 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
353 aFilter->RegisterCellsWithType(VTK_VERTEX);
355 //Definition of Pickable and Highlitable engines
356 //----------------------------------------------
358 myBaseActor = SMESH_DeviceActor::New();
359 myBaseActor->SetUserMatrix(aMatrix);
360 myBaseActor->SetStoreGemetryMapping(true);
361 myBaseActor->GetProperty()->SetOpacity(0.0);
363 myPickableActor = myBaseActor;
365 myHighlightProp = vtkProperty::New();
366 myHighlightProp->SetAmbient(1.0);
367 myHighlightProp->SetDiffuse(0.0);
368 myHighlightProp->SetSpecular(0.0);
369 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
370 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
371 myHighlightProp->SetPointSize(aElem0DSize); // ??
372 myHighlightProp->SetRepresentation(1);
374 myPreselectProp = vtkProperty::New();
375 myPreselectProp->SetAmbient(1.0);
376 myPreselectProp->SetDiffuse(0.0);
377 myPreselectProp->SetSpecular(0.0);
378 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
379 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
380 myPreselectProp->SetPointSize(aElem0DSize); // ??
381 myPreselectProp->SetRepresentation(1);
383 myHighlitableActor = SMESH_DeviceActor::New();
384 myHighlitableActor->SetUserMatrix(aMatrix);
385 myHighlitableActor->PickableOff();
386 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
393 myControlMode = eNone;
394 myControlActor = my2DActor;
396 //Definition of myScalarBarActor
397 //------------------------------
398 myLookupTable = vtkLookupTable::New();
399 //Fix for Bug PAL5195 - SMESH764:
400 //Controls - Aspect Ratio: incorrect colors of the best and worst values
401 myLookupTable->SetHueRange(0.667,0.0);
403 myScalarBarActor = SMESH_ScalarBarActor::New();
404 myScalarBarActor->SetVisibility(false);
405 myScalarBarActor->SetLookupTable(myLookupTable);
408 //Incorrect "Min value" in Scalar Bar in Mesh:
409 // myScalarBarActor->SetLabelFormat("%.4g");
410 // changes was commented because of regression bug IPAL 19981
412 mgr = SUIT_Session::session()->resourceMgr();
416 //Definition of points numbering pipeline
417 //---------------------------------------
418 myPointsNumDataSet = vtkUnstructuredGrid::New();
420 myPtsMaskPoints = vtkMaskPoints::New();
421 myPtsMaskPoints->SetInput(myPointsNumDataSet);
422 myPtsMaskPoints->SetOnRatio(1);
424 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
425 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
426 myPtsSelectVisiblePoints->SelectInvisibleOff();
427 myPtsSelectVisiblePoints->SetTolerance(0.1);
429 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
430 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
431 #if (VTK_XVERSION < 0x050200)
432 myPtsLabeledDataMapper->SetLabelFormat("%g");
434 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
436 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
437 aPtsTextProp->SetFontFamilyToTimes();
438 static int aPointsFontSize = 10;
439 aPtsTextProp->SetFontSize(aPointsFontSize);
440 aPtsTextProp->SetBold(1);
441 aPtsTextProp->SetItalic(0);
442 aPtsTextProp->SetShadow(0);
443 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
444 aPtsTextProp->Delete();
446 myEntityMode = eAllEntity;
448 myIsPointsLabeled = false;
450 myPointLabels = vtkActor2D::New();
451 myPointLabels->SetMapper(myPtsLabeledDataMapper);
452 myPointLabels->GetProperty()->SetColor(1,1,1);
453 myPointLabels->SetVisibility(myIsPointsLabeled);
456 //Definition of cells numbering pipeline
457 //---------------------------------------
458 myCellsNumDataSet = vtkUnstructuredGrid::New();
460 myCellCenters = VTKViewer_CellCenters::New();
461 myCellCenters->SetInput(myCellsNumDataSet);
463 myClsMaskPoints = vtkMaskPoints::New();
464 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
465 myClsMaskPoints->SetOnRatio(1);
467 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
468 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
469 myClsSelectVisiblePoints->SelectInvisibleOff();
470 myClsSelectVisiblePoints->SetTolerance(0.1);
472 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
473 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
474 #if (VTK_XVERSION < 0x050200)
475 myClsLabeledDataMapper->SetLabelFormat("%g");
477 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
479 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
480 aClsTextProp->SetFontFamilyToTimes();
481 static int aCellsFontSize = 12;
482 aClsTextProp->SetFontSize(aCellsFontSize);
483 aClsTextProp->SetBold(1);
484 aClsTextProp->SetItalic(0);
485 aClsTextProp->SetShadow(0);
486 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
487 aClsTextProp->Delete();
489 myIsCellsLabeled = false;
491 myCellsLabels = vtkActor2D::New();
492 myCellsLabels->SetMapper(myClsLabeledDataMapper);
493 myCellsLabels->GetProperty()->SetColor(0,1,0);
494 myCellsLabels->SetVisibility(myIsCellsLabeled);
497 myImplicitBoolean = vtkImplicitBoolean::New();
498 myImplicitBoolean->SetOperationTypeToIntersection();
502 //Quadratic 2D elements representation
503 //-----------------------------------------------------------------------------
504 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
505 if(aQuadratic2DMode == 0){
506 myHighlitableActor->SetQuadraticArcMode(false);
507 my2DActor->SetQuadraticArcMode(false);
508 my1DActor->SetQuadraticArcMode(false);
510 else if(aQuadratic2DMode == 1){
511 myHighlitableActor->SetQuadraticArcMode(true);
512 my2DActor->SetQuadraticArcMode(true);
513 my1DActor->SetQuadraticArcMode(true);
516 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
517 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
518 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
520 // Set colors of the name actor
521 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
522 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
523 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
524 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
526 #ifndef DISABLE_PLOT2DVIEWER
533 SMESH_ActorDef::~SMESH_ActorDef()
535 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
537 #ifndef DISABLE_PLOT2DVIEWER
539 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
540 delete my2dHistogram;
544 // caught by SMESHGUI::ProcessEvents() static method
545 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
547 myScalarBarActor->Delete();
548 myLookupTable->Delete();
550 mySurfaceProp->Delete();
551 myBackSurfaceProp->Delete();
553 myEdgeProp->Delete();
554 myHighlightProp->Delete();
555 myPreselectProp->Delete();
557 myNodeProp->Delete();
558 myNodeExtProp->Delete();
563 //my0DExtProp->Delete();
564 //my0DExtActor->Delete();
569 my1DExtProp->Delete();
570 my1DExtActor->Delete();
573 my2DExtProp->Delete();
574 my2DExtActor->Delete();
576 my3DExtActor->Delete();
578 myNodeActor->Delete();
579 myBaseActor->Delete();
581 myNodeExtActor->Delete();
583 myHighlitableActor->Delete();
585 //Deleting of points numbering pipeline
586 //---------------------------------------
587 myPointsNumDataSet->Delete();
589 // commented: porting to vtk 5.0
590 // myPtsLabeledDataMapper->RemoveAllInputs();
591 myPtsLabeledDataMapper->Delete();
593 // commented: porting to vtk 5.0
594 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
595 myPtsSelectVisiblePoints->Delete();
597 // commented: porting to vtk 5.0
598 // myPtsMaskPoints->UnRegisterAllOutputs();
599 myPtsMaskPoints->Delete();
601 myPointLabels->Delete();
604 //Deleting of cells numbering pipeline
605 //---------------------------------------
606 myCellsNumDataSet->Delete();
608 myClsLabeledDataMapper->RemoveAllInputs();
609 myClsLabeledDataMapper->Delete();
611 // commented: porting to vtk 5.0
612 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
613 myClsSelectVisiblePoints->Delete();
615 // commented: porting to vtk 5.0
616 // myClsMaskPoints->UnRegisterAllOutputs();
617 myClsMaskPoints->Delete();
619 // commented: porting to vtk 5.0
620 // myCellCenters->UnRegisterAllOutputs();
621 myCellCenters->Delete();
623 myCellsLabels->Delete();
625 myImplicitBoolean->Delete();
627 myTimeStamp->Delete();
631 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
633 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
635 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
637 if ( myIsPointsLabeled )
639 myPointsNumDataSet->ShallowCopy(aGrid);
640 vtkDataSet *aDataSet = myPointsNumDataSet;
642 int aNbElem = aDataSet->GetNumberOfPoints();
644 vtkIntArray *anArray = vtkIntArray::New();
645 anArray->SetNumberOfValues( aNbElem );
647 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
649 int aSMDSId = myVisualObj->GetNodeObjId( anId );
650 anArray->SetValue( anId, aSMDSId );
653 aDataSet->GetPointData()->SetScalars( anArray );
655 myPtsMaskPoints->SetInput( aDataSet );
656 myPointLabels->SetVisibility( GetVisibility() );
660 myPointLabels->SetVisibility( false );
662 SetRepresentation(GetRepresentation());
663 myTimeStamp->Modified();
667 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
669 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
670 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
671 if(myIsCellsLabeled){
672 myCellsNumDataSet->ShallowCopy(aGrid);
673 vtkDataSet *aDataSet = myCellsNumDataSet;
674 int aNbElem = aDataSet->GetNumberOfCells();
675 vtkIntArray *anArray = vtkIntArray::New();
676 anArray->SetNumberOfValues(aNbElem);
677 for(int anId = 0; anId < aNbElem; anId++){
678 int aSMDSId = myVisualObj->GetElemObjId(anId);
679 anArray->SetValue(anId,aSMDSId);
681 aDataSet->GetCellData()->SetScalars(anArray);
682 myCellCenters->SetInput(aDataSet);
683 myCellsLabels->SetVisibility(GetVisibility());
685 myCellsLabels->SetVisibility(false);
687 myTimeStamp->Modified();
691 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
693 myIsFacesOriented = theIsFacesOriented;
695 my2DActor->SetFacesOriented(theIsFacesOriented);
696 my3DActor->SetFacesOriented(theIsFacesOriented);
698 myTimeStamp->Modified();
701 bool SMESH_ActorDef::GetFacesOriented()
703 return myIsFacesOriented;
706 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
708 my2DActor->SetFacesOrientationColor( theColor );
709 my3DActor->SetFacesOrientationColor( theColor );
712 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
714 my3DActor->GetFacesOrientationColor( theColor );
717 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
719 my2DActor->SetFacesOrientationScale( theScale );
720 my3DActor->SetFacesOrientationScale( theScale );
723 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
725 return my3DActor->GetFacesOrientationScale();
728 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
730 my2DActor->SetFacesOrientation3DVectors( theState );
731 my3DActor->SetFacesOrientation3DVectors( theState );
734 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
736 return my3DActor->GetFacesOrientation3DVectors();
742 SetControlMode(eControl theMode)
744 SetControlMode(theMode,true);
750 SetControlMode(eControl theMode,
751 bool theCheckEntityMode)
753 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
757 myControlMode = eNone;
758 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
760 my0DActor->GetMapper()->SetScalarVisibility(false);
761 my1DActor->GetMapper()->SetScalarVisibility(false);
762 my2DActor->GetMapper()->SetScalarVisibility(false);
763 my3DActor->GetMapper()->SetScalarVisibility(false);
764 myScalarBarActor->SetVisibility(false);
766 bool anIsScalarVisible = theMode > eNone;
768 if(anIsScalarVisible) {
772 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
773 aControl->SetPrecision( myControlsPrecision );
774 myFunctor.reset( aControl );
775 myControlActor = my1DActor;
780 myFunctor.reset(new SMESH::Controls::Length2D());
781 myControlActor = my2DActor;
785 myFunctor.reset(new SMESH::Controls::FreeBorders());
786 myControlActor = my1DActor;
789 myFunctor.reset(new SMESH::Controls::FreeEdges());
790 myControlActor = my2DActor;
793 myFunctor.reset(new SMESH::Controls::FreeNodes());
794 myControlActor = myNodeActor;
797 myFunctor.reset(new SMESH::Controls::FreeFaces());
798 myControlActor = my2DActor;
800 case eBareBorderFace:
801 myFunctor.reset(new SMESH::Controls::BareBorderFace());
802 myControlActor = my2DActor;
804 case eOverConstrainedFace:
805 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
806 myControlActor = my2DActor;
808 case eMultiConnection:
809 myFunctor.reset(new SMESH::Controls::MultiConnection());
810 myControlActor = my1DActor;
812 case eMultiConnection2D:
813 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
814 myControlActor = my2DActor;
818 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
819 aControl->SetPrecision( myControlsPrecision );
820 myFunctor.reset( aControl );
821 myControlActor = my2DActor;
826 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
827 aControl->SetPrecision( myControlsPrecision );
828 myFunctor.reset( aControl );
829 myControlActor = my2DActor;
834 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
835 aControl->SetPrecision( myControlsPrecision );
836 myFunctor.reset( aControl );
837 myControlActor = my2DActor;
842 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
843 aControl->SetPrecision( myControlsPrecision );
844 myFunctor.reset( aControl );
845 myControlActor = my3DActor;
850 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
851 aControl->SetPrecision( myControlsPrecision );
852 myFunctor.reset( aControl );
853 myControlActor = my3DActor;
856 case eMaxElementLength2D:
858 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
859 aControl->SetPrecision( myControlsPrecision );
860 myFunctor.reset( aControl );
861 myControlActor = my2DActor;
864 case eMaxElementLength3D:
866 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
867 aControl->SetPrecision( myControlsPrecision );
868 myFunctor.reset( aControl );
869 myControlActor = my3DActor;
872 case eBareBorderVolume:
874 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
875 myControlActor = my3DActor;
878 case eOverConstrainedVolume:
880 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
881 myControlActor = my3DActor;
886 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
887 aControl->SetPrecision( myControlsPrecision );
888 myFunctor.reset( aControl );
889 myControlActor = my2DActor;
894 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
895 aControl->SetPrecision( myControlsPrecision );
896 myFunctor.reset( aControl );
897 myControlActor = my2DActor;
902 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
903 aControl->SetPrecision( myControlsPrecision );
904 myFunctor.reset( aControl );
905 myControlActor = my2DActor;
912 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
913 vtkIdType aNbCells = aGrid->GetNumberOfCells();
915 myControlMode = theMode;
916 switch(myControlMode){
918 myNodeExtActor->SetExtControlMode(myFunctor);
922 my1DExtActor->SetExtControlMode(myFunctor);
925 case eBareBorderFace:
926 case eOverConstrainedFace:
927 my2DExtActor->SetExtControlMode(myFunctor);
929 case eBareBorderVolume:
930 case eOverConstrainedVolume:
931 my3DExtActor->SetExtControlMode(myFunctor);
934 case eMultiConnection2D:
935 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
936 UpdateDistribution();
939 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
940 UpdateDistribution();
944 if(theCheckEntityMode){
945 if(myControlActor == my1DActor)
946 SetEntityMode(eEdges);
947 else if(myControlActor == my2DActor){
948 switch(myControlMode){
952 case eMultiConnection2D:
953 //SetEntityMode(eEdges);
954 SetEntityMode(eFaces);
957 SetEntityMode(eFaces);
959 }else if(myControlActor == my3DActor)
960 SetEntityMode(eVolumes);
965 if(theCheckEntityMode)
966 myEntityMode = eAllEntity;
970 SetRepresentation(GetRepresentation());
972 myTimeStamp->Modified();
977 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
978 theRenderer->AddActor(myNodeActor);
979 theRenderer->AddActor(myBaseActor);
981 theRenderer->AddActor(myNodeExtActor);
983 my3DActor->AddToRender(theRenderer);
984 my3DExtActor->AddToRender(theRenderer);
985 my2DActor->AddToRender(theRenderer);
986 my2DExtActor->AddToRender(theRenderer);
988 theRenderer->AddActor(my1DActor);
989 theRenderer->AddActor(my1DExtActor);
991 theRenderer->AddActor(my0DActor);
992 //theRenderer->AddActor(my0DExtActor);
994 theRenderer->AddActor(myHighlitableActor);
996 theRenderer->AddActor2D(myScalarBarActor);
998 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
999 myClsSelectVisiblePoints->SetRenderer(theRenderer);
1001 theRenderer->AddActor2D(myPointLabels);
1002 theRenderer->AddActor2D(myCellsLabels);
1004 // the superclass' method should be called at the end
1005 // (in particular, for correct work of selection)
1006 SALOME_Actor::AddToRender(theRenderer);
1009 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1010 SALOME_Actor::RemoveFromRender(theRenderer);
1012 theRenderer->RemoveActor(myNodeActor);
1013 theRenderer->RemoveActor(myBaseActor);
1015 theRenderer->RemoveActor(myNodeExtActor);
1017 theRenderer->RemoveActor(myHighlitableActor);
1019 theRenderer->RemoveActor(my0DActor);
1020 //theRenderer->RemoveActor(my0DExtActor);
1022 theRenderer->RemoveActor(my1DActor);
1023 theRenderer->RemoveActor(my1DExtActor);
1025 my2DActor->RemoveFromRender(theRenderer);
1026 my2DExtActor->RemoveFromRender(theRenderer);
1027 my3DActor->RemoveFromRender(theRenderer);
1028 my3DExtActor->RemoveFromRender(theRenderer);
1030 theRenderer->RemoveActor(myScalarBarActor);
1031 theRenderer->RemoveActor(myPointLabels);
1032 theRenderer->RemoveActor(myCellsLabels);
1036 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1037 const char* theEntry,
1038 const char* theName,
1041 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1045 myVisualObj = theVisualObj;
1046 myVisualObj->Update(theIsClear);
1048 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1049 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1051 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1053 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1055 my0DActor->Init(myVisualObj,myImplicitBoolean);
1056 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1058 my1DActor->Init(myVisualObj,myImplicitBoolean);
1059 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1061 my2DActor->Init(myVisualObj,myImplicitBoolean);
1062 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1063 my3DActor->Init(myVisualObj,myImplicitBoolean);
1064 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1066 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1067 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1069 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1070 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1072 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1073 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1074 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1075 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1077 vtkFloatingPointType aFactor, aUnits;
1078 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1079 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1080 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1082 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1086 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1087 SetIsShrunkable(true);
1089 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1091 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1092 SetRepresentation(-1);
1095 SetRepresentation(eEdge);
1096 }else if(aMode == 1){
1097 SetRepresentation(eSurface);
1098 }else if(aMode == 2){
1099 SetRepresentation(ePoint);
1106 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1107 SetIsDisplayNameActor( true );
1109 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1110 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1111 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1113 myTimeStamp->Modified();
1119 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1120 return myNodeActor->GetBounds();
1124 vtkDataSet* SMESH_ActorDef::GetInput(){
1125 return GetUnstructuredGrid();
1129 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1130 Superclass::SetTransform(theTransform);
1132 myNodeActor->SetTransform(theTransform);
1133 myBaseActor->SetTransform(theTransform);
1135 myHighlitableActor->SetTransform(theTransform);
1137 myNodeExtActor->SetTransform(theTransform);
1139 my0DActor->SetTransform(theTransform);
1140 //my0DExtActor->SetTransform(theTransform);
1142 my1DActor->SetTransform(theTransform);
1143 my1DExtActor->SetTransform(theTransform);
1145 my2DActor->SetTransform(theTransform);
1146 my2DExtActor->SetTransform(theTransform);
1147 my3DActor->SetTransform(theTransform);
1148 my3DExtActor->SetTransform(theTransform);
1154 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1155 vtkLODActor::SetMapper(theMapper);
1159 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1160 SALOME_Actor::ShallowCopy(prop);
1164 vtkMapper* SMESH_ActorDef::GetMapper(){
1165 return myPickableActor->GetMapper();
1169 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1170 return myVisualObj->GetUnstructuredGrid();
1174 bool SMESH_ActorDef::IsInfinitive(){
1175 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1177 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1178 ( aDataSet->GetNumberOfCells() == 1 &&
1179 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1180 return SALOME_Actor::IsInfinitive();
1184 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1185 if ( myIsShrinkable == theShrunkable )
1187 myIsShrinkable = theShrunkable;
1191 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1192 return myBaseActor->GetShrinkFactor();
1195 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1196 myBaseActor->SetShrinkFactor(theValue);
1198 my1DActor->SetShrinkFactor(theValue);
1199 my1DExtActor->SetShrinkFactor(theValue);
1201 my2DActor->SetShrinkFactor(theValue);
1202 my2DExtActor->SetShrinkFactor(theValue);
1203 my3DActor->SetShrinkFactor(theValue);
1204 my3DExtActor->SetShrinkFactor(theValue);
1209 void SMESH_ActorDef::SetShrink(){
1210 if(!myIsShrinkable) return;
1212 myBaseActor->SetShrink();
1214 my1DActor->SetShrink();
1215 my1DExtActor->SetShrink();
1217 my2DActor->SetShrink();
1218 my2DExtActor->SetShrink();
1219 my3DActor->SetShrink();
1220 my3DExtActor->SetShrink();
1226 void SMESH_ActorDef::UnShrink(){
1227 if(!myIsShrunk) return;
1229 myBaseActor->UnShrink();
1231 my1DActor->UnShrink();
1232 my1DExtActor->UnShrink();
1234 my2DActor->UnShrink();
1235 my2DExtActor->UnShrink();
1236 my3DActor->UnShrink();
1237 my3DExtActor->UnShrink();
1244 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1245 return myPickableActor->GetNodeObjId(theVtkID);
1248 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1249 return myPickableActor->GetNodeCoord(theObjID);
1253 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1254 return myPickableActor->GetElemObjId(theVtkID);
1257 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1258 return myPickableActor->GetElemCell(theObjID);
1262 void SMESH_ActorDef::SetVisibility(int theMode){
1263 SetVisibility(theMode,true);
1267 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1268 SALOME_Actor::SetVisibility(theMode);
1270 myNodeActor->VisibilityOff();
1271 myBaseActor->VisibilityOff();
1273 myNodeExtActor->VisibilityOff();
1275 my0DActor->VisibilityOff();
1276 //my0DExtActor->VisibilityOff();
1278 my1DActor->VisibilityOff();
1279 my1DExtActor->VisibilityOff();
1281 my2DActor->VisibilityOff();
1282 my2DExtActor->VisibilityOff();
1283 my3DActor->VisibilityOff();
1284 my3DExtActor->VisibilityOff();
1286 myScalarBarActor->VisibilityOff();
1287 myPointLabels->VisibilityOff();
1288 myCellsLabels->VisibilityOff();
1290 if(GetVisibility()){
1291 if(theIsUpdateRepersentation)
1292 SetRepresentation(GetRepresentation());
1294 if(myControlMode != eNone){
1295 switch(myControlMode){
1297 myNodeExtActor->VisibilityOn();
1301 my1DExtActor->VisibilityOn();
1304 case eBareBorderFace:
1305 case eOverConstrainedFace:
1306 my2DExtActor->VisibilityOn();
1308 case eBareBorderVolume:
1309 case eOverConstrainedVolume:
1310 my3DExtActor->VisibilityOn();
1313 case eMultiConnection2D:
1314 my1DExtActor->VisibilityOn();
1316 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1317 myScalarBarActor->VisibilityOn();
1321 if(myRepresentation != ePoint)
1322 myPickableActor->VisibilityOn();
1324 myNodeActor->VisibilityOn();
1327 if(myEntityMode & e0DElements){
1328 my0DActor->VisibilityOn();
1331 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1332 my1DActor->VisibilityOn();
1335 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1336 my2DActor->VisibilityOn();
1339 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1340 my3DActor->VisibilityOn();
1343 if(myIsPointsLabeled){
1344 myPointLabels->VisibilityOn();
1345 myNodeActor->VisibilityOn();
1348 if(myIsCellsLabeled)
1349 myCellsLabels->VisibilityOn();
1351 #ifndef DISABLE_PLOT2DVIEWER
1353 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1360 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1362 myEntityState = eAllEntity;
1364 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1365 myEntityState &= ~e0DElements;
1366 theMode &= ~e0DElements;
1369 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1370 myEntityState &= ~eEdges;
1374 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1375 myEntityState &= ~eFaces;
1379 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1380 myEntityState &= ~eVolumes;
1381 theMode &= ~eVolumes;
1385 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1386 theMode |= e0DElements;
1388 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1391 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1394 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1395 theMode |= eVolumes;
1398 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1400 myEntityMode = theMode;
1401 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1402 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1403 aFilter->ClearRegisteredCellsWithType();
1404 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1406 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1407 aHightFilter->ClearRegisteredCellsWithType();
1408 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1410 if (myEntityMode & e0DElements) {
1411 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1412 aFilter->RegisterCellsWithType(VTK_VERTEX);
1413 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1416 if (myEntityMode & eEdges) {
1417 if (MYDEBUG) MESSAGE("EDGES");
1418 aFilter->RegisterCellsWithType(VTK_LINE);
1419 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1421 aHightFilter->RegisterCellsWithType(VTK_LINE);
1422 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1425 if (myEntityMode & eFaces) {
1426 if (MYDEBUG) MESSAGE("FACES");
1427 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1428 aFilter->RegisterCellsWithType(VTK_POLYGON);
1429 aFilter->RegisterCellsWithType(VTK_QUAD);
1430 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1431 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1433 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1434 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1435 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1436 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1437 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1440 if (myEntityMode & eVolumes) {
1441 if (MYDEBUG) MESSAGE("VOLUMES");
1442 aFilter->RegisterCellsWithType(VTK_TETRA);
1443 aFilter->RegisterCellsWithType(VTK_VOXEL);
1444 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1445 aFilter->RegisterCellsWithType(VTK_WEDGE);
1446 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1447 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1448 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1449 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1450 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1451 //#ifdef VTK_HAVE_POLYHEDRON
1452 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1455 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1456 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1457 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1458 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1459 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1460 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1461 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1462 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1463 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1464 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1465 //#ifdef VTK_HAVE_POLYHEDRON
1466 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1470 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1471 SetVisibility(GetVisibility(),false);
1474 void SMESH_ActorDef::SetRepresentation (int theMode)
1476 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1477 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1478 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1481 myRepresentation = eSurface;
1482 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1483 myRepresentation = eEdge;
1484 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1485 myRepresentation = ePoint;
1490 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1493 if (!aNbFaces && !aNbVolumes) return;
1496 myRepresentation = theMode;
1499 if (!GetUnstructuredGrid()->GetNumberOfCells())
1500 myRepresentation = ePoint;
1503 if (myRepresentation == ePoint) {
1511 myPickableActor = myBaseActor;
1512 myNodeActor->SetVisibility(false);
1513 myNodeExtActor->SetVisibility(false);
1514 vtkProperty *aProp = NULL, *aBackProp = NULL;
1515 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1516 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1517 switch (myRepresentation) {
1519 myPickableActor = myNodeActor;
1520 myNodeActor->SetVisibility(true);
1521 aQuadraticMode = SMESH_Actor::eLines;
1522 aProp = aBackProp = myNodeProp;
1523 aReperesent = SMESH_DeviceActor::ePoint;
1526 aProp = aBackProp = myEdgeProp;
1527 aReperesent = SMESH_DeviceActor::eInsideframe;
1530 aProp = mySurfaceProp;
1531 aBackProp = myBackSurfaceProp;
1532 aReperesent = SMESH_DeviceActor::eSurface;
1536 my2DActor->SetProperty(aProp);
1537 my2DActor->SetBackfaceProperty(aBackProp);
1538 my2DActor->SetRepresentation(aReperesent);
1540 if(aQuadraticMode == SMESH_Actor::eLines)
1541 my2DActor->SetQuadraticArcMode(false);
1542 else if(aQuadraticMode == SMESH_Actor::eArcs)
1543 my2DActor->SetQuadraticArcMode(true);
1545 my2DExtActor->SetRepresentation(aReperesent);
1547 my3DActor->SetProperty(aProp);
1548 my3DActor->SetBackfaceProperty(aBackProp);
1549 my3DActor->SetRepresentation(aReperesent);
1551 //my0DExtActor->SetVisibility(false);
1552 my1DExtActor->SetVisibility(false);
1553 my2DExtActor->SetVisibility(false);
1554 my3DExtActor->SetVisibility(false);
1557 //my0DActor->SetProperty(aProp);
1558 //my0DActor->SetBackfaceProperty(aBackProp);
1559 my0DActor->SetRepresentation(aReperesent);
1560 //my0DExtActor->SetRepresentation(aReperesent);
1562 switch(myControlMode){
1564 case eMultiConnection:
1565 aProp = aBackProp = my1DProp;
1566 if(myRepresentation != ePoint)
1567 aReperesent = SMESH_DeviceActor::eInsideframe;
1571 if(aQuadraticMode == SMESH_Actor::eLines)
1572 my1DActor->SetQuadraticArcMode(false);
1573 else if(aQuadraticMode == SMESH_Actor::eArcs)
1574 my1DActor->SetQuadraticArcMode(true);
1576 my1DActor->SetProperty(aProp);
1577 my1DActor->SetBackfaceProperty(aBackProp);
1578 my1DActor->SetRepresentation(aReperesent);
1580 my1DExtActor->SetRepresentation(aReperesent);
1582 if(myIsPointsVisible)
1583 myPickableActor = myNodeActor;
1584 if(GetPointRepresentation())
1585 myNodeActor->SetVisibility(true);
1587 SetMapper(myPickableActor->GetMapper());
1589 SetVisibility(GetVisibility(),false);
1595 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1596 if ( myIsPointsVisible == theIsPointsVisible )
1598 myIsPointsVisible = theIsPointsVisible;
1599 SetRepresentation(GetRepresentation());
1602 bool SMESH_ActorDef::GetPointRepresentation(){
1603 return myIsPointsVisible || myIsPointsLabeled;
1607 void SMESH_ActorDef::UpdateHighlight(){
1608 myHighlitableActor->SetVisibility(false);
1609 myHighlitableActor->SetHighlited(false);
1611 if(myIsHighlighted){
1612 myHighlitableActor->SetProperty(myHighlightProp);
1613 }else if(myIsPreselected){
1614 myHighlitableActor->SetProperty(myPreselectProp);
1617 bool anIsVisible = GetVisibility();
1619 if(myIsHighlighted || myIsPreselected){
1620 if(GetUnstructuredGrid()->GetNumberOfCells()){
1621 myHighlitableActor->SetHighlited(anIsVisible);
1622 myHighlitableActor->SetVisibility(anIsVisible);
1623 myHighlitableActor->GetExtractUnstructuredGrid()->
1624 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1625 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1626 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1627 myHighlitableActor->SetHighlited(anIsVisible);
1628 myHighlitableActor->GetExtractUnstructuredGrid()->
1629 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1630 myHighlitableActor->SetVisibility(anIsVisible);
1631 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1633 VTK::MarkerType aMarkerType = GetMarkerType();
1634 if(aMarkerType != VTK::MT_USER)
1635 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1637 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1643 void SMESH_ActorDef::highlight(bool theHighlight){
1644 if ( myIsHighlighted == theHighlight )
1646 myIsHighlighted = theHighlight;
1651 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1652 if ( myIsPreselected == thePreselect )
1654 myIsPreselected = thePreselect;
1660 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1662 if (myPickableActor->GetIsOpaque())
1664 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1672 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1674 if (!myPickableActor->GetIsOpaque())
1676 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1684 void SMESH_ActorDef::Render(vtkRenderer *ren){
1685 unsigned long aTime = myTimeStamp->GetMTime();
1686 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1687 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1688 if(anObjTime > aTime || aClippingTime > aTime)
1693 void SMESH_ActorDef::Update(){
1694 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1696 if(GetControlMode() != eNone) {
1697 unsigned long aTime = myTimeStamp->GetMTime();
1698 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1699 if (anObjTime > aTime)
1700 SetControlMode(GetControlMode(),false);
1702 if(myIsPointsLabeled){
1703 SetPointsLabeled(myIsPointsLabeled);
1705 if(myIsCellsLabeled){
1706 SetCellsLabeled(myIsCellsLabeled);
1708 if(myIsFacesOriented){
1709 SetFacesOriented(myIsFacesOriented);
1711 SetEntityMode(GetEntityMode());
1712 SetVisibility(GetVisibility());
1714 myTimeStamp->Modified();
1719 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1720 SALOME_Actor::ReleaseGraphicsResources(renWin);
1722 myPickableActor->ReleaseGraphicsResources(renWin);
1726 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1727 vtkFloatingPointType* aColor = theProperty->GetColor();
1734 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1735 mySurfaceProp->SetOpacity(theValue);
1736 myBackSurfaceProp->SetOpacity(theValue);
1737 myEdgeProp->SetOpacity(theValue);
1738 myNodeProp->SetOpacity(theValue);
1740 my1DProp->SetOpacity(theValue);
1744 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1745 return mySurfaceProp->GetOpacity();
1749 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1750 mySurfaceProp->SetColor(r,g,b);
1751 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1752 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1753 aGroupObj->GetElementType() == SMDSAbs_Volume )
1754 myNameActor->SetBackgroundColor(r,g,b);
1758 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1759 ::GetColor(mySurfaceProp,r,g,b);
1760 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1763 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1764 myBackSurfaceProp->SetColor(r,g,b);
1768 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1769 ::GetColor(myBackSurfaceProp,r,g,b);
1772 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1773 myEdgeProp->SetColor(r,g,b);
1774 my1DProp->SetColor(r,g,b);
1775 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1776 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1777 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1778 myNameActor->SetBackgroundColor(r,g,b);
1782 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1783 ::GetColor(myEdgeProp,r,g,b);
1786 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1787 myNodeProp->SetColor(r,g,b);
1788 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1789 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1790 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1791 myNameActor->SetBackgroundColor(r,g,b);
1795 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1796 ::GetColor(myNodeProp,r,g,b);
1799 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1800 my0DProp->SetColor(r,g,b);
1801 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1802 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1803 myNameActor->SetBackgroundColor(r,g,b);
1807 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1808 ::GetColor(my0DProp,r,g,b);
1811 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1812 myHighlightProp->SetColor(r,g,b);
1816 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1817 ::GetColor(myHighlightProp,r,g,b);
1820 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1821 myPreselectProp->SetColor(r,g,b);
1825 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1826 ::GetColor(myPreselectProp,r,g,b);
1830 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1831 return myEdgeProp->GetLineWidth();
1835 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1836 myEdgeProp->SetLineWidth(theVal);
1838 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1839 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1845 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1846 my0DProp->SetPointSize(theVal);
1850 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1851 return my0DProp->GetPointSize();
1854 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1856 return myVisualObj->GetElemDimension( theObjId );
1861 IsImplicitFunctionUsed() const
1863 return myBaseActor->IsImplicitFunctionUsed();
1867 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1869 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1870 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1872 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1874 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1876 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1877 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1879 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1880 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1882 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1883 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1884 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1885 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1889 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1892 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1893 myCippingPlaneCont.push_back(thePlane);
1894 if(!IsImplicitFunctionUsed())
1895 SetImplicitFunctionUsed(true);
1897 return myCippingPlaneCont.size();
1902 RemoveAllClippingPlanes()
1904 myImplicitBoolean->GetFunction()->RemoveAllItems();
1905 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1906 myCippingPlaneCont.clear();
1907 SetImplicitFunctionUsed(false);
1912 GetNumberOfClippingPlanes()
1914 return myCippingPlaneCont.size();
1919 GetClippingPlane(vtkIdType theID)
1921 if(theID >= myCippingPlaneCont.size())
1923 return myCippingPlaneCont[theID].Get();
1926 void SMESH_ActorDef::UpdateScalarBar()
1928 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1932 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1934 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1935 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1937 aScalarBarTitleProp->SetFontFamilyToArial();
1939 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1941 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1942 if ( f.family() == "Arial" )
1943 aScalarBarTitleProp->SetFontFamilyToArial();
1944 else if ( f.family() == "Courier" )
1945 aScalarBarTitleProp->SetFontFamilyToCourier();
1946 else if ( f.family() == "Times" )
1947 aScalarBarTitleProp->SetFontFamilyToTimes();
1950 aScalarBarTitleProp->BoldOn();
1952 aScalarBarTitleProp->BoldOff();
1955 aScalarBarTitleProp->ItalicOn();
1957 aScalarBarTitleProp->ItalicOff();
1960 aScalarBarTitleProp->ShadowOn();
1962 aScalarBarTitleProp->ShadowOff();
1965 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1966 aScalarBarTitleProp->Delete();
1968 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1970 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1971 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1973 aScalarBarLabelProp->SetFontFamilyToArial();
1974 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1976 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1977 if( f.family() == "Arial" )
1978 aScalarBarLabelProp->SetFontFamilyToArial();
1979 else if( f.family() == "Courier" )
1980 aScalarBarLabelProp->SetFontFamilyToCourier();
1981 else if( f.family() == "Times" )
1982 aScalarBarLabelProp->SetFontFamilyToTimes();
1985 aScalarBarLabelProp->BoldOn();
1987 aScalarBarLabelProp->BoldOff();
1990 aScalarBarLabelProp->ItalicOn();
1992 aScalarBarLabelProp->ItalicOff();
1995 aScalarBarLabelProp->ShadowOn();
1997 aScalarBarLabelProp->ShadowOff();
2000 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2001 aScalarBarLabelProp->Delete();
2003 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2004 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2006 myScalarBarActor->SetOrientationToHorizontal();
2008 myScalarBarActor->SetOrientationToVertical();
2011 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2012 if( mgr->hasValue( "SMESH", name + "x" ) )
2013 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2015 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2016 if( mgr->hasValue( "SMESH", name + "y" ) )
2017 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2018 myScalarBarActor->SetPosition( aXVal, aYVal );
2020 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2021 if( mgr->hasValue( "SMESH", name + "width" ) )
2022 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2023 myScalarBarActor->SetWidth( aWVal );
2025 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2026 if( mgr->hasValue( "SMESH", name + "height" ) )
2027 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2028 myScalarBarActor->SetHeight( aHVal );
2031 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2032 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2033 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2036 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2037 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2038 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2040 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2041 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2043 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2044 myScalarBarActor->SetDistributionColoringType(coloringType);
2046 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2047 QColor(255, 255, 255));
2049 rgb[0]= distributionColor.red()/255.;
2050 rgb[1]= distributionColor.green()/255.;
2051 rgb[2]= distributionColor.blue()/255.;
2052 myScalarBarActor->SetDistributionColor(rgb);
2057 void SMESH_ActorDef::UpdateDistribution()
2059 if(SMESH::Controls::NumericalFunctor* fun =
2060 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2062 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2063 std::vector<int> nbEvents;
2064 std::vector<double> funValues;
2065 SMESH_VisualObjDef::TEntityList elems;
2066 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2067 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2068 std::vector<int> elemIds;
2069 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2070 elemIds.push_back( (*e)->GetID());
2071 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2072 double * range = lookupTable->GetRange();
2073 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2074 myScalarBarActor->SetDistribution(nbEvents);
2078 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2081 case SMESH_Actor::eLines :
2082 myHighlitableActor->SetQuadraticArcMode(false);
2083 my2DActor->SetQuadraticArcMode(false);
2084 my1DActor->SetQuadraticArcMode(false);
2086 case SMESH_Actor::eArcs :
2087 myHighlitableActor->SetQuadraticArcMode(true);
2088 if(GetRepresentation() != SMESH_Actor::ePoint) {
2089 my2DActor->SetQuadraticArcMode(true);
2090 my1DActor->SetQuadraticArcMode(true);
2099 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2101 if(myHighlitableActor->GetQuadraticArcMode())
2102 return SMESH_Actor::eArcs;
2104 return SMESH_Actor::eLines;
2107 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2109 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2110 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2111 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2114 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2116 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2117 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2118 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2119 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2122 #ifndef DISABLE_PLOT2DVIEWER
2123 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2126 my2dHistogram->clearAllPoints();
2128 if(SMESH::Controls::NumericalFunctor* fun =
2129 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2132 if(!my2dHistogram) {
2133 my2dHistogram = new SPlot2d_Histogram();
2134 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2135 my2dHistogram->setIO(anIO);
2138 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2139 std::vector<int> nbEvents;
2140 std::vector<double> funValues;
2141 SMESH_VisualObjDef::TEntityList elems;
2142 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2143 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2144 std::vector<int> elemIds;
2146 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2147 elemIds.push_back( (*e)->GetID());
2149 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2150 double * range = lookupTable->GetRange();
2151 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2153 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2154 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2156 if(funValues.size() >= 2)
2157 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2161 //Color of the histogram
2162 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2163 my2dHistogram->setAutoAssign(true);
2166 myScalarBarActor->GetDistributionColor(rgb);
2167 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2168 my2dHistogram->setColor(aColor);
2172 return my2dHistogram;