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 "SMESH_ScalarBarActor.h"
34 #include "VTKViewer_CellCenters.h"
35 #include "VTKViewer_ExtractUnstructuredGrid.h"
36 #include "VTKViewer_FramedTextActor.h"
37 #include "SALOME_InteractiveObject.hxx"
39 #include "SUIT_Session.h"
40 #include "SUIT_ResourceMgr.h"
42 #include <vtkProperty.h>
43 #include <vtkTimeStamp.h>
44 #include <vtkObjectFactory.h>
45 #include <vtkShrinkPolyData.h>
46 #include <vtkMergeFilter.h>
48 #include <vtkMatrix4x4.h>
49 #include <vtkUnstructuredGrid.h>
50 #include <vtkPointData.h>
51 #include <vtkCellData.h>
53 #include <vtkMapper.h>
54 #include <vtkRenderer.h>
57 #include <vtkIdList.h>
58 #include <vtkIntArray.h>
60 #include <vtkActor2D.h>
61 #include <vtkProperty2D.h>
62 #include <vtkPolyData.h>
63 #include <vtkMaskPoints.h>
64 #include <vtkTextProperty.h>
65 #include <vtkLabeledDataMapper.h>
66 #include <vtkSelectVisiblePoints.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 my3DExtActor = SMESH_DeviceActor::New();
203 my3DExtActor->SetUserMatrix(aMatrix);
204 my3DExtActor->PickableOff();
205 my3DExtActor->SetProperty(my2DExtProp);
206 my3DExtActor->SetBackfaceProperty(my2DExtProp);
207 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
208 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
209 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
210 aFilter->RegisterCellsWithType(VTK_TETRA);
211 aFilter->RegisterCellsWithType(VTK_VOXEL);
212 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
213 aFilter->RegisterCellsWithType(VTK_WEDGE);
214 aFilter->RegisterCellsWithType(VTK_PYRAMID);
215 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
216 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
217 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
218 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
219 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
221 //Definition 1D device of the actor
222 //---------------------------------
223 myEdgeProp = vtkProperty::New();
224 myEdgeProp->SetAmbient(1.0);
225 myEdgeProp->SetDiffuse(0.0);
226 myEdgeProp->SetSpecular(0.0);
227 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
228 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
229 myEdgeProp->SetLineWidth(aLineWidth);
231 my1DActor = SMESH_DeviceActor::New();
232 my1DActor->SetUserMatrix(aMatrix);
233 my1DActor->PickableOff();
234 my1DActor->SetHighlited(true);
235 my1DActor->SetProperty(myEdgeProp);
236 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
237 aFilter = my1DActor->GetExtractUnstructuredGrid();
238 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
239 aFilter->RegisterCellsWithType(VTK_LINE);
240 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
242 my1DProp = vtkProperty::New();
243 my1DProp->DeepCopy(myEdgeProp);
244 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
245 my1DProp->SetPointSize(aElem0DSize);
247 my1DExtProp = vtkProperty::New();
248 my1DExtProp->DeepCopy(myEdgeProp);
249 anRGB[0] = 1 - anRGB[0];
250 anRGB[1] = 1 - anRGB[1];
251 anRGB[2] = 1 - anRGB[2];
252 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
253 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
254 my1DExtProp->SetPointSize(aElem0DSize);
256 my1DExtActor = SMESH_DeviceActor::New();
257 my1DExtActor->SetUserMatrix(aMatrix);
258 my1DExtActor->PickableOff();
259 my1DExtActor->SetHighlited(true);
260 my1DExtActor->SetVisibility(false);
261 my1DExtActor->SetProperty(my1DExtProp);
262 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
263 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
264 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
265 aFilter->RegisterCellsWithType(VTK_LINE);
266 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
269 //Definition 0D device of the actor (0d elements)
270 //-----------------------------------------------
271 my0DProp = vtkProperty::New();
272 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
273 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
274 my0DProp->SetPointSize(aElem0DSize);
276 my0DActor = SMESH_DeviceActor::New();
277 my0DActor->SetUserMatrix(aMatrix);
278 my0DActor->SetStoreClippingMapping(true);
279 my0DActor->PickableOff();
280 my0DActor->SetVisibility(false);
281 my0DActor->SetProperty(my0DProp);
282 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
283 aFilter = my0DActor->GetExtractUnstructuredGrid();
284 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
285 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
286 aFilter->RegisterCellsWithType(VTK_VERTEX);
288 //my0DExtProp = vtkProperty::New();
289 //my0DExtProp->DeepCopy(my0DProp);
290 //anRGB[0] = 1 - anRGB[0];
291 //anRGB[1] = 1 - anRGB[1];
292 //anRGB[2] = 1 - anRGB[2];
293 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
294 //my0DExtProp->SetPointSize(aElem0DSize);
296 //my0DExtActor = SMESH_DeviceActor::New();
297 //my0DExtActor->SetUserMatrix(aMatrix);
298 //my0DExtActor->SetStoreClippingMapping(true);
299 //my0DExtActor->PickableOff();
300 //my0DExtActor->SetHighlited(true);
301 //my0DExtActor->SetVisibility(false);
302 //my0DExtActor->SetProperty(my0DExtProp);
303 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
304 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
305 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
306 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
307 //aFilter->RegisterCellsWithType(VTK_VERTEX);
310 //Definition 0D device of the actor (nodes)
311 //-----------------------------------------
312 myNodeProp = vtkProperty::New();
313 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
314 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
316 myNodeActor = SMESH_DeviceActor::New();
317 myNodeActor->SetUserMatrix(aMatrix);
318 myNodeActor->SetStoreClippingMapping(true);
319 myNodeActor->PickableOff();
320 myNodeActor->SetVisibility(false);
321 myNodeActor->SetProperty(myNodeProp);
322 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
323 aFilter = myNodeActor->GetExtractUnstructuredGrid();
324 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
326 myNodeExtProp = vtkProperty::New();
327 myNodeExtProp->DeepCopy(myNodeProp);
328 anRGB[0] = 1 - anRGB[0];
329 anRGB[1] = 1 - anRGB[1];
330 anRGB[2] = 1 - anRGB[2];
331 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
333 myNodeExtActor = SMESH_DeviceActor::New();
334 myNodeExtActor->SetUserMatrix(aMatrix);
335 myNodeExtActor->SetStoreClippingMapping(true);
336 myNodeExtActor->PickableOff();
337 myNodeExtActor->SetHighlited(true);
338 myNodeExtActor->SetVisibility(false);
339 myNodeExtActor->SetProperty(myNodeExtProp);
340 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
341 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
342 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
343 aFilter->RegisterCellsWithType(VTK_VERTEX);
345 //Definition of Pickable and Highlitable engines
346 //----------------------------------------------
348 myBaseActor = SMESH_DeviceActor::New();
349 myBaseActor->SetUserMatrix(aMatrix);
350 myBaseActor->SetStoreGemetryMapping(true);
351 myBaseActor->GetProperty()->SetOpacity(0.0);
353 myPickableActor = myBaseActor;
355 myHighlightProp = vtkProperty::New();
356 myHighlightProp->SetAmbient(1.0);
357 myHighlightProp->SetDiffuse(0.0);
358 myHighlightProp->SetSpecular(0.0);
359 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
360 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
361 myHighlightProp->SetPointSize(aElem0DSize); // ??
362 myHighlightProp->SetRepresentation(1);
364 myPreselectProp = vtkProperty::New();
365 myPreselectProp->SetAmbient(1.0);
366 myPreselectProp->SetDiffuse(0.0);
367 myPreselectProp->SetSpecular(0.0);
368 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
369 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
370 myPreselectProp->SetPointSize(aElem0DSize); // ??
371 myPreselectProp->SetRepresentation(1);
373 myHighlitableActor = SMESH_DeviceActor::New();
374 myHighlitableActor->SetUserMatrix(aMatrix);
375 myHighlitableActor->PickableOff();
376 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
383 myControlMode = eNone;
384 myControlActor = my2DActor;
386 //Definition of myScalarBarActor
387 //------------------------------
388 myLookupTable = vtkLookupTable::New();
389 //Fix for Bug PAL5195 - SMESH764:
390 //Controls - Aspect Ratio: incorrect colors of the best and worst values
391 myLookupTable->SetHueRange(0.667,0.0);
393 myScalarBarActor = SMESH_ScalarBarActor::New();
394 myScalarBarActor->SetVisibility(false);
395 myScalarBarActor->SetLookupTable(myLookupTable);
398 //Incorrect "Min value" in Scalar Bar in Mesh:
399 // myScalarBarActor->SetLabelFormat("%.4g");
400 // changes was commented because of regression bug IPAL 19981
402 mgr = SUIT_Session::session()->resourceMgr();
406 //Definition of points numbering pipeline
407 //---------------------------------------
408 myPointsNumDataSet = vtkUnstructuredGrid::New();
410 myPtsMaskPoints = vtkMaskPoints::New();
411 myPtsMaskPoints->SetInput(myPointsNumDataSet);
412 myPtsMaskPoints->SetOnRatio(1);
414 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
415 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
416 myPtsSelectVisiblePoints->SelectInvisibleOff();
417 myPtsSelectVisiblePoints->SetTolerance(0.1);
419 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
420 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
421 #if (VTK_XVERSION < 0x050200)
422 myPtsLabeledDataMapper->SetLabelFormat("%g");
424 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
426 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
427 aPtsTextProp->SetFontFamilyToTimes();
428 static int aPointsFontSize = 10;
429 aPtsTextProp->SetFontSize(aPointsFontSize);
430 aPtsTextProp->SetBold(1);
431 aPtsTextProp->SetItalic(0);
432 aPtsTextProp->SetShadow(0);
433 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
434 aPtsTextProp->Delete();
436 myEntityMode = eAllEntity;
438 myIsPointsLabeled = false;
440 myPointLabels = vtkActor2D::New();
441 myPointLabels->SetMapper(myPtsLabeledDataMapper);
442 myPointLabels->GetProperty()->SetColor(1,1,1);
443 myPointLabels->SetVisibility(myIsPointsLabeled);
446 //Definition of cells numbering pipeline
447 //---------------------------------------
448 myCellsNumDataSet = vtkUnstructuredGrid::New();
450 myCellCenters = VTKViewer_CellCenters::New();
451 myCellCenters->SetInput(myCellsNumDataSet);
453 myClsMaskPoints = vtkMaskPoints::New();
454 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
455 myClsMaskPoints->SetOnRatio(1);
457 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
458 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
459 myClsSelectVisiblePoints->SelectInvisibleOff();
460 myClsSelectVisiblePoints->SetTolerance(0.1);
462 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
463 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
464 #if (VTK_XVERSION < 0x050200)
465 myClsLabeledDataMapper->SetLabelFormat("%g");
467 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
469 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
470 aClsTextProp->SetFontFamilyToTimes();
471 static int aCellsFontSize = 12;
472 aClsTextProp->SetFontSize(aCellsFontSize);
473 aClsTextProp->SetBold(1);
474 aClsTextProp->SetItalic(0);
475 aClsTextProp->SetShadow(0);
476 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
477 aClsTextProp->Delete();
479 myIsCellsLabeled = false;
481 myCellsLabels = vtkActor2D::New();
482 myCellsLabels->SetMapper(myClsLabeledDataMapper);
483 myCellsLabels->GetProperty()->SetColor(0,1,0);
484 myCellsLabels->SetVisibility(myIsCellsLabeled);
487 myImplicitBoolean = vtkImplicitBoolean::New();
488 myImplicitBoolean->SetOperationTypeToIntersection();
492 //Quadratic 2D elements representation
493 //-----------------------------------------------------------------------------
494 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
495 if(aQuadratic2DMode == 0){
496 myHighlitableActor->SetQuadraticArcMode(false);
497 my2DActor->SetQuadraticArcMode(false);
498 my1DActor->SetQuadraticArcMode(false);
500 else if(aQuadratic2DMode == 1){
501 myHighlitableActor->SetQuadraticArcMode(true);
502 my2DActor->SetQuadraticArcMode(true);
503 my1DActor->SetQuadraticArcMode(true);
506 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
507 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
508 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
510 // Set colors of the name actor
511 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
512 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
513 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
514 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
518 SMESH_ActorDef::~SMESH_ActorDef()
520 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
522 // caught by SMESHGUI::ProcessEvents() static method
523 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
525 myScalarBarActor->Delete();
526 myLookupTable->Delete();
528 mySurfaceProp->Delete();
529 myBackSurfaceProp->Delete();
531 myEdgeProp->Delete();
532 myHighlightProp->Delete();
533 myPreselectProp->Delete();
535 myNodeProp->Delete();
536 myNodeExtProp->Delete();
541 //my0DExtProp->Delete();
542 //my0DExtActor->Delete();
547 my1DExtProp->Delete();
548 my1DExtActor->Delete();
551 my2DExtProp->Delete();
552 my2DExtActor->Delete();
554 my3DExtActor->Delete();
556 myNodeActor->Delete();
557 myBaseActor->Delete();
559 myNodeExtActor->Delete();
561 myHighlitableActor->Delete();
563 //Deleting of points numbering pipeline
564 //---------------------------------------
565 myPointsNumDataSet->Delete();
567 // commented: porting to vtk 5.0
568 // myPtsLabeledDataMapper->RemoveAllInputs();
569 myPtsLabeledDataMapper->Delete();
571 // commented: porting to vtk 5.0
572 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
573 myPtsSelectVisiblePoints->Delete();
575 // commented: porting to vtk 5.0
576 // myPtsMaskPoints->UnRegisterAllOutputs();
577 myPtsMaskPoints->Delete();
579 myPointLabels->Delete();
582 //Deleting of cells numbering pipeline
583 //---------------------------------------
584 myCellsNumDataSet->Delete();
586 myClsLabeledDataMapper->RemoveAllInputs();
587 myClsLabeledDataMapper->Delete();
589 // commented: porting to vtk 5.0
590 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
591 myClsSelectVisiblePoints->Delete();
593 // commented: porting to vtk 5.0
594 // myClsMaskPoints->UnRegisterAllOutputs();
595 myClsMaskPoints->Delete();
597 // commented: porting to vtk 5.0
598 // myCellCenters->UnRegisterAllOutputs();
599 myCellCenters->Delete();
601 myCellsLabels->Delete();
603 myImplicitBoolean->Delete();
605 myTimeStamp->Delete();
609 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
611 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
613 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
615 if ( myIsPointsLabeled )
617 myPointsNumDataSet->ShallowCopy(aGrid);
618 vtkDataSet *aDataSet = myPointsNumDataSet;
620 int aNbElem = aDataSet->GetNumberOfPoints();
622 vtkIntArray *anArray = vtkIntArray::New();
623 anArray->SetNumberOfValues( aNbElem );
625 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
627 int aSMDSId = myVisualObj->GetNodeObjId( anId );
628 anArray->SetValue( anId, aSMDSId );
631 aDataSet->GetPointData()->SetScalars( anArray );
633 myPtsMaskPoints->SetInput( aDataSet );
634 myPointLabels->SetVisibility( GetVisibility() );
638 myPointLabels->SetVisibility( false );
640 SetRepresentation(GetRepresentation());
641 myTimeStamp->Modified();
645 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
647 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
648 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
649 if(myIsCellsLabeled){
650 myCellsNumDataSet->ShallowCopy(aGrid);
651 vtkDataSet *aDataSet = myCellsNumDataSet;
652 int aNbElem = aDataSet->GetNumberOfCells();
653 vtkIntArray *anArray = vtkIntArray::New();
654 anArray->SetNumberOfValues(aNbElem);
655 for(int anId = 0; anId < aNbElem; anId++){
656 int aSMDSId = myVisualObj->GetElemObjId(anId);
657 anArray->SetValue(anId,aSMDSId);
659 aDataSet->GetCellData()->SetScalars(anArray);
660 myCellCenters->SetInput(aDataSet);
661 myCellsLabels->SetVisibility(GetVisibility());
663 myCellsLabels->SetVisibility(false);
665 myTimeStamp->Modified();
669 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
671 myIsFacesOriented = theIsFacesOriented;
673 my2DActor->SetFacesOriented(theIsFacesOriented);
674 my3DActor->SetFacesOriented(theIsFacesOriented);
676 myTimeStamp->Modified();
679 bool SMESH_ActorDef::GetFacesOriented()
681 return myIsFacesOriented;
684 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
686 my2DActor->SetFacesOrientationColor( theColor );
687 my3DActor->SetFacesOrientationColor( theColor );
690 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
692 my3DActor->GetFacesOrientationColor( theColor );
695 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
697 my2DActor->SetFacesOrientationScale( theScale );
698 my3DActor->SetFacesOrientationScale( theScale );
701 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
703 return my3DActor->GetFacesOrientationScale();
706 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
708 my2DActor->SetFacesOrientation3DVectors( theState );
709 my3DActor->SetFacesOrientation3DVectors( theState );
712 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
714 return my3DActor->GetFacesOrientation3DVectors();
720 SetControlMode(eControl theMode)
722 SetControlMode(theMode,true);
728 SetControlMode(eControl theMode,
729 bool theCheckEntityMode)
731 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
735 myControlMode = eNone;
736 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
738 my0DActor->GetMapper()->SetScalarVisibility(false);
739 my1DActor->GetMapper()->SetScalarVisibility(false);
740 my2DActor->GetMapper()->SetScalarVisibility(false);
741 my3DActor->GetMapper()->SetScalarVisibility(false);
742 myScalarBarActor->SetVisibility(false);
744 bool anIsScalarVisible = theMode > eNone;
746 if(anIsScalarVisible) {
750 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
751 aControl->SetPrecision( myControlsPrecision );
752 myFunctor.reset( aControl );
753 myControlActor = my1DActor;
758 myFunctor.reset(new SMESH::Controls::Length2D());
759 myControlActor = my2DActor;
763 myFunctor.reset(new SMESH::Controls::FreeBorders());
764 myControlActor = my1DActor;
767 myFunctor.reset(new SMESH::Controls::FreeEdges());
768 myControlActor = my2DActor;
771 myFunctor.reset(new SMESH::Controls::FreeNodes());
772 myControlActor = myNodeActor;
775 myFunctor.reset(new SMESH::Controls::FreeFaces());
776 myControlActor = my2DActor;
778 case eBareBorderFace:
779 myFunctor.reset(new SMESH::Controls::BareBorderFace());
780 myControlActor = my2DActor;
782 case eMultiConnection:
783 myFunctor.reset(new SMESH::Controls::MultiConnection());
784 myControlActor = my1DActor;
786 case eMultiConnection2D:
787 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
788 myControlActor = my2DActor;
792 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
793 aControl->SetPrecision( myControlsPrecision );
794 myFunctor.reset( aControl );
795 myControlActor = my2DActor;
800 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
801 aControl->SetPrecision( myControlsPrecision );
802 myFunctor.reset( aControl );
803 myControlActor = my2DActor;
808 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
809 aControl->SetPrecision( myControlsPrecision );
810 myFunctor.reset( aControl );
811 myControlActor = my2DActor;
816 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
817 aControl->SetPrecision( myControlsPrecision );
818 myFunctor.reset( aControl );
819 myControlActor = my3DActor;
824 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
825 aControl->SetPrecision( myControlsPrecision );
826 myFunctor.reset( aControl );
827 myControlActor = my3DActor;
830 case eMaxElementLength2D:
832 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
833 aControl->SetPrecision( myControlsPrecision );
834 myFunctor.reset( aControl );
835 myControlActor = my2DActor;
838 case eMaxElementLength3D:
840 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
841 aControl->SetPrecision( myControlsPrecision );
842 myFunctor.reset( aControl );
843 myControlActor = my3DActor;
846 case eBareBorderVolume:
848 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
849 myControlActor = my3DActor;
854 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
855 aControl->SetPrecision( myControlsPrecision );
856 myFunctor.reset( aControl );
857 myControlActor = my2DActor;
862 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
863 aControl->SetPrecision( myControlsPrecision );
864 myFunctor.reset( aControl );
865 myControlActor = my2DActor;
870 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
871 aControl->SetPrecision( myControlsPrecision );
872 myFunctor.reset( aControl );
873 myControlActor = my2DActor;
880 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
881 vtkIdType aNbCells = aGrid->GetNumberOfCells();
883 myControlMode = theMode;
884 switch(myControlMode){
886 myNodeExtActor->SetExtControlMode(myFunctor);
890 my1DExtActor->SetExtControlMode(myFunctor);
893 my2DExtActor->SetExtControlMode(myFunctor);
895 case eBareBorderFace:
896 my2DExtActor->SetExtControlMode(myFunctor);
898 case eBareBorderVolume:
899 my3DExtActor->SetExtControlMode(myFunctor);
902 case eMultiConnection2D:
903 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
906 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
910 if(theCheckEntityMode){
911 if(myControlActor == my1DActor)
912 SetEntityMode(eEdges);
913 else if(myControlActor == my2DActor){
914 switch(myControlMode){
918 case eMultiConnection2D:
919 //SetEntityMode(eEdges);
920 SetEntityMode(eFaces);
923 SetEntityMode(eFaces);
925 }else if(myControlActor == my3DActor)
926 SetEntityMode(eVolumes);
931 if(theCheckEntityMode)
932 myEntityMode = eAllEntity;
936 SetRepresentation(GetRepresentation());
938 myTimeStamp->Modified();
943 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
944 theRenderer->AddActor(myNodeActor);
945 theRenderer->AddActor(myBaseActor);
947 theRenderer->AddActor(myNodeExtActor);
949 my3DActor->AddToRender(theRenderer);
950 my3DExtActor->AddToRender(theRenderer);
951 my2DActor->AddToRender(theRenderer);
952 my2DExtActor->AddToRender(theRenderer);
954 theRenderer->AddActor(my1DActor);
955 theRenderer->AddActor(my1DExtActor);
957 theRenderer->AddActor(my0DActor);
958 //theRenderer->AddActor(my0DExtActor);
960 theRenderer->AddActor(myHighlitableActor);
962 theRenderer->AddActor2D(myScalarBarActor);
964 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
965 myClsSelectVisiblePoints->SetRenderer(theRenderer);
967 theRenderer->AddActor2D(myPointLabels);
968 theRenderer->AddActor2D(myCellsLabels);
970 // the superclass' method should be called at the end
971 // (in particular, for correct work of selection)
972 SALOME_Actor::AddToRender(theRenderer);
975 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
976 SALOME_Actor::RemoveFromRender(theRenderer);
978 theRenderer->RemoveActor(myNodeActor);
979 theRenderer->RemoveActor(myBaseActor);
981 theRenderer->RemoveActor(myNodeExtActor);
983 theRenderer->RemoveActor(myHighlitableActor);
985 theRenderer->RemoveActor(my0DActor);
986 //theRenderer->RemoveActor(my0DExtActor);
988 theRenderer->RemoveActor(my1DActor);
989 theRenderer->RemoveActor(my1DExtActor);
991 my2DActor->RemoveFromRender(theRenderer);
992 my2DExtActor->RemoveFromRender(theRenderer);
993 my3DActor->RemoveFromRender(theRenderer);
994 my3DExtActor->RemoveFromRender(theRenderer);
996 theRenderer->RemoveActor(myScalarBarActor);
997 theRenderer->RemoveActor(myPointLabels);
998 theRenderer->RemoveActor(myCellsLabels);
1002 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1003 const char* theEntry,
1004 const char* theName,
1007 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1011 myVisualObj = theVisualObj;
1012 myVisualObj->Update(theIsClear);
1014 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1015 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1017 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1019 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1021 my0DActor->Init(myVisualObj,myImplicitBoolean);
1022 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1024 my1DActor->Init(myVisualObj,myImplicitBoolean);
1025 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1027 my2DActor->Init(myVisualObj,myImplicitBoolean);
1028 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1029 my3DActor->Init(myVisualObj,myImplicitBoolean);
1030 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1032 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1033 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1035 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1036 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1038 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1039 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1040 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1041 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1043 vtkFloatingPointType aFactor, aUnits;
1044 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1045 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1046 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1048 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1052 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1053 SetIsShrunkable(true);
1055 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1057 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1058 SetRepresentation(-1);
1061 SetRepresentation(eEdge);
1062 }else if(aMode == 1){
1063 SetRepresentation(eSurface);
1064 }else if(aMode == 2){
1065 SetRepresentation(ePoint);
1072 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1073 SetIsDisplayNameActor( true );
1075 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1076 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1077 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1079 myTimeStamp->Modified();
1085 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1086 return myNodeActor->GetBounds();
1090 vtkDataSet* SMESH_ActorDef::GetInput(){
1091 return GetUnstructuredGrid();
1095 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1096 Superclass::SetTransform(theTransform);
1098 myNodeActor->SetTransform(theTransform);
1099 myBaseActor->SetTransform(theTransform);
1101 myHighlitableActor->SetTransform(theTransform);
1103 myNodeExtActor->SetTransform(theTransform);
1105 my0DActor->SetTransform(theTransform);
1106 //my0DExtActor->SetTransform(theTransform);
1108 my1DActor->SetTransform(theTransform);
1109 my1DExtActor->SetTransform(theTransform);
1111 my2DActor->SetTransform(theTransform);
1112 my2DExtActor->SetTransform(theTransform);
1113 my3DActor->SetTransform(theTransform);
1114 my3DExtActor->SetTransform(theTransform);
1120 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1121 vtkLODActor::SetMapper(theMapper);
1125 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1126 SALOME_Actor::ShallowCopy(prop);
1130 vtkMapper* SMESH_ActorDef::GetMapper(){
1131 return myPickableActor->GetMapper();
1135 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1136 return myVisualObj->GetUnstructuredGrid();
1140 bool SMESH_ActorDef::IsInfinitive(){
1141 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1143 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1144 ( aDataSet->GetNumberOfCells() == 1 &&
1145 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1146 return SALOME_Actor::IsInfinitive();
1150 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1151 if ( myIsShrinkable == theShrunkable )
1153 myIsShrinkable = theShrunkable;
1157 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1158 return myBaseActor->GetShrinkFactor();
1161 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1162 myBaseActor->SetShrinkFactor(theValue);
1164 my1DActor->SetShrinkFactor(theValue);
1165 my1DExtActor->SetShrinkFactor(theValue);
1167 my2DActor->SetShrinkFactor(theValue);
1168 my2DExtActor->SetShrinkFactor(theValue);
1169 my3DActor->SetShrinkFactor(theValue);
1170 my3DExtActor->SetShrinkFactor(theValue);
1175 void SMESH_ActorDef::SetShrink(){
1176 if(!myIsShrinkable) return;
1178 myBaseActor->SetShrink();
1180 my1DActor->SetShrink();
1181 my1DExtActor->SetShrink();
1183 my2DActor->SetShrink();
1184 my2DExtActor->SetShrink();
1185 my3DActor->SetShrink();
1186 my3DExtActor->SetShrink();
1192 void SMESH_ActorDef::UnShrink(){
1193 if(!myIsShrunk) return;
1195 myBaseActor->UnShrink();
1197 my1DActor->UnShrink();
1198 my1DExtActor->UnShrink();
1200 my2DActor->UnShrink();
1201 my2DExtActor->UnShrink();
1202 my3DActor->UnShrink();
1203 my3DExtActor->UnShrink();
1210 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1211 return myPickableActor->GetNodeObjId(theVtkID);
1214 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1215 return myPickableActor->GetNodeCoord(theObjID);
1219 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1220 return myPickableActor->GetElemObjId(theVtkID);
1223 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1224 return myPickableActor->GetElemCell(theObjID);
1228 void SMESH_ActorDef::SetVisibility(int theMode){
1229 SetVisibility(theMode,true);
1233 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1234 SALOME_Actor::SetVisibility(theMode);
1236 myNodeActor->VisibilityOff();
1237 myBaseActor->VisibilityOff();
1239 myNodeExtActor->VisibilityOff();
1241 my0DActor->VisibilityOff();
1242 //my0DExtActor->VisibilityOff();
1244 my1DActor->VisibilityOff();
1245 my1DExtActor->VisibilityOff();
1247 my2DActor->VisibilityOff();
1248 my2DExtActor->VisibilityOff();
1249 my3DActor->VisibilityOff();
1250 my3DExtActor->VisibilityOff();
1252 myScalarBarActor->VisibilityOff();
1253 myPointLabels->VisibilityOff();
1254 myCellsLabels->VisibilityOff();
1256 if(GetVisibility()){
1257 if(theIsUpdateRepersentation)
1258 SetRepresentation(GetRepresentation());
1260 if(myControlMode != eNone){
1261 switch(myControlMode){
1263 myNodeExtActor->VisibilityOn();
1267 my1DExtActor->VisibilityOn();
1270 case eBareBorderFace:
1271 my2DExtActor->VisibilityOn();
1273 case eBareBorderVolume:
1274 my3DExtActor->VisibilityOn();
1277 case eMultiConnection2D:
1278 my1DExtActor->VisibilityOn();
1280 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1281 myScalarBarActor->VisibilityOn();
1285 if(myRepresentation != ePoint)
1286 myPickableActor->VisibilityOn();
1288 myNodeActor->VisibilityOn();
1291 if(myEntityMode & e0DElements){
1292 my0DActor->VisibilityOn();
1295 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1296 my1DActor->VisibilityOn();
1299 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1300 my2DActor->VisibilityOn();
1303 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1304 my3DActor->VisibilityOn();
1307 if(myIsPointsLabeled){
1308 myPointLabels->VisibilityOn();
1309 myNodeActor->VisibilityOn();
1312 if(myIsCellsLabeled)
1313 myCellsLabels->VisibilityOn();
1320 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1322 myEntityState = eAllEntity;
1324 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1325 myEntityState &= ~e0DElements;
1326 theMode &= ~e0DElements;
1329 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1330 myEntityState &= ~eEdges;
1334 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1335 myEntityState &= ~eFaces;
1339 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1340 myEntityState &= ~eVolumes;
1341 theMode &= ~eVolumes;
1345 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1346 theMode |= e0DElements;
1348 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1351 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1354 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1355 theMode |= eVolumes;
1358 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1360 myEntityMode = theMode;
1361 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1362 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1363 aFilter->ClearRegisteredCellsWithType();
1364 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1366 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1367 aHightFilter->ClearRegisteredCellsWithType();
1368 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1370 if (myEntityMode & e0DElements) {
1371 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1372 aFilter->RegisterCellsWithType(VTK_VERTEX);
1373 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1376 if (myEntityMode & eEdges) {
1377 if (MYDEBUG) MESSAGE("EDGES");
1378 aFilter->RegisterCellsWithType(VTK_LINE);
1379 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1381 aHightFilter->RegisterCellsWithType(VTK_LINE);
1382 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1385 if (myEntityMode & eFaces) {
1386 if (MYDEBUG) MESSAGE("FACES");
1387 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1388 aFilter->RegisterCellsWithType(VTK_POLYGON);
1389 aFilter->RegisterCellsWithType(VTK_QUAD);
1390 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1391 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1393 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1394 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1395 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1396 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1397 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1400 if (myEntityMode & eVolumes) {
1401 if (MYDEBUG) MESSAGE("VOLUMES");
1402 aFilter->RegisterCellsWithType(VTK_TETRA);
1403 aFilter->RegisterCellsWithType(VTK_VOXEL);
1404 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1405 aFilter->RegisterCellsWithType(VTK_WEDGE);
1406 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1407 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1408 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1409 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1410 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1412 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1413 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1414 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1415 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1416 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1417 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1418 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1419 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1420 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1421 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1424 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1425 SetVisibility(GetVisibility(),false);
1428 void SMESH_ActorDef::SetRepresentation (int theMode)
1430 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1431 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1432 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1435 myRepresentation = eSurface;
1436 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1437 myRepresentation = eEdge;
1438 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1439 myRepresentation = ePoint;
1444 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1447 if (!aNbFaces && !aNbVolumes) return;
1450 myRepresentation = theMode;
1453 if (!GetUnstructuredGrid()->GetNumberOfCells())
1454 myRepresentation = ePoint;
1457 if (myRepresentation == ePoint) {
1465 myPickableActor = myBaseActor;
1466 myNodeActor->SetVisibility(false);
1467 myNodeExtActor->SetVisibility(false);
1468 vtkProperty *aProp = NULL, *aBackProp = NULL;
1469 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1470 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1471 switch (myRepresentation) {
1473 myPickableActor = myNodeActor;
1474 myNodeActor->SetVisibility(true);
1475 aQuadraticMode = SMESH_Actor::eLines;
1476 aProp = aBackProp = myNodeProp;
1477 aReperesent = SMESH_DeviceActor::ePoint;
1480 aProp = aBackProp = myEdgeProp;
1481 aReperesent = SMESH_DeviceActor::eInsideframe;
1484 aProp = mySurfaceProp;
1485 aBackProp = myBackSurfaceProp;
1486 aReperesent = SMESH_DeviceActor::eSurface;
1490 my2DActor->SetProperty(aProp);
1491 my2DActor->SetBackfaceProperty(aBackProp);
1492 my2DActor->SetRepresentation(aReperesent);
1494 if(aQuadraticMode == SMESH_Actor::eLines)
1495 my2DActor->SetQuadraticArcMode(false);
1496 else if(aQuadraticMode == SMESH_Actor::eArcs)
1497 my2DActor->SetQuadraticArcMode(true);
1499 my2DExtActor->SetRepresentation(aReperesent);
1501 my3DActor->SetProperty(aProp);
1502 my3DActor->SetBackfaceProperty(aBackProp);
1503 my3DActor->SetRepresentation(aReperesent);
1505 //my0DExtActor->SetVisibility(false);
1506 my1DExtActor->SetVisibility(false);
1507 my2DExtActor->SetVisibility(false);
1508 my3DExtActor->SetVisibility(false);
1511 //my0DActor->SetProperty(aProp);
1512 //my0DActor->SetBackfaceProperty(aBackProp);
1513 my0DActor->SetRepresentation(aReperesent);
1514 //my0DExtActor->SetRepresentation(aReperesent);
1516 switch(myControlMode){
1518 case eMultiConnection:
1519 aProp = aBackProp = my1DProp;
1520 if(myRepresentation != ePoint)
1521 aReperesent = SMESH_DeviceActor::eInsideframe;
1525 if(aQuadraticMode == SMESH_Actor::eLines)
1526 my1DActor->SetQuadraticArcMode(false);
1527 else if(aQuadraticMode == SMESH_Actor::eArcs)
1528 my1DActor->SetQuadraticArcMode(true);
1530 my1DActor->SetProperty(aProp);
1531 my1DActor->SetBackfaceProperty(aBackProp);
1532 my1DActor->SetRepresentation(aReperesent);
1534 my1DExtActor->SetRepresentation(aReperesent);
1536 if(myIsPointsVisible)
1537 myPickableActor = myNodeActor;
1538 if(GetPointRepresentation())
1539 myNodeActor->SetVisibility(true);
1541 SetMapper(myPickableActor->GetMapper());
1543 SetVisibility(GetVisibility(),false);
1549 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1550 if ( myIsPointsVisible == theIsPointsVisible )
1552 myIsPointsVisible = theIsPointsVisible;
1553 SetRepresentation(GetRepresentation());
1556 bool SMESH_ActorDef::GetPointRepresentation(){
1557 return myIsPointsVisible || myIsPointsLabeled;
1561 void SMESH_ActorDef::UpdateHighlight(){
1562 myHighlitableActor->SetVisibility(false);
1563 myHighlitableActor->SetHighlited(false);
1565 if(myIsHighlighted){
1566 myHighlitableActor->SetProperty(myHighlightProp);
1567 }else if(myIsPreselected){
1568 myHighlitableActor->SetProperty(myPreselectProp);
1571 bool anIsVisible = GetVisibility();
1573 if(myIsHighlighted || myIsPreselected){
1574 if(GetUnstructuredGrid()->GetNumberOfCells()){
1575 myHighlitableActor->SetHighlited(anIsVisible);
1576 myHighlitableActor->SetVisibility(anIsVisible);
1577 myHighlitableActor->GetExtractUnstructuredGrid()->
1578 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1579 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1580 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1581 myHighlitableActor->SetHighlited(anIsVisible);
1582 myHighlitableActor->GetExtractUnstructuredGrid()->
1583 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1584 myHighlitableActor->SetVisibility(anIsVisible);
1585 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1587 VTK::MarkerType aMarkerType = GetMarkerType();
1588 if(aMarkerType != VTK::MT_USER)
1589 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1591 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1597 void SMESH_ActorDef::highlight(bool theHighlight){
1598 if ( myIsHighlighted == theHighlight )
1600 myIsHighlighted = theHighlight;
1605 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1606 if ( myIsPreselected == thePreselect )
1608 myIsPreselected = thePreselect;
1614 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1616 if (myPickableActor->GetIsOpaque())
1618 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1626 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1628 if (!myPickableActor->GetIsOpaque())
1630 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1638 void SMESH_ActorDef::Render(vtkRenderer *ren){
1639 unsigned long aTime = myTimeStamp->GetMTime();
1640 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1641 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1642 if(anObjTime > aTime || aClippingTime > aTime)
1647 void SMESH_ActorDef::Update(){
1648 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1650 if(GetControlMode() != eNone) {
1651 unsigned long aTime = myTimeStamp->GetMTime();
1652 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1653 if (anObjTime > aTime)
1654 SetControlMode(GetControlMode(),false);
1656 if(myIsPointsLabeled){
1657 SetPointsLabeled(myIsPointsLabeled);
1659 if(myIsCellsLabeled){
1660 SetCellsLabeled(myIsCellsLabeled);
1662 if(myIsFacesOriented){
1663 SetFacesOriented(myIsFacesOriented);
1665 SetEntityMode(GetEntityMode());
1666 SetVisibility(GetVisibility());
1668 myTimeStamp->Modified();
1673 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1674 SALOME_Actor::ReleaseGraphicsResources(renWin);
1676 myPickableActor->ReleaseGraphicsResources(renWin);
1680 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1681 vtkFloatingPointType* aColor = theProperty->GetColor();
1688 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1689 mySurfaceProp->SetOpacity(theValue);
1690 myBackSurfaceProp->SetOpacity(theValue);
1691 myEdgeProp->SetOpacity(theValue);
1692 myNodeProp->SetOpacity(theValue);
1694 my1DProp->SetOpacity(theValue);
1698 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1699 return mySurfaceProp->GetOpacity();
1703 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1704 mySurfaceProp->SetColor(r,g,b);
1705 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1706 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1707 aGroupObj->GetElementType() == SMDSAbs_Volume )
1708 myNameActor->SetBackgroundColor(r,g,b);
1712 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1713 ::GetColor(mySurfaceProp,r,g,b);
1714 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1717 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1718 myBackSurfaceProp->SetColor(r,g,b);
1722 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1723 ::GetColor(myBackSurfaceProp,r,g,b);
1726 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1727 myEdgeProp->SetColor(r,g,b);
1728 my1DProp->SetColor(r,g,b);
1729 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1730 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1731 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1732 myNameActor->SetBackgroundColor(r,g,b);
1736 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1737 ::GetColor(myEdgeProp,r,g,b);
1740 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1741 myNodeProp->SetColor(r,g,b);
1742 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1743 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1744 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1745 myNameActor->SetBackgroundColor(r,g,b);
1749 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1750 ::GetColor(myNodeProp,r,g,b);
1753 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1754 my0DProp->SetColor(r,g,b);
1755 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1756 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1757 myNameActor->SetBackgroundColor(r,g,b);
1761 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1762 ::GetColor(my0DProp,r,g,b);
1765 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1766 myHighlightProp->SetColor(r,g,b);
1770 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1771 ::GetColor(myHighlightProp,r,g,b);
1774 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1775 myPreselectProp->SetColor(r,g,b);
1779 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1780 ::GetColor(myPreselectProp,r,g,b);
1784 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1785 return myEdgeProp->GetLineWidth();
1789 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1790 myEdgeProp->SetLineWidth(theVal);
1792 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1793 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1799 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1800 my0DProp->SetPointSize(theVal);
1804 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1805 return my0DProp->GetPointSize();
1808 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1810 return myVisualObj->GetElemDimension( theObjId );
1815 IsImplicitFunctionUsed() const
1817 return myBaseActor->IsImplicitFunctionUsed();
1821 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1823 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1824 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1826 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1828 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1830 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1831 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1833 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1834 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1836 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1837 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1838 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1839 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1843 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1846 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1847 myCippingPlaneCont.push_back(thePlane);
1848 if(!IsImplicitFunctionUsed())
1849 SetImplicitFunctionUsed(true);
1851 return myCippingPlaneCont.size();
1856 RemoveAllClippingPlanes()
1858 myImplicitBoolean->GetFunction()->RemoveAllItems();
1859 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1860 myCippingPlaneCont.clear();
1861 SetImplicitFunctionUsed(false);
1866 GetNumberOfClippingPlanes()
1868 return myCippingPlaneCont.size();
1873 GetClippingPlane(vtkIdType theID)
1875 if(theID >= myCippingPlaneCont.size())
1877 return myCippingPlaneCont[theID].Get();
1880 void SMESH_ActorDef::UpdateScalarBar()
1882 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1886 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1888 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1889 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1891 aScalarBarTitleProp->SetFontFamilyToArial();
1893 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1895 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1896 if ( f.family() == "Arial" )
1897 aScalarBarTitleProp->SetFontFamilyToArial();
1898 else if ( f.family() == "Courier" )
1899 aScalarBarTitleProp->SetFontFamilyToCourier();
1900 else if ( f.family() == "Times" )
1901 aScalarBarTitleProp->SetFontFamilyToTimes();
1904 aScalarBarTitleProp->BoldOn();
1906 aScalarBarTitleProp->BoldOff();
1909 aScalarBarTitleProp->ItalicOn();
1911 aScalarBarTitleProp->ItalicOff();
1914 aScalarBarTitleProp->ShadowOn();
1916 aScalarBarTitleProp->ShadowOff();
1919 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1920 aScalarBarTitleProp->Delete();
1922 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1924 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1925 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1927 aScalarBarLabelProp->SetFontFamilyToArial();
1928 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1930 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1931 if( f.family() == "Arial" )
1932 aScalarBarLabelProp->SetFontFamilyToArial();
1933 else if( f.family() == "Courier" )
1934 aScalarBarLabelProp->SetFontFamilyToCourier();
1935 else if( f.family() == "Times" )
1936 aScalarBarLabelProp->SetFontFamilyToTimes();
1939 aScalarBarLabelProp->BoldOn();
1941 aScalarBarLabelProp->BoldOff();
1944 aScalarBarLabelProp->ItalicOn();
1946 aScalarBarLabelProp->ItalicOff();
1949 aScalarBarLabelProp->ShadowOn();
1951 aScalarBarLabelProp->ShadowOff();
1954 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1955 aScalarBarLabelProp->Delete();
1957 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1958 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1960 myScalarBarActor->SetOrientationToHorizontal();
1962 myScalarBarActor->SetOrientationToVertical();
1965 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1966 if( mgr->hasValue( "SMESH", name + "x" ) )
1967 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1969 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1970 if( mgr->hasValue( "SMESH", name + "y" ) )
1971 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1972 myScalarBarActor->SetPosition( aXVal, aYVal );
1974 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1975 if( mgr->hasValue( "SMESH", name + "width" ) )
1976 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1977 myScalarBarActor->SetWidth( aWVal );
1979 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1980 if( mgr->hasValue( "SMESH", name + "height" ) )
1981 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1982 myScalarBarActor->SetHeight( aHVal );
1985 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1986 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1987 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1990 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1991 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1992 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
1994 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
1995 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
1997 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
1998 myScalarBarActor->SetDistributionColoringType(coloringType);
2000 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2001 QColor(255, 255, 255));
2003 rgb[0]= distributionColor.red()/255.;
2004 rgb[1]= distributionColor.green()/255.;
2005 rgb[2]= distributionColor.blue()/255.;
2006 myScalarBarActor->SetDistributionColor(rgb);
2011 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2014 case SMESH_Actor::eLines :
2015 myHighlitableActor->SetQuadraticArcMode(false);
2016 my2DActor->SetQuadraticArcMode(false);
2017 my1DActor->SetQuadraticArcMode(false);
2019 case SMESH_Actor::eArcs :
2020 myHighlitableActor->SetQuadraticArcMode(true);
2021 if(GetRepresentation() != SMESH_Actor::ePoint) {
2022 my2DActor->SetQuadraticArcMode(true);
2023 my1DActor->SetQuadraticArcMode(true);
2032 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2034 if(myHighlitableActor->GetQuadraticArcMode())
2035 return SMESH_Actor::eArcs;
2037 return SMESH_Actor::eLines;
2040 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2042 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2043 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2044 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2047 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2049 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2050 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2051 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2052 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor