1 // Copyright (C) 2007-2011 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_DataSetMapper.h"
37 #include "VTKViewer_ExtractUnstructuredGrid.h"
38 #include "VTKViewer_FramedTextActor.h"
39 #include "SALOME_InteractiveObject.hxx"
41 #include "SUIT_Session.h"
42 #include "SUIT_ResourceMgr.h"
44 #ifndef DISABLE_PLOT2DVIEWER
45 #include <SPlot2d_Histogram.h>
48 #include <vtkProperty.h>
49 #include <vtkTimeStamp.h>
50 #include <vtkObjectFactory.h>
51 #include <vtkShrinkPolyData.h>
52 #include <vtkMergeFilter.h>
54 #include <vtkMatrix4x4.h>
55 #include <vtkUnstructuredGrid.h>
56 #include <vtkPointData.h>
57 #include <vtkCellData.h>
59 #include <vtkMapper.h>
60 #include <vtkRenderer.h>
63 #include <vtkIdList.h>
64 #include <vtkIntArray.h>
66 #include <vtkActor2D.h>
67 #include <vtkProperty2D.h>
68 #include <vtkPolyData.h>
69 #include <vtkMaskPoints.h>
70 #include <vtkTextProperty.h>
71 #include <vtkLabeledDataMapper.h>
72 #include <vtkSelectVisiblePoints.h>
74 #include <vtkLookupTable.h>
78 #include <vtkImplicitBoolean.h>
79 #include <vtkImplicitFunctionCollection.h>
81 #include <vtkConfigure.h>
82 #if !defined(VTK_XVERSION)
83 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
86 #include "utilities.h"
89 static int MYDEBUG = 1;
91 static int MYDEBUG = 1;
94 static int aLineWidthInc = 2;
97 SMESH_ActorDef* SMESH_ActorDef::New(){
98 return new SMESH_ActorDef();
102 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
103 const char* theEntry,
107 SMESH_ActorDef* anActor = NULL;
108 if(theVisualObj->IsValid() ) {
109 anActor = SMESH_ActorDef::New();
110 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
115 anActor->UpdateScalarBar();
121 SMESH_ActorDef::SMESH_ActorDef()
123 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
129 myIsShrinkable = false;
132 myIsFacesOriented = false;
134 myControlsPrecision = -1;
135 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
137 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
138 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
140 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
141 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
143 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
144 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
146 //Definition 2D and 3D devices of the actor
147 //-----------------------------------------
148 vtkFloatingPointType anRGB[3] = {1,1,1};
149 mySurfaceProp = vtkProperty::New();
150 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
151 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
153 myBackSurfaceProp = vtkProperty::New();
154 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
155 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
157 my2DActor = SMESH_DeviceActor::New();
158 my2DActor->SetUserMatrix(aMatrix);
159 my2DActor->PickableOff();
160 my2DActor->SetProperty(mySurfaceProp);
161 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
162 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
163 aFilter = my2DActor->GetExtractUnstructuredGrid();
164 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
165 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
166 aFilter->RegisterCellsWithType(VTK_POLYGON);
167 aFilter->RegisterCellsWithType(VTK_QUAD);
168 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
169 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
171 my2DExtProp = vtkProperty::New();
172 my2DExtProp->DeepCopy(mySurfaceProp);
173 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
174 anRGB[0] = 1 - anRGB[0];
175 anRGB[1] = 1 - anRGB[1];
176 anRGB[2] = 1 - anRGB[2];
177 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
179 my2DExtActor = SMESH_DeviceActor::New();
180 my2DExtActor->SetUserMatrix(aMatrix);
181 my2DExtActor->PickableOff();
182 my2DExtActor->SetProperty(my2DExtProp);
183 my2DExtActor->SetBackfaceProperty(my2DExtProp);
184 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
185 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
186 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
187 aFilter->RegisterCellsWithType(VTK_POLYGON);
188 aFilter->RegisterCellsWithType(VTK_QUAD);
189 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
190 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
192 my3DActor = SMESH_DeviceActor::New();
193 my3DActor->SetUserMatrix(aMatrix);
194 my3DActor->PickableOff();
195 my3DActor->SetProperty(mySurfaceProp);
196 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
197 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
198 aFilter = my3DActor->GetExtractUnstructuredGrid();
199 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
200 aFilter->RegisterCellsWithType(VTK_TETRA);
201 aFilter->RegisterCellsWithType(VTK_VOXEL);
202 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
203 aFilter->RegisterCellsWithType(VTK_WEDGE);
204 aFilter->RegisterCellsWithType(VTK_PYRAMID);
205 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
206 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
207 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
208 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
209 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
210 //#ifdef VTK_HAVE_POLYHEDRON
211 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
212 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
215 my3DExtActor = SMESH_DeviceActor::New();
216 my3DExtActor->SetUserMatrix(aMatrix);
217 my3DExtActor->PickableOff();
218 my3DExtActor->SetProperty(my2DExtProp);
219 my3DExtActor->SetBackfaceProperty(my2DExtProp);
220 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
221 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
222 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
223 aFilter->RegisterCellsWithType(VTK_TETRA);
224 aFilter->RegisterCellsWithType(VTK_VOXEL);
225 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
226 aFilter->RegisterCellsWithType(VTK_WEDGE);
227 aFilter->RegisterCellsWithType(VTK_PYRAMID);
228 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
229 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
231 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
232 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
233 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
235 //Definition 1D device of the actor
236 //---------------------------------
237 myEdgeProp = vtkProperty::New();
238 myEdgeProp->SetAmbient(1.0);
239 myEdgeProp->SetDiffuse(0.0);
240 myEdgeProp->SetSpecular(0.0);
241 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
242 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
243 myEdgeProp->SetLineWidth(aLineWidth);
245 my1DActor = SMESH_DeviceActor::New();
246 my1DActor->SetUserMatrix(aMatrix);
247 my1DActor->PickableOff();
248 my1DActor->SetHighlited(true);
249 my1DActor->SetProperty(myEdgeProp);
250 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
251 aFilter = my1DActor->GetExtractUnstructuredGrid();
252 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
253 aFilter->RegisterCellsWithType(VTK_LINE);
254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
256 my1DProp = vtkProperty::New();
257 my1DProp->DeepCopy(myEdgeProp);
258 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
259 my1DProp->SetPointSize(aElem0DSize);
261 my1DExtProp = vtkProperty::New();
262 my1DExtProp->DeepCopy(myEdgeProp);
263 anRGB[0] = 1 - anRGB[0];
264 anRGB[1] = 1 - anRGB[1];
265 anRGB[2] = 1 - anRGB[2];
266 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
267 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
268 my1DExtProp->SetPointSize(aElem0DSize);
270 my1DExtActor = SMESH_DeviceActor::New();
271 my1DExtActor->SetUserMatrix(aMatrix);
272 my1DExtActor->PickableOff();
273 my1DExtActor->SetHighlited(true);
274 my1DExtActor->SetVisibility(false);
275 my1DExtActor->SetProperty(my1DExtProp);
276 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
277 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
278 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
279 aFilter->RegisterCellsWithType(VTK_LINE);
280 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
283 //Definition 0D device of the actor (0d elements)
284 //-----------------------------------------------
285 my0DProp = vtkProperty::New();
286 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
287 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
288 my0DProp->SetPointSize(aElem0DSize);
290 my0DActor = SMESH_DeviceActor::New();
291 my0DActor->SetUserMatrix(aMatrix);
292 my0DActor->SetStoreClippingMapping(true);
293 my0DActor->PickableOff();
294 my0DActor->SetVisibility(false);
295 my0DActor->SetProperty(my0DProp);
296 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
297 aFilter = my0DActor->GetExtractUnstructuredGrid();
298 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
299 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
300 aFilter->RegisterCellsWithType(VTK_VERTEX);
302 //my0DExtProp = vtkProperty::New();
303 //my0DExtProp->DeepCopy(my0DProp);
304 //anRGB[0] = 1 - anRGB[0];
305 //anRGB[1] = 1 - anRGB[1];
306 //anRGB[2] = 1 - anRGB[2];
307 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
308 //my0DExtProp->SetPointSize(aElem0DSize);
310 //my0DExtActor = SMESH_DeviceActor::New();
311 //my0DExtActor->SetUserMatrix(aMatrix);
312 //my0DExtActor->SetStoreClippingMapping(true);
313 //my0DExtActor->PickableOff();
314 //my0DExtActor->SetHighlited(true);
315 //my0DExtActor->SetVisibility(false);
316 //my0DExtActor->SetProperty(my0DExtProp);
317 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
318 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
319 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
320 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
321 //aFilter->RegisterCellsWithType(VTK_VERTEX);
324 //Definition 0D device of the actor (nodes)
325 //-----------------------------------------
326 myNodeProp = vtkProperty::New();
327 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
328 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
330 myNodeActor = SMESH_DeviceActor::New();
331 myNodeActor->SetUserMatrix(aMatrix);
332 myNodeActor->SetStoreClippingMapping(true);
333 myNodeActor->PickableOff();
334 myNodeActor->SetVisibility(false);
335 myNodeActor->SetProperty(myNodeProp);
336 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
337 aFilter = myNodeActor->GetExtractUnstructuredGrid();
338 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
340 myNodeExtProp = vtkProperty::New();
341 myNodeExtProp->DeepCopy(myNodeProp);
342 anRGB[0] = 1 - anRGB[0];
343 anRGB[1] = 1 - anRGB[1];
344 anRGB[2] = 1 - anRGB[2];
345 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
347 myNodeExtActor = SMESH_DeviceActor::New();
348 myNodeExtActor->SetUserMatrix(aMatrix);
349 myNodeExtActor->SetStoreClippingMapping(true);
350 myNodeExtActor->PickableOff();
351 myNodeExtActor->SetHighlited(true);
352 myNodeExtActor->SetVisibility(false);
353 myNodeExtActor->SetProperty(myNodeExtProp);
354 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
355 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
356 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
357 aFilter->RegisterCellsWithType(VTK_VERTEX);
359 //Definition of Pickable and Highlitable engines
360 //----------------------------------------------
362 myBaseActor = SMESH_DeviceActor::New();
363 myBaseActor->SetUserMatrix(aMatrix);
364 myBaseActor->SetStoreGemetryMapping(true);
365 myBaseActor->GetProperty()->SetOpacity(0.0);
367 myPickableActor = myBaseActor;
369 myMapper = VTKViewer_DataSetMapper::New();
370 myMapper->SetInput( myPickableActor->GetUnstructuredGrid() );
372 myHighlightProp = vtkProperty::New();
373 myHighlightProp->SetAmbient(1.0);
374 myHighlightProp->SetDiffuse(0.0);
375 myHighlightProp->SetSpecular(0.0);
376 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
377 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
378 myHighlightProp->SetPointSize(aElem0DSize); // ??
379 myHighlightProp->SetRepresentation(1);
381 myPreselectProp = vtkProperty::New();
382 myPreselectProp->SetAmbient(1.0);
383 myPreselectProp->SetDiffuse(0.0);
384 myPreselectProp->SetSpecular(0.0);
385 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
386 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
387 myPreselectProp->SetPointSize(aElem0DSize); // ??
388 myPreselectProp->SetRepresentation(1);
390 myHighlitableActor = SMESH_DeviceActor::New();
391 myHighlitableActor->SetUserMatrix(aMatrix);
392 myHighlitableActor->PickableOff();
393 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
400 myControlMode = eNone;
401 myControlActor = my2DActor;
403 //Definition of myScalarBarActor
404 //------------------------------
405 myLookupTable = vtkLookupTable::New();
406 //Fix for Bug PAL5195 - SMESH764:
407 //Controls - Aspect Ratio: incorrect colors of the best and worst values
408 myLookupTable->SetHueRange(0.667,0.0);
410 myScalarBarActor = SMESH_ScalarBarActor::New();
411 myScalarBarActor->SetVisibility(false);
412 myScalarBarActor->SetLookupTable(myLookupTable);
415 //Incorrect "Min value" in Scalar Bar in Mesh:
416 // myScalarBarActor->SetLabelFormat("%.4g");
417 // changes was commented because of regression bug IPAL 19981
419 mgr = SUIT_Session::session()->resourceMgr();
423 //Definition of points numbering pipeline
424 //---------------------------------------
425 myPointsNumDataSet = vtkUnstructuredGrid::New();
427 myPtsMaskPoints = vtkMaskPoints::New();
428 myPtsMaskPoints->SetInput(myPointsNumDataSet);
429 myPtsMaskPoints->SetOnRatio(1);
431 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
432 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
433 myPtsSelectVisiblePoints->SelectInvisibleOff();
434 myPtsSelectVisiblePoints->SetTolerance(0.1);
436 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
437 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
438 #if (VTK_XVERSION < 0x050200)
439 myPtsLabeledDataMapper->SetLabelFormat("%g");
441 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
443 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
444 aPtsTextProp->SetFontFamilyToTimes();
445 static int aPointsFontSize = 10;
446 aPtsTextProp->SetFontSize(aPointsFontSize);
447 aPtsTextProp->SetBold(1);
448 aPtsTextProp->SetItalic(0);
449 aPtsTextProp->SetShadow(0);
450 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
451 aPtsTextProp->Delete();
453 myEntityMode = eAllEntity;
455 myIsPointsLabeled = false;
457 myPointLabels = vtkActor2D::New();
458 myPointLabels->SetMapper(myPtsLabeledDataMapper);
459 myPointLabels->GetProperty()->SetColor(1,1,1);
460 myPointLabels->SetVisibility(myIsPointsLabeled);
463 //Definition of cells numbering pipeline
464 //---------------------------------------
465 myCellsNumDataSet = vtkUnstructuredGrid::New();
467 myCellCenters = VTKViewer_CellCenters::New();
468 myCellCenters->SetInput(myCellsNumDataSet);
470 myClsMaskPoints = vtkMaskPoints::New();
471 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
472 myClsMaskPoints->SetOnRatio(1);
474 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
475 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
476 myClsSelectVisiblePoints->SelectInvisibleOff();
477 myClsSelectVisiblePoints->SetTolerance(0.1);
479 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
480 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
481 #if (VTK_XVERSION < 0x050200)
482 myClsLabeledDataMapper->SetLabelFormat("%g");
484 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
486 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
487 aClsTextProp->SetFontFamilyToTimes();
488 static int aCellsFontSize = 12;
489 aClsTextProp->SetFontSize(aCellsFontSize);
490 aClsTextProp->SetBold(1);
491 aClsTextProp->SetItalic(0);
492 aClsTextProp->SetShadow(0);
493 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
494 aClsTextProp->Delete();
496 myIsCellsLabeled = false;
498 myCellsLabels = vtkActor2D::New();
499 myCellsLabels->SetMapper(myClsLabeledDataMapper);
500 myCellsLabels->GetProperty()->SetColor(0,1,0);
501 myCellsLabels->SetVisibility(myIsCellsLabeled);
504 myImplicitBoolean = vtkImplicitBoolean::New();
505 myImplicitBoolean->SetOperationTypeToIntersection();
509 //Quadratic 2D elements representation
510 //-----------------------------------------------------------------------------
511 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
512 if(aQuadratic2DMode == 0){
513 myHighlitableActor->SetQuadraticArcMode(false);
514 my2DActor->SetQuadraticArcMode(false);
515 my1DActor->SetQuadraticArcMode(false);
517 else if(aQuadratic2DMode == 1){
518 myHighlitableActor->SetQuadraticArcMode(true);
519 my2DActor->SetQuadraticArcMode(true);
520 my1DActor->SetQuadraticArcMode(true);
523 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
524 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
525 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
527 // Set colors of the name actor
528 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
529 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
530 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
531 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
533 #ifndef DISABLE_PLOT2DVIEWER
540 SMESH_ActorDef::~SMESH_ActorDef()
542 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
544 #ifndef DISABLE_PLOT2DVIEWER
546 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
547 delete my2dHistogram;
551 // caught by SMESHGUI::ProcessEvents() static method
552 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
554 myScalarBarActor->Delete();
555 myLookupTable->Delete();
557 mySurfaceProp->Delete();
558 myBackSurfaceProp->Delete();
560 myEdgeProp->Delete();
561 myHighlightProp->Delete();
562 myPreselectProp->Delete();
564 myNodeProp->Delete();
565 myNodeExtProp->Delete();
570 //my0DExtProp->Delete();
571 //my0DExtActor->Delete();
576 my1DExtProp->Delete();
577 my1DExtActor->Delete();
580 my2DExtProp->Delete();
581 my2DExtActor->Delete();
583 my3DExtActor->Delete();
585 myNodeActor->Delete();
586 myBaseActor->Delete();
588 myNodeExtActor->Delete();
590 myHighlitableActor->Delete();
592 //Deleting of points numbering pipeline
593 //---------------------------------------
594 myPointsNumDataSet->Delete();
596 // commented: porting to vtk 5.0
597 // myPtsLabeledDataMapper->RemoveAllInputs();
598 myPtsLabeledDataMapper->Delete();
600 // commented: porting to vtk 5.0
601 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
602 myPtsSelectVisiblePoints->Delete();
604 // commented: porting to vtk 5.0
605 // myPtsMaskPoints->UnRegisterAllOutputs();
606 myPtsMaskPoints->Delete();
608 myPointLabels->Delete();
611 //Deleting of cells numbering pipeline
612 //---------------------------------------
613 myCellsNumDataSet->Delete();
615 myClsLabeledDataMapper->RemoveAllInputs();
616 myClsLabeledDataMapper->Delete();
618 // commented: porting to vtk 5.0
619 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
620 myClsSelectVisiblePoints->Delete();
622 // commented: porting to vtk 5.0
623 // myClsMaskPoints->UnRegisterAllOutputs();
624 myClsMaskPoints->Delete();
626 // commented: porting to vtk 5.0
627 // myCellCenters->UnRegisterAllOutputs();
628 myCellCenters->Delete();
630 myCellsLabels->Delete();
632 myImplicitBoolean->Delete();
636 myTimeStamp->Delete();
640 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
642 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
644 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
646 if ( myIsPointsLabeled )
648 myPointsNumDataSet->ShallowCopy(aGrid);
649 vtkDataSet *aDataSet = myPointsNumDataSet;
651 int aNbElem = aDataSet->GetNumberOfPoints();
653 vtkIntArray *anArray = vtkIntArray::New();
654 anArray->SetNumberOfValues( aNbElem );
656 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
658 int aSMDSId = myVisualObj->GetNodeObjId( anId );
659 anArray->SetValue( anId, aSMDSId );
662 aDataSet->GetPointData()->SetScalars( anArray );
664 myPtsMaskPoints->SetInput( aDataSet );
665 myPointLabels->SetVisibility( GetVisibility() );
669 myPointLabels->SetVisibility( false );
671 SetRepresentation(GetRepresentation());
672 myTimeStamp->Modified();
676 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
678 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
679 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
680 if(myIsCellsLabeled){
681 myCellsNumDataSet->ShallowCopy(aGrid);
682 vtkDataSet *aDataSet = myCellsNumDataSet;
683 int aNbElem = aDataSet->GetNumberOfCells();
684 vtkIntArray *anArray = vtkIntArray::New();
685 anArray->SetNumberOfValues(aNbElem);
686 for(int anId = 0; anId < aNbElem; anId++){
687 int aSMDSId = myVisualObj->GetElemObjId(anId);
688 anArray->SetValue(anId,aSMDSId);
690 aDataSet->GetCellData()->SetScalars(anArray);
691 myCellCenters->SetInput(aDataSet);
692 myCellsLabels->SetVisibility(GetVisibility());
694 myCellsLabels->SetVisibility(false);
696 myTimeStamp->Modified();
700 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
702 myIsFacesOriented = theIsFacesOriented;
704 my2DActor->SetFacesOriented(theIsFacesOriented);
705 my3DActor->SetFacesOriented(theIsFacesOriented);
707 myTimeStamp->Modified();
710 bool SMESH_ActorDef::GetFacesOriented()
712 return myIsFacesOriented;
715 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
717 my2DActor->SetFacesOrientationColor( theColor );
718 my3DActor->SetFacesOrientationColor( theColor );
721 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
723 my3DActor->GetFacesOrientationColor( theColor );
726 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
728 my2DActor->SetFacesOrientationScale( theScale );
729 my3DActor->SetFacesOrientationScale( theScale );
732 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
734 return my3DActor->GetFacesOrientationScale();
737 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
739 my2DActor->SetFacesOrientation3DVectors( theState );
740 my3DActor->SetFacesOrientation3DVectors( theState );
743 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
745 return my3DActor->GetFacesOrientation3DVectors();
751 SetControlMode(eControl theMode)
753 SetControlMode(theMode,true);
759 SetControlMode(eControl theMode,
760 bool theCheckEntityMode)
762 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
766 myControlMode = eNone;
767 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
769 my0DActor->GetMapper()->SetScalarVisibility(false);
770 my1DActor->GetMapper()->SetScalarVisibility(false);
771 my2DActor->GetMapper()->SetScalarVisibility(false);
772 my3DActor->GetMapper()->SetScalarVisibility(false);
773 myScalarBarActor->SetVisibility(false);
775 bool anIsScalarVisible = theMode > eNone;
777 if(anIsScalarVisible) {
781 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
782 aControl->SetPrecision( myControlsPrecision );
783 myFunctor.reset( aControl );
784 myControlActor = my1DActor;
789 myFunctor.reset(new SMESH::Controls::Length2D());
790 myControlActor = my2DActor;
794 myFunctor.reset(new SMESH::Controls::FreeBorders());
795 myControlActor = my1DActor;
798 myFunctor.reset(new SMESH::Controls::FreeEdges());
799 myControlActor = my2DActor;
802 myFunctor.reset(new SMESH::Controls::FreeNodes());
803 myControlActor = myNodeActor;
806 myFunctor.reset(new SMESH::Controls::FreeFaces());
807 myControlActor = my2DActor;
809 case eBareBorderFace:
810 myFunctor.reset(new SMESH::Controls::BareBorderFace());
811 myControlActor = my2DActor;
813 case eOverConstrainedFace:
814 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
815 myControlActor = my2DActor;
817 case eMultiConnection:
818 myFunctor.reset(new SMESH::Controls::MultiConnection());
819 myControlActor = my1DActor;
821 case eMultiConnection2D:
822 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
823 myControlActor = my2DActor;
827 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
828 aControl->SetPrecision( myControlsPrecision );
829 myFunctor.reset( aControl );
830 myControlActor = my2DActor;
835 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
836 aControl->SetPrecision( myControlsPrecision );
837 myFunctor.reset( aControl );
838 myControlActor = my2DActor;
843 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
844 aControl->SetPrecision( myControlsPrecision );
845 myFunctor.reset( aControl );
846 myControlActor = my2DActor;
851 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
852 aControl->SetPrecision( myControlsPrecision );
853 myFunctor.reset( aControl );
854 myControlActor = my3DActor;
859 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
860 aControl->SetPrecision( myControlsPrecision );
861 myFunctor.reset( aControl );
862 myControlActor = my3DActor;
865 case eMaxElementLength2D:
867 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
868 aControl->SetPrecision( myControlsPrecision );
869 myFunctor.reset( aControl );
870 myControlActor = my2DActor;
873 case eMaxElementLength3D:
875 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
876 aControl->SetPrecision( myControlsPrecision );
877 myFunctor.reset( aControl );
878 myControlActor = my3DActor;
881 case eBareBorderVolume:
883 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
884 myControlActor = my3DActor;
887 case eOverConstrainedVolume:
889 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
890 myControlActor = my3DActor;
895 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
896 aControl->SetPrecision( myControlsPrecision );
897 myFunctor.reset( aControl );
898 myControlActor = my2DActor;
903 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
904 aControl->SetPrecision( myControlsPrecision );
905 myFunctor.reset( aControl );
906 myControlActor = my2DActor;
911 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
912 aControl->SetPrecision( myControlsPrecision );
913 myFunctor.reset( aControl );
914 myControlActor = my2DActor;
921 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
922 vtkIdType aNbCells = aGrid->GetNumberOfCells();
924 myControlMode = theMode;
925 switch(myControlMode){
927 myNodeExtActor->SetExtControlMode(myFunctor);
931 my1DExtActor->SetExtControlMode(myFunctor);
934 case eBareBorderFace:
935 case eOverConstrainedFace:
936 my2DExtActor->SetExtControlMode(myFunctor);
938 case eBareBorderVolume:
939 case eOverConstrainedVolume:
940 my3DExtActor->SetExtControlMode(myFunctor);
943 case eMultiConnection2D:
944 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
945 UpdateDistribution();
948 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
949 UpdateDistribution();
953 if(theCheckEntityMode){
954 if(myControlActor == my1DActor)
955 SetEntityMode(eEdges);
956 else if(myControlActor == my2DActor){
957 switch(myControlMode){
961 case eMultiConnection2D:
962 //SetEntityMode(eEdges);
963 SetEntityMode(eFaces);
966 SetEntityMode(eFaces);
968 }else if(myControlActor == my3DActor)
969 SetEntityMode(eVolumes);
974 if(theCheckEntityMode)
975 myEntityMode = eAllEntity;
979 SetRepresentation(GetRepresentation());
981 myTimeStamp->Modified();
986 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
987 theRenderer->AddActor(myNodeActor);
988 theRenderer->AddActor(myBaseActor);
990 theRenderer->AddActor(myNodeExtActor);
992 my3DActor->AddToRender(theRenderer);
993 my3DExtActor->AddToRender(theRenderer);
994 my2DActor->AddToRender(theRenderer);
995 my2DExtActor->AddToRender(theRenderer);
997 theRenderer->AddActor(my1DActor);
998 theRenderer->AddActor(my1DExtActor);
1000 theRenderer->AddActor(my0DActor);
1001 //theRenderer->AddActor(my0DExtActor);
1003 theRenderer->AddActor(myHighlitableActor);
1005 theRenderer->AddActor2D(myScalarBarActor);
1007 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
1008 myClsSelectVisiblePoints->SetRenderer(theRenderer);
1010 theRenderer->AddActor2D(myPointLabels);
1011 theRenderer->AddActor2D(myCellsLabels);
1013 // the superclass' method should be called at the end
1014 // (in particular, for correct work of selection)
1015 SALOME_Actor::AddToRender(theRenderer);
1018 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1019 SALOME_Actor::RemoveFromRender(theRenderer);
1021 theRenderer->RemoveActor(myNodeActor);
1022 theRenderer->RemoveActor(myBaseActor);
1024 theRenderer->RemoveActor(myNodeExtActor);
1026 theRenderer->RemoveActor(myHighlitableActor);
1028 theRenderer->RemoveActor(my0DActor);
1029 //theRenderer->RemoveActor(my0DExtActor);
1031 theRenderer->RemoveActor(my1DActor);
1032 theRenderer->RemoveActor(my1DExtActor);
1034 my2DActor->RemoveFromRender(theRenderer);
1035 my2DExtActor->RemoveFromRender(theRenderer);
1036 my3DActor->RemoveFromRender(theRenderer);
1037 my3DExtActor->RemoveFromRender(theRenderer);
1039 theRenderer->RemoveActor(myScalarBarActor);
1040 theRenderer->RemoveActor(myPointLabels);
1041 theRenderer->RemoveActor(myCellsLabels);
1045 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1046 const char* theEntry,
1047 const char* theName,
1050 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1054 myVisualObj = theVisualObj;
1055 myVisualObj->Update(theIsClear);
1057 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1058 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1060 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1062 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1064 my0DActor->Init(myVisualObj,myImplicitBoolean);
1065 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1067 my1DActor->Init(myVisualObj,myImplicitBoolean);
1068 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1070 my2DActor->Init(myVisualObj,myImplicitBoolean);
1071 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1072 my3DActor->Init(myVisualObj,myImplicitBoolean);
1073 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1075 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1076 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1078 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1079 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1081 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1082 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1083 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1084 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1086 vtkFloatingPointType aFactor, aUnits;
1087 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1088 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1089 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1091 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1095 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1096 SetIsShrunkable(true);
1098 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1100 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1101 SetRepresentation(-1);
1104 SetRepresentation(eEdge);
1105 }else if(aMode == 1){
1106 SetRepresentation(eSurface);
1107 }else if(aMode == 2){
1108 SetRepresentation(ePoint);
1115 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1116 SetIsDisplayNameActor( true );
1118 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1119 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1120 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1122 myTimeStamp->Modified();
1128 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1129 return myNodeActor->GetBounds();
1133 vtkDataSet* SMESH_ActorDef::GetInput(){
1134 return GetUnstructuredGrid();
1138 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1139 Superclass::SetTransform(theTransform);
1141 myNodeActor->SetTransform(theTransform);
1142 myBaseActor->SetTransform(theTransform);
1144 myHighlitableActor->SetTransform(theTransform);
1146 myNodeExtActor->SetTransform(theTransform);
1148 my0DActor->SetTransform(theTransform);
1149 //my0DExtActor->SetTransform(theTransform);
1151 my1DActor->SetTransform(theTransform);
1152 my1DExtActor->SetTransform(theTransform);
1154 my2DActor->SetTransform(theTransform);
1155 my2DExtActor->SetTransform(theTransform);
1156 my3DActor->SetTransform(theTransform);
1157 my3DExtActor->SetTransform(theTransform);
1163 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1164 vtkLODActor::SetMapper(theMapper);
1168 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1169 SALOME_Actor::ShallowCopy(prop);
1173 vtkMapper* SMESH_ActorDef::GetMapper(){
1178 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1179 return myVisualObj->GetUnstructuredGrid();
1183 bool SMESH_ActorDef::IsInfinitive(){
1184 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1186 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1187 ( aDataSet->GetNumberOfCells() == 1 &&
1188 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1189 return SALOME_Actor::IsInfinitive();
1193 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1194 if ( myIsShrinkable == theShrunkable )
1196 myIsShrinkable = theShrunkable;
1200 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1201 return myBaseActor->GetShrinkFactor();
1204 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1205 myBaseActor->SetShrinkFactor(theValue);
1207 my1DActor->SetShrinkFactor(theValue);
1208 my1DExtActor->SetShrinkFactor(theValue);
1210 my2DActor->SetShrinkFactor(theValue);
1211 my2DExtActor->SetShrinkFactor(theValue);
1212 my3DActor->SetShrinkFactor(theValue);
1213 my3DExtActor->SetShrinkFactor(theValue);
1218 void SMESH_ActorDef::SetShrink(){
1219 if(!myIsShrinkable) return;
1221 myBaseActor->SetShrink();
1223 my1DActor->SetShrink();
1224 my1DExtActor->SetShrink();
1226 my2DActor->SetShrink();
1227 my2DExtActor->SetShrink();
1228 my3DActor->SetShrink();
1229 my3DExtActor->SetShrink();
1235 void SMESH_ActorDef::UnShrink(){
1236 if(!myIsShrunk) return;
1238 myBaseActor->UnShrink();
1240 my1DActor->UnShrink();
1241 my1DExtActor->UnShrink();
1243 my2DActor->UnShrink();
1244 my2DExtActor->UnShrink();
1245 my3DActor->UnShrink();
1246 my3DExtActor->UnShrink();
1253 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1254 return myPickableActor->GetNodeObjId(theVtkID);
1257 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1258 return myPickableActor->GetNodeCoord(theObjID);
1262 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1263 return myPickableActor->GetElemObjId(theVtkID);
1266 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1267 return myPickableActor->GetElemCell(theObjID);
1271 void SMESH_ActorDef::SetVisibility(int theMode){
1272 SetVisibility(theMode,true);
1276 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1277 SALOME_Actor::SetVisibility(theMode);
1279 myNodeActor->VisibilityOff();
1280 myBaseActor->VisibilityOff();
1282 myNodeExtActor->VisibilityOff();
1284 my0DActor->VisibilityOff();
1285 //my0DExtActor->VisibilityOff();
1287 my1DActor->VisibilityOff();
1288 my1DExtActor->VisibilityOff();
1290 my2DActor->VisibilityOff();
1291 my2DExtActor->VisibilityOff();
1292 my3DActor->VisibilityOff();
1293 my3DExtActor->VisibilityOff();
1295 myScalarBarActor->VisibilityOff();
1296 myPointLabels->VisibilityOff();
1297 myCellsLabels->VisibilityOff();
1299 if(GetVisibility()){
1300 if(theIsUpdateRepersentation)
1301 SetRepresentation(GetRepresentation());
1303 if(myControlMode != eNone){
1304 switch(myControlMode){
1306 myNodeExtActor->VisibilityOn();
1310 my1DExtActor->VisibilityOn();
1313 case eBareBorderFace:
1314 case eOverConstrainedFace:
1315 my2DExtActor->VisibilityOn();
1317 case eBareBorderVolume:
1318 case eOverConstrainedVolume:
1319 my3DExtActor->VisibilityOn();
1322 case eMultiConnection2D:
1323 my1DExtActor->VisibilityOn();
1325 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1326 myScalarBarActor->VisibilityOn();
1330 if(myRepresentation != ePoint)
1331 myPickableActor->VisibilityOn();
1333 myNodeActor->VisibilityOn();
1336 if(myEntityMode & e0DElements){
1337 my0DActor->VisibilityOn();
1340 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1341 my1DActor->VisibilityOn();
1344 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1345 my2DActor->VisibilityOn();
1348 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1349 my3DActor->VisibilityOn();
1352 if(myIsPointsLabeled){
1353 myPointLabels->VisibilityOn();
1354 myNodeActor->VisibilityOn();
1357 if(myIsCellsLabeled)
1358 myCellsLabels->VisibilityOn();
1360 #ifndef DISABLE_PLOT2DVIEWER
1362 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1369 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1371 myEntityState = eAllEntity;
1373 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1374 myEntityState &= ~e0DElements;
1375 theMode &= ~e0DElements;
1378 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1379 myEntityState &= ~eEdges;
1383 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1384 myEntityState &= ~eFaces;
1388 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1389 myEntityState &= ~eVolumes;
1390 theMode &= ~eVolumes;
1394 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1395 theMode |= e0DElements;
1397 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1400 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1403 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1404 theMode |= eVolumes;
1407 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1409 myEntityMode = theMode;
1410 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1411 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1412 aFilter->ClearRegisteredCellsWithType();
1413 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1415 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1416 aHightFilter->ClearRegisteredCellsWithType();
1417 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1419 if (myEntityMode & e0DElements) {
1420 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1421 aFilter->RegisterCellsWithType(VTK_VERTEX);
1422 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1425 if (myEntityMode & eEdges) {
1426 if (MYDEBUG) MESSAGE("EDGES");
1427 aFilter->RegisterCellsWithType(VTK_LINE);
1428 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1430 aHightFilter->RegisterCellsWithType(VTK_LINE);
1431 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1434 if (myEntityMode & eFaces) {
1435 if (MYDEBUG) MESSAGE("FACES");
1436 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1437 aFilter->RegisterCellsWithType(VTK_POLYGON);
1438 aFilter->RegisterCellsWithType(VTK_QUAD);
1439 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1440 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1442 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1443 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1444 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1445 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1446 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1449 if (myEntityMode & eVolumes) {
1450 if (MYDEBUG) MESSAGE("VOLUMES");
1451 aFilter->RegisterCellsWithType(VTK_TETRA);
1452 aFilter->RegisterCellsWithType(VTK_VOXEL);
1453 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1454 aFilter->RegisterCellsWithType(VTK_WEDGE);
1455 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1456 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1457 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1458 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1459 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1460 //#ifdef VTK_HAVE_POLYHEDRON
1461 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1464 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1465 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1466 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1467 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1468 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1469 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1470 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1471 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1472 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1473 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1474 //#ifdef VTK_HAVE_POLYHEDRON
1475 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1479 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1480 SetVisibility(GetVisibility(),false);
1483 void SMESH_ActorDef::SetRepresentation (int theMode)
1485 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1486 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1487 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1490 myRepresentation = eSurface;
1491 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1492 myRepresentation = eEdge;
1493 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1494 myRepresentation = ePoint;
1499 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1502 if (!aNbFaces && !aNbVolumes) return;
1505 myRepresentation = theMode;
1508 if (!GetUnstructuredGrid()->GetNumberOfCells())
1509 myRepresentation = ePoint;
1512 if (myRepresentation == ePoint) {
1520 myPickableActor = myBaseActor;
1521 myNodeActor->SetVisibility(false);
1522 myNodeExtActor->SetVisibility(false);
1523 vtkProperty *aProp = NULL, *aBackProp = NULL;
1524 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1525 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1526 switch (myRepresentation) {
1528 myPickableActor = myNodeActor;
1529 myNodeActor->SetVisibility(true);
1530 aQuadraticMode = SMESH_Actor::eLines;
1531 aProp = aBackProp = myNodeProp;
1532 aReperesent = SMESH_DeviceActor::ePoint;
1535 aProp = aBackProp = myEdgeProp;
1536 aReperesent = SMESH_DeviceActor::eInsideframe;
1539 aProp = mySurfaceProp;
1540 aBackProp = myBackSurfaceProp;
1541 aReperesent = SMESH_DeviceActor::eSurface;
1545 my2DActor->SetProperty(aProp);
1546 my2DActor->SetBackfaceProperty(aBackProp);
1547 my2DActor->SetRepresentation(aReperesent);
1549 if(aQuadraticMode == SMESH_Actor::eLines)
1550 my2DActor->SetQuadraticArcMode(false);
1551 else if(aQuadraticMode == SMESH_Actor::eArcs)
1552 my2DActor->SetQuadraticArcMode(true);
1554 my2DExtActor->SetRepresentation(aReperesent);
1556 my3DActor->SetProperty(aProp);
1557 my3DActor->SetBackfaceProperty(aBackProp);
1558 my3DActor->SetRepresentation(aReperesent);
1560 //my0DExtActor->SetVisibility(false);
1561 my1DExtActor->SetVisibility(false);
1562 my2DExtActor->SetVisibility(false);
1563 my3DExtActor->SetVisibility(false);
1566 //my0DActor->SetProperty(aProp);
1567 //my0DActor->SetBackfaceProperty(aBackProp);
1568 my0DActor->SetRepresentation(aReperesent);
1569 //my0DExtActor->SetRepresentation(aReperesent);
1571 switch(myControlMode){
1573 case eMultiConnection:
1574 aProp = aBackProp = my1DProp;
1575 if(myRepresentation != ePoint)
1576 aReperesent = SMESH_DeviceActor::eInsideframe;
1580 if(aQuadraticMode == SMESH_Actor::eLines)
1581 my1DActor->SetQuadraticArcMode(false);
1582 else if(aQuadraticMode == SMESH_Actor::eArcs)
1583 my1DActor->SetQuadraticArcMode(true);
1585 my1DActor->SetProperty(aProp);
1586 my1DActor->SetBackfaceProperty(aBackProp);
1587 my1DActor->SetRepresentation(aReperesent);
1589 my1DExtActor->SetRepresentation(aReperesent);
1591 if(myIsPointsVisible)
1592 myPickableActor = myNodeActor;
1593 if(GetPointRepresentation())
1594 myNodeActor->SetVisibility(true);
1596 SetMapper(myPickableActor->GetMapper());
1598 SetVisibility(GetVisibility(),false);
1604 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1605 if ( myIsPointsVisible == theIsPointsVisible )
1607 myIsPointsVisible = theIsPointsVisible;
1608 SetRepresentation(GetRepresentation());
1611 bool SMESH_ActorDef::GetPointRepresentation(){
1612 return myIsPointsVisible || myIsPointsLabeled;
1616 void SMESH_ActorDef::UpdateHighlight(){
1617 myHighlitableActor->SetVisibility(false);
1618 myHighlitableActor->SetHighlited(false);
1620 if(myIsHighlighted){
1621 myHighlitableActor->SetProperty(myHighlightProp);
1622 }else if(myIsPreselected){
1623 myHighlitableActor->SetProperty(myPreselectProp);
1626 bool anIsVisible = GetVisibility();
1628 if(myIsHighlighted || myIsPreselected){
1629 if(GetUnstructuredGrid()->GetNumberOfCells()){
1630 myHighlitableActor->SetHighlited(anIsVisible);
1631 myHighlitableActor->SetVisibility(anIsVisible);
1632 myHighlitableActor->GetExtractUnstructuredGrid()->
1633 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1634 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1635 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1636 myHighlitableActor->SetHighlited(anIsVisible);
1637 myHighlitableActor->GetExtractUnstructuredGrid()->
1638 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1639 myHighlitableActor->SetVisibility(anIsVisible);
1640 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1642 VTK::MarkerType aMarkerType = GetMarkerType();
1643 if(aMarkerType != VTK::MT_USER)
1644 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1646 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1652 void SMESH_ActorDef::highlight(bool theHighlight){
1653 if ( myIsHighlighted == theHighlight )
1655 myIsHighlighted = theHighlight;
1660 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1661 if ( myIsPreselected == thePreselect )
1663 myIsPreselected = thePreselect;
1669 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1671 if (myPickableActor->GetIsOpaque())
1673 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1681 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1683 if (!myPickableActor->GetIsOpaque())
1685 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1693 void SMESH_ActorDef::Render(vtkRenderer *ren){
1694 unsigned long aTime = myTimeStamp->GetMTime();
1695 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1696 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1697 if(anObjTime > aTime || aClippingTime > aTime)
1702 void SMESH_ActorDef::Update(){
1703 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1705 if(GetControlMode() != eNone) {
1706 unsigned long aTime = myTimeStamp->GetMTime();
1707 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1708 if (anObjTime > aTime)
1709 SetControlMode(GetControlMode(),false);
1711 if(myIsPointsLabeled){
1712 SetPointsLabeled(myIsPointsLabeled);
1714 if(myIsCellsLabeled){
1715 SetCellsLabeled(myIsCellsLabeled);
1717 if(myIsFacesOriented){
1718 SetFacesOriented(myIsFacesOriented);
1720 SetEntityMode(GetEntityMode());
1721 SetVisibility(GetVisibility());
1723 myTimeStamp->Modified();
1728 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1729 SALOME_Actor::ReleaseGraphicsResources(renWin);
1731 myPickableActor->ReleaseGraphicsResources(renWin);
1735 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1736 vtkFloatingPointType* aColor = theProperty->GetColor();
1743 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1744 mySurfaceProp->SetOpacity(theValue);
1745 myBackSurfaceProp->SetOpacity(theValue);
1746 myEdgeProp->SetOpacity(theValue);
1747 myNodeProp->SetOpacity(theValue);
1749 my1DProp->SetOpacity(theValue);
1753 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1754 return mySurfaceProp->GetOpacity();
1758 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1759 mySurfaceProp->SetColor(r,g,b);
1760 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1761 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1762 aGroupObj->GetElementType() == SMDSAbs_Volume )
1763 myNameActor->SetBackgroundColor(r,g,b);
1767 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1768 ::GetColor(mySurfaceProp,r,g,b);
1769 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1772 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1773 myBackSurfaceProp->SetColor(r,g,b);
1777 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1778 ::GetColor(myBackSurfaceProp,r,g,b);
1781 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1782 myEdgeProp->SetColor(r,g,b);
1783 my1DProp->SetColor(r,g,b);
1784 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1785 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1786 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1787 myNameActor->SetBackgroundColor(r,g,b);
1791 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1792 ::GetColor(myEdgeProp,r,g,b);
1795 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1796 myNodeProp->SetColor(r,g,b);
1797 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1798 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1799 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1800 myNameActor->SetBackgroundColor(r,g,b);
1804 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1805 ::GetColor(myNodeProp,r,g,b);
1808 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1809 my0DProp->SetColor(r,g,b);
1810 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1811 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1812 myNameActor->SetBackgroundColor(r,g,b);
1816 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1817 ::GetColor(my0DProp,r,g,b);
1820 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1821 myHighlightProp->SetColor(r,g,b);
1825 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1826 ::GetColor(myHighlightProp,r,g,b);
1829 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1830 myPreselectProp->SetColor(r,g,b);
1834 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1835 ::GetColor(myPreselectProp,r,g,b);
1839 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1840 return myEdgeProp->GetLineWidth();
1844 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1845 myEdgeProp->SetLineWidth(theVal);
1847 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1848 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1854 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1855 my0DProp->SetPointSize(theVal);
1859 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1860 return my0DProp->GetPointSize();
1863 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1865 return myVisualObj->GetElemDimension( theObjId );
1870 IsImplicitFunctionUsed() const
1872 return myBaseActor->IsImplicitFunctionUsed();
1876 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1878 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1879 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1881 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1883 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1885 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1886 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1888 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1889 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1891 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1892 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1893 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1894 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1898 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1901 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1902 myCippingPlaneCont.push_back(thePlane);
1903 if(!IsImplicitFunctionUsed())
1904 SetImplicitFunctionUsed(true);
1906 return myCippingPlaneCont.size();
1911 RemoveAllClippingPlanes()
1913 myImplicitBoolean->GetFunction()->RemoveAllItems();
1914 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1915 myCippingPlaneCont.clear();
1916 SetImplicitFunctionUsed(false);
1921 GetNumberOfClippingPlanes()
1923 return myCippingPlaneCont.size();
1928 GetClippingPlane(vtkIdType theID)
1930 if(theID >= myCippingPlaneCont.size())
1932 return myCippingPlaneCont[theID].Get();
1935 void SMESH_ActorDef::UpdateScalarBar()
1937 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1941 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1943 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1944 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1946 aScalarBarTitleProp->SetFontFamilyToArial();
1948 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1950 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1951 if ( f.family() == "Arial" )
1952 aScalarBarTitleProp->SetFontFamilyToArial();
1953 else if ( f.family() == "Courier" )
1954 aScalarBarTitleProp->SetFontFamilyToCourier();
1955 else if ( f.family() == "Times" )
1956 aScalarBarTitleProp->SetFontFamilyToTimes();
1959 aScalarBarTitleProp->BoldOn();
1961 aScalarBarTitleProp->BoldOff();
1964 aScalarBarTitleProp->ItalicOn();
1966 aScalarBarTitleProp->ItalicOff();
1969 aScalarBarTitleProp->ShadowOn();
1971 aScalarBarTitleProp->ShadowOff();
1974 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1975 aScalarBarTitleProp->Delete();
1977 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1979 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1980 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1982 aScalarBarLabelProp->SetFontFamilyToArial();
1983 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1985 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1986 if( f.family() == "Arial" )
1987 aScalarBarLabelProp->SetFontFamilyToArial();
1988 else if( f.family() == "Courier" )
1989 aScalarBarLabelProp->SetFontFamilyToCourier();
1990 else if( f.family() == "Times" )
1991 aScalarBarLabelProp->SetFontFamilyToTimes();
1994 aScalarBarLabelProp->BoldOn();
1996 aScalarBarLabelProp->BoldOff();
1999 aScalarBarLabelProp->ItalicOn();
2001 aScalarBarLabelProp->ItalicOff();
2004 aScalarBarLabelProp->ShadowOn();
2006 aScalarBarLabelProp->ShadowOff();
2009 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2010 aScalarBarLabelProp->Delete();
2012 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2013 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2015 myScalarBarActor->SetOrientationToHorizontal();
2017 myScalarBarActor->SetOrientationToVertical();
2020 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2021 if( mgr->hasValue( "SMESH", name + "x" ) )
2022 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2024 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2025 if( mgr->hasValue( "SMESH", name + "y" ) )
2026 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2027 myScalarBarActor->SetPosition( aXVal, aYVal );
2029 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2030 if( mgr->hasValue( "SMESH", name + "width" ) )
2031 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2032 myScalarBarActor->SetWidth( aWVal );
2034 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2035 if( mgr->hasValue( "SMESH", name + "height" ) )
2036 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2037 myScalarBarActor->SetHeight( aHVal );
2040 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2041 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2042 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2045 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2046 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2047 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2049 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2050 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2052 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2053 myScalarBarActor->SetDistributionColoringType(coloringType);
2055 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2056 QColor(255, 255, 255));
2058 rgb[0]= distributionColor.red()/255.;
2059 rgb[1]= distributionColor.green()/255.;
2060 rgb[2]= distributionColor.blue()/255.;
2061 myScalarBarActor->SetDistributionColor(rgb);
2066 void SMESH_ActorDef::UpdateDistribution()
2068 if(SMESH::Controls::NumericalFunctor* fun =
2069 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2071 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2072 std::vector<int> nbEvents;
2073 std::vector<double> funValues;
2074 SMESH_VisualObjDef::TEntityList elems;
2075 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2076 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2077 std::vector<int> elemIds;
2078 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2079 elemIds.push_back( (*e)->GetID());
2080 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2081 double * range = lookupTable->GetRange();
2082 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2083 myScalarBarActor->SetDistribution(nbEvents);
2087 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2090 case SMESH_Actor::eLines :
2091 myHighlitableActor->SetQuadraticArcMode(false);
2092 my2DActor->SetQuadraticArcMode(false);
2093 my1DActor->SetQuadraticArcMode(false);
2095 case SMESH_Actor::eArcs :
2096 myHighlitableActor->SetQuadraticArcMode(true);
2097 if(GetRepresentation() != SMESH_Actor::ePoint) {
2098 my2DActor->SetQuadraticArcMode(true);
2099 my1DActor->SetQuadraticArcMode(true);
2108 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2110 if(myHighlitableActor->GetQuadraticArcMode())
2111 return SMESH_Actor::eArcs;
2113 return SMESH_Actor::eLines;
2116 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2118 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2119 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2120 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2123 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2125 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2126 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2127 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2128 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2131 #ifndef DISABLE_PLOT2DVIEWER
2132 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2135 my2dHistogram->clearAllPoints();
2137 if(SMESH::Controls::NumericalFunctor* fun =
2138 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2141 if(!my2dHistogram) {
2142 my2dHistogram = new SPlot2d_Histogram();
2143 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2144 my2dHistogram->setIO(anIO);
2147 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2148 std::vector<int> nbEvents;
2149 std::vector<double> funValues;
2150 SMESH_VisualObjDef::TEntityList elems;
2151 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2152 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2153 std::vector<int> elemIds;
2155 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2156 elemIds.push_back( (*e)->GetID());
2158 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2159 double * range = lookupTable->GetRange();
2160 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2162 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2163 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2165 if(funValues.size() >= 2)
2166 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2170 //Color of the histogram
2171 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2172 my2dHistogram->setAutoAssign(true);
2175 myScalarBarActor->GetDistributionColor(rgb);
2176 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2177 my2dHistogram->setColor(aColor);
2181 return my2dHistogram;