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_ExtractUnstructuredGrid.h"
34 #include "VTKViewer_FramedTextActor.h"
35 #include "SALOME_InteractiveObject.hxx"
37 #include "SUIT_Session.h"
38 #include "SUIT_ResourceMgr.h"
40 #include <vtkProperty.h>
41 #include <vtkTimeStamp.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkShrinkPolyData.h>
44 #include <vtkMergeFilter.h>
46 #include <vtkMatrix4x4.h>
47 #include <vtkUnstructuredGrid.h>
48 #include <vtkPointData.h>
49 #include <vtkCellData.h>
51 #include <vtkMapper.h>
52 #include <vtkRenderer.h>
55 #include <vtkIdList.h>
56 #include <vtkIntArray.h>
58 #include <vtkActor2D.h>
59 #include <vtkProperty2D.h>
60 #include <vtkPolyData.h>
61 #include <vtkMaskPoints.h>
62 #include <vtkCellCenters.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_CONVEX_POINT_SET);
201 //Definition 1D device of the actor
202 //---------------------------------
203 myEdgeProp = vtkProperty::New();
204 myEdgeProp->SetAmbient(1.0);
205 myEdgeProp->SetDiffuse(0.0);
206 myEdgeProp->SetSpecular(0.0);
207 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
208 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
209 myEdgeProp->SetLineWidth(aLineWidth);
211 my1DActor = SMESH_DeviceActor::New();
212 my1DActor->SetUserMatrix(aMatrix);
213 my1DActor->PickableOff();
214 my1DActor->SetHighlited(true);
215 my1DActor->SetProperty(myEdgeProp);
216 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
217 aFilter = my1DActor->GetExtractUnstructuredGrid();
218 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
219 aFilter->RegisterCellsWithType(VTK_LINE);
220 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
222 my1DProp = vtkProperty::New();
223 my1DProp->DeepCopy(myEdgeProp);
224 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
225 my1DProp->SetPointSize(aElem0DSize);
227 my1DExtProp = vtkProperty::New();
228 my1DExtProp->DeepCopy(myEdgeProp);
229 anRGB[0] = 1 - anRGB[0];
230 anRGB[1] = 1 - anRGB[1];
231 anRGB[2] = 1 - anRGB[2];
232 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
233 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
234 my1DExtProp->SetPointSize(aElem0DSize);
236 my1DExtActor = SMESH_DeviceActor::New();
237 my1DExtActor->SetUserMatrix(aMatrix);
238 my1DExtActor->PickableOff();
239 my1DExtActor->SetHighlited(true);
240 my1DExtActor->SetVisibility(false);
241 my1DExtActor->SetProperty(my1DExtProp);
242 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
243 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
244 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
245 aFilter->RegisterCellsWithType(VTK_LINE);
246 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
249 //Definition 0D device of the actor (0d elements)
250 //-----------------------------------------------
251 my0DProp = vtkProperty::New();
252 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
253 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
254 my0DProp->SetPointSize(aElem0DSize);
256 my0DActor = SMESH_DeviceActor::New();
257 my0DActor->SetUserMatrix(aMatrix);
258 my0DActor->SetStoreClippingMapping(true);
259 my0DActor->PickableOff();
260 my0DActor->SetVisibility(false);
261 my0DActor->SetProperty(my0DProp);
262 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
263 aFilter = my0DActor->GetExtractUnstructuredGrid();
264 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
265 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
266 aFilter->RegisterCellsWithType(VTK_VERTEX);
268 //my0DExtProp = vtkProperty::New();
269 //my0DExtProp->DeepCopy(my0DProp);
270 //anRGB[0] = 1 - anRGB[0];
271 //anRGB[1] = 1 - anRGB[1];
272 //anRGB[2] = 1 - anRGB[2];
273 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
274 //my0DExtProp->SetPointSize(aElem0DSize);
276 //my0DExtActor = SMESH_DeviceActor::New();
277 //my0DExtActor->SetUserMatrix(aMatrix);
278 //my0DExtActor->SetStoreClippingMapping(true);
279 //my0DExtActor->PickableOff();
280 //my0DExtActor->SetHighlited(true);
281 //my0DExtActor->SetVisibility(false);
282 //my0DExtActor->SetProperty(my0DExtProp);
283 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
284 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
285 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
286 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
287 //aFilter->RegisterCellsWithType(VTK_VERTEX);
290 //Definition 0D device of the actor (nodes)
291 //-----------------------------------------
292 myNodeProp = vtkProperty::New();
293 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
294 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
296 myNodeActor = SMESH_DeviceActor::New();
297 myNodeActor->SetUserMatrix(aMatrix);
298 myNodeActor->SetStoreClippingMapping(true);
299 myNodeActor->PickableOff();
300 myNodeActor->SetVisibility(false);
301 myNodeActor->SetProperty(myNodeProp);
302 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
303 aFilter = myNodeActor->GetExtractUnstructuredGrid();
304 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
306 myNodeExtProp = vtkProperty::New();
307 myNodeExtProp->DeepCopy(myNodeProp);
308 anRGB[0] = 1 - anRGB[0];
309 anRGB[1] = 1 - anRGB[1];
310 anRGB[2] = 1 - anRGB[2];
311 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
313 myNodeExtActor = SMESH_DeviceActor::New();
314 myNodeExtActor->SetUserMatrix(aMatrix);
315 myNodeExtActor->SetStoreClippingMapping(true);
316 myNodeExtActor->PickableOff();
317 myNodeExtActor->SetHighlited(true);
318 myNodeExtActor->SetVisibility(false);
319 myNodeExtActor->SetProperty(myNodeExtProp);
320 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
321 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
322 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
323 aFilter->RegisterCellsWithType(VTK_VERTEX);
325 //Definition of Pickable and Highlitable engines
326 //----------------------------------------------
328 myBaseActor = SMESH_DeviceActor::New();
329 myBaseActor->SetUserMatrix(aMatrix);
330 myBaseActor->SetStoreGemetryMapping(true);
331 myBaseActor->GetProperty()->SetOpacity(0.0);
333 myPickableActor = myBaseActor;
335 myHighlightProp = vtkProperty::New();
336 myHighlightProp->SetAmbient(1.0);
337 myHighlightProp->SetDiffuse(0.0);
338 myHighlightProp->SetSpecular(0.0);
339 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
340 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
341 myHighlightProp->SetPointSize(aElem0DSize); // ??
342 myHighlightProp->SetRepresentation(1);
344 myPreselectProp = vtkProperty::New();
345 myPreselectProp->SetAmbient(1.0);
346 myPreselectProp->SetDiffuse(0.0);
347 myPreselectProp->SetSpecular(0.0);
348 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
349 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
350 myPreselectProp->SetPointSize(aElem0DSize); // ??
351 myPreselectProp->SetRepresentation(1);
353 myHighlitableActor = SMESH_DeviceActor::New();
354 myHighlitableActor->SetUserMatrix(aMatrix);
355 myHighlitableActor->PickableOff();
356 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
363 myControlMode = eNone;
364 myControlActor = my2DActor;
366 //Definition of myScalarBarActor
367 //------------------------------
368 myLookupTable = vtkLookupTable::New();
369 //Fix for Bug PAL5195 - SMESH764:
370 //Controls - Aspect Ratio: incorrect colors of the best and worst values
371 myLookupTable->SetHueRange(0.667,0.0);
373 myScalarBarActor = vtkScalarBarActor::New();
374 myScalarBarActor->SetVisibility(false);
375 myScalarBarActor->SetLookupTable(myLookupTable);
378 //Incorrect "Min value" in Scalar Bar in Mesh:
379 // myScalarBarActor->SetLabelFormat("%.4g");
380 // changes was commented because of regression bug IPAL 19981
382 mgr = SUIT_Session::session()->resourceMgr();
386 //Definition of points numbering pipeline
387 //---------------------------------------
388 myPointsNumDataSet = vtkUnstructuredGrid::New();
390 myPtsMaskPoints = vtkMaskPoints::New();
391 myPtsMaskPoints->SetInput(myPointsNumDataSet);
392 myPtsMaskPoints->SetOnRatio(1);
394 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
395 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
396 myPtsSelectVisiblePoints->SelectInvisibleOff();
397 myPtsSelectVisiblePoints->SetTolerance(0.1);
399 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
400 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
401 #if (VTK_XVERSION < 0x050200)
402 myPtsLabeledDataMapper->SetLabelFormat("%g");
404 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
406 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
407 aPtsTextProp->SetFontFamilyToTimes();
408 static int aPointsFontSize = 10;
409 aPtsTextProp->SetFontSize(aPointsFontSize);
410 aPtsTextProp->SetBold(1);
411 aPtsTextProp->SetItalic(0);
412 aPtsTextProp->SetShadow(0);
413 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
414 aPtsTextProp->Delete();
416 myEntityMode = eAllEntity;
418 myIsPointsLabeled = false;
420 myPointLabels = vtkActor2D::New();
421 myPointLabels->SetMapper(myPtsLabeledDataMapper);
422 myPointLabels->GetProperty()->SetColor(1,1,1);
423 myPointLabels->SetVisibility(myIsPointsLabeled);
426 //Definition of cells numbering pipeline
427 //---------------------------------------
428 myCellsNumDataSet = vtkUnstructuredGrid::New();
430 myCellCenters = vtkCellCenters::New();
431 myCellCenters->SetInput(myCellsNumDataSet);
433 myClsMaskPoints = vtkMaskPoints::New();
434 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
435 myClsMaskPoints->SetOnRatio(1);
437 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
438 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
439 myClsSelectVisiblePoints->SelectInvisibleOff();
440 myClsSelectVisiblePoints->SetTolerance(0.1);
442 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
443 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
444 #if (VTK_XVERSION < 0x050200)
445 myClsLabeledDataMapper->SetLabelFormat("%g");
447 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
449 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
450 aClsTextProp->SetFontFamilyToTimes();
451 static int aCellsFontSize = 12;
452 aClsTextProp->SetFontSize(aCellsFontSize);
453 aClsTextProp->SetBold(1);
454 aClsTextProp->SetItalic(0);
455 aClsTextProp->SetShadow(0);
456 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
457 aClsTextProp->Delete();
459 myIsCellsLabeled = false;
461 myCellsLabels = vtkActor2D::New();
462 myCellsLabels->SetMapper(myClsLabeledDataMapper);
463 myCellsLabels->GetProperty()->SetColor(0,1,0);
464 myCellsLabels->SetVisibility(myIsCellsLabeled);
467 myImplicitBoolean = vtkImplicitBoolean::New();
468 myImplicitBoolean->SetOperationTypeToIntersection();
472 //Quadratic 2D elements representation
473 //-----------------------------------------------------------------------------
474 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
475 if(aQuadratic2DMode == 0){
476 myHighlitableActor->SetQuadraticArcMode(false);
477 my2DActor->SetQuadraticArcMode(false);
478 my1DActor->SetQuadraticArcMode(false);
480 else if(aQuadratic2DMode == 1){
481 myHighlitableActor->SetQuadraticArcMode(true);
482 my2DActor->SetQuadraticArcMode(true);
483 my1DActor->SetQuadraticArcMode(true);
486 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
487 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
488 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
490 // Set color of the name actor
491 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
492 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
496 SMESH_ActorDef::~SMESH_ActorDef()
498 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
500 myScalarBarActor->Delete();
501 myLookupTable->Delete();
503 mySurfaceProp->Delete();
504 myBackSurfaceProp->Delete();
506 myEdgeProp->Delete();
507 myHighlightProp->Delete();
508 myPreselectProp->Delete();
510 myNodeProp->Delete();
511 myNodeExtProp->Delete();
516 //my0DExtProp->Delete();
517 //my0DExtActor->Delete();
522 my1DExtProp->Delete();
523 my1DExtActor->Delete();
526 my2DExtProp->Delete();
527 my2DExtActor->Delete();
530 myNodeActor->Delete();
531 myBaseActor->Delete();
533 myNodeExtActor->Delete();
535 myHighlitableActor->Delete();
537 //Deleting of points numbering pipeline
538 //---------------------------------------
539 myPointsNumDataSet->Delete();
541 // commented: porting to vtk 5.0
542 // myPtsLabeledDataMapper->RemoveAllInputs();
543 myPtsLabeledDataMapper->Delete();
545 // commented: porting to vtk 5.0
546 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
547 myPtsSelectVisiblePoints->Delete();
549 // commented: porting to vtk 5.0
550 // myPtsMaskPoints->UnRegisterAllOutputs();
551 myPtsMaskPoints->Delete();
553 myPointLabels->Delete();
556 //Deleting of cells numbering pipeline
557 //---------------------------------------
558 myCellsNumDataSet->Delete();
560 myClsLabeledDataMapper->RemoveAllInputs();
561 myClsLabeledDataMapper->Delete();
563 // commented: porting to vtk 5.0
564 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
565 myClsSelectVisiblePoints->Delete();
567 // commented: porting to vtk 5.0
568 // myClsMaskPoints->UnRegisterAllOutputs();
569 myClsMaskPoints->Delete();
571 // commented: porting to vtk 5.0
572 // myCellCenters->UnRegisterAllOutputs();
573 myCellCenters->Delete();
575 myCellsLabels->Delete();
577 myImplicitBoolean->Delete();
579 myTimeStamp->Delete();
583 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
585 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
587 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
589 if ( myIsPointsLabeled )
591 myPointsNumDataSet->ShallowCopy(aGrid);
592 vtkDataSet *aDataSet = myPointsNumDataSet;
594 int aNbElem = aDataSet->GetNumberOfPoints();
596 vtkIntArray *anArray = vtkIntArray::New();
597 anArray->SetNumberOfValues( aNbElem );
599 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
601 int aSMDSId = myVisualObj->GetNodeObjId( anId );
602 anArray->SetValue( anId, aSMDSId );
605 aDataSet->GetPointData()->SetScalars( anArray );
607 myPtsMaskPoints->SetInput( aDataSet );
608 myPointLabels->SetVisibility( GetVisibility() );
612 myPointLabels->SetVisibility( false );
614 SetRepresentation(GetRepresentation());
615 myTimeStamp->Modified();
619 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
621 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
622 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
623 if(myIsCellsLabeled){
624 myCellsNumDataSet->ShallowCopy(aGrid);
625 vtkDataSet *aDataSet = myCellsNumDataSet;
626 int aNbElem = aDataSet->GetNumberOfCells();
627 vtkIntArray *anArray = vtkIntArray::New();
628 anArray->SetNumberOfValues(aNbElem);
629 for(int anId = 0; anId < aNbElem; anId++){
630 int aSMDSId = myVisualObj->GetElemObjId(anId);
631 anArray->SetValue(anId,aSMDSId);
633 aDataSet->GetCellData()->SetScalars(anArray);
634 myCellCenters->SetInput(aDataSet);
635 myCellsLabels->SetVisibility(GetVisibility());
637 myCellsLabels->SetVisibility(false);
639 myTimeStamp->Modified();
643 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
645 myIsFacesOriented = theIsFacesOriented;
647 my2DActor->SetFacesOriented(theIsFacesOriented);
648 my3DActor->SetFacesOriented(theIsFacesOriented);
650 myTimeStamp->Modified();
653 bool SMESH_ActorDef::GetFacesOriented()
655 return myIsFacesOriented;
658 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
660 my2DActor->SetFacesOrientationColor( theColor );
661 my3DActor->SetFacesOrientationColor( theColor );
664 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
666 my3DActor->GetFacesOrientationColor( theColor );
669 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
671 my2DActor->SetFacesOrientationScale( theScale );
672 my3DActor->SetFacesOrientationScale( theScale );
675 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
677 return my3DActor->GetFacesOrientationScale();
680 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
682 my2DActor->SetFacesOrientation3DVectors( theState );
683 my3DActor->SetFacesOrientation3DVectors( theState );
686 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
688 return my3DActor->GetFacesOrientation3DVectors();
694 SetControlMode(eControl theMode)
696 SetControlMode(theMode,true);
702 SetControlMode(eControl theMode,
703 bool theCheckEntityMode)
705 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
709 myControlMode = eNone;
710 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
712 my0DActor->GetMapper()->SetScalarVisibility(false);
713 my1DActor->GetMapper()->SetScalarVisibility(false);
714 my2DActor->GetMapper()->SetScalarVisibility(false);
715 my3DActor->GetMapper()->SetScalarVisibility(false);
716 myScalarBarActor->SetVisibility(false);
718 bool anIsScalarVisible = theMode > eNone;
720 if(anIsScalarVisible){
721 SMESH::Controls::FunctorPtr aFunctor;
725 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
726 aControl->SetPrecision( myControlsPrecision );
727 aFunctor.reset( aControl );
728 myControlActor = my1DActor;
733 aFunctor.reset(new SMESH::Controls::Length2D());
734 myControlActor = my2DActor;
738 aFunctor.reset(new SMESH::Controls::FreeBorders());
739 myControlActor = my1DActor;
742 aFunctor.reset(new SMESH::Controls::FreeEdges());
743 myControlActor = my2DActor;
746 aFunctor.reset(new SMESH::Controls::FreeNodes());
747 myControlActor = myNodeActor;
750 aFunctor.reset(new SMESH::Controls::FreeFaces());
751 myControlActor = my2DActor;
753 case eMultiConnection:
754 aFunctor.reset(new SMESH::Controls::MultiConnection());
755 myControlActor = my1DActor;
757 case eMultiConnection2D:
758 aFunctor.reset(new SMESH::Controls::MultiConnection2D());
759 myControlActor = my2DActor;
763 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
764 aControl->SetPrecision( myControlsPrecision );
765 aFunctor.reset( aControl );
766 myControlActor = my2DActor;
771 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
772 aControl->SetPrecision( myControlsPrecision );
773 aFunctor.reset( aControl );
774 myControlActor = my2DActor;
779 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
780 aControl->SetPrecision( myControlsPrecision );
781 aFunctor.reset( aControl );
782 myControlActor = my2DActor;
787 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
788 aControl->SetPrecision( myControlsPrecision );
789 aFunctor.reset( aControl );
790 myControlActor = my3DActor;
795 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
796 aControl->SetPrecision( myControlsPrecision );
797 aFunctor.reset( aControl );
798 myControlActor = my3DActor;
803 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
804 aControl->SetPrecision( myControlsPrecision );
805 aFunctor.reset( aControl );
806 myControlActor = my2DActor;
811 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
812 aControl->SetPrecision( myControlsPrecision );
813 aFunctor.reset( aControl );
814 myControlActor = my2DActor;
819 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
820 aControl->SetPrecision( myControlsPrecision );
821 aFunctor.reset( aControl );
822 myControlActor = my2DActor;
829 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
830 vtkIdType aNbCells = aGrid->GetNumberOfCells();
832 myControlMode = theMode;
833 switch(myControlMode){
835 myNodeExtActor->SetExtControlMode(aFunctor);
839 my1DExtActor->SetExtControlMode(aFunctor);
842 my2DExtActor->SetExtControlMode(aFunctor);
845 case eMultiConnection2D:
846 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
849 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
853 if(theCheckEntityMode){
854 if(myControlActor == my1DActor)
855 SetEntityMode(eEdges);
856 else if(myControlActor == my2DActor){
857 switch(myControlMode){
861 case eMultiConnection2D:
862 //SetEntityMode(eEdges);
863 SetEntityMode(eFaces);
866 SetEntityMode(eFaces);
868 }else if(myControlActor == my3DActor)
869 SetEntityMode(eVolumes);
872 }else if(theCheckEntityMode){
873 myEntityMode = eAllEntity;
876 SetRepresentation(GetRepresentation());
878 myTimeStamp->Modified();
883 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
884 theRenderer->AddActor(myNodeActor);
885 theRenderer->AddActor(myBaseActor);
887 theRenderer->AddActor(myNodeExtActor);
889 my3DActor->AddToRender(theRenderer);
890 my2DActor->AddToRender(theRenderer);
891 my2DExtActor->AddToRender(theRenderer);
893 theRenderer->AddActor(my1DActor);
894 theRenderer->AddActor(my1DExtActor);
896 theRenderer->AddActor(my0DActor);
897 //theRenderer->AddActor(my0DExtActor);
899 theRenderer->AddActor(myHighlitableActor);
901 theRenderer->AddActor2D(myScalarBarActor);
903 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
904 myClsSelectVisiblePoints->SetRenderer(theRenderer);
906 theRenderer->AddActor2D(myPointLabels);
907 theRenderer->AddActor2D(myCellsLabels);
909 // the superclass' method should be called at the end
910 // (in particular, for correct work of selection)
911 SALOME_Actor::AddToRender(theRenderer);
914 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
915 SALOME_Actor::RemoveFromRender(theRenderer);
917 theRenderer->RemoveActor(myNodeActor);
918 theRenderer->RemoveActor(myBaseActor);
920 theRenderer->RemoveActor(myNodeExtActor);
922 theRenderer->RemoveActor(myHighlitableActor);
924 theRenderer->RemoveActor(my0DActor);
925 //theRenderer->RemoveActor(my0DExtActor);
927 theRenderer->RemoveActor(my1DActor);
928 theRenderer->RemoveActor(my1DExtActor);
930 my2DActor->RemoveFromRender(theRenderer);
931 my2DExtActor->RemoveFromRender(theRenderer);
932 my3DActor->RemoveFromRender(theRenderer);
934 theRenderer->RemoveActor(myScalarBarActor);
935 theRenderer->RemoveActor(myPointLabels);
936 theRenderer->RemoveActor(myCellsLabels);
940 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
941 const char* theEntry,
945 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
949 myVisualObj = theVisualObj;
950 myVisualObj->Update(theIsClear);
952 myNodeActor->Init(myVisualObj,myImplicitBoolean);
953 myBaseActor->Init(myVisualObj,myImplicitBoolean);
955 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
957 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
959 my0DActor->Init(myVisualObj,myImplicitBoolean);
960 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
962 my1DActor->Init(myVisualObj,myImplicitBoolean);
963 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
965 my2DActor->Init(myVisualObj,myImplicitBoolean);
966 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
967 my3DActor->Init(myVisualObj,myImplicitBoolean);
969 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
970 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
972 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
973 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
975 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
976 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
977 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
979 vtkFloatingPointType aFactor, aUnits;
980 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
981 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
982 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
984 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
988 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
989 SetIsShrunkable(true);
991 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
993 int aMode = mgr->integerValue( "SMESH", "display_mode" );
994 SetRepresentation(-1);
997 SetRepresentation(eEdge);
998 }else if(aMode == 1){
999 SetRepresentation(eSurface);
1000 }else if(aMode == 2){
1001 SetRepresentation(ePoint);
1008 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1009 SetIsDisplayNameActor( true );
1011 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1012 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1013 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1015 myTimeStamp->Modified();
1021 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1022 return myNodeActor->GetBounds();
1026 vtkDataSet* SMESH_ActorDef::GetInput(){
1027 return GetUnstructuredGrid();
1031 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1032 Superclass::SetTransform(theTransform);
1034 myNodeActor->SetTransform(theTransform);
1035 myBaseActor->SetTransform(theTransform);
1037 myHighlitableActor->SetTransform(theTransform);
1039 myNodeExtActor->SetTransform(theTransform);
1041 my0DActor->SetTransform(theTransform);
1042 //my0DExtActor->SetTransform(theTransform);
1044 my1DActor->SetTransform(theTransform);
1045 my1DExtActor->SetTransform(theTransform);
1047 my2DActor->SetTransform(theTransform);
1048 my2DExtActor->SetTransform(theTransform);
1049 my3DActor->SetTransform(theTransform);
1055 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1056 vtkLODActor::SetMapper(theMapper);
1060 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1061 SALOME_Actor::ShallowCopy(prop);
1065 vtkMapper* SMESH_ActorDef::GetMapper(){
1066 return myPickableActor->GetMapper();
1070 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1071 return myVisualObj->GetUnstructuredGrid();
1075 bool SMESH_ActorDef::IsInfinitive(){
1076 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1078 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1079 ( aDataSet->GetNumberOfCells() == 1 &&
1080 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1081 return SALOME_Actor::IsInfinitive();
1085 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1086 if ( myIsShrinkable == theShrunkable )
1088 myIsShrinkable = theShrunkable;
1092 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1093 return myBaseActor->GetShrinkFactor();
1096 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1097 myBaseActor->SetShrinkFactor(theValue);
1099 my1DActor->SetShrinkFactor(theValue);
1100 my1DExtActor->SetShrinkFactor(theValue);
1102 my2DActor->SetShrinkFactor(theValue);
1103 my2DExtActor->SetShrinkFactor(theValue);
1104 my3DActor->SetShrinkFactor(theValue);
1109 void SMESH_ActorDef::SetShrink(){
1110 if(!myIsShrinkable) return;
1112 myBaseActor->SetShrink();
1114 my1DActor->SetShrink();
1115 my1DExtActor->SetShrink();
1117 my2DActor->SetShrink();
1118 my2DExtActor->SetShrink();
1119 my3DActor->SetShrink();
1125 void SMESH_ActorDef::UnShrink(){
1126 if(!myIsShrunk) return;
1128 myBaseActor->UnShrink();
1130 my1DActor->UnShrink();
1131 my1DExtActor->UnShrink();
1133 my2DActor->UnShrink();
1134 my2DExtActor->UnShrink();
1135 my3DActor->UnShrink();
1142 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1143 return myPickableActor->GetNodeObjId(theVtkID);
1146 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1147 return myPickableActor->GetNodeCoord(theObjID);
1151 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1152 return myPickableActor->GetElemObjId(theVtkID);
1155 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1156 return myPickableActor->GetElemCell(theObjID);
1160 void SMESH_ActorDef::SetVisibility(int theMode){
1161 SetVisibility(theMode,true);
1165 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1166 SALOME_Actor::SetVisibility(theMode);
1168 myNodeActor->VisibilityOff();
1169 myBaseActor->VisibilityOff();
1171 myNodeExtActor->VisibilityOff();
1173 my0DActor->VisibilityOff();
1174 //my0DExtActor->VisibilityOff();
1176 my1DActor->VisibilityOff();
1177 my1DExtActor->VisibilityOff();
1179 my2DActor->VisibilityOff();
1180 my2DExtActor->VisibilityOff();
1181 my3DActor->VisibilityOff();
1183 myScalarBarActor->VisibilityOff();
1184 myPointLabels->VisibilityOff();
1185 myCellsLabels->VisibilityOff();
1187 if(GetVisibility()){
1188 if(theIsUpdateRepersentation)
1189 SetRepresentation(GetRepresentation());
1191 if(myControlMode != eNone){
1192 switch(myControlMode){
1194 myNodeExtActor->VisibilityOn();
1198 my1DExtActor->VisibilityOn();
1201 my2DExtActor->VisibilityOn();
1204 case eMultiConnection2D:
1205 my1DExtActor->VisibilityOn();
1207 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1208 myScalarBarActor->VisibilityOn();
1212 if(myRepresentation != ePoint)
1213 myPickableActor->VisibilityOn();
1215 myNodeActor->VisibilityOn();
1218 if(myEntityMode & e0DElements){
1219 my0DActor->VisibilityOn();
1222 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1223 my1DActor->VisibilityOn();
1226 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1227 my2DActor->VisibilityOn();
1230 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1231 my3DActor->VisibilityOn();
1234 if(myIsPointsLabeled){
1235 myPointLabels->VisibilityOn();
1236 myNodeActor->VisibilityOn();
1239 if(myIsCellsLabeled)
1240 myCellsLabels->VisibilityOn();
1247 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1249 myEntityState = eAllEntity;
1251 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1252 myEntityState &= ~e0DElements;
1253 theMode &= ~e0DElements;
1256 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1257 myEntityState &= ~eEdges;
1261 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1262 myEntityState &= ~eFaces;
1266 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1267 myEntityState &= ~eVolumes;
1268 theMode &= ~eVolumes;
1272 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1273 theMode |= e0DElements;
1275 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1278 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1281 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1282 theMode |= eVolumes;
1285 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1287 myEntityMode = theMode;
1288 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1289 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1290 aFilter->ClearRegisteredCellsWithType();
1291 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1293 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1294 aHightFilter->ClearRegisteredCellsWithType();
1295 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1297 if (myEntityMode & e0DElements) {
1298 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1299 aFilter->RegisterCellsWithType(VTK_VERTEX);
1300 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1303 if (myEntityMode & eEdges) {
1304 if (MYDEBUG) MESSAGE("EDGES");
1305 aFilter->RegisterCellsWithType(VTK_LINE);
1306 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1308 aHightFilter->RegisterCellsWithType(VTK_LINE);
1309 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1312 if (myEntityMode & eFaces) {
1313 if (MYDEBUG) MESSAGE("FACES");
1314 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1315 aFilter->RegisterCellsWithType(VTK_POLYGON);
1316 aFilter->RegisterCellsWithType(VTK_QUAD);
1317 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1318 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1320 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1321 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1322 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1323 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1324 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1327 if (myEntityMode & eVolumes) {
1328 if (MYDEBUG) MESSAGE("VOLUMES");
1329 aFilter->RegisterCellsWithType(VTK_TETRA);
1330 aFilter->RegisterCellsWithType(VTK_VOXEL);
1331 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1332 aFilter->RegisterCellsWithType(VTK_WEDGE);
1333 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1334 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1335 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1336 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1337 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1339 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1340 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1341 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1342 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1343 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1344 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1345 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1346 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1347 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1350 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1351 SetVisibility(GetVisibility(),false);
1354 void SMESH_ActorDef::SetRepresentation (int theMode)
1356 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1357 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1358 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1361 myRepresentation = eSurface;
1362 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1363 myRepresentation = eEdge;
1364 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1365 myRepresentation = ePoint;
1370 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1373 if (!aNbFaces && !aNbVolumes) return;
1376 myRepresentation = theMode;
1379 if (!GetUnstructuredGrid()->GetNumberOfCells())
1380 myRepresentation = ePoint;
1383 if (myRepresentation == ePoint) {
1391 myPickableActor = myBaseActor;
1392 myNodeActor->SetVisibility(false);
1393 myNodeExtActor->SetVisibility(false);
1394 vtkProperty *aProp = NULL, *aBackProp = NULL;
1395 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1396 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1397 switch (myRepresentation) {
1399 myPickableActor = myNodeActor;
1400 myNodeActor->SetVisibility(true);
1401 aQuadraticMode = SMESH_Actor::eLines;
1402 aProp = aBackProp = myNodeProp;
1403 aReperesent = SMESH_DeviceActor::ePoint;
1406 aProp = aBackProp = myEdgeProp;
1407 aReperesent = SMESH_DeviceActor::eInsideframe;
1410 aProp = mySurfaceProp;
1411 aBackProp = myBackSurfaceProp;
1412 aReperesent = SMESH_DeviceActor::eSurface;
1416 my2DActor->SetProperty(aProp);
1417 my2DActor->SetBackfaceProperty(aBackProp);
1418 my2DActor->SetRepresentation(aReperesent);
1420 if(aQuadraticMode == SMESH_Actor::eLines)
1421 my2DActor->SetQuadraticArcMode(false);
1422 else if(aQuadraticMode == SMESH_Actor::eArcs)
1423 my2DActor->SetQuadraticArcMode(true);
1425 my2DExtActor->SetRepresentation(aReperesent);
1427 my3DActor->SetProperty(aProp);
1428 my3DActor->SetBackfaceProperty(aBackProp);
1429 my3DActor->SetRepresentation(aReperesent);
1431 //my0DExtActor->SetVisibility(false);
1432 my1DExtActor->SetVisibility(false);
1433 my2DExtActor->SetVisibility(false);
1436 //my0DActor->SetProperty(aProp);
1437 //my0DActor->SetBackfaceProperty(aBackProp);
1438 my0DActor->SetRepresentation(aReperesent);
1439 //my0DExtActor->SetRepresentation(aReperesent);
1441 switch(myControlMode){
1443 case eMultiConnection:
1444 aProp = aBackProp = my1DProp;
1445 if(myRepresentation != ePoint)
1446 aReperesent = SMESH_DeviceActor::eInsideframe;
1450 if(aQuadraticMode == SMESH_Actor::eLines)
1451 my1DActor->SetQuadraticArcMode(false);
1452 else if(aQuadraticMode == SMESH_Actor::eArcs)
1453 my1DActor->SetQuadraticArcMode(true);
1455 my1DActor->SetProperty(aProp);
1456 my1DActor->SetBackfaceProperty(aBackProp);
1457 my1DActor->SetRepresentation(aReperesent);
1459 my1DExtActor->SetRepresentation(aReperesent);
1461 if(myIsPointsVisible)
1462 myPickableActor = myNodeActor;
1463 if(GetPointRepresentation())
1464 myNodeActor->SetVisibility(true);
1466 SetMapper(myPickableActor->GetMapper());
1468 SetVisibility(GetVisibility(),false);
1474 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1475 if ( myIsPointsVisible == theIsPointsVisible )
1477 myIsPointsVisible = theIsPointsVisible;
1478 SetRepresentation(GetRepresentation());
1481 bool SMESH_ActorDef::GetPointRepresentation(){
1482 return myIsPointsVisible || myIsPointsLabeled;
1486 void SMESH_ActorDef::UpdateHighlight(){
1487 myHighlitableActor->SetVisibility(false);
1488 myHighlitableActor->SetHighlited(false);
1490 if(myIsHighlighted){
1491 myHighlitableActor->SetProperty(myHighlightProp);
1492 }else if(myIsPreselected){
1493 myHighlitableActor->SetProperty(myPreselectProp);
1496 bool anIsVisible = GetVisibility();
1498 if(myIsHighlighted || myIsPreselected){
1499 if(GetUnstructuredGrid()->GetNumberOfCells()){
1500 myHighlitableActor->SetHighlited(anIsVisible);
1501 myHighlitableActor->SetVisibility(anIsVisible);
1502 myHighlitableActor->GetExtractUnstructuredGrid()->
1503 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1504 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1505 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1506 myHighlitableActor->SetHighlited(anIsVisible);
1507 myHighlitableActor->GetExtractUnstructuredGrid()->
1508 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1509 myHighlitableActor->SetVisibility(anIsVisible);
1510 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1512 VTK::MarkerType aMarkerType = GetMarkerType();
1513 if(aMarkerType != VTK::MT_USER)
1514 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1516 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1522 void SMESH_ActorDef::highlight(bool theHighlight){
1523 if ( myIsHighlighted == theHighlight )
1525 myIsHighlighted = theHighlight;
1530 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1531 if ( myIsPreselected == thePreselect )
1533 myIsPreselected = thePreselect;
1539 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1541 if (myPickableActor->GetIsOpaque())
1543 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1551 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1553 if (!myPickableActor->GetIsOpaque())
1555 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1563 void SMESH_ActorDef::Render(vtkRenderer *ren){
1564 unsigned long aTime = myTimeStamp->GetMTime();
1565 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1566 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1567 if(anObjTime > aTime || aClippingTime > aTime)
1572 void SMESH_ActorDef::Update(){
1573 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1575 if(GetControlMode() != eNone) {
1576 unsigned long aTime = myTimeStamp->GetMTime();
1577 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1578 if (anObjTime > aTime)
1579 SetControlMode(GetControlMode(),false);
1581 if(myIsPointsLabeled){
1582 SetPointsLabeled(myIsPointsLabeled);
1584 if(myIsCellsLabeled){
1585 SetCellsLabeled(myIsCellsLabeled);
1587 if(myIsFacesOriented){
1588 SetFacesOriented(myIsFacesOriented);
1590 SetEntityMode(GetEntityMode());
1591 SetVisibility(GetVisibility());
1593 myTimeStamp->Modified();
1598 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1599 SALOME_Actor::ReleaseGraphicsResources(renWin);
1601 myPickableActor->ReleaseGraphicsResources(renWin);
1605 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1606 vtkFloatingPointType* aColor = theProperty->GetColor();
1613 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1614 mySurfaceProp->SetOpacity(theValue);
1615 myBackSurfaceProp->SetOpacity(theValue);
1616 myEdgeProp->SetOpacity(theValue);
1617 myNodeProp->SetOpacity(theValue);
1619 my1DProp->SetOpacity(theValue);
1623 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1624 return mySurfaceProp->GetOpacity();
1628 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1629 mySurfaceProp->SetColor(r,g,b);
1630 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1631 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1632 aGroupObj->GetElementType() == SMDSAbs_Volume )
1633 myNameActor->SetBackgroundColor(r,g,b);
1637 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1638 ::GetColor(mySurfaceProp,r,g,b);
1639 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1642 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1643 myBackSurfaceProp->SetColor(r,g,b);
1647 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1648 ::GetColor(myBackSurfaceProp,r,g,b);
1651 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1652 myEdgeProp->SetColor(r,g,b);
1653 my1DProp->SetColor(r,g,b);
1654 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1655 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1656 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1657 myNameActor->SetBackgroundColor(r,g,b);
1661 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1662 ::GetColor(myEdgeProp,r,g,b);
1665 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1666 myNodeProp->SetColor(r,g,b);
1667 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1668 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1669 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1670 myNameActor->SetBackgroundColor(r,g,b);
1674 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1675 ::GetColor(myNodeProp,r,g,b);
1678 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1679 my0DProp->SetColor(r,g,b);
1683 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1684 ::GetColor(my0DProp,r,g,b);
1687 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1688 myHighlightProp->SetColor(r,g,b);
1692 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1693 ::GetColor(myHighlightProp,r,g,b);
1696 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1697 myPreselectProp->SetColor(r,g,b);
1701 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1702 ::GetColor(myPreselectProp,r,g,b);
1706 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1707 return myEdgeProp->GetLineWidth();
1711 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1712 myEdgeProp->SetLineWidth(theVal);
1714 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1715 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1721 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1722 my0DProp->SetPointSize(theVal);
1726 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1727 return my0DProp->GetPointSize();
1730 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1732 return myVisualObj->GetElemDimension( theObjId );
1737 IsImplicitFunctionUsed() const
1739 return myBaseActor->IsImplicitFunctionUsed();
1743 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1745 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1746 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1748 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1750 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1752 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1753 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1755 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1756 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1758 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1759 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1760 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1764 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1767 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1768 myCippingPlaneCont.push_back(thePlane);
1769 if(!IsImplicitFunctionUsed())
1770 SetImplicitFunctionUsed(true);
1772 return myCippingPlaneCont.size();
1777 RemoveAllClippingPlanes()
1779 myImplicitBoolean->GetFunction()->RemoveAllItems();
1780 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1781 myCippingPlaneCont.clear();
1782 SetImplicitFunctionUsed(false);
1787 GetNumberOfClippingPlanes()
1789 return myCippingPlaneCont.size();
1794 GetClippingPlane(vtkIdType theID)
1796 if(theID >= myCippingPlaneCont.size())
1798 return myCippingPlaneCont[theID].Get();
1802 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1803 vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1804 vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1806 vtkFloatingPointType aBounds[6];
1807 theDataSet->GetBounds(aBounds);
1809 //Enlarge bounds in order to avoid conflicts of precision
1810 for(int i = 0; i < 6; i += 2){
1811 static double EPS = 1.0E-3;
1812 vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1813 aBounds[i] -= aDelta;
1814 aBounds[i+1] += aDelta;
1817 vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1818 {aBounds[1],aBounds[2],aBounds[4]},
1819 {aBounds[0],aBounds[3],aBounds[4]},
1820 {aBounds[1],aBounds[3],aBounds[4]},
1821 {aBounds[0],aBounds[2],aBounds[5]},
1822 {aBounds[1],aBounds[2],aBounds[5]},
1823 {aBounds[0],aBounds[3],aBounds[5]},
1824 {aBounds[1],aBounds[3],aBounds[5]}};
1826 int aMaxId = 0, aMinId = aMaxId;
1827 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1828 theMinBoundPrj = theMaxBoundPrj;
1829 for(int i = 1; i < 8; i++){
1830 vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1831 if(theMaxBoundPrj < aTmp){
1832 theMaxBoundPrj = aTmp;
1835 if(theMinBoundPrj > aTmp){
1836 theMinBoundPrj = aTmp;
1840 vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1841 theMinPnt[0] = aMinPnt[0];
1842 theMinPnt[1] = aMinPnt[1];
1843 theMinPnt[2] = aMinPnt[2];
1847 static void DistanceToPosition(vtkDataSet* theDataSet,
1848 vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1850 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1851 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1852 vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1853 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1854 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1855 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1859 static void PositionToDistance(vtkDataSet* theDataSet,
1860 vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1862 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1863 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1864 vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1865 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1869 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1871 thePlane->SetNormal(theDir);
1872 vtkFloatingPointType anOrigin[3];
1873 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1874 thePlane->SetOrigin(anOrigin);
1878 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1880 thePlane->GetNormal(theDir);
1882 vtkFloatingPointType anOrigin[3];
1883 thePlane->GetOrigin(anOrigin);
1884 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1887 void SMESH_ActorDef::UpdateScalarBar()
1889 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1893 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1895 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1896 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1898 aScalarBarTitleProp->SetFontFamilyToArial();
1900 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1902 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1903 if ( f.family() == "Arial" )
1904 aScalarBarTitleProp->SetFontFamilyToArial();
1905 else if ( f.family() == "Courier" )
1906 aScalarBarTitleProp->SetFontFamilyToCourier();
1907 else if ( f.family() == "Times" )
1908 aScalarBarTitleProp->SetFontFamilyToTimes();
1911 aScalarBarTitleProp->BoldOn();
1913 aScalarBarTitleProp->BoldOff();
1916 aScalarBarTitleProp->ItalicOn();
1918 aScalarBarTitleProp->ItalicOff();
1921 aScalarBarTitleProp->ShadowOn();
1923 aScalarBarTitleProp->ShadowOff();
1926 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1927 aScalarBarTitleProp->Delete();
1929 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1931 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1932 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1934 aScalarBarLabelProp->SetFontFamilyToArial();
1935 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1937 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1938 if( f.family() == "Arial" )
1939 aScalarBarLabelProp->SetFontFamilyToArial();
1940 else if( f.family() == "Courier" )
1941 aScalarBarLabelProp->SetFontFamilyToCourier();
1942 else if( f.family() == "Times" )
1943 aScalarBarLabelProp->SetFontFamilyToTimes();
1946 aScalarBarLabelProp->BoldOn();
1948 aScalarBarLabelProp->BoldOff();
1951 aScalarBarLabelProp->ItalicOn();
1953 aScalarBarLabelProp->ItalicOff();
1956 aScalarBarLabelProp->ShadowOn();
1958 aScalarBarLabelProp->ShadowOff();
1961 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1962 aScalarBarLabelProp->Delete();
1964 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1965 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1967 myScalarBarActor->SetOrientationToHorizontal();
1969 myScalarBarActor->SetOrientationToVertical();
1972 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1973 if( mgr->hasValue( "SMESH", name + "x" ) )
1974 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1976 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1977 if( mgr->hasValue( "SMESH", name + "y" ) )
1978 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1979 myScalarBarActor->SetPosition( aXVal, aYVal );
1981 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1982 if( mgr->hasValue( "SMESH", name + "width" ) )
1983 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1984 myScalarBarActor->SetWidth( aWVal );
1986 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1987 if( mgr->hasValue( "SMESH", name + "height" ) )
1988 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1989 myScalarBarActor->SetHeight( aHVal );
1992 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1993 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1994 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1997 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1998 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1999 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2003 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2006 case SMESH_Actor::eLines :
2007 myHighlitableActor->SetQuadraticArcMode(false);
2008 my2DActor->SetQuadraticArcMode(false);
2009 my1DActor->SetQuadraticArcMode(false);
2011 case SMESH_Actor::eArcs :
2012 myHighlitableActor->SetQuadraticArcMode(true);
2013 if(GetRepresentation() != SMESH_Actor::ePoint) {
2014 my2DActor->SetQuadraticArcMode(true);
2015 my1DActor->SetQuadraticArcMode(true);
2024 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2026 if(myHighlitableActor->GetQuadraticArcMode())
2027 return SMESH_Actor::eArcs;
2029 return SMESH_Actor::eLines;
2032 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2034 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2035 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2036 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2039 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2041 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2042 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2043 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2044 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor