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_ExtractUnstructuredGrid.h"
37 #include "VTKViewer_FramedTextActor.h"
38 #include "SALOME_InteractiveObject.hxx"
40 #include "SUIT_Session.h"
41 #include "SUIT_ResourceMgr.h"
45 #ifndef DISABLE_PLOT2DVIEWER
46 #include <SPlot2d_Histogram.h>
49 #include <vtkProperty.h>
50 #include <vtkTimeStamp.h>
51 #include <vtkObjectFactory.h>
52 #include <vtkShrinkPolyData.h>
53 #include <vtkMergeFilter.h>
55 #include <vtkMatrix4x4.h>
56 #include <vtkUnstructuredGrid.h>
57 #include <vtkPointData.h>
58 #include <vtkCellData.h>
60 #include <vtkMapper.h>
61 #include <vtkRenderer.h>
64 #include <vtkIdList.h>
65 #include <vtkIntArray.h>
67 #include <vtkActor2D.h>
68 #include <vtkProperty2D.h>
69 #include <vtkPolyData.h>
70 #include <vtkMaskPoints.h>
71 #include <vtkTextProperty.h>
72 #include <vtkLabeledDataMapper.h>
73 #include <vtkSelectVisiblePoints.h>
75 #include <vtkLookupTable.h>
79 #include <vtkImplicitBoolean.h>
80 #include <vtkImplicitFunctionCollection.h>
82 #include <vtkConfigure.h>
83 #if !defined(VTK_XVERSION)
84 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
87 #include "utilities.h"
90 static int MYDEBUG = 1;
92 static int MYDEBUG = 1;
95 static int aLineWidthInc = 2;
98 SMESH_ActorDef* SMESH_ActorDef::New(){
99 return new SMESH_ActorDef();
103 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
104 const char* theEntry,
108 SMESH_ActorDef* anActor = NULL;
109 if(theVisualObj->IsValid() ) {
110 anActor = SMESH_ActorDef::New();
111 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
116 anActor->UpdateScalarBar();
122 SMESH_ActorDef::SMESH_ActorDef()
124 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
126 myTimeStamp = vtkTimeStamp::New();
128 myIsPointsVisible = false;
130 myIsShrinkable = false;
133 myIsFacesOriented = false;
135 myControlsPrecision = -1;
136 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
138 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
139 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
141 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
142 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
144 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
145 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
147 //Definition 2D and 3D devices of the actor
148 //-----------------------------------------
149 vtkFloatingPointType anRGB[3] = {1,1,1};
150 mySurfaceProp = vtkProperty::New();
153 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
154 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
155 myDeltaBrightness = delta;
157 myBackSurfaceProp = vtkProperty::New();
158 bfc = Qtx::mainColorToSecondary(ffc, delta);
159 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
161 my2DActor = SMESH_DeviceActor::New();
162 my2DActor->SetUserMatrix(aMatrix);
163 my2DActor->PickableOff();
164 my2DActor->SetProperty(mySurfaceProp);
165 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
166 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
167 aFilter = my2DActor->GetExtractUnstructuredGrid();
168 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
169 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
170 aFilter->RegisterCellsWithType(VTK_POLYGON);
171 aFilter->RegisterCellsWithType(VTK_QUAD);
172 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
173 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
175 my2DExtProp = vtkProperty::New();
176 my2DExtProp->DeepCopy(mySurfaceProp);
177 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
178 anRGB[0] = 1 - anRGB[0];
179 anRGB[1] = 1 - anRGB[1];
180 anRGB[2] = 1 - anRGB[2];
181 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
183 my2DExtActor = SMESH_DeviceActor::New();
184 my2DExtActor->SetUserMatrix(aMatrix);
185 my2DExtActor->PickableOff();
186 my2DExtActor->SetProperty(my2DExtProp);
187 my2DExtActor->SetBackfaceProperty(my2DExtProp);
188 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
189 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
190 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
191 aFilter->RegisterCellsWithType(VTK_POLYGON);
192 aFilter->RegisterCellsWithType(VTK_QUAD);
193 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
194 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
196 my3DActor = SMESH_DeviceActor::New();
197 my3DActor->SetUserMatrix(aMatrix);
198 my3DActor->PickableOff();
199 my3DActor->SetProperty(mySurfaceProp);
200 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
201 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
202 aFilter = my3DActor->GetExtractUnstructuredGrid();
203 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
204 aFilter->RegisterCellsWithType(VTK_TETRA);
205 aFilter->RegisterCellsWithType(VTK_VOXEL);
206 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
207 aFilter->RegisterCellsWithType(VTK_WEDGE);
208 aFilter->RegisterCellsWithType(VTK_PYRAMID);
209 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
210 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
211 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
212 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
213 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
214 //#ifdef VTK_HAVE_POLYHEDRON
215 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
216 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
219 my3DExtActor = SMESH_DeviceActor::New();
220 my3DExtActor->SetUserMatrix(aMatrix);
221 my3DExtActor->PickableOff();
222 my3DExtActor->SetProperty(my2DExtProp);
223 my3DExtActor->SetBackfaceProperty(my2DExtProp);
224 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
225 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
226 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
227 aFilter->RegisterCellsWithType(VTK_TETRA);
228 aFilter->RegisterCellsWithType(VTK_VOXEL);
229 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
230 aFilter->RegisterCellsWithType(VTK_WEDGE);
231 aFilter->RegisterCellsWithType(VTK_PYRAMID);
232 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
233 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
234 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
235 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
236 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
237 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
239 //Definition 1D device of the actor
240 //---------------------------------
241 myEdgeProp = vtkProperty::New();
242 myEdgeProp->SetAmbient(1.0);
243 myEdgeProp->SetDiffuse(0.0);
244 myEdgeProp->SetSpecular(0.0);
245 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
246 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
247 myEdgeProp->SetLineWidth(aLineWidth);
249 my1DActor = SMESH_DeviceActor::New();
250 my1DActor->SetUserMatrix(aMatrix);
251 my1DActor->PickableOff();
252 my1DActor->SetHighlited(true);
253 my1DActor->SetProperty(myEdgeProp);
254 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
255 aFilter = my1DActor->GetExtractUnstructuredGrid();
256 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
257 aFilter->RegisterCellsWithType(VTK_LINE);
258 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
260 my1DProp = vtkProperty::New();
261 my1DProp->DeepCopy(myEdgeProp);
262 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
263 my1DProp->SetPointSize(aElem0DSize);
265 my1DExtProp = vtkProperty::New();
266 my1DExtProp->DeepCopy(myEdgeProp);
267 anRGB[0] = 1 - anRGB[0];
268 anRGB[1] = 1 - anRGB[1];
269 anRGB[2] = 1 - anRGB[2];
270 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
271 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
272 my1DExtProp->SetPointSize(aElem0DSize);
274 my1DExtActor = SMESH_DeviceActor::New();
275 my1DExtActor->SetUserMatrix(aMatrix);
276 my1DExtActor->PickableOff();
277 my1DExtActor->SetHighlited(true);
278 my1DExtActor->SetVisibility(false);
279 my1DExtActor->SetProperty(my1DExtProp);
280 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
281 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
282 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
283 aFilter->RegisterCellsWithType(VTK_LINE);
284 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
287 //Definition 0D device of the actor (0d elements)
288 //-----------------------------------------------
289 my0DProp = vtkProperty::New();
290 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
291 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
292 my0DProp->SetPointSize(aElem0DSize);
294 my0DActor = SMESH_DeviceActor::New();
295 my0DActor->SetUserMatrix(aMatrix);
296 my0DActor->SetStoreClippingMapping(true);
297 my0DActor->PickableOff();
298 my0DActor->SetVisibility(false);
299 my0DActor->SetProperty(my0DProp);
300 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
301 aFilter = my0DActor->GetExtractUnstructuredGrid();
302 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
303 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
304 aFilter->RegisterCellsWithType(VTK_VERTEX);
306 //my0DExtProp = vtkProperty::New();
307 //my0DExtProp->DeepCopy(my0DProp);
308 //anRGB[0] = 1 - anRGB[0];
309 //anRGB[1] = 1 - anRGB[1];
310 //anRGB[2] = 1 - anRGB[2];
311 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
312 //my0DExtProp->SetPointSize(aElem0DSize);
314 //my0DExtActor = SMESH_DeviceActor::New();
315 //my0DExtActor->SetUserMatrix(aMatrix);
316 //my0DExtActor->SetStoreClippingMapping(true);
317 //my0DExtActor->PickableOff();
318 //my0DExtActor->SetHighlited(true);
319 //my0DExtActor->SetVisibility(false);
320 //my0DExtActor->SetProperty(my0DExtProp);
321 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
322 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
323 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
324 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
325 //aFilter->RegisterCellsWithType(VTK_VERTEX);
328 //Definition 0D device of the actor (nodes)
329 //-----------------------------------------
330 myNodeProp = vtkProperty::New();
331 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
332 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
334 myNodeActor = SMESH_DeviceActor::New();
335 myNodeActor->SetUserMatrix(aMatrix);
336 myNodeActor->SetStoreClippingMapping(true);
337 myNodeActor->PickableOff();
338 myNodeActor->SetVisibility(false);
339 myNodeActor->SetProperty(myNodeProp);
340 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
341 aFilter = myNodeActor->GetExtractUnstructuredGrid();
342 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
344 myNodeExtProp = vtkProperty::New();
345 myNodeExtProp->DeepCopy(myNodeProp);
346 anRGB[0] = 1 - anRGB[0];
347 anRGB[1] = 1 - anRGB[1];
348 anRGB[2] = 1 - anRGB[2];
349 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
351 myNodeExtActor = SMESH_DeviceActor::New();
352 myNodeExtActor->SetUserMatrix(aMatrix);
353 myNodeExtActor->SetStoreClippingMapping(true);
354 myNodeExtActor->PickableOff();
355 myNodeExtActor->SetHighlited(true);
356 myNodeExtActor->SetVisibility(false);
357 myNodeExtActor->SetProperty(myNodeExtProp);
358 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
359 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
360 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
361 aFilter->RegisterCellsWithType(VTK_VERTEX);
363 //Definition of Pickable and Highlitable engines
364 //----------------------------------------------
366 myBaseActor = SMESH_DeviceActor::New();
367 myBaseActor->SetUserMatrix(aMatrix);
368 myBaseActor->SetStoreGemetryMapping(true);
369 myBaseActor->GetProperty()->SetOpacity(0.0);
371 myPickableActor = myBaseActor;
373 myHighlightProp = vtkProperty::New();
374 myHighlightProp->SetAmbient(1.0);
375 myHighlightProp->SetDiffuse(0.0);
376 myHighlightProp->SetSpecular(0.0);
377 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
378 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
379 myHighlightProp->SetPointSize(aElem0DSize); // ??
380 myHighlightProp->SetRepresentation(1);
382 myPreselectProp = vtkProperty::New();
383 myPreselectProp->SetAmbient(1.0);
384 myPreselectProp->SetDiffuse(0.0);
385 myPreselectProp->SetSpecular(0.0);
386 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
387 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
388 myPreselectProp->SetPointSize(aElem0DSize); // ??
389 myPreselectProp->SetRepresentation(1);
391 myHighlitableActor = SMESH_DeviceActor::New();
392 myHighlitableActor->SetUserMatrix(aMatrix);
393 myHighlitableActor->PickableOff();
394 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
401 myControlMode = eNone;
402 myControlActor = my2DActor;
404 //Definition of myScalarBarActor
405 //------------------------------
406 myLookupTable = vtkLookupTable::New();
407 //Fix for Bug PAL5195 - SMESH764:
408 //Controls - Aspect Ratio: incorrect colors of the best and worst values
409 myLookupTable->SetHueRange(0.667,0.0);
411 myScalarBarActor = SMESH_ScalarBarActor::New();
412 myScalarBarActor->SetVisibility(false);
413 myScalarBarActor->SetLookupTable(myLookupTable);
416 //Incorrect "Min value" in Scalar Bar in Mesh:
417 // myScalarBarActor->SetLabelFormat("%.4g");
418 // changes was commented because of regression bug IPAL 19981
420 mgr = SUIT_Session::session()->resourceMgr();
424 //Definition of points numbering pipeline
425 //---------------------------------------
426 myPointsNumDataSet = vtkUnstructuredGrid::New();
428 myPtsMaskPoints = vtkMaskPoints::New();
429 myPtsMaskPoints->SetInput(myPointsNumDataSet);
430 myPtsMaskPoints->SetOnRatio(1);
432 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
433 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
434 myPtsSelectVisiblePoints->SelectInvisibleOff();
435 myPtsSelectVisiblePoints->SetTolerance(0.1);
437 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
438 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
439 #if (VTK_XVERSION < 0x050200)
440 myPtsLabeledDataMapper->SetLabelFormat("%g");
442 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
444 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
445 aPtsTextProp->SetFontFamilyToTimes();
446 static int aPointsFontSize = 10;
447 aPtsTextProp->SetFontSize(aPointsFontSize);
448 aPtsTextProp->SetBold(1);
449 aPtsTextProp->SetItalic(0);
450 aPtsTextProp->SetShadow(0);
451 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
452 aPtsTextProp->Delete();
454 myEntityMode = eAllEntity;
456 myIsPointsLabeled = false;
458 myPointLabels = vtkActor2D::New();
459 myPointLabels->SetMapper(myPtsLabeledDataMapper);
460 myPointLabels->GetProperty()->SetColor(1,1,1);
461 myPointLabels->SetVisibility(myIsPointsLabeled);
464 //Definition of cells numbering pipeline
465 //---------------------------------------
466 myCellsNumDataSet = vtkUnstructuredGrid::New();
468 myCellCenters = VTKViewer_CellCenters::New();
469 myCellCenters->SetInput(myCellsNumDataSet);
471 myClsMaskPoints = vtkMaskPoints::New();
472 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
473 myClsMaskPoints->SetOnRatio(1);
475 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
476 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
477 myClsSelectVisiblePoints->SelectInvisibleOff();
478 myClsSelectVisiblePoints->SetTolerance(0.1);
480 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
481 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
482 #if (VTK_XVERSION < 0x050200)
483 myClsLabeledDataMapper->SetLabelFormat("%g");
485 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
487 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
488 aClsTextProp->SetFontFamilyToTimes();
489 static int aCellsFontSize = 12;
490 aClsTextProp->SetFontSize(aCellsFontSize);
491 aClsTextProp->SetBold(1);
492 aClsTextProp->SetItalic(0);
493 aClsTextProp->SetShadow(0);
494 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
495 aClsTextProp->Delete();
497 myIsCellsLabeled = false;
499 myCellsLabels = vtkActor2D::New();
500 myCellsLabels->SetMapper(myClsLabeledDataMapper);
501 myCellsLabels->GetProperty()->SetColor(0,1,0);
502 myCellsLabels->SetVisibility(myIsCellsLabeled);
505 myImplicitBoolean = vtkImplicitBoolean::New();
506 myImplicitBoolean->SetOperationTypeToIntersection();
510 //Quadratic 2D elements representation
511 //-----------------------------------------------------------------------------
512 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
513 if(aQuadratic2DMode == 0){
514 myHighlitableActor->SetQuadraticArcMode(false);
515 my2DActor->SetQuadraticArcMode(false);
516 my1DActor->SetQuadraticArcMode(false);
518 else if(aQuadratic2DMode == 1){
519 myHighlitableActor->SetQuadraticArcMode(true);
520 my2DActor->SetQuadraticArcMode(true);
521 my1DActor->SetQuadraticArcMode(true);
524 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
525 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
526 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
528 // Set colors of the name actor
529 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
530 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
531 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
532 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
534 #ifndef DISABLE_PLOT2DVIEWER
541 SMESH_ActorDef::~SMESH_ActorDef()
543 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
545 #ifndef DISABLE_PLOT2DVIEWER
547 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
548 delete my2dHistogram;
552 // caught by SMESHGUI::ProcessEvents() static method
553 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
555 myScalarBarActor->Delete();
556 myLookupTable->Delete();
558 mySurfaceProp->Delete();
559 myBackSurfaceProp->Delete();
561 myEdgeProp->Delete();
562 myHighlightProp->Delete();
563 myPreselectProp->Delete();
565 myNodeProp->Delete();
566 myNodeExtProp->Delete();
571 //my0DExtProp->Delete();
572 //my0DExtActor->Delete();
577 my1DExtProp->Delete();
578 my1DExtActor->Delete();
581 my2DExtProp->Delete();
582 my2DExtActor->Delete();
584 my3DExtActor->Delete();
586 myNodeActor->Delete();
587 myBaseActor->Delete();
589 myNodeExtActor->Delete();
591 myHighlitableActor->Delete();
593 //Deleting of points numbering pipeline
594 //---------------------------------------
595 myPointsNumDataSet->Delete();
597 // commented: porting to vtk 5.0
598 // myPtsLabeledDataMapper->RemoveAllInputs();
599 myPtsLabeledDataMapper->Delete();
601 // commented: porting to vtk 5.0
602 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
603 myPtsSelectVisiblePoints->Delete();
605 // commented: porting to vtk 5.0
606 // myPtsMaskPoints->UnRegisterAllOutputs();
607 myPtsMaskPoints->Delete();
609 myPointLabels->Delete();
612 //Deleting of cells numbering pipeline
613 //---------------------------------------
614 myCellsNumDataSet->Delete();
616 myClsLabeledDataMapper->RemoveAllInputs();
617 myClsLabeledDataMapper->Delete();
619 // commented: porting to vtk 5.0
620 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
621 myClsSelectVisiblePoints->Delete();
623 // commented: porting to vtk 5.0
624 // myClsMaskPoints->UnRegisterAllOutputs();
625 myClsMaskPoints->Delete();
627 // commented: porting to vtk 5.0
628 // myCellCenters->UnRegisterAllOutputs();
629 myCellCenters->Delete();
631 myCellsLabels->Delete();
633 myImplicitBoolean->Delete();
635 myTimeStamp->Delete();
639 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
641 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
643 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
645 if ( myIsPointsLabeled )
647 myPointsNumDataSet->ShallowCopy(aGrid);
648 vtkDataSet *aDataSet = myPointsNumDataSet;
650 int aNbElem = aDataSet->GetNumberOfPoints();
652 vtkIntArray *anArray = vtkIntArray::New();
653 anArray->SetNumberOfValues( aNbElem );
655 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
657 int aSMDSId = myVisualObj->GetNodeObjId( anId );
658 anArray->SetValue( anId, aSMDSId );
661 aDataSet->GetPointData()->SetScalars( anArray );
663 myPtsMaskPoints->SetInput( aDataSet );
664 myPointLabels->SetVisibility( GetVisibility() );
668 myPointLabels->SetVisibility( false );
670 SetRepresentation(GetRepresentation());
671 myTimeStamp->Modified();
675 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
677 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
678 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
679 if(myIsCellsLabeled){
680 myCellsNumDataSet->ShallowCopy(aGrid);
681 vtkDataSet *aDataSet = myCellsNumDataSet;
682 int aNbElem = aDataSet->GetNumberOfCells();
683 vtkIntArray *anArray = vtkIntArray::New();
684 anArray->SetNumberOfValues(aNbElem);
685 for(int anId = 0; anId < aNbElem; anId++){
686 int aSMDSId = myVisualObj->GetElemObjId(anId);
687 anArray->SetValue(anId,aSMDSId);
689 aDataSet->GetCellData()->SetScalars(anArray);
690 myCellCenters->SetInput(aDataSet);
691 myCellsLabels->SetVisibility(GetVisibility());
693 myCellsLabels->SetVisibility(false);
695 myTimeStamp->Modified();
699 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
701 myIsFacesOriented = theIsFacesOriented;
703 my2DActor->SetFacesOriented(theIsFacesOriented);
704 my3DActor->SetFacesOriented(theIsFacesOriented);
706 myTimeStamp->Modified();
709 bool SMESH_ActorDef::GetFacesOriented()
711 return myIsFacesOriented;
714 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
716 my2DActor->SetFacesOrientationColor( theColor );
717 my3DActor->SetFacesOrientationColor( theColor );
720 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
722 my3DActor->GetFacesOrientationColor( theColor );
725 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
727 my2DActor->SetFacesOrientationScale( theScale );
728 my3DActor->SetFacesOrientationScale( theScale );
731 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
733 return my3DActor->GetFacesOrientationScale();
736 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
738 my2DActor->SetFacesOrientation3DVectors( theState );
739 my3DActor->SetFacesOrientation3DVectors( theState );
742 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
744 return my3DActor->GetFacesOrientation3DVectors();
750 SetControlMode(eControl theMode)
752 SetControlMode(theMode,true);
758 SetControlMode(eControl theMode,
759 bool theCheckEntityMode)
761 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
765 myControlMode = eNone;
766 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
768 my0DActor->GetMapper()->SetScalarVisibility(false);
769 my1DActor->GetMapper()->SetScalarVisibility(false);
770 my2DActor->GetMapper()->SetScalarVisibility(false);
771 my3DActor->GetMapper()->SetScalarVisibility(false);
772 myScalarBarActor->SetVisibility(false);
774 bool anIsScalarVisible = theMode > eNone;
776 if(anIsScalarVisible) {
780 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
781 aControl->SetPrecision( myControlsPrecision );
782 myFunctor.reset( aControl );
783 myControlActor = my1DActor;
788 myFunctor.reset(new SMESH::Controls::Length2D());
789 myControlActor = my2DActor;
793 myFunctor.reset(new SMESH::Controls::FreeBorders());
794 myControlActor = my1DActor;
797 myFunctor.reset(new SMESH::Controls::FreeEdges());
798 myControlActor = my2DActor;
801 myFunctor.reset(new SMESH::Controls::FreeNodes());
802 myControlActor = myNodeActor;
805 myFunctor.reset(new SMESH::Controls::FreeFaces());
806 myControlActor = my2DActor;
808 case eBareBorderFace:
809 myFunctor.reset(new SMESH::Controls::BareBorderFace());
810 myControlActor = my2DActor;
812 case eOverConstrainedFace:
813 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
814 myControlActor = my2DActor;
816 case eMultiConnection:
817 myFunctor.reset(new SMESH::Controls::MultiConnection());
818 myControlActor = my1DActor;
820 case eMultiConnection2D:
821 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
822 myControlActor = my2DActor;
826 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
827 aControl->SetPrecision( myControlsPrecision );
828 myFunctor.reset( aControl );
829 myControlActor = my2DActor;
834 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
835 aControl->SetPrecision( myControlsPrecision );
836 myFunctor.reset( aControl );
837 myControlActor = my2DActor;
842 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
843 aControl->SetPrecision( myControlsPrecision );
844 myFunctor.reset( aControl );
845 myControlActor = my2DActor;
850 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
851 aControl->SetPrecision( myControlsPrecision );
852 myFunctor.reset( aControl );
853 myControlActor = my3DActor;
858 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
859 aControl->SetPrecision( myControlsPrecision );
860 myFunctor.reset( aControl );
861 myControlActor = my3DActor;
864 case eMaxElementLength2D:
866 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
867 aControl->SetPrecision( myControlsPrecision );
868 myFunctor.reset( aControl );
869 myControlActor = my2DActor;
872 case eMaxElementLength3D:
874 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
875 aControl->SetPrecision( myControlsPrecision );
876 myFunctor.reset( aControl );
877 myControlActor = my3DActor;
880 case eBareBorderVolume:
882 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
883 myControlActor = my3DActor;
886 case eOverConstrainedVolume:
888 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
889 myControlActor = my3DActor;
894 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
895 aControl->SetPrecision( myControlsPrecision );
896 myFunctor.reset( aControl );
897 myControlActor = my2DActor;
902 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
903 aControl->SetPrecision( myControlsPrecision );
904 myFunctor.reset( aControl );
905 myControlActor = my2DActor;
910 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
911 aControl->SetPrecision( myControlsPrecision );
912 myFunctor.reset( aControl );
913 myControlActor = my2DActor;
920 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
921 vtkIdType aNbCells = aGrid->GetNumberOfCells();
923 myControlMode = theMode;
924 switch(myControlMode){
926 myNodeExtActor->SetExtControlMode(myFunctor);
930 my1DExtActor->SetExtControlMode(myFunctor);
933 case eBareBorderFace:
934 case eOverConstrainedFace:
935 my2DExtActor->SetExtControlMode(myFunctor);
937 case eBareBorderVolume:
938 case eOverConstrainedVolume:
939 my3DExtActor->SetExtControlMode(myFunctor);
942 case eMultiConnection2D:
943 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
944 UpdateDistribution();
947 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
948 UpdateDistribution();
952 if(theCheckEntityMode){
953 if(myControlActor == my1DActor)
954 SetEntityMode(eEdges);
955 else if(myControlActor == my2DActor){
956 switch(myControlMode){
960 case eMultiConnection2D:
961 //SetEntityMode(eEdges);
962 SetEntityMode(eFaces);
965 SetEntityMode(eFaces);
967 }else if(myControlActor == my3DActor)
968 SetEntityMode(eVolumes);
973 if(theCheckEntityMode)
974 myEntityMode = eAllEntity;
978 SetRepresentation(GetRepresentation());
980 myTimeStamp->Modified();
985 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
986 theRenderer->AddActor(myNodeActor);
987 theRenderer->AddActor(myBaseActor);
989 theRenderer->AddActor(myNodeExtActor);
991 my3DActor->AddToRender(theRenderer);
992 my3DExtActor->AddToRender(theRenderer);
993 my2DActor->AddToRender(theRenderer);
994 my2DExtActor->AddToRender(theRenderer);
996 theRenderer->AddActor(my1DActor);
997 theRenderer->AddActor(my1DExtActor);
999 theRenderer->AddActor(my0DActor);
1000 //theRenderer->AddActor(my0DExtActor);
1002 theRenderer->AddActor(myHighlitableActor);
1004 theRenderer->AddActor2D(myScalarBarActor);
1006 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
1007 myClsSelectVisiblePoints->SetRenderer(theRenderer);
1009 theRenderer->AddActor2D(myPointLabels);
1010 theRenderer->AddActor2D(myCellsLabels);
1012 // the superclass' method should be called at the end
1013 // (in particular, for correct work of selection)
1014 SALOME_Actor::AddToRender(theRenderer);
1017 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1018 SALOME_Actor::RemoveFromRender(theRenderer);
1020 theRenderer->RemoveActor(myNodeActor);
1021 theRenderer->RemoveActor(myBaseActor);
1023 theRenderer->RemoveActor(myNodeExtActor);
1025 theRenderer->RemoveActor(myHighlitableActor);
1027 theRenderer->RemoveActor(my0DActor);
1028 //theRenderer->RemoveActor(my0DExtActor);
1030 theRenderer->RemoveActor(my1DActor);
1031 theRenderer->RemoveActor(my1DExtActor);
1033 my2DActor->RemoveFromRender(theRenderer);
1034 my2DExtActor->RemoveFromRender(theRenderer);
1035 my3DActor->RemoveFromRender(theRenderer);
1036 my3DExtActor->RemoveFromRender(theRenderer);
1038 theRenderer->RemoveActor(myScalarBarActor);
1039 theRenderer->RemoveActor(myPointLabels);
1040 theRenderer->RemoveActor(myCellsLabels);
1044 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1045 const char* theEntry,
1046 const char* theName,
1049 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1053 myVisualObj = theVisualObj;
1054 myVisualObj->Update(theIsClear);
1056 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1057 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1059 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1061 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1063 my0DActor->Init(myVisualObj,myImplicitBoolean);
1064 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1066 my1DActor->Init(myVisualObj,myImplicitBoolean);
1067 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1069 my2DActor->Init(myVisualObj,myImplicitBoolean);
1070 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1071 my3DActor->Init(myVisualObj,myImplicitBoolean);
1072 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1074 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1075 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1077 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1078 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1080 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1081 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1082 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1083 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1085 vtkFloatingPointType aFactor, aUnits;
1086 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1087 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1088 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1090 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1094 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1095 SetIsShrunkable(true);
1097 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1099 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1100 SetRepresentation(-1);
1103 SetRepresentation(eEdge);
1104 }else if(aMode == 1){
1105 SetRepresentation(eSurface);
1106 }else if(aMode == 2){
1107 SetRepresentation(ePoint);
1114 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1115 SetIsDisplayNameActor( true );
1117 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1118 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1119 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1121 myTimeStamp->Modified();
1127 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1128 return myNodeActor->GetBounds();
1132 vtkDataSet* SMESH_ActorDef::GetInput(){
1133 return GetUnstructuredGrid();
1137 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1138 Superclass::SetTransform(theTransform);
1140 myNodeActor->SetTransform(theTransform);
1141 myBaseActor->SetTransform(theTransform);
1143 myHighlitableActor->SetTransform(theTransform);
1145 myNodeExtActor->SetTransform(theTransform);
1147 my0DActor->SetTransform(theTransform);
1148 //my0DExtActor->SetTransform(theTransform);
1150 my1DActor->SetTransform(theTransform);
1151 my1DExtActor->SetTransform(theTransform);
1153 my2DActor->SetTransform(theTransform);
1154 my2DExtActor->SetTransform(theTransform);
1155 my3DActor->SetTransform(theTransform);
1156 my3DExtActor->SetTransform(theTransform);
1162 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1163 vtkLODActor::SetMapper(theMapper);
1167 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1168 SALOME_Actor::ShallowCopy(prop);
1172 vtkMapper* SMESH_ActorDef::GetMapper(){
1173 return myPickableActor->GetMapper();
1177 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1178 return myVisualObj->GetUnstructuredGrid();
1182 bool SMESH_ActorDef::IsInfinitive(){
1183 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1185 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1186 ( aDataSet->GetNumberOfCells() == 1 &&
1187 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1188 return SALOME_Actor::IsInfinitive();
1192 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1193 if ( myIsShrinkable == theShrunkable )
1195 myIsShrinkable = theShrunkable;
1199 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1200 return myBaseActor->GetShrinkFactor();
1203 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1204 myBaseActor->SetShrinkFactor(theValue);
1206 my1DActor->SetShrinkFactor(theValue);
1207 my1DExtActor->SetShrinkFactor(theValue);
1209 my2DActor->SetShrinkFactor(theValue);
1210 my2DExtActor->SetShrinkFactor(theValue);
1211 my3DActor->SetShrinkFactor(theValue);
1212 my3DExtActor->SetShrinkFactor(theValue);
1217 void SMESH_ActorDef::SetShrink(){
1218 if(!myIsShrinkable) return;
1220 myBaseActor->SetShrink();
1222 my1DActor->SetShrink();
1223 my1DExtActor->SetShrink();
1225 my2DActor->SetShrink();
1226 my2DExtActor->SetShrink();
1227 my3DActor->SetShrink();
1228 my3DExtActor->SetShrink();
1234 void SMESH_ActorDef::UnShrink(){
1235 if(!myIsShrunk) return;
1237 myBaseActor->UnShrink();
1239 my1DActor->UnShrink();
1240 my1DExtActor->UnShrink();
1242 my2DActor->UnShrink();
1243 my2DExtActor->UnShrink();
1244 my3DActor->UnShrink();
1245 my3DExtActor->UnShrink();
1252 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1253 return myPickableActor->GetNodeObjId(theVtkID);
1256 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1257 return myPickableActor->GetNodeCoord(theObjID);
1261 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1262 return myPickableActor->GetElemObjId(theVtkID);
1265 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1266 return myPickableActor->GetElemCell(theObjID);
1270 void SMESH_ActorDef::SetVisibility(int theMode){
1271 SetVisibility(theMode,true);
1275 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1276 SALOME_Actor::SetVisibility(theMode);
1278 myNodeActor->VisibilityOff();
1279 myBaseActor->VisibilityOff();
1281 myNodeExtActor->VisibilityOff();
1283 my0DActor->VisibilityOff();
1284 //my0DExtActor->VisibilityOff();
1286 my1DActor->VisibilityOff();
1287 my1DExtActor->VisibilityOff();
1289 my2DActor->VisibilityOff();
1290 my2DExtActor->VisibilityOff();
1291 my3DActor->VisibilityOff();
1292 my3DExtActor->VisibilityOff();
1294 myScalarBarActor->VisibilityOff();
1295 myPointLabels->VisibilityOff();
1296 myCellsLabels->VisibilityOff();
1298 if(GetVisibility()){
1299 if(theIsUpdateRepersentation)
1300 SetRepresentation(GetRepresentation());
1302 if(myControlMode != eNone){
1303 switch(myControlMode){
1305 myNodeExtActor->VisibilityOn();
1309 my1DExtActor->VisibilityOn();
1312 case eBareBorderFace:
1313 case eOverConstrainedFace:
1314 my2DExtActor->VisibilityOn();
1316 case eBareBorderVolume:
1317 case eOverConstrainedVolume:
1318 my3DExtActor->VisibilityOn();
1321 case eMultiConnection2D:
1322 my1DExtActor->VisibilityOn();
1324 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1325 myScalarBarActor->VisibilityOn();
1329 if(myRepresentation != ePoint)
1330 myPickableActor->VisibilityOn();
1332 myNodeActor->VisibilityOn();
1335 if(myEntityMode & e0DElements){
1336 my0DActor->VisibilityOn();
1339 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1340 my1DActor->VisibilityOn();
1343 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1344 my2DActor->VisibilityOn();
1347 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1348 my3DActor->VisibilityOn();
1351 if(myIsPointsLabeled){
1352 myPointLabels->VisibilityOn();
1353 myNodeActor->VisibilityOn();
1356 if(myIsCellsLabeled)
1357 myCellsLabels->VisibilityOn();
1359 #ifndef DISABLE_PLOT2DVIEWER
1361 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1368 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1370 myEntityState = eAllEntity;
1372 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1373 myEntityState &= ~e0DElements;
1374 theMode &= ~e0DElements;
1377 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1378 myEntityState &= ~eEdges;
1382 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1383 myEntityState &= ~eFaces;
1387 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1388 myEntityState &= ~eVolumes;
1389 theMode &= ~eVolumes;
1393 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1394 theMode |= e0DElements;
1396 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1399 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1402 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1403 theMode |= eVolumes;
1406 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1408 myEntityMode = theMode;
1409 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1410 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1411 aFilter->ClearRegisteredCellsWithType();
1412 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1414 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1415 aHightFilter->ClearRegisteredCellsWithType();
1416 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1418 if (myEntityMode & e0DElements) {
1419 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1420 aFilter->RegisterCellsWithType(VTK_VERTEX);
1421 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1424 if (myEntityMode & eEdges) {
1425 if (MYDEBUG) MESSAGE("EDGES");
1426 aFilter->RegisterCellsWithType(VTK_LINE);
1427 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1429 aHightFilter->RegisterCellsWithType(VTK_LINE);
1430 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1433 if (myEntityMode & eFaces) {
1434 if (MYDEBUG) MESSAGE("FACES");
1435 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1436 aFilter->RegisterCellsWithType(VTK_POLYGON);
1437 aFilter->RegisterCellsWithType(VTK_QUAD);
1438 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1439 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1441 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1442 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1443 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1444 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1445 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1448 if (myEntityMode & eVolumes) {
1449 if (MYDEBUG) MESSAGE("VOLUMES");
1450 aFilter->RegisterCellsWithType(VTK_TETRA);
1451 aFilter->RegisterCellsWithType(VTK_VOXEL);
1452 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1453 aFilter->RegisterCellsWithType(VTK_WEDGE);
1454 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1455 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1456 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1457 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1458 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1459 //#ifdef VTK_HAVE_POLYHEDRON
1460 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1463 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1464 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1465 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1466 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1467 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1468 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1469 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1470 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1471 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1472 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1473 //#ifdef VTK_HAVE_POLYHEDRON
1474 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1478 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1479 SetVisibility(GetVisibility(),false);
1482 void SMESH_ActorDef::SetRepresentation (int theMode)
1484 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1485 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1486 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1489 myRepresentation = eSurface;
1490 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1491 myRepresentation = eEdge;
1492 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1493 myRepresentation = ePoint;
1498 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1501 if (!aNbFaces && !aNbVolumes) return;
1504 myRepresentation = theMode;
1507 if (!GetUnstructuredGrid()->GetNumberOfCells())
1508 myRepresentation = ePoint;
1511 if (myRepresentation == ePoint) {
1519 myPickableActor = myBaseActor;
1520 myNodeActor->SetVisibility(false);
1521 myNodeExtActor->SetVisibility(false);
1522 vtkProperty *aProp = NULL, *aBackProp = NULL;
1523 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1524 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1525 switch (myRepresentation) {
1527 myPickableActor = myNodeActor;
1528 myNodeActor->SetVisibility(true);
1529 aQuadraticMode = SMESH_Actor::eLines;
1530 aProp = aBackProp = myNodeProp;
1531 aReperesent = SMESH_DeviceActor::ePoint;
1534 aProp = aBackProp = myEdgeProp;
1535 aReperesent = SMESH_DeviceActor::eInsideframe;
1538 aProp = mySurfaceProp;
1539 aBackProp = myBackSurfaceProp;
1540 aReperesent = SMESH_DeviceActor::eSurface;
1544 my2DActor->SetProperty(aProp);
1545 my2DActor->SetBackfaceProperty(aBackProp);
1546 my2DActor->SetRepresentation(aReperesent);
1548 if(aQuadraticMode == SMESH_Actor::eLines)
1549 my2DActor->SetQuadraticArcMode(false);
1550 else if(aQuadraticMode == SMESH_Actor::eArcs)
1551 my2DActor->SetQuadraticArcMode(true);
1553 my2DExtActor->SetRepresentation(aReperesent);
1555 my3DActor->SetProperty(aProp);
1556 my3DActor->SetBackfaceProperty(aBackProp);
1557 my3DActor->SetRepresentation(aReperesent);
1559 //my0DExtActor->SetVisibility(false);
1560 my1DExtActor->SetVisibility(false);
1561 my2DExtActor->SetVisibility(false);
1562 my3DExtActor->SetVisibility(false);
1565 //my0DActor->SetProperty(aProp);
1566 //my0DActor->SetBackfaceProperty(aBackProp);
1567 my0DActor->SetRepresentation(aReperesent);
1568 //my0DExtActor->SetRepresentation(aReperesent);
1570 switch(myControlMode){
1572 case eMultiConnection:
1573 aProp = aBackProp = my1DProp;
1574 if(myRepresentation != ePoint)
1575 aReperesent = SMESH_DeviceActor::eInsideframe;
1579 if(aQuadraticMode == SMESH_Actor::eLines)
1580 my1DActor->SetQuadraticArcMode(false);
1581 else if(aQuadraticMode == SMESH_Actor::eArcs)
1582 my1DActor->SetQuadraticArcMode(true);
1584 my1DActor->SetProperty(aProp);
1585 my1DActor->SetBackfaceProperty(aBackProp);
1586 my1DActor->SetRepresentation(aReperesent);
1588 my1DExtActor->SetRepresentation(aReperesent);
1590 if(myIsPointsVisible)
1591 myPickableActor = myNodeActor;
1592 if(GetPointRepresentation())
1593 myNodeActor->SetVisibility(true);
1595 SetMapper(myPickableActor->GetMapper());
1597 SetVisibility(GetVisibility(),false);
1603 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1604 if ( myIsPointsVisible == theIsPointsVisible )
1606 myIsPointsVisible = theIsPointsVisible;
1607 SetRepresentation(GetRepresentation());
1610 bool SMESH_ActorDef::GetPointRepresentation(){
1611 return myIsPointsVisible || myIsPointsLabeled;
1615 void SMESH_ActorDef::UpdateHighlight(){
1616 myHighlitableActor->SetVisibility(false);
1617 myHighlitableActor->SetHighlited(false);
1619 if(myIsHighlighted){
1620 myHighlitableActor->SetProperty(myHighlightProp);
1621 }else if(myIsPreselected){
1622 myHighlitableActor->SetProperty(myPreselectProp);
1625 bool anIsVisible = GetVisibility();
1627 if(myIsHighlighted || myIsPreselected){
1628 if(GetUnstructuredGrid()->GetNumberOfCells()){
1629 myHighlitableActor->SetHighlited(anIsVisible);
1630 myHighlitableActor->SetVisibility(anIsVisible);
1631 myHighlitableActor->GetExtractUnstructuredGrid()->
1632 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1633 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1634 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1635 myHighlitableActor->SetHighlited(anIsVisible);
1636 myHighlitableActor->GetExtractUnstructuredGrid()->
1637 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1638 myHighlitableActor->SetVisibility(anIsVisible);
1639 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1641 VTK::MarkerType aMarkerType = GetMarkerType();
1642 if(aMarkerType != VTK::MT_USER)
1643 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
1645 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
1651 void SMESH_ActorDef::highlight(bool theHighlight){
1652 if ( myIsHighlighted == theHighlight )
1654 myIsHighlighted = theHighlight;
1659 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1660 if ( myIsPreselected == thePreselect )
1662 myIsPreselected = thePreselect;
1668 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1670 if (myPickableActor->GetIsOpaque())
1672 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1680 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1682 if (!myPickableActor->GetIsOpaque())
1684 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1692 void SMESH_ActorDef::Render(vtkRenderer *ren){
1693 unsigned long aTime = myTimeStamp->GetMTime();
1694 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1695 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1696 if(anObjTime > aTime || aClippingTime > aTime)
1701 void SMESH_ActorDef::Update(){
1702 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1704 if(GetControlMode() != eNone) {
1705 unsigned long aTime = myTimeStamp->GetMTime();
1706 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1707 if (anObjTime > aTime)
1708 SetControlMode(GetControlMode(),false);
1710 if(myIsPointsLabeled){
1711 SetPointsLabeled(myIsPointsLabeled);
1713 if(myIsCellsLabeled){
1714 SetCellsLabeled(myIsCellsLabeled);
1716 if(myIsFacesOriented){
1717 SetFacesOriented(myIsFacesOriented);
1719 SetEntityMode(GetEntityMode());
1720 SetVisibility(GetVisibility());
1722 myTimeStamp->Modified();
1727 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1728 SALOME_Actor::ReleaseGraphicsResources(renWin);
1730 myPickableActor->ReleaseGraphicsResources(renWin);
1734 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1735 vtkFloatingPointType* aColor = theProperty->GetColor();
1742 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1743 mySurfaceProp->SetOpacity(theValue);
1744 myBackSurfaceProp->SetOpacity(theValue);
1745 myEdgeProp->SetOpacity(theValue);
1746 myNodeProp->SetOpacity(theValue);
1748 my1DProp->SetOpacity(theValue);
1752 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1753 return mySurfaceProp->GetOpacity();
1757 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1758 mySurfaceProp->SetColor(r,g,b);
1759 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1760 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1761 aGroupObj->GetElementType() == SMDSAbs_Volume )
1762 myNameActor->SetBackgroundColor(r,g,b);
1764 myDeltaBrightness = delta;
1765 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1766 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1770 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1771 ::GetColor(mySurfaceProp,r,g,b);
1772 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1773 delta = myDeltaBrightness;
1776 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1777 myEdgeProp->SetColor(r,g,b);
1778 my1DProp->SetColor(r,g,b);
1779 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1780 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1781 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1782 myNameActor->SetBackgroundColor(r,g,b);
1786 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1787 ::GetColor(myEdgeProp,r,g,b);
1790 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1791 myNodeProp->SetColor(r,g,b);
1792 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1793 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1794 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1795 myNameActor->SetBackgroundColor(r,g,b);
1799 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1800 ::GetColor(myNodeProp,r,g,b);
1803 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1804 my0DProp->SetColor(r,g,b);
1805 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1806 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1807 myNameActor->SetBackgroundColor(r,g,b);
1811 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1812 ::GetColor(my0DProp,r,g,b);
1815 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1816 myHighlightProp->SetColor(r,g,b);
1820 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1821 ::GetColor(myHighlightProp,r,g,b);
1824 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1825 myPreselectProp->SetColor(r,g,b);
1829 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1830 ::GetColor(myPreselectProp,r,g,b);
1834 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1835 return myEdgeProp->GetLineWidth();
1839 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1840 myEdgeProp->SetLineWidth(theVal);
1842 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1843 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1849 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1850 my0DProp->SetPointSize(theVal);
1854 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1855 return my0DProp->GetPointSize();
1858 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1860 return myVisualObj->GetElemDimension( theObjId );
1865 IsImplicitFunctionUsed() const
1867 return myBaseActor->IsImplicitFunctionUsed();
1871 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1873 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1874 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1876 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1878 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1880 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1881 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1883 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1884 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1886 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1887 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1888 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1889 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1893 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1896 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1897 myCippingPlaneCont.push_back(thePlane);
1898 if(!IsImplicitFunctionUsed())
1899 SetImplicitFunctionUsed(true);
1901 return myCippingPlaneCont.size();
1906 RemoveAllClippingPlanes()
1908 myImplicitBoolean->GetFunction()->RemoveAllItems();
1909 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1910 myCippingPlaneCont.clear();
1911 SetImplicitFunctionUsed(false);
1916 GetNumberOfClippingPlanes()
1918 return myCippingPlaneCont.size();
1923 GetClippingPlane(vtkIdType theID)
1925 if(theID >= myCippingPlaneCont.size())
1927 return myCippingPlaneCont[theID].Get();
1930 void SMESH_ActorDef::UpdateScalarBar()
1932 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1936 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1938 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1939 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1941 aScalarBarTitleProp->SetFontFamilyToArial();
1943 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1945 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1946 if ( f.family() == "Arial" )
1947 aScalarBarTitleProp->SetFontFamilyToArial();
1948 else if ( f.family() == "Courier" )
1949 aScalarBarTitleProp->SetFontFamilyToCourier();
1950 else if ( f.family() == "Times" )
1951 aScalarBarTitleProp->SetFontFamilyToTimes();
1954 aScalarBarTitleProp->BoldOn();
1956 aScalarBarTitleProp->BoldOff();
1959 aScalarBarTitleProp->ItalicOn();
1961 aScalarBarTitleProp->ItalicOff();
1964 aScalarBarTitleProp->ShadowOn();
1966 aScalarBarTitleProp->ShadowOff();
1969 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1970 aScalarBarTitleProp->Delete();
1972 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1974 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1975 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1977 aScalarBarLabelProp->SetFontFamilyToArial();
1978 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1980 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1981 if( f.family() == "Arial" )
1982 aScalarBarLabelProp->SetFontFamilyToArial();
1983 else if( f.family() == "Courier" )
1984 aScalarBarLabelProp->SetFontFamilyToCourier();
1985 else if( f.family() == "Times" )
1986 aScalarBarLabelProp->SetFontFamilyToTimes();
1989 aScalarBarLabelProp->BoldOn();
1991 aScalarBarLabelProp->BoldOff();
1994 aScalarBarLabelProp->ItalicOn();
1996 aScalarBarLabelProp->ItalicOff();
1999 aScalarBarLabelProp->ShadowOn();
2001 aScalarBarLabelProp->ShadowOff();
2004 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2005 aScalarBarLabelProp->Delete();
2007 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2008 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2010 myScalarBarActor->SetOrientationToHorizontal();
2012 myScalarBarActor->SetOrientationToVertical();
2015 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2016 if( mgr->hasValue( "SMESH", name + "x" ) )
2017 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2019 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2020 if( mgr->hasValue( "SMESH", name + "y" ) )
2021 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2022 myScalarBarActor->SetPosition( aXVal, aYVal );
2024 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2025 if( mgr->hasValue( "SMESH", name + "width" ) )
2026 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2027 myScalarBarActor->SetWidth( aWVal );
2029 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2030 if( mgr->hasValue( "SMESH", name + "height" ) )
2031 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2032 myScalarBarActor->SetHeight( aHVal );
2035 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2036 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2037 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2040 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2041 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2042 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2044 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2045 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2047 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2048 myScalarBarActor->SetDistributionColoringType(coloringType);
2050 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2051 QColor(255, 255, 255));
2053 rgb[0]= distributionColor.red()/255.;
2054 rgb[1]= distributionColor.green()/255.;
2055 rgb[2]= distributionColor.blue()/255.;
2056 myScalarBarActor->SetDistributionColor(rgb);
2061 void SMESH_ActorDef::UpdateDistribution()
2063 if(SMESH::Controls::NumericalFunctor* fun =
2064 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2066 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2067 std::vector<int> nbEvents;
2068 std::vector<double> funValues;
2069 SMESH_VisualObjDef::TEntityList elems;
2070 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2071 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2072 std::vector<int> elemIds;
2073 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2074 elemIds.push_back( (*e)->GetID());
2075 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2076 double * range = lookupTable->GetRange();
2077 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2078 myScalarBarActor->SetDistribution(nbEvents);
2082 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2085 case SMESH_Actor::eLines :
2086 myHighlitableActor->SetQuadraticArcMode(false);
2087 my2DActor->SetQuadraticArcMode(false);
2088 my1DActor->SetQuadraticArcMode(false);
2090 case SMESH_Actor::eArcs :
2091 myHighlitableActor->SetQuadraticArcMode(true);
2092 if(GetRepresentation() != SMESH_Actor::ePoint) {
2093 my2DActor->SetQuadraticArcMode(true);
2094 my1DActor->SetQuadraticArcMode(true);
2103 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2105 if(myHighlitableActor->GetQuadraticArcMode())
2106 return SMESH_Actor::eArcs;
2108 return SMESH_Actor::eLines;
2111 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2113 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2114 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2115 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2118 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2120 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2121 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2122 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2123 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2126 #ifndef DISABLE_PLOT2DVIEWER
2127 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2130 my2dHistogram->clearAllPoints();
2132 if(SMESH::Controls::NumericalFunctor* fun =
2133 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2136 if(!my2dHistogram) {
2137 my2dHistogram = new SPlot2d_Histogram();
2138 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2139 my2dHistogram->setIO(anIO);
2142 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2143 std::vector<int> nbEvents;
2144 std::vector<double> funValues;
2145 SMESH_VisualObjDef::TEntityList elems;
2146 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2147 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2148 std::vector<int> elemIds;
2150 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2151 elemIds.push_back( (*e)->GetID());
2153 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2154 double * range = lookupTable->GetRange();
2155 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2157 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2158 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2160 if(funValues.size() >= 2)
2161 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2165 //Color of the histogram
2166 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2167 my2dHistogram->setAutoAssign(true);
2170 myScalarBarActor->GetDistributionColor(rgb);
2171 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2172 my2dHistogram->setColor(aColor);
2176 return my2dHistogram;