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 "SMDS_UnstructuredGrid.hxx"
34 #include "SMESH_ScalarBarActor.h"
35 #include "VTKViewer_CellCenters.h"
36 #include "VTKViewer_ExtractUnstructuredGrid.h"
37 #include "VTKViewer_FramedTextActor.h"
38 #include "SALOME_InteractiveObject.hxx"
40 #include "SUIT_Session.h"
41 #include "SUIT_ResourceMgr.h"
43 #ifndef DISABLE_PLOT2DVIEWER
44 #include <SPlot2d_Histogram.h>
47 #include <vtkProperty.h>
48 #include <vtkTimeStamp.h>
49 #include <vtkObjectFactory.h>
50 #include <vtkShrinkPolyData.h>
51 #include <vtkMergeFilter.h>
53 #include <vtkMatrix4x4.h>
54 #include <vtkUnstructuredGrid.h>
55 #include <vtkPointData.h>
56 #include <vtkCellData.h>
58 #include <vtkMapper.h>
59 #include <vtkRenderer.h>
62 #include <vtkIdList.h>
63 #include <vtkIntArray.h>
65 #include <vtkActor2D.h>
66 #include <vtkProperty2D.h>
67 #include <vtkPolyData.h>
68 #include <vtkMaskPoints.h>
69 #include <vtkTextProperty.h>
70 #include <vtkLabeledDataMapper.h>
71 #include <vtkSelectVisiblePoints.h>
73 #include <vtkLookupTable.h>
77 #include <vtkImplicitBoolean.h>
78 #include <vtkImplicitFunctionCollection.h>
80 #include <vtkConfigure.h>
81 #if !defined(VTK_XVERSION)
82 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
85 #include "utilities.h"
88 static int MYDEBUG = 1;
90 static int MYDEBUG = 1;
93 static int aLineWidthInc = 2;
96 SMESH_ActorDef* SMESH_ActorDef::New(){
97 return new SMESH_ActorDef();
101 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 const char* theEntry,
106 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
107 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
112 anActor->UpdateScalarBar();
117 SMESH_ActorDef::SMESH_ActorDef()
119 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
121 myTimeStamp = vtkTimeStamp::New();
123 myIsPointsVisible = false;
125 myIsShrinkable = false;
128 myIsFacesOriented = false;
130 myControlsPrecision = -1;
131 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
133 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
134 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
136 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
137 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
139 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
140 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
142 //Definition 2D and 3D devices of the actor
143 //-----------------------------------------
144 vtkFloatingPointType anRGB[3] = {1,1,1};
145 mySurfaceProp = vtkProperty::New();
146 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
147 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
149 myBackSurfaceProp = vtkProperty::New();
150 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
151 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
153 my2DActor = SMESH_DeviceActor::New();
154 my2DActor->SetUserMatrix(aMatrix);
155 my2DActor->PickableOff();
156 my2DActor->SetProperty(mySurfaceProp);
157 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
158 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
159 aFilter = my2DActor->GetExtractUnstructuredGrid();
160 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
161 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
162 aFilter->RegisterCellsWithType(VTK_POLYGON);
163 aFilter->RegisterCellsWithType(VTK_QUAD);
164 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
165 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
167 my2DExtProp = vtkProperty::New();
168 my2DExtProp->DeepCopy(mySurfaceProp);
169 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
170 anRGB[0] = 1 - anRGB[0];
171 anRGB[1] = 1 - anRGB[1];
172 anRGB[2] = 1 - anRGB[2];
173 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
175 my2DExtActor = SMESH_DeviceActor::New();
176 my2DExtActor->SetUserMatrix(aMatrix);
177 my2DExtActor->PickableOff();
178 my2DExtActor->SetProperty(my2DExtProp);
179 my2DExtActor->SetBackfaceProperty(my2DExtProp);
180 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
181 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
182 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
183 aFilter->RegisterCellsWithType(VTK_POLYGON);
184 aFilter->RegisterCellsWithType(VTK_QUAD);
185 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
186 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
188 my3DActor = SMESH_DeviceActor::New();
189 my3DActor->SetUserMatrix(aMatrix);
190 my3DActor->PickableOff();
191 my3DActor->SetProperty(mySurfaceProp);
192 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
193 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
194 aFilter = my3DActor->GetExtractUnstructuredGrid();
195 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
196 aFilter->RegisterCellsWithType(VTK_TETRA);
197 aFilter->RegisterCellsWithType(VTK_VOXEL);
198 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
199 aFilter->RegisterCellsWithType(VTK_WEDGE);
200 aFilter->RegisterCellsWithType(VTK_PYRAMID);
201 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
202 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
203 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
204 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
205 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
206 //#ifdef VTK_HAVE_POLYHEDRON
207 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
208 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
211 my3DExtActor = SMESH_DeviceActor::New();
212 my3DExtActor->SetUserMatrix(aMatrix);
213 my3DExtActor->PickableOff();
214 my3DExtActor->SetProperty(my2DExtProp);
215 my3DExtActor->SetBackfaceProperty(my2DExtProp);
216 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
217 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
218 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
219 aFilter->RegisterCellsWithType(VTK_TETRA);
220 aFilter->RegisterCellsWithType(VTK_VOXEL);
221 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
222 aFilter->RegisterCellsWithType(VTK_WEDGE);
223 aFilter->RegisterCellsWithType(VTK_PYRAMID);
224 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
225 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
226 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
227 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
228 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
230 //Definition 1D device of the actor
231 //---------------------------------
232 myEdgeProp = vtkProperty::New();
233 myEdgeProp->SetAmbient(1.0);
234 myEdgeProp->SetDiffuse(0.0);
235 myEdgeProp->SetSpecular(0.0);
236 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
237 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
238 myEdgeProp->SetLineWidth(aLineWidth);
240 my1DActor = SMESH_DeviceActor::New();
241 my1DActor->SetUserMatrix(aMatrix);
242 my1DActor->PickableOff();
243 my1DActor->SetHighlited(true);
244 my1DActor->SetProperty(myEdgeProp);
245 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
246 aFilter = my1DActor->GetExtractUnstructuredGrid();
247 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
248 aFilter->RegisterCellsWithType(VTK_LINE);
249 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
251 my1DProp = vtkProperty::New();
252 my1DProp->DeepCopy(myEdgeProp);
253 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
254 my1DProp->SetPointSize(aElem0DSize);
256 my1DExtProp = vtkProperty::New();
257 my1DExtProp->DeepCopy(myEdgeProp);
258 anRGB[0] = 1 - anRGB[0];
259 anRGB[1] = 1 - anRGB[1];
260 anRGB[2] = 1 - anRGB[2];
261 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
262 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
263 my1DExtProp->SetPointSize(aElem0DSize);
265 my1DExtActor = SMESH_DeviceActor::New();
266 my1DExtActor->SetUserMatrix(aMatrix);
267 my1DExtActor->PickableOff();
268 my1DExtActor->SetHighlited(true);
269 my1DExtActor->SetVisibility(false);
270 my1DExtActor->SetProperty(my1DExtProp);
271 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
272 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
273 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
274 aFilter->RegisterCellsWithType(VTK_LINE);
275 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
278 //Definition 0D device of the actor (0d elements)
279 //-----------------------------------------------
280 my0DProp = vtkProperty::New();
281 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
282 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
283 my0DProp->SetPointSize(aElem0DSize);
285 my0DActor = SMESH_DeviceActor::New();
286 my0DActor->SetUserMatrix(aMatrix);
287 my0DActor->SetStoreClippingMapping(true);
288 my0DActor->PickableOff();
289 my0DActor->SetVisibility(false);
290 my0DActor->SetProperty(my0DProp);
291 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
292 aFilter = my0DActor->GetExtractUnstructuredGrid();
293 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
294 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
295 aFilter->RegisterCellsWithType(VTK_VERTEX);
297 //my0DExtProp = vtkProperty::New();
298 //my0DExtProp->DeepCopy(my0DProp);
299 //anRGB[0] = 1 - anRGB[0];
300 //anRGB[1] = 1 - anRGB[1];
301 //anRGB[2] = 1 - anRGB[2];
302 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
303 //my0DExtProp->SetPointSize(aElem0DSize);
305 //my0DExtActor = SMESH_DeviceActor::New();
306 //my0DExtActor->SetUserMatrix(aMatrix);
307 //my0DExtActor->SetStoreClippingMapping(true);
308 //my0DExtActor->PickableOff();
309 //my0DExtActor->SetHighlited(true);
310 //my0DExtActor->SetVisibility(false);
311 //my0DExtActor->SetProperty(my0DExtProp);
312 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
313 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
314 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
315 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
316 //aFilter->RegisterCellsWithType(VTK_VERTEX);
319 //Definition 0D device of the actor (nodes)
320 //-----------------------------------------
321 myNodeProp = vtkProperty::New();
322 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
323 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
325 myNodeActor = SMESH_DeviceActor::New();
326 myNodeActor->SetUserMatrix(aMatrix);
327 myNodeActor->SetStoreClippingMapping(true);
328 myNodeActor->PickableOff();
329 myNodeActor->SetVisibility(false);
330 myNodeActor->SetProperty(myNodeProp);
331 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
332 aFilter = myNodeActor->GetExtractUnstructuredGrid();
333 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
335 myNodeExtProp = vtkProperty::New();
336 myNodeExtProp->DeepCopy(myNodeProp);
337 anRGB[0] = 1 - anRGB[0];
338 anRGB[1] = 1 - anRGB[1];
339 anRGB[2] = 1 - anRGB[2];
340 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
342 myNodeExtActor = SMESH_DeviceActor::New();
343 myNodeExtActor->SetUserMatrix(aMatrix);
344 myNodeExtActor->SetStoreClippingMapping(true);
345 myNodeExtActor->PickableOff();
346 myNodeExtActor->SetHighlited(true);
347 myNodeExtActor->SetVisibility(false);
348 myNodeExtActor->SetProperty(myNodeExtProp);
349 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
350 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
351 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
352 aFilter->RegisterCellsWithType(VTK_VERTEX);
354 //Definition of Pickable and Highlitable engines
355 //----------------------------------------------
357 myBaseActor = SMESH_DeviceActor::New();
358 myBaseActor->SetUserMatrix(aMatrix);
359 myBaseActor->SetStoreGemetryMapping(true);
360 myBaseActor->GetProperty()->SetOpacity(0.0);
362 myPickableActor = myBaseActor;
364 myHighlightProp = vtkProperty::New();
365 myHighlightProp->SetAmbient(1.0);
366 myHighlightProp->SetDiffuse(0.0);
367 myHighlightProp->SetSpecular(0.0);
368 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
369 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
370 myHighlightProp->SetPointSize(aElem0DSize); // ??
371 myHighlightProp->SetRepresentation(1);
373 myPreselectProp = vtkProperty::New();
374 myPreselectProp->SetAmbient(1.0);
375 myPreselectProp->SetDiffuse(0.0);
376 myPreselectProp->SetSpecular(0.0);
377 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
378 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
379 myPreselectProp->SetPointSize(aElem0DSize); // ??
380 myPreselectProp->SetRepresentation(1);
382 myHighlitableActor = SMESH_DeviceActor::New();
383 myHighlitableActor->SetUserMatrix(aMatrix);
384 myHighlitableActor->PickableOff();
385 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
392 myControlMode = eNone;
393 myControlActor = my2DActor;
395 //Definition of myScalarBarActor
396 //------------------------------
397 myLookupTable = vtkLookupTable::New();
398 //Fix for Bug PAL5195 - SMESH764:
399 //Controls - Aspect Ratio: incorrect colors of the best and worst values
400 myLookupTable->SetHueRange(0.667,0.0);
402 myScalarBarActor = SMESH_ScalarBarActor::New();
403 myScalarBarActor->SetVisibility(false);
404 myScalarBarActor->SetLookupTable(myLookupTable);
407 //Incorrect "Min value" in Scalar Bar in Mesh:
408 // myScalarBarActor->SetLabelFormat("%.4g");
409 // changes was commented because of regression bug IPAL 19981
411 mgr = SUIT_Session::session()->resourceMgr();
415 //Definition of points numbering pipeline
416 //---------------------------------------
417 myPointsNumDataSet = vtkUnstructuredGrid::New();
419 myPtsMaskPoints = vtkMaskPoints::New();
420 myPtsMaskPoints->SetInput(myPointsNumDataSet);
421 myPtsMaskPoints->SetOnRatio(1);
423 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
424 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
425 myPtsSelectVisiblePoints->SelectInvisibleOff();
426 myPtsSelectVisiblePoints->SetTolerance(0.1);
428 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
429 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
430 #if (VTK_XVERSION < 0x050200)
431 myPtsLabeledDataMapper->SetLabelFormat("%g");
433 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
435 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
436 aPtsTextProp->SetFontFamilyToTimes();
437 static int aPointsFontSize = 10;
438 aPtsTextProp->SetFontSize(aPointsFontSize);
439 aPtsTextProp->SetBold(1);
440 aPtsTextProp->SetItalic(0);
441 aPtsTextProp->SetShadow(0);
442 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
443 aPtsTextProp->Delete();
445 myEntityMode = eAllEntity;
447 myIsPointsLabeled = false;
449 myPointLabels = vtkActor2D::New();
450 myPointLabels->SetMapper(myPtsLabeledDataMapper);
451 myPointLabels->GetProperty()->SetColor(1,1,1);
452 myPointLabels->SetVisibility(myIsPointsLabeled);
455 //Definition of cells numbering pipeline
456 //---------------------------------------
457 myCellsNumDataSet = vtkUnstructuredGrid::New();
459 myCellCenters = VTKViewer_CellCenters::New();
460 myCellCenters->SetInput(myCellsNumDataSet);
462 myClsMaskPoints = vtkMaskPoints::New();
463 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
464 myClsMaskPoints->SetOnRatio(1);
466 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
467 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
468 myClsSelectVisiblePoints->SelectInvisibleOff();
469 myClsSelectVisiblePoints->SetTolerance(0.1);
471 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
472 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
473 #if (VTK_XVERSION < 0x050200)
474 myClsLabeledDataMapper->SetLabelFormat("%g");
476 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
478 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
479 aClsTextProp->SetFontFamilyToTimes();
480 static int aCellsFontSize = 12;
481 aClsTextProp->SetFontSize(aCellsFontSize);
482 aClsTextProp->SetBold(1);
483 aClsTextProp->SetItalic(0);
484 aClsTextProp->SetShadow(0);
485 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
486 aClsTextProp->Delete();
488 myIsCellsLabeled = false;
490 myCellsLabels = vtkActor2D::New();
491 myCellsLabels->SetMapper(myClsLabeledDataMapper);
492 myCellsLabels->GetProperty()->SetColor(0,1,0);
493 myCellsLabels->SetVisibility(myIsCellsLabeled);
496 myImplicitBoolean = vtkImplicitBoolean::New();
497 myImplicitBoolean->SetOperationTypeToIntersection();
501 //Quadratic 2D elements representation
502 //-----------------------------------------------------------------------------
503 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
504 if(aQuadratic2DMode == 0){
505 myHighlitableActor->SetQuadraticArcMode(false);
506 my2DActor->SetQuadraticArcMode(false);
507 my1DActor->SetQuadraticArcMode(false);
509 else if(aQuadratic2DMode == 1){
510 myHighlitableActor->SetQuadraticArcMode(true);
511 my2DActor->SetQuadraticArcMode(true);
512 my1DActor->SetQuadraticArcMode(true);
515 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
516 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
517 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
519 // Set colors of the name actor
520 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
521 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
522 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
523 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
525 #ifndef DISABLE_PLOT2DVIEWER
532 SMESH_ActorDef::~SMESH_ActorDef()
534 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
536 // caught by SMESHGUI::ProcessEvents() static method
537 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
539 myScalarBarActor->Delete();
540 myLookupTable->Delete();
542 mySurfaceProp->Delete();
543 myBackSurfaceProp->Delete();
545 myEdgeProp->Delete();
546 myHighlightProp->Delete();
547 myPreselectProp->Delete();
549 myNodeProp->Delete();
550 myNodeExtProp->Delete();
555 //my0DExtProp->Delete();
556 //my0DExtActor->Delete();
561 my1DExtProp->Delete();
562 my1DExtActor->Delete();
565 my2DExtProp->Delete();
566 my2DExtActor->Delete();
568 my3DExtActor->Delete();
570 myNodeActor->Delete();
571 myBaseActor->Delete();
573 myNodeExtActor->Delete();
575 myHighlitableActor->Delete();
577 //Deleting of points numbering pipeline
578 //---------------------------------------
579 myPointsNumDataSet->Delete();
581 // commented: porting to vtk 5.0
582 // myPtsLabeledDataMapper->RemoveAllInputs();
583 myPtsLabeledDataMapper->Delete();
585 // commented: porting to vtk 5.0
586 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
587 myPtsSelectVisiblePoints->Delete();
589 // commented: porting to vtk 5.0
590 // myPtsMaskPoints->UnRegisterAllOutputs();
591 myPtsMaskPoints->Delete();
593 myPointLabels->Delete();
596 //Deleting of cells numbering pipeline
597 //---------------------------------------
598 myCellsNumDataSet->Delete();
600 myClsLabeledDataMapper->RemoveAllInputs();
601 myClsLabeledDataMapper->Delete();
603 // commented: porting to vtk 5.0
604 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
605 myClsSelectVisiblePoints->Delete();
607 // commented: porting to vtk 5.0
608 // myClsMaskPoints->UnRegisterAllOutputs();
609 myClsMaskPoints->Delete();
611 // commented: porting to vtk 5.0
612 // myCellCenters->UnRegisterAllOutputs();
613 myCellCenters->Delete();
615 myCellsLabels->Delete();
617 myImplicitBoolean->Delete();
619 myTimeStamp->Delete();
620 #ifndef DISABLE_PLOT2DVIEWER
622 delete my2dHistogram;
627 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
629 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
631 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
633 if ( myIsPointsLabeled )
635 myPointsNumDataSet->ShallowCopy(aGrid);
636 vtkDataSet *aDataSet = myPointsNumDataSet;
638 int aNbElem = aDataSet->GetNumberOfPoints();
640 vtkIntArray *anArray = vtkIntArray::New();
641 anArray->SetNumberOfValues( aNbElem );
643 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
645 int aSMDSId = myVisualObj->GetNodeObjId( anId );
646 anArray->SetValue( anId, aSMDSId );
649 aDataSet->GetPointData()->SetScalars( anArray );
651 myPtsMaskPoints->SetInput( aDataSet );
652 myPointLabels->SetVisibility( GetVisibility() );
656 myPointLabels->SetVisibility( false );
658 SetRepresentation(GetRepresentation());
659 myTimeStamp->Modified();
663 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
665 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
666 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
667 if(myIsCellsLabeled){
668 myCellsNumDataSet->ShallowCopy(aGrid);
669 vtkDataSet *aDataSet = myCellsNumDataSet;
670 int aNbElem = aDataSet->GetNumberOfCells();
671 vtkIntArray *anArray = vtkIntArray::New();
672 anArray->SetNumberOfValues(aNbElem);
673 for(int anId = 0; anId < aNbElem; anId++){
674 int aSMDSId = myVisualObj->GetElemObjId(anId);
675 anArray->SetValue(anId,aSMDSId);
677 aDataSet->GetCellData()->SetScalars(anArray);
678 myCellCenters->SetInput(aDataSet);
679 myCellsLabels->SetVisibility(GetVisibility());
681 myCellsLabels->SetVisibility(false);
683 myTimeStamp->Modified();
687 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
689 myIsFacesOriented = theIsFacesOriented;
691 my2DActor->SetFacesOriented(theIsFacesOriented);
692 my3DActor->SetFacesOriented(theIsFacesOriented);
694 myTimeStamp->Modified();
697 bool SMESH_ActorDef::GetFacesOriented()
699 return myIsFacesOriented;
702 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
704 my2DActor->SetFacesOrientationColor( theColor );
705 my3DActor->SetFacesOrientationColor( theColor );
708 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
710 my3DActor->GetFacesOrientationColor( theColor );
713 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
715 my2DActor->SetFacesOrientationScale( theScale );
716 my3DActor->SetFacesOrientationScale( theScale );
719 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
721 return my3DActor->GetFacesOrientationScale();
724 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
726 my2DActor->SetFacesOrientation3DVectors( theState );
727 my3DActor->SetFacesOrientation3DVectors( theState );
730 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
732 return my3DActor->GetFacesOrientation3DVectors();
738 SetControlMode(eControl theMode)
740 SetControlMode(theMode,true);
746 SetControlMode(eControl theMode,
747 bool theCheckEntityMode)
749 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
753 myControlMode = eNone;
754 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
756 my0DActor->GetMapper()->SetScalarVisibility(false);
757 my1DActor->GetMapper()->SetScalarVisibility(false);
758 my2DActor->GetMapper()->SetScalarVisibility(false);
759 my3DActor->GetMapper()->SetScalarVisibility(false);
760 myScalarBarActor->SetVisibility(false);
762 bool anIsScalarVisible = theMode > eNone;
764 if(anIsScalarVisible) {
768 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
769 aControl->SetPrecision( myControlsPrecision );
770 myFunctor.reset( aControl );
771 myControlActor = my1DActor;
776 myFunctor.reset(new SMESH::Controls::Length2D());
777 myControlActor = my2DActor;
781 myFunctor.reset(new SMESH::Controls::FreeBorders());
782 myControlActor = my1DActor;
785 myFunctor.reset(new SMESH::Controls::FreeEdges());
786 myControlActor = my2DActor;
789 myFunctor.reset(new SMESH::Controls::FreeNodes());
790 myControlActor = myNodeActor;
793 myFunctor.reset(new SMESH::Controls::FreeFaces());
794 myControlActor = my2DActor;
796 case eBareBorderFace:
797 myFunctor.reset(new SMESH::Controls::BareBorderFace());
798 myControlActor = my2DActor;
800 case eOverConstrainedFace:
801 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
802 myControlActor = my2DActor;
804 case eMultiConnection:
805 myFunctor.reset(new SMESH::Controls::MultiConnection());
806 myControlActor = my1DActor;
808 case eMultiConnection2D:
809 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
810 myControlActor = my2DActor;
814 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
815 aControl->SetPrecision( myControlsPrecision );
816 myFunctor.reset( aControl );
817 myControlActor = my2DActor;
822 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
823 aControl->SetPrecision( myControlsPrecision );
824 myFunctor.reset( aControl );
825 myControlActor = my2DActor;
830 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
831 aControl->SetPrecision( myControlsPrecision );
832 myFunctor.reset( aControl );
833 myControlActor = my2DActor;
838 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
839 aControl->SetPrecision( myControlsPrecision );
840 myFunctor.reset( aControl );
841 myControlActor = my3DActor;
846 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
847 aControl->SetPrecision( myControlsPrecision );
848 myFunctor.reset( aControl );
849 myControlActor = my3DActor;
852 case eMaxElementLength2D:
854 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
855 aControl->SetPrecision( myControlsPrecision );
856 myFunctor.reset( aControl );
857 myControlActor = my2DActor;
860 case eMaxElementLength3D:
862 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
863 aControl->SetPrecision( myControlsPrecision );
864 myFunctor.reset( aControl );
865 myControlActor = my3DActor;
868 case eBareBorderVolume:
870 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
871 myControlActor = my3DActor;
874 case eOverConstrainedVolume:
876 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
877 myControlActor = my3DActor;
882 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
883 aControl->SetPrecision( myControlsPrecision );
884 myFunctor.reset( aControl );
885 myControlActor = my2DActor;
890 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
891 aControl->SetPrecision( myControlsPrecision );
892 myFunctor.reset( aControl );
893 myControlActor = my2DActor;
898 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
899 aControl->SetPrecision( myControlsPrecision );
900 myFunctor.reset( aControl );
901 myControlActor = my2DActor;
908 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
909 vtkIdType aNbCells = aGrid->GetNumberOfCells();
911 myControlMode = theMode;
912 switch(myControlMode){
914 myNodeExtActor->SetExtControlMode(myFunctor);
918 my1DExtActor->SetExtControlMode(myFunctor);
921 case eBareBorderFace:
922 case eOverConstrainedFace:
923 my2DExtActor->SetExtControlMode(myFunctor);
925 case eBareBorderVolume:
926 case eOverConstrainedVolume:
927 my3DExtActor->SetExtControlMode(myFunctor);
930 case eMultiConnection2D:
931 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
932 UpdateDistribution();
935 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
936 UpdateDistribution();
940 if(theCheckEntityMode){
941 if(myControlActor == my1DActor)
942 SetEntityMode(eEdges);
943 else if(myControlActor == my2DActor){
944 switch(myControlMode){
948 case eMultiConnection2D:
949 //SetEntityMode(eEdges);
950 SetEntityMode(eFaces);
953 SetEntityMode(eFaces);
955 }else if(myControlActor == my3DActor)
956 SetEntityMode(eVolumes);
961 if(theCheckEntityMode)
962 myEntityMode = eAllEntity;
966 SetRepresentation(GetRepresentation());
968 myTimeStamp->Modified();
973 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
974 theRenderer->AddActor(myNodeActor);
975 theRenderer->AddActor(myBaseActor);
977 theRenderer->AddActor(myNodeExtActor);
979 my3DActor->AddToRender(theRenderer);
980 my3DExtActor->AddToRender(theRenderer);
981 my2DActor->AddToRender(theRenderer);
982 my2DExtActor->AddToRender(theRenderer);
984 theRenderer->AddActor(my1DActor);
985 theRenderer->AddActor(my1DExtActor);
987 theRenderer->AddActor(my0DActor);
988 //theRenderer->AddActor(my0DExtActor);
990 theRenderer->AddActor(myHighlitableActor);
992 theRenderer->AddActor2D(myScalarBarActor);
994 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
995 myClsSelectVisiblePoints->SetRenderer(theRenderer);
997 theRenderer->AddActor2D(myPointLabels);
998 theRenderer->AddActor2D(myCellsLabels);
1000 // the superclass' method should be called at the end
1001 // (in particular, for correct work of selection)
1002 SALOME_Actor::AddToRender(theRenderer);
1005 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1006 SALOME_Actor::RemoveFromRender(theRenderer);
1008 theRenderer->RemoveActor(myNodeActor);
1009 theRenderer->RemoveActor(myBaseActor);
1011 theRenderer->RemoveActor(myNodeExtActor);
1013 theRenderer->RemoveActor(myHighlitableActor);
1015 theRenderer->RemoveActor(my0DActor);
1016 //theRenderer->RemoveActor(my0DExtActor);
1018 theRenderer->RemoveActor(my1DActor);
1019 theRenderer->RemoveActor(my1DExtActor);
1021 my2DActor->RemoveFromRender(theRenderer);
1022 my2DExtActor->RemoveFromRender(theRenderer);
1023 my3DActor->RemoveFromRender(theRenderer);
1024 my3DExtActor->RemoveFromRender(theRenderer);
1026 theRenderer->RemoveActor(myScalarBarActor);
1027 theRenderer->RemoveActor(myPointLabels);
1028 theRenderer->RemoveActor(myCellsLabels);
1032 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1033 const char* theEntry,
1034 const char* theName,
1037 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1041 myVisualObj = theVisualObj;
1042 myVisualObj->Update(theIsClear);
1044 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1045 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1047 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1049 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1051 my0DActor->Init(myVisualObj,myImplicitBoolean);
1052 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1054 my1DActor->Init(myVisualObj,myImplicitBoolean);
1055 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1057 my2DActor->Init(myVisualObj,myImplicitBoolean);
1058 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1059 my3DActor->Init(myVisualObj,myImplicitBoolean);
1060 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1062 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1063 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1065 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1066 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1068 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1069 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1070 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1071 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1073 vtkFloatingPointType aFactor, aUnits;
1074 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1075 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1076 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1078 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1082 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1083 SetIsShrunkable(true);
1085 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1087 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1088 SetRepresentation(-1);
1091 SetRepresentation(eEdge);
1092 }else if(aMode == 1){
1093 SetRepresentation(eSurface);
1094 }else if(aMode == 2){
1095 SetRepresentation(ePoint);
1102 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1103 SetIsDisplayNameActor( true );
1105 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1106 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1107 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1109 myTimeStamp->Modified();
1115 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1116 return myNodeActor->GetBounds();
1120 vtkDataSet* SMESH_ActorDef::GetInput(){
1121 return GetUnstructuredGrid();
1125 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1126 Superclass::SetTransform(theTransform);
1128 myNodeActor->SetTransform(theTransform);
1129 myBaseActor->SetTransform(theTransform);
1131 myHighlitableActor->SetTransform(theTransform);
1133 myNodeExtActor->SetTransform(theTransform);
1135 my0DActor->SetTransform(theTransform);
1136 //my0DExtActor->SetTransform(theTransform);
1138 my1DActor->SetTransform(theTransform);
1139 my1DExtActor->SetTransform(theTransform);
1141 my2DActor->SetTransform(theTransform);
1142 my2DExtActor->SetTransform(theTransform);
1143 my3DActor->SetTransform(theTransform);
1144 my3DExtActor->SetTransform(theTransform);
1150 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1151 vtkLODActor::SetMapper(theMapper);
1155 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1156 SALOME_Actor::ShallowCopy(prop);
1160 vtkMapper* SMESH_ActorDef::GetMapper(){
1161 return myPickableActor->GetMapper();
1165 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1166 return myVisualObj->GetUnstructuredGrid();
1170 bool SMESH_ActorDef::IsInfinitive(){
1171 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1173 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1174 ( aDataSet->GetNumberOfCells() == 1 &&
1175 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1176 return SALOME_Actor::IsInfinitive();
1180 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1181 if ( myIsShrinkable == theShrunkable )
1183 myIsShrinkable = theShrunkable;
1187 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1188 return myBaseActor->GetShrinkFactor();
1191 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1192 myBaseActor->SetShrinkFactor(theValue);
1194 my1DActor->SetShrinkFactor(theValue);
1195 my1DExtActor->SetShrinkFactor(theValue);
1197 my2DActor->SetShrinkFactor(theValue);
1198 my2DExtActor->SetShrinkFactor(theValue);
1199 my3DActor->SetShrinkFactor(theValue);
1200 my3DExtActor->SetShrinkFactor(theValue);
1205 void SMESH_ActorDef::SetShrink(){
1206 if(!myIsShrinkable) return;
1208 myBaseActor->SetShrink();
1210 my1DActor->SetShrink();
1211 my1DExtActor->SetShrink();
1213 my2DActor->SetShrink();
1214 my2DExtActor->SetShrink();
1215 my3DActor->SetShrink();
1216 my3DExtActor->SetShrink();
1222 void SMESH_ActorDef::UnShrink(){
1223 if(!myIsShrunk) return;
1225 myBaseActor->UnShrink();
1227 my1DActor->UnShrink();
1228 my1DExtActor->UnShrink();
1230 my2DActor->UnShrink();
1231 my2DExtActor->UnShrink();
1232 my3DActor->UnShrink();
1233 my3DExtActor->UnShrink();
1240 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1241 return myPickableActor->GetNodeObjId(theVtkID);
1244 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1245 return myPickableActor->GetNodeCoord(theObjID);
1249 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1250 return myPickableActor->GetElemObjId(theVtkID);
1253 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1254 return myPickableActor->GetElemCell(theObjID);
1258 void SMESH_ActorDef::SetVisibility(int theMode){
1259 SetVisibility(theMode,true);
1263 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1264 SALOME_Actor::SetVisibility(theMode);
1266 myNodeActor->VisibilityOff();
1267 myBaseActor->VisibilityOff();
1269 myNodeExtActor->VisibilityOff();
1271 my0DActor->VisibilityOff();
1272 //my0DExtActor->VisibilityOff();
1274 my1DActor->VisibilityOff();
1275 my1DExtActor->VisibilityOff();
1277 my2DActor->VisibilityOff();
1278 my2DExtActor->VisibilityOff();
1279 my3DActor->VisibilityOff();
1280 my3DExtActor->VisibilityOff();
1282 myScalarBarActor->VisibilityOff();
1283 myPointLabels->VisibilityOff();
1284 myCellsLabels->VisibilityOff();
1286 if(GetVisibility()){
1287 if(theIsUpdateRepersentation)
1288 SetRepresentation(GetRepresentation());
1290 if(myControlMode != eNone){
1291 switch(myControlMode){
1293 myNodeExtActor->VisibilityOn();
1297 my1DExtActor->VisibilityOn();
1300 case eBareBorderFace:
1301 case eOverConstrainedFace:
1302 my2DExtActor->VisibilityOn();
1304 case eBareBorderVolume:
1305 case eOverConstrainedVolume:
1306 my3DExtActor->VisibilityOn();
1309 case eMultiConnection2D:
1310 my1DExtActor->VisibilityOn();
1312 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1313 myScalarBarActor->VisibilityOn();
1317 if(myRepresentation != ePoint)
1318 myPickableActor->VisibilityOn();
1320 myNodeActor->VisibilityOn();
1323 if(myEntityMode & e0DElements){
1324 my0DActor->VisibilityOn();
1327 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1328 my1DActor->VisibilityOn();
1331 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1332 my2DActor->VisibilityOn();
1335 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1336 my3DActor->VisibilityOn();
1339 if(myIsPointsLabeled){
1340 myPointLabels->VisibilityOn();
1341 myNodeActor->VisibilityOn();
1344 if(myIsCellsLabeled)
1345 myCellsLabels->VisibilityOn();
1352 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1354 myEntityState = eAllEntity;
1356 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1357 myEntityState &= ~e0DElements;
1358 theMode &= ~e0DElements;
1361 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1362 myEntityState &= ~eEdges;
1366 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1367 myEntityState &= ~eFaces;
1371 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1372 myEntityState &= ~eVolumes;
1373 theMode &= ~eVolumes;
1377 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1378 theMode |= e0DElements;
1380 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1383 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1386 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1387 theMode |= eVolumes;
1390 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1392 myEntityMode = theMode;
1393 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1394 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1395 aFilter->ClearRegisteredCellsWithType();
1396 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1398 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1399 aHightFilter->ClearRegisteredCellsWithType();
1400 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1402 if (myEntityMode & e0DElements) {
1403 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1404 aFilter->RegisterCellsWithType(VTK_VERTEX);
1405 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1408 if (myEntityMode & eEdges) {
1409 if (MYDEBUG) MESSAGE("EDGES");
1410 aFilter->RegisterCellsWithType(VTK_LINE);
1411 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1413 aHightFilter->RegisterCellsWithType(VTK_LINE);
1414 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1417 if (myEntityMode & eFaces) {
1418 if (MYDEBUG) MESSAGE("FACES");
1419 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1420 aFilter->RegisterCellsWithType(VTK_POLYGON);
1421 aFilter->RegisterCellsWithType(VTK_QUAD);
1422 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1423 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1425 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1426 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1427 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1428 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1429 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1432 if (myEntityMode & eVolumes) {
1433 if (MYDEBUG) MESSAGE("VOLUMES");
1434 aFilter->RegisterCellsWithType(VTK_TETRA);
1435 aFilter->RegisterCellsWithType(VTK_VOXEL);
1436 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1437 aFilter->RegisterCellsWithType(VTK_WEDGE);
1438 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1439 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1440 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1441 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1442 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1443 //#ifdef VTK_HAVE_POLYHEDRON
1444 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1447 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1448 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1449 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1450 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1451 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1452 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1453 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1454 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1455 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1456 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1457 //#ifdef VTK_HAVE_POLYHEDRON
1458 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1462 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1463 SetVisibility(GetVisibility(),false);
1466 void SMESH_ActorDef::SetRepresentation (int theMode)
1468 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1469 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1470 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1473 myRepresentation = eSurface;
1474 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1475 myRepresentation = eEdge;
1476 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1477 myRepresentation = ePoint;
1482 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1485 if (!aNbFaces && !aNbVolumes) return;
1488 myRepresentation = theMode;
1491 if (!GetUnstructuredGrid()->GetNumberOfCells())
1492 myRepresentation = ePoint;
1495 if (myRepresentation == ePoint) {
1503 myPickableActor = myBaseActor;
1504 myNodeActor->SetVisibility(false);
1505 myNodeExtActor->SetVisibility(false);
1506 vtkProperty *aProp = NULL, *aBackProp = NULL;
1507 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1508 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1509 switch (myRepresentation) {
1511 myPickableActor = myNodeActor;
1512 myNodeActor->SetVisibility(true);
1513 aQuadraticMode = SMESH_Actor::eLines;
1514 aProp = aBackProp = myNodeProp;
1515 aReperesent = SMESH_DeviceActor::ePoint;
1518 aProp = aBackProp = myEdgeProp;
1519 aReperesent = SMESH_DeviceActor::eInsideframe;
1522 aProp = mySurfaceProp;
1523 aBackProp = myBackSurfaceProp;
1524 aReperesent = SMESH_DeviceActor::eSurface;
1528 my2DActor->SetProperty(aProp);
1529 my2DActor->SetBackfaceProperty(aBackProp);
1530 my2DActor->SetRepresentation(aReperesent);
1532 if(aQuadraticMode == SMESH_Actor::eLines)
1533 my2DActor->SetQuadraticArcMode(false);
1534 else if(aQuadraticMode == SMESH_Actor::eArcs)
1535 my2DActor->SetQuadraticArcMode(true);
1537 my2DExtActor->SetRepresentation(aReperesent);
1539 my3DActor->SetProperty(aProp);
1540 my3DActor->SetBackfaceProperty(aBackProp);
1541 my3DActor->SetRepresentation(aReperesent);
1543 //my0DExtActor->SetVisibility(false);
1544 my1DExtActor->SetVisibility(false);
1545 my2DExtActor->SetVisibility(false);
1546 my3DExtActor->SetVisibility(false);
1549 //my0DActor->SetProperty(aProp);
1550 //my0DActor->SetBackfaceProperty(aBackProp);
1551 my0DActor->SetRepresentation(aReperesent);
1552 //my0DExtActor->SetRepresentation(aReperesent);
1554 switch(myControlMode){
1556 case eMultiConnection:
1557 aProp = aBackProp = my1DProp;
1558 if(myRepresentation != ePoint)
1559 aReperesent = SMESH_DeviceActor::eInsideframe;
1563 if(aQuadraticMode == SMESH_Actor::eLines)
1564 my1DActor->SetQuadraticArcMode(false);
1565 else if(aQuadraticMode == SMESH_Actor::eArcs)
1566 my1DActor->SetQuadraticArcMode(true);
1568 my1DActor->SetProperty(aProp);
1569 my1DActor->SetBackfaceProperty(aBackProp);
1570 my1DActor->SetRepresentation(aReperesent);
1572 my1DExtActor->SetRepresentation(aReperesent);
1574 if(myIsPointsVisible)
1575 myPickableActor = myNodeActor;
1576 if(GetPointRepresentation())
1577 myNodeActor->SetVisibility(true);
1579 SetMapper(myPickableActor->GetMapper());
1581 SetVisibility(GetVisibility(),false);
1587 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1588 if ( myIsPointsVisible == theIsPointsVisible )
1590 myIsPointsVisible = theIsPointsVisible;
1591 SetRepresentation(GetRepresentation());
1594 bool SMESH_ActorDef::GetPointRepresentation(){
1595 return myIsPointsVisible || myIsPointsLabeled;
1599 void SMESH_ActorDef::UpdateHighlight(){
1600 myHighlitableActor->SetVisibility(false);
1601 myHighlitableActor->SetHighlited(false);
1603 if(myIsHighlighted){
1604 myHighlitableActor->SetProperty(myHighlightProp);
1605 }else if(myIsPreselected){
1606 myHighlitableActor->SetProperty(myPreselectProp);
1609 bool anIsVisible = GetVisibility();
1611 if(myIsHighlighted || myIsPreselected){
1612 if(GetUnstructuredGrid()->GetNumberOfCells()){
1613 myHighlitableActor->SetHighlited(anIsVisible);
1614 myHighlitableActor->SetVisibility(anIsVisible);
1615 myHighlitableActor->GetExtractUnstructuredGrid()->
1616 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1617 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1618 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1619 myHighlitableActor->SetHighlited(anIsVisible);
1620 myHighlitableActor->GetExtractUnstructuredGrid()->
1621 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1622 myHighlitableActor->SetVisibility(anIsVisible);
1623 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1625 VTK::MarkerType aMarkerType = GetMarkerType();
1626 if(aMarkerType != VTK::MT_USER)
1627 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1629 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1635 void SMESH_ActorDef::highlight(bool theHighlight){
1636 if ( myIsHighlighted == theHighlight )
1638 myIsHighlighted = theHighlight;
1643 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1644 if ( myIsPreselected == thePreselect )
1646 myIsPreselected = thePreselect;
1652 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1654 if (myPickableActor->GetIsOpaque())
1656 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1664 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1666 if (!myPickableActor->GetIsOpaque())
1668 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1676 void SMESH_ActorDef::Render(vtkRenderer *ren){
1677 unsigned long aTime = myTimeStamp->GetMTime();
1678 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1679 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1680 if(anObjTime > aTime || aClippingTime > aTime)
1685 void SMESH_ActorDef::Update(){
1686 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1688 if(GetControlMode() != eNone) {
1689 unsigned long aTime = myTimeStamp->GetMTime();
1690 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1691 if (anObjTime > aTime)
1692 SetControlMode(GetControlMode(),false);
1694 if(myIsPointsLabeled){
1695 SetPointsLabeled(myIsPointsLabeled);
1697 if(myIsCellsLabeled){
1698 SetCellsLabeled(myIsCellsLabeled);
1700 if(myIsFacesOriented){
1701 SetFacesOriented(myIsFacesOriented);
1703 SetEntityMode(GetEntityMode());
1704 SetVisibility(GetVisibility());
1706 myTimeStamp->Modified();
1711 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1712 SALOME_Actor::ReleaseGraphicsResources(renWin);
1714 myPickableActor->ReleaseGraphicsResources(renWin);
1718 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1719 vtkFloatingPointType* aColor = theProperty->GetColor();
1726 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1727 mySurfaceProp->SetOpacity(theValue);
1728 myBackSurfaceProp->SetOpacity(theValue);
1729 myEdgeProp->SetOpacity(theValue);
1730 myNodeProp->SetOpacity(theValue);
1732 my1DProp->SetOpacity(theValue);
1736 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1737 return mySurfaceProp->GetOpacity();
1741 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1742 mySurfaceProp->SetColor(r,g,b);
1743 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1744 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1745 aGroupObj->GetElementType() == SMDSAbs_Volume )
1746 myNameActor->SetBackgroundColor(r,g,b);
1750 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1751 ::GetColor(mySurfaceProp,r,g,b);
1752 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1755 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1756 myBackSurfaceProp->SetColor(r,g,b);
1760 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1761 ::GetColor(myBackSurfaceProp,r,g,b);
1764 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1765 myEdgeProp->SetColor(r,g,b);
1766 my1DProp->SetColor(r,g,b);
1767 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1768 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1769 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1770 myNameActor->SetBackgroundColor(r,g,b);
1774 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1775 ::GetColor(myEdgeProp,r,g,b);
1778 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1779 myNodeProp->SetColor(r,g,b);
1780 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1781 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1782 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1783 myNameActor->SetBackgroundColor(r,g,b);
1787 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1788 ::GetColor(myNodeProp,r,g,b);
1791 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1792 my0DProp->SetColor(r,g,b);
1793 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1794 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1795 myNameActor->SetBackgroundColor(r,g,b);
1799 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1800 ::GetColor(my0DProp,r,g,b);
1803 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1804 myHighlightProp->SetColor(r,g,b);
1808 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1809 ::GetColor(myHighlightProp,r,g,b);
1812 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1813 myPreselectProp->SetColor(r,g,b);
1817 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1818 ::GetColor(myPreselectProp,r,g,b);
1822 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1823 return myEdgeProp->GetLineWidth();
1827 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1828 myEdgeProp->SetLineWidth(theVal);
1830 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1831 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1837 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1838 my0DProp->SetPointSize(theVal);
1842 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1843 return my0DProp->GetPointSize();
1846 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1848 return myVisualObj->GetElemDimension( theObjId );
1853 IsImplicitFunctionUsed() const
1855 return myBaseActor->IsImplicitFunctionUsed();
1859 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1861 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1862 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1864 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1866 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1868 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1869 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1871 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1872 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1874 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1875 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1876 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1877 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1881 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1884 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1885 myCippingPlaneCont.push_back(thePlane);
1886 if(!IsImplicitFunctionUsed())
1887 SetImplicitFunctionUsed(true);
1889 return myCippingPlaneCont.size();
1894 RemoveAllClippingPlanes()
1896 myImplicitBoolean->GetFunction()->RemoveAllItems();
1897 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1898 myCippingPlaneCont.clear();
1899 SetImplicitFunctionUsed(false);
1904 GetNumberOfClippingPlanes()
1906 return myCippingPlaneCont.size();
1911 GetClippingPlane(vtkIdType theID)
1913 if(theID >= myCippingPlaneCont.size())
1915 return myCippingPlaneCont[theID].Get();
1918 void SMESH_ActorDef::UpdateScalarBar()
1920 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1924 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1926 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1927 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1929 aScalarBarTitleProp->SetFontFamilyToArial();
1931 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1933 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1934 if ( f.family() == "Arial" )
1935 aScalarBarTitleProp->SetFontFamilyToArial();
1936 else if ( f.family() == "Courier" )
1937 aScalarBarTitleProp->SetFontFamilyToCourier();
1938 else if ( f.family() == "Times" )
1939 aScalarBarTitleProp->SetFontFamilyToTimes();
1942 aScalarBarTitleProp->BoldOn();
1944 aScalarBarTitleProp->BoldOff();
1947 aScalarBarTitleProp->ItalicOn();
1949 aScalarBarTitleProp->ItalicOff();
1952 aScalarBarTitleProp->ShadowOn();
1954 aScalarBarTitleProp->ShadowOff();
1957 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1958 aScalarBarTitleProp->Delete();
1960 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1962 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1963 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1965 aScalarBarLabelProp->SetFontFamilyToArial();
1966 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1968 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1969 if( f.family() == "Arial" )
1970 aScalarBarLabelProp->SetFontFamilyToArial();
1971 else if( f.family() == "Courier" )
1972 aScalarBarLabelProp->SetFontFamilyToCourier();
1973 else if( f.family() == "Times" )
1974 aScalarBarLabelProp->SetFontFamilyToTimes();
1977 aScalarBarLabelProp->BoldOn();
1979 aScalarBarLabelProp->BoldOff();
1982 aScalarBarLabelProp->ItalicOn();
1984 aScalarBarLabelProp->ItalicOff();
1987 aScalarBarLabelProp->ShadowOn();
1989 aScalarBarLabelProp->ShadowOff();
1992 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1993 aScalarBarLabelProp->Delete();
1995 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1996 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1998 myScalarBarActor->SetOrientationToHorizontal();
2000 myScalarBarActor->SetOrientationToVertical();
2003 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2004 if( mgr->hasValue( "SMESH", name + "x" ) )
2005 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2007 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2008 if( mgr->hasValue( "SMESH", name + "y" ) )
2009 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2010 myScalarBarActor->SetPosition( aXVal, aYVal );
2012 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2013 if( mgr->hasValue( "SMESH", name + "width" ) )
2014 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2015 myScalarBarActor->SetWidth( aWVal );
2017 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2018 if( mgr->hasValue( "SMESH", name + "height" ) )
2019 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2020 myScalarBarActor->SetHeight( aHVal );
2023 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2024 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2025 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2028 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2029 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2030 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2032 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2033 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2035 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2036 myScalarBarActor->SetDistributionColoringType(coloringType);
2038 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2039 QColor(255, 255, 255));
2041 rgb[0]= distributionColor.red()/255.;
2042 rgb[1]= distributionColor.green()/255.;
2043 rgb[2]= distributionColor.blue()/255.;
2044 myScalarBarActor->SetDistributionColor(rgb);
2049 void SMESH_ActorDef::UpdateDistribution()
2051 if(SMESH::Controls::NumericalFunctor* fun =
2052 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2054 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2055 std::vector<int> nbEvents;
2056 std::vector<double> funValues;
2057 SMESH_VisualObjDef::TEntityList elems;
2058 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2059 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2060 std::vector<int> elemIds;
2061 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2062 elemIds.push_back( (*e)->GetID());
2063 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2064 double * range = lookupTable->GetRange();
2065 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2066 myScalarBarActor->SetDistribution(nbEvents);
2070 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2073 case SMESH_Actor::eLines :
2074 myHighlitableActor->SetQuadraticArcMode(false);
2075 my2DActor->SetQuadraticArcMode(false);
2076 my1DActor->SetQuadraticArcMode(false);
2078 case SMESH_Actor::eArcs :
2079 myHighlitableActor->SetQuadraticArcMode(true);
2080 if(GetRepresentation() != SMESH_Actor::ePoint) {
2081 my2DActor->SetQuadraticArcMode(true);
2082 my1DActor->SetQuadraticArcMode(true);
2091 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2093 if(myHighlitableActor->GetQuadraticArcMode())
2094 return SMESH_Actor::eArcs;
2096 return SMESH_Actor::eLines;
2099 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2101 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2102 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2103 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2106 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2108 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2109 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2110 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2111 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2114 #ifndef DISABLE_PLOT2DVIEWER
2115 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2118 my2dHistogram->clearAllPoints();
2120 if(SMESH::Controls::NumericalFunctor* fun =
2121 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2124 if(!my2dHistogram) {
2125 my2dHistogram = new SPlot2d_Histogram();
2126 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2127 my2dHistogram->setIO(anIO);
2130 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2131 std::vector<int> nbEvents;
2132 std::vector<double> funValues;
2133 SMESH_VisualObjDef::TEntityList elems;
2134 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2135 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2136 std::vector<int> elemIds;
2138 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2139 elemIds.push_back( (*e)->GetID());
2141 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2142 double * range = lookupTable->GetRange();
2143 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2145 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2146 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2148 if(funValues.size() >= 2)
2149 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2153 //Color of the histogram
2154 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2155 my2dHistogram->setAutoAssign(true);
2158 myScalarBarActor->GetDistributionColor(rgb);
2159 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2160 my2dHistogram->setColor(aColor);
2164 return my2dHistogram;