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;
804 case eMaxElementLength2D:
806 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
807 aControl->SetPrecision( myControlsPrecision );
808 aFunctor.reset( aControl );
809 myControlActor = my2DActor;
812 case eMaxElementLength3D:
814 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
815 aControl->SetPrecision( myControlsPrecision );
816 aFunctor.reset( aControl );
817 myControlActor = my3DActor;
822 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
823 aControl->SetPrecision( myControlsPrecision );
824 aFunctor.reset( aControl );
825 myControlActor = my2DActor;
830 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
831 aControl->SetPrecision( myControlsPrecision );
832 aFunctor.reset( aControl );
833 myControlActor = my2DActor;
838 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
839 aControl->SetPrecision( myControlsPrecision );
840 aFunctor.reset( aControl );
841 myControlActor = my2DActor;
848 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
849 vtkIdType aNbCells = aGrid->GetNumberOfCells();
851 myControlMode = theMode;
852 switch(myControlMode){
854 myNodeExtActor->SetExtControlMode(aFunctor);
858 my1DExtActor->SetExtControlMode(aFunctor);
861 my2DExtActor->SetExtControlMode(aFunctor);
864 case eMultiConnection2D:
865 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
868 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
872 if(theCheckEntityMode){
873 if(myControlActor == my1DActor)
874 SetEntityMode(eEdges);
875 else if(myControlActor == my2DActor){
876 switch(myControlMode){
880 case eMultiConnection2D:
881 //SetEntityMode(eEdges);
882 SetEntityMode(eFaces);
885 SetEntityMode(eFaces);
887 }else if(myControlActor == my3DActor)
888 SetEntityMode(eVolumes);
891 }else if(theCheckEntityMode){
892 myEntityMode = eAllEntity;
895 SetRepresentation(GetRepresentation());
897 myTimeStamp->Modified();
902 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
903 theRenderer->AddActor(myNodeActor);
904 theRenderer->AddActor(myBaseActor);
906 theRenderer->AddActor(myNodeExtActor);
908 my3DActor->AddToRender(theRenderer);
909 my2DActor->AddToRender(theRenderer);
910 my2DExtActor->AddToRender(theRenderer);
912 theRenderer->AddActor(my1DActor);
913 theRenderer->AddActor(my1DExtActor);
915 theRenderer->AddActor(my0DActor);
916 //theRenderer->AddActor(my0DExtActor);
918 theRenderer->AddActor(myHighlitableActor);
920 theRenderer->AddActor2D(myScalarBarActor);
922 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
923 myClsSelectVisiblePoints->SetRenderer(theRenderer);
925 theRenderer->AddActor2D(myPointLabels);
926 theRenderer->AddActor2D(myCellsLabels);
928 // the superclass' method should be called at the end
929 // (in particular, for correct work of selection)
930 SALOME_Actor::AddToRender(theRenderer);
933 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
934 SALOME_Actor::RemoveFromRender(theRenderer);
936 theRenderer->RemoveActor(myNodeActor);
937 theRenderer->RemoveActor(myBaseActor);
939 theRenderer->RemoveActor(myNodeExtActor);
941 theRenderer->RemoveActor(myHighlitableActor);
943 theRenderer->RemoveActor(my0DActor);
944 //theRenderer->RemoveActor(my0DExtActor);
946 theRenderer->RemoveActor(my1DActor);
947 theRenderer->RemoveActor(my1DExtActor);
949 my2DActor->RemoveFromRender(theRenderer);
950 my2DExtActor->RemoveFromRender(theRenderer);
951 my3DActor->RemoveFromRender(theRenderer);
953 theRenderer->RemoveActor(myScalarBarActor);
954 theRenderer->RemoveActor(myPointLabels);
955 theRenderer->RemoveActor(myCellsLabels);
959 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
960 const char* theEntry,
964 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
968 myVisualObj = theVisualObj;
969 myVisualObj->Update(theIsClear);
971 myNodeActor->Init(myVisualObj,myImplicitBoolean);
972 myBaseActor->Init(myVisualObj,myImplicitBoolean);
974 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
976 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
978 my0DActor->Init(myVisualObj,myImplicitBoolean);
979 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
981 my1DActor->Init(myVisualObj,myImplicitBoolean);
982 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
984 my2DActor->Init(myVisualObj,myImplicitBoolean);
985 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
986 my3DActor->Init(myVisualObj,myImplicitBoolean);
988 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
989 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
991 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
992 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
994 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
995 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
996 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
998 vtkFloatingPointType aFactor, aUnits;
999 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1000 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1001 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1003 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1007 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1008 SetIsShrunkable(true);
1010 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1012 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1013 SetRepresentation(-1);
1016 SetRepresentation(eEdge);
1017 }else if(aMode == 1){
1018 SetRepresentation(eSurface);
1019 }else if(aMode == 2){
1020 SetRepresentation(ePoint);
1027 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1028 SetIsDisplayNameActor( true );
1030 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1031 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1032 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1034 myTimeStamp->Modified();
1040 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1041 return myNodeActor->GetBounds();
1045 vtkDataSet* SMESH_ActorDef::GetInput(){
1046 return GetUnstructuredGrid();
1050 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1051 Superclass::SetTransform(theTransform);
1053 myNodeActor->SetTransform(theTransform);
1054 myBaseActor->SetTransform(theTransform);
1056 myHighlitableActor->SetTransform(theTransform);
1058 myNodeExtActor->SetTransform(theTransform);
1060 my0DActor->SetTransform(theTransform);
1061 //my0DExtActor->SetTransform(theTransform);
1063 my1DActor->SetTransform(theTransform);
1064 my1DExtActor->SetTransform(theTransform);
1066 my2DActor->SetTransform(theTransform);
1067 my2DExtActor->SetTransform(theTransform);
1068 my3DActor->SetTransform(theTransform);
1074 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1075 vtkLODActor::SetMapper(theMapper);
1079 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1080 SALOME_Actor::ShallowCopy(prop);
1084 vtkMapper* SMESH_ActorDef::GetMapper(){
1085 return myPickableActor->GetMapper();
1089 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1090 return myVisualObj->GetUnstructuredGrid();
1094 bool SMESH_ActorDef::IsInfinitive(){
1095 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1097 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1098 ( aDataSet->GetNumberOfCells() == 1 &&
1099 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1100 return SALOME_Actor::IsInfinitive();
1104 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1105 if ( myIsShrinkable == theShrunkable )
1107 myIsShrinkable = theShrunkable;
1111 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1112 return myBaseActor->GetShrinkFactor();
1115 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1116 myBaseActor->SetShrinkFactor(theValue);
1118 my1DActor->SetShrinkFactor(theValue);
1119 my1DExtActor->SetShrinkFactor(theValue);
1121 my2DActor->SetShrinkFactor(theValue);
1122 my2DExtActor->SetShrinkFactor(theValue);
1123 my3DActor->SetShrinkFactor(theValue);
1128 void SMESH_ActorDef::SetShrink(){
1129 if(!myIsShrinkable) return;
1131 myBaseActor->SetShrink();
1133 my1DActor->SetShrink();
1134 my1DExtActor->SetShrink();
1136 my2DActor->SetShrink();
1137 my2DExtActor->SetShrink();
1138 my3DActor->SetShrink();
1144 void SMESH_ActorDef::UnShrink(){
1145 if(!myIsShrunk) return;
1147 myBaseActor->UnShrink();
1149 my1DActor->UnShrink();
1150 my1DExtActor->UnShrink();
1152 my2DActor->UnShrink();
1153 my2DExtActor->UnShrink();
1154 my3DActor->UnShrink();
1161 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1162 return myPickableActor->GetNodeObjId(theVtkID);
1165 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1166 return myPickableActor->GetNodeCoord(theObjID);
1170 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1171 return myPickableActor->GetElemObjId(theVtkID);
1174 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1175 return myPickableActor->GetElemCell(theObjID);
1179 void SMESH_ActorDef::SetVisibility(int theMode){
1180 SetVisibility(theMode,true);
1184 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1185 SALOME_Actor::SetVisibility(theMode);
1187 myNodeActor->VisibilityOff();
1188 myBaseActor->VisibilityOff();
1190 myNodeExtActor->VisibilityOff();
1192 my0DActor->VisibilityOff();
1193 //my0DExtActor->VisibilityOff();
1195 my1DActor->VisibilityOff();
1196 my1DExtActor->VisibilityOff();
1198 my2DActor->VisibilityOff();
1199 my2DExtActor->VisibilityOff();
1200 my3DActor->VisibilityOff();
1202 myScalarBarActor->VisibilityOff();
1203 myPointLabels->VisibilityOff();
1204 myCellsLabels->VisibilityOff();
1206 if(GetVisibility()){
1207 if(theIsUpdateRepersentation)
1208 SetRepresentation(GetRepresentation());
1210 if(myControlMode != eNone){
1211 switch(myControlMode){
1213 myNodeExtActor->VisibilityOn();
1217 my1DExtActor->VisibilityOn();
1220 my2DExtActor->VisibilityOn();
1223 case eMultiConnection2D:
1224 my1DExtActor->VisibilityOn();
1226 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1227 myScalarBarActor->VisibilityOn();
1231 if(myRepresentation != ePoint)
1232 myPickableActor->VisibilityOn();
1234 myNodeActor->VisibilityOn();
1237 if(myEntityMode & e0DElements){
1238 my0DActor->VisibilityOn();
1241 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1242 my1DActor->VisibilityOn();
1245 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1246 my2DActor->VisibilityOn();
1249 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1250 my3DActor->VisibilityOn();
1253 if(myIsPointsLabeled){
1254 myPointLabels->VisibilityOn();
1255 myNodeActor->VisibilityOn();
1258 if(myIsCellsLabeled)
1259 myCellsLabels->VisibilityOn();
1266 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1268 myEntityState = eAllEntity;
1270 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1271 myEntityState &= ~e0DElements;
1272 theMode &= ~e0DElements;
1275 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1276 myEntityState &= ~eEdges;
1280 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1281 myEntityState &= ~eFaces;
1285 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1286 myEntityState &= ~eVolumes;
1287 theMode &= ~eVolumes;
1291 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1292 theMode |= e0DElements;
1294 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1297 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1300 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1301 theMode |= eVolumes;
1304 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1306 myEntityMode = theMode;
1307 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1308 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1309 aFilter->ClearRegisteredCellsWithType();
1310 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1312 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1313 aHightFilter->ClearRegisteredCellsWithType();
1314 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1316 if (myEntityMode & e0DElements) {
1317 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1318 aFilter->RegisterCellsWithType(VTK_VERTEX);
1319 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1322 if (myEntityMode & eEdges) {
1323 if (MYDEBUG) MESSAGE("EDGES");
1324 aFilter->RegisterCellsWithType(VTK_LINE);
1325 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1327 aHightFilter->RegisterCellsWithType(VTK_LINE);
1328 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1331 if (myEntityMode & eFaces) {
1332 if (MYDEBUG) MESSAGE("FACES");
1333 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1334 aFilter->RegisterCellsWithType(VTK_POLYGON);
1335 aFilter->RegisterCellsWithType(VTK_QUAD);
1336 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1337 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1339 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1340 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1341 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1342 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1343 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1346 if (myEntityMode & eVolumes) {
1347 if (MYDEBUG) MESSAGE("VOLUMES");
1348 aFilter->RegisterCellsWithType(VTK_TETRA);
1349 aFilter->RegisterCellsWithType(VTK_VOXEL);
1350 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1351 aFilter->RegisterCellsWithType(VTK_WEDGE);
1352 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1353 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1354 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1355 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1356 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1358 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1359 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1360 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1361 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1362 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1363 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1364 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1365 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1366 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1367 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1370 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1371 SetVisibility(GetVisibility(),false);
1374 void SMESH_ActorDef::SetRepresentation (int theMode)
1376 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1377 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1378 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1381 myRepresentation = eSurface;
1382 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1383 myRepresentation = eEdge;
1384 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1385 myRepresentation = ePoint;
1390 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1393 if (!aNbFaces && !aNbVolumes) return;
1396 myRepresentation = theMode;
1399 if (!GetUnstructuredGrid()->GetNumberOfCells())
1400 myRepresentation = ePoint;
1403 if (myRepresentation == ePoint) {
1411 myPickableActor = myBaseActor;
1412 myNodeActor->SetVisibility(false);
1413 myNodeExtActor->SetVisibility(false);
1414 vtkProperty *aProp = NULL, *aBackProp = NULL;
1415 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1416 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1417 switch (myRepresentation) {
1419 myPickableActor = myNodeActor;
1420 myNodeActor->SetVisibility(true);
1421 aQuadraticMode = SMESH_Actor::eLines;
1422 aProp = aBackProp = myNodeProp;
1423 aReperesent = SMESH_DeviceActor::ePoint;
1426 aProp = aBackProp = myEdgeProp;
1427 aReperesent = SMESH_DeviceActor::eInsideframe;
1430 aProp = mySurfaceProp;
1431 aBackProp = myBackSurfaceProp;
1432 aReperesent = SMESH_DeviceActor::eSurface;
1436 my2DActor->SetProperty(aProp);
1437 my2DActor->SetBackfaceProperty(aBackProp);
1438 my2DActor->SetRepresentation(aReperesent);
1440 if(aQuadraticMode == SMESH_Actor::eLines)
1441 my2DActor->SetQuadraticArcMode(false);
1442 else if(aQuadraticMode == SMESH_Actor::eArcs)
1443 my2DActor->SetQuadraticArcMode(true);
1445 my2DExtActor->SetRepresentation(aReperesent);
1447 my3DActor->SetProperty(aProp);
1448 my3DActor->SetBackfaceProperty(aBackProp);
1449 my3DActor->SetRepresentation(aReperesent);
1451 //my0DExtActor->SetVisibility(false);
1452 my1DExtActor->SetVisibility(false);
1453 my2DExtActor->SetVisibility(false);
1456 //my0DActor->SetProperty(aProp);
1457 //my0DActor->SetBackfaceProperty(aBackProp);
1458 my0DActor->SetRepresentation(aReperesent);
1459 //my0DExtActor->SetRepresentation(aReperesent);
1461 switch(myControlMode){
1463 case eMultiConnection:
1464 aProp = aBackProp = my1DProp;
1465 if(myRepresentation != ePoint)
1466 aReperesent = SMESH_DeviceActor::eInsideframe;
1470 if(aQuadraticMode == SMESH_Actor::eLines)
1471 my1DActor->SetQuadraticArcMode(false);
1472 else if(aQuadraticMode == SMESH_Actor::eArcs)
1473 my1DActor->SetQuadraticArcMode(true);
1475 my1DActor->SetProperty(aProp);
1476 my1DActor->SetBackfaceProperty(aBackProp);
1477 my1DActor->SetRepresentation(aReperesent);
1479 my1DExtActor->SetRepresentation(aReperesent);
1481 if(myIsPointsVisible)
1482 myPickableActor = myNodeActor;
1483 if(GetPointRepresentation())
1484 myNodeActor->SetVisibility(true);
1486 SetMapper(myPickableActor->GetMapper());
1488 SetVisibility(GetVisibility(),false);
1494 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1495 if ( myIsPointsVisible == theIsPointsVisible )
1497 myIsPointsVisible = theIsPointsVisible;
1498 SetRepresentation(GetRepresentation());
1501 bool SMESH_ActorDef::GetPointRepresentation(){
1502 return myIsPointsVisible || myIsPointsLabeled;
1506 void SMESH_ActorDef::UpdateHighlight(){
1507 myHighlitableActor->SetVisibility(false);
1508 myHighlitableActor->SetHighlited(false);
1510 if(myIsHighlighted){
1511 myHighlitableActor->SetProperty(myHighlightProp);
1512 }else if(myIsPreselected){
1513 myHighlitableActor->SetProperty(myPreselectProp);
1516 bool anIsVisible = GetVisibility();
1518 if(myIsHighlighted || myIsPreselected){
1519 if(GetUnstructuredGrid()->GetNumberOfCells()){
1520 myHighlitableActor->SetHighlited(anIsVisible);
1521 myHighlitableActor->SetVisibility(anIsVisible);
1522 myHighlitableActor->GetExtractUnstructuredGrid()->
1523 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1524 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1525 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1526 myHighlitableActor->SetHighlited(anIsVisible);
1527 myHighlitableActor->GetExtractUnstructuredGrid()->
1528 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1529 myHighlitableActor->SetVisibility(anIsVisible);
1530 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1532 VTK::MarkerType aMarkerType = GetMarkerType();
1533 if(aMarkerType != VTK::MT_USER)
1534 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1536 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1542 void SMESH_ActorDef::highlight(bool theHighlight){
1543 if ( myIsHighlighted == theHighlight )
1545 myIsHighlighted = theHighlight;
1550 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1551 if ( myIsPreselected == thePreselect )
1553 myIsPreselected = thePreselect;
1559 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1561 if (myPickableActor->GetIsOpaque())
1563 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1571 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1573 if (!myPickableActor->GetIsOpaque())
1575 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1583 void SMESH_ActorDef::Render(vtkRenderer *ren){
1584 unsigned long aTime = myTimeStamp->GetMTime();
1585 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1586 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1587 if(anObjTime > aTime || aClippingTime > aTime)
1592 void SMESH_ActorDef::Update(){
1593 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1595 if(GetControlMode() != eNone) {
1596 unsigned long aTime = myTimeStamp->GetMTime();
1597 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1598 if (anObjTime > aTime)
1599 SetControlMode(GetControlMode(),false);
1601 if(myIsPointsLabeled){
1602 SetPointsLabeled(myIsPointsLabeled);
1604 if(myIsCellsLabeled){
1605 SetCellsLabeled(myIsCellsLabeled);
1607 if(myIsFacesOriented){
1608 SetFacesOriented(myIsFacesOriented);
1610 SetEntityMode(GetEntityMode());
1611 SetVisibility(GetVisibility());
1613 myTimeStamp->Modified();
1618 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1619 SALOME_Actor::ReleaseGraphicsResources(renWin);
1621 myPickableActor->ReleaseGraphicsResources(renWin);
1625 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1626 vtkFloatingPointType* aColor = theProperty->GetColor();
1633 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1634 mySurfaceProp->SetOpacity(theValue);
1635 myBackSurfaceProp->SetOpacity(theValue);
1636 myEdgeProp->SetOpacity(theValue);
1637 myNodeProp->SetOpacity(theValue);
1639 my1DProp->SetOpacity(theValue);
1643 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1644 return mySurfaceProp->GetOpacity();
1648 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1649 mySurfaceProp->SetColor(r,g,b);
1650 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1651 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1652 aGroupObj->GetElementType() == SMDSAbs_Volume )
1653 myNameActor->SetBackgroundColor(r,g,b);
1657 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1658 ::GetColor(mySurfaceProp,r,g,b);
1659 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1662 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1663 myBackSurfaceProp->SetColor(r,g,b);
1667 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1668 ::GetColor(myBackSurfaceProp,r,g,b);
1671 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1672 myEdgeProp->SetColor(r,g,b);
1673 my1DProp->SetColor(r,g,b);
1674 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1675 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1676 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1677 myNameActor->SetBackgroundColor(r,g,b);
1681 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1682 ::GetColor(myEdgeProp,r,g,b);
1685 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1686 myNodeProp->SetColor(r,g,b);
1687 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1688 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1689 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1690 myNameActor->SetBackgroundColor(r,g,b);
1694 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1695 ::GetColor(myNodeProp,r,g,b);
1698 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1699 my0DProp->SetColor(r,g,b);
1700 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1701 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1702 myNameActor->SetBackgroundColor(r,g,b);
1706 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1707 ::GetColor(my0DProp,r,g,b);
1710 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1711 myHighlightProp->SetColor(r,g,b);
1715 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1716 ::GetColor(myHighlightProp,r,g,b);
1719 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1720 myPreselectProp->SetColor(r,g,b);
1724 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1725 ::GetColor(myPreselectProp,r,g,b);
1729 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1730 return myEdgeProp->GetLineWidth();
1734 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1735 myEdgeProp->SetLineWidth(theVal);
1737 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1738 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1744 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1745 my0DProp->SetPointSize(theVal);
1749 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1750 return my0DProp->GetPointSize();
1753 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1755 return myVisualObj->GetElemDimension( theObjId );
1760 IsImplicitFunctionUsed() const
1762 return myBaseActor->IsImplicitFunctionUsed();
1766 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1768 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1769 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1771 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1773 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1775 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1776 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1778 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1779 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1781 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1782 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1783 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1787 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1790 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1791 myCippingPlaneCont.push_back(thePlane);
1792 if(!IsImplicitFunctionUsed())
1793 SetImplicitFunctionUsed(true);
1795 return myCippingPlaneCont.size();
1800 RemoveAllClippingPlanes()
1802 myImplicitBoolean->GetFunction()->RemoveAllItems();
1803 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1804 myCippingPlaneCont.clear();
1805 SetImplicitFunctionUsed(false);
1810 GetNumberOfClippingPlanes()
1812 return myCippingPlaneCont.size();
1817 GetClippingPlane(vtkIdType theID)
1819 if(theID >= myCippingPlaneCont.size())
1821 return myCippingPlaneCont[theID].Get();
1825 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1826 vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1827 vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1829 vtkFloatingPointType aBounds[6];
1830 theDataSet->GetBounds(aBounds);
1832 //Enlarge bounds in order to avoid conflicts of precision
1833 for(int i = 0; i < 6; i += 2){
1834 static double EPS = 1.0E-3;
1835 vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1836 aBounds[i] -= aDelta;
1837 aBounds[i+1] += aDelta;
1840 vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1841 {aBounds[1],aBounds[2],aBounds[4]},
1842 {aBounds[0],aBounds[3],aBounds[4]},
1843 {aBounds[1],aBounds[3],aBounds[4]},
1844 {aBounds[0],aBounds[2],aBounds[5]},
1845 {aBounds[1],aBounds[2],aBounds[5]},
1846 {aBounds[0],aBounds[3],aBounds[5]},
1847 {aBounds[1],aBounds[3],aBounds[5]}};
1849 int aMaxId = 0, aMinId = aMaxId;
1850 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1851 theMinBoundPrj = theMaxBoundPrj;
1852 for(int i = 1; i < 8; i++){
1853 vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1854 if(theMaxBoundPrj < aTmp){
1855 theMaxBoundPrj = aTmp;
1858 if(theMinBoundPrj > aTmp){
1859 theMinBoundPrj = aTmp;
1863 vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1864 theMinPnt[0] = aMinPnt[0];
1865 theMinPnt[1] = aMinPnt[1];
1866 theMinPnt[2] = aMinPnt[2];
1870 static void DistanceToPosition(vtkDataSet* theDataSet,
1871 vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1873 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1874 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1875 vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1876 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1877 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1878 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1882 static void PositionToDistance(vtkDataSet* theDataSet,
1883 vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1885 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1886 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1887 vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1888 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1892 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1894 thePlane->SetNormal(theDir);
1895 vtkFloatingPointType anOrigin[3];
1896 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1897 thePlane->SetOrigin(anOrigin);
1901 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1903 thePlane->GetNormal(theDir);
1905 vtkFloatingPointType anOrigin[3];
1906 thePlane->GetOrigin(anOrigin);
1907 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1910 void SMESH_ActorDef::UpdateScalarBar()
1912 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1916 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1918 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1919 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1921 aScalarBarTitleProp->SetFontFamilyToArial();
1923 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1925 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1926 if ( f.family() == "Arial" )
1927 aScalarBarTitleProp->SetFontFamilyToArial();
1928 else if ( f.family() == "Courier" )
1929 aScalarBarTitleProp->SetFontFamilyToCourier();
1930 else if ( f.family() == "Times" )
1931 aScalarBarTitleProp->SetFontFamilyToTimes();
1934 aScalarBarTitleProp->BoldOn();
1936 aScalarBarTitleProp->BoldOff();
1939 aScalarBarTitleProp->ItalicOn();
1941 aScalarBarTitleProp->ItalicOff();
1944 aScalarBarTitleProp->ShadowOn();
1946 aScalarBarTitleProp->ShadowOff();
1949 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1950 aScalarBarTitleProp->Delete();
1952 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1954 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1955 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1957 aScalarBarLabelProp->SetFontFamilyToArial();
1958 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1960 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1961 if( f.family() == "Arial" )
1962 aScalarBarLabelProp->SetFontFamilyToArial();
1963 else if( f.family() == "Courier" )
1964 aScalarBarLabelProp->SetFontFamilyToCourier();
1965 else if( f.family() == "Times" )
1966 aScalarBarLabelProp->SetFontFamilyToTimes();
1969 aScalarBarLabelProp->BoldOn();
1971 aScalarBarLabelProp->BoldOff();
1974 aScalarBarLabelProp->ItalicOn();
1976 aScalarBarLabelProp->ItalicOff();
1979 aScalarBarLabelProp->ShadowOn();
1981 aScalarBarLabelProp->ShadowOff();
1984 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1985 aScalarBarLabelProp->Delete();
1987 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1988 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1990 myScalarBarActor->SetOrientationToHorizontal();
1992 myScalarBarActor->SetOrientationToVertical();
1995 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1996 if( mgr->hasValue( "SMESH", name + "x" ) )
1997 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1999 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2000 if( mgr->hasValue( "SMESH", name + "y" ) )
2001 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2002 myScalarBarActor->SetPosition( aXVal, aYVal );
2004 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2005 if( mgr->hasValue( "SMESH", name + "width" ) )
2006 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2007 myScalarBarActor->SetWidth( aWVal );
2009 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2010 if( mgr->hasValue( "SMESH", name + "height" ) )
2011 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2012 myScalarBarActor->SetHeight( aHVal );
2015 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2016 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2017 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2020 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2021 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2022 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2026 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2029 case SMESH_Actor::eLines :
2030 myHighlitableActor->SetQuadraticArcMode(false);
2031 my2DActor->SetQuadraticArcMode(false);
2032 my1DActor->SetQuadraticArcMode(false);
2034 case SMESH_Actor::eArcs :
2035 myHighlitableActor->SetQuadraticArcMode(true);
2036 if(GetRepresentation() != SMESH_Actor::ePoint) {
2037 my2DActor->SetQuadraticArcMode(true);
2038 my1DActor->SetQuadraticArcMode(true);
2047 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2049 if(myHighlitableActor->GetQuadraticArcMode())
2050 return SMESH_Actor::eArcs;
2052 return SMESH_Actor::eLines;
2055 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2057 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2058 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2059 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2062 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2064 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2065 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2066 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2067 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor