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 #include <vtkProperty.h>
44 #include <vtkTimeStamp.h>
45 #include <vtkObjectFactory.h>
46 #include <vtkShrinkPolyData.h>
47 #include <vtkMergeFilter.h>
49 #include <vtkMatrix4x4.h>
50 #include <vtkUnstructuredGrid.h>
51 #include <vtkPointData.h>
52 #include <vtkCellData.h>
54 #include <vtkMapper.h>
55 #include <vtkRenderer.h>
58 #include <vtkIdList.h>
59 #include <vtkIntArray.h>
61 #include <vtkActor2D.h>
62 #include <vtkProperty2D.h>
63 #include <vtkPolyData.h>
64 #include <vtkMaskPoints.h>
65 #include <vtkTextProperty.h>
66 #include <vtkLabeledDataMapper.h>
67 #include <vtkSelectVisiblePoints.h>
69 #include <vtkLookupTable.h>
73 #include <vtkImplicitBoolean.h>
74 #include <vtkImplicitFunctionCollection.h>
76 #include <vtkConfigure.h>
77 #if !defined(VTK_XVERSION)
78 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
81 #include "utilities.h"
84 static int MYDEBUG = 1;
86 static int MYDEBUG = 1;
89 static int aLineWidthInc = 2;
92 SMESH_ActorDef* SMESH_ActorDef::New(){
93 return new SMESH_ActorDef();
97 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
103 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
108 anActor->UpdateScalarBar();
113 SMESH_ActorDef::SMESH_ActorDef()
115 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
117 myTimeStamp = vtkTimeStamp::New();
119 myIsPointsVisible = false;
121 myIsShrinkable = false;
124 myIsFacesOriented = false;
126 myControlsPrecision = -1;
127 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
129 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
130 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
132 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
133 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
135 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
136 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
138 //Definition 2D and 3D devices of the actor
139 //-----------------------------------------
140 vtkFloatingPointType anRGB[3] = {1,1,1};
141 mySurfaceProp = vtkProperty::New();
142 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
143 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
145 myBackSurfaceProp = vtkProperty::New();
146 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
147 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
149 my2DActor = SMESH_DeviceActor::New();
150 my2DActor->SetUserMatrix(aMatrix);
151 my2DActor->PickableOff();
152 my2DActor->SetProperty(mySurfaceProp);
153 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
154 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
155 aFilter = my2DActor->GetExtractUnstructuredGrid();
156 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
157 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
158 aFilter->RegisterCellsWithType(VTK_POLYGON);
159 aFilter->RegisterCellsWithType(VTK_QUAD);
160 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
161 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
163 my2DExtProp = vtkProperty::New();
164 my2DExtProp->DeepCopy(mySurfaceProp);
165 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
166 anRGB[0] = 1 - anRGB[0];
167 anRGB[1] = 1 - anRGB[1];
168 anRGB[2] = 1 - anRGB[2];
169 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
171 my2DExtActor = SMESH_DeviceActor::New();
172 my2DExtActor->SetUserMatrix(aMatrix);
173 my2DExtActor->PickableOff();
174 my2DExtActor->SetProperty(my2DExtProp);
175 my2DExtActor->SetBackfaceProperty(my2DExtProp);
176 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
177 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
178 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
179 aFilter->RegisterCellsWithType(VTK_POLYGON);
180 aFilter->RegisterCellsWithType(VTK_QUAD);
181 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
182 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
184 my3DActor = SMESH_DeviceActor::New();
185 my3DActor->SetUserMatrix(aMatrix);
186 my3DActor->PickableOff();
187 my3DActor->SetProperty(mySurfaceProp);
188 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
189 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
190 aFilter = my3DActor->GetExtractUnstructuredGrid();
191 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
192 aFilter->RegisterCellsWithType(VTK_TETRA);
193 aFilter->RegisterCellsWithType(VTK_VOXEL);
194 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
195 aFilter->RegisterCellsWithType(VTK_WEDGE);
196 aFilter->RegisterCellsWithType(VTK_PYRAMID);
197 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
198 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
199 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
200 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
201 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
202 //#ifdef VTK_HAVE_POLYHEDRON
203 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
204 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
207 my3DExtActor = SMESH_DeviceActor::New();
208 my3DExtActor->SetUserMatrix(aMatrix);
209 my3DExtActor->PickableOff();
210 my3DExtActor->SetProperty(my2DExtProp);
211 my3DExtActor->SetBackfaceProperty(my2DExtProp);
212 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
213 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
214 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
215 aFilter->RegisterCellsWithType(VTK_TETRA);
216 aFilter->RegisterCellsWithType(VTK_VOXEL);
217 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
218 aFilter->RegisterCellsWithType(VTK_WEDGE);
219 aFilter->RegisterCellsWithType(VTK_PYRAMID);
220 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
221 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
222 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
223 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
224 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
226 //Definition 1D device of the actor
227 //---------------------------------
228 myEdgeProp = vtkProperty::New();
229 myEdgeProp->SetAmbient(1.0);
230 myEdgeProp->SetDiffuse(0.0);
231 myEdgeProp->SetSpecular(0.0);
232 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
233 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
234 myEdgeProp->SetLineWidth(aLineWidth);
236 my1DActor = SMESH_DeviceActor::New();
237 my1DActor->SetUserMatrix(aMatrix);
238 my1DActor->PickableOff();
239 my1DActor->SetHighlited(true);
240 my1DActor->SetProperty(myEdgeProp);
241 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
242 aFilter = my1DActor->GetExtractUnstructuredGrid();
243 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
244 aFilter->RegisterCellsWithType(VTK_LINE);
245 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
247 my1DProp = vtkProperty::New();
248 my1DProp->DeepCopy(myEdgeProp);
249 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
250 my1DProp->SetPointSize(aElem0DSize);
252 my1DExtProp = vtkProperty::New();
253 my1DExtProp->DeepCopy(myEdgeProp);
254 anRGB[0] = 1 - anRGB[0];
255 anRGB[1] = 1 - anRGB[1];
256 anRGB[2] = 1 - anRGB[2];
257 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
258 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
259 my1DExtProp->SetPointSize(aElem0DSize);
261 my1DExtActor = SMESH_DeviceActor::New();
262 my1DExtActor->SetUserMatrix(aMatrix);
263 my1DExtActor->PickableOff();
264 my1DExtActor->SetHighlited(true);
265 my1DExtActor->SetVisibility(false);
266 my1DExtActor->SetProperty(my1DExtProp);
267 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
268 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
269 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
270 aFilter->RegisterCellsWithType(VTK_LINE);
271 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
274 //Definition 0D device of the actor (0d elements)
275 //-----------------------------------------------
276 my0DProp = vtkProperty::New();
277 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
278 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
279 my0DProp->SetPointSize(aElem0DSize);
281 my0DActor = SMESH_DeviceActor::New();
282 my0DActor->SetUserMatrix(aMatrix);
283 my0DActor->SetStoreClippingMapping(true);
284 my0DActor->PickableOff();
285 my0DActor->SetVisibility(false);
286 my0DActor->SetProperty(my0DProp);
287 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
288 aFilter = my0DActor->GetExtractUnstructuredGrid();
289 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
290 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
291 aFilter->RegisterCellsWithType(VTK_VERTEX);
293 //my0DExtProp = vtkProperty::New();
294 //my0DExtProp->DeepCopy(my0DProp);
295 //anRGB[0] = 1 - anRGB[0];
296 //anRGB[1] = 1 - anRGB[1];
297 //anRGB[2] = 1 - anRGB[2];
298 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
299 //my0DExtProp->SetPointSize(aElem0DSize);
301 //my0DExtActor = SMESH_DeviceActor::New();
302 //my0DExtActor->SetUserMatrix(aMatrix);
303 //my0DExtActor->SetStoreClippingMapping(true);
304 //my0DExtActor->PickableOff();
305 //my0DExtActor->SetHighlited(true);
306 //my0DExtActor->SetVisibility(false);
307 //my0DExtActor->SetProperty(my0DExtProp);
308 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
309 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
310 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
311 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
312 //aFilter->RegisterCellsWithType(VTK_VERTEX);
315 //Definition 0D device of the actor (nodes)
316 //-----------------------------------------
317 myNodeProp = vtkProperty::New();
318 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
319 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
321 myNodeActor = SMESH_DeviceActor::New();
322 myNodeActor->SetUserMatrix(aMatrix);
323 myNodeActor->SetStoreClippingMapping(true);
324 myNodeActor->PickableOff();
325 myNodeActor->SetVisibility(false);
326 myNodeActor->SetProperty(myNodeProp);
327 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
328 aFilter = myNodeActor->GetExtractUnstructuredGrid();
329 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
331 myNodeExtProp = vtkProperty::New();
332 myNodeExtProp->DeepCopy(myNodeProp);
333 anRGB[0] = 1 - anRGB[0];
334 anRGB[1] = 1 - anRGB[1];
335 anRGB[2] = 1 - anRGB[2];
336 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
338 myNodeExtActor = SMESH_DeviceActor::New();
339 myNodeExtActor->SetUserMatrix(aMatrix);
340 myNodeExtActor->SetStoreClippingMapping(true);
341 myNodeExtActor->PickableOff();
342 myNodeExtActor->SetHighlited(true);
343 myNodeExtActor->SetVisibility(false);
344 myNodeExtActor->SetProperty(myNodeExtProp);
345 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
346 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
347 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
348 aFilter->RegisterCellsWithType(VTK_VERTEX);
350 //Definition of Pickable and Highlitable engines
351 //----------------------------------------------
353 myBaseActor = SMESH_DeviceActor::New();
354 myBaseActor->SetUserMatrix(aMatrix);
355 myBaseActor->SetStoreGemetryMapping(true);
356 myBaseActor->GetProperty()->SetOpacity(0.0);
358 myPickableActor = myBaseActor;
360 myHighlightProp = vtkProperty::New();
361 myHighlightProp->SetAmbient(1.0);
362 myHighlightProp->SetDiffuse(0.0);
363 myHighlightProp->SetSpecular(0.0);
364 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
365 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
366 myHighlightProp->SetPointSize(aElem0DSize); // ??
367 myHighlightProp->SetRepresentation(1);
369 myPreselectProp = vtkProperty::New();
370 myPreselectProp->SetAmbient(1.0);
371 myPreselectProp->SetDiffuse(0.0);
372 myPreselectProp->SetSpecular(0.0);
373 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
374 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
375 myPreselectProp->SetPointSize(aElem0DSize); // ??
376 myPreselectProp->SetRepresentation(1);
378 myHighlitableActor = SMESH_DeviceActor::New();
379 myHighlitableActor->SetUserMatrix(aMatrix);
380 myHighlitableActor->PickableOff();
381 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
388 myControlMode = eNone;
389 myControlActor = my2DActor;
391 //Definition of myScalarBarActor
392 //------------------------------
393 myLookupTable = vtkLookupTable::New();
394 //Fix for Bug PAL5195 - SMESH764:
395 //Controls - Aspect Ratio: incorrect colors of the best and worst values
396 myLookupTable->SetHueRange(0.667,0.0);
398 myScalarBarActor = SMESH_ScalarBarActor::New();
399 myScalarBarActor->SetVisibility(false);
400 myScalarBarActor->SetLookupTable(myLookupTable);
403 //Incorrect "Min value" in Scalar Bar in Mesh:
404 // myScalarBarActor->SetLabelFormat("%.4g");
405 // changes was commented because of regression bug IPAL 19981
407 mgr = SUIT_Session::session()->resourceMgr();
411 //Definition of points numbering pipeline
412 //---------------------------------------
413 myPointsNumDataSet = vtkUnstructuredGrid::New();
415 myPtsMaskPoints = vtkMaskPoints::New();
416 myPtsMaskPoints->SetInput(myPointsNumDataSet);
417 myPtsMaskPoints->SetOnRatio(1);
419 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
420 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
421 myPtsSelectVisiblePoints->SelectInvisibleOff();
422 myPtsSelectVisiblePoints->SetTolerance(0.1);
424 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
425 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
426 #if (VTK_XVERSION < 0x050200)
427 myPtsLabeledDataMapper->SetLabelFormat("%g");
429 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
431 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
432 aPtsTextProp->SetFontFamilyToTimes();
433 static int aPointsFontSize = 10;
434 aPtsTextProp->SetFontSize(aPointsFontSize);
435 aPtsTextProp->SetBold(1);
436 aPtsTextProp->SetItalic(0);
437 aPtsTextProp->SetShadow(0);
438 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
439 aPtsTextProp->Delete();
441 myEntityMode = eAllEntity;
443 myIsPointsLabeled = false;
445 myPointLabels = vtkActor2D::New();
446 myPointLabels->SetMapper(myPtsLabeledDataMapper);
447 myPointLabels->GetProperty()->SetColor(1,1,1);
448 myPointLabels->SetVisibility(myIsPointsLabeled);
451 //Definition of cells numbering pipeline
452 //---------------------------------------
453 myCellsNumDataSet = vtkUnstructuredGrid::New();
455 myCellCenters = VTKViewer_CellCenters::New();
456 myCellCenters->SetInput(myCellsNumDataSet);
458 myClsMaskPoints = vtkMaskPoints::New();
459 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
460 myClsMaskPoints->SetOnRatio(1);
462 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
463 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
464 myClsSelectVisiblePoints->SelectInvisibleOff();
465 myClsSelectVisiblePoints->SetTolerance(0.1);
467 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
468 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
469 #if (VTK_XVERSION < 0x050200)
470 myClsLabeledDataMapper->SetLabelFormat("%g");
472 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
474 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
475 aClsTextProp->SetFontFamilyToTimes();
476 static int aCellsFontSize = 12;
477 aClsTextProp->SetFontSize(aCellsFontSize);
478 aClsTextProp->SetBold(1);
479 aClsTextProp->SetItalic(0);
480 aClsTextProp->SetShadow(0);
481 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
482 aClsTextProp->Delete();
484 myIsCellsLabeled = false;
486 myCellsLabels = vtkActor2D::New();
487 myCellsLabels->SetMapper(myClsLabeledDataMapper);
488 myCellsLabels->GetProperty()->SetColor(0,1,0);
489 myCellsLabels->SetVisibility(myIsCellsLabeled);
492 myImplicitBoolean = vtkImplicitBoolean::New();
493 myImplicitBoolean->SetOperationTypeToIntersection();
497 //Quadratic 2D elements representation
498 //-----------------------------------------------------------------------------
499 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
500 if(aQuadratic2DMode == 0){
501 myHighlitableActor->SetQuadraticArcMode(false);
502 my2DActor->SetQuadraticArcMode(false);
503 my1DActor->SetQuadraticArcMode(false);
505 else if(aQuadratic2DMode == 1){
506 myHighlitableActor->SetQuadraticArcMode(true);
507 my2DActor->SetQuadraticArcMode(true);
508 my1DActor->SetQuadraticArcMode(true);
511 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
512 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
513 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
515 // Set colors of the name actor
516 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
517 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
518 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
519 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
523 SMESH_ActorDef::~SMESH_ActorDef()
525 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
527 // caught by SMESHGUI::ProcessEvents() static method
528 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
530 myScalarBarActor->Delete();
531 myLookupTable->Delete();
533 mySurfaceProp->Delete();
534 myBackSurfaceProp->Delete();
536 myEdgeProp->Delete();
537 myHighlightProp->Delete();
538 myPreselectProp->Delete();
540 myNodeProp->Delete();
541 myNodeExtProp->Delete();
546 //my0DExtProp->Delete();
547 //my0DExtActor->Delete();
552 my1DExtProp->Delete();
553 my1DExtActor->Delete();
556 my2DExtProp->Delete();
557 my2DExtActor->Delete();
559 my3DExtActor->Delete();
561 myNodeActor->Delete();
562 myBaseActor->Delete();
564 myNodeExtActor->Delete();
566 myHighlitableActor->Delete();
568 //Deleting of points numbering pipeline
569 //---------------------------------------
570 myPointsNumDataSet->Delete();
572 // commented: porting to vtk 5.0
573 // myPtsLabeledDataMapper->RemoveAllInputs();
574 myPtsLabeledDataMapper->Delete();
576 // commented: porting to vtk 5.0
577 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
578 myPtsSelectVisiblePoints->Delete();
580 // commented: porting to vtk 5.0
581 // myPtsMaskPoints->UnRegisterAllOutputs();
582 myPtsMaskPoints->Delete();
584 myPointLabels->Delete();
587 //Deleting of cells numbering pipeline
588 //---------------------------------------
589 myCellsNumDataSet->Delete();
591 myClsLabeledDataMapper->RemoveAllInputs();
592 myClsLabeledDataMapper->Delete();
594 // commented: porting to vtk 5.0
595 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
596 myClsSelectVisiblePoints->Delete();
598 // commented: porting to vtk 5.0
599 // myClsMaskPoints->UnRegisterAllOutputs();
600 myClsMaskPoints->Delete();
602 // commented: porting to vtk 5.0
603 // myCellCenters->UnRegisterAllOutputs();
604 myCellCenters->Delete();
606 myCellsLabels->Delete();
608 myImplicitBoolean->Delete();
610 myTimeStamp->Delete();
614 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
616 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
618 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
620 if ( myIsPointsLabeled )
622 myPointsNumDataSet->ShallowCopy(aGrid);
623 vtkDataSet *aDataSet = myPointsNumDataSet;
625 int aNbElem = aDataSet->GetNumberOfPoints();
627 vtkIntArray *anArray = vtkIntArray::New();
628 anArray->SetNumberOfValues( aNbElem );
630 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
632 int aSMDSId = myVisualObj->GetNodeObjId( anId );
633 anArray->SetValue( anId, aSMDSId );
636 aDataSet->GetPointData()->SetScalars( anArray );
638 myPtsMaskPoints->SetInput( aDataSet );
639 myPointLabels->SetVisibility( GetVisibility() );
643 myPointLabels->SetVisibility( false );
645 SetRepresentation(GetRepresentation());
646 myTimeStamp->Modified();
650 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
652 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
653 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
654 if(myIsCellsLabeled){
655 myCellsNumDataSet->ShallowCopy(aGrid);
656 vtkDataSet *aDataSet = myCellsNumDataSet;
657 int aNbElem = aDataSet->GetNumberOfCells();
658 vtkIntArray *anArray = vtkIntArray::New();
659 anArray->SetNumberOfValues(aNbElem);
660 for(int anId = 0; anId < aNbElem; anId++){
661 int aSMDSId = myVisualObj->GetElemObjId(anId);
662 anArray->SetValue(anId,aSMDSId);
664 aDataSet->GetCellData()->SetScalars(anArray);
665 myCellCenters->SetInput(aDataSet);
666 myCellsLabels->SetVisibility(GetVisibility());
668 myCellsLabels->SetVisibility(false);
670 myTimeStamp->Modified();
674 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
676 myIsFacesOriented = theIsFacesOriented;
678 my2DActor->SetFacesOriented(theIsFacesOriented);
679 my3DActor->SetFacesOriented(theIsFacesOriented);
681 myTimeStamp->Modified();
684 bool SMESH_ActorDef::GetFacesOriented()
686 return myIsFacesOriented;
689 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
691 my2DActor->SetFacesOrientationColor( theColor );
692 my3DActor->SetFacesOrientationColor( theColor );
695 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
697 my3DActor->GetFacesOrientationColor( theColor );
700 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
702 my2DActor->SetFacesOrientationScale( theScale );
703 my3DActor->SetFacesOrientationScale( theScale );
706 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
708 return my3DActor->GetFacesOrientationScale();
711 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
713 my2DActor->SetFacesOrientation3DVectors( theState );
714 my3DActor->SetFacesOrientation3DVectors( theState );
717 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
719 return my3DActor->GetFacesOrientation3DVectors();
725 SetControlMode(eControl theMode)
727 SetControlMode(theMode,true);
733 SetControlMode(eControl theMode,
734 bool theCheckEntityMode)
736 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
740 myControlMode = eNone;
741 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
743 my0DActor->GetMapper()->SetScalarVisibility(false);
744 my1DActor->GetMapper()->SetScalarVisibility(false);
745 my2DActor->GetMapper()->SetScalarVisibility(false);
746 my3DActor->GetMapper()->SetScalarVisibility(false);
747 myScalarBarActor->SetVisibility(false);
749 bool anIsScalarVisible = theMode > eNone;
751 if(anIsScalarVisible) {
755 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
756 aControl->SetPrecision( myControlsPrecision );
757 myFunctor.reset( aControl );
758 myControlActor = my1DActor;
763 myFunctor.reset(new SMESH::Controls::Length2D());
764 myControlActor = my2DActor;
768 myFunctor.reset(new SMESH::Controls::FreeBorders());
769 myControlActor = my1DActor;
772 myFunctor.reset(new SMESH::Controls::FreeEdges());
773 myControlActor = my2DActor;
776 myFunctor.reset(new SMESH::Controls::FreeNodes());
777 myControlActor = myNodeActor;
780 myFunctor.reset(new SMESH::Controls::FreeFaces());
781 myControlActor = my2DActor;
783 case eBareBorderFace:
784 myFunctor.reset(new SMESH::Controls::BareBorderFace());
785 myControlActor = my2DActor;
787 case eOverConstrainedFace:
788 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
789 myControlActor = my2DActor;
791 case eMultiConnection:
792 myFunctor.reset(new SMESH::Controls::MultiConnection());
793 myControlActor = my1DActor;
795 case eMultiConnection2D:
796 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
797 myControlActor = my2DActor;
801 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
802 aControl->SetPrecision( myControlsPrecision );
803 myFunctor.reset( aControl );
804 myControlActor = my2DActor;
809 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
810 aControl->SetPrecision( myControlsPrecision );
811 myFunctor.reset( aControl );
812 myControlActor = my2DActor;
817 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
818 aControl->SetPrecision( myControlsPrecision );
819 myFunctor.reset( aControl );
820 myControlActor = my2DActor;
825 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
826 aControl->SetPrecision( myControlsPrecision );
827 myFunctor.reset( aControl );
828 myControlActor = my3DActor;
833 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
834 aControl->SetPrecision( myControlsPrecision );
835 myFunctor.reset( aControl );
836 myControlActor = my3DActor;
839 case eMaxElementLength2D:
841 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
842 aControl->SetPrecision( myControlsPrecision );
843 myFunctor.reset( aControl );
844 myControlActor = my2DActor;
847 case eMaxElementLength3D:
849 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
850 aControl->SetPrecision( myControlsPrecision );
851 myFunctor.reset( aControl );
852 myControlActor = my3DActor;
855 case eBareBorderVolume:
857 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
858 myControlActor = my3DActor;
861 case eOverConstrainedVolume:
863 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
864 myControlActor = my3DActor;
869 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
870 aControl->SetPrecision( myControlsPrecision );
871 myFunctor.reset( aControl );
872 myControlActor = my2DActor;
877 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
878 aControl->SetPrecision( myControlsPrecision );
879 myFunctor.reset( aControl );
880 myControlActor = my2DActor;
885 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
886 aControl->SetPrecision( myControlsPrecision );
887 myFunctor.reset( aControl );
888 myControlActor = my2DActor;
895 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
896 vtkIdType aNbCells = aGrid->GetNumberOfCells();
898 myControlMode = theMode;
899 switch(myControlMode){
901 myNodeExtActor->SetExtControlMode(myFunctor);
905 my1DExtActor->SetExtControlMode(myFunctor);
908 case eBareBorderFace:
909 case eOverConstrainedFace:
910 my2DExtActor->SetExtControlMode(myFunctor);
912 case eBareBorderVolume:
913 case eOverConstrainedVolume:
914 my3DExtActor->SetExtControlMode(myFunctor);
917 case eMultiConnection2D:
918 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
919 UpdateDistribution();
922 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
923 UpdateDistribution();
927 if(theCheckEntityMode){
928 if(myControlActor == my1DActor)
929 SetEntityMode(eEdges);
930 else if(myControlActor == my2DActor){
931 switch(myControlMode){
935 case eMultiConnection2D:
936 //SetEntityMode(eEdges);
937 SetEntityMode(eFaces);
940 SetEntityMode(eFaces);
942 }else if(myControlActor == my3DActor)
943 SetEntityMode(eVolumes);
948 if(theCheckEntityMode)
949 myEntityMode = eAllEntity;
953 SetRepresentation(GetRepresentation());
955 myTimeStamp->Modified();
960 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
961 theRenderer->AddActor(myNodeActor);
962 theRenderer->AddActor(myBaseActor);
964 theRenderer->AddActor(myNodeExtActor);
966 my3DActor->AddToRender(theRenderer);
967 my3DExtActor->AddToRender(theRenderer);
968 my2DActor->AddToRender(theRenderer);
969 my2DExtActor->AddToRender(theRenderer);
971 theRenderer->AddActor(my1DActor);
972 theRenderer->AddActor(my1DExtActor);
974 theRenderer->AddActor(my0DActor);
975 //theRenderer->AddActor(my0DExtActor);
977 theRenderer->AddActor(myHighlitableActor);
979 theRenderer->AddActor2D(myScalarBarActor);
981 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
982 myClsSelectVisiblePoints->SetRenderer(theRenderer);
984 theRenderer->AddActor2D(myPointLabels);
985 theRenderer->AddActor2D(myCellsLabels);
987 // the superclass' method should be called at the end
988 // (in particular, for correct work of selection)
989 SALOME_Actor::AddToRender(theRenderer);
992 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
993 SALOME_Actor::RemoveFromRender(theRenderer);
995 theRenderer->RemoveActor(myNodeActor);
996 theRenderer->RemoveActor(myBaseActor);
998 theRenderer->RemoveActor(myNodeExtActor);
1000 theRenderer->RemoveActor(myHighlitableActor);
1002 theRenderer->RemoveActor(my0DActor);
1003 //theRenderer->RemoveActor(my0DExtActor);
1005 theRenderer->RemoveActor(my1DActor);
1006 theRenderer->RemoveActor(my1DExtActor);
1008 my2DActor->RemoveFromRender(theRenderer);
1009 my2DExtActor->RemoveFromRender(theRenderer);
1010 my3DActor->RemoveFromRender(theRenderer);
1011 my3DExtActor->RemoveFromRender(theRenderer);
1013 theRenderer->RemoveActor(myScalarBarActor);
1014 theRenderer->RemoveActor(myPointLabels);
1015 theRenderer->RemoveActor(myCellsLabels);
1019 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1020 const char* theEntry,
1021 const char* theName,
1024 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1028 myVisualObj = theVisualObj;
1029 myVisualObj->Update(theIsClear);
1031 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1032 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1034 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1036 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1038 my0DActor->Init(myVisualObj,myImplicitBoolean);
1039 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1041 my1DActor->Init(myVisualObj,myImplicitBoolean);
1042 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1044 my2DActor->Init(myVisualObj,myImplicitBoolean);
1045 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1046 my3DActor->Init(myVisualObj,myImplicitBoolean);
1047 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1049 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1050 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1052 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1053 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1055 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1056 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1057 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1058 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1060 vtkFloatingPointType aFactor, aUnits;
1061 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1062 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1063 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1065 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1069 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1070 SetIsShrunkable(true);
1072 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1074 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1075 SetRepresentation(-1);
1078 SetRepresentation(eEdge);
1079 }else if(aMode == 1){
1080 SetRepresentation(eSurface);
1081 }else if(aMode == 2){
1082 SetRepresentation(ePoint);
1089 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1090 SetIsDisplayNameActor( true );
1092 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1093 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1094 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1096 myTimeStamp->Modified();
1102 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1103 return myNodeActor->GetBounds();
1107 vtkDataSet* SMESH_ActorDef::GetInput(){
1108 return GetUnstructuredGrid();
1112 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1113 Superclass::SetTransform(theTransform);
1115 myNodeActor->SetTransform(theTransform);
1116 myBaseActor->SetTransform(theTransform);
1118 myHighlitableActor->SetTransform(theTransform);
1120 myNodeExtActor->SetTransform(theTransform);
1122 my0DActor->SetTransform(theTransform);
1123 //my0DExtActor->SetTransform(theTransform);
1125 my1DActor->SetTransform(theTransform);
1126 my1DExtActor->SetTransform(theTransform);
1128 my2DActor->SetTransform(theTransform);
1129 my2DExtActor->SetTransform(theTransform);
1130 my3DActor->SetTransform(theTransform);
1131 my3DExtActor->SetTransform(theTransform);
1137 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1138 vtkLODActor::SetMapper(theMapper);
1142 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1143 SALOME_Actor::ShallowCopy(prop);
1147 vtkMapper* SMESH_ActorDef::GetMapper(){
1148 return myPickableActor->GetMapper();
1152 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1153 return myVisualObj->GetUnstructuredGrid();
1157 bool SMESH_ActorDef::IsInfinitive(){
1158 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1160 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1161 ( aDataSet->GetNumberOfCells() == 1 &&
1162 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1163 return SALOME_Actor::IsInfinitive();
1167 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1168 if ( myIsShrinkable == theShrunkable )
1170 myIsShrinkable = theShrunkable;
1174 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1175 return myBaseActor->GetShrinkFactor();
1178 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1179 myBaseActor->SetShrinkFactor(theValue);
1181 my1DActor->SetShrinkFactor(theValue);
1182 my1DExtActor->SetShrinkFactor(theValue);
1184 my2DActor->SetShrinkFactor(theValue);
1185 my2DExtActor->SetShrinkFactor(theValue);
1186 my3DActor->SetShrinkFactor(theValue);
1187 my3DExtActor->SetShrinkFactor(theValue);
1192 void SMESH_ActorDef::SetShrink(){
1193 if(!myIsShrinkable) return;
1195 myBaseActor->SetShrink();
1197 my1DActor->SetShrink();
1198 my1DExtActor->SetShrink();
1200 my2DActor->SetShrink();
1201 my2DExtActor->SetShrink();
1202 my3DActor->SetShrink();
1203 my3DExtActor->SetShrink();
1209 void SMESH_ActorDef::UnShrink(){
1210 if(!myIsShrunk) return;
1212 myBaseActor->UnShrink();
1214 my1DActor->UnShrink();
1215 my1DExtActor->UnShrink();
1217 my2DActor->UnShrink();
1218 my2DExtActor->UnShrink();
1219 my3DActor->UnShrink();
1220 my3DExtActor->UnShrink();
1227 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1228 return myPickableActor->GetNodeObjId(theVtkID);
1231 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1232 return myPickableActor->GetNodeCoord(theObjID);
1236 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1237 return myPickableActor->GetElemObjId(theVtkID);
1240 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1241 return myPickableActor->GetElemCell(theObjID);
1245 void SMESH_ActorDef::SetVisibility(int theMode){
1246 SetVisibility(theMode,true);
1250 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1251 SALOME_Actor::SetVisibility(theMode);
1253 myNodeActor->VisibilityOff();
1254 myBaseActor->VisibilityOff();
1256 myNodeExtActor->VisibilityOff();
1258 my0DActor->VisibilityOff();
1259 //my0DExtActor->VisibilityOff();
1261 my1DActor->VisibilityOff();
1262 my1DExtActor->VisibilityOff();
1264 my2DActor->VisibilityOff();
1265 my2DExtActor->VisibilityOff();
1266 my3DActor->VisibilityOff();
1267 my3DExtActor->VisibilityOff();
1269 myScalarBarActor->VisibilityOff();
1270 myPointLabels->VisibilityOff();
1271 myCellsLabels->VisibilityOff();
1273 if(GetVisibility()){
1274 if(theIsUpdateRepersentation)
1275 SetRepresentation(GetRepresentation());
1277 if(myControlMode != eNone){
1278 switch(myControlMode){
1280 myNodeExtActor->VisibilityOn();
1284 my1DExtActor->VisibilityOn();
1287 case eBareBorderFace:
1288 case eOverConstrainedFace:
1289 my2DExtActor->VisibilityOn();
1291 case eBareBorderVolume:
1292 case eOverConstrainedVolume:
1293 my3DExtActor->VisibilityOn();
1296 case eMultiConnection2D:
1297 my1DExtActor->VisibilityOn();
1299 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1300 myScalarBarActor->VisibilityOn();
1304 if(myRepresentation != ePoint)
1305 myPickableActor->VisibilityOn();
1307 myNodeActor->VisibilityOn();
1310 if(myEntityMode & e0DElements){
1311 my0DActor->VisibilityOn();
1314 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1315 my1DActor->VisibilityOn();
1318 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1319 my2DActor->VisibilityOn();
1322 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1323 my3DActor->VisibilityOn();
1326 if(myIsPointsLabeled){
1327 myPointLabels->VisibilityOn();
1328 myNodeActor->VisibilityOn();
1331 if(myIsCellsLabeled)
1332 myCellsLabels->VisibilityOn();
1339 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1341 myEntityState = eAllEntity;
1343 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1344 myEntityState &= ~e0DElements;
1345 theMode &= ~e0DElements;
1348 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1349 myEntityState &= ~eEdges;
1353 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1354 myEntityState &= ~eFaces;
1358 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1359 myEntityState &= ~eVolumes;
1360 theMode &= ~eVolumes;
1364 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1365 theMode |= e0DElements;
1367 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1370 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1373 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1374 theMode |= eVolumes;
1377 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1379 myEntityMode = theMode;
1380 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1381 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1382 aFilter->ClearRegisteredCellsWithType();
1383 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1385 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1386 aHightFilter->ClearRegisteredCellsWithType();
1387 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1389 if (myEntityMode & e0DElements) {
1390 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1391 aFilter->RegisterCellsWithType(VTK_VERTEX);
1392 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1395 if (myEntityMode & eEdges) {
1396 if (MYDEBUG) MESSAGE("EDGES");
1397 aFilter->RegisterCellsWithType(VTK_LINE);
1398 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1400 aHightFilter->RegisterCellsWithType(VTK_LINE);
1401 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1404 if (myEntityMode & eFaces) {
1405 if (MYDEBUG) MESSAGE("FACES");
1406 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1407 aFilter->RegisterCellsWithType(VTK_POLYGON);
1408 aFilter->RegisterCellsWithType(VTK_QUAD);
1409 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1410 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1412 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1413 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1414 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1415 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1416 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1419 if (myEntityMode & eVolumes) {
1420 if (MYDEBUG) MESSAGE("VOLUMES");
1421 aFilter->RegisterCellsWithType(VTK_TETRA);
1422 aFilter->RegisterCellsWithType(VTK_VOXEL);
1423 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1424 aFilter->RegisterCellsWithType(VTK_WEDGE);
1425 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1426 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1427 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1428 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1429 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1430 //#ifdef VTK_HAVE_POLYHEDRON
1431 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1434 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1435 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1436 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1437 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1438 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1439 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1440 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1441 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1442 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1443 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1444 //#ifdef VTK_HAVE_POLYHEDRON
1445 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1449 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1450 SetVisibility(GetVisibility(),false);
1453 void SMESH_ActorDef::SetRepresentation (int theMode)
1455 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1456 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1457 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1460 myRepresentation = eSurface;
1461 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1462 myRepresentation = eEdge;
1463 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1464 myRepresentation = ePoint;
1469 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1472 if (!aNbFaces && !aNbVolumes) return;
1475 myRepresentation = theMode;
1478 if (!GetUnstructuredGrid()->GetNumberOfCells())
1479 myRepresentation = ePoint;
1482 if (myRepresentation == ePoint) {
1490 myPickableActor = myBaseActor;
1491 myNodeActor->SetVisibility(false);
1492 myNodeExtActor->SetVisibility(false);
1493 vtkProperty *aProp = NULL, *aBackProp = NULL;
1494 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1495 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1496 switch (myRepresentation) {
1498 myPickableActor = myNodeActor;
1499 myNodeActor->SetVisibility(true);
1500 aQuadraticMode = SMESH_Actor::eLines;
1501 aProp = aBackProp = myNodeProp;
1502 aReperesent = SMESH_DeviceActor::ePoint;
1505 aProp = aBackProp = myEdgeProp;
1506 aReperesent = SMESH_DeviceActor::eInsideframe;
1509 aProp = mySurfaceProp;
1510 aBackProp = myBackSurfaceProp;
1511 aReperesent = SMESH_DeviceActor::eSurface;
1515 my2DActor->SetProperty(aProp);
1516 my2DActor->SetBackfaceProperty(aBackProp);
1517 my2DActor->SetRepresentation(aReperesent);
1519 if(aQuadraticMode == SMESH_Actor::eLines)
1520 my2DActor->SetQuadraticArcMode(false);
1521 else if(aQuadraticMode == SMESH_Actor::eArcs)
1522 my2DActor->SetQuadraticArcMode(true);
1524 my2DExtActor->SetRepresentation(aReperesent);
1526 my3DActor->SetProperty(aProp);
1527 my3DActor->SetBackfaceProperty(aBackProp);
1528 my3DActor->SetRepresentation(aReperesent);
1530 //my0DExtActor->SetVisibility(false);
1531 my1DExtActor->SetVisibility(false);
1532 my2DExtActor->SetVisibility(false);
1533 my3DExtActor->SetVisibility(false);
1536 //my0DActor->SetProperty(aProp);
1537 //my0DActor->SetBackfaceProperty(aBackProp);
1538 my0DActor->SetRepresentation(aReperesent);
1539 //my0DExtActor->SetRepresentation(aReperesent);
1541 switch(myControlMode){
1543 case eMultiConnection:
1544 aProp = aBackProp = my1DProp;
1545 if(myRepresentation != ePoint)
1546 aReperesent = SMESH_DeviceActor::eInsideframe;
1550 if(aQuadraticMode == SMESH_Actor::eLines)
1551 my1DActor->SetQuadraticArcMode(false);
1552 else if(aQuadraticMode == SMESH_Actor::eArcs)
1553 my1DActor->SetQuadraticArcMode(true);
1555 my1DActor->SetProperty(aProp);
1556 my1DActor->SetBackfaceProperty(aBackProp);
1557 my1DActor->SetRepresentation(aReperesent);
1559 my1DExtActor->SetRepresentation(aReperesent);
1561 if(myIsPointsVisible)
1562 myPickableActor = myNodeActor;
1563 if(GetPointRepresentation())
1564 myNodeActor->SetVisibility(true);
1566 SetMapper(myPickableActor->GetMapper());
1568 SetVisibility(GetVisibility(),false);
1574 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1575 if ( myIsPointsVisible == theIsPointsVisible )
1577 myIsPointsVisible = theIsPointsVisible;
1578 SetRepresentation(GetRepresentation());
1581 bool SMESH_ActorDef::GetPointRepresentation(){
1582 return myIsPointsVisible || myIsPointsLabeled;
1586 void SMESH_ActorDef::UpdateHighlight(){
1587 myHighlitableActor->SetVisibility(false);
1588 myHighlitableActor->SetHighlited(false);
1590 if(myIsHighlighted){
1591 myHighlitableActor->SetProperty(myHighlightProp);
1592 }else if(myIsPreselected){
1593 myHighlitableActor->SetProperty(myPreselectProp);
1596 bool anIsVisible = GetVisibility();
1598 if(myIsHighlighted || myIsPreselected){
1599 if(GetUnstructuredGrid()->GetNumberOfCells()){
1600 myHighlitableActor->SetHighlited(anIsVisible);
1601 myHighlitableActor->SetVisibility(anIsVisible);
1602 myHighlitableActor->GetExtractUnstructuredGrid()->
1603 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1604 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1605 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1606 myHighlitableActor->SetHighlited(anIsVisible);
1607 myHighlitableActor->GetExtractUnstructuredGrid()->
1608 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1609 myHighlitableActor->SetVisibility(anIsVisible);
1610 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1612 VTK::MarkerType aMarkerType = GetMarkerType();
1613 if(aMarkerType != VTK::MT_USER)
1614 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1616 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1622 void SMESH_ActorDef::highlight(bool theHighlight){
1623 if ( myIsHighlighted == theHighlight )
1625 myIsHighlighted = theHighlight;
1630 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1631 if ( myIsPreselected == thePreselect )
1633 myIsPreselected = thePreselect;
1639 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1641 if (myPickableActor->GetIsOpaque())
1643 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1651 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1653 if (!myPickableActor->GetIsOpaque())
1655 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1663 void SMESH_ActorDef::Render(vtkRenderer *ren){
1664 unsigned long aTime = myTimeStamp->GetMTime();
1665 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1666 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1667 if(anObjTime > aTime || aClippingTime > aTime)
1672 void SMESH_ActorDef::Update(){
1673 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1675 if(GetControlMode() != eNone) {
1676 unsigned long aTime = myTimeStamp->GetMTime();
1677 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1678 if (anObjTime > aTime)
1679 SetControlMode(GetControlMode(),false);
1681 if(myIsPointsLabeled){
1682 SetPointsLabeled(myIsPointsLabeled);
1684 if(myIsCellsLabeled){
1685 SetCellsLabeled(myIsCellsLabeled);
1687 if(myIsFacesOriented){
1688 SetFacesOriented(myIsFacesOriented);
1690 SetEntityMode(GetEntityMode());
1691 SetVisibility(GetVisibility());
1693 myTimeStamp->Modified();
1698 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1699 SALOME_Actor::ReleaseGraphicsResources(renWin);
1701 myPickableActor->ReleaseGraphicsResources(renWin);
1705 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1706 vtkFloatingPointType* aColor = theProperty->GetColor();
1713 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1714 mySurfaceProp->SetOpacity(theValue);
1715 myBackSurfaceProp->SetOpacity(theValue);
1716 myEdgeProp->SetOpacity(theValue);
1717 myNodeProp->SetOpacity(theValue);
1719 my1DProp->SetOpacity(theValue);
1723 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1724 return mySurfaceProp->GetOpacity();
1728 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1729 mySurfaceProp->SetColor(r,g,b);
1730 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1731 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1732 aGroupObj->GetElementType() == SMDSAbs_Volume )
1733 myNameActor->SetBackgroundColor(r,g,b);
1737 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1738 ::GetColor(mySurfaceProp,r,g,b);
1739 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1742 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1743 myBackSurfaceProp->SetColor(r,g,b);
1747 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1748 ::GetColor(myBackSurfaceProp,r,g,b);
1751 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1752 myEdgeProp->SetColor(r,g,b);
1753 my1DProp->SetColor(r,g,b);
1754 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1755 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1756 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1757 myNameActor->SetBackgroundColor(r,g,b);
1761 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1762 ::GetColor(myEdgeProp,r,g,b);
1765 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1766 myNodeProp->SetColor(r,g,b);
1767 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1768 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1769 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1770 myNameActor->SetBackgroundColor(r,g,b);
1774 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1775 ::GetColor(myNodeProp,r,g,b);
1778 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1779 my0DProp->SetColor(r,g,b);
1780 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1781 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1782 myNameActor->SetBackgroundColor(r,g,b);
1786 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1787 ::GetColor(my0DProp,r,g,b);
1790 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1791 myHighlightProp->SetColor(r,g,b);
1795 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1796 ::GetColor(myHighlightProp,r,g,b);
1799 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1800 myPreselectProp->SetColor(r,g,b);
1804 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1805 ::GetColor(myPreselectProp,r,g,b);
1809 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1810 return myEdgeProp->GetLineWidth();
1814 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1815 myEdgeProp->SetLineWidth(theVal);
1817 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1818 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1824 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1825 my0DProp->SetPointSize(theVal);
1829 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1830 return my0DProp->GetPointSize();
1833 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1835 return myVisualObj->GetElemDimension( theObjId );
1840 IsImplicitFunctionUsed() const
1842 return myBaseActor->IsImplicitFunctionUsed();
1846 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1848 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1849 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1851 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1853 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1855 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1856 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1858 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1859 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1861 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1862 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1863 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1864 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1868 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1871 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1872 myCippingPlaneCont.push_back(thePlane);
1873 if(!IsImplicitFunctionUsed())
1874 SetImplicitFunctionUsed(true);
1876 return myCippingPlaneCont.size();
1881 RemoveAllClippingPlanes()
1883 myImplicitBoolean->GetFunction()->RemoveAllItems();
1884 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1885 myCippingPlaneCont.clear();
1886 SetImplicitFunctionUsed(false);
1891 GetNumberOfClippingPlanes()
1893 return myCippingPlaneCont.size();
1898 GetClippingPlane(vtkIdType theID)
1900 if(theID >= myCippingPlaneCont.size())
1902 return myCippingPlaneCont[theID].Get();
1905 void SMESH_ActorDef::UpdateScalarBar()
1907 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1911 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1913 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1914 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1916 aScalarBarTitleProp->SetFontFamilyToArial();
1918 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1920 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1921 if ( f.family() == "Arial" )
1922 aScalarBarTitleProp->SetFontFamilyToArial();
1923 else if ( f.family() == "Courier" )
1924 aScalarBarTitleProp->SetFontFamilyToCourier();
1925 else if ( f.family() == "Times" )
1926 aScalarBarTitleProp->SetFontFamilyToTimes();
1929 aScalarBarTitleProp->BoldOn();
1931 aScalarBarTitleProp->BoldOff();
1934 aScalarBarTitleProp->ItalicOn();
1936 aScalarBarTitleProp->ItalicOff();
1939 aScalarBarTitleProp->ShadowOn();
1941 aScalarBarTitleProp->ShadowOff();
1944 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1945 aScalarBarTitleProp->Delete();
1947 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1949 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1950 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1952 aScalarBarLabelProp->SetFontFamilyToArial();
1953 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1955 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1956 if( f.family() == "Arial" )
1957 aScalarBarLabelProp->SetFontFamilyToArial();
1958 else if( f.family() == "Courier" )
1959 aScalarBarLabelProp->SetFontFamilyToCourier();
1960 else if( f.family() == "Times" )
1961 aScalarBarLabelProp->SetFontFamilyToTimes();
1964 aScalarBarLabelProp->BoldOn();
1966 aScalarBarLabelProp->BoldOff();
1969 aScalarBarLabelProp->ItalicOn();
1971 aScalarBarLabelProp->ItalicOff();
1974 aScalarBarLabelProp->ShadowOn();
1976 aScalarBarLabelProp->ShadowOff();
1979 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1980 aScalarBarLabelProp->Delete();
1982 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1983 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1985 myScalarBarActor->SetOrientationToHorizontal();
1987 myScalarBarActor->SetOrientationToVertical();
1990 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1991 if( mgr->hasValue( "SMESH", name + "x" ) )
1992 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1994 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1995 if( mgr->hasValue( "SMESH", name + "y" ) )
1996 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1997 myScalarBarActor->SetPosition( aXVal, aYVal );
1999 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2000 if( mgr->hasValue( "SMESH", name + "width" ) )
2001 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2002 myScalarBarActor->SetWidth( aWVal );
2004 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2005 if( mgr->hasValue( "SMESH", name + "height" ) )
2006 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2007 myScalarBarActor->SetHeight( aHVal );
2010 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2011 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2012 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2015 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2016 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2017 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2019 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2020 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2022 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2023 myScalarBarActor->SetDistributionColoringType(coloringType);
2025 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2026 QColor(255, 255, 255));
2028 rgb[0]= distributionColor.red()/255.;
2029 rgb[1]= distributionColor.green()/255.;
2030 rgb[2]= distributionColor.blue()/255.;
2031 myScalarBarActor->SetDistributionColor(rgb);
2036 void SMESH_ActorDef::UpdateDistribution()
2038 if(SMESH::Controls::NumericalFunctor* fun =
2039 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2041 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2042 std::vector<int> nbEvents;
2043 std::vector<double> funValues;
2044 SMESH_VisualObjDef::TEntityList elems;
2045 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2046 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2047 std::vector<int> elemIds;
2048 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2049 elemIds.push_back( (*e)->GetID());
2050 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2051 double * range = lookupTable->GetRange();
2052 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2053 myScalarBarActor->SetDistribution(nbEvents);
2057 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2060 case SMESH_Actor::eLines :
2061 myHighlitableActor->SetQuadraticArcMode(false);
2062 my2DActor->SetQuadraticArcMode(false);
2063 my1DActor->SetQuadraticArcMode(false);
2065 case SMESH_Actor::eArcs :
2066 myHighlitableActor->SetQuadraticArcMode(true);
2067 if(GetRepresentation() != SMESH_Actor::ePoint) {
2068 my2DActor->SetQuadraticArcMode(true);
2069 my1DActor->SetQuadraticArcMode(true);
2078 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2080 if(myHighlitableActor->GetQuadraticArcMode())
2081 return SMESH_Actor::eArcs;
2083 return SMESH_Actor::eLines;
2086 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2088 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2089 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2090 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2093 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2095 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2096 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2097 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2098 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor