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 eOverConstrainedFace:
783 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
784 myControlActor = my2DActor;
786 case eMultiConnection:
787 myFunctor.reset(new SMESH::Controls::MultiConnection());
788 myControlActor = my1DActor;
790 case eMultiConnection2D:
791 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
792 myControlActor = my2DActor;
796 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
797 aControl->SetPrecision( myControlsPrecision );
798 myFunctor.reset( aControl );
799 myControlActor = my2DActor;
804 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
805 aControl->SetPrecision( myControlsPrecision );
806 myFunctor.reset( aControl );
807 myControlActor = my2DActor;
812 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
813 aControl->SetPrecision( myControlsPrecision );
814 myFunctor.reset( aControl );
815 myControlActor = my2DActor;
820 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
821 aControl->SetPrecision( myControlsPrecision );
822 myFunctor.reset( aControl );
823 myControlActor = my3DActor;
828 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
829 aControl->SetPrecision( myControlsPrecision );
830 myFunctor.reset( aControl );
831 myControlActor = my3DActor;
834 case eMaxElementLength2D:
836 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
837 aControl->SetPrecision( myControlsPrecision );
838 myFunctor.reset( aControl );
839 myControlActor = my2DActor;
842 case eMaxElementLength3D:
844 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
845 aControl->SetPrecision( myControlsPrecision );
846 myFunctor.reset( aControl );
847 myControlActor = my3DActor;
850 case eBareBorderVolume:
852 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
853 myControlActor = my3DActor;
856 case eOverConstrainedVolume:
858 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
859 myControlActor = my3DActor;
864 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
865 aControl->SetPrecision( myControlsPrecision );
866 myFunctor.reset( aControl );
867 myControlActor = my2DActor;
872 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
873 aControl->SetPrecision( myControlsPrecision );
874 myFunctor.reset( aControl );
875 myControlActor = my2DActor;
880 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
881 aControl->SetPrecision( myControlsPrecision );
882 myFunctor.reset( aControl );
883 myControlActor = my2DActor;
890 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
891 vtkIdType aNbCells = aGrid->GetNumberOfCells();
893 myControlMode = theMode;
894 switch(myControlMode){
896 myNodeExtActor->SetExtControlMode(myFunctor);
900 my1DExtActor->SetExtControlMode(myFunctor);
903 case eBareBorderFace:
904 case eOverConstrainedFace:
905 my2DExtActor->SetExtControlMode(myFunctor);
907 case eBareBorderVolume:
908 case eOverConstrainedVolume:
909 my3DExtActor->SetExtControlMode(myFunctor);
912 case eMultiConnection2D:
913 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
914 UpdateDistribution();
917 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
918 UpdateDistribution();
922 if(theCheckEntityMode){
923 if(myControlActor == my1DActor)
924 SetEntityMode(eEdges);
925 else if(myControlActor == my2DActor){
926 switch(myControlMode){
930 case eMultiConnection2D:
931 //SetEntityMode(eEdges);
932 SetEntityMode(eFaces);
935 SetEntityMode(eFaces);
937 }else if(myControlActor == my3DActor)
938 SetEntityMode(eVolumes);
943 if(theCheckEntityMode)
944 myEntityMode = eAllEntity;
948 SetRepresentation(GetRepresentation());
950 myTimeStamp->Modified();
955 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
956 theRenderer->AddActor(myNodeActor);
957 theRenderer->AddActor(myBaseActor);
959 theRenderer->AddActor(myNodeExtActor);
961 my3DActor->AddToRender(theRenderer);
962 my3DExtActor->AddToRender(theRenderer);
963 my2DActor->AddToRender(theRenderer);
964 my2DExtActor->AddToRender(theRenderer);
966 theRenderer->AddActor(my1DActor);
967 theRenderer->AddActor(my1DExtActor);
969 theRenderer->AddActor(my0DActor);
970 //theRenderer->AddActor(my0DExtActor);
972 theRenderer->AddActor(myHighlitableActor);
974 theRenderer->AddActor2D(myScalarBarActor);
976 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
977 myClsSelectVisiblePoints->SetRenderer(theRenderer);
979 theRenderer->AddActor2D(myPointLabels);
980 theRenderer->AddActor2D(myCellsLabels);
982 // the superclass' method should be called at the end
983 // (in particular, for correct work of selection)
984 SALOME_Actor::AddToRender(theRenderer);
987 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
988 SALOME_Actor::RemoveFromRender(theRenderer);
990 theRenderer->RemoveActor(myNodeActor);
991 theRenderer->RemoveActor(myBaseActor);
993 theRenderer->RemoveActor(myNodeExtActor);
995 theRenderer->RemoveActor(myHighlitableActor);
997 theRenderer->RemoveActor(my0DActor);
998 //theRenderer->RemoveActor(my0DExtActor);
1000 theRenderer->RemoveActor(my1DActor);
1001 theRenderer->RemoveActor(my1DExtActor);
1003 my2DActor->RemoveFromRender(theRenderer);
1004 my2DExtActor->RemoveFromRender(theRenderer);
1005 my3DActor->RemoveFromRender(theRenderer);
1006 my3DExtActor->RemoveFromRender(theRenderer);
1008 theRenderer->RemoveActor(myScalarBarActor);
1009 theRenderer->RemoveActor(myPointLabels);
1010 theRenderer->RemoveActor(myCellsLabels);
1014 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1015 const char* theEntry,
1016 const char* theName,
1019 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1023 myVisualObj = theVisualObj;
1024 myVisualObj->Update(theIsClear);
1026 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1027 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1029 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1031 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1033 my0DActor->Init(myVisualObj,myImplicitBoolean);
1034 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1036 my1DActor->Init(myVisualObj,myImplicitBoolean);
1037 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1039 my2DActor->Init(myVisualObj,myImplicitBoolean);
1040 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1041 my3DActor->Init(myVisualObj,myImplicitBoolean);
1042 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1044 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1045 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1047 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1048 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1050 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1051 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1052 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1053 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1055 vtkFloatingPointType aFactor, aUnits;
1056 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1057 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1058 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1060 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1064 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1065 SetIsShrunkable(true);
1067 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1069 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1070 SetRepresentation(-1);
1073 SetRepresentation(eEdge);
1074 }else if(aMode == 1){
1075 SetRepresentation(eSurface);
1076 }else if(aMode == 2){
1077 SetRepresentation(ePoint);
1084 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1085 SetIsDisplayNameActor( true );
1087 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1088 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1089 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1091 myTimeStamp->Modified();
1097 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1098 return myNodeActor->GetBounds();
1102 vtkDataSet* SMESH_ActorDef::GetInput(){
1103 return GetUnstructuredGrid();
1107 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1108 Superclass::SetTransform(theTransform);
1110 myNodeActor->SetTransform(theTransform);
1111 myBaseActor->SetTransform(theTransform);
1113 myHighlitableActor->SetTransform(theTransform);
1115 myNodeExtActor->SetTransform(theTransform);
1117 my0DActor->SetTransform(theTransform);
1118 //my0DExtActor->SetTransform(theTransform);
1120 my1DActor->SetTransform(theTransform);
1121 my1DExtActor->SetTransform(theTransform);
1123 my2DActor->SetTransform(theTransform);
1124 my2DExtActor->SetTransform(theTransform);
1125 my3DActor->SetTransform(theTransform);
1126 my3DExtActor->SetTransform(theTransform);
1132 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1133 vtkLODActor::SetMapper(theMapper);
1137 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1138 SALOME_Actor::ShallowCopy(prop);
1142 vtkMapper* SMESH_ActorDef::GetMapper(){
1143 return myPickableActor->GetMapper();
1147 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1148 return myVisualObj->GetUnstructuredGrid();
1152 bool SMESH_ActorDef::IsInfinitive(){
1153 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1155 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1156 ( aDataSet->GetNumberOfCells() == 1 &&
1157 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1158 return SALOME_Actor::IsInfinitive();
1162 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1163 if ( myIsShrinkable == theShrunkable )
1165 myIsShrinkable = theShrunkable;
1169 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1170 return myBaseActor->GetShrinkFactor();
1173 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1174 myBaseActor->SetShrinkFactor(theValue);
1176 my1DActor->SetShrinkFactor(theValue);
1177 my1DExtActor->SetShrinkFactor(theValue);
1179 my2DActor->SetShrinkFactor(theValue);
1180 my2DExtActor->SetShrinkFactor(theValue);
1181 my3DActor->SetShrinkFactor(theValue);
1182 my3DExtActor->SetShrinkFactor(theValue);
1187 void SMESH_ActorDef::SetShrink(){
1188 if(!myIsShrinkable) return;
1190 myBaseActor->SetShrink();
1192 my1DActor->SetShrink();
1193 my1DExtActor->SetShrink();
1195 my2DActor->SetShrink();
1196 my2DExtActor->SetShrink();
1197 my3DActor->SetShrink();
1198 my3DExtActor->SetShrink();
1204 void SMESH_ActorDef::UnShrink(){
1205 if(!myIsShrunk) return;
1207 myBaseActor->UnShrink();
1209 my1DActor->UnShrink();
1210 my1DExtActor->UnShrink();
1212 my2DActor->UnShrink();
1213 my2DExtActor->UnShrink();
1214 my3DActor->UnShrink();
1215 my3DExtActor->UnShrink();
1222 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1223 return myPickableActor->GetNodeObjId(theVtkID);
1226 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1227 return myPickableActor->GetNodeCoord(theObjID);
1231 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1232 return myPickableActor->GetElemObjId(theVtkID);
1235 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1236 return myPickableActor->GetElemCell(theObjID);
1240 void SMESH_ActorDef::SetVisibility(int theMode){
1241 SetVisibility(theMode,true);
1245 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1246 SALOME_Actor::SetVisibility(theMode);
1248 myNodeActor->VisibilityOff();
1249 myBaseActor->VisibilityOff();
1251 myNodeExtActor->VisibilityOff();
1253 my0DActor->VisibilityOff();
1254 //my0DExtActor->VisibilityOff();
1256 my1DActor->VisibilityOff();
1257 my1DExtActor->VisibilityOff();
1259 my2DActor->VisibilityOff();
1260 my2DExtActor->VisibilityOff();
1261 my3DActor->VisibilityOff();
1262 my3DExtActor->VisibilityOff();
1264 myScalarBarActor->VisibilityOff();
1265 myPointLabels->VisibilityOff();
1266 myCellsLabels->VisibilityOff();
1268 if(GetVisibility()){
1269 if(theIsUpdateRepersentation)
1270 SetRepresentation(GetRepresentation());
1272 if(myControlMode != eNone){
1273 switch(myControlMode){
1275 myNodeExtActor->VisibilityOn();
1279 my1DExtActor->VisibilityOn();
1282 case eBareBorderFace:
1283 case eOverConstrainedFace:
1284 my2DExtActor->VisibilityOn();
1286 case eBareBorderVolume:
1287 case eOverConstrainedVolume:
1288 my3DExtActor->VisibilityOn();
1291 case eMultiConnection2D:
1292 my1DExtActor->VisibilityOn();
1294 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1295 myScalarBarActor->VisibilityOn();
1299 if(myRepresentation != ePoint)
1300 myPickableActor->VisibilityOn();
1302 myNodeActor->VisibilityOn();
1305 if(myEntityMode & e0DElements){
1306 my0DActor->VisibilityOn();
1309 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1310 my1DActor->VisibilityOn();
1313 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1314 my2DActor->VisibilityOn();
1317 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1318 my3DActor->VisibilityOn();
1321 if(myIsPointsLabeled){
1322 myPointLabels->VisibilityOn();
1323 myNodeActor->VisibilityOn();
1326 if(myIsCellsLabeled)
1327 myCellsLabels->VisibilityOn();
1334 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1336 myEntityState = eAllEntity;
1338 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1339 myEntityState &= ~e0DElements;
1340 theMode &= ~e0DElements;
1343 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1344 myEntityState &= ~eEdges;
1348 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1349 myEntityState &= ~eFaces;
1353 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1354 myEntityState &= ~eVolumes;
1355 theMode &= ~eVolumes;
1359 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1360 theMode |= e0DElements;
1362 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1365 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1368 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1369 theMode |= eVolumes;
1372 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1374 myEntityMode = theMode;
1375 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1376 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1377 aFilter->ClearRegisteredCellsWithType();
1378 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1380 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1381 aHightFilter->ClearRegisteredCellsWithType();
1382 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1384 if (myEntityMode & e0DElements) {
1385 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1386 aFilter->RegisterCellsWithType(VTK_VERTEX);
1387 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1390 if (myEntityMode & eEdges) {
1391 if (MYDEBUG) MESSAGE("EDGES");
1392 aFilter->RegisterCellsWithType(VTK_LINE);
1393 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1395 aHightFilter->RegisterCellsWithType(VTK_LINE);
1396 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1399 if (myEntityMode & eFaces) {
1400 if (MYDEBUG) MESSAGE("FACES");
1401 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1402 aFilter->RegisterCellsWithType(VTK_POLYGON);
1403 aFilter->RegisterCellsWithType(VTK_QUAD);
1404 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1405 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1407 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1408 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1409 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1410 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1411 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1414 if (myEntityMode & eVolumes) {
1415 if (MYDEBUG) MESSAGE("VOLUMES");
1416 aFilter->RegisterCellsWithType(VTK_TETRA);
1417 aFilter->RegisterCellsWithType(VTK_VOXEL);
1418 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1419 aFilter->RegisterCellsWithType(VTK_WEDGE);
1420 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1421 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1422 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1423 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1424 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1426 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1427 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1428 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1429 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1430 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1431 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1432 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1433 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1434 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1435 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1438 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1439 SetVisibility(GetVisibility(),false);
1442 void SMESH_ActorDef::SetRepresentation (int theMode)
1444 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1445 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1446 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1449 myRepresentation = eSurface;
1450 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1451 myRepresentation = eEdge;
1452 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1453 myRepresentation = ePoint;
1458 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1461 if (!aNbFaces && !aNbVolumes) return;
1464 myRepresentation = theMode;
1467 if (!GetUnstructuredGrid()->GetNumberOfCells())
1468 myRepresentation = ePoint;
1471 if (myRepresentation == ePoint) {
1479 myPickableActor = myBaseActor;
1480 myNodeActor->SetVisibility(false);
1481 myNodeExtActor->SetVisibility(false);
1482 vtkProperty *aProp = NULL, *aBackProp = NULL;
1483 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1484 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1485 switch (myRepresentation) {
1487 myPickableActor = myNodeActor;
1488 myNodeActor->SetVisibility(true);
1489 aQuadraticMode = SMESH_Actor::eLines;
1490 aProp = aBackProp = myNodeProp;
1491 aReperesent = SMESH_DeviceActor::ePoint;
1494 aProp = aBackProp = myEdgeProp;
1495 aReperesent = SMESH_DeviceActor::eInsideframe;
1498 aProp = mySurfaceProp;
1499 aBackProp = myBackSurfaceProp;
1500 aReperesent = SMESH_DeviceActor::eSurface;
1504 my2DActor->SetProperty(aProp);
1505 my2DActor->SetBackfaceProperty(aBackProp);
1506 my2DActor->SetRepresentation(aReperesent);
1508 if(aQuadraticMode == SMESH_Actor::eLines)
1509 my2DActor->SetQuadraticArcMode(false);
1510 else if(aQuadraticMode == SMESH_Actor::eArcs)
1511 my2DActor->SetQuadraticArcMode(true);
1513 my2DExtActor->SetRepresentation(aReperesent);
1515 my3DActor->SetProperty(aProp);
1516 my3DActor->SetBackfaceProperty(aBackProp);
1517 my3DActor->SetRepresentation(aReperesent);
1519 //my0DExtActor->SetVisibility(false);
1520 my1DExtActor->SetVisibility(false);
1521 my2DExtActor->SetVisibility(false);
1522 my3DExtActor->SetVisibility(false);
1525 //my0DActor->SetProperty(aProp);
1526 //my0DActor->SetBackfaceProperty(aBackProp);
1527 my0DActor->SetRepresentation(aReperesent);
1528 //my0DExtActor->SetRepresentation(aReperesent);
1530 switch(myControlMode){
1532 case eMultiConnection:
1533 aProp = aBackProp = my1DProp;
1534 if(myRepresentation != ePoint)
1535 aReperesent = SMESH_DeviceActor::eInsideframe;
1539 if(aQuadraticMode == SMESH_Actor::eLines)
1540 my1DActor->SetQuadraticArcMode(false);
1541 else if(aQuadraticMode == SMESH_Actor::eArcs)
1542 my1DActor->SetQuadraticArcMode(true);
1544 my1DActor->SetProperty(aProp);
1545 my1DActor->SetBackfaceProperty(aBackProp);
1546 my1DActor->SetRepresentation(aReperesent);
1548 my1DExtActor->SetRepresentation(aReperesent);
1550 if(myIsPointsVisible)
1551 myPickableActor = myNodeActor;
1552 if(GetPointRepresentation())
1553 myNodeActor->SetVisibility(true);
1555 SetMapper(myPickableActor->GetMapper());
1557 SetVisibility(GetVisibility(),false);
1563 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1564 if ( myIsPointsVisible == theIsPointsVisible )
1566 myIsPointsVisible = theIsPointsVisible;
1567 SetRepresentation(GetRepresentation());
1570 bool SMESH_ActorDef::GetPointRepresentation(){
1571 return myIsPointsVisible || myIsPointsLabeled;
1575 void SMESH_ActorDef::UpdateHighlight(){
1576 myHighlitableActor->SetVisibility(false);
1577 myHighlitableActor->SetHighlited(false);
1579 if(myIsHighlighted){
1580 myHighlitableActor->SetProperty(myHighlightProp);
1581 }else if(myIsPreselected){
1582 myHighlitableActor->SetProperty(myPreselectProp);
1585 bool anIsVisible = GetVisibility();
1587 if(myIsHighlighted || myIsPreselected){
1588 if(GetUnstructuredGrid()->GetNumberOfCells()){
1589 myHighlitableActor->SetHighlited(anIsVisible);
1590 myHighlitableActor->SetVisibility(anIsVisible);
1591 myHighlitableActor->GetExtractUnstructuredGrid()->
1592 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1593 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1594 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1595 myHighlitableActor->SetHighlited(anIsVisible);
1596 myHighlitableActor->GetExtractUnstructuredGrid()->
1597 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1598 myHighlitableActor->SetVisibility(anIsVisible);
1599 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1601 VTK::MarkerType aMarkerType = GetMarkerType();
1602 if(aMarkerType != VTK::MT_USER)
1603 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1605 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1611 void SMESH_ActorDef::highlight(bool theHighlight){
1612 if ( myIsHighlighted == theHighlight )
1614 myIsHighlighted = theHighlight;
1619 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1620 if ( myIsPreselected == thePreselect )
1622 myIsPreselected = thePreselect;
1628 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1630 if (myPickableActor->GetIsOpaque())
1632 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1640 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1642 if (!myPickableActor->GetIsOpaque())
1644 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1652 void SMESH_ActorDef::Render(vtkRenderer *ren){
1653 unsigned long aTime = myTimeStamp->GetMTime();
1654 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1655 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1656 if(anObjTime > aTime || aClippingTime > aTime)
1661 void SMESH_ActorDef::Update(){
1662 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1664 if(GetControlMode() != eNone) {
1665 unsigned long aTime = myTimeStamp->GetMTime();
1666 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1667 if (anObjTime > aTime)
1668 SetControlMode(GetControlMode(),false);
1670 if(myIsPointsLabeled){
1671 SetPointsLabeled(myIsPointsLabeled);
1673 if(myIsCellsLabeled){
1674 SetCellsLabeled(myIsCellsLabeled);
1676 if(myIsFacesOriented){
1677 SetFacesOriented(myIsFacesOriented);
1679 SetEntityMode(GetEntityMode());
1680 SetVisibility(GetVisibility());
1682 myTimeStamp->Modified();
1687 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1688 SALOME_Actor::ReleaseGraphicsResources(renWin);
1690 myPickableActor->ReleaseGraphicsResources(renWin);
1694 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1695 vtkFloatingPointType* aColor = theProperty->GetColor();
1702 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1703 mySurfaceProp->SetOpacity(theValue);
1704 myBackSurfaceProp->SetOpacity(theValue);
1705 myEdgeProp->SetOpacity(theValue);
1706 myNodeProp->SetOpacity(theValue);
1708 my1DProp->SetOpacity(theValue);
1712 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1713 return mySurfaceProp->GetOpacity();
1717 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1718 mySurfaceProp->SetColor(r,g,b);
1719 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1720 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1721 aGroupObj->GetElementType() == SMDSAbs_Volume )
1722 myNameActor->SetBackgroundColor(r,g,b);
1726 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1727 ::GetColor(mySurfaceProp,r,g,b);
1728 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1731 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1732 myBackSurfaceProp->SetColor(r,g,b);
1736 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1737 ::GetColor(myBackSurfaceProp,r,g,b);
1740 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1741 myEdgeProp->SetColor(r,g,b);
1742 my1DProp->SetColor(r,g,b);
1743 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1744 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1745 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1746 myNameActor->SetBackgroundColor(r,g,b);
1750 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1751 ::GetColor(myEdgeProp,r,g,b);
1754 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1755 myNodeProp->SetColor(r,g,b);
1756 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1757 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1758 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1759 myNameActor->SetBackgroundColor(r,g,b);
1763 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1764 ::GetColor(myNodeProp,r,g,b);
1767 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1768 my0DProp->SetColor(r,g,b);
1769 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1770 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1771 myNameActor->SetBackgroundColor(r,g,b);
1775 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1776 ::GetColor(my0DProp,r,g,b);
1779 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1780 myHighlightProp->SetColor(r,g,b);
1784 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1785 ::GetColor(myHighlightProp,r,g,b);
1788 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1789 myPreselectProp->SetColor(r,g,b);
1793 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1794 ::GetColor(myPreselectProp,r,g,b);
1798 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1799 return myEdgeProp->GetLineWidth();
1803 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1804 myEdgeProp->SetLineWidth(theVal);
1806 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1807 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1813 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1814 my0DProp->SetPointSize(theVal);
1818 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1819 return my0DProp->GetPointSize();
1822 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1824 return myVisualObj->GetElemDimension( theObjId );
1829 IsImplicitFunctionUsed() const
1831 return myBaseActor->IsImplicitFunctionUsed();
1835 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1837 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1838 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1840 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1842 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1844 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1845 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1847 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1848 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1850 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1851 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1852 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1853 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1857 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1860 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1861 myCippingPlaneCont.push_back(thePlane);
1862 if(!IsImplicitFunctionUsed())
1863 SetImplicitFunctionUsed(true);
1865 return myCippingPlaneCont.size();
1870 RemoveAllClippingPlanes()
1872 myImplicitBoolean->GetFunction()->RemoveAllItems();
1873 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1874 myCippingPlaneCont.clear();
1875 SetImplicitFunctionUsed(false);
1880 GetNumberOfClippingPlanes()
1882 return myCippingPlaneCont.size();
1887 GetClippingPlane(vtkIdType theID)
1889 if(theID >= myCippingPlaneCont.size())
1891 return myCippingPlaneCont[theID].Get();
1894 void SMESH_ActorDef::UpdateScalarBar()
1896 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1900 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1902 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1903 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1905 aScalarBarTitleProp->SetFontFamilyToArial();
1907 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1909 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1910 if ( f.family() == "Arial" )
1911 aScalarBarTitleProp->SetFontFamilyToArial();
1912 else if ( f.family() == "Courier" )
1913 aScalarBarTitleProp->SetFontFamilyToCourier();
1914 else if ( f.family() == "Times" )
1915 aScalarBarTitleProp->SetFontFamilyToTimes();
1918 aScalarBarTitleProp->BoldOn();
1920 aScalarBarTitleProp->BoldOff();
1923 aScalarBarTitleProp->ItalicOn();
1925 aScalarBarTitleProp->ItalicOff();
1928 aScalarBarTitleProp->ShadowOn();
1930 aScalarBarTitleProp->ShadowOff();
1933 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1934 aScalarBarTitleProp->Delete();
1936 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1938 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1939 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1941 aScalarBarLabelProp->SetFontFamilyToArial();
1942 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1944 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1945 if( f.family() == "Arial" )
1946 aScalarBarLabelProp->SetFontFamilyToArial();
1947 else if( f.family() == "Courier" )
1948 aScalarBarLabelProp->SetFontFamilyToCourier();
1949 else if( f.family() == "Times" )
1950 aScalarBarLabelProp->SetFontFamilyToTimes();
1953 aScalarBarLabelProp->BoldOn();
1955 aScalarBarLabelProp->BoldOff();
1958 aScalarBarLabelProp->ItalicOn();
1960 aScalarBarLabelProp->ItalicOff();
1963 aScalarBarLabelProp->ShadowOn();
1965 aScalarBarLabelProp->ShadowOff();
1968 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1969 aScalarBarLabelProp->Delete();
1971 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1972 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1974 myScalarBarActor->SetOrientationToHorizontal();
1976 myScalarBarActor->SetOrientationToVertical();
1979 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1980 if( mgr->hasValue( "SMESH", name + "x" ) )
1981 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1983 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1984 if( mgr->hasValue( "SMESH", name + "y" ) )
1985 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1986 myScalarBarActor->SetPosition( aXVal, aYVal );
1988 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1989 if( mgr->hasValue( "SMESH", name + "width" ) )
1990 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1991 myScalarBarActor->SetWidth( aWVal );
1993 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1994 if( mgr->hasValue( "SMESH", name + "height" ) )
1995 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1996 myScalarBarActor->SetHeight( aHVal );
1999 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2000 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2001 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2004 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2005 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2006 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2008 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2009 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2011 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2012 myScalarBarActor->SetDistributionColoringType(coloringType);
2014 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2015 QColor(255, 255, 255));
2017 rgb[0]= distributionColor.red()/255.;
2018 rgb[1]= distributionColor.green()/255.;
2019 rgb[2]= distributionColor.blue()/255.;
2020 myScalarBarActor->SetDistributionColor(rgb);
2025 void SMESH_ActorDef::UpdateDistribution()
2027 if(SMESH::Controls::NumericalFunctor* fun =
2028 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2030 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2031 std::vector<int> nbEvents;
2032 std::vector<double> funValues;
2033 SMESH_VisualObjDef::TEntityList elems;
2034 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2035 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2036 std::vector<int> elemIds;
2037 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2038 elemIds.push_back( (*e)->GetID());
2039 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2040 double * range = lookupTable->GetRange();
2041 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2042 myScalarBarActor->SetDistribution(nbEvents);
2046 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2049 case SMESH_Actor::eLines :
2050 myHighlitableActor->SetQuadraticArcMode(false);
2051 my2DActor->SetQuadraticArcMode(false);
2052 my1DActor->SetQuadraticArcMode(false);
2054 case SMESH_Actor::eArcs :
2055 myHighlitableActor->SetQuadraticArcMode(true);
2056 if(GetRepresentation() != SMESH_Actor::ePoint) {
2057 my2DActor->SetQuadraticArcMode(true);
2058 my1DActor->SetQuadraticArcMode(true);
2067 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2069 if(myHighlitableActor->GetQuadraticArcMode())
2070 return SMESH_Actor::eArcs;
2072 return SMESH_Actor::eLines;
2075 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2077 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2078 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2079 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2082 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2084 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2085 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2086 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2087 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor