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){
724 SMESH::Controls::FunctorPtr aFunctor;
728 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
729 aControl->SetPrecision( myControlsPrecision );
730 aFunctor.reset( aControl );
731 myControlActor = my1DActor;
736 aFunctor.reset(new SMESH::Controls::Length2D());
737 myControlActor = my2DActor;
741 aFunctor.reset(new SMESH::Controls::FreeBorders());
742 myControlActor = my1DActor;
745 aFunctor.reset(new SMESH::Controls::FreeEdges());
746 myControlActor = my2DActor;
749 aFunctor.reset(new SMESH::Controls::FreeNodes());
750 myControlActor = myNodeActor;
753 aFunctor.reset(new SMESH::Controls::FreeFaces());
754 myControlActor = my2DActor;
756 case eMultiConnection:
757 aFunctor.reset(new SMESH::Controls::MultiConnection());
758 myControlActor = my1DActor;
760 case eMultiConnection2D:
761 aFunctor.reset(new SMESH::Controls::MultiConnection2D());
762 myControlActor = my2DActor;
766 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
767 aControl->SetPrecision( myControlsPrecision );
768 aFunctor.reset( aControl );
769 myControlActor = my2DActor;
774 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
775 aControl->SetPrecision( myControlsPrecision );
776 aFunctor.reset( aControl );
777 myControlActor = my2DActor;
782 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
783 aControl->SetPrecision( myControlsPrecision );
784 aFunctor.reset( aControl );
785 myControlActor = my2DActor;
790 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
791 aControl->SetPrecision( myControlsPrecision );
792 aFunctor.reset( aControl );
793 myControlActor = my3DActor;
798 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
799 aControl->SetPrecision( myControlsPrecision );
800 aFunctor.reset( aControl );
801 myControlActor = my3DActor;
806 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
807 aControl->SetPrecision( myControlsPrecision );
808 aFunctor.reset( aControl );
809 myControlActor = my2DActor;
814 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
815 aControl->SetPrecision( myControlsPrecision );
816 aFunctor.reset( aControl );
817 myControlActor = my2DActor;
822 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
823 aControl->SetPrecision( myControlsPrecision );
824 aFunctor.reset( aControl );
825 myControlActor = my2DActor;
832 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
833 vtkIdType aNbCells = aGrid->GetNumberOfCells();
835 myControlMode = theMode;
836 switch(myControlMode){
838 myNodeExtActor->SetExtControlMode(aFunctor);
842 my1DExtActor->SetExtControlMode(aFunctor);
845 my2DExtActor->SetExtControlMode(aFunctor);
848 case eMultiConnection2D:
849 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
852 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
856 if(theCheckEntityMode){
857 if(myControlActor == my1DActor)
858 SetEntityMode(eEdges);
859 else if(myControlActor == my2DActor){
860 switch(myControlMode){
864 case eMultiConnection2D:
865 //SetEntityMode(eEdges);
866 SetEntityMode(eFaces);
869 SetEntityMode(eFaces);
871 }else if(myControlActor == my3DActor)
872 SetEntityMode(eVolumes);
875 }else if(theCheckEntityMode){
876 myEntityMode = eAllEntity;
879 SetRepresentation(GetRepresentation());
881 myTimeStamp->Modified();
886 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
887 theRenderer->AddActor(myNodeActor);
888 theRenderer->AddActor(myBaseActor);
890 theRenderer->AddActor(myNodeExtActor);
892 my3DActor->AddToRender(theRenderer);
893 my2DActor->AddToRender(theRenderer);
894 my2DExtActor->AddToRender(theRenderer);
896 theRenderer->AddActor(my1DActor);
897 theRenderer->AddActor(my1DExtActor);
899 theRenderer->AddActor(my0DActor);
900 //theRenderer->AddActor(my0DExtActor);
902 theRenderer->AddActor(myHighlitableActor);
904 theRenderer->AddActor2D(myScalarBarActor);
906 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
907 myClsSelectVisiblePoints->SetRenderer(theRenderer);
909 theRenderer->AddActor2D(myPointLabels);
910 theRenderer->AddActor2D(myCellsLabels);
912 // the superclass' method should be called at the end
913 // (in particular, for correct work of selection)
914 SALOME_Actor::AddToRender(theRenderer);
917 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
918 SALOME_Actor::RemoveFromRender(theRenderer);
920 theRenderer->RemoveActor(myNodeActor);
921 theRenderer->RemoveActor(myBaseActor);
923 theRenderer->RemoveActor(myNodeExtActor);
925 theRenderer->RemoveActor(myHighlitableActor);
927 theRenderer->RemoveActor(my0DActor);
928 //theRenderer->RemoveActor(my0DExtActor);
930 theRenderer->RemoveActor(my1DActor);
931 theRenderer->RemoveActor(my1DExtActor);
933 my2DActor->RemoveFromRender(theRenderer);
934 my2DExtActor->RemoveFromRender(theRenderer);
935 my3DActor->RemoveFromRender(theRenderer);
937 theRenderer->RemoveActor(myScalarBarActor);
938 theRenderer->RemoveActor(myPointLabels);
939 theRenderer->RemoveActor(myCellsLabels);
943 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
944 const char* theEntry,
948 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
952 myVisualObj = theVisualObj;
953 myVisualObj->Update(theIsClear);
955 myNodeActor->Init(myVisualObj,myImplicitBoolean);
956 myBaseActor->Init(myVisualObj,myImplicitBoolean);
958 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
960 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
962 my0DActor->Init(myVisualObj,myImplicitBoolean);
963 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
965 my1DActor->Init(myVisualObj,myImplicitBoolean);
966 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
968 my2DActor->Init(myVisualObj,myImplicitBoolean);
969 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
970 my3DActor->Init(myVisualObj,myImplicitBoolean);
972 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
973 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
975 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
976 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
978 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
979 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
980 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
982 vtkFloatingPointType aFactor, aUnits;
983 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
984 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
985 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
987 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
991 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
992 SetIsShrunkable(true);
994 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
996 int aMode = mgr->integerValue( "SMESH", "display_mode" );
997 SetRepresentation(-1);
1000 SetRepresentation(eEdge);
1001 }else if(aMode == 1){
1002 SetRepresentation(eSurface);
1003 }else if(aMode == 2){
1004 SetRepresentation(ePoint);
1011 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1012 SetIsDisplayNameActor( true );
1014 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1015 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1016 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1018 myTimeStamp->Modified();
1024 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1025 return myNodeActor->GetBounds();
1029 vtkDataSet* SMESH_ActorDef::GetInput(){
1030 return GetUnstructuredGrid();
1034 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1035 Superclass::SetTransform(theTransform);
1037 myNodeActor->SetTransform(theTransform);
1038 myBaseActor->SetTransform(theTransform);
1040 myHighlitableActor->SetTransform(theTransform);
1042 myNodeExtActor->SetTransform(theTransform);
1044 my0DActor->SetTransform(theTransform);
1045 //my0DExtActor->SetTransform(theTransform);
1047 my1DActor->SetTransform(theTransform);
1048 my1DExtActor->SetTransform(theTransform);
1050 my2DActor->SetTransform(theTransform);
1051 my2DExtActor->SetTransform(theTransform);
1052 my3DActor->SetTransform(theTransform);
1058 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1059 vtkLODActor::SetMapper(theMapper);
1063 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1064 SALOME_Actor::ShallowCopy(prop);
1068 vtkMapper* SMESH_ActorDef::GetMapper(){
1069 return myPickableActor->GetMapper();
1073 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1074 return myVisualObj->GetUnstructuredGrid();
1078 bool SMESH_ActorDef::IsInfinitive(){
1079 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1081 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1082 ( aDataSet->GetNumberOfCells() == 1 &&
1083 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1084 return SALOME_Actor::IsInfinitive();
1088 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1089 if ( myIsShrinkable == theShrunkable )
1091 myIsShrinkable = theShrunkable;
1095 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1096 return myBaseActor->GetShrinkFactor();
1099 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1100 myBaseActor->SetShrinkFactor(theValue);
1102 my1DActor->SetShrinkFactor(theValue);
1103 my1DExtActor->SetShrinkFactor(theValue);
1105 my2DActor->SetShrinkFactor(theValue);
1106 my2DExtActor->SetShrinkFactor(theValue);
1107 my3DActor->SetShrinkFactor(theValue);
1112 void SMESH_ActorDef::SetShrink(){
1113 if(!myIsShrinkable) return;
1115 myBaseActor->SetShrink();
1117 my1DActor->SetShrink();
1118 my1DExtActor->SetShrink();
1120 my2DActor->SetShrink();
1121 my2DExtActor->SetShrink();
1122 my3DActor->SetShrink();
1128 void SMESH_ActorDef::UnShrink(){
1129 if(!myIsShrunk) return;
1131 myBaseActor->UnShrink();
1133 my1DActor->UnShrink();
1134 my1DExtActor->UnShrink();
1136 my2DActor->UnShrink();
1137 my2DExtActor->UnShrink();
1138 my3DActor->UnShrink();
1145 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1146 return myPickableActor->GetNodeObjId(theVtkID);
1149 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1150 return myPickableActor->GetNodeCoord(theObjID);
1154 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1155 return myPickableActor->GetElemObjId(theVtkID);
1158 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1159 return myPickableActor->GetElemCell(theObjID);
1163 void SMESH_ActorDef::SetVisibility(int theMode){
1164 SetVisibility(theMode,true);
1168 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1169 SALOME_Actor::SetVisibility(theMode);
1171 myNodeActor->VisibilityOff();
1172 myBaseActor->VisibilityOff();
1174 myNodeExtActor->VisibilityOff();
1176 my0DActor->VisibilityOff();
1177 //my0DExtActor->VisibilityOff();
1179 my1DActor->VisibilityOff();
1180 my1DExtActor->VisibilityOff();
1182 my2DActor->VisibilityOff();
1183 my2DExtActor->VisibilityOff();
1184 my3DActor->VisibilityOff();
1186 myScalarBarActor->VisibilityOff();
1187 myPointLabels->VisibilityOff();
1188 myCellsLabels->VisibilityOff();
1190 if(GetVisibility()){
1191 if(theIsUpdateRepersentation)
1192 SetRepresentation(GetRepresentation());
1194 if(myControlMode != eNone){
1195 switch(myControlMode){
1197 myNodeExtActor->VisibilityOn();
1201 my1DExtActor->VisibilityOn();
1204 my2DExtActor->VisibilityOn();
1207 case eMultiConnection2D:
1208 my1DExtActor->VisibilityOn();
1210 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1211 myScalarBarActor->VisibilityOn();
1215 if(myRepresentation != ePoint)
1216 myPickableActor->VisibilityOn();
1218 myNodeActor->VisibilityOn();
1221 if(myEntityMode & e0DElements){
1222 my0DActor->VisibilityOn();
1225 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1226 my1DActor->VisibilityOn();
1229 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1230 my2DActor->VisibilityOn();
1233 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1234 my3DActor->VisibilityOn();
1237 if(myIsPointsLabeled){
1238 myPointLabels->VisibilityOn();
1239 myNodeActor->VisibilityOn();
1242 if(myIsCellsLabeled)
1243 myCellsLabels->VisibilityOn();
1250 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1252 myEntityState = eAllEntity;
1254 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1255 myEntityState &= ~e0DElements;
1256 theMode &= ~e0DElements;
1259 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1260 myEntityState &= ~eEdges;
1264 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1265 myEntityState &= ~eFaces;
1269 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1270 myEntityState &= ~eVolumes;
1271 theMode &= ~eVolumes;
1275 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1276 theMode |= e0DElements;
1278 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1281 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1284 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1285 theMode |= eVolumes;
1288 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1290 myEntityMode = theMode;
1291 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1292 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1293 aFilter->ClearRegisteredCellsWithType();
1294 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1296 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1297 aHightFilter->ClearRegisteredCellsWithType();
1298 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1300 if (myEntityMode & e0DElements) {
1301 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1302 aFilter->RegisterCellsWithType(VTK_VERTEX);
1303 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1306 if (myEntityMode & eEdges) {
1307 if (MYDEBUG) MESSAGE("EDGES");
1308 aFilter->RegisterCellsWithType(VTK_LINE);
1309 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1311 aHightFilter->RegisterCellsWithType(VTK_LINE);
1312 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1315 if (myEntityMode & eFaces) {
1316 if (MYDEBUG) MESSAGE("FACES");
1317 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1318 aFilter->RegisterCellsWithType(VTK_POLYGON);
1319 aFilter->RegisterCellsWithType(VTK_QUAD);
1320 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1321 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1323 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1324 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1325 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1326 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1327 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1330 if (myEntityMode & eVolumes) {
1331 if (MYDEBUG) MESSAGE("VOLUMES");
1332 aFilter->RegisterCellsWithType(VTK_TETRA);
1333 aFilter->RegisterCellsWithType(VTK_VOXEL);
1334 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1335 aFilter->RegisterCellsWithType(VTK_WEDGE);
1336 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1337 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1338 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1339 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1340 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1342 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1343 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1344 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1345 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1346 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1347 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1348 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1349 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1350 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1351 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1354 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1355 SetVisibility(GetVisibility(),false);
1358 void SMESH_ActorDef::SetRepresentation (int theMode)
1360 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1361 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1362 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1365 myRepresentation = eSurface;
1366 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1367 myRepresentation = eEdge;
1368 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1369 myRepresentation = ePoint;
1374 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1377 if (!aNbFaces && !aNbVolumes) return;
1380 myRepresentation = theMode;
1383 if (!GetUnstructuredGrid()->GetNumberOfCells())
1384 myRepresentation = ePoint;
1387 if (myRepresentation == ePoint) {
1395 myPickableActor = myBaseActor;
1396 myNodeActor->SetVisibility(false);
1397 myNodeExtActor->SetVisibility(false);
1398 vtkProperty *aProp = NULL, *aBackProp = NULL;
1399 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1400 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1401 switch (myRepresentation) {
1403 myPickableActor = myNodeActor;
1404 myNodeActor->SetVisibility(true);
1405 aQuadraticMode = SMESH_Actor::eLines;
1406 aProp = aBackProp = myNodeProp;
1407 aReperesent = SMESH_DeviceActor::ePoint;
1410 aProp = aBackProp = myEdgeProp;
1411 aReperesent = SMESH_DeviceActor::eInsideframe;
1414 aProp = mySurfaceProp;
1415 aBackProp = myBackSurfaceProp;
1416 aReperesent = SMESH_DeviceActor::eSurface;
1420 my2DActor->SetProperty(aProp);
1421 my2DActor->SetBackfaceProperty(aBackProp);
1422 my2DActor->SetRepresentation(aReperesent);
1424 if(aQuadraticMode == SMESH_Actor::eLines)
1425 my2DActor->SetQuadraticArcMode(false);
1426 else if(aQuadraticMode == SMESH_Actor::eArcs)
1427 my2DActor->SetQuadraticArcMode(true);
1429 my2DExtActor->SetRepresentation(aReperesent);
1431 my3DActor->SetProperty(aProp);
1432 my3DActor->SetBackfaceProperty(aBackProp);
1433 my3DActor->SetRepresentation(aReperesent);
1435 //my0DExtActor->SetVisibility(false);
1436 my1DExtActor->SetVisibility(false);
1437 my2DExtActor->SetVisibility(false);
1440 //my0DActor->SetProperty(aProp);
1441 //my0DActor->SetBackfaceProperty(aBackProp);
1442 my0DActor->SetRepresentation(aReperesent);
1443 //my0DExtActor->SetRepresentation(aReperesent);
1445 switch(myControlMode){
1447 case eMultiConnection:
1448 aProp = aBackProp = my1DProp;
1449 if(myRepresentation != ePoint)
1450 aReperesent = SMESH_DeviceActor::eInsideframe;
1454 if(aQuadraticMode == SMESH_Actor::eLines)
1455 my1DActor->SetQuadraticArcMode(false);
1456 else if(aQuadraticMode == SMESH_Actor::eArcs)
1457 my1DActor->SetQuadraticArcMode(true);
1459 my1DActor->SetProperty(aProp);
1460 my1DActor->SetBackfaceProperty(aBackProp);
1461 my1DActor->SetRepresentation(aReperesent);
1463 my1DExtActor->SetRepresentation(aReperesent);
1465 if(myIsPointsVisible)
1466 myPickableActor = myNodeActor;
1467 if(GetPointRepresentation())
1468 myNodeActor->SetVisibility(true);
1470 SetMapper(myPickableActor->GetMapper());
1472 SetVisibility(GetVisibility(),false);
1478 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1479 if ( myIsPointsVisible == theIsPointsVisible )
1481 myIsPointsVisible = theIsPointsVisible;
1482 SetRepresentation(GetRepresentation());
1485 bool SMESH_ActorDef::GetPointRepresentation(){
1486 return myIsPointsVisible || myIsPointsLabeled;
1490 void SMESH_ActorDef::UpdateHighlight(){
1491 myHighlitableActor->SetVisibility(false);
1492 myHighlitableActor->SetHighlited(false);
1494 if(myIsHighlighted){
1495 myHighlitableActor->SetProperty(myHighlightProp);
1496 }else if(myIsPreselected){
1497 myHighlitableActor->SetProperty(myPreselectProp);
1500 bool anIsVisible = GetVisibility();
1502 if(myIsHighlighted || myIsPreselected){
1503 if(GetUnstructuredGrid()->GetNumberOfCells()){
1504 myHighlitableActor->SetHighlited(anIsVisible);
1505 myHighlitableActor->SetVisibility(anIsVisible);
1506 myHighlitableActor->GetExtractUnstructuredGrid()->
1507 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1508 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1509 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1510 myHighlitableActor->SetHighlited(anIsVisible);
1511 myHighlitableActor->GetExtractUnstructuredGrid()->
1512 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1513 myHighlitableActor->SetVisibility(anIsVisible);
1514 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1516 VTK::MarkerType aMarkerType = GetMarkerType();
1517 if(aMarkerType != VTK::MT_USER)
1518 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1520 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1526 void SMESH_ActorDef::highlight(bool theHighlight){
1527 if ( myIsHighlighted == theHighlight )
1529 myIsHighlighted = theHighlight;
1534 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1535 if ( myIsPreselected == thePreselect )
1537 myIsPreselected = thePreselect;
1543 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1545 if (myPickableActor->GetIsOpaque())
1547 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1555 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1557 if (!myPickableActor->GetIsOpaque())
1559 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1567 void SMESH_ActorDef::Render(vtkRenderer *ren){
1568 unsigned long aTime = myTimeStamp->GetMTime();
1569 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1570 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1571 if(anObjTime > aTime || aClippingTime > aTime)
1576 void SMESH_ActorDef::Update(){
1577 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1579 if(GetControlMode() != eNone) {
1580 unsigned long aTime = myTimeStamp->GetMTime();
1581 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1582 if (anObjTime > aTime)
1583 SetControlMode(GetControlMode(),false);
1585 if(myIsPointsLabeled){
1586 SetPointsLabeled(myIsPointsLabeled);
1588 if(myIsCellsLabeled){
1589 SetCellsLabeled(myIsCellsLabeled);
1591 if(myIsFacesOriented){
1592 SetFacesOriented(myIsFacesOriented);
1594 SetEntityMode(GetEntityMode());
1595 SetVisibility(GetVisibility());
1597 myTimeStamp->Modified();
1602 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1603 SALOME_Actor::ReleaseGraphicsResources(renWin);
1605 myPickableActor->ReleaseGraphicsResources(renWin);
1609 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1610 vtkFloatingPointType* aColor = theProperty->GetColor();
1617 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1618 mySurfaceProp->SetOpacity(theValue);
1619 myBackSurfaceProp->SetOpacity(theValue);
1620 myEdgeProp->SetOpacity(theValue);
1621 myNodeProp->SetOpacity(theValue);
1623 my1DProp->SetOpacity(theValue);
1627 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1628 return mySurfaceProp->GetOpacity();
1632 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1633 mySurfaceProp->SetColor(r,g,b);
1634 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1635 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1636 aGroupObj->GetElementType() == SMDSAbs_Volume )
1637 myNameActor->SetBackgroundColor(r,g,b);
1641 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1642 ::GetColor(mySurfaceProp,r,g,b);
1643 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1646 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1647 myBackSurfaceProp->SetColor(r,g,b);
1651 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1652 ::GetColor(myBackSurfaceProp,r,g,b);
1655 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1656 myEdgeProp->SetColor(r,g,b);
1657 my1DProp->SetColor(r,g,b);
1658 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1659 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1660 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1661 myNameActor->SetBackgroundColor(r,g,b);
1665 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1666 ::GetColor(myEdgeProp,r,g,b);
1669 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1670 myNodeProp->SetColor(r,g,b);
1671 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1672 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1673 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1674 myNameActor->SetBackgroundColor(r,g,b);
1678 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1679 ::GetColor(myNodeProp,r,g,b);
1682 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1683 my0DProp->SetColor(r,g,b);
1684 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1685 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1686 myNameActor->SetBackgroundColor(r,g,b);
1690 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1691 ::GetColor(my0DProp,r,g,b);
1694 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1695 myHighlightProp->SetColor(r,g,b);
1699 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1700 ::GetColor(myHighlightProp,r,g,b);
1703 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1704 myPreselectProp->SetColor(r,g,b);
1708 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1709 ::GetColor(myPreselectProp,r,g,b);
1713 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1714 return myEdgeProp->GetLineWidth();
1718 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1719 myEdgeProp->SetLineWidth(theVal);
1721 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1722 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1728 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1729 my0DProp->SetPointSize(theVal);
1733 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1734 return my0DProp->GetPointSize();
1737 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1739 return myVisualObj->GetElemDimension( theObjId );
1744 IsImplicitFunctionUsed() const
1746 return myBaseActor->IsImplicitFunctionUsed();
1750 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1752 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1753 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1755 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1757 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1759 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1760 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1762 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1763 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1765 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1766 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1767 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1771 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1774 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1775 myCippingPlaneCont.push_back(thePlane);
1776 if(!IsImplicitFunctionUsed())
1777 SetImplicitFunctionUsed(true);
1779 return myCippingPlaneCont.size();
1784 RemoveAllClippingPlanes()
1786 myImplicitBoolean->GetFunction()->RemoveAllItems();
1787 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1788 myCippingPlaneCont.clear();
1789 SetImplicitFunctionUsed(false);
1794 GetNumberOfClippingPlanes()
1796 return myCippingPlaneCont.size();
1801 GetClippingPlane(vtkIdType theID)
1803 if(theID >= myCippingPlaneCont.size())
1805 return myCippingPlaneCont[theID].Get();
1809 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1810 vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1811 vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1813 vtkFloatingPointType aBounds[6];
1814 theDataSet->GetBounds(aBounds);
1816 //Enlarge bounds in order to avoid conflicts of precision
1817 for(int i = 0; i < 6; i += 2){
1818 static double EPS = 1.0E-3;
1819 vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1820 aBounds[i] -= aDelta;
1821 aBounds[i+1] += aDelta;
1824 vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1825 {aBounds[1],aBounds[2],aBounds[4]},
1826 {aBounds[0],aBounds[3],aBounds[4]},
1827 {aBounds[1],aBounds[3],aBounds[4]},
1828 {aBounds[0],aBounds[2],aBounds[5]},
1829 {aBounds[1],aBounds[2],aBounds[5]},
1830 {aBounds[0],aBounds[3],aBounds[5]},
1831 {aBounds[1],aBounds[3],aBounds[5]}};
1833 int aMaxId = 0, aMinId = aMaxId;
1834 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1835 theMinBoundPrj = theMaxBoundPrj;
1836 for(int i = 1; i < 8; i++){
1837 vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1838 if(theMaxBoundPrj < aTmp){
1839 theMaxBoundPrj = aTmp;
1842 if(theMinBoundPrj > aTmp){
1843 theMinBoundPrj = aTmp;
1847 vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1848 theMinPnt[0] = aMinPnt[0];
1849 theMinPnt[1] = aMinPnt[1];
1850 theMinPnt[2] = aMinPnt[2];
1854 static void DistanceToPosition(vtkDataSet* theDataSet,
1855 vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1857 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1858 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1859 vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1860 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1861 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1862 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1866 static void PositionToDistance(vtkDataSet* theDataSet,
1867 vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1869 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1870 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1871 vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1872 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1876 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1878 thePlane->SetNormal(theDir);
1879 vtkFloatingPointType anOrigin[3];
1880 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1881 thePlane->SetOrigin(anOrigin);
1885 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1887 thePlane->GetNormal(theDir);
1889 vtkFloatingPointType anOrigin[3];
1890 thePlane->GetOrigin(anOrigin);
1891 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1894 void SMESH_ActorDef::UpdateScalarBar()
1896 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1900 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1902 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1903 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1905 aScalarBarTitleProp->SetFontFamilyToArial();
1907 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1909 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1910 if ( f.family() == "Arial" )
1911 aScalarBarTitleProp->SetFontFamilyToArial();
1912 else if ( f.family() == "Courier" )
1913 aScalarBarTitleProp->SetFontFamilyToCourier();
1914 else if ( f.family() == "Times" )
1915 aScalarBarTitleProp->SetFontFamilyToTimes();
1918 aScalarBarTitleProp->BoldOn();
1920 aScalarBarTitleProp->BoldOff();
1923 aScalarBarTitleProp->ItalicOn();
1925 aScalarBarTitleProp->ItalicOff();
1928 aScalarBarTitleProp->ShadowOn();
1930 aScalarBarTitleProp->ShadowOff();
1933 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1934 aScalarBarTitleProp->Delete();
1936 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1938 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1939 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1941 aScalarBarLabelProp->SetFontFamilyToArial();
1942 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1944 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1945 if( f.family() == "Arial" )
1946 aScalarBarLabelProp->SetFontFamilyToArial();
1947 else if( f.family() == "Courier" )
1948 aScalarBarLabelProp->SetFontFamilyToCourier();
1949 else if( f.family() == "Times" )
1950 aScalarBarLabelProp->SetFontFamilyToTimes();
1953 aScalarBarLabelProp->BoldOn();
1955 aScalarBarLabelProp->BoldOff();
1958 aScalarBarLabelProp->ItalicOn();
1960 aScalarBarLabelProp->ItalicOff();
1963 aScalarBarLabelProp->ShadowOn();
1965 aScalarBarLabelProp->ShadowOff();
1968 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1969 aScalarBarLabelProp->Delete();
1971 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1972 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1974 myScalarBarActor->SetOrientationToHorizontal();
1976 myScalarBarActor->SetOrientationToVertical();
1979 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1980 if( mgr->hasValue( "SMESH", name + "x" ) )
1981 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1983 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1984 if( mgr->hasValue( "SMESH", name + "y" ) )
1985 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1986 myScalarBarActor->SetPosition( aXVal, aYVal );
1988 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1989 if( mgr->hasValue( "SMESH", name + "width" ) )
1990 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1991 myScalarBarActor->SetWidth( aWVal );
1993 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1994 if( mgr->hasValue( "SMESH", name + "height" ) )
1995 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1996 myScalarBarActor->SetHeight( aHVal );
1999 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2000 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2001 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2004 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2005 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2006 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2010 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2013 case SMESH_Actor::eLines :
2014 myHighlitableActor->SetQuadraticArcMode(false);
2015 my2DActor->SetQuadraticArcMode(false);
2016 my1DActor->SetQuadraticArcMode(false);
2018 case SMESH_Actor::eArcs :
2019 myHighlitableActor->SetQuadraticArcMode(true);
2020 if(GetRepresentation() != SMESH_Actor::ePoint) {
2021 my2DActor->SetQuadraticArcMode(true);
2022 my1DActor->SetQuadraticArcMode(true);
2031 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2033 if(myHighlitableActor->GetQuadraticArcMode())
2034 return SMESH_Actor::eArcs;
2036 return SMESH_Actor::eLines;
2039 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2041 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2042 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2043 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2046 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2048 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2049 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2050 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2051 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor