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 "VTKViewer_CellCenters.h"
34 #include "VTKViewer_ExtractUnstructuredGrid.h"
35 #include "VTKViewer_FramedTextActor.h"
36 #include "SALOME_InteractiveObject.hxx"
38 #include "SUIT_Session.h"
39 #include "SUIT_ResourceMgr.h"
41 #include <vtkProperty.h>
42 #include <vtkTimeStamp.h>
43 #include <vtkObjectFactory.h>
44 #include <vtkShrinkPolyData.h>
45 #include <vtkMergeFilter.h>
47 #include <vtkMatrix4x4.h>
48 #include <vtkUnstructuredGrid.h>
49 #include <vtkPointData.h>
50 #include <vtkCellData.h>
52 #include <vtkMapper.h>
53 #include <vtkRenderer.h>
56 #include <vtkIdList.h>
57 #include <vtkIntArray.h>
59 #include <vtkActor2D.h>
60 #include <vtkProperty2D.h>
61 #include <vtkPolyData.h>
62 #include <vtkMaskPoints.h>
63 #include <vtkTextProperty.h>
64 #include <vtkLabeledDataMapper.h>
65 #include <vtkSelectVisiblePoints.h>
67 #include <vtkScalarBarActor.h>
68 #include <vtkLookupTable.h>
72 #include <vtkImplicitBoolean.h>
73 #include <vtkImplicitFunctionCollection.h>
75 #include <vtkConfigure.h>
76 #if !defined(VTK_XVERSION)
77 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
80 #include "utilities.h"
83 static int MYDEBUG = 1;
85 static int MYDEBUG = 0;
88 static int aLineWidthInc = 2;
91 SMESH_ActorDef* SMESH_ActorDef::New(){
92 return new SMESH_ActorDef();
96 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
101 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
102 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
107 anActor->UpdateScalarBar();
112 SMESH_ActorDef::SMESH_ActorDef()
114 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
116 myTimeStamp = vtkTimeStamp::New();
118 myIsPointsVisible = false;
120 myIsShrinkable = false;
123 myIsFacesOriented = false;
125 myControlsPrecision = -1;
126 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
128 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
129 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
131 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
132 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
134 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
135 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
137 //Definition 2D and 3D devices of the actor
138 //-----------------------------------------
139 vtkFloatingPointType anRGB[3] = {1,1,1};
140 mySurfaceProp = vtkProperty::New();
141 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
142 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
144 myBackSurfaceProp = vtkProperty::New();
145 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
146 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
148 my2DActor = SMESH_DeviceActor::New();
149 my2DActor->SetUserMatrix(aMatrix);
150 my2DActor->PickableOff();
151 my2DActor->SetProperty(mySurfaceProp);
152 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
153 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
154 aFilter = my2DActor->GetExtractUnstructuredGrid();
155 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
156 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
157 aFilter->RegisterCellsWithType(VTK_POLYGON);
158 aFilter->RegisterCellsWithType(VTK_QUAD);
159 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
160 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
162 my2DExtProp = vtkProperty::New();
163 my2DExtProp->DeepCopy(mySurfaceProp);
164 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
165 anRGB[0] = 1 - anRGB[0];
166 anRGB[1] = 1 - anRGB[1];
167 anRGB[2] = 1 - anRGB[2];
168 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
170 my2DExtActor = SMESH_DeviceActor::New();
171 my2DExtActor->SetUserMatrix(aMatrix);
172 my2DExtActor->PickableOff();
173 my2DExtActor->SetProperty(my2DExtProp);
174 my2DExtActor->SetBackfaceProperty(my2DExtProp);
175 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
176 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
177 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
178 aFilter->RegisterCellsWithType(VTK_POLYGON);
179 aFilter->RegisterCellsWithType(VTK_QUAD);
180 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
181 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
183 my3DActor = SMESH_DeviceActor::New();
184 my3DActor->SetUserMatrix(aMatrix);
185 my3DActor->PickableOff();
186 my3DActor->SetProperty(mySurfaceProp);
187 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
188 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
189 aFilter = my3DActor->GetExtractUnstructuredGrid();
190 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
191 aFilter->RegisterCellsWithType(VTK_TETRA);
192 aFilter->RegisterCellsWithType(VTK_VOXEL);
193 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
194 aFilter->RegisterCellsWithType(VTK_WEDGE);
195 aFilter->RegisterCellsWithType(VTK_PYRAMID);
196 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
197 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
198 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
199 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
200 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
202 //Definition 1D device of the actor
203 //---------------------------------
204 myEdgeProp = vtkProperty::New();
205 myEdgeProp->SetAmbient(1.0);
206 myEdgeProp->SetDiffuse(0.0);
207 myEdgeProp->SetSpecular(0.0);
208 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
209 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
210 myEdgeProp->SetLineWidth(aLineWidth);
212 my1DActor = SMESH_DeviceActor::New();
213 my1DActor->SetUserMatrix(aMatrix);
214 my1DActor->PickableOff();
215 my1DActor->SetHighlited(true);
216 my1DActor->SetProperty(myEdgeProp);
217 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
218 aFilter = my1DActor->GetExtractUnstructuredGrid();
219 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
220 aFilter->RegisterCellsWithType(VTK_LINE);
221 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
223 my1DProp = vtkProperty::New();
224 my1DProp->DeepCopy(myEdgeProp);
225 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
226 my1DProp->SetPointSize(aElem0DSize);
228 my1DExtProp = vtkProperty::New();
229 my1DExtProp->DeepCopy(myEdgeProp);
230 anRGB[0] = 1 - anRGB[0];
231 anRGB[1] = 1 - anRGB[1];
232 anRGB[2] = 1 - anRGB[2];
233 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
234 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
235 my1DExtProp->SetPointSize(aElem0DSize);
237 my1DExtActor = SMESH_DeviceActor::New();
238 my1DExtActor->SetUserMatrix(aMatrix);
239 my1DExtActor->PickableOff();
240 my1DExtActor->SetHighlited(true);
241 my1DExtActor->SetVisibility(false);
242 my1DExtActor->SetProperty(my1DExtProp);
243 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
244 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
245 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
246 aFilter->RegisterCellsWithType(VTK_LINE);
247 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
250 //Definition 0D device of the actor (0d elements)
251 //-----------------------------------------------
252 my0DProp = vtkProperty::New();
253 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
254 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
255 my0DProp->SetPointSize(aElem0DSize);
257 my0DActor = SMESH_DeviceActor::New();
258 my0DActor->SetUserMatrix(aMatrix);
259 my0DActor->SetStoreClippingMapping(true);
260 my0DActor->PickableOff();
261 my0DActor->SetVisibility(false);
262 my0DActor->SetProperty(my0DProp);
263 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
264 aFilter = my0DActor->GetExtractUnstructuredGrid();
265 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
266 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
267 aFilter->RegisterCellsWithType(VTK_VERTEX);
269 //my0DExtProp = vtkProperty::New();
270 //my0DExtProp->DeepCopy(my0DProp);
271 //anRGB[0] = 1 - anRGB[0];
272 //anRGB[1] = 1 - anRGB[1];
273 //anRGB[2] = 1 - anRGB[2];
274 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
275 //my0DExtProp->SetPointSize(aElem0DSize);
277 //my0DExtActor = SMESH_DeviceActor::New();
278 //my0DExtActor->SetUserMatrix(aMatrix);
279 //my0DExtActor->SetStoreClippingMapping(true);
280 //my0DExtActor->PickableOff();
281 //my0DExtActor->SetHighlited(true);
282 //my0DExtActor->SetVisibility(false);
283 //my0DExtActor->SetProperty(my0DExtProp);
284 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
285 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
286 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
287 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
288 //aFilter->RegisterCellsWithType(VTK_VERTEX);
291 //Definition 0D device of the actor (nodes)
292 //-----------------------------------------
293 myNodeProp = vtkProperty::New();
294 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
295 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
297 myNodeActor = SMESH_DeviceActor::New();
298 myNodeActor->SetUserMatrix(aMatrix);
299 myNodeActor->SetStoreClippingMapping(true);
300 myNodeActor->PickableOff();
301 myNodeActor->SetVisibility(false);
302 myNodeActor->SetProperty(myNodeProp);
303 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
304 aFilter = myNodeActor->GetExtractUnstructuredGrid();
305 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
307 myNodeExtProp = vtkProperty::New();
308 myNodeExtProp->DeepCopy(myNodeProp);
309 anRGB[0] = 1 - anRGB[0];
310 anRGB[1] = 1 - anRGB[1];
311 anRGB[2] = 1 - anRGB[2];
312 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
314 myNodeExtActor = SMESH_DeviceActor::New();
315 myNodeExtActor->SetUserMatrix(aMatrix);
316 myNodeExtActor->SetStoreClippingMapping(true);
317 myNodeExtActor->PickableOff();
318 myNodeExtActor->SetHighlited(true);
319 myNodeExtActor->SetVisibility(false);
320 myNodeExtActor->SetProperty(myNodeExtProp);
321 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
322 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
323 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
324 aFilter->RegisterCellsWithType(VTK_VERTEX);
326 //Definition of Pickable and Highlitable engines
327 //----------------------------------------------
329 myBaseActor = SMESH_DeviceActor::New();
330 myBaseActor->SetUserMatrix(aMatrix);
331 myBaseActor->SetStoreGemetryMapping(true);
332 myBaseActor->GetProperty()->SetOpacity(0.0);
334 myPickableActor = myBaseActor;
336 myHighlightProp = vtkProperty::New();
337 myHighlightProp->SetAmbient(1.0);
338 myHighlightProp->SetDiffuse(0.0);
339 myHighlightProp->SetSpecular(0.0);
340 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
341 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
342 myHighlightProp->SetPointSize(aElem0DSize); // ??
343 myHighlightProp->SetRepresentation(1);
345 myPreselectProp = vtkProperty::New();
346 myPreselectProp->SetAmbient(1.0);
347 myPreselectProp->SetDiffuse(0.0);
348 myPreselectProp->SetSpecular(0.0);
349 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
350 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
351 myPreselectProp->SetPointSize(aElem0DSize); // ??
352 myPreselectProp->SetRepresentation(1);
354 myHighlitableActor = SMESH_DeviceActor::New();
355 myHighlitableActor->SetUserMatrix(aMatrix);
356 myHighlitableActor->PickableOff();
357 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
364 myControlMode = eNone;
365 myControlActor = my2DActor;
367 //Definition of myScalarBarActor
368 //------------------------------
369 myLookupTable = vtkLookupTable::New();
370 //Fix for Bug PAL5195 - SMESH764:
371 //Controls - Aspect Ratio: incorrect colors of the best and worst values
372 myLookupTable->SetHueRange(0.667,0.0);
374 myScalarBarActor = vtkScalarBarActor::New();
375 myScalarBarActor->SetVisibility(false);
376 myScalarBarActor->SetLookupTable(myLookupTable);
379 //Incorrect "Min value" in Scalar Bar in Mesh:
380 // myScalarBarActor->SetLabelFormat("%.4g");
381 // changes was commented because of regression bug IPAL 19981
383 mgr = SUIT_Session::session()->resourceMgr();
387 //Definition of points numbering pipeline
388 //---------------------------------------
389 myPointsNumDataSet = vtkUnstructuredGrid::New();
391 myPtsMaskPoints = vtkMaskPoints::New();
392 myPtsMaskPoints->SetInput(myPointsNumDataSet);
393 myPtsMaskPoints->SetOnRatio(1);
395 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
396 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
397 myPtsSelectVisiblePoints->SelectInvisibleOff();
398 myPtsSelectVisiblePoints->SetTolerance(0.1);
400 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
401 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
402 #if (VTK_XVERSION < 0x050200)
403 myPtsLabeledDataMapper->SetLabelFormat("%g");
405 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
407 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
408 aPtsTextProp->SetFontFamilyToTimes();
409 static int aPointsFontSize = 10;
410 aPtsTextProp->SetFontSize(aPointsFontSize);
411 aPtsTextProp->SetBold(1);
412 aPtsTextProp->SetItalic(0);
413 aPtsTextProp->SetShadow(0);
414 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
415 aPtsTextProp->Delete();
417 myEntityMode = eAllEntity;
419 myIsPointsLabeled = false;
421 myPointLabels = vtkActor2D::New();
422 myPointLabels->SetMapper(myPtsLabeledDataMapper);
423 myPointLabels->GetProperty()->SetColor(1,1,1);
424 myPointLabels->SetVisibility(myIsPointsLabeled);
427 //Definition of cells numbering pipeline
428 //---------------------------------------
429 myCellsNumDataSet = vtkUnstructuredGrid::New();
431 myCellCenters = VTKViewer_CellCenters::New();
432 myCellCenters->SetInput(myCellsNumDataSet);
434 myClsMaskPoints = vtkMaskPoints::New();
435 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
436 myClsMaskPoints->SetOnRatio(1);
438 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
439 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
440 myClsSelectVisiblePoints->SelectInvisibleOff();
441 myClsSelectVisiblePoints->SetTolerance(0.1);
443 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
444 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
445 #if (VTK_XVERSION < 0x050200)
446 myClsLabeledDataMapper->SetLabelFormat("%g");
448 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
450 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
451 aClsTextProp->SetFontFamilyToTimes();
452 static int aCellsFontSize = 12;
453 aClsTextProp->SetFontSize(aCellsFontSize);
454 aClsTextProp->SetBold(1);
455 aClsTextProp->SetItalic(0);
456 aClsTextProp->SetShadow(0);
457 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
458 aClsTextProp->Delete();
460 myIsCellsLabeled = false;
462 myCellsLabels = vtkActor2D::New();
463 myCellsLabels->SetMapper(myClsLabeledDataMapper);
464 myCellsLabels->GetProperty()->SetColor(0,1,0);
465 myCellsLabels->SetVisibility(myIsCellsLabeled);
468 myImplicitBoolean = vtkImplicitBoolean::New();
469 myImplicitBoolean->SetOperationTypeToIntersection();
473 //Quadratic 2D elements representation
474 //-----------------------------------------------------------------------------
475 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
476 if(aQuadratic2DMode == 0){
477 myHighlitableActor->SetQuadraticArcMode(false);
478 my2DActor->SetQuadraticArcMode(false);
479 my1DActor->SetQuadraticArcMode(false);
481 else if(aQuadratic2DMode == 1){
482 myHighlitableActor->SetQuadraticArcMode(true);
483 my2DActor->SetQuadraticArcMode(true);
484 my1DActor->SetQuadraticArcMode(true);
487 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
488 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
489 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
491 // Set colors of the name actor
492 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
493 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
494 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
495 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
499 SMESH_ActorDef::~SMESH_ActorDef()
501 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
503 myScalarBarActor->Delete();
504 myLookupTable->Delete();
506 mySurfaceProp->Delete();
507 myBackSurfaceProp->Delete();
509 myEdgeProp->Delete();
510 myHighlightProp->Delete();
511 myPreselectProp->Delete();
513 myNodeProp->Delete();
514 myNodeExtProp->Delete();
519 //my0DExtProp->Delete();
520 //my0DExtActor->Delete();
525 my1DExtProp->Delete();
526 my1DExtActor->Delete();
529 my2DExtProp->Delete();
530 my2DExtActor->Delete();
533 myNodeActor->Delete();
534 myBaseActor->Delete();
536 myNodeExtActor->Delete();
538 myHighlitableActor->Delete();
540 //Deleting of points numbering pipeline
541 //---------------------------------------
542 myPointsNumDataSet->Delete();
544 // commented: porting to vtk 5.0
545 // myPtsLabeledDataMapper->RemoveAllInputs();
546 myPtsLabeledDataMapper->Delete();
548 // commented: porting to vtk 5.0
549 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
550 myPtsSelectVisiblePoints->Delete();
552 // commented: porting to vtk 5.0
553 // myPtsMaskPoints->UnRegisterAllOutputs();
554 myPtsMaskPoints->Delete();
556 myPointLabels->Delete();
559 //Deleting of cells numbering pipeline
560 //---------------------------------------
561 myCellsNumDataSet->Delete();
563 myClsLabeledDataMapper->RemoveAllInputs();
564 myClsLabeledDataMapper->Delete();
566 // commented: porting to vtk 5.0
567 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
568 myClsSelectVisiblePoints->Delete();
570 // commented: porting to vtk 5.0
571 // myClsMaskPoints->UnRegisterAllOutputs();
572 myClsMaskPoints->Delete();
574 // commented: porting to vtk 5.0
575 // myCellCenters->UnRegisterAllOutputs();
576 myCellCenters->Delete();
578 myCellsLabels->Delete();
580 myImplicitBoolean->Delete();
582 myTimeStamp->Delete();
586 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
588 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
590 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
592 if ( myIsPointsLabeled )
594 myPointsNumDataSet->ShallowCopy(aGrid);
595 vtkDataSet *aDataSet = myPointsNumDataSet;
597 int aNbElem = aDataSet->GetNumberOfPoints();
599 vtkIntArray *anArray = vtkIntArray::New();
600 anArray->SetNumberOfValues( aNbElem );
602 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
604 int aSMDSId = myVisualObj->GetNodeObjId( anId );
605 anArray->SetValue( anId, aSMDSId );
608 aDataSet->GetPointData()->SetScalars( anArray );
610 myPtsMaskPoints->SetInput( aDataSet );
611 myPointLabels->SetVisibility( GetVisibility() );
615 myPointLabels->SetVisibility( false );
617 SetRepresentation(GetRepresentation());
618 myTimeStamp->Modified();
622 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
624 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
625 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
626 if(myIsCellsLabeled){
627 myCellsNumDataSet->ShallowCopy(aGrid);
628 vtkDataSet *aDataSet = myCellsNumDataSet;
629 int aNbElem = aDataSet->GetNumberOfCells();
630 vtkIntArray *anArray = vtkIntArray::New();
631 anArray->SetNumberOfValues(aNbElem);
632 for(int anId = 0; anId < aNbElem; anId++){
633 int aSMDSId = myVisualObj->GetElemObjId(anId);
634 anArray->SetValue(anId,aSMDSId);
636 aDataSet->GetCellData()->SetScalars(anArray);
637 myCellCenters->SetInput(aDataSet);
638 myCellsLabels->SetVisibility(GetVisibility());
640 myCellsLabels->SetVisibility(false);
642 myTimeStamp->Modified();
646 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
648 myIsFacesOriented = theIsFacesOriented;
650 my2DActor->SetFacesOriented(theIsFacesOriented);
651 my3DActor->SetFacesOriented(theIsFacesOriented);
653 myTimeStamp->Modified();
656 bool SMESH_ActorDef::GetFacesOriented()
658 return myIsFacesOriented;
661 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
663 my2DActor->SetFacesOrientationColor( theColor );
664 my3DActor->SetFacesOrientationColor( theColor );
667 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
669 my3DActor->GetFacesOrientationColor( theColor );
672 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
674 my2DActor->SetFacesOrientationScale( theScale );
675 my3DActor->SetFacesOrientationScale( theScale );
678 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
680 return my3DActor->GetFacesOrientationScale();
683 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
685 my2DActor->SetFacesOrientation3DVectors( theState );
686 my3DActor->SetFacesOrientation3DVectors( theState );
689 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
691 return my3DActor->GetFacesOrientation3DVectors();
697 SetControlMode(eControl theMode)
699 SetControlMode(theMode,true);
705 SetControlMode(eControl theMode,
706 bool theCheckEntityMode)
708 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
712 myControlMode = eNone;
713 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
715 my0DActor->GetMapper()->SetScalarVisibility(false);
716 my1DActor->GetMapper()->SetScalarVisibility(false);
717 my2DActor->GetMapper()->SetScalarVisibility(false);
718 my3DActor->GetMapper()->SetScalarVisibility(false);
719 myScalarBarActor->SetVisibility(false);
721 bool anIsScalarVisible = theMode > eNone;
723 if(anIsScalarVisible){
727 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
728 aControl->SetPrecision( myControlsPrecision );
729 myFunctor.reset( aControl );
730 myControlActor = my1DActor;
735 myFunctor.reset(new SMESH::Controls::Length2D());
736 myControlActor = my2DActor;
740 myFunctor.reset(new SMESH::Controls::FreeBorders());
741 myControlActor = my1DActor;
744 myFunctor.reset(new SMESH::Controls::FreeEdges());
745 myControlActor = my2DActor;
748 myFunctor.reset(new SMESH::Controls::FreeNodes());
749 myControlActor = myNodeActor;
752 myFunctor.reset(new SMESH::Controls::FreeFaces());
753 myControlActor = my2DActor;
755 case eMultiConnection:
756 myFunctor.reset(new SMESH::Controls::MultiConnection());
757 myControlActor = my1DActor;
759 case eMultiConnection2D:
760 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
761 myControlActor = my2DActor;
765 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
766 aControl->SetPrecision( myControlsPrecision );
767 myFunctor.reset( aControl );
768 myControlActor = my2DActor;
773 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
774 aControl->SetPrecision( myControlsPrecision );
775 myFunctor.reset( aControl );
776 myControlActor = my2DActor;
781 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
782 aControl->SetPrecision( myControlsPrecision );
783 myFunctor.reset( aControl );
784 myControlActor = my2DActor;
789 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
790 aControl->SetPrecision( myControlsPrecision );
791 myFunctor.reset( aControl );
792 myControlActor = my3DActor;
797 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
798 aControl->SetPrecision( myControlsPrecision );
799 myFunctor.reset( aControl );
800 myControlActor = my3DActor;
803 case eMaxElementLength2D:
805 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
806 aControl->SetPrecision( myControlsPrecision );
807 myFunctor.reset( aControl );
808 myControlActor = my2DActor;
811 case eMaxElementLength3D:
813 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
814 aControl->SetPrecision( myControlsPrecision );
815 myFunctor.reset( aControl );
816 myControlActor = my3DActor;
821 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
822 aControl->SetPrecision( myControlsPrecision );
823 myFunctor.reset( aControl );
824 myControlActor = my2DActor;
829 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
830 aControl->SetPrecision( myControlsPrecision );
831 myFunctor.reset( aControl );
832 myControlActor = my2DActor;
837 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
838 aControl->SetPrecision( myControlsPrecision );
839 myFunctor.reset( aControl );
840 myControlActor = my2DActor;
847 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
848 vtkIdType aNbCells = aGrid->GetNumberOfCells();
850 myControlMode = theMode;
851 switch(myControlMode){
853 myNodeExtActor->SetExtControlMode(myFunctor);
857 my1DExtActor->SetExtControlMode(myFunctor);
860 my2DExtActor->SetExtControlMode(myFunctor);
863 case eMultiConnection2D:
864 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
867 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
871 if(theCheckEntityMode){
872 if(myControlActor == my1DActor)
873 SetEntityMode(eEdges);
874 else if(myControlActor == my2DActor){
875 switch(myControlMode){
879 case eMultiConnection2D:
880 //SetEntityMode(eEdges);
881 SetEntityMode(eFaces);
884 SetEntityMode(eFaces);
886 }else if(myControlActor == my3DActor)
887 SetEntityMode(eVolumes);
892 if(theCheckEntityMode)
893 myEntityMode = eAllEntity;
897 SetRepresentation(GetRepresentation());
899 myTimeStamp->Modified();
904 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
905 theRenderer->AddActor(myNodeActor);
906 theRenderer->AddActor(myBaseActor);
908 theRenderer->AddActor(myNodeExtActor);
910 my3DActor->AddToRender(theRenderer);
911 my2DActor->AddToRender(theRenderer);
912 my2DExtActor->AddToRender(theRenderer);
914 theRenderer->AddActor(my1DActor);
915 theRenderer->AddActor(my1DExtActor);
917 theRenderer->AddActor(my0DActor);
918 //theRenderer->AddActor(my0DExtActor);
920 theRenderer->AddActor(myHighlitableActor);
922 theRenderer->AddActor2D(myScalarBarActor);
924 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
925 myClsSelectVisiblePoints->SetRenderer(theRenderer);
927 theRenderer->AddActor2D(myPointLabels);
928 theRenderer->AddActor2D(myCellsLabels);
930 // the superclass' method should be called at the end
931 // (in particular, for correct work of selection)
932 SALOME_Actor::AddToRender(theRenderer);
935 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
936 SALOME_Actor::RemoveFromRender(theRenderer);
938 theRenderer->RemoveActor(myNodeActor);
939 theRenderer->RemoveActor(myBaseActor);
941 theRenderer->RemoveActor(myNodeExtActor);
943 theRenderer->RemoveActor(myHighlitableActor);
945 theRenderer->RemoveActor(my0DActor);
946 //theRenderer->RemoveActor(my0DExtActor);
948 theRenderer->RemoveActor(my1DActor);
949 theRenderer->RemoveActor(my1DExtActor);
951 my2DActor->RemoveFromRender(theRenderer);
952 my2DExtActor->RemoveFromRender(theRenderer);
953 my3DActor->RemoveFromRender(theRenderer);
955 theRenderer->RemoveActor(myScalarBarActor);
956 theRenderer->RemoveActor(myPointLabels);
957 theRenderer->RemoveActor(myCellsLabels);
961 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
962 const char* theEntry,
966 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
970 myVisualObj = theVisualObj;
971 myVisualObj->Update(theIsClear);
973 myNodeActor->Init(myVisualObj,myImplicitBoolean);
974 myBaseActor->Init(myVisualObj,myImplicitBoolean);
976 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
978 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
980 my0DActor->Init(myVisualObj,myImplicitBoolean);
981 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
983 my1DActor->Init(myVisualObj,myImplicitBoolean);
984 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
986 my2DActor->Init(myVisualObj,myImplicitBoolean);
987 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
988 my3DActor->Init(myVisualObj,myImplicitBoolean);
990 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
991 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
993 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
994 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
996 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
997 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
998 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1000 vtkFloatingPointType aFactor, aUnits;
1001 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1002 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1003 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1005 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1009 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1010 SetIsShrunkable(true);
1012 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1014 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1015 SetRepresentation(-1);
1018 SetRepresentation(eEdge);
1019 }else if(aMode == 1){
1020 SetRepresentation(eSurface);
1021 }else if(aMode == 2){
1022 SetRepresentation(ePoint);
1029 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1030 SetIsDisplayNameActor( true );
1032 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1033 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1034 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1036 myTimeStamp->Modified();
1042 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1043 return myNodeActor->GetBounds();
1047 vtkDataSet* SMESH_ActorDef::GetInput(){
1048 return GetUnstructuredGrid();
1052 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1053 Superclass::SetTransform(theTransform);
1055 myNodeActor->SetTransform(theTransform);
1056 myBaseActor->SetTransform(theTransform);
1058 myHighlitableActor->SetTransform(theTransform);
1060 myNodeExtActor->SetTransform(theTransform);
1062 my0DActor->SetTransform(theTransform);
1063 //my0DExtActor->SetTransform(theTransform);
1065 my1DActor->SetTransform(theTransform);
1066 my1DExtActor->SetTransform(theTransform);
1068 my2DActor->SetTransform(theTransform);
1069 my2DExtActor->SetTransform(theTransform);
1070 my3DActor->SetTransform(theTransform);
1076 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1077 vtkLODActor::SetMapper(theMapper);
1081 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1082 SALOME_Actor::ShallowCopy(prop);
1086 vtkMapper* SMESH_ActorDef::GetMapper(){
1087 return myPickableActor->GetMapper();
1091 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1092 return myVisualObj->GetUnstructuredGrid();
1096 bool SMESH_ActorDef::IsInfinitive(){
1097 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1099 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1100 ( aDataSet->GetNumberOfCells() == 1 &&
1101 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1102 return SALOME_Actor::IsInfinitive();
1106 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1107 if ( myIsShrinkable == theShrunkable )
1109 myIsShrinkable = theShrunkable;
1113 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1114 return myBaseActor->GetShrinkFactor();
1117 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1118 myBaseActor->SetShrinkFactor(theValue);
1120 my1DActor->SetShrinkFactor(theValue);
1121 my1DExtActor->SetShrinkFactor(theValue);
1123 my2DActor->SetShrinkFactor(theValue);
1124 my2DExtActor->SetShrinkFactor(theValue);
1125 my3DActor->SetShrinkFactor(theValue);
1130 void SMESH_ActorDef::SetShrink(){
1131 if(!myIsShrinkable) return;
1133 myBaseActor->SetShrink();
1135 my1DActor->SetShrink();
1136 my1DExtActor->SetShrink();
1138 my2DActor->SetShrink();
1139 my2DExtActor->SetShrink();
1140 my3DActor->SetShrink();
1146 void SMESH_ActorDef::UnShrink(){
1147 if(!myIsShrunk) return;
1149 myBaseActor->UnShrink();
1151 my1DActor->UnShrink();
1152 my1DExtActor->UnShrink();
1154 my2DActor->UnShrink();
1155 my2DExtActor->UnShrink();
1156 my3DActor->UnShrink();
1163 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1164 return myPickableActor->GetNodeObjId(theVtkID);
1167 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1168 return myPickableActor->GetNodeCoord(theObjID);
1172 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1173 return myPickableActor->GetElemObjId(theVtkID);
1176 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1177 return myPickableActor->GetElemCell(theObjID);
1181 void SMESH_ActorDef::SetVisibility(int theMode){
1182 SetVisibility(theMode,true);
1186 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1187 SALOME_Actor::SetVisibility(theMode);
1189 myNodeActor->VisibilityOff();
1190 myBaseActor->VisibilityOff();
1192 myNodeExtActor->VisibilityOff();
1194 my0DActor->VisibilityOff();
1195 //my0DExtActor->VisibilityOff();
1197 my1DActor->VisibilityOff();
1198 my1DExtActor->VisibilityOff();
1200 my2DActor->VisibilityOff();
1201 my2DExtActor->VisibilityOff();
1202 my3DActor->VisibilityOff();
1204 myScalarBarActor->VisibilityOff();
1205 myPointLabels->VisibilityOff();
1206 myCellsLabels->VisibilityOff();
1208 if(GetVisibility()){
1209 if(theIsUpdateRepersentation)
1210 SetRepresentation(GetRepresentation());
1212 if(myControlMode != eNone){
1213 switch(myControlMode){
1215 myNodeExtActor->VisibilityOn();
1219 my1DExtActor->VisibilityOn();
1222 my2DExtActor->VisibilityOn();
1225 case eMultiConnection2D:
1226 my1DExtActor->VisibilityOn();
1228 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1229 myScalarBarActor->VisibilityOn();
1233 if(myRepresentation != ePoint)
1234 myPickableActor->VisibilityOn();
1236 myNodeActor->VisibilityOn();
1239 if(myEntityMode & e0DElements){
1240 my0DActor->VisibilityOn();
1243 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1244 my1DActor->VisibilityOn();
1247 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1248 my2DActor->VisibilityOn();
1251 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1252 my3DActor->VisibilityOn();
1255 if(myIsPointsLabeled){
1256 myPointLabels->VisibilityOn();
1257 myNodeActor->VisibilityOn();
1260 if(myIsCellsLabeled)
1261 myCellsLabels->VisibilityOn();
1268 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1270 myEntityState = eAllEntity;
1272 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1273 myEntityState &= ~e0DElements;
1274 theMode &= ~e0DElements;
1277 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1278 myEntityState &= ~eEdges;
1282 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1283 myEntityState &= ~eFaces;
1287 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1288 myEntityState &= ~eVolumes;
1289 theMode &= ~eVolumes;
1293 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1294 theMode |= e0DElements;
1296 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1299 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1302 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1303 theMode |= eVolumes;
1306 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1308 myEntityMode = theMode;
1309 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1310 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1311 aFilter->ClearRegisteredCellsWithType();
1312 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1314 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1315 aHightFilter->ClearRegisteredCellsWithType();
1316 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1318 if (myEntityMode & e0DElements) {
1319 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1320 aFilter->RegisterCellsWithType(VTK_VERTEX);
1321 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1324 if (myEntityMode & eEdges) {
1325 if (MYDEBUG) MESSAGE("EDGES");
1326 aFilter->RegisterCellsWithType(VTK_LINE);
1327 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1329 aHightFilter->RegisterCellsWithType(VTK_LINE);
1330 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1333 if (myEntityMode & eFaces) {
1334 if (MYDEBUG) MESSAGE("FACES");
1335 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1336 aFilter->RegisterCellsWithType(VTK_POLYGON);
1337 aFilter->RegisterCellsWithType(VTK_QUAD);
1338 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1339 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1341 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1342 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1343 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1344 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1345 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1348 if (myEntityMode & eVolumes) {
1349 if (MYDEBUG) MESSAGE("VOLUMES");
1350 aFilter->RegisterCellsWithType(VTK_TETRA);
1351 aFilter->RegisterCellsWithType(VTK_VOXEL);
1352 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1353 aFilter->RegisterCellsWithType(VTK_WEDGE);
1354 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1355 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1356 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1357 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1358 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1360 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1361 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1362 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1363 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1364 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1365 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1366 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1367 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1368 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1369 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1372 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1373 SetVisibility(GetVisibility(),false);
1376 void SMESH_ActorDef::SetRepresentation (int theMode)
1378 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1379 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1380 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1383 myRepresentation = eSurface;
1384 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1385 myRepresentation = eEdge;
1386 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1387 myRepresentation = ePoint;
1392 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1395 if (!aNbFaces && !aNbVolumes) return;
1398 myRepresentation = theMode;
1401 if (!GetUnstructuredGrid()->GetNumberOfCells())
1402 myRepresentation = ePoint;
1405 if (myRepresentation == ePoint) {
1413 myPickableActor = myBaseActor;
1414 myNodeActor->SetVisibility(false);
1415 myNodeExtActor->SetVisibility(false);
1416 vtkProperty *aProp = NULL, *aBackProp = NULL;
1417 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1418 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1419 switch (myRepresentation) {
1421 myPickableActor = myNodeActor;
1422 myNodeActor->SetVisibility(true);
1423 aQuadraticMode = SMESH_Actor::eLines;
1424 aProp = aBackProp = myNodeProp;
1425 aReperesent = SMESH_DeviceActor::ePoint;
1428 aProp = aBackProp = myEdgeProp;
1429 aReperesent = SMESH_DeviceActor::eInsideframe;
1432 aProp = mySurfaceProp;
1433 aBackProp = myBackSurfaceProp;
1434 aReperesent = SMESH_DeviceActor::eSurface;
1438 my2DActor->SetProperty(aProp);
1439 my2DActor->SetBackfaceProperty(aBackProp);
1440 my2DActor->SetRepresentation(aReperesent);
1442 if(aQuadraticMode == SMESH_Actor::eLines)
1443 my2DActor->SetQuadraticArcMode(false);
1444 else if(aQuadraticMode == SMESH_Actor::eArcs)
1445 my2DActor->SetQuadraticArcMode(true);
1447 my2DExtActor->SetRepresentation(aReperesent);
1449 my3DActor->SetProperty(aProp);
1450 my3DActor->SetBackfaceProperty(aBackProp);
1451 my3DActor->SetRepresentation(aReperesent);
1453 //my0DExtActor->SetVisibility(false);
1454 my1DExtActor->SetVisibility(false);
1455 my2DExtActor->SetVisibility(false);
1458 //my0DActor->SetProperty(aProp);
1459 //my0DActor->SetBackfaceProperty(aBackProp);
1460 my0DActor->SetRepresentation(aReperesent);
1461 //my0DExtActor->SetRepresentation(aReperesent);
1463 switch(myControlMode){
1465 case eMultiConnection:
1466 aProp = aBackProp = my1DProp;
1467 if(myRepresentation != ePoint)
1468 aReperesent = SMESH_DeviceActor::eInsideframe;
1472 if(aQuadraticMode == SMESH_Actor::eLines)
1473 my1DActor->SetQuadraticArcMode(false);
1474 else if(aQuadraticMode == SMESH_Actor::eArcs)
1475 my1DActor->SetQuadraticArcMode(true);
1477 my1DActor->SetProperty(aProp);
1478 my1DActor->SetBackfaceProperty(aBackProp);
1479 my1DActor->SetRepresentation(aReperesent);
1481 my1DExtActor->SetRepresentation(aReperesent);
1483 if(myIsPointsVisible)
1484 myPickableActor = myNodeActor;
1485 if(GetPointRepresentation())
1486 myNodeActor->SetVisibility(true);
1488 SetMapper(myPickableActor->GetMapper());
1490 SetVisibility(GetVisibility(),false);
1496 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1497 if ( myIsPointsVisible == theIsPointsVisible )
1499 myIsPointsVisible = theIsPointsVisible;
1500 SetRepresentation(GetRepresentation());
1503 bool SMESH_ActorDef::GetPointRepresentation(){
1504 return myIsPointsVisible || myIsPointsLabeled;
1508 void SMESH_ActorDef::UpdateHighlight(){
1509 myHighlitableActor->SetVisibility(false);
1510 myHighlitableActor->SetHighlited(false);
1512 if(myIsHighlighted){
1513 myHighlitableActor->SetProperty(myHighlightProp);
1514 }else if(myIsPreselected){
1515 myHighlitableActor->SetProperty(myPreselectProp);
1518 bool anIsVisible = GetVisibility();
1520 if(myIsHighlighted || myIsPreselected){
1521 if(GetUnstructuredGrid()->GetNumberOfCells()){
1522 myHighlitableActor->SetHighlited(anIsVisible);
1523 myHighlitableActor->SetVisibility(anIsVisible);
1524 myHighlitableActor->GetExtractUnstructuredGrid()->
1525 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1526 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1527 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1528 myHighlitableActor->SetHighlited(anIsVisible);
1529 myHighlitableActor->GetExtractUnstructuredGrid()->
1530 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1531 myHighlitableActor->SetVisibility(anIsVisible);
1532 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1534 VTK::MarkerType aMarkerType = GetMarkerType();
1535 if(aMarkerType != VTK::MT_USER)
1536 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1538 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1544 void SMESH_ActorDef::highlight(bool theHighlight){
1545 if ( myIsHighlighted == theHighlight )
1547 myIsHighlighted = theHighlight;
1552 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1553 if ( myIsPreselected == thePreselect )
1555 myIsPreselected = thePreselect;
1561 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1563 if (myPickableActor->GetIsOpaque())
1565 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1573 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1575 if (!myPickableActor->GetIsOpaque())
1577 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1585 void SMESH_ActorDef::Render(vtkRenderer *ren){
1586 unsigned long aTime = myTimeStamp->GetMTime();
1587 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1588 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1589 if(anObjTime > aTime || aClippingTime > aTime)
1594 void SMESH_ActorDef::Update(){
1595 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1597 if(GetControlMode() != eNone) {
1598 unsigned long aTime = myTimeStamp->GetMTime();
1599 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1600 if (anObjTime > aTime)
1601 SetControlMode(GetControlMode(),false);
1603 if(myIsPointsLabeled){
1604 SetPointsLabeled(myIsPointsLabeled);
1606 if(myIsCellsLabeled){
1607 SetCellsLabeled(myIsCellsLabeled);
1609 if(myIsFacesOriented){
1610 SetFacesOriented(myIsFacesOriented);
1612 SetEntityMode(GetEntityMode());
1613 SetVisibility(GetVisibility());
1615 myTimeStamp->Modified();
1620 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1621 SALOME_Actor::ReleaseGraphicsResources(renWin);
1623 myPickableActor->ReleaseGraphicsResources(renWin);
1627 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1628 vtkFloatingPointType* aColor = theProperty->GetColor();
1635 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1636 mySurfaceProp->SetOpacity(theValue);
1637 myBackSurfaceProp->SetOpacity(theValue);
1638 myEdgeProp->SetOpacity(theValue);
1639 myNodeProp->SetOpacity(theValue);
1641 my1DProp->SetOpacity(theValue);
1645 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1646 return mySurfaceProp->GetOpacity();
1650 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1651 mySurfaceProp->SetColor(r,g,b);
1652 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1653 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1654 aGroupObj->GetElementType() == SMDSAbs_Volume )
1655 myNameActor->SetBackgroundColor(r,g,b);
1659 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1660 ::GetColor(mySurfaceProp,r,g,b);
1661 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1664 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1665 myBackSurfaceProp->SetColor(r,g,b);
1669 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1670 ::GetColor(myBackSurfaceProp,r,g,b);
1673 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1674 myEdgeProp->SetColor(r,g,b);
1675 my1DProp->SetColor(r,g,b);
1676 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1677 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1678 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1679 myNameActor->SetBackgroundColor(r,g,b);
1683 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1684 ::GetColor(myEdgeProp,r,g,b);
1687 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1688 myNodeProp->SetColor(r,g,b);
1689 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1690 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1691 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1692 myNameActor->SetBackgroundColor(r,g,b);
1696 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1697 ::GetColor(myNodeProp,r,g,b);
1700 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1701 my0DProp->SetColor(r,g,b);
1702 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1703 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1704 myNameActor->SetBackgroundColor(r,g,b);
1708 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1709 ::GetColor(my0DProp,r,g,b);
1712 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1713 myHighlightProp->SetColor(r,g,b);
1717 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1718 ::GetColor(myHighlightProp,r,g,b);
1721 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1722 myPreselectProp->SetColor(r,g,b);
1726 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1727 ::GetColor(myPreselectProp,r,g,b);
1731 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1732 return myEdgeProp->GetLineWidth();
1736 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1737 myEdgeProp->SetLineWidth(theVal);
1739 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1740 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1746 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1747 my0DProp->SetPointSize(theVal);
1751 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1752 return my0DProp->GetPointSize();
1755 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1757 return myVisualObj->GetElemDimension( theObjId );
1762 IsImplicitFunctionUsed() const
1764 return myBaseActor->IsImplicitFunctionUsed();
1768 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1770 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1771 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1773 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1775 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1777 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1778 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1780 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1781 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1783 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1784 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1785 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1789 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1792 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1793 myCippingPlaneCont.push_back(thePlane);
1794 if(!IsImplicitFunctionUsed())
1795 SetImplicitFunctionUsed(true);
1797 return myCippingPlaneCont.size();
1802 RemoveAllClippingPlanes()
1804 myImplicitBoolean->GetFunction()->RemoveAllItems();
1805 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1806 myCippingPlaneCont.clear();
1807 SetImplicitFunctionUsed(false);
1812 GetNumberOfClippingPlanes()
1814 return myCippingPlaneCont.size();
1819 GetClippingPlane(vtkIdType theID)
1821 if(theID >= myCippingPlaneCont.size())
1823 return myCippingPlaneCont[theID].Get();
1827 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1828 vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1829 vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1831 vtkFloatingPointType aBounds[6];
1832 theDataSet->GetBounds(aBounds);
1834 //Enlarge bounds in order to avoid conflicts of precision
1835 for(int i = 0; i < 6; i += 2){
1836 static double EPS = 1.0E-3;
1837 vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1838 aBounds[i] -= aDelta;
1839 aBounds[i+1] += aDelta;
1842 vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1843 {aBounds[1],aBounds[2],aBounds[4]},
1844 {aBounds[0],aBounds[3],aBounds[4]},
1845 {aBounds[1],aBounds[3],aBounds[4]},
1846 {aBounds[0],aBounds[2],aBounds[5]},
1847 {aBounds[1],aBounds[2],aBounds[5]},
1848 {aBounds[0],aBounds[3],aBounds[5]},
1849 {aBounds[1],aBounds[3],aBounds[5]}};
1851 int aMaxId = 0, aMinId = aMaxId;
1852 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1853 theMinBoundPrj = theMaxBoundPrj;
1854 for(int i = 1; i < 8; i++){
1855 vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1856 if(theMaxBoundPrj < aTmp){
1857 theMaxBoundPrj = aTmp;
1860 if(theMinBoundPrj > aTmp){
1861 theMinBoundPrj = aTmp;
1865 vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1866 theMinPnt[0] = aMinPnt[0];
1867 theMinPnt[1] = aMinPnt[1];
1868 theMinPnt[2] = aMinPnt[2];
1872 static void DistanceToPosition(vtkDataSet* theDataSet,
1873 vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1875 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1876 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1877 vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1878 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1879 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1880 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1884 static void PositionToDistance(vtkDataSet* theDataSet,
1885 vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1887 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1888 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1889 vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1890 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1894 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1896 thePlane->SetNormal(theDir);
1897 vtkFloatingPointType anOrigin[3];
1898 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1899 thePlane->SetOrigin(anOrigin);
1903 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1905 thePlane->GetNormal(theDir);
1907 vtkFloatingPointType anOrigin[3];
1908 thePlane->GetOrigin(anOrigin);
1909 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1912 void SMESH_ActorDef::UpdateScalarBar()
1914 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1918 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1920 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1921 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1923 aScalarBarTitleProp->SetFontFamilyToArial();
1925 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1927 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1928 if ( f.family() == "Arial" )
1929 aScalarBarTitleProp->SetFontFamilyToArial();
1930 else if ( f.family() == "Courier" )
1931 aScalarBarTitleProp->SetFontFamilyToCourier();
1932 else if ( f.family() == "Times" )
1933 aScalarBarTitleProp->SetFontFamilyToTimes();
1936 aScalarBarTitleProp->BoldOn();
1938 aScalarBarTitleProp->BoldOff();
1941 aScalarBarTitleProp->ItalicOn();
1943 aScalarBarTitleProp->ItalicOff();
1946 aScalarBarTitleProp->ShadowOn();
1948 aScalarBarTitleProp->ShadowOff();
1951 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1952 aScalarBarTitleProp->Delete();
1954 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1956 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1957 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1959 aScalarBarLabelProp->SetFontFamilyToArial();
1960 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1962 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1963 if( f.family() == "Arial" )
1964 aScalarBarLabelProp->SetFontFamilyToArial();
1965 else if( f.family() == "Courier" )
1966 aScalarBarLabelProp->SetFontFamilyToCourier();
1967 else if( f.family() == "Times" )
1968 aScalarBarLabelProp->SetFontFamilyToTimes();
1971 aScalarBarLabelProp->BoldOn();
1973 aScalarBarLabelProp->BoldOff();
1976 aScalarBarLabelProp->ItalicOn();
1978 aScalarBarLabelProp->ItalicOff();
1981 aScalarBarLabelProp->ShadowOn();
1983 aScalarBarLabelProp->ShadowOff();
1986 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1987 aScalarBarLabelProp->Delete();
1989 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1990 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1992 myScalarBarActor->SetOrientationToHorizontal();
1994 myScalarBarActor->SetOrientationToVertical();
1997 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1998 if( mgr->hasValue( "SMESH", name + "x" ) )
1999 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2001 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2002 if( mgr->hasValue( "SMESH", name + "y" ) )
2003 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2004 myScalarBarActor->SetPosition( aXVal, aYVal );
2006 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2007 if( mgr->hasValue( "SMESH", name + "width" ) )
2008 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2009 myScalarBarActor->SetWidth( aWVal );
2011 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2012 if( mgr->hasValue( "SMESH", name + "height" ) )
2013 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2014 myScalarBarActor->SetHeight( aHVal );
2017 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2018 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2019 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2022 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2023 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2024 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2028 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2031 case SMESH_Actor::eLines :
2032 myHighlitableActor->SetQuadraticArcMode(false);
2033 my2DActor->SetQuadraticArcMode(false);
2034 my1DActor->SetQuadraticArcMode(false);
2036 case SMESH_Actor::eArcs :
2037 myHighlitableActor->SetQuadraticArcMode(true);
2038 if(GetRepresentation() != SMESH_Actor::ePoint) {
2039 my2DActor->SetQuadraticArcMode(true);
2040 my1DActor->SetQuadraticArcMode(true);
2049 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2051 if(myHighlitableActor->GetQuadraticArcMode())
2052 return SMESH_Actor::eArcs;
2054 return SMESH_Actor::eLines;
2057 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2059 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2060 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2061 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2064 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2066 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2067 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2068 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2069 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor