1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_ObjectDef.h"
32 #include "SMESH_ControlsDef.hxx"
33 #include "VTKViewer_ExtractUnstructuredGrid.h"
34 #include "VTKViewer_FramedTextActor.h"
35 #include "SALOME_InteractiveObject.hxx"
37 #include "SUIT_Session.h"
38 #include "SUIT_ResourceMgr.h"
40 #include <vtkProperty.h>
41 #include <vtkTimeStamp.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkShrinkPolyData.h>
44 #include <vtkMergeFilter.h>
46 #include <vtkMatrix4x4.h>
47 #include <vtkUnstructuredGrid.h>
48 #include <vtkPointData.h>
49 #include <vtkCellData.h>
51 #include <vtkMapper.h>
52 #include <vtkRenderer.h>
55 #include <vtkIdList.h>
56 #include <vtkIntArray.h>
58 #include <vtkActor2D.h>
59 #include <vtkProperty2D.h>
60 #include <vtkPolyData.h>
61 #include <vtkMaskPoints.h>
62 #include <vtkCellCenters.h>
63 #include <vtkTextProperty.h>
64 #include <vtkLabeledDataMapper.h>
65 #include <vtkSelectVisiblePoints.h>
67 #include <vtkScalarBarActor.h>
68 #include <vtkLookupTable.h>
72 #include <vtkImplicitBoolean.h>
73 #include <vtkImplicitFunctionCollection.h>
75 #include <vtkConfigure.h>
76 #if !defined(VTK_XVERSION)
77 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
80 #include "utilities.h"
83 static int MYDEBUG = 1;
85 static int MYDEBUG = 0;
88 static int aLineWidthInc = 2;
91 SMESH_ActorDef* SMESH_ActorDef::New(){
92 return new SMESH_ActorDef();
96 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
101 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
102 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
107 anActor->UpdateScalarBar();
112 SMESH_ActorDef::SMESH_ActorDef()
114 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
116 myTimeStamp = vtkTimeStamp::New();
118 myIsPointsVisible = false;
120 myIsShrinkable = false;
123 myIsFacesOriented = false;
125 myControlsPrecision = -1;
126 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
128 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
129 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
131 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
132 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
134 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
135 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
137 //Definition 2D and 3D devices of the actor
138 //-----------------------------------------
139 vtkFloatingPointType anRGB[3] = {1,1,1};
140 mySurfaceProp = vtkProperty::New();
141 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
142 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
144 myBackSurfaceProp = vtkProperty::New();
145 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
146 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
148 my2DActor = SMESH_DeviceActor::New();
149 my2DActor->SetUserMatrix(aMatrix);
150 my2DActor->PickableOff();
151 my2DActor->SetProperty(mySurfaceProp);
152 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
153 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
154 aFilter = my2DActor->GetExtractUnstructuredGrid();
155 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
156 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
157 aFilter->RegisterCellsWithType(VTK_POLYGON);
158 aFilter->RegisterCellsWithType(VTK_QUAD);
159 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
160 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
162 my2DExtProp = vtkProperty::New();
163 my2DExtProp->DeepCopy(mySurfaceProp);
164 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
165 anRGB[0] = 1 - anRGB[0];
166 anRGB[1] = 1 - anRGB[1];
167 anRGB[2] = 1 - anRGB[2];
168 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
170 my2DExtActor = SMESH_DeviceActor::New();
171 my2DExtActor->SetUserMatrix(aMatrix);
172 my2DExtActor->PickableOff();
173 my2DExtActor->SetProperty(my2DExtProp);
174 my2DExtActor->SetBackfaceProperty(my2DExtProp);
175 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
176 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
177 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
178 aFilter->RegisterCellsWithType(VTK_POLYGON);
179 aFilter->RegisterCellsWithType(VTK_QUAD);
180 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
181 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
183 my3DActor = SMESH_DeviceActor::New();
184 my3DActor->SetUserMatrix(aMatrix);
185 my3DActor->PickableOff();
186 my3DActor->SetProperty(mySurfaceProp);
187 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
188 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
189 aFilter = my3DActor->GetExtractUnstructuredGrid();
190 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
191 aFilter->RegisterCellsWithType(VTK_TETRA);
192 aFilter->RegisterCellsWithType(VTK_VOXEL);
193 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
194 aFilter->RegisterCellsWithType(VTK_WEDGE);
195 aFilter->RegisterCellsWithType(VTK_PYRAMID);
196 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
197 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
198 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
199 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
201 //Definition 1D device of the actor
202 //---------------------------------
203 myEdgeProp = vtkProperty::New();
204 myEdgeProp->SetAmbient(1.0);
205 myEdgeProp->SetDiffuse(0.0);
206 myEdgeProp->SetSpecular(0.0);
207 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
208 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
209 myEdgeProp->SetLineWidth(aLineWidth);
211 my1DActor = SMESH_DeviceActor::New();
212 my1DActor->SetUserMatrix(aMatrix);
213 my1DActor->PickableOff();
214 my1DActor->SetHighlited(true);
215 my1DActor->SetProperty(myEdgeProp);
216 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
217 aFilter = my1DActor->GetExtractUnstructuredGrid();
218 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
219 aFilter->RegisterCellsWithType(VTK_LINE);
220 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
222 my1DProp = vtkProperty::New();
223 my1DProp->DeepCopy(myEdgeProp);
224 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
225 my1DProp->SetPointSize(aElem0DSize);
227 my1DExtProp = vtkProperty::New();
228 my1DExtProp->DeepCopy(myEdgeProp);
229 anRGB[0] = 1 - anRGB[0];
230 anRGB[1] = 1 - anRGB[1];
231 anRGB[2] = 1 - anRGB[2];
232 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
233 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
234 my1DExtProp->SetPointSize(aElem0DSize);
236 my1DExtActor = SMESH_DeviceActor::New();
237 my1DExtActor->SetUserMatrix(aMatrix);
238 my1DExtActor->PickableOff();
239 my1DExtActor->SetHighlited(true);
240 my1DExtActor->SetVisibility(false);
241 my1DExtActor->SetProperty(my1DExtProp);
242 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
243 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
244 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
245 aFilter->RegisterCellsWithType(VTK_LINE);
246 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
249 //Definition 0D device of the actor (0d elements)
250 //-----------------------------------------------
251 my0DProp = vtkProperty::New();
252 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
253 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
254 my0DProp->SetPointSize(aElem0DSize);
256 my0DActor = SMESH_DeviceActor::New();
257 my0DActor->SetUserMatrix(aMatrix);
258 my0DActor->SetStoreClippingMapping(true);
259 my0DActor->PickableOff();
260 my0DActor->SetVisibility(false);
261 my0DActor->SetProperty(my0DProp);
262 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
263 aFilter = my0DActor->GetExtractUnstructuredGrid();
264 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
265 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
266 aFilter->RegisterCellsWithType(VTK_VERTEX);
268 //my0DExtProp = vtkProperty::New();
269 //my0DExtProp->DeepCopy(my0DProp);
270 //anRGB[0] = 1 - anRGB[0];
271 //anRGB[1] = 1 - anRGB[1];
272 //anRGB[2] = 1 - anRGB[2];
273 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
274 //my0DExtProp->SetPointSize(aElem0DSize);
276 //my0DExtActor = SMESH_DeviceActor::New();
277 //my0DExtActor->SetUserMatrix(aMatrix);
278 //my0DExtActor->SetStoreClippingMapping(true);
279 //my0DExtActor->PickableOff();
280 //my0DExtActor->SetHighlited(true);
281 //my0DExtActor->SetVisibility(false);
282 //my0DExtActor->SetProperty(my0DExtProp);
283 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
284 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
285 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
286 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
287 //aFilter->RegisterCellsWithType(VTK_VERTEX);
290 //Definition 0D device of the actor (nodes)
291 //-----------------------------------------
292 myNodeProp = vtkProperty::New();
293 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
294 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
296 myNodeActor = SMESH_DeviceActor::New();
297 myNodeActor->SetUserMatrix(aMatrix);
298 myNodeActor->SetStoreClippingMapping(true);
299 myNodeActor->PickableOff();
300 myNodeActor->SetVisibility(false);
301 myNodeActor->SetProperty(myNodeProp);
302 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
303 aFilter = myNodeActor->GetExtractUnstructuredGrid();
304 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
306 myNodeExtProp = vtkProperty::New();
307 myNodeExtProp->DeepCopy(myNodeProp);
308 anRGB[0] = 1 - anRGB[0];
309 anRGB[1] = 1 - anRGB[1];
310 anRGB[2] = 1 - anRGB[2];
311 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
313 myNodeExtActor = SMESH_DeviceActor::New();
314 myNodeExtActor->SetUserMatrix(aMatrix);
315 myNodeExtActor->SetStoreClippingMapping(true);
316 myNodeExtActor->PickableOff();
317 myNodeExtActor->SetHighlited(true);
318 myNodeExtActor->SetVisibility(false);
319 myNodeExtActor->SetProperty(myNodeExtProp);
320 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
321 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
322 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
323 aFilter->RegisterCellsWithType(VTK_VERTEX);
325 //Definition of Pickable and Highlitable engines
326 //----------------------------------------------
328 myBaseActor = SMESH_DeviceActor::New();
329 myBaseActor->SetUserMatrix(aMatrix);
330 myBaseActor->SetStoreGemetryMapping(true);
331 myBaseActor->GetProperty()->SetOpacity(0.0);
333 myPickableActor = myBaseActor;
335 myHighlightProp = vtkProperty::New();
336 myHighlightProp->SetAmbient(1.0);
337 myHighlightProp->SetDiffuse(0.0);
338 myHighlightProp->SetSpecular(0.0);
339 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
340 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
341 myHighlightProp->SetPointSize(aElem0DSize); // ??
342 myHighlightProp->SetRepresentation(1);
344 myPreselectProp = vtkProperty::New();
345 myPreselectProp->SetAmbient(1.0);
346 myPreselectProp->SetDiffuse(0.0);
347 myPreselectProp->SetSpecular(0.0);
348 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
349 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
350 myPreselectProp->SetPointSize(aElem0DSize); // ??
351 myPreselectProp->SetRepresentation(1);
353 myHighlitableActor = SMESH_DeviceActor::New();
354 myHighlitableActor->SetUserMatrix(aMatrix);
355 myHighlitableActor->PickableOff();
356 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
363 myControlMode = eNone;
364 myControlActor = my2DActor;
366 //Definition of myScalarBarActor
367 //------------------------------
368 myLookupTable = vtkLookupTable::New();
369 //Fix for Bug PAL5195 - SMESH764:
370 //Controls - Aspect Ratio: incorrect colors of the best and worst values
371 myLookupTable->SetHueRange(0.667,0.0);
373 myScalarBarActor = vtkScalarBarActor::New();
374 myScalarBarActor->SetVisibility(false);
375 myScalarBarActor->SetLookupTable(myLookupTable);
378 //Incorrect "Min value" in Scalar Bar in Mesh:
379 // myScalarBarActor->SetLabelFormat("%.4g");
380 // changes was commented because of regression bug IPAL 19981
382 mgr = SUIT_Session::session()->resourceMgr();
386 //Definition of points numbering pipeline
387 //---------------------------------------
388 myPointsNumDataSet = vtkUnstructuredGrid::New();
390 myPtsMaskPoints = vtkMaskPoints::New();
391 myPtsMaskPoints->SetInput(myPointsNumDataSet);
392 myPtsMaskPoints->SetOnRatio(1);
394 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
395 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
396 myPtsSelectVisiblePoints->SelectInvisibleOff();
397 myPtsSelectVisiblePoints->SetTolerance(0.1);
399 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
400 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
401 #if (VTK_XVERSION < 0x050200)
402 myPtsLabeledDataMapper->SetLabelFormat("%g");
404 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
406 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
407 aPtsTextProp->SetFontFamilyToTimes();
408 static int aPointsFontSize = 10;
409 aPtsTextProp->SetFontSize(aPointsFontSize);
410 aPtsTextProp->SetBold(1);
411 aPtsTextProp->SetItalic(0);
412 aPtsTextProp->SetShadow(0);
413 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
414 aPtsTextProp->Delete();
416 myEntityMode = eAllEntity;
418 myIsPointsLabeled = false;
420 myPointLabels = vtkActor2D::New();
421 myPointLabels->SetMapper(myPtsLabeledDataMapper);
422 myPointLabels->GetProperty()->SetColor(1,1,1);
423 myPointLabels->SetVisibility(myIsPointsLabeled);
426 //Definition of cells numbering pipeline
427 //---------------------------------------
428 myCellsNumDataSet = vtkUnstructuredGrid::New();
430 myCellCenters = vtkCellCenters::New();
431 myCellCenters->SetInput(myCellsNumDataSet);
433 myClsMaskPoints = vtkMaskPoints::New();
434 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
435 myClsMaskPoints->SetOnRatio(1);
437 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
438 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
439 myClsSelectVisiblePoints->SelectInvisibleOff();
440 myClsSelectVisiblePoints->SetTolerance(0.1);
442 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
443 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
444 #if (VTK_XVERSION < 0x050200)
445 myClsLabeledDataMapper->SetLabelFormat("%g");
447 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
449 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
450 aClsTextProp->SetFontFamilyToTimes();
451 static int aCellsFontSize = 12;
452 aClsTextProp->SetFontSize(aCellsFontSize);
453 aClsTextProp->SetBold(1);
454 aClsTextProp->SetItalic(0);
455 aClsTextProp->SetShadow(0);
456 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
457 aClsTextProp->Delete();
459 myIsCellsLabeled = false;
461 myCellsLabels = vtkActor2D::New();
462 myCellsLabels->SetMapper(myClsLabeledDataMapper);
463 myCellsLabels->GetProperty()->SetColor(0,1,0);
464 myCellsLabels->SetVisibility(myIsCellsLabeled);
467 myImplicitBoolean = vtkImplicitBoolean::New();
468 myImplicitBoolean->SetOperationTypeToIntersection();
472 //Quadratic 2D elements representation
473 //-----------------------------------------------------------------------------
474 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
475 if(aQuadratic2DMode == 0){
476 myHighlitableActor->SetQuadraticArcMode(false);
477 my2DActor->SetQuadraticArcMode(false);
478 my1DActor->SetQuadraticArcMode(false);
480 else if(aQuadratic2DMode == 1){
481 myHighlitableActor->SetQuadraticArcMode(true);
482 my2DActor->SetQuadraticArcMode(true);
483 my1DActor->SetQuadraticArcMode(true);
486 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
487 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
488 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
490 // Set colors of the name actor
491 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
492 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
493 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
494 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
498 SMESH_ActorDef::~SMESH_ActorDef()
500 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
502 myScalarBarActor->Delete();
503 myLookupTable->Delete();
505 mySurfaceProp->Delete();
506 myBackSurfaceProp->Delete();
508 myEdgeProp->Delete();
509 myHighlightProp->Delete();
510 myPreselectProp->Delete();
512 myNodeProp->Delete();
513 myNodeExtProp->Delete();
518 //my0DExtProp->Delete();
519 //my0DExtActor->Delete();
524 my1DExtProp->Delete();
525 my1DExtActor->Delete();
528 my2DExtProp->Delete();
529 my2DExtActor->Delete();
532 myNodeActor->Delete();
533 myBaseActor->Delete();
535 myNodeExtActor->Delete();
537 myHighlitableActor->Delete();
539 //Deleting of points numbering pipeline
540 //---------------------------------------
541 myPointsNumDataSet->Delete();
543 // commented: porting to vtk 5.0
544 // myPtsLabeledDataMapper->RemoveAllInputs();
545 myPtsLabeledDataMapper->Delete();
547 // commented: porting to vtk 5.0
548 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
549 myPtsSelectVisiblePoints->Delete();
551 // commented: porting to vtk 5.0
552 // myPtsMaskPoints->UnRegisterAllOutputs();
553 myPtsMaskPoints->Delete();
555 myPointLabels->Delete();
558 //Deleting of cells numbering pipeline
559 //---------------------------------------
560 myCellsNumDataSet->Delete();
562 myClsLabeledDataMapper->RemoveAllInputs();
563 myClsLabeledDataMapper->Delete();
565 // commented: porting to vtk 5.0
566 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
567 myClsSelectVisiblePoints->Delete();
569 // commented: porting to vtk 5.0
570 // myClsMaskPoints->UnRegisterAllOutputs();
571 myClsMaskPoints->Delete();
573 // commented: porting to vtk 5.0
574 // myCellCenters->UnRegisterAllOutputs();
575 myCellCenters->Delete();
577 myCellsLabels->Delete();
579 myImplicitBoolean->Delete();
581 myTimeStamp->Delete();
585 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
587 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
589 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
591 if ( myIsPointsLabeled )
593 myPointsNumDataSet->ShallowCopy(aGrid);
594 vtkDataSet *aDataSet = myPointsNumDataSet;
596 int aNbElem = aDataSet->GetNumberOfPoints();
598 vtkIntArray *anArray = vtkIntArray::New();
599 anArray->SetNumberOfValues( aNbElem );
601 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
603 int aSMDSId = myVisualObj->GetNodeObjId( anId );
604 anArray->SetValue( anId, aSMDSId );
607 aDataSet->GetPointData()->SetScalars( anArray );
609 myPtsMaskPoints->SetInput( aDataSet );
610 myPointLabels->SetVisibility( GetVisibility() );
614 myPointLabels->SetVisibility( false );
616 SetRepresentation(GetRepresentation());
617 myTimeStamp->Modified();
621 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
623 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
624 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
625 if(myIsCellsLabeled){
626 myCellsNumDataSet->ShallowCopy(aGrid);
627 vtkDataSet *aDataSet = myCellsNumDataSet;
628 int aNbElem = aDataSet->GetNumberOfCells();
629 vtkIntArray *anArray = vtkIntArray::New();
630 anArray->SetNumberOfValues(aNbElem);
631 for(int anId = 0; anId < aNbElem; anId++){
632 int aSMDSId = myVisualObj->GetElemObjId(anId);
633 anArray->SetValue(anId,aSMDSId);
635 aDataSet->GetCellData()->SetScalars(anArray);
636 myCellCenters->SetInput(aDataSet);
637 myCellsLabels->SetVisibility(GetVisibility());
639 myCellsLabels->SetVisibility(false);
641 myTimeStamp->Modified();
645 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
647 myIsFacesOriented = theIsFacesOriented;
649 my2DActor->SetFacesOriented(theIsFacesOriented);
650 my3DActor->SetFacesOriented(theIsFacesOriented);
652 myTimeStamp->Modified();
655 bool SMESH_ActorDef::GetFacesOriented()
657 return myIsFacesOriented;
660 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
662 my2DActor->SetFacesOrientationColor( theColor );
663 my3DActor->SetFacesOrientationColor( theColor );
666 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
668 my3DActor->GetFacesOrientationColor( theColor );
671 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
673 my2DActor->SetFacesOrientationScale( theScale );
674 my3DActor->SetFacesOrientationScale( theScale );
677 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
679 return my3DActor->GetFacesOrientationScale();
682 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
684 my2DActor->SetFacesOrientation3DVectors( theState );
685 my3DActor->SetFacesOrientation3DVectors( theState );
688 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
690 return my3DActor->GetFacesOrientation3DVectors();
696 SetControlMode(eControl theMode)
698 SetControlMode(theMode,true);
704 SetControlMode(eControl theMode,
705 bool theCheckEntityMode)
707 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
711 myControlMode = eNone;
712 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
714 my0DActor->GetMapper()->SetScalarVisibility(false);
715 my1DActor->GetMapper()->SetScalarVisibility(false);
716 my2DActor->GetMapper()->SetScalarVisibility(false);
717 my3DActor->GetMapper()->SetScalarVisibility(false);
718 myScalarBarActor->SetVisibility(false);
720 bool anIsScalarVisible = theMode > eNone;
722 if(anIsScalarVisible){
723 SMESH::Controls::FunctorPtr aFunctor;
727 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
728 aControl->SetPrecision( myControlsPrecision );
729 aFunctor.reset( aControl );
730 myControlActor = my1DActor;
735 aFunctor.reset(new SMESH::Controls::Length2D());
736 myControlActor = my2DActor;
740 aFunctor.reset(new SMESH::Controls::FreeBorders());
741 myControlActor = my1DActor;
744 aFunctor.reset(new SMESH::Controls::FreeEdges());
745 myControlActor = my2DActor;
748 aFunctor.reset(new SMESH::Controls::FreeNodes());
749 myControlActor = myNodeActor;
752 aFunctor.reset(new SMESH::Controls::FreeFaces());
753 myControlActor = my2DActor;
755 case eMultiConnection:
756 aFunctor.reset(new SMESH::Controls::MultiConnection());
757 myControlActor = my1DActor;
759 case eMultiConnection2D:
760 aFunctor.reset(new SMESH::Controls::MultiConnection2D());
761 myControlActor = my2DActor;
765 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
766 aControl->SetPrecision( myControlsPrecision );
767 aFunctor.reset( aControl );
768 myControlActor = my2DActor;
773 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
774 aControl->SetPrecision( myControlsPrecision );
775 aFunctor.reset( aControl );
776 myControlActor = my2DActor;
781 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
782 aControl->SetPrecision( myControlsPrecision );
783 aFunctor.reset( aControl );
784 myControlActor = my2DActor;
789 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
790 aControl->SetPrecision( myControlsPrecision );
791 aFunctor.reset( aControl );
792 myControlActor = my3DActor;
797 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
798 aControl->SetPrecision( myControlsPrecision );
799 aFunctor.reset( aControl );
800 myControlActor = my3DActor;
805 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
806 aControl->SetPrecision( myControlsPrecision );
807 aFunctor.reset( aControl );
808 myControlActor = my2DActor;
813 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
814 aControl->SetPrecision( myControlsPrecision );
815 aFunctor.reset( aControl );
816 myControlActor = my2DActor;
821 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
822 aControl->SetPrecision( myControlsPrecision );
823 aFunctor.reset( aControl );
824 myControlActor = my2DActor;
831 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
832 vtkIdType aNbCells = aGrid->GetNumberOfCells();
834 myControlMode = theMode;
835 switch(myControlMode){
837 myNodeExtActor->SetExtControlMode(aFunctor);
841 my1DExtActor->SetExtControlMode(aFunctor);
844 my2DExtActor->SetExtControlMode(aFunctor);
847 case eMultiConnection2D:
848 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
851 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
855 if(theCheckEntityMode){
856 if(myControlActor == my1DActor)
857 SetEntityMode(eEdges);
858 else if(myControlActor == my2DActor){
859 switch(myControlMode){
863 case eMultiConnection2D:
864 //SetEntityMode(eEdges);
865 SetEntityMode(eFaces);
868 SetEntityMode(eFaces);
870 }else if(myControlActor == my3DActor)
871 SetEntityMode(eVolumes);
874 }else if(theCheckEntityMode){
875 myEntityMode = eAllEntity;
878 SetRepresentation(GetRepresentation());
880 myTimeStamp->Modified();
885 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
886 theRenderer->AddActor(myNodeActor);
887 theRenderer->AddActor(myBaseActor);
889 theRenderer->AddActor(myNodeExtActor);
891 my3DActor->AddToRender(theRenderer);
892 my2DActor->AddToRender(theRenderer);
893 my2DExtActor->AddToRender(theRenderer);
895 theRenderer->AddActor(my1DActor);
896 theRenderer->AddActor(my1DExtActor);
898 theRenderer->AddActor(my0DActor);
899 //theRenderer->AddActor(my0DExtActor);
901 theRenderer->AddActor(myHighlitableActor);
903 theRenderer->AddActor2D(myScalarBarActor);
905 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
906 myClsSelectVisiblePoints->SetRenderer(theRenderer);
908 theRenderer->AddActor2D(myPointLabels);
909 theRenderer->AddActor2D(myCellsLabels);
911 // the superclass' method should be called at the end
912 // (in particular, for correct work of selection)
913 SALOME_Actor::AddToRender(theRenderer);
916 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
917 SALOME_Actor::RemoveFromRender(theRenderer);
919 theRenderer->RemoveActor(myNodeActor);
920 theRenderer->RemoveActor(myBaseActor);
922 theRenderer->RemoveActor(myNodeExtActor);
924 theRenderer->RemoveActor(myHighlitableActor);
926 theRenderer->RemoveActor(my0DActor);
927 //theRenderer->RemoveActor(my0DExtActor);
929 theRenderer->RemoveActor(my1DActor);
930 theRenderer->RemoveActor(my1DExtActor);
932 my2DActor->RemoveFromRender(theRenderer);
933 my2DExtActor->RemoveFromRender(theRenderer);
934 my3DActor->RemoveFromRender(theRenderer);
936 theRenderer->RemoveActor(myScalarBarActor);
937 theRenderer->RemoveActor(myPointLabels);
938 theRenderer->RemoveActor(myCellsLabels);
942 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
943 const char* theEntry,
947 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
951 myVisualObj = theVisualObj;
952 myVisualObj->Update(theIsClear);
954 myNodeActor->Init(myVisualObj,myImplicitBoolean);
955 myBaseActor->Init(myVisualObj,myImplicitBoolean);
957 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
959 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
961 my0DActor->Init(myVisualObj,myImplicitBoolean);
962 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
964 my1DActor->Init(myVisualObj,myImplicitBoolean);
965 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
967 my2DActor->Init(myVisualObj,myImplicitBoolean);
968 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
969 my3DActor->Init(myVisualObj,myImplicitBoolean);
971 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
972 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
974 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
975 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
977 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
978 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
979 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
981 vtkFloatingPointType aFactor, aUnits;
982 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
983 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
984 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
986 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
990 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
991 SetIsShrunkable(true);
993 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
995 int aMode = mgr->integerValue( "SMESH", "display_mode" );
996 SetRepresentation(-1);
999 SetRepresentation(eEdge);
1000 }else if(aMode == 1){
1001 SetRepresentation(eSurface);
1002 }else if(aMode == 2){
1003 SetRepresentation(ePoint);
1010 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1011 SetIsDisplayNameActor( true );
1013 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1014 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1015 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1017 myTimeStamp->Modified();
1023 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1024 return myNodeActor->GetBounds();
1028 vtkDataSet* SMESH_ActorDef::GetInput(){
1029 return GetUnstructuredGrid();
1033 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1034 Superclass::SetTransform(theTransform);
1036 myNodeActor->SetTransform(theTransform);
1037 myBaseActor->SetTransform(theTransform);
1039 myHighlitableActor->SetTransform(theTransform);
1041 myNodeExtActor->SetTransform(theTransform);
1043 my0DActor->SetTransform(theTransform);
1044 //my0DExtActor->SetTransform(theTransform);
1046 my1DActor->SetTransform(theTransform);
1047 my1DExtActor->SetTransform(theTransform);
1049 my2DActor->SetTransform(theTransform);
1050 my2DExtActor->SetTransform(theTransform);
1051 my3DActor->SetTransform(theTransform);
1057 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1058 vtkLODActor::SetMapper(theMapper);
1062 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1063 SALOME_Actor::ShallowCopy(prop);
1067 vtkMapper* SMESH_ActorDef::GetMapper(){
1068 return myPickableActor->GetMapper();
1072 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1073 return myVisualObj->GetUnstructuredGrid();
1077 bool SMESH_ActorDef::IsInfinitive(){
1078 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1080 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1081 ( aDataSet->GetNumberOfCells() == 1 &&
1082 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1083 return SALOME_Actor::IsInfinitive();
1087 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1088 if ( myIsShrinkable == theShrunkable )
1090 myIsShrinkable = theShrunkable;
1094 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1095 return myBaseActor->GetShrinkFactor();
1098 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1099 myBaseActor->SetShrinkFactor(theValue);
1101 my1DActor->SetShrinkFactor(theValue);
1102 my1DExtActor->SetShrinkFactor(theValue);
1104 my2DActor->SetShrinkFactor(theValue);
1105 my2DExtActor->SetShrinkFactor(theValue);
1106 my3DActor->SetShrinkFactor(theValue);
1111 void SMESH_ActorDef::SetShrink(){
1112 if(!myIsShrinkable) return;
1114 myBaseActor->SetShrink();
1116 my1DActor->SetShrink();
1117 my1DExtActor->SetShrink();
1119 my2DActor->SetShrink();
1120 my2DExtActor->SetShrink();
1121 my3DActor->SetShrink();
1127 void SMESH_ActorDef::UnShrink(){
1128 if(!myIsShrunk) return;
1130 myBaseActor->UnShrink();
1132 my1DActor->UnShrink();
1133 my1DExtActor->UnShrink();
1135 my2DActor->UnShrink();
1136 my2DExtActor->UnShrink();
1137 my3DActor->UnShrink();
1144 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1145 return myPickableActor->GetNodeObjId(theVtkID);
1148 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1149 return myPickableActor->GetNodeCoord(theObjID);
1153 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1154 return myPickableActor->GetElemObjId(theVtkID);
1157 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1158 return myPickableActor->GetElemCell(theObjID);
1162 void SMESH_ActorDef::SetVisibility(int theMode){
1163 SetVisibility(theMode,true);
1167 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1168 SALOME_Actor::SetVisibility(theMode);
1170 myNodeActor->VisibilityOff();
1171 myBaseActor->VisibilityOff();
1173 myNodeExtActor->VisibilityOff();
1175 my0DActor->VisibilityOff();
1176 //my0DExtActor->VisibilityOff();
1178 my1DActor->VisibilityOff();
1179 my1DExtActor->VisibilityOff();
1181 my2DActor->VisibilityOff();
1182 my2DExtActor->VisibilityOff();
1183 my3DActor->VisibilityOff();
1185 myScalarBarActor->VisibilityOff();
1186 myPointLabels->VisibilityOff();
1187 myCellsLabels->VisibilityOff();
1189 if(GetVisibility()){
1190 if(theIsUpdateRepersentation)
1191 SetRepresentation(GetRepresentation());
1193 if(myControlMode != eNone){
1194 switch(myControlMode){
1196 myNodeExtActor->VisibilityOn();
1200 my1DExtActor->VisibilityOn();
1203 my2DExtActor->VisibilityOn();
1206 case eMultiConnection2D:
1207 my1DExtActor->VisibilityOn();
1209 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1210 myScalarBarActor->VisibilityOn();
1214 if(myRepresentation != ePoint)
1215 myPickableActor->VisibilityOn();
1217 myNodeActor->VisibilityOn();
1220 if(myEntityMode & e0DElements){
1221 my0DActor->VisibilityOn();
1224 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1225 my1DActor->VisibilityOn();
1228 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1229 my2DActor->VisibilityOn();
1232 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1233 my3DActor->VisibilityOn();
1236 if(myIsPointsLabeled){
1237 myPointLabels->VisibilityOn();
1238 myNodeActor->VisibilityOn();
1241 if(myIsCellsLabeled)
1242 myCellsLabels->VisibilityOn();
1249 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1251 myEntityState = eAllEntity;
1253 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1254 myEntityState &= ~e0DElements;
1255 theMode &= ~e0DElements;
1258 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1259 myEntityState &= ~eEdges;
1263 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1264 myEntityState &= ~eFaces;
1268 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1269 myEntityState &= ~eVolumes;
1270 theMode &= ~eVolumes;
1274 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1275 theMode |= e0DElements;
1277 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1280 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1283 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1284 theMode |= eVolumes;
1287 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1289 myEntityMode = theMode;
1290 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1291 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1292 aFilter->ClearRegisteredCellsWithType();
1293 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1295 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1296 aHightFilter->ClearRegisteredCellsWithType();
1297 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1299 if (myEntityMode & e0DElements) {
1300 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1301 aFilter->RegisterCellsWithType(VTK_VERTEX);
1302 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1305 if (myEntityMode & eEdges) {
1306 if (MYDEBUG) MESSAGE("EDGES");
1307 aFilter->RegisterCellsWithType(VTK_LINE);
1308 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1310 aHightFilter->RegisterCellsWithType(VTK_LINE);
1311 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1314 if (myEntityMode & eFaces) {
1315 if (MYDEBUG) MESSAGE("FACES");
1316 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1317 aFilter->RegisterCellsWithType(VTK_POLYGON);
1318 aFilter->RegisterCellsWithType(VTK_QUAD);
1319 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1320 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1322 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1323 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1324 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1325 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1326 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1329 if (myEntityMode & eVolumes) {
1330 if (MYDEBUG) MESSAGE("VOLUMES");
1331 aFilter->RegisterCellsWithType(VTK_TETRA);
1332 aFilter->RegisterCellsWithType(VTK_VOXEL);
1333 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1334 aFilter->RegisterCellsWithType(VTK_WEDGE);
1335 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1336 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1337 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1338 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1339 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1341 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1342 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1343 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1344 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1345 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1346 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1347 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1348 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1349 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1352 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1353 SetVisibility(GetVisibility(),false);
1356 void SMESH_ActorDef::SetRepresentation (int theMode)
1358 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1359 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1360 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1363 myRepresentation = eSurface;
1364 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1365 myRepresentation = eEdge;
1366 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1367 myRepresentation = ePoint;
1372 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1375 if (!aNbFaces && !aNbVolumes) return;
1378 myRepresentation = theMode;
1381 if (!GetUnstructuredGrid()->GetNumberOfCells())
1382 myRepresentation = ePoint;
1385 if (myRepresentation == ePoint) {
1393 myPickableActor = myBaseActor;
1394 myNodeActor->SetVisibility(false);
1395 myNodeExtActor->SetVisibility(false);
1396 vtkProperty *aProp = NULL, *aBackProp = NULL;
1397 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1398 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1399 switch (myRepresentation) {
1401 myPickableActor = myNodeActor;
1402 myNodeActor->SetVisibility(true);
1403 aQuadraticMode = SMESH_Actor::eLines;
1404 aProp = aBackProp = myNodeProp;
1405 aReperesent = SMESH_DeviceActor::ePoint;
1408 aProp = aBackProp = myEdgeProp;
1409 aReperesent = SMESH_DeviceActor::eInsideframe;
1412 aProp = mySurfaceProp;
1413 aBackProp = myBackSurfaceProp;
1414 aReperesent = SMESH_DeviceActor::eSurface;
1418 my2DActor->SetProperty(aProp);
1419 my2DActor->SetBackfaceProperty(aBackProp);
1420 my2DActor->SetRepresentation(aReperesent);
1422 if(aQuadraticMode == SMESH_Actor::eLines)
1423 my2DActor->SetQuadraticArcMode(false);
1424 else if(aQuadraticMode == SMESH_Actor::eArcs)
1425 my2DActor->SetQuadraticArcMode(true);
1427 my2DExtActor->SetRepresentation(aReperesent);
1429 my3DActor->SetProperty(aProp);
1430 my3DActor->SetBackfaceProperty(aBackProp);
1431 my3DActor->SetRepresentation(aReperesent);
1433 //my0DExtActor->SetVisibility(false);
1434 my1DExtActor->SetVisibility(false);
1435 my2DExtActor->SetVisibility(false);
1438 //my0DActor->SetProperty(aProp);
1439 //my0DActor->SetBackfaceProperty(aBackProp);
1440 my0DActor->SetRepresentation(aReperesent);
1441 //my0DExtActor->SetRepresentation(aReperesent);
1443 switch(myControlMode){
1445 case eMultiConnection:
1446 aProp = aBackProp = my1DProp;
1447 if(myRepresentation != ePoint)
1448 aReperesent = SMESH_DeviceActor::eInsideframe;
1452 if(aQuadraticMode == SMESH_Actor::eLines)
1453 my1DActor->SetQuadraticArcMode(false);
1454 else if(aQuadraticMode == SMESH_Actor::eArcs)
1455 my1DActor->SetQuadraticArcMode(true);
1457 my1DActor->SetProperty(aProp);
1458 my1DActor->SetBackfaceProperty(aBackProp);
1459 my1DActor->SetRepresentation(aReperesent);
1461 my1DExtActor->SetRepresentation(aReperesent);
1463 if(myIsPointsVisible)
1464 myPickableActor = myNodeActor;
1465 if(GetPointRepresentation())
1466 myNodeActor->SetVisibility(true);
1468 SetMapper(myPickableActor->GetMapper());
1470 SetVisibility(GetVisibility(),false);
1476 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1477 if ( myIsPointsVisible == theIsPointsVisible )
1479 myIsPointsVisible = theIsPointsVisible;
1480 SetRepresentation(GetRepresentation());
1483 bool SMESH_ActorDef::GetPointRepresentation(){
1484 return myIsPointsVisible || myIsPointsLabeled;
1488 void SMESH_ActorDef::UpdateHighlight(){
1489 myHighlitableActor->SetVisibility(false);
1490 myHighlitableActor->SetHighlited(false);
1492 if(myIsHighlighted){
1493 myHighlitableActor->SetProperty(myHighlightProp);
1494 }else if(myIsPreselected){
1495 myHighlitableActor->SetProperty(myPreselectProp);
1498 bool anIsVisible = GetVisibility();
1500 if(myIsHighlighted || myIsPreselected){
1501 if(GetUnstructuredGrid()->GetNumberOfCells()){
1502 myHighlitableActor->SetHighlited(anIsVisible);
1503 myHighlitableActor->SetVisibility(anIsVisible);
1504 myHighlitableActor->GetExtractUnstructuredGrid()->
1505 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1506 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1507 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1508 myHighlitableActor->SetHighlited(anIsVisible);
1509 myHighlitableActor->GetExtractUnstructuredGrid()->
1510 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1511 myHighlitableActor->SetVisibility(anIsVisible);
1512 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1514 VTK::MarkerType aMarkerType = GetMarkerType();
1515 if(aMarkerType != VTK::MT_USER)
1516 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1518 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1524 void SMESH_ActorDef::highlight(bool theHighlight){
1525 if ( myIsHighlighted == theHighlight )
1527 myIsHighlighted = theHighlight;
1532 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1533 if ( myIsPreselected == thePreselect )
1535 myIsPreselected = thePreselect;
1541 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1543 if (myPickableActor->GetIsOpaque())
1545 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1553 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1555 if (!myPickableActor->GetIsOpaque())
1557 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1565 void SMESH_ActorDef::Render(vtkRenderer *ren){
1566 unsigned long aTime = myTimeStamp->GetMTime();
1567 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1568 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1569 if(anObjTime > aTime || aClippingTime > aTime)
1574 void SMESH_ActorDef::Update(){
1575 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1577 if(GetControlMode() != eNone) {
1578 unsigned long aTime = myTimeStamp->GetMTime();
1579 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1580 if (anObjTime > aTime)
1581 SetControlMode(GetControlMode(),false);
1583 if(myIsPointsLabeled){
1584 SetPointsLabeled(myIsPointsLabeled);
1586 if(myIsCellsLabeled){
1587 SetCellsLabeled(myIsCellsLabeled);
1589 if(myIsFacesOriented){
1590 SetFacesOriented(myIsFacesOriented);
1592 SetEntityMode(GetEntityMode());
1593 SetVisibility(GetVisibility());
1595 myTimeStamp->Modified();
1600 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1601 SALOME_Actor::ReleaseGraphicsResources(renWin);
1603 myPickableActor->ReleaseGraphicsResources(renWin);
1607 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1608 vtkFloatingPointType* aColor = theProperty->GetColor();
1615 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1616 mySurfaceProp->SetOpacity(theValue);
1617 myBackSurfaceProp->SetOpacity(theValue);
1618 myEdgeProp->SetOpacity(theValue);
1619 myNodeProp->SetOpacity(theValue);
1621 my1DProp->SetOpacity(theValue);
1625 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1626 return mySurfaceProp->GetOpacity();
1630 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1631 mySurfaceProp->SetColor(r,g,b);
1632 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1633 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1634 aGroupObj->GetElementType() == SMDSAbs_Volume )
1635 myNameActor->SetBackgroundColor(r,g,b);
1639 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1640 ::GetColor(mySurfaceProp,r,g,b);
1641 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1644 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1645 myBackSurfaceProp->SetColor(r,g,b);
1649 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1650 ::GetColor(myBackSurfaceProp,r,g,b);
1653 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1654 myEdgeProp->SetColor(r,g,b);
1655 my1DProp->SetColor(r,g,b);
1656 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1657 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1658 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1659 myNameActor->SetBackgroundColor(r,g,b);
1663 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1664 ::GetColor(myEdgeProp,r,g,b);
1667 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1668 myNodeProp->SetColor(r,g,b);
1669 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1670 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1671 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1672 myNameActor->SetBackgroundColor(r,g,b);
1676 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1677 ::GetColor(myNodeProp,r,g,b);
1680 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1681 my0DProp->SetColor(r,g,b);
1682 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1683 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1684 myNameActor->SetBackgroundColor(r,g,b);
1688 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1689 ::GetColor(my0DProp,r,g,b);
1692 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1693 myHighlightProp->SetColor(r,g,b);
1697 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1698 ::GetColor(myHighlightProp,r,g,b);
1701 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1702 myPreselectProp->SetColor(r,g,b);
1706 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1707 ::GetColor(myPreselectProp,r,g,b);
1711 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1712 return myEdgeProp->GetLineWidth();
1716 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1717 myEdgeProp->SetLineWidth(theVal);
1719 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1720 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1726 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1727 my0DProp->SetPointSize(theVal);
1731 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1732 return my0DProp->GetPointSize();
1735 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1737 return myVisualObj->GetElemDimension( theObjId );
1742 IsImplicitFunctionUsed() const
1744 return myBaseActor->IsImplicitFunctionUsed();
1748 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1750 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1751 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1753 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1755 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1757 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1758 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1760 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1761 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1763 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1764 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1765 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1769 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1772 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1773 myCippingPlaneCont.push_back(thePlane);
1774 if(!IsImplicitFunctionUsed())
1775 SetImplicitFunctionUsed(true);
1777 return myCippingPlaneCont.size();
1782 RemoveAllClippingPlanes()
1784 myImplicitBoolean->GetFunction()->RemoveAllItems();
1785 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1786 myCippingPlaneCont.clear();
1787 SetImplicitFunctionUsed(false);
1792 GetNumberOfClippingPlanes()
1794 return myCippingPlaneCont.size();
1799 GetClippingPlane(vtkIdType theID)
1801 if(theID >= myCippingPlaneCont.size())
1803 return myCippingPlaneCont[theID].Get();
1807 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1808 vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1809 vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1811 vtkFloatingPointType aBounds[6];
1812 theDataSet->GetBounds(aBounds);
1814 //Enlarge bounds in order to avoid conflicts of precision
1815 for(int i = 0; i < 6; i += 2){
1816 static double EPS = 1.0E-3;
1817 vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1818 aBounds[i] -= aDelta;
1819 aBounds[i+1] += aDelta;
1822 vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1823 {aBounds[1],aBounds[2],aBounds[4]},
1824 {aBounds[0],aBounds[3],aBounds[4]},
1825 {aBounds[1],aBounds[3],aBounds[4]},
1826 {aBounds[0],aBounds[2],aBounds[5]},
1827 {aBounds[1],aBounds[2],aBounds[5]},
1828 {aBounds[0],aBounds[3],aBounds[5]},
1829 {aBounds[1],aBounds[3],aBounds[5]}};
1831 int aMaxId = 0, aMinId = aMaxId;
1832 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1833 theMinBoundPrj = theMaxBoundPrj;
1834 for(int i = 1; i < 8; i++){
1835 vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1836 if(theMaxBoundPrj < aTmp){
1837 theMaxBoundPrj = aTmp;
1840 if(theMinBoundPrj > aTmp){
1841 theMinBoundPrj = aTmp;
1845 vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1846 theMinPnt[0] = aMinPnt[0];
1847 theMinPnt[1] = aMinPnt[1];
1848 theMinPnt[2] = aMinPnt[2];
1852 static void DistanceToPosition(vtkDataSet* theDataSet,
1853 vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1855 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1856 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1857 vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1858 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1859 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1860 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1864 static void PositionToDistance(vtkDataSet* theDataSet,
1865 vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1867 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1868 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1869 vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1870 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1874 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1876 thePlane->SetNormal(theDir);
1877 vtkFloatingPointType anOrigin[3];
1878 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1879 thePlane->SetOrigin(anOrigin);
1883 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1885 thePlane->GetNormal(theDir);
1887 vtkFloatingPointType anOrigin[3];
1888 thePlane->GetOrigin(anOrigin);
1889 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1892 void SMESH_ActorDef::UpdateScalarBar()
1894 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1898 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1900 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1901 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1903 aScalarBarTitleProp->SetFontFamilyToArial();
1905 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1907 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1908 if ( f.family() == "Arial" )
1909 aScalarBarTitleProp->SetFontFamilyToArial();
1910 else if ( f.family() == "Courier" )
1911 aScalarBarTitleProp->SetFontFamilyToCourier();
1912 else if ( f.family() == "Times" )
1913 aScalarBarTitleProp->SetFontFamilyToTimes();
1916 aScalarBarTitleProp->BoldOn();
1918 aScalarBarTitleProp->BoldOff();
1921 aScalarBarTitleProp->ItalicOn();
1923 aScalarBarTitleProp->ItalicOff();
1926 aScalarBarTitleProp->ShadowOn();
1928 aScalarBarTitleProp->ShadowOff();
1931 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1932 aScalarBarTitleProp->Delete();
1934 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1936 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1937 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1939 aScalarBarLabelProp->SetFontFamilyToArial();
1940 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1942 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1943 if( f.family() == "Arial" )
1944 aScalarBarLabelProp->SetFontFamilyToArial();
1945 else if( f.family() == "Courier" )
1946 aScalarBarLabelProp->SetFontFamilyToCourier();
1947 else if( f.family() == "Times" )
1948 aScalarBarLabelProp->SetFontFamilyToTimes();
1951 aScalarBarLabelProp->BoldOn();
1953 aScalarBarLabelProp->BoldOff();
1956 aScalarBarLabelProp->ItalicOn();
1958 aScalarBarLabelProp->ItalicOff();
1961 aScalarBarLabelProp->ShadowOn();
1963 aScalarBarLabelProp->ShadowOff();
1966 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1967 aScalarBarLabelProp->Delete();
1969 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1970 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1972 myScalarBarActor->SetOrientationToHorizontal();
1974 myScalarBarActor->SetOrientationToVertical();
1977 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1978 if( mgr->hasValue( "SMESH", name + "x" ) )
1979 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1981 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1982 if( mgr->hasValue( "SMESH", name + "y" ) )
1983 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1984 myScalarBarActor->SetPosition( aXVal, aYVal );
1986 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1987 if( mgr->hasValue( "SMESH", name + "width" ) )
1988 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1989 myScalarBarActor->SetWidth( aWVal );
1991 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1992 if( mgr->hasValue( "SMESH", name + "height" ) )
1993 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1994 myScalarBarActor->SetHeight( aHVal );
1997 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1998 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1999 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2002 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2003 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2004 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2008 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2011 case SMESH_Actor::eLines :
2012 myHighlitableActor->SetQuadraticArcMode(false);
2013 my2DActor->SetQuadraticArcMode(false);
2014 my1DActor->SetQuadraticArcMode(false);
2016 case SMESH_Actor::eArcs :
2017 myHighlitableActor->SetQuadraticArcMode(true);
2018 if(GetRepresentation() != SMESH_Actor::ePoint) {
2019 my2DActor->SetQuadraticArcMode(true);
2020 my1DActor->SetQuadraticArcMode(true);
2029 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2031 if(myHighlitableActor->GetQuadraticArcMode())
2032 return SMESH_Actor::eArcs;
2034 return SMESH_Actor::eLines;
2037 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2039 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2040 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2041 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2044 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2046 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2047 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2048 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2049 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor