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);
230 //Definition 1D device of the actor
231 //---------------------------------
232 myEdgeProp = vtkProperty::New();
233 myEdgeProp->SetAmbient(1.0);
234 myEdgeProp->SetDiffuse(0.0);
235 myEdgeProp->SetSpecular(0.0);
236 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
237 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
238 myEdgeProp->SetLineWidth(aLineWidth);
240 my1DActor = SMESH_DeviceActor::New();
241 my1DActor->SetUserMatrix(aMatrix);
242 my1DActor->PickableOff();
243 my1DActor->SetHighlited(true);
244 my1DActor->SetProperty(myEdgeProp);
245 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
246 aFilter = my1DActor->GetExtractUnstructuredGrid();
247 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
248 aFilter->RegisterCellsWithType(VTK_LINE);
249 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
251 my1DProp = vtkProperty::New();
252 my1DProp->DeepCopy(myEdgeProp);
253 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
254 my1DProp->SetPointSize(aElem0DSize);
256 my1DExtProp = vtkProperty::New();
257 my1DExtProp->DeepCopy(myEdgeProp);
258 anRGB[0] = 1 - anRGB[0];
259 anRGB[1] = 1 - anRGB[1];
260 anRGB[2] = 1 - anRGB[2];
261 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
262 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
263 my1DExtProp->SetPointSize(aElem0DSize);
265 my1DExtActor = SMESH_DeviceActor::New();
266 my1DExtActor->SetUserMatrix(aMatrix);
267 my1DExtActor->PickableOff();
268 my1DExtActor->SetHighlited(true);
269 my1DExtActor->SetVisibility(false);
270 my1DExtActor->SetProperty(my1DExtProp);
271 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
272 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
273 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
274 aFilter->RegisterCellsWithType(VTK_LINE);
275 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
278 //Definition 0D device of the actor (0d elements)
279 //-----------------------------------------------
280 my0DProp = vtkProperty::New();
281 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
282 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
283 my0DProp->SetPointSize(aElem0DSize);
285 my0DActor = SMESH_DeviceActor::New();
286 my0DActor->SetUserMatrix(aMatrix);
287 my0DActor->SetStoreClippingMapping(true);
288 my0DActor->PickableOff();
289 my0DActor->SetVisibility(false);
290 my0DActor->SetProperty(my0DProp);
291 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
292 aFilter = my0DActor->GetExtractUnstructuredGrid();
293 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
294 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
295 aFilter->RegisterCellsWithType(VTK_VERTEX);
297 //my0DExtProp = vtkProperty::New();
298 //my0DExtProp->DeepCopy(my0DProp);
299 //anRGB[0] = 1 - anRGB[0];
300 //anRGB[1] = 1 - anRGB[1];
301 //anRGB[2] = 1 - anRGB[2];
302 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
303 //my0DExtProp->SetPointSize(aElem0DSize);
305 //my0DExtActor = SMESH_DeviceActor::New();
306 //my0DExtActor->SetUserMatrix(aMatrix);
307 //my0DExtActor->SetStoreClippingMapping(true);
308 //my0DExtActor->PickableOff();
309 //my0DExtActor->SetHighlited(true);
310 //my0DExtActor->SetVisibility(false);
311 //my0DExtActor->SetProperty(my0DExtProp);
312 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
313 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
314 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
315 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
316 //aFilter->RegisterCellsWithType(VTK_VERTEX);
319 //Definition 0D device of the actor (nodes)
320 //-----------------------------------------
321 myNodeProp = vtkProperty::New();
322 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
323 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
325 myNodeActor = SMESH_DeviceActor::New();
326 myNodeActor->SetUserMatrix(aMatrix);
327 myNodeActor->SetStoreClippingMapping(true);
328 myNodeActor->PickableOff();
329 myNodeActor->SetVisibility(false);
330 myNodeActor->SetProperty(myNodeProp);
331 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
332 aFilter = myNodeActor->GetExtractUnstructuredGrid();
333 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
335 myNodeExtProp = vtkProperty::New();
336 myNodeExtProp->DeepCopy(myNodeProp);
337 anRGB[0] = 1 - anRGB[0];
338 anRGB[1] = 1 - anRGB[1];
339 anRGB[2] = 1 - anRGB[2];
340 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
342 myNodeExtActor = SMESH_DeviceActor::New();
343 myNodeExtActor->SetUserMatrix(aMatrix);
344 myNodeExtActor->SetStoreClippingMapping(true);
345 myNodeExtActor->PickableOff();
346 myNodeExtActor->SetHighlited(true);
347 myNodeExtActor->SetVisibility(false);
348 myNodeExtActor->SetProperty(myNodeExtProp);
349 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
350 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
351 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
352 aFilter->RegisterCellsWithType(VTK_VERTEX);
354 //Definition of Pickable and Highlitable engines
355 //----------------------------------------------
357 myBaseActor = SMESH_DeviceActor::New();
358 myBaseActor->SetUserMatrix(aMatrix);
359 myBaseActor->SetStoreGemetryMapping(true);
360 myBaseActor->GetProperty()->SetOpacity(0.0);
362 myPickableActor = myBaseActor;
364 myHighlightProp = vtkProperty::New();
365 myHighlightProp->SetAmbient(1.0);
366 myHighlightProp->SetDiffuse(0.0);
367 myHighlightProp->SetSpecular(0.0);
368 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
369 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
370 myHighlightProp->SetPointSize(aElem0DSize); // ??
371 myHighlightProp->SetRepresentation(1);
373 myPreselectProp = vtkProperty::New();
374 myPreselectProp->SetAmbient(1.0);
375 myPreselectProp->SetDiffuse(0.0);
376 myPreselectProp->SetSpecular(0.0);
377 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
378 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
379 myPreselectProp->SetPointSize(aElem0DSize); // ??
380 myPreselectProp->SetRepresentation(1);
382 myHighlitableActor = SMESH_DeviceActor::New();
383 myHighlitableActor->SetUserMatrix(aMatrix);
384 myHighlitableActor->PickableOff();
385 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
392 myControlMode = eNone;
393 myControlActor = my2DActor;
395 //Definition of myScalarBarActor
396 //------------------------------
397 myLookupTable = vtkLookupTable::New();
398 //Fix for Bug PAL5195 - SMESH764:
399 //Controls - Aspect Ratio: incorrect colors of the best and worst values
400 myLookupTable->SetHueRange(0.667,0.0);
402 myScalarBarActor = SMESH_ScalarBarActor::New();
403 myScalarBarActor->SetVisibility(false);
404 myScalarBarActor->SetLookupTable(myLookupTable);
407 //Incorrect "Min value" in Scalar Bar in Mesh:
408 // myScalarBarActor->SetLabelFormat("%.4g");
409 // changes was commented because of regression bug IPAL 19981
411 mgr = SUIT_Session::session()->resourceMgr();
415 //Definition of points numbering pipeline
416 //---------------------------------------
417 myPointsNumDataSet = vtkUnstructuredGrid::New();
419 myPtsMaskPoints = vtkMaskPoints::New();
420 myPtsMaskPoints->SetInput(myPointsNumDataSet);
421 myPtsMaskPoints->SetOnRatio(1);
423 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
424 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
425 myPtsSelectVisiblePoints->SelectInvisibleOff();
426 myPtsSelectVisiblePoints->SetTolerance(0.1);
428 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
429 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
430 #if (VTK_XVERSION < 0x050200)
431 myPtsLabeledDataMapper->SetLabelFormat("%g");
433 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
435 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
436 aPtsTextProp->SetFontFamilyToTimes();
437 static int aPointsFontSize = 10;
438 aPtsTextProp->SetFontSize(aPointsFontSize);
439 aPtsTextProp->SetBold(1);
440 aPtsTextProp->SetItalic(0);
441 aPtsTextProp->SetShadow(0);
442 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
443 aPtsTextProp->Delete();
445 myEntityMode = eAllEntity;
447 myIsPointsLabeled = false;
449 myPointLabels = vtkActor2D::New();
450 myPointLabels->SetMapper(myPtsLabeledDataMapper);
451 myPointLabels->GetProperty()->SetColor(1,1,1);
452 myPointLabels->SetVisibility(myIsPointsLabeled);
455 //Definition of cells numbering pipeline
456 //---------------------------------------
457 myCellsNumDataSet = vtkUnstructuredGrid::New();
459 myCellCenters = VTKViewer_CellCenters::New();
460 myCellCenters->SetInput(myCellsNumDataSet);
462 myClsMaskPoints = vtkMaskPoints::New();
463 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
464 myClsMaskPoints->SetOnRatio(1);
466 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
467 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
468 myClsSelectVisiblePoints->SelectInvisibleOff();
469 myClsSelectVisiblePoints->SetTolerance(0.1);
471 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
472 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
473 #if (VTK_XVERSION < 0x050200)
474 myClsLabeledDataMapper->SetLabelFormat("%g");
476 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
478 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
479 aClsTextProp->SetFontFamilyToTimes();
480 static int aCellsFontSize = 12;
481 aClsTextProp->SetFontSize(aCellsFontSize);
482 aClsTextProp->SetBold(1);
483 aClsTextProp->SetItalic(0);
484 aClsTextProp->SetShadow(0);
485 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
486 aClsTextProp->Delete();
488 myIsCellsLabeled = false;
490 myCellsLabels = vtkActor2D::New();
491 myCellsLabels->SetMapper(myClsLabeledDataMapper);
492 myCellsLabels->GetProperty()->SetColor(0,1,0);
493 myCellsLabels->SetVisibility(myIsCellsLabeled);
496 myImplicitBoolean = vtkImplicitBoolean::New();
497 myImplicitBoolean->SetOperationTypeToIntersection();
501 //Quadratic 2D elements representation
502 //-----------------------------------------------------------------------------
503 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
504 if(aQuadratic2DMode == 0){
505 myHighlitableActor->SetQuadraticArcMode(false);
506 my2DActor->SetQuadraticArcMode(false);
507 my1DActor->SetQuadraticArcMode(false);
509 else if(aQuadratic2DMode == 1){
510 myHighlitableActor->SetQuadraticArcMode(true);
511 my2DActor->SetQuadraticArcMode(true);
512 my1DActor->SetQuadraticArcMode(true);
515 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
516 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
517 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
519 // Set colors of the name actor
520 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
521 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
522 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
523 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
525 #ifndef DISABLE_PLOT2DVIEWER
532 SMESH_ActorDef::~SMESH_ActorDef()
534 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
536 #ifndef DISABLE_PLOT2DVIEWER
538 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
539 delete my2dHistogram;
543 // caught by SMESHGUI::ProcessEvents() static method
544 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
546 myScalarBarActor->Delete();
547 myLookupTable->Delete();
549 mySurfaceProp->Delete();
550 myBackSurfaceProp->Delete();
552 myEdgeProp->Delete();
553 myHighlightProp->Delete();
554 myPreselectProp->Delete();
556 myNodeProp->Delete();
557 myNodeExtProp->Delete();
562 //my0DExtProp->Delete();
563 //my0DExtActor->Delete();
568 my1DExtProp->Delete();
569 my1DExtActor->Delete();
572 my2DExtProp->Delete();
573 my2DExtActor->Delete();
575 my3DExtActor->Delete();
577 myNodeActor->Delete();
578 myBaseActor->Delete();
580 myNodeExtActor->Delete();
582 myHighlitableActor->Delete();
584 //Deleting of points numbering pipeline
585 //---------------------------------------
586 myPointsNumDataSet->Delete();
588 // commented: porting to vtk 5.0
589 // myPtsLabeledDataMapper->RemoveAllInputs();
590 myPtsLabeledDataMapper->Delete();
592 // commented: porting to vtk 5.0
593 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
594 myPtsSelectVisiblePoints->Delete();
596 // commented: porting to vtk 5.0
597 // myPtsMaskPoints->UnRegisterAllOutputs();
598 myPtsMaskPoints->Delete();
600 myPointLabels->Delete();
603 //Deleting of cells numbering pipeline
604 //---------------------------------------
605 myCellsNumDataSet->Delete();
607 myClsLabeledDataMapper->RemoveAllInputs();
608 myClsLabeledDataMapper->Delete();
610 // commented: porting to vtk 5.0
611 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
612 myClsSelectVisiblePoints->Delete();
614 // commented: porting to vtk 5.0
615 // myClsMaskPoints->UnRegisterAllOutputs();
616 myClsMaskPoints->Delete();
618 // commented: porting to vtk 5.0
619 // myCellCenters->UnRegisterAllOutputs();
620 myCellCenters->Delete();
622 myCellsLabels->Delete();
624 myImplicitBoolean->Delete();
626 myTimeStamp->Delete();
630 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
632 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
634 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
636 if ( myIsPointsLabeled )
638 myPointsNumDataSet->ShallowCopy(aGrid);
639 vtkDataSet *aDataSet = myPointsNumDataSet;
641 int aNbElem = aDataSet->GetNumberOfPoints();
643 vtkIntArray *anArray = vtkIntArray::New();
644 anArray->SetNumberOfValues( aNbElem );
646 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
648 int aSMDSId = myVisualObj->GetNodeObjId( anId );
649 anArray->SetValue( anId, aSMDSId );
652 aDataSet->GetPointData()->SetScalars( anArray );
654 myPtsMaskPoints->SetInput( aDataSet );
655 myPointLabels->SetVisibility( GetVisibility() );
659 myPointLabels->SetVisibility( false );
661 SetRepresentation(GetRepresentation());
662 myTimeStamp->Modified();
666 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
668 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
669 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
670 if(myIsCellsLabeled){
671 myCellsNumDataSet->ShallowCopy(aGrid);
672 vtkDataSet *aDataSet = myCellsNumDataSet;
673 int aNbElem = aDataSet->GetNumberOfCells();
674 vtkIntArray *anArray = vtkIntArray::New();
675 anArray->SetNumberOfValues(aNbElem);
676 for(int anId = 0; anId < aNbElem; anId++){
677 int aSMDSId = myVisualObj->GetElemObjId(anId);
678 anArray->SetValue(anId,aSMDSId);
680 aDataSet->GetCellData()->SetScalars(anArray);
681 myCellCenters->SetInput(aDataSet);
682 myCellsLabels->SetVisibility(GetVisibility());
684 myCellsLabels->SetVisibility(false);
686 myTimeStamp->Modified();
690 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
692 myIsFacesOriented = theIsFacesOriented;
694 my2DActor->SetFacesOriented(theIsFacesOriented);
695 my3DActor->SetFacesOriented(theIsFacesOriented);
697 myTimeStamp->Modified();
700 bool SMESH_ActorDef::GetFacesOriented()
702 return myIsFacesOriented;
705 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
707 my2DActor->SetFacesOrientationColor( theColor );
708 my3DActor->SetFacesOrientationColor( theColor );
711 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
713 my3DActor->GetFacesOrientationColor( theColor );
716 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
718 my2DActor->SetFacesOrientationScale( theScale );
719 my3DActor->SetFacesOrientationScale( theScale );
722 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
724 return my3DActor->GetFacesOrientationScale();
727 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
729 my2DActor->SetFacesOrientation3DVectors( theState );
730 my3DActor->SetFacesOrientation3DVectors( theState );
733 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
735 return my3DActor->GetFacesOrientation3DVectors();
741 SetControlMode(eControl theMode)
743 SetControlMode(theMode,true);
749 SetControlMode(eControl theMode,
750 bool theCheckEntityMode)
752 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
756 myControlMode = eNone;
757 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
759 my0DActor->GetMapper()->SetScalarVisibility(false);
760 my1DActor->GetMapper()->SetScalarVisibility(false);
761 my2DActor->GetMapper()->SetScalarVisibility(false);
762 my3DActor->GetMapper()->SetScalarVisibility(false);
763 myScalarBarActor->SetVisibility(false);
765 bool anIsScalarVisible = theMode > eNone;
767 if(anIsScalarVisible) {
771 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
772 aControl->SetPrecision( myControlsPrecision );
773 myFunctor.reset( aControl );
774 myControlActor = my1DActor;
779 myFunctor.reset(new SMESH::Controls::Length2D());
780 myControlActor = my2DActor;
784 myFunctor.reset(new SMESH::Controls::FreeBorders());
785 myControlActor = my1DActor;
788 myFunctor.reset(new SMESH::Controls::FreeEdges());
789 myControlActor = my2DActor;
792 myFunctor.reset(new SMESH::Controls::FreeNodes());
793 myControlActor = myNodeActor;
796 myFunctor.reset(new SMESH::Controls::FreeFaces());
797 myControlActor = my2DActor;
799 case eBareBorderFace:
800 myFunctor.reset(new SMESH::Controls::BareBorderFace());
801 myControlActor = my2DActor;
803 case eOverConstrainedFace:
804 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
805 myControlActor = my2DActor;
807 case eMultiConnection:
808 myFunctor.reset(new SMESH::Controls::MultiConnection());
809 myControlActor = my1DActor;
811 case eMultiConnection2D:
812 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
813 myControlActor = my2DActor;
817 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
818 aControl->SetPrecision( myControlsPrecision );
819 myFunctor.reset( aControl );
820 myControlActor = my2DActor;
825 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
826 aControl->SetPrecision( myControlsPrecision );
827 myFunctor.reset( aControl );
828 myControlActor = my2DActor;
833 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
834 aControl->SetPrecision( myControlsPrecision );
835 myFunctor.reset( aControl );
836 myControlActor = my2DActor;
841 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
842 aControl->SetPrecision( myControlsPrecision );
843 myFunctor.reset( aControl );
844 myControlActor = my3DActor;
849 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
850 aControl->SetPrecision( myControlsPrecision );
851 myFunctor.reset( aControl );
852 myControlActor = my3DActor;
855 case eMaxElementLength2D:
857 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
858 aControl->SetPrecision( myControlsPrecision );
859 myFunctor.reset( aControl );
860 myControlActor = my2DActor;
863 case eMaxElementLength3D:
865 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
866 aControl->SetPrecision( myControlsPrecision );
867 myFunctor.reset( aControl );
868 myControlActor = my3DActor;
871 case eBareBorderVolume:
873 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
874 myControlActor = my3DActor;
877 case eOverConstrainedVolume:
879 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
880 myControlActor = my3DActor;
885 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
886 aControl->SetPrecision( myControlsPrecision );
887 myFunctor.reset( aControl );
888 myControlActor = my2DActor;
893 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
894 aControl->SetPrecision( myControlsPrecision );
895 myFunctor.reset( aControl );
896 myControlActor = my2DActor;
901 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
902 aControl->SetPrecision( myControlsPrecision );
903 myFunctor.reset( aControl );
904 myControlActor = my2DActor;
911 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
912 vtkIdType aNbCells = aGrid->GetNumberOfCells();
914 myControlMode = theMode;
915 switch(myControlMode){
917 myNodeExtActor->SetExtControlMode(myFunctor);
921 my1DExtActor->SetExtControlMode(myFunctor);
924 case eBareBorderFace:
925 case eOverConstrainedFace:
926 my2DExtActor->SetExtControlMode(myFunctor);
928 case eBareBorderVolume:
929 case eOverConstrainedVolume:
930 my3DExtActor->SetExtControlMode(myFunctor);
933 case eMultiConnection2D:
934 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
935 UpdateDistribution();
938 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
939 UpdateDistribution();
943 if(theCheckEntityMode){
944 if(myControlActor == my1DActor)
945 SetEntityMode(eEdges);
946 else if(myControlActor == my2DActor){
947 switch(myControlMode){
951 case eMultiConnection2D:
952 //SetEntityMode(eEdges);
953 SetEntityMode(eFaces);
956 SetEntityMode(eFaces);
958 }else if(myControlActor == my3DActor)
959 SetEntityMode(eVolumes);
964 if(theCheckEntityMode)
965 myEntityMode = eAllEntity;
969 SetRepresentation(GetRepresentation());
971 myTimeStamp->Modified();
976 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
977 theRenderer->AddActor(myNodeActor);
978 theRenderer->AddActor(myBaseActor);
980 theRenderer->AddActor(myNodeExtActor);
982 my3DActor->AddToRender(theRenderer);
983 my3DExtActor->AddToRender(theRenderer);
984 my2DActor->AddToRender(theRenderer);
985 my2DExtActor->AddToRender(theRenderer);
987 theRenderer->AddActor(my1DActor);
988 theRenderer->AddActor(my1DExtActor);
990 theRenderer->AddActor(my0DActor);
991 //theRenderer->AddActor(my0DExtActor);
993 theRenderer->AddActor(myHighlitableActor);
995 theRenderer->AddActor2D(myScalarBarActor);
997 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
998 myClsSelectVisiblePoints->SetRenderer(theRenderer);
1000 theRenderer->AddActor2D(myPointLabels);
1001 theRenderer->AddActor2D(myCellsLabels);
1003 // the superclass' method should be called at the end
1004 // (in particular, for correct work of selection)
1005 SALOME_Actor::AddToRender(theRenderer);
1008 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1009 SALOME_Actor::RemoveFromRender(theRenderer);
1011 theRenderer->RemoveActor(myNodeActor);
1012 theRenderer->RemoveActor(myBaseActor);
1014 theRenderer->RemoveActor(myNodeExtActor);
1016 theRenderer->RemoveActor(myHighlitableActor);
1018 theRenderer->RemoveActor(my0DActor);
1019 //theRenderer->RemoveActor(my0DExtActor);
1021 theRenderer->RemoveActor(my1DActor);
1022 theRenderer->RemoveActor(my1DExtActor);
1024 my2DActor->RemoveFromRender(theRenderer);
1025 my2DExtActor->RemoveFromRender(theRenderer);
1026 my3DActor->RemoveFromRender(theRenderer);
1027 my3DExtActor->RemoveFromRender(theRenderer);
1029 theRenderer->RemoveActor(myScalarBarActor);
1030 theRenderer->RemoveActor(myPointLabels);
1031 theRenderer->RemoveActor(myCellsLabels);
1035 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1036 const char* theEntry,
1037 const char* theName,
1040 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1044 myVisualObj = theVisualObj;
1045 myVisualObj->Update(theIsClear);
1047 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1048 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1050 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1052 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1054 my0DActor->Init(myVisualObj,myImplicitBoolean);
1055 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1057 my1DActor->Init(myVisualObj,myImplicitBoolean);
1058 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1060 my2DActor->Init(myVisualObj,myImplicitBoolean);
1061 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1062 my3DActor->Init(myVisualObj,myImplicitBoolean);
1063 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1065 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1066 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1068 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1069 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1071 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1072 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1073 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1074 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1076 vtkFloatingPointType aFactor, aUnits;
1077 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1078 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1079 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1081 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1085 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1086 SetIsShrunkable(true);
1088 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1090 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1091 SetRepresentation(-1);
1094 SetRepresentation(eEdge);
1095 }else if(aMode == 1){
1096 SetRepresentation(eSurface);
1097 }else if(aMode == 2){
1098 SetRepresentation(ePoint);
1105 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1106 SetIsDisplayNameActor( true );
1108 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1109 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1110 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1112 myTimeStamp->Modified();
1118 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1119 return myNodeActor->GetBounds();
1123 vtkDataSet* SMESH_ActorDef::GetInput(){
1124 return GetUnstructuredGrid();
1128 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1129 Superclass::SetTransform(theTransform);
1131 myNodeActor->SetTransform(theTransform);
1132 myBaseActor->SetTransform(theTransform);
1134 myHighlitableActor->SetTransform(theTransform);
1136 myNodeExtActor->SetTransform(theTransform);
1138 my0DActor->SetTransform(theTransform);
1139 //my0DExtActor->SetTransform(theTransform);
1141 my1DActor->SetTransform(theTransform);
1142 my1DExtActor->SetTransform(theTransform);
1144 my2DActor->SetTransform(theTransform);
1145 my2DExtActor->SetTransform(theTransform);
1146 my3DActor->SetTransform(theTransform);
1147 my3DExtActor->SetTransform(theTransform);
1153 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1154 vtkLODActor::SetMapper(theMapper);
1158 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1159 SALOME_Actor::ShallowCopy(prop);
1163 vtkMapper* SMESH_ActorDef::GetMapper(){
1164 return myPickableActor->GetMapper();
1168 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1169 return myVisualObj->GetUnstructuredGrid();
1173 bool SMESH_ActorDef::IsInfinitive(){
1174 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1176 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1177 ( aDataSet->GetNumberOfCells() == 1 &&
1178 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1179 return SALOME_Actor::IsInfinitive();
1183 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1184 if ( myIsShrinkable == theShrunkable )
1186 myIsShrinkable = theShrunkable;
1190 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1191 return myBaseActor->GetShrinkFactor();
1194 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1195 myBaseActor->SetShrinkFactor(theValue);
1197 my1DActor->SetShrinkFactor(theValue);
1198 my1DExtActor->SetShrinkFactor(theValue);
1200 my2DActor->SetShrinkFactor(theValue);
1201 my2DExtActor->SetShrinkFactor(theValue);
1202 my3DActor->SetShrinkFactor(theValue);
1203 my3DExtActor->SetShrinkFactor(theValue);
1208 void SMESH_ActorDef::SetShrink(){
1209 if(!myIsShrinkable) return;
1211 myBaseActor->SetShrink();
1213 my1DActor->SetShrink();
1214 my1DExtActor->SetShrink();
1216 my2DActor->SetShrink();
1217 my2DExtActor->SetShrink();
1218 my3DActor->SetShrink();
1219 my3DExtActor->SetShrink();
1225 void SMESH_ActorDef::UnShrink(){
1226 if(!myIsShrunk) return;
1228 myBaseActor->UnShrink();
1230 my1DActor->UnShrink();
1231 my1DExtActor->UnShrink();
1233 my2DActor->UnShrink();
1234 my2DExtActor->UnShrink();
1235 my3DActor->UnShrink();
1236 my3DExtActor->UnShrink();
1243 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1244 return myPickableActor->GetNodeObjId(theVtkID);
1247 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1248 return myPickableActor->GetNodeCoord(theObjID);
1252 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1253 return myPickableActor->GetElemObjId(theVtkID);
1256 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1257 return myPickableActor->GetElemCell(theObjID);
1261 void SMESH_ActorDef::SetVisibility(int theMode){
1262 SetVisibility(theMode,true);
1266 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1267 SALOME_Actor::SetVisibility(theMode);
1269 myNodeActor->VisibilityOff();
1270 myBaseActor->VisibilityOff();
1272 myNodeExtActor->VisibilityOff();
1274 my0DActor->VisibilityOff();
1275 //my0DExtActor->VisibilityOff();
1277 my1DActor->VisibilityOff();
1278 my1DExtActor->VisibilityOff();
1280 my2DActor->VisibilityOff();
1281 my2DExtActor->VisibilityOff();
1282 my3DActor->VisibilityOff();
1283 my3DExtActor->VisibilityOff();
1285 myScalarBarActor->VisibilityOff();
1286 myPointLabels->VisibilityOff();
1287 myCellsLabels->VisibilityOff();
1289 if(GetVisibility()){
1290 if(theIsUpdateRepersentation)
1291 SetRepresentation(GetRepresentation());
1293 if(myControlMode != eNone){
1294 switch(myControlMode){
1296 myNodeExtActor->VisibilityOn();
1300 my1DExtActor->VisibilityOn();
1303 case eBareBorderFace:
1304 case eOverConstrainedFace:
1305 my2DExtActor->VisibilityOn();
1307 case eBareBorderVolume:
1308 case eOverConstrainedVolume:
1309 my3DExtActor->VisibilityOn();
1312 case eMultiConnection2D:
1313 my1DExtActor->VisibilityOn();
1315 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1316 myScalarBarActor->VisibilityOn();
1320 if(myRepresentation != ePoint)
1321 myPickableActor->VisibilityOn();
1323 myNodeActor->VisibilityOn();
1326 if(myEntityMode & e0DElements){
1327 my0DActor->VisibilityOn();
1330 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1331 my1DActor->VisibilityOn();
1334 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1335 my2DActor->VisibilityOn();
1338 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1339 my3DActor->VisibilityOn();
1342 if(myIsPointsLabeled){
1343 myPointLabels->VisibilityOn();
1344 myNodeActor->VisibilityOn();
1347 if(myIsCellsLabeled)
1348 myCellsLabels->VisibilityOn();
1350 #ifndef DISABLE_PLOT2DVIEWER
1352 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1359 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1361 myEntityState = eAllEntity;
1363 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1364 myEntityState &= ~e0DElements;
1365 theMode &= ~e0DElements;
1368 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1369 myEntityState &= ~eEdges;
1373 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1374 myEntityState &= ~eFaces;
1378 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1379 myEntityState &= ~eVolumes;
1380 theMode &= ~eVolumes;
1384 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1385 theMode |= e0DElements;
1387 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1390 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1393 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1394 theMode |= eVolumes;
1397 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1399 myEntityMode = theMode;
1400 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1401 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1402 aFilter->ClearRegisteredCellsWithType();
1403 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1405 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1406 aHightFilter->ClearRegisteredCellsWithType();
1407 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1409 if (myEntityMode & e0DElements) {
1410 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1411 aFilter->RegisterCellsWithType(VTK_VERTEX);
1412 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1415 if (myEntityMode & eEdges) {
1416 if (MYDEBUG) MESSAGE("EDGES");
1417 aFilter->RegisterCellsWithType(VTK_LINE);
1418 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1420 aHightFilter->RegisterCellsWithType(VTK_LINE);
1421 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1424 if (myEntityMode & eFaces) {
1425 if (MYDEBUG) MESSAGE("FACES");
1426 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1427 aFilter->RegisterCellsWithType(VTK_POLYGON);
1428 aFilter->RegisterCellsWithType(VTK_QUAD);
1429 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1430 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1432 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1433 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1434 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1435 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1436 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1439 if (myEntityMode & eVolumes) {
1440 if (MYDEBUG) MESSAGE("VOLUMES");
1441 aFilter->RegisterCellsWithType(VTK_TETRA);
1442 aFilter->RegisterCellsWithType(VTK_VOXEL);
1443 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1444 aFilter->RegisterCellsWithType(VTK_WEDGE);
1445 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1446 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1447 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1448 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1449 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1450 //#ifdef VTK_HAVE_POLYHEDRON
1451 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1454 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1455 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1456 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1457 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1458 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1459 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1460 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1461 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1462 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1463 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1464 //#ifdef VTK_HAVE_POLYHEDRON
1465 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1469 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1470 SetVisibility(GetVisibility(),false);
1473 void SMESH_ActorDef::SetRepresentation (int theMode)
1475 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1476 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1477 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1480 myRepresentation = eSurface;
1481 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1482 myRepresentation = eEdge;
1483 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1484 myRepresentation = ePoint;
1489 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1492 if (!aNbFaces && !aNbVolumes) return;
1495 myRepresentation = theMode;
1498 if (!GetUnstructuredGrid()->GetNumberOfCells())
1499 myRepresentation = ePoint;
1502 if (myRepresentation == ePoint) {
1510 myPickableActor = myBaseActor;
1511 myNodeActor->SetVisibility(false);
1512 myNodeExtActor->SetVisibility(false);
1513 vtkProperty *aProp = NULL, *aBackProp = NULL;
1514 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1515 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1516 switch (myRepresentation) {
1518 myPickableActor = myNodeActor;
1519 myNodeActor->SetVisibility(true);
1520 aQuadraticMode = SMESH_Actor::eLines;
1521 aProp = aBackProp = myNodeProp;
1522 aReperesent = SMESH_DeviceActor::ePoint;
1525 aProp = aBackProp = myEdgeProp;
1526 aReperesent = SMESH_DeviceActor::eInsideframe;
1529 aProp = mySurfaceProp;
1530 aBackProp = myBackSurfaceProp;
1531 aReperesent = SMESH_DeviceActor::eSurface;
1535 my2DActor->SetProperty(aProp);
1536 my2DActor->SetBackfaceProperty(aBackProp);
1537 my2DActor->SetRepresentation(aReperesent);
1539 if(aQuadraticMode == SMESH_Actor::eLines)
1540 my2DActor->SetQuadraticArcMode(false);
1541 else if(aQuadraticMode == SMESH_Actor::eArcs)
1542 my2DActor->SetQuadraticArcMode(true);
1544 my2DExtActor->SetRepresentation(aReperesent);
1546 my3DActor->SetProperty(aProp);
1547 my3DActor->SetBackfaceProperty(aBackProp);
1548 my3DActor->SetRepresentation(aReperesent);
1550 //my0DExtActor->SetVisibility(false);
1551 my1DExtActor->SetVisibility(false);
1552 my2DExtActor->SetVisibility(false);
1553 my3DExtActor->SetVisibility(false);
1556 //my0DActor->SetProperty(aProp);
1557 //my0DActor->SetBackfaceProperty(aBackProp);
1558 my0DActor->SetRepresentation(aReperesent);
1559 //my0DExtActor->SetRepresentation(aReperesent);
1561 switch(myControlMode){
1563 case eMultiConnection:
1564 aProp = aBackProp = my1DProp;
1565 if(myRepresentation != ePoint)
1566 aReperesent = SMESH_DeviceActor::eInsideframe;
1570 if(aQuadraticMode == SMESH_Actor::eLines)
1571 my1DActor->SetQuadraticArcMode(false);
1572 else if(aQuadraticMode == SMESH_Actor::eArcs)
1573 my1DActor->SetQuadraticArcMode(true);
1575 my1DActor->SetProperty(aProp);
1576 my1DActor->SetBackfaceProperty(aBackProp);
1577 my1DActor->SetRepresentation(aReperesent);
1579 my1DExtActor->SetRepresentation(aReperesent);
1581 if(myIsPointsVisible)
1582 myPickableActor = myNodeActor;
1583 if(GetPointRepresentation())
1584 myNodeActor->SetVisibility(true);
1586 SetMapper(myPickableActor->GetMapper());
1588 SetVisibility(GetVisibility(),false);
1594 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1595 if ( myIsPointsVisible == theIsPointsVisible )
1597 myIsPointsVisible = theIsPointsVisible;
1598 SetRepresentation(GetRepresentation());
1601 bool SMESH_ActorDef::GetPointRepresentation(){
1602 return myIsPointsVisible || myIsPointsLabeled;
1606 void SMESH_ActorDef::UpdateHighlight(){
1607 myHighlitableActor->SetVisibility(false);
1608 myHighlitableActor->SetHighlited(false);
1610 if(myIsHighlighted){
1611 myHighlitableActor->SetProperty(myHighlightProp);
1612 }else if(myIsPreselected){
1613 myHighlitableActor->SetProperty(myPreselectProp);
1616 bool anIsVisible = GetVisibility();
1618 if(myIsHighlighted || myIsPreselected){
1619 if(GetUnstructuredGrid()->GetNumberOfCells()){
1620 myHighlitableActor->SetHighlited(anIsVisible);
1621 myHighlitableActor->SetVisibility(anIsVisible);
1622 myHighlitableActor->GetExtractUnstructuredGrid()->
1623 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1624 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1625 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1626 myHighlitableActor->SetHighlited(anIsVisible);
1627 myHighlitableActor->GetExtractUnstructuredGrid()->
1628 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1629 myHighlitableActor->SetVisibility(anIsVisible);
1630 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1632 VTK::MarkerType aMarkerType = GetMarkerType();
1633 if(aMarkerType != VTK::MT_USER)
1634 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1636 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1642 void SMESH_ActorDef::highlight(bool theHighlight){
1643 if ( myIsHighlighted == theHighlight )
1645 myIsHighlighted = theHighlight;
1650 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1651 if ( myIsPreselected == thePreselect )
1653 myIsPreselected = thePreselect;
1659 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1661 if (myPickableActor->GetIsOpaque())
1663 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1671 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1673 if (!myPickableActor->GetIsOpaque())
1675 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1683 void SMESH_ActorDef::Render(vtkRenderer *ren){
1684 unsigned long aTime = myTimeStamp->GetMTime();
1685 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1686 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1687 if(anObjTime > aTime || aClippingTime > aTime)
1692 void SMESH_ActorDef::Update(){
1693 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1695 if(GetControlMode() != eNone) {
1696 unsigned long aTime = myTimeStamp->GetMTime();
1697 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1698 if (anObjTime > aTime)
1699 SetControlMode(GetControlMode(),false);
1701 if(myIsPointsLabeled){
1702 SetPointsLabeled(myIsPointsLabeled);
1704 if(myIsCellsLabeled){
1705 SetCellsLabeled(myIsCellsLabeled);
1707 if(myIsFacesOriented){
1708 SetFacesOriented(myIsFacesOriented);
1710 SetEntityMode(GetEntityMode());
1711 SetVisibility(GetVisibility());
1713 myTimeStamp->Modified();
1718 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1719 SALOME_Actor::ReleaseGraphicsResources(renWin);
1721 myPickableActor->ReleaseGraphicsResources(renWin);
1725 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1726 vtkFloatingPointType* aColor = theProperty->GetColor();
1733 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1734 mySurfaceProp->SetOpacity(theValue);
1735 myBackSurfaceProp->SetOpacity(theValue);
1736 myEdgeProp->SetOpacity(theValue);
1737 myNodeProp->SetOpacity(theValue);
1739 my1DProp->SetOpacity(theValue);
1743 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1744 return mySurfaceProp->GetOpacity();
1748 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1749 mySurfaceProp->SetColor(r,g,b);
1750 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1751 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1752 aGroupObj->GetElementType() == SMDSAbs_Volume )
1753 myNameActor->SetBackgroundColor(r,g,b);
1757 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1758 ::GetColor(mySurfaceProp,r,g,b);
1759 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1762 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1763 myBackSurfaceProp->SetColor(r,g,b);
1767 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1768 ::GetColor(myBackSurfaceProp,r,g,b);
1771 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1772 myEdgeProp->SetColor(r,g,b);
1773 my1DProp->SetColor(r,g,b);
1774 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1775 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1776 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1777 myNameActor->SetBackgroundColor(r,g,b);
1781 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1782 ::GetColor(myEdgeProp,r,g,b);
1785 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1786 myNodeProp->SetColor(r,g,b);
1787 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1788 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1789 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1790 myNameActor->SetBackgroundColor(r,g,b);
1794 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1795 ::GetColor(myNodeProp,r,g,b);
1798 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1799 my0DProp->SetColor(r,g,b);
1800 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1801 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1802 myNameActor->SetBackgroundColor(r,g,b);
1806 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1807 ::GetColor(my0DProp,r,g,b);
1810 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1811 myHighlightProp->SetColor(r,g,b);
1815 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1816 ::GetColor(myHighlightProp,r,g,b);
1819 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1820 myPreselectProp->SetColor(r,g,b);
1824 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1825 ::GetColor(myPreselectProp,r,g,b);
1829 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1830 return myEdgeProp->GetLineWidth();
1834 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1835 myEdgeProp->SetLineWidth(theVal);
1837 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1838 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1844 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1845 my0DProp->SetPointSize(theVal);
1849 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1850 return my0DProp->GetPointSize();
1853 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1855 return myVisualObj->GetElemDimension( theObjId );
1860 IsImplicitFunctionUsed() const
1862 return myBaseActor->IsImplicitFunctionUsed();
1866 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1868 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1869 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1871 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1873 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1875 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1876 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1878 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1879 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1881 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1882 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1883 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1884 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1888 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1891 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1892 myCippingPlaneCont.push_back(thePlane);
1893 if(!IsImplicitFunctionUsed())
1894 SetImplicitFunctionUsed(true);
1896 return myCippingPlaneCont.size();
1901 RemoveAllClippingPlanes()
1903 myImplicitBoolean->GetFunction()->RemoveAllItems();
1904 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1905 myCippingPlaneCont.clear();
1906 SetImplicitFunctionUsed(false);
1911 GetNumberOfClippingPlanes()
1913 return myCippingPlaneCont.size();
1918 GetClippingPlane(vtkIdType theID)
1920 if(theID >= myCippingPlaneCont.size())
1922 return myCippingPlaneCont[theID].Get();
1925 void SMESH_ActorDef::UpdateScalarBar()
1927 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1931 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1933 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1934 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1936 aScalarBarTitleProp->SetFontFamilyToArial();
1938 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1940 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1941 if ( f.family() == "Arial" )
1942 aScalarBarTitleProp->SetFontFamilyToArial();
1943 else if ( f.family() == "Courier" )
1944 aScalarBarTitleProp->SetFontFamilyToCourier();
1945 else if ( f.family() == "Times" )
1946 aScalarBarTitleProp->SetFontFamilyToTimes();
1949 aScalarBarTitleProp->BoldOn();
1951 aScalarBarTitleProp->BoldOff();
1954 aScalarBarTitleProp->ItalicOn();
1956 aScalarBarTitleProp->ItalicOff();
1959 aScalarBarTitleProp->ShadowOn();
1961 aScalarBarTitleProp->ShadowOff();
1964 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1965 aScalarBarTitleProp->Delete();
1967 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1969 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1970 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1972 aScalarBarLabelProp->SetFontFamilyToArial();
1973 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1975 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1976 if( f.family() == "Arial" )
1977 aScalarBarLabelProp->SetFontFamilyToArial();
1978 else if( f.family() == "Courier" )
1979 aScalarBarLabelProp->SetFontFamilyToCourier();
1980 else if( f.family() == "Times" )
1981 aScalarBarLabelProp->SetFontFamilyToTimes();
1984 aScalarBarLabelProp->BoldOn();
1986 aScalarBarLabelProp->BoldOff();
1989 aScalarBarLabelProp->ItalicOn();
1991 aScalarBarLabelProp->ItalicOff();
1994 aScalarBarLabelProp->ShadowOn();
1996 aScalarBarLabelProp->ShadowOff();
1999 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2000 aScalarBarLabelProp->Delete();
2002 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2003 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2005 myScalarBarActor->SetOrientationToHorizontal();
2007 myScalarBarActor->SetOrientationToVertical();
2010 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2011 if( mgr->hasValue( "SMESH", name + "x" ) )
2012 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2014 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2015 if( mgr->hasValue( "SMESH", name + "y" ) )
2016 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2017 myScalarBarActor->SetPosition( aXVal, aYVal );
2019 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2020 if( mgr->hasValue( "SMESH", name + "width" ) )
2021 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2022 myScalarBarActor->SetWidth( aWVal );
2024 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2025 if( mgr->hasValue( "SMESH", name + "height" ) )
2026 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2027 myScalarBarActor->SetHeight( aHVal );
2030 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2031 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2032 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2035 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2036 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2037 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2039 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2040 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2042 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2043 myScalarBarActor->SetDistributionColoringType(coloringType);
2045 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2046 QColor(255, 255, 255));
2048 rgb[0]= distributionColor.red()/255.;
2049 rgb[1]= distributionColor.green()/255.;
2050 rgb[2]= distributionColor.blue()/255.;
2051 myScalarBarActor->SetDistributionColor(rgb);
2056 void SMESH_ActorDef::UpdateDistribution()
2058 if(SMESH::Controls::NumericalFunctor* fun =
2059 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2061 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2062 std::vector<int> nbEvents;
2063 std::vector<double> funValues;
2064 SMESH_VisualObjDef::TEntityList elems;
2065 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2066 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2067 std::vector<int> elemIds;
2068 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2069 elemIds.push_back( (*e)->GetID());
2070 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2071 double * range = lookupTable->GetRange();
2072 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2073 myScalarBarActor->SetDistribution(nbEvents);
2077 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2080 case SMESH_Actor::eLines :
2081 myHighlitableActor->SetQuadraticArcMode(false);
2082 my2DActor->SetQuadraticArcMode(false);
2083 my1DActor->SetQuadraticArcMode(false);
2085 case SMESH_Actor::eArcs :
2086 myHighlitableActor->SetQuadraticArcMode(true);
2087 if(GetRepresentation() != SMESH_Actor::ePoint) {
2088 my2DActor->SetQuadraticArcMode(true);
2089 my1DActor->SetQuadraticArcMode(true);
2098 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2100 if(myHighlitableActor->GetQuadraticArcMode())
2101 return SMESH_Actor::eArcs;
2103 return SMESH_Actor::eLines;
2106 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2108 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2109 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2110 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2113 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2115 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2116 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2117 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2118 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2121 #ifndef DISABLE_PLOT2DVIEWER
2122 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2125 my2dHistogram->clearAllPoints();
2127 if(SMESH::Controls::NumericalFunctor* fun =
2128 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2131 if(!my2dHistogram) {
2132 my2dHistogram = new SPlot2d_Histogram();
2133 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2134 my2dHistogram->setIO(anIO);
2137 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2138 std::vector<int> nbEvents;
2139 std::vector<double> funValues;
2140 SMESH_VisualObjDef::TEntityList elems;
2141 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2142 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2143 std::vector<int> elemIds;
2145 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2146 elemIds.push_back( (*e)->GetID());
2148 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2149 double * range = lookupTable->GetRange();
2150 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2152 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2153 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2155 if(funValues.size() >= 2)
2156 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2160 //Color of the histogram
2161 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2162 my2dHistogram->setAutoAssign(true);
2165 myScalarBarActor->GetDistributionColor(rgb);
2166 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2167 my2dHistogram->setColor(aColor);
2171 return my2dHistogram;