1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_ObjectDef.h"
32 #include "SMESH_ControlsDef.hxx"
33 #include "SMDS_UnstructuredGrid.hxx"
34 #include "SMESH_ScalarBarActor.h"
35 #include "VTKViewer_CellCenters.h"
36 #include "VTKViewer_ExtractUnstructuredGrid.h"
37 #include "VTKViewer_FramedTextActor.h"
38 #include "SALOME_InteractiveObject.hxx"
40 #include "SUIT_Session.h"
41 #include "SUIT_ResourceMgr.h"
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 = NULL;
107 if(theVisualObj->IsValid() ) {
108 anActor = SMESH_ActorDef::New();
109 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
114 anActor->UpdateScalarBar();
120 SMESH_ActorDef::SMESH_ActorDef()
122 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
124 myTimeStamp = vtkTimeStamp::New();
126 myIsPointsVisible = false;
128 myIsShrinkable = false;
131 myIsFacesOriented = false;
133 myControlsPrecision = -1;
134 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
136 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
137 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
139 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
140 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
142 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
143 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
145 //Definition 2D and 3D devices of the actor
146 //-----------------------------------------
147 vtkFloatingPointType anRGB[3] = {1,1,1};
148 mySurfaceProp = vtkProperty::New();
149 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
150 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
152 myBackSurfaceProp = vtkProperty::New();
153 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
154 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
156 my2DActor = SMESH_DeviceActor::New();
157 my2DActor->SetUserMatrix(aMatrix);
158 my2DActor->PickableOff();
159 my2DActor->SetProperty(mySurfaceProp);
160 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
161 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
162 aFilter = my2DActor->GetExtractUnstructuredGrid();
163 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
164 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
165 aFilter->RegisterCellsWithType(VTK_POLYGON);
166 aFilter->RegisterCellsWithType(VTK_QUAD);
167 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
168 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
170 my2DExtProp = vtkProperty::New();
171 my2DExtProp->DeepCopy(mySurfaceProp);
172 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
173 anRGB[0] = 1 - anRGB[0];
174 anRGB[1] = 1 - anRGB[1];
175 anRGB[2] = 1 - anRGB[2];
176 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
178 my2DExtActor = SMESH_DeviceActor::New();
179 my2DExtActor->SetUserMatrix(aMatrix);
180 my2DExtActor->PickableOff();
181 my2DExtActor->SetProperty(my2DExtProp);
182 my2DExtActor->SetBackfaceProperty(my2DExtProp);
183 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
184 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
185 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
186 aFilter->RegisterCellsWithType(VTK_POLYGON);
187 aFilter->RegisterCellsWithType(VTK_QUAD);
188 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
189 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
191 my3DActor = SMESH_DeviceActor::New();
192 my3DActor->SetUserMatrix(aMatrix);
193 my3DActor->PickableOff();
194 my3DActor->SetProperty(mySurfaceProp);
195 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
196 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
197 aFilter = my3DActor->GetExtractUnstructuredGrid();
198 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
199 aFilter->RegisterCellsWithType(VTK_TETRA);
200 aFilter->RegisterCellsWithType(VTK_VOXEL);
201 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
202 aFilter->RegisterCellsWithType(VTK_WEDGE);
203 aFilter->RegisterCellsWithType(VTK_PYRAMID);
204 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
205 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
206 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
207 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
208 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
209 //#ifdef VTK_HAVE_POLYHEDRON
210 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
211 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
214 my3DExtActor = SMESH_DeviceActor::New();
215 my3DExtActor->SetUserMatrix(aMatrix);
216 my3DExtActor->PickableOff();
217 my3DExtActor->SetProperty(my2DExtProp);
218 my3DExtActor->SetBackfaceProperty(my2DExtProp);
219 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
220 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
221 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
222 aFilter->RegisterCellsWithType(VTK_TETRA);
223 aFilter->RegisterCellsWithType(VTK_VOXEL);
224 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
225 aFilter->RegisterCellsWithType(VTK_WEDGE);
226 aFilter->RegisterCellsWithType(VTK_PYRAMID);
227 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
228 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
229 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
231 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
232 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
234 //Definition 1D device of the actor
235 //---------------------------------
236 myEdgeProp = vtkProperty::New();
237 myEdgeProp->SetAmbient(1.0);
238 myEdgeProp->SetDiffuse(0.0);
239 myEdgeProp->SetSpecular(0.0);
240 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
241 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
242 myEdgeProp->SetLineWidth(aLineWidth);
244 my1DActor = SMESH_DeviceActor::New();
245 my1DActor->SetUserMatrix(aMatrix);
246 my1DActor->PickableOff();
247 my1DActor->SetHighlited(true);
248 my1DActor->SetProperty(myEdgeProp);
249 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
250 aFilter = my1DActor->GetExtractUnstructuredGrid();
251 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
252 aFilter->RegisterCellsWithType(VTK_LINE);
253 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
255 my1DProp = vtkProperty::New();
256 my1DProp->DeepCopy(myEdgeProp);
257 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
258 my1DProp->SetPointSize(aElem0DSize);
260 my1DExtProp = vtkProperty::New();
261 my1DExtProp->DeepCopy(myEdgeProp);
262 anRGB[0] = 1 - anRGB[0];
263 anRGB[1] = 1 - anRGB[1];
264 anRGB[2] = 1 - anRGB[2];
265 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
266 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
267 my1DExtProp->SetPointSize(aElem0DSize);
269 my1DExtActor = SMESH_DeviceActor::New();
270 my1DExtActor->SetUserMatrix(aMatrix);
271 my1DExtActor->PickableOff();
272 my1DExtActor->SetHighlited(true);
273 my1DExtActor->SetVisibility(false);
274 my1DExtActor->SetProperty(my1DExtProp);
275 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
276 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
277 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
278 aFilter->RegisterCellsWithType(VTK_LINE);
279 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
282 //Definition 0D device of the actor (0d elements)
283 //-----------------------------------------------
284 my0DProp = vtkProperty::New();
285 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
286 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
287 my0DProp->SetPointSize(aElem0DSize);
289 my0DActor = SMESH_DeviceActor::New();
290 my0DActor->SetUserMatrix(aMatrix);
291 my0DActor->SetStoreClippingMapping(true);
292 my0DActor->PickableOff();
293 my0DActor->SetVisibility(false);
294 my0DActor->SetProperty(my0DProp);
295 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
296 aFilter = my0DActor->GetExtractUnstructuredGrid();
297 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
298 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
299 aFilter->RegisterCellsWithType(VTK_VERTEX);
301 //my0DExtProp = vtkProperty::New();
302 //my0DExtProp->DeepCopy(my0DProp);
303 //anRGB[0] = 1 - anRGB[0];
304 //anRGB[1] = 1 - anRGB[1];
305 //anRGB[2] = 1 - anRGB[2];
306 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
307 //my0DExtProp->SetPointSize(aElem0DSize);
309 //my0DExtActor = SMESH_DeviceActor::New();
310 //my0DExtActor->SetUserMatrix(aMatrix);
311 //my0DExtActor->SetStoreClippingMapping(true);
312 //my0DExtActor->PickableOff();
313 //my0DExtActor->SetHighlited(true);
314 //my0DExtActor->SetVisibility(false);
315 //my0DExtActor->SetProperty(my0DExtProp);
316 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
317 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
318 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
319 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
320 //aFilter->RegisterCellsWithType(VTK_VERTEX);
323 //Definition 0D device of the actor (nodes)
324 //-----------------------------------------
325 myNodeProp = vtkProperty::New();
326 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
327 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
329 myNodeActor = SMESH_DeviceActor::New();
330 myNodeActor->SetUserMatrix(aMatrix);
331 myNodeActor->SetStoreClippingMapping(true);
332 myNodeActor->PickableOff();
333 myNodeActor->SetVisibility(false);
334 myNodeActor->SetProperty(myNodeProp);
335 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
336 aFilter = myNodeActor->GetExtractUnstructuredGrid();
337 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
339 myNodeExtProp = vtkProperty::New();
340 myNodeExtProp->DeepCopy(myNodeProp);
341 anRGB[0] = 1 - anRGB[0];
342 anRGB[1] = 1 - anRGB[1];
343 anRGB[2] = 1 - anRGB[2];
344 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
346 myNodeExtActor = SMESH_DeviceActor::New();
347 myNodeExtActor->SetUserMatrix(aMatrix);
348 myNodeExtActor->SetStoreClippingMapping(true);
349 myNodeExtActor->PickableOff();
350 myNodeExtActor->SetHighlited(true);
351 myNodeExtActor->SetVisibility(false);
352 myNodeExtActor->SetProperty(myNodeExtProp);
353 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
354 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
355 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
356 aFilter->RegisterCellsWithType(VTK_VERTEX);
358 //Definition of Pickable and Highlitable engines
359 //----------------------------------------------
361 myBaseActor = SMESH_DeviceActor::New();
362 myBaseActor->SetUserMatrix(aMatrix);
363 myBaseActor->SetStoreGemetryMapping(true);
364 myBaseActor->GetProperty()->SetOpacity(0.0);
366 myPickableActor = myBaseActor;
368 myHighlightProp = vtkProperty::New();
369 myHighlightProp->SetAmbient(1.0);
370 myHighlightProp->SetDiffuse(0.0);
371 myHighlightProp->SetSpecular(0.0);
372 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
373 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
374 myHighlightProp->SetPointSize(aElem0DSize); // ??
375 myHighlightProp->SetRepresentation(1);
377 myPreselectProp = vtkProperty::New();
378 myPreselectProp->SetAmbient(1.0);
379 myPreselectProp->SetDiffuse(0.0);
380 myPreselectProp->SetSpecular(0.0);
381 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
382 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
383 myPreselectProp->SetPointSize(aElem0DSize); // ??
384 myPreselectProp->SetRepresentation(1);
386 myHighlitableActor = SMESH_DeviceActor::New();
387 myHighlitableActor->SetUserMatrix(aMatrix);
388 myHighlitableActor->PickableOff();
389 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
396 myControlMode = eNone;
397 myControlActor = my2DActor;
399 //Definition of myScalarBarActor
400 //------------------------------
401 myLookupTable = vtkLookupTable::New();
402 //Fix for Bug PAL5195 - SMESH764:
403 //Controls - Aspect Ratio: incorrect colors of the best and worst values
404 myLookupTable->SetHueRange(0.667,0.0);
406 myScalarBarActor = SMESH_ScalarBarActor::New();
407 myScalarBarActor->SetVisibility(false);
408 myScalarBarActor->SetLookupTable(myLookupTable);
411 //Incorrect "Min value" in Scalar Bar in Mesh:
412 // myScalarBarActor->SetLabelFormat("%.4g");
413 // changes was commented because of regression bug IPAL 19981
415 mgr = SUIT_Session::session()->resourceMgr();
419 //Definition of points numbering pipeline
420 //---------------------------------------
421 myPointsNumDataSet = vtkUnstructuredGrid::New();
423 myPtsMaskPoints = vtkMaskPoints::New();
424 myPtsMaskPoints->SetInput(myPointsNumDataSet);
425 myPtsMaskPoints->SetOnRatio(1);
427 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
428 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
429 myPtsSelectVisiblePoints->SelectInvisibleOff();
430 myPtsSelectVisiblePoints->SetTolerance(0.1);
432 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
433 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
434 #if (VTK_XVERSION < 0x050200)
435 myPtsLabeledDataMapper->SetLabelFormat("%g");
437 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
439 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
440 aPtsTextProp->SetFontFamilyToTimes();
441 static int aPointsFontSize = 10;
442 aPtsTextProp->SetFontSize(aPointsFontSize);
443 aPtsTextProp->SetBold(1);
444 aPtsTextProp->SetItalic(0);
445 aPtsTextProp->SetShadow(0);
446 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
447 aPtsTextProp->Delete();
449 myEntityMode = eAllEntity;
451 myIsPointsLabeled = false;
453 myPointLabels = vtkActor2D::New();
454 myPointLabels->SetMapper(myPtsLabeledDataMapper);
455 myPointLabels->GetProperty()->SetColor(1,1,1);
456 myPointLabels->SetVisibility(myIsPointsLabeled);
459 //Definition of cells numbering pipeline
460 //---------------------------------------
461 myCellsNumDataSet = vtkUnstructuredGrid::New();
463 myCellCenters = VTKViewer_CellCenters::New();
464 myCellCenters->SetInput(myCellsNumDataSet);
466 myClsMaskPoints = vtkMaskPoints::New();
467 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
468 myClsMaskPoints->SetOnRatio(1);
470 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
471 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
472 myClsSelectVisiblePoints->SelectInvisibleOff();
473 myClsSelectVisiblePoints->SetTolerance(0.1);
475 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
476 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
477 #if (VTK_XVERSION < 0x050200)
478 myClsLabeledDataMapper->SetLabelFormat("%g");
480 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
482 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
483 aClsTextProp->SetFontFamilyToTimes();
484 static int aCellsFontSize = 12;
485 aClsTextProp->SetFontSize(aCellsFontSize);
486 aClsTextProp->SetBold(1);
487 aClsTextProp->SetItalic(0);
488 aClsTextProp->SetShadow(0);
489 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
490 aClsTextProp->Delete();
492 myIsCellsLabeled = false;
494 myCellsLabels = vtkActor2D::New();
495 myCellsLabels->SetMapper(myClsLabeledDataMapper);
496 myCellsLabels->GetProperty()->SetColor(0,1,0);
497 myCellsLabels->SetVisibility(myIsCellsLabeled);
500 myImplicitBoolean = vtkImplicitBoolean::New();
501 myImplicitBoolean->SetOperationTypeToIntersection();
505 //Quadratic 2D elements representation
506 //-----------------------------------------------------------------------------
507 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
508 if(aQuadratic2DMode == 0){
509 myHighlitableActor->SetQuadraticArcMode(false);
510 my2DActor->SetQuadraticArcMode(false);
511 my1DActor->SetQuadraticArcMode(false);
513 else if(aQuadratic2DMode == 1){
514 myHighlitableActor->SetQuadraticArcMode(true);
515 my2DActor->SetQuadraticArcMode(true);
516 my1DActor->SetQuadraticArcMode(true);
519 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
520 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
521 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
523 // Set colors of the name actor
524 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
525 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
526 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
527 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
529 #ifndef DISABLE_PLOT2DVIEWER
536 SMESH_ActorDef::~SMESH_ActorDef()
538 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
540 #ifndef DISABLE_PLOT2DVIEWER
542 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
543 delete my2dHistogram;
547 // caught by SMESHGUI::ProcessEvents() static method
548 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
550 myScalarBarActor->Delete();
551 myLookupTable->Delete();
553 mySurfaceProp->Delete();
554 myBackSurfaceProp->Delete();
556 myEdgeProp->Delete();
557 myHighlightProp->Delete();
558 myPreselectProp->Delete();
560 myNodeProp->Delete();
561 myNodeExtProp->Delete();
566 //my0DExtProp->Delete();
567 //my0DExtActor->Delete();
572 my1DExtProp->Delete();
573 my1DExtActor->Delete();
576 my2DExtProp->Delete();
577 my2DExtActor->Delete();
579 my3DExtActor->Delete();
581 myNodeActor->Delete();
582 myBaseActor->Delete();
584 myNodeExtActor->Delete();
586 myHighlitableActor->Delete();
588 //Deleting of points numbering pipeline
589 //---------------------------------------
590 myPointsNumDataSet->Delete();
592 // commented: porting to vtk 5.0
593 // myPtsLabeledDataMapper->RemoveAllInputs();
594 myPtsLabeledDataMapper->Delete();
596 // commented: porting to vtk 5.0
597 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
598 myPtsSelectVisiblePoints->Delete();
600 // commented: porting to vtk 5.0
601 // myPtsMaskPoints->UnRegisterAllOutputs();
602 myPtsMaskPoints->Delete();
604 myPointLabels->Delete();
607 //Deleting of cells numbering pipeline
608 //---------------------------------------
609 myCellsNumDataSet->Delete();
611 myClsLabeledDataMapper->RemoveAllInputs();
612 myClsLabeledDataMapper->Delete();
614 // commented: porting to vtk 5.0
615 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
616 myClsSelectVisiblePoints->Delete();
618 // commented: porting to vtk 5.0
619 // myClsMaskPoints->UnRegisterAllOutputs();
620 myClsMaskPoints->Delete();
622 // commented: porting to vtk 5.0
623 // myCellCenters->UnRegisterAllOutputs();
624 myCellCenters->Delete();
626 myCellsLabels->Delete();
628 myImplicitBoolean->Delete();
630 myTimeStamp->Delete();
634 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
636 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
638 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
640 if ( myIsPointsLabeled )
642 myPointsNumDataSet->ShallowCopy(aGrid);
643 vtkDataSet *aDataSet = myPointsNumDataSet;
645 int aNbElem = aDataSet->GetNumberOfPoints();
647 vtkIntArray *anArray = vtkIntArray::New();
648 anArray->SetNumberOfValues( aNbElem );
650 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
652 int aSMDSId = myVisualObj->GetNodeObjId( anId );
653 anArray->SetValue( anId, aSMDSId );
656 aDataSet->GetPointData()->SetScalars( anArray );
658 myPtsMaskPoints->SetInput( aDataSet );
659 myPointLabels->SetVisibility( GetVisibility() );
663 myPointLabels->SetVisibility( false );
665 SetRepresentation(GetRepresentation());
666 myTimeStamp->Modified();
670 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
672 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
673 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
674 if(myIsCellsLabeled){
675 myCellsNumDataSet->ShallowCopy(aGrid);
676 vtkDataSet *aDataSet = myCellsNumDataSet;
677 int aNbElem = aDataSet->GetNumberOfCells();
678 vtkIntArray *anArray = vtkIntArray::New();
679 anArray->SetNumberOfValues(aNbElem);
680 for(int anId = 0; anId < aNbElem; anId++){
681 int aSMDSId = myVisualObj->GetElemObjId(anId);
682 anArray->SetValue(anId,aSMDSId);
684 aDataSet->GetCellData()->SetScalars(anArray);
685 myCellCenters->SetInput(aDataSet);
686 myCellsLabels->SetVisibility(GetVisibility());
688 myCellsLabels->SetVisibility(false);
690 myTimeStamp->Modified();
694 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
696 myIsFacesOriented = theIsFacesOriented;
698 my2DActor->SetFacesOriented(theIsFacesOriented);
699 my3DActor->SetFacesOriented(theIsFacesOriented);
701 myTimeStamp->Modified();
704 bool SMESH_ActorDef::GetFacesOriented()
706 return myIsFacesOriented;
709 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
711 my2DActor->SetFacesOrientationColor( theColor );
712 my3DActor->SetFacesOrientationColor( theColor );
715 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
717 my3DActor->GetFacesOrientationColor( theColor );
720 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
722 my2DActor->SetFacesOrientationScale( theScale );
723 my3DActor->SetFacesOrientationScale( theScale );
726 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
728 return my3DActor->GetFacesOrientationScale();
731 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
733 my2DActor->SetFacesOrientation3DVectors( theState );
734 my3DActor->SetFacesOrientation3DVectors( theState );
737 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
739 return my3DActor->GetFacesOrientation3DVectors();
745 SetControlMode(eControl theMode)
747 SetControlMode(theMode,true);
753 SetControlMode(eControl theMode,
754 bool theCheckEntityMode)
756 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
760 myControlMode = eNone;
761 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
763 my0DActor->GetMapper()->SetScalarVisibility(false);
764 my1DActor->GetMapper()->SetScalarVisibility(false);
765 my2DActor->GetMapper()->SetScalarVisibility(false);
766 my3DActor->GetMapper()->SetScalarVisibility(false);
767 myScalarBarActor->SetVisibility(false);
769 bool anIsScalarVisible = theMode > eNone;
771 if(anIsScalarVisible) {
775 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
776 aControl->SetPrecision( myControlsPrecision );
777 myFunctor.reset( aControl );
778 myControlActor = my1DActor;
783 myFunctor.reset(new SMESH::Controls::Length2D());
784 myControlActor = my2DActor;
788 myFunctor.reset(new SMESH::Controls::FreeBorders());
789 myControlActor = my1DActor;
792 myFunctor.reset(new SMESH::Controls::FreeEdges());
793 myControlActor = my2DActor;
796 myFunctor.reset(new SMESH::Controls::FreeNodes());
797 myControlActor = myNodeActor;
800 myFunctor.reset(new SMESH::Controls::FreeFaces());
801 myControlActor = my2DActor;
803 case eBareBorderFace:
804 myFunctor.reset(new SMESH::Controls::BareBorderFace());
805 myControlActor = my2DActor;
807 case eOverConstrainedFace:
808 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
809 myControlActor = my2DActor;
811 case eMultiConnection:
812 myFunctor.reset(new SMESH::Controls::MultiConnection());
813 myControlActor = my1DActor;
815 case eMultiConnection2D:
816 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
817 myControlActor = my2DActor;
821 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
822 aControl->SetPrecision( myControlsPrecision );
823 myFunctor.reset( aControl );
824 myControlActor = my2DActor;
829 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
830 aControl->SetPrecision( myControlsPrecision );
831 myFunctor.reset( aControl );
832 myControlActor = my2DActor;
837 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
838 aControl->SetPrecision( myControlsPrecision );
839 myFunctor.reset( aControl );
840 myControlActor = my2DActor;
845 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
846 aControl->SetPrecision( myControlsPrecision );
847 myFunctor.reset( aControl );
848 myControlActor = my3DActor;
853 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
854 aControl->SetPrecision( myControlsPrecision );
855 myFunctor.reset( aControl );
856 myControlActor = my3DActor;
859 case eMaxElementLength2D:
861 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
862 aControl->SetPrecision( myControlsPrecision );
863 myFunctor.reset( aControl );
864 myControlActor = my2DActor;
867 case eMaxElementLength3D:
869 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
870 aControl->SetPrecision( myControlsPrecision );
871 myFunctor.reset( aControl );
872 myControlActor = my3DActor;
875 case eBareBorderVolume:
877 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
878 myControlActor = my3DActor;
881 case eOverConstrainedVolume:
883 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
884 myControlActor = my3DActor;
889 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
890 aControl->SetPrecision( myControlsPrecision );
891 myFunctor.reset( aControl );
892 myControlActor = my2DActor;
897 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
898 aControl->SetPrecision( myControlsPrecision );
899 myFunctor.reset( aControl );
900 myControlActor = my2DActor;
905 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
906 aControl->SetPrecision( myControlsPrecision );
907 myFunctor.reset( aControl );
908 myControlActor = my2DActor;
915 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
916 vtkIdType aNbCells = aGrid->GetNumberOfCells();
918 myControlMode = theMode;
919 switch(myControlMode){
921 myNodeExtActor->SetExtControlMode(myFunctor);
925 my1DExtActor->SetExtControlMode(myFunctor);
928 case eBareBorderFace:
929 case eOverConstrainedFace:
930 my2DExtActor->SetExtControlMode(myFunctor);
932 case eBareBorderVolume:
933 case eOverConstrainedVolume:
934 my3DExtActor->SetExtControlMode(myFunctor);
937 case eMultiConnection2D:
938 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
939 UpdateDistribution();
942 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
943 UpdateDistribution();
947 if(theCheckEntityMode){
948 if(myControlActor == my1DActor)
949 SetEntityMode(eEdges);
950 else if(myControlActor == my2DActor){
951 switch(myControlMode){
955 case eMultiConnection2D:
956 //SetEntityMode(eEdges);
957 SetEntityMode(eFaces);
960 SetEntityMode(eFaces);
962 }else if(myControlActor == my3DActor)
963 SetEntityMode(eVolumes);
968 if(theCheckEntityMode)
969 myEntityMode = eAllEntity;
973 SetRepresentation(GetRepresentation());
975 myTimeStamp->Modified();
980 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
981 theRenderer->AddActor(myNodeActor);
982 theRenderer->AddActor(myBaseActor);
984 theRenderer->AddActor(myNodeExtActor);
986 my3DActor->AddToRender(theRenderer);
987 my3DExtActor->AddToRender(theRenderer);
988 my2DActor->AddToRender(theRenderer);
989 my2DExtActor->AddToRender(theRenderer);
991 theRenderer->AddActor(my1DActor);
992 theRenderer->AddActor(my1DExtActor);
994 theRenderer->AddActor(my0DActor);
995 //theRenderer->AddActor(my0DExtActor);
997 theRenderer->AddActor(myHighlitableActor);
999 theRenderer->AddActor2D(myScalarBarActor);
1001 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
1002 myClsSelectVisiblePoints->SetRenderer(theRenderer);
1004 theRenderer->AddActor2D(myPointLabels);
1005 theRenderer->AddActor2D(myCellsLabels);
1007 // the superclass' method should be called at the end
1008 // (in particular, for correct work of selection)
1009 SALOME_Actor::AddToRender(theRenderer);
1012 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1013 SALOME_Actor::RemoveFromRender(theRenderer);
1015 theRenderer->RemoveActor(myNodeActor);
1016 theRenderer->RemoveActor(myBaseActor);
1018 theRenderer->RemoveActor(myNodeExtActor);
1020 theRenderer->RemoveActor(myHighlitableActor);
1022 theRenderer->RemoveActor(my0DActor);
1023 //theRenderer->RemoveActor(my0DExtActor);
1025 theRenderer->RemoveActor(my1DActor);
1026 theRenderer->RemoveActor(my1DExtActor);
1028 my2DActor->RemoveFromRender(theRenderer);
1029 my2DExtActor->RemoveFromRender(theRenderer);
1030 my3DActor->RemoveFromRender(theRenderer);
1031 my3DExtActor->RemoveFromRender(theRenderer);
1033 theRenderer->RemoveActor(myScalarBarActor);
1034 theRenderer->RemoveActor(myPointLabels);
1035 theRenderer->RemoveActor(myCellsLabels);
1039 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1040 const char* theEntry,
1041 const char* theName,
1044 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1048 myVisualObj = theVisualObj;
1049 myVisualObj->Update(theIsClear);
1051 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1052 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1054 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1056 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1058 my0DActor->Init(myVisualObj,myImplicitBoolean);
1059 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1061 my1DActor->Init(myVisualObj,myImplicitBoolean);
1062 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1064 my2DActor->Init(myVisualObj,myImplicitBoolean);
1065 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1066 my3DActor->Init(myVisualObj,myImplicitBoolean);
1067 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1069 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1070 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1072 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1073 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1075 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1076 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1077 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1078 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1080 vtkFloatingPointType aFactor, aUnits;
1081 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1082 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1083 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1085 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1089 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1090 SetIsShrunkable(true);
1092 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1094 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1095 SetRepresentation(-1);
1098 SetRepresentation(eEdge);
1099 }else if(aMode == 1){
1100 SetRepresentation(eSurface);
1101 }else if(aMode == 2){
1102 SetRepresentation(ePoint);
1109 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1110 SetIsDisplayNameActor( true );
1112 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1113 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1114 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1116 myTimeStamp->Modified();
1122 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1123 return myNodeActor->GetBounds();
1127 vtkDataSet* SMESH_ActorDef::GetInput(){
1128 return GetUnstructuredGrid();
1132 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1133 Superclass::SetTransform(theTransform);
1135 myNodeActor->SetTransform(theTransform);
1136 myBaseActor->SetTransform(theTransform);
1138 myHighlitableActor->SetTransform(theTransform);
1140 myNodeExtActor->SetTransform(theTransform);
1142 my0DActor->SetTransform(theTransform);
1143 //my0DExtActor->SetTransform(theTransform);
1145 my1DActor->SetTransform(theTransform);
1146 my1DExtActor->SetTransform(theTransform);
1148 my2DActor->SetTransform(theTransform);
1149 my2DExtActor->SetTransform(theTransform);
1150 my3DActor->SetTransform(theTransform);
1151 my3DExtActor->SetTransform(theTransform);
1157 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1158 vtkLODActor::SetMapper(theMapper);
1162 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1163 SALOME_Actor::ShallowCopy(prop);
1167 vtkMapper* SMESH_ActorDef::GetMapper(){
1168 return myPickableActor->GetMapper();
1172 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1173 return myVisualObj->GetUnstructuredGrid();
1177 bool SMESH_ActorDef::IsInfinitive(){
1178 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1180 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1181 ( aDataSet->GetNumberOfCells() == 1 &&
1182 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1183 return SALOME_Actor::IsInfinitive();
1187 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1188 if ( myIsShrinkable == theShrunkable )
1190 myIsShrinkable = theShrunkable;
1194 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1195 return myBaseActor->GetShrinkFactor();
1198 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1199 myBaseActor->SetShrinkFactor(theValue);
1201 my1DActor->SetShrinkFactor(theValue);
1202 my1DExtActor->SetShrinkFactor(theValue);
1204 my2DActor->SetShrinkFactor(theValue);
1205 my2DExtActor->SetShrinkFactor(theValue);
1206 my3DActor->SetShrinkFactor(theValue);
1207 my3DExtActor->SetShrinkFactor(theValue);
1212 void SMESH_ActorDef::SetShrink(){
1213 if(!myIsShrinkable) return;
1215 myBaseActor->SetShrink();
1217 my1DActor->SetShrink();
1218 my1DExtActor->SetShrink();
1220 my2DActor->SetShrink();
1221 my2DExtActor->SetShrink();
1222 my3DActor->SetShrink();
1223 my3DExtActor->SetShrink();
1229 void SMESH_ActorDef::UnShrink(){
1230 if(!myIsShrunk) return;
1232 myBaseActor->UnShrink();
1234 my1DActor->UnShrink();
1235 my1DExtActor->UnShrink();
1237 my2DActor->UnShrink();
1238 my2DExtActor->UnShrink();
1239 my3DActor->UnShrink();
1240 my3DExtActor->UnShrink();
1247 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1248 return myPickableActor->GetNodeObjId(theVtkID);
1251 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1252 return myPickableActor->GetNodeCoord(theObjID);
1256 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1257 return myPickableActor->GetElemObjId(theVtkID);
1260 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1261 return myPickableActor->GetElemCell(theObjID);
1265 void SMESH_ActorDef::SetVisibility(int theMode){
1266 SetVisibility(theMode,true);
1270 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1271 SALOME_Actor::SetVisibility(theMode);
1273 myNodeActor->VisibilityOff();
1274 myBaseActor->VisibilityOff();
1276 myNodeExtActor->VisibilityOff();
1278 my0DActor->VisibilityOff();
1279 //my0DExtActor->VisibilityOff();
1281 my1DActor->VisibilityOff();
1282 my1DExtActor->VisibilityOff();
1284 my2DActor->VisibilityOff();
1285 my2DExtActor->VisibilityOff();
1286 my3DActor->VisibilityOff();
1287 my3DExtActor->VisibilityOff();
1289 myScalarBarActor->VisibilityOff();
1290 myPointLabels->VisibilityOff();
1291 myCellsLabels->VisibilityOff();
1293 if(GetVisibility()){
1294 if(theIsUpdateRepersentation)
1295 SetRepresentation(GetRepresentation());
1297 if(myControlMode != eNone){
1298 switch(myControlMode){
1300 myNodeExtActor->VisibilityOn();
1304 my1DExtActor->VisibilityOn();
1307 case eBareBorderFace:
1308 case eOverConstrainedFace:
1309 my2DExtActor->VisibilityOn();
1311 case eBareBorderVolume:
1312 case eOverConstrainedVolume:
1313 my3DExtActor->VisibilityOn();
1316 case eMultiConnection2D:
1317 my1DExtActor->VisibilityOn();
1319 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1320 myScalarBarActor->VisibilityOn();
1324 if(myRepresentation != ePoint)
1325 myPickableActor->VisibilityOn();
1327 myNodeActor->VisibilityOn();
1330 if(myEntityMode & e0DElements){
1331 my0DActor->VisibilityOn();
1334 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1335 my1DActor->VisibilityOn();
1338 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1339 my2DActor->VisibilityOn();
1342 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1343 my3DActor->VisibilityOn();
1346 if(myIsPointsLabeled){
1347 myPointLabels->VisibilityOn();
1348 myNodeActor->VisibilityOn();
1351 if(myIsCellsLabeled)
1352 myCellsLabels->VisibilityOn();
1354 #ifndef DISABLE_PLOT2DVIEWER
1356 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1363 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1365 myEntityState = eAllEntity;
1367 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1368 myEntityState &= ~e0DElements;
1369 theMode &= ~e0DElements;
1372 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1373 myEntityState &= ~eEdges;
1377 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1378 myEntityState &= ~eFaces;
1382 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1383 myEntityState &= ~eVolumes;
1384 theMode &= ~eVolumes;
1388 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1389 theMode |= e0DElements;
1391 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1394 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1397 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1398 theMode |= eVolumes;
1401 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1403 myEntityMode = theMode;
1404 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1405 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1406 aFilter->ClearRegisteredCellsWithType();
1407 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1409 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1410 aHightFilter->ClearRegisteredCellsWithType();
1411 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1413 if (myEntityMode & e0DElements) {
1414 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1415 aFilter->RegisterCellsWithType(VTK_VERTEX);
1416 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1419 if (myEntityMode & eEdges) {
1420 if (MYDEBUG) MESSAGE("EDGES");
1421 aFilter->RegisterCellsWithType(VTK_LINE);
1422 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1424 aHightFilter->RegisterCellsWithType(VTK_LINE);
1425 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1428 if (myEntityMode & eFaces) {
1429 if (MYDEBUG) MESSAGE("FACES");
1430 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1431 aFilter->RegisterCellsWithType(VTK_POLYGON);
1432 aFilter->RegisterCellsWithType(VTK_QUAD);
1433 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1434 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1436 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1437 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1438 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1439 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1440 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1443 if (myEntityMode & eVolumes) {
1444 if (MYDEBUG) MESSAGE("VOLUMES");
1445 aFilter->RegisterCellsWithType(VTK_TETRA);
1446 aFilter->RegisterCellsWithType(VTK_VOXEL);
1447 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1448 aFilter->RegisterCellsWithType(VTK_WEDGE);
1449 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1450 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1451 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1452 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1453 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1454 //#ifdef VTK_HAVE_POLYHEDRON
1455 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1458 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1459 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1460 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1461 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1462 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1463 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1464 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1465 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1466 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1467 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1468 //#ifdef VTK_HAVE_POLYHEDRON
1469 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1473 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1474 SetVisibility(GetVisibility(),false);
1477 void SMESH_ActorDef::SetRepresentation (int theMode)
1479 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1480 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1481 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1484 myRepresentation = eSurface;
1485 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1486 myRepresentation = eEdge;
1487 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1488 myRepresentation = ePoint;
1493 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1496 if (!aNbFaces && !aNbVolumes) return;
1499 myRepresentation = theMode;
1502 if (!GetUnstructuredGrid()->GetNumberOfCells())
1503 myRepresentation = ePoint;
1506 if (myRepresentation == ePoint) {
1514 myPickableActor = myBaseActor;
1515 myNodeActor->SetVisibility(false);
1516 myNodeExtActor->SetVisibility(false);
1517 vtkProperty *aProp = NULL, *aBackProp = NULL;
1518 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1519 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1520 switch (myRepresentation) {
1522 myPickableActor = myNodeActor;
1523 myNodeActor->SetVisibility(true);
1524 aQuadraticMode = SMESH_Actor::eLines;
1525 aProp = aBackProp = myNodeProp;
1526 aReperesent = SMESH_DeviceActor::ePoint;
1529 aProp = aBackProp = myEdgeProp;
1530 aReperesent = SMESH_DeviceActor::eInsideframe;
1533 aProp = mySurfaceProp;
1534 aBackProp = myBackSurfaceProp;
1535 aReperesent = SMESH_DeviceActor::eSurface;
1539 my2DActor->SetProperty(aProp);
1540 my2DActor->SetBackfaceProperty(aBackProp);
1541 my2DActor->SetRepresentation(aReperesent);
1543 if(aQuadraticMode == SMESH_Actor::eLines)
1544 my2DActor->SetQuadraticArcMode(false);
1545 else if(aQuadraticMode == SMESH_Actor::eArcs)
1546 my2DActor->SetQuadraticArcMode(true);
1548 my2DExtActor->SetRepresentation(aReperesent);
1550 my3DActor->SetProperty(aProp);
1551 my3DActor->SetBackfaceProperty(aBackProp);
1552 my3DActor->SetRepresentation(aReperesent);
1554 //my0DExtActor->SetVisibility(false);
1555 my1DExtActor->SetVisibility(false);
1556 my2DExtActor->SetVisibility(false);
1557 my3DExtActor->SetVisibility(false);
1560 //my0DActor->SetProperty(aProp);
1561 //my0DActor->SetBackfaceProperty(aBackProp);
1562 my0DActor->SetRepresentation(aReperesent);
1563 //my0DExtActor->SetRepresentation(aReperesent);
1565 switch(myControlMode){
1567 case eMultiConnection:
1568 aProp = aBackProp = my1DProp;
1569 if(myRepresentation != ePoint)
1570 aReperesent = SMESH_DeviceActor::eInsideframe;
1574 if(aQuadraticMode == SMESH_Actor::eLines)
1575 my1DActor->SetQuadraticArcMode(false);
1576 else if(aQuadraticMode == SMESH_Actor::eArcs)
1577 my1DActor->SetQuadraticArcMode(true);
1579 my1DActor->SetProperty(aProp);
1580 my1DActor->SetBackfaceProperty(aBackProp);
1581 my1DActor->SetRepresentation(aReperesent);
1583 my1DExtActor->SetRepresentation(aReperesent);
1585 if(myIsPointsVisible)
1586 myPickableActor = myNodeActor;
1587 if(GetPointRepresentation())
1588 myNodeActor->SetVisibility(true);
1590 SetMapper(myPickableActor->GetMapper());
1592 SetVisibility(GetVisibility(),false);
1598 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1599 if ( myIsPointsVisible == theIsPointsVisible )
1601 myIsPointsVisible = theIsPointsVisible;
1602 SetRepresentation(GetRepresentation());
1605 bool SMESH_ActorDef::GetPointRepresentation(){
1606 return myIsPointsVisible || myIsPointsLabeled;
1610 void SMESH_ActorDef::UpdateHighlight(){
1611 myHighlitableActor->SetVisibility(false);
1612 myHighlitableActor->SetHighlited(false);
1614 if(myIsHighlighted){
1615 myHighlitableActor->SetProperty(myHighlightProp);
1616 }else if(myIsPreselected){
1617 myHighlitableActor->SetProperty(myPreselectProp);
1620 bool anIsVisible = GetVisibility();
1622 if(myIsHighlighted || myIsPreselected){
1623 if(GetUnstructuredGrid()->GetNumberOfCells()){
1624 myHighlitableActor->SetHighlited(anIsVisible);
1625 myHighlitableActor->SetVisibility(anIsVisible);
1626 myHighlitableActor->GetExtractUnstructuredGrid()->
1627 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1628 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1629 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1630 myHighlitableActor->SetHighlited(anIsVisible);
1631 myHighlitableActor->GetExtractUnstructuredGrid()->
1632 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1633 myHighlitableActor->SetVisibility(anIsVisible);
1634 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1636 VTK::MarkerType aMarkerType = GetMarkerType();
1637 if(aMarkerType != VTK::MT_USER)
1638 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1640 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1646 void SMESH_ActorDef::highlight(bool theHighlight){
1647 if ( myIsHighlighted == theHighlight )
1649 myIsHighlighted = theHighlight;
1654 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1655 if ( myIsPreselected == thePreselect )
1657 myIsPreselected = thePreselect;
1663 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1665 if (myPickableActor->GetIsOpaque())
1667 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1675 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1677 if (!myPickableActor->GetIsOpaque())
1679 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1687 void SMESH_ActorDef::Render(vtkRenderer *ren){
1688 unsigned long aTime = myTimeStamp->GetMTime();
1689 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1690 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1691 if(anObjTime > aTime || aClippingTime > aTime)
1696 void SMESH_ActorDef::Update(){
1697 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1699 if(GetControlMode() != eNone) {
1700 unsigned long aTime = myTimeStamp->GetMTime();
1701 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1702 if (anObjTime > aTime)
1703 SetControlMode(GetControlMode(),false);
1705 if(myIsPointsLabeled){
1706 SetPointsLabeled(myIsPointsLabeled);
1708 if(myIsCellsLabeled){
1709 SetCellsLabeled(myIsCellsLabeled);
1711 if(myIsFacesOriented){
1712 SetFacesOriented(myIsFacesOriented);
1714 SetEntityMode(GetEntityMode());
1715 SetVisibility(GetVisibility());
1717 myTimeStamp->Modified();
1722 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1723 SALOME_Actor::ReleaseGraphicsResources(renWin);
1725 myPickableActor->ReleaseGraphicsResources(renWin);
1729 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1730 vtkFloatingPointType* aColor = theProperty->GetColor();
1737 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1738 mySurfaceProp->SetOpacity(theValue);
1739 myBackSurfaceProp->SetOpacity(theValue);
1740 myEdgeProp->SetOpacity(theValue);
1741 myNodeProp->SetOpacity(theValue);
1743 my1DProp->SetOpacity(theValue);
1747 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1748 return mySurfaceProp->GetOpacity();
1752 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1753 mySurfaceProp->SetColor(r,g,b);
1754 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1755 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1756 aGroupObj->GetElementType() == SMDSAbs_Volume )
1757 myNameActor->SetBackgroundColor(r,g,b);
1761 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1762 ::GetColor(mySurfaceProp,r,g,b);
1763 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1766 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1767 myBackSurfaceProp->SetColor(r,g,b);
1771 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1772 ::GetColor(myBackSurfaceProp,r,g,b);
1775 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1776 myEdgeProp->SetColor(r,g,b);
1777 my1DProp->SetColor(r,g,b);
1778 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1779 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1780 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1781 myNameActor->SetBackgroundColor(r,g,b);
1785 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1786 ::GetColor(myEdgeProp,r,g,b);
1789 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1790 myNodeProp->SetColor(r,g,b);
1791 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1792 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1793 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1794 myNameActor->SetBackgroundColor(r,g,b);
1798 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1799 ::GetColor(myNodeProp,r,g,b);
1802 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1803 my0DProp->SetColor(r,g,b);
1804 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1805 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1806 myNameActor->SetBackgroundColor(r,g,b);
1810 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1811 ::GetColor(my0DProp,r,g,b);
1814 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1815 myHighlightProp->SetColor(r,g,b);
1819 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1820 ::GetColor(myHighlightProp,r,g,b);
1823 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1824 myPreselectProp->SetColor(r,g,b);
1828 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1829 ::GetColor(myPreselectProp,r,g,b);
1833 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1834 return myEdgeProp->GetLineWidth();
1838 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1839 myEdgeProp->SetLineWidth(theVal);
1841 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1842 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1848 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1849 my0DProp->SetPointSize(theVal);
1853 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1854 return my0DProp->GetPointSize();
1857 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1859 return myVisualObj->GetElemDimension( theObjId );
1864 IsImplicitFunctionUsed() const
1866 return myBaseActor->IsImplicitFunctionUsed();
1870 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1872 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1873 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1875 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1877 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1879 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1880 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1882 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1883 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1885 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1886 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1887 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1888 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1892 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1895 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1896 myCippingPlaneCont.push_back(thePlane);
1897 if(!IsImplicitFunctionUsed())
1898 SetImplicitFunctionUsed(true);
1900 return myCippingPlaneCont.size();
1905 RemoveAllClippingPlanes()
1907 myImplicitBoolean->GetFunction()->RemoveAllItems();
1908 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1909 myCippingPlaneCont.clear();
1910 SetImplicitFunctionUsed(false);
1915 GetNumberOfClippingPlanes()
1917 return myCippingPlaneCont.size();
1922 GetClippingPlane(vtkIdType theID)
1924 if(theID >= myCippingPlaneCont.size())
1926 return myCippingPlaneCont[theID].Get();
1929 void SMESH_ActorDef::UpdateScalarBar()
1931 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1935 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1937 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1938 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1940 aScalarBarTitleProp->SetFontFamilyToArial();
1942 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1944 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1945 if ( f.family() == "Arial" )
1946 aScalarBarTitleProp->SetFontFamilyToArial();
1947 else if ( f.family() == "Courier" )
1948 aScalarBarTitleProp->SetFontFamilyToCourier();
1949 else if ( f.family() == "Times" )
1950 aScalarBarTitleProp->SetFontFamilyToTimes();
1953 aScalarBarTitleProp->BoldOn();
1955 aScalarBarTitleProp->BoldOff();
1958 aScalarBarTitleProp->ItalicOn();
1960 aScalarBarTitleProp->ItalicOff();
1963 aScalarBarTitleProp->ShadowOn();
1965 aScalarBarTitleProp->ShadowOff();
1968 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1969 aScalarBarTitleProp->Delete();
1971 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1973 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1974 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1976 aScalarBarLabelProp->SetFontFamilyToArial();
1977 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1979 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1980 if( f.family() == "Arial" )
1981 aScalarBarLabelProp->SetFontFamilyToArial();
1982 else if( f.family() == "Courier" )
1983 aScalarBarLabelProp->SetFontFamilyToCourier();
1984 else if( f.family() == "Times" )
1985 aScalarBarLabelProp->SetFontFamilyToTimes();
1988 aScalarBarLabelProp->BoldOn();
1990 aScalarBarLabelProp->BoldOff();
1993 aScalarBarLabelProp->ItalicOn();
1995 aScalarBarLabelProp->ItalicOff();
1998 aScalarBarLabelProp->ShadowOn();
2000 aScalarBarLabelProp->ShadowOff();
2003 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2004 aScalarBarLabelProp->Delete();
2006 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2007 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2009 myScalarBarActor->SetOrientationToHorizontal();
2011 myScalarBarActor->SetOrientationToVertical();
2014 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2015 if( mgr->hasValue( "SMESH", name + "x" ) )
2016 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2018 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2019 if( mgr->hasValue( "SMESH", name + "y" ) )
2020 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2021 myScalarBarActor->SetPosition( aXVal, aYVal );
2023 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2024 if( mgr->hasValue( "SMESH", name + "width" ) )
2025 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2026 myScalarBarActor->SetWidth( aWVal );
2028 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2029 if( mgr->hasValue( "SMESH", name + "height" ) )
2030 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2031 myScalarBarActor->SetHeight( aHVal );
2034 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2035 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2036 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2039 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2040 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2041 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2043 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2044 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2046 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2047 myScalarBarActor->SetDistributionColoringType(coloringType);
2049 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2050 QColor(255, 255, 255));
2052 rgb[0]= distributionColor.red()/255.;
2053 rgb[1]= distributionColor.green()/255.;
2054 rgb[2]= distributionColor.blue()/255.;
2055 myScalarBarActor->SetDistributionColor(rgb);
2060 void SMESH_ActorDef::UpdateDistribution()
2062 if(SMESH::Controls::NumericalFunctor* fun =
2063 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2065 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2066 std::vector<int> nbEvents;
2067 std::vector<double> funValues;
2068 SMESH_VisualObjDef::TEntityList elems;
2069 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2070 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2071 std::vector<int> elemIds;
2072 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2073 elemIds.push_back( (*e)->GetID());
2074 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2075 double * range = lookupTable->GetRange();
2076 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2077 myScalarBarActor->SetDistribution(nbEvents);
2081 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2084 case SMESH_Actor::eLines :
2085 myHighlitableActor->SetQuadraticArcMode(false);
2086 my2DActor->SetQuadraticArcMode(false);
2087 my1DActor->SetQuadraticArcMode(false);
2089 case SMESH_Actor::eArcs :
2090 myHighlitableActor->SetQuadraticArcMode(true);
2091 if(GetRepresentation() != SMESH_Actor::ePoint) {
2092 my2DActor->SetQuadraticArcMode(true);
2093 my1DActor->SetQuadraticArcMode(true);
2102 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2104 if(myHighlitableActor->GetQuadraticArcMode())
2105 return SMESH_Actor::eArcs;
2107 return SMESH_Actor::eLines;
2110 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2112 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2113 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2114 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2117 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2119 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2120 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2121 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2122 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2125 #ifndef DISABLE_PLOT2DVIEWER
2126 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2129 my2dHistogram->clearAllPoints();
2131 if(SMESH::Controls::NumericalFunctor* fun =
2132 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2135 if(!my2dHistogram) {
2136 my2dHistogram = new SPlot2d_Histogram();
2137 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2138 my2dHistogram->setIO(anIO);
2141 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2142 std::vector<int> nbEvents;
2143 std::vector<double> funValues;
2144 SMESH_VisualObjDef::TEntityList elems;
2145 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2146 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2147 std::vector<int> elemIds;
2149 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2150 elemIds.push_back( (*e)->GetID());
2152 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2153 double * range = lookupTable->GetRange();
2154 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2156 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2157 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2159 if(funValues.size() >= 2)
2160 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2164 //Color of the histogram
2165 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2166 my2dHistogram->setAutoAssign(true);
2169 myScalarBarActor->GetDistributionColor(rgb);
2170 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2171 my2dHistogram->setColor(aColor);
2175 return my2dHistogram;