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_NodeLabelActor.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ObjectDef.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMDS_UnstructuredGrid.hxx"
36 #include "SMESH_ScalarBarActor.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"
46 #ifndef DISABLE_PLOT2DVIEWER
47 #include <SPlot2d_Histogram.h>
50 #include <vtkProperty.h>
51 #include <vtkTimeStamp.h>
52 #include <vtkObjectFactory.h>
53 #include <vtkShrinkPolyData.h>
54 #include <vtkMergeFilter.h>
56 #include <vtkMatrix4x4.h>
57 #include <vtkUnstructuredGrid.h>
58 #include <vtkPointData.h>
59 #include <vtkCellData.h>
61 #include <vtkMapper.h>
62 #include <vtkRenderer.h>
65 #include <vtkIdList.h>
66 #include <vtkIntArray.h>
68 #include <vtkActor2D.h>
69 #include <vtkProperty2D.h>
70 #include <vtkPolyData.h>
71 #include <vtkTextProperty.h>
73 #include <vtkLookupTable.h>
77 #include <vtkImplicitBoolean.h>
78 #include <vtkImplicitFunctionCollection.h>
80 #include <vtkConfigure.h>
81 #if !defined(VTK_XVERSION)
82 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
85 #include "utilities.h"
88 static int MYDEBUG = 1;
90 static int MYDEBUG = 1;
93 static int aLineWidthInc = 2;
96 SMESH_ActorDef* SMESH_ActorDef::New(){
97 return new SMESH_ActorDef();
101 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 const char* theEntry,
106 SMESH_ActorDef* anActor = NULL;
107 if(theVisualObj->IsValid() ) {
108 anActor = SMESH_ActorDef::New();
109 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
114 anActor->UpdateScalarBar();
120 SMESH_ActorDef::SMESH_ActorDef()
122 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
123 myBaseActor = SMESH_DeviceActor::New();
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();
152 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
153 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
154 myDeltaBrightness = delta;
156 myBackSurfaceProp = vtkProperty::New();
157 bfc = Qtx::mainColorToSecondary(ffc, delta);
158 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
160 my2DActor = SMESH_CellLabelActor::New();
161 my2DActor->SetStoreGemetryMapping(true);
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_CellLabelActor::New();
197 my3DActor->SetStoreGemetryMapping(true);
198 my3DActor->SetUserMatrix(aMatrix);
199 my3DActor->PickableOff();
200 my3DActor->SetProperty(mySurfaceProp);
201 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
202 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
203 aFilter = my3DActor->GetExtractUnstructuredGrid();
204 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
205 aFilter->RegisterCellsWithType(VTK_TETRA);
206 aFilter->RegisterCellsWithType(VTK_VOXEL);
207 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
208 aFilter->RegisterCellsWithType(VTK_WEDGE);
209 aFilter->RegisterCellsWithType(VTK_PYRAMID);
210 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
211 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
212 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
213 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
214 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
215 //#ifdef VTK_HAVE_POLYHEDRON
216 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
217 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
220 my3DExtActor = SMESH_DeviceActor::New();
221 my3DExtActor->SetUserMatrix(aMatrix);
222 my3DExtActor->PickableOff();
223 my3DExtActor->SetProperty(my2DExtProp);
224 my3DExtActor->SetBackfaceProperty(my2DExtProp);
225 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
226 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
227 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
228 aFilter->RegisterCellsWithType(VTK_TETRA);
229 aFilter->RegisterCellsWithType(VTK_VOXEL);
230 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
231 aFilter->RegisterCellsWithType(VTK_WEDGE);
232 aFilter->RegisterCellsWithType(VTK_PYRAMID);
233 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
234 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
235 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
236 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
237 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
238 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
240 //Definition 1D device of the actor
241 //---------------------------------
242 myEdgeProp = vtkProperty::New();
243 myEdgeProp->SetAmbient(1.0);
244 myEdgeProp->SetDiffuse(0.0);
245 myEdgeProp->SetSpecular(0.0);
246 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
247 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
248 myEdgeProp->SetLineWidth(aLineWidth);
250 my1DActor = SMESH_CellLabelActor::New();
251 my1DActor->SetStoreGemetryMapping(true);
252 my1DActor->SetUserMatrix(aMatrix);
253 my1DActor->PickableOff();
254 my1DActor->SetHighlited(true);
255 my1DActor->SetProperty(myEdgeProp);
256 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
257 aFilter = my1DActor->GetExtractUnstructuredGrid();
258 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
259 aFilter->RegisterCellsWithType(VTK_LINE);
260 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
262 my1DProp = vtkProperty::New();
263 my1DProp->DeepCopy(myEdgeProp);
264 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
265 my1DProp->SetPointSize(aElem0DSize);
267 my1DExtProp = vtkProperty::New();
268 my1DExtProp->DeepCopy(myEdgeProp);
269 anRGB[0] = 1 - anRGB[0];
270 anRGB[1] = 1 - anRGB[1];
271 anRGB[2] = 1 - anRGB[2];
272 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
273 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
274 my1DExtProp->SetPointSize(aElem0DSize);
276 my1DExtActor = SMESH_DeviceActor::New();
277 my1DExtActor->SetUserMatrix(aMatrix);
278 my1DExtActor->PickableOff();
279 my1DExtActor->SetHighlited(true);
280 my1DExtActor->SetVisibility(false);
281 my1DExtActor->SetProperty(my1DExtProp);
282 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
283 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
284 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
285 aFilter->RegisterCellsWithType(VTK_LINE);
286 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
289 //Definition 0D device of the actor (0d elements)
290 //-----------------------------------------------
291 my0DProp = vtkProperty::New();
292 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
293 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
294 my0DProp->SetPointSize(aElem0DSize);
296 my0DActor = SMESH_CellLabelActor::New();
297 my0DActor->SetUserMatrix(aMatrix);
298 my0DActor->SetStoreGemetryMapping(true);
299 my0DActor->PickableOff();
300 my0DActor->SetVisibility(false);
301 my0DActor->SetProperty(my0DProp);
302 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
303 aFilter = my0DActor->GetExtractUnstructuredGrid();
304 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
305 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
306 aFilter->RegisterCellsWithType(VTK_VERTEX);
308 //my0DExtProp = vtkProperty::New();
309 //my0DExtProp->DeepCopy(my0DProp);
310 //anRGB[0] = 1 - anRGB[0];
311 //anRGB[1] = 1 - anRGB[1];
312 //anRGB[2] = 1 - anRGB[2];
313 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
314 //my0DExtProp->SetPointSize(aElem0DSize);
316 //my0DExtActor = SMESH_DeviceActor::New();
317 //my0DExtActor->SetUserMatrix(aMatrix);
318 //my0DExtActor->SetStoreClippingMapping(true);
319 //my0DExtActor->PickableOff();
320 //my0DExtActor->SetHighlited(true);
321 //my0DExtActor->SetVisibility(false);
322 //my0DExtActor->SetProperty(my0DExtProp);
323 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
324 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
325 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
326 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
327 //aFilter->RegisterCellsWithType(VTK_VERTEX);
330 //Definition 0D device of the actor (nodes)
331 //-----------------------------------------
332 myNodeProp = vtkProperty::New();
333 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
334 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
336 myNodeActor = SMESH_NodeLabelActor::New();
337 myNodeActor->SetUserMatrix(aMatrix);
338 myNodeActor->SetStoreClippingMapping(true);
339 myNodeActor->PickableOff();
340 myNodeActor->SetVisibility(false);
341 myNodeActor->SetProperty(myNodeProp);
342 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
343 aFilter = myNodeActor->GetExtractUnstructuredGrid();
344 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
346 myNodeExtProp = vtkProperty::New();
347 myNodeExtProp->DeepCopy(myNodeProp);
348 anRGB[0] = 1 - anRGB[0];
349 anRGB[1] = 1 - anRGB[1];
350 anRGB[2] = 1 - anRGB[2];
351 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
353 myNodeExtActor = SMESH_DeviceActor::New();
354 myNodeExtActor->SetUserMatrix(aMatrix);
355 myNodeExtActor->SetStoreClippingMapping(true);
356 myNodeExtActor->PickableOff();
357 myNodeExtActor->SetHighlited(true);
358 myNodeExtActor->SetVisibility(false);
359 myNodeExtActor->SetProperty(myNodeExtProp);
360 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
361 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
362 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
363 aFilter->RegisterCellsWithType(VTK_VERTEX);
365 //Definition of Pickable and Highlitable engines
366 //----------------------------------------------
368 myBaseActor->SetUserMatrix(aMatrix);
369 myBaseActor->SetStoreGemetryMapping(true);
370 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 myOutLineProp = vtkProperty::New();
383 myOutLineProp->SetAmbient(1.0);
384 myOutLineProp->SetDiffuse(0.0);
385 myOutLineProp->SetSpecular(0.0);
386 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
387 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
388 myOutLineProp->SetPointSize(aElem0DSize); // ??
389 myOutLineProp->SetRepresentation(1);
391 myPreselectProp = vtkProperty::New();
392 myPreselectProp->SetAmbient(1.0);
393 myPreselectProp->SetDiffuse(0.0);
394 myPreselectProp->SetSpecular(0.0);
395 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
396 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
397 myPreselectProp->SetPointSize(aElem0DSize); // ??
398 myPreselectProp->SetRepresentation(1);
400 myHighlitableActor = SMESH_DeviceActor::New();
401 myHighlitableActor->SetUserMatrix(aMatrix);
402 myHighlitableActor->PickableOff();
403 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
410 myControlMode = eNone;
411 myControlActor = my2DActor;
413 //Definition of myScalarBarActor
414 //------------------------------
415 myLookupTable = vtkLookupTable::New();
416 //Fix for Bug PAL5195 - SMESH764:
417 //Controls - Aspect Ratio: incorrect colors of the best and worst values
418 myLookupTable->SetHueRange(0.667,0.0);
420 myScalarBarActor = SMESH_ScalarBarActor::New();
421 myScalarBarActor->SetVisibility(false);
422 myScalarBarActor->SetLookupTable(myLookupTable);
425 //Incorrect "Min value" in Scalar Bar in Mesh:
426 // myScalarBarActor->SetLabelFormat("%.4g");
427 // changes was commented because of regression bug IPAL 19981
429 mgr = SUIT_Session::session()->resourceMgr();
433 myEntityMode = eAllEntity;
436 myImplicitBoolean = vtkImplicitBoolean::New();
437 myImplicitBoolean->SetOperationTypeToIntersection();
439 //Quadratic 2D elements representation
440 //-----------------------------------------------------------------------------
441 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
442 if(aQuadratic2DMode == 0){
443 myHighlitableActor->SetQuadraticArcMode(false);
444 my2DActor->SetQuadraticArcMode(false);
445 my1DActor->SetQuadraticArcMode(false);
447 else if(aQuadratic2DMode == 1){
448 myHighlitableActor->SetQuadraticArcMode(true);
449 my2DActor->SetQuadraticArcMode(true);
450 my1DActor->SetQuadraticArcMode(true);
453 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
454 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
455 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
457 // Set colors of the name actor
458 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
459 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
460 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
461 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
463 #ifndef DISABLE_PLOT2DVIEWER
470 SMESH_ActorDef::~SMESH_ActorDef()
472 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
474 #ifndef DISABLE_PLOT2DVIEWER
476 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
477 delete my2dHistogram;
481 // caught by SMESHGUI::ProcessEvents() static method
482 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
484 myScalarBarActor->Delete();
485 myLookupTable->Delete();
487 mySurfaceProp->Delete();
488 myBackSurfaceProp->Delete();
489 myOutLineProp->Delete();
491 myEdgeProp->Delete();
492 myHighlightProp->Delete();
493 myPreselectProp->Delete();
495 myNodeProp->Delete();
496 myNodeExtProp->Delete();
501 //my0DExtProp->Delete();
502 //my0DExtActor->Delete();
507 my1DExtProp->Delete();
508 my1DExtActor->Delete();
511 my2DExtProp->Delete();
512 my2DExtActor->Delete();
514 my3DExtActor->Delete();
516 myNodeActor->Delete();
517 myBaseActor->Delete();
519 myNodeExtActor->Delete();
520 myHighlitableActor->Delete();
522 myImplicitBoolean->Delete();
524 myTimeStamp->Delete();
528 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
531 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
532 SetRepresentation(GetRepresentation());
533 myTimeStamp->Modified();
537 bool SMESH_ActorDef::GetPointsLabeled() {
538 return myNodeActor && myNodeActor->GetPointsLabeled();
541 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
544 my3DActor->SetCellsLabeled(theIsCellsLabeled);
547 my2DActor->SetCellsLabeled(theIsCellsLabeled);
550 my1DActor->SetCellsLabeled(theIsCellsLabeled);
553 my0DActor->SetCellsLabeled(theIsCellsLabeled);
555 myTimeStamp->Modified();
559 bool SMESH_ActorDef::GetCellsLabeled() {
562 result = result || my3DActor->GetCellsLabeled();
565 result = result || my2DActor->GetCellsLabeled();
568 result = result || my1DActor->GetCellsLabeled();
571 result = result || my0DActor->GetCellsLabeled();
577 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
579 myIsFacesOriented = theIsFacesOriented;
581 my2DActor->SetFacesOriented(theIsFacesOriented);
582 my3DActor->SetFacesOriented(theIsFacesOriented);
584 myTimeStamp->Modified();
587 bool SMESH_ActorDef::GetFacesOriented()
589 return myIsFacesOriented;
592 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
594 my2DActor->SetFacesOrientationColor( theColor );
595 my3DActor->SetFacesOrientationColor( theColor );
598 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
600 my3DActor->GetFacesOrientationColor( theColor );
603 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
605 my2DActor->SetFacesOrientationScale( theScale );
606 my3DActor->SetFacesOrientationScale( theScale );
609 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
611 return my3DActor->GetFacesOrientationScale();
614 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
616 my2DActor->SetFacesOrientation3DVectors( theState );
617 my3DActor->SetFacesOrientation3DVectors( theState );
620 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
622 return my3DActor->GetFacesOrientation3DVectors();
628 SetControlMode(eControl theMode)
630 SetControlMode(theMode,true);
636 SetControlMode(eControl theMode,
637 bool theCheckEntityMode)
639 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
643 myControlMode = eNone;
644 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
646 my0DActor->GetMapper()->SetScalarVisibility(false);
647 my1DActor->GetMapper()->SetScalarVisibility(false);
648 my2DActor->GetMapper()->SetScalarVisibility(false);
649 my3DActor->GetMapper()->SetScalarVisibility(false);
650 myScalarBarActor->SetVisibility(false);
652 bool anIsScalarVisible = theMode > eNone;
654 if(anIsScalarVisible) {
658 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
659 aControl->SetPrecision( myControlsPrecision );
660 myFunctor.reset( aControl );
661 myControlActor = my1DActor;
666 myFunctor.reset(new SMESH::Controls::Length2D());
667 myControlActor = my2DActor;
671 myFunctor.reset(new SMESH::Controls::FreeBorders());
672 myControlActor = my1DActor;
675 myFunctor.reset(new SMESH::Controls::FreeEdges());
676 myControlActor = my2DActor;
679 myFunctor.reset(new SMESH::Controls::FreeNodes());
680 myControlActor = myNodeActor;
683 myFunctor.reset(new SMESH::Controls::FreeFaces());
684 myControlActor = my2DActor;
686 case eBareBorderFace:
687 myFunctor.reset(new SMESH::Controls::BareBorderFace());
688 myControlActor = my2DActor;
690 case eOverConstrainedFace:
691 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
692 myControlActor = my2DActor;
694 case eMultiConnection:
695 myFunctor.reset(new SMESH::Controls::MultiConnection());
696 myControlActor = my1DActor;
698 case eMultiConnection2D:
699 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
700 myControlActor = my2DActor;
704 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
705 aControl->SetPrecision( myControlsPrecision );
706 myFunctor.reset( aControl );
707 myControlActor = my2DActor;
712 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
713 aControl->SetPrecision( myControlsPrecision );
714 myFunctor.reset( aControl );
715 myControlActor = my2DActor;
720 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
721 aControl->SetPrecision( myControlsPrecision );
722 myFunctor.reset( aControl );
723 myControlActor = my2DActor;
728 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
729 aControl->SetPrecision( myControlsPrecision );
730 myFunctor.reset( aControl );
731 myControlActor = my3DActor;
736 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
737 aControl->SetPrecision( myControlsPrecision );
738 myFunctor.reset( aControl );
739 myControlActor = my3DActor;
742 case eMaxElementLength2D:
744 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
745 aControl->SetPrecision( myControlsPrecision );
746 myFunctor.reset( aControl );
747 myControlActor = my2DActor;
750 case eMaxElementLength3D:
752 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
753 aControl->SetPrecision( myControlsPrecision );
754 myFunctor.reset( aControl );
755 myControlActor = my3DActor;
758 case eBareBorderVolume:
760 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
761 myControlActor = my3DActor;
764 case eOverConstrainedVolume:
766 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
767 myControlActor = my3DActor;
772 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
773 aControl->SetPrecision( myControlsPrecision );
774 myFunctor.reset( aControl );
775 myControlActor = my2DActor;
780 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
781 aControl->SetPrecision( myControlsPrecision );
782 myFunctor.reset( aControl );
783 myControlActor = my2DActor;
788 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
789 aControl->SetPrecision( myControlsPrecision );
790 myFunctor.reset( aControl );
791 myControlActor = my2DActor;
798 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
799 vtkIdType aNbCells = aGrid->GetNumberOfCells();
801 myControlMode = theMode;
802 switch(myControlMode){
804 myNodeExtActor->SetExtControlMode(myFunctor);
808 my1DExtActor->SetExtControlMode(myFunctor);
811 case eBareBorderFace:
812 case eOverConstrainedFace:
813 my2DExtActor->SetExtControlMode(myFunctor);
815 case eBareBorderVolume:
816 case eOverConstrainedVolume:
817 my3DExtActor->SetExtControlMode(myFunctor);
820 case eMultiConnection2D:
821 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
822 UpdateDistribution();
825 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
826 UpdateDistribution();
830 if(theCheckEntityMode){
831 if(myControlActor == my1DActor)
832 SetEntityMode(eEdges);
833 else if(myControlActor == my2DActor){
834 switch(myControlMode){
838 case eMultiConnection2D:
839 //SetEntityMode(eEdges);
840 SetEntityMode(eFaces);
843 SetEntityMode(eFaces);
845 }else if(myControlActor == my3DActor)
846 SetEntityMode(eVolumes);
851 if(theCheckEntityMode)
852 myEntityMode = eAllEntity;
856 SetRepresentation(GetRepresentation());
858 myTimeStamp->Modified();
863 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
864 theRenderer->AddActor(myBaseActor);
865 theRenderer->AddActor(myNodeExtActor);
866 theRenderer->AddActor(my1DExtActor);
868 my3DActor->AddToRender(theRenderer);
869 my3DExtActor->AddToRender(theRenderer);
870 my2DActor->AddToRender(theRenderer);
871 my2DExtActor->AddToRender(theRenderer);
872 myNodeActor->AddToRender(theRenderer);
873 my1DActor->AddToRender(theRenderer);
874 my0DActor->AddToRender(theRenderer);
875 //theRenderer->AddActor(my0DExtActor);
877 theRenderer->AddActor(myHighlitableActor);
879 theRenderer->AddActor2D(myScalarBarActor);
881 // the superclass' method should be called at the end
882 // (in particular, for correct work of selection)
883 SALOME_Actor::AddToRender(theRenderer);
886 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
887 SALOME_Actor::RemoveFromRender(theRenderer);
889 theRenderer->RemoveActor(myBaseActor);
891 theRenderer->RemoveActor(myNodeExtActor);
893 theRenderer->RemoveActor(myHighlitableActor);
895 //theRenderer->RemoveActor(my0DExtActor);
897 theRenderer->RemoveActor(my1DExtActor);
899 my2DActor->RemoveFromRender(theRenderer);
900 my2DExtActor->RemoveFromRender(theRenderer);
901 my3DActor->RemoveFromRender(theRenderer);
902 my3DExtActor->RemoveFromRender(theRenderer);
903 myNodeActor->RemoveFromRender(theRenderer);
904 my0DActor->RemoveFromRender(theRenderer);
905 my1DActor->RemoveFromRender(theRenderer);
907 theRenderer->RemoveActor(myScalarBarActor);
911 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
912 const char* theEntry,
916 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
920 myVisualObj = theVisualObj;
921 myVisualObj->Update(theIsClear);
923 myNodeActor->Init(myVisualObj,myImplicitBoolean);
924 myBaseActor->Init(myVisualObj,myImplicitBoolean);
926 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
928 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
930 my0DActor->Init(myVisualObj,myImplicitBoolean);
931 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
933 my1DActor->Init(myVisualObj,myImplicitBoolean);
934 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
936 my2DActor->Init(myVisualObj,myImplicitBoolean);
937 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
938 my3DActor->Init(myVisualObj,myImplicitBoolean);
939 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
941 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
942 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
944 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
945 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
947 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
948 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
949 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
950 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
952 vtkFloatingPointType aFactor, aUnits;
953 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
954 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
955 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
957 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
961 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
962 SetIsShrunkable(true);
964 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
966 int aMode = mgr->integerValue( "SMESH", "display_mode" );
967 SetRepresentation(-1);
970 SetRepresentation(eEdge);
971 }else if(aMode == 1){
972 SetRepresentation(eSurface);
973 }else if(aMode == 2){
974 SetRepresentation(ePoint);
981 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
982 SetIsDisplayNameActor( true );
984 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
985 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
986 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
988 myTimeStamp->Modified();
994 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
995 return myNodeActor->GetBounds();
999 vtkDataSet* SMESH_ActorDef::GetInput(){
1000 return GetUnstructuredGrid();
1004 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1005 Superclass::SetTransform(theTransform);
1007 myNodeActor->SetTransform(theTransform);
1008 myBaseActor->SetTransform(theTransform);
1010 myHighlitableActor->SetTransform(theTransform);
1012 myNodeExtActor->SetTransform(theTransform);
1014 my0DActor->SetTransform(theTransform);
1015 //my0DExtActor->SetTransform(theTransform);
1017 my1DActor->SetTransform(theTransform);
1018 my1DExtActor->SetTransform(theTransform);
1020 my2DActor->SetTransform(theTransform);
1021 my2DExtActor->SetTransform(theTransform);
1022 my3DActor->SetTransform(theTransform);
1023 my3DExtActor->SetTransform(theTransform);
1029 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1030 vtkLODActor::SetMapper(theMapper);
1034 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1035 SALOME_Actor::ShallowCopy(prop);
1039 vtkMapper* SMESH_ActorDef::GetMapper(){
1040 return myPickableActor->GetMapper();
1044 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1045 return myVisualObj->GetUnstructuredGrid();
1049 bool SMESH_ActorDef::IsInfinitive(){
1050 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1052 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1053 ( aDataSet->GetNumberOfCells() == 1 &&
1054 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1055 return SALOME_Actor::IsInfinitive();
1059 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1060 if ( myIsShrinkable == theShrunkable )
1062 myIsShrinkable = theShrunkable;
1066 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1067 return myBaseActor->GetShrinkFactor();
1070 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1071 myBaseActor->SetShrinkFactor(theValue);
1073 my1DActor->SetShrinkFactor(theValue);
1074 my1DExtActor->SetShrinkFactor(theValue);
1076 my2DActor->SetShrinkFactor(theValue);
1077 my2DExtActor->SetShrinkFactor(theValue);
1078 my3DActor->SetShrinkFactor(theValue);
1079 my3DExtActor->SetShrinkFactor(theValue);
1080 my3DExtActor->SetShrinkFactor(theValue);
1081 myHighlitableActor->SetShrinkFactor(theValue);
1086 void SMESH_ActorDef::SetShrink(){
1087 if(!myIsShrinkable) return;
1089 myBaseActor->SetShrink();
1091 my1DActor->SetShrink();
1092 my1DExtActor->SetShrink();
1094 my2DActor->SetShrink();
1095 my2DExtActor->SetShrink();
1096 my3DActor->SetShrink();
1097 my3DExtActor->SetShrink();
1098 myHighlitableActor->SetShrink();
1104 void SMESH_ActorDef::UnShrink(){
1105 if(!myIsShrunk) return;
1107 myBaseActor->UnShrink();
1109 my1DActor->UnShrink();
1110 my1DExtActor->UnShrink();
1112 my2DActor->UnShrink();
1113 my2DExtActor->UnShrink();
1114 my3DActor->UnShrink();
1115 my3DExtActor->UnShrink();
1116 myHighlitableActor->UnShrink();
1123 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1124 return myPickableActor->GetNodeObjId(theVtkID);
1127 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1128 return myPickableActor->GetNodeCoord(theObjID);
1132 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1133 return myPickableActor->GetElemObjId(theVtkID);
1136 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1137 return myPickableActor->GetElemCell(theObjID);
1141 void SMESH_ActorDef::SetVisibility(int theMode){
1142 SetVisibility(theMode,true);
1146 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1147 SALOME_Actor::SetVisibility(theMode);
1149 myNodeActor->VisibilityOff();
1150 myBaseActor->VisibilityOff();
1152 myNodeExtActor->VisibilityOff();
1154 my0DActor->VisibilityOff();
1155 //my0DExtActor->VisibilityOff();
1157 my1DActor->VisibilityOff();
1158 my1DExtActor->VisibilityOff();
1160 my2DActor->VisibilityOff();
1161 my2DExtActor->VisibilityOff();
1162 my3DActor->VisibilityOff();
1163 my3DExtActor->VisibilityOff();
1165 myScalarBarActor->VisibilityOff();
1167 if(GetVisibility()){
1168 if(theIsUpdateRepersentation)
1169 SetRepresentation(GetRepresentation());
1171 if(myControlMode != eNone){
1172 switch(myControlMode){
1174 myNodeExtActor->VisibilityOn();
1178 my1DExtActor->VisibilityOn();
1181 case eBareBorderFace:
1182 case eOverConstrainedFace:
1183 my2DExtActor->VisibilityOn();
1185 case eBareBorderVolume:
1186 case eOverConstrainedVolume:
1187 my3DExtActor->VisibilityOn();
1190 case eMultiConnection2D:
1191 my1DExtActor->VisibilityOn();
1193 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1194 myScalarBarActor->VisibilityOn();
1198 if(myRepresentation != ePoint)
1199 myPickableActor->VisibilityOn();
1201 myNodeActor->VisibilityOn();
1204 if(myEntityMode & e0DElements){
1205 my0DActor->VisibilityOn();
1208 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1209 my1DActor->VisibilityOn();
1212 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1213 my2DActor->VisibilityOn();
1216 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1217 my3DActor->VisibilityOn();
1220 if(myNodeActor->GetPointsLabeled()){
1221 myNodeActor->VisibilityOn();
1225 my0DActor->UpdateLabels();
1228 my1DActor->UpdateLabels();
1231 my2DActor->UpdateLabels();
1234 my3DActor->UpdateLabels();
1236 #ifndef DISABLE_PLOT2DVIEWER
1238 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1245 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1247 myEntityState = eAllEntity;
1249 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1250 myEntityState &= ~e0DElements;
1251 theMode &= ~e0DElements;
1254 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1255 myEntityState &= ~eEdges;
1259 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1260 myEntityState &= ~eFaces;
1264 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1265 myEntityState &= ~eVolumes;
1266 theMode &= ~eVolumes;
1270 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1271 theMode |= e0DElements;
1273 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1276 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1279 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1280 theMode |= eVolumes;
1283 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1285 myEntityMode = theMode;
1286 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1287 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1288 aFilter->ClearRegisteredCellsWithType();
1289 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1291 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1292 aHightFilter->ClearRegisteredCellsWithType();
1293 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1295 if (myEntityMode & e0DElements) {
1296 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1297 aFilter->RegisterCellsWithType(VTK_VERTEX);
1298 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1301 if (myEntityMode & eEdges) {
1302 if (MYDEBUG) MESSAGE("EDGES");
1303 aFilter->RegisterCellsWithType(VTK_LINE);
1304 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1306 aHightFilter->RegisterCellsWithType(VTK_LINE);
1307 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1310 if (myEntityMode & eFaces) {
1311 if (MYDEBUG) MESSAGE("FACES");
1312 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1313 aFilter->RegisterCellsWithType(VTK_POLYGON);
1314 aFilter->RegisterCellsWithType(VTK_QUAD);
1315 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1316 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1318 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1319 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1320 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1321 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1322 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1325 if (myEntityMode & eVolumes) {
1326 if (MYDEBUG) MESSAGE("VOLUMES");
1327 aFilter->RegisterCellsWithType(VTK_TETRA);
1328 aFilter->RegisterCellsWithType(VTK_VOXEL);
1329 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1330 aFilter->RegisterCellsWithType(VTK_WEDGE);
1331 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1332 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1333 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1334 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1335 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1336 //#ifdef VTK_HAVE_POLYHEDRON
1337 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1340 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1341 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1342 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1343 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1344 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1345 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1346 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1347 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1348 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1349 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1350 //#ifdef VTK_HAVE_POLYHEDRON
1351 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1355 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1356 SetVisibility(GetVisibility(),false);
1359 void SMESH_ActorDef::SetRepresentation (int theMode)
1361 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1362 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1363 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1366 myRepresentation = eSurface;
1367 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1368 myRepresentation = eEdge;
1369 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1370 myRepresentation = ePoint;
1375 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1378 if (!aNbFaces && !aNbVolumes) return;
1381 myRepresentation = theMode;
1384 if (!GetUnstructuredGrid()->GetNumberOfCells())
1385 myRepresentation = ePoint;
1388 if (myRepresentation == ePoint) {
1396 myPickableActor = myBaseActor;
1397 myNodeActor->SetVisibility(false);
1398 myNodeExtActor->SetVisibility(false);
1399 vtkProperty *aProp = NULL, *aBackProp = NULL;
1400 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1401 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1402 switch (myRepresentation) {
1404 myPickableActor = myNodeActor;
1405 myNodeActor->SetVisibility(true);
1406 aQuadraticMode = SMESH_Actor::eLines;
1407 aProp = aBackProp = myNodeProp;
1408 aReperesent = SMESH_DeviceActor::ePoint;
1411 aProp = aBackProp = myEdgeProp;
1412 aReperesent = SMESH_DeviceActor::eInsideframe;
1415 aProp = mySurfaceProp;
1416 aBackProp = myBackSurfaceProp;
1417 aReperesent = SMESH_DeviceActor::eSurface;
1421 my2DActor->SetProperty(aProp);
1422 my2DActor->SetBackfaceProperty(aBackProp);
1423 my2DActor->SetRepresentation(aReperesent);
1425 if(aQuadraticMode == SMESH_Actor::eLines)
1426 my2DActor->SetQuadraticArcMode(false);
1427 else if(aQuadraticMode == SMESH_Actor::eArcs)
1428 my2DActor->SetQuadraticArcMode(true);
1430 my2DExtActor->SetRepresentation(aReperesent);
1432 my3DActor->SetProperty(aProp);
1433 my3DActor->SetBackfaceProperty(aBackProp);
1434 my3DActor->SetRepresentation(aReperesent);
1436 //my0DExtActor->SetVisibility(false);
1437 my1DExtActor->SetVisibility(false);
1438 my2DExtActor->SetVisibility(false);
1439 my3DExtActor->SetVisibility(false);
1442 //my0DActor->SetProperty(aProp);
1443 //my0DActor->SetBackfaceProperty(aBackProp);
1444 my0DActor->SetRepresentation(aReperesent);
1445 //my0DExtActor->SetRepresentation(aReperesent);
1447 switch(myControlMode){
1449 case eMultiConnection:
1450 aProp = aBackProp = my1DProp;
1451 if(myRepresentation != ePoint)
1452 aReperesent = SMESH_DeviceActor::eInsideframe;
1456 if(aQuadraticMode == SMESH_Actor::eLines)
1457 my1DActor->SetQuadraticArcMode(false);
1458 else if(aQuadraticMode == SMESH_Actor::eArcs)
1459 my1DActor->SetQuadraticArcMode(true);
1461 my1DActor->SetProperty(aProp);
1462 my1DActor->SetBackfaceProperty(aBackProp);
1463 my1DActor->SetRepresentation(aReperesent);
1465 my1DExtActor->SetRepresentation(aReperesent);
1467 if(myIsPointsVisible)
1468 myPickableActor = myNodeActor;
1469 if(GetPointRepresentation())
1470 myNodeActor->SetVisibility(true);
1472 SetMapper(myPickableActor->GetMapper());
1474 SetVisibility(GetVisibility(),false);
1480 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1481 if ( myIsPointsVisible == theIsPointsVisible )
1483 myIsPointsVisible = theIsPointsVisible;
1484 SetRepresentation(GetRepresentation());
1487 bool SMESH_ActorDef::GetPointRepresentation(){
1488 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1492 void SMESH_ActorDef::UpdateHighlight(){
1493 myHighlitableActor->SetHighlited(false);
1494 myHighlitableActor->SetVisibility(false);
1496 bool anIsVisible = GetVisibility();
1498 switch(myRepresentation){
1499 case SMESH_DeviceActor::eSurface:
1500 case SMESH_DeviceActor::eWireframe:
1502 if(myIsHighlighted) {
1503 myHighlitableActor->SetProperty(myHighlightProp);
1504 }else if(myIsPreselected){
1505 myHighlitableActor->SetProperty(myPreselectProp);
1506 } else if(anIsVisible){
1507 (myRepresentation == eSurface) ?
1508 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1510 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1511 myHighlitableActor->SetHighlited(anIsVisible);
1512 myHighlitableActor->GetExtractUnstructuredGrid()->
1513 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1514 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1516 myHighlitableActor->SetVisibility(anIsVisible);
1519 case SMESH_DeviceActor::ePoint:
1521 if(myIsHighlighted) {
1522 myNodeActor->SetProperty(myHighlightProp);
1523 }else if(myIsPreselected) {
1524 myNodeActor->SetProperty(myPreselectProp);
1525 } else if(anIsVisible) {
1526 myNodeActor->SetProperty(myNodeProp);
1528 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1529 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1536 void SMESH_ActorDef::highlight(bool theHighlight){
1537 if ( myIsHighlighted == theHighlight )
1539 myIsHighlighted = theHighlight;
1544 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1545 if ( myIsPreselected == thePreselect )
1547 myIsPreselected = thePreselect;
1553 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1555 if (myPickableActor->GetIsOpaque())
1557 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1565 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1567 if (!myPickableActor->GetIsOpaque())
1569 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1577 void SMESH_ActorDef::Render(vtkRenderer *ren){
1578 unsigned long aTime = myTimeStamp->GetMTime();
1579 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1580 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1581 if(anObjTime > aTime || aClippingTime > aTime)
1586 void SMESH_ActorDef::Update(){
1587 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1589 if(GetControlMode() != eNone) {
1590 unsigned long aTime = myTimeStamp->GetMTime();
1591 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1592 if (anObjTime > aTime)
1593 SetControlMode(GetControlMode(),false);
1597 myNodeActor->UpdateLabels();
1600 my0DActor->UpdateLabels();
1603 my1DActor->UpdateLabels();
1606 my2DActor->UpdateLabels();
1609 my3DActor->UpdateLabels();
1611 if(myIsFacesOriented){
1612 SetFacesOriented(myIsFacesOriented);
1614 SetEntityMode(GetEntityMode());
1615 SetVisibility(GetVisibility());
1617 myTimeStamp->Modified();
1622 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1623 SALOME_Actor::ReleaseGraphicsResources(renWin);
1625 myPickableActor->ReleaseGraphicsResources(renWin);
1629 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1630 vtkFloatingPointType* aColor = theProperty->GetColor();
1637 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1638 mySurfaceProp->SetOpacity(theValue);
1639 myBackSurfaceProp->SetOpacity(theValue);
1640 myEdgeProp->SetOpacity(theValue);
1641 myNodeProp->SetOpacity(theValue);
1643 my1DProp->SetOpacity(theValue);
1647 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1648 return mySurfaceProp->GetOpacity();
1652 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1653 mySurfaceProp->SetColor(r,g,b);
1654 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1655 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1656 aGroupObj->GetElementType() == SMDSAbs_Volume )
1657 myNameActor->SetBackgroundColor(r,g,b);
1659 myDeltaBrightness = delta;
1660 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1661 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1665 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1666 ::GetColor(mySurfaceProp,r,g,b);
1667 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1668 delta = myDeltaBrightness;
1671 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1672 myEdgeProp->SetColor(r,g,b);
1673 my1DProp->SetColor(r,g,b);
1674 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1675 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1676 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1677 myNameActor->SetBackgroundColor(r,g,b);
1681 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1682 ::GetColor(myEdgeProp,r,g,b);
1685 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1686 myOutLineProp->SetColor(r,g,b);
1690 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1691 ::GetColor(myOutLineProp,r,g,b);
1695 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1696 myNodeProp->SetColor(r,g,b);
1697 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1698 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1699 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1700 myNameActor->SetBackgroundColor(r,g,b);
1704 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1705 ::GetColor(myNodeProp,r,g,b);
1708 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1709 my0DProp->SetColor(r,g,b);
1710 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1711 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1712 myNameActor->SetBackgroundColor(r,g,b);
1716 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1717 ::GetColor(my0DProp,r,g,b);
1720 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1721 myHighlightProp->SetColor(r,g,b);
1725 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1726 ::GetColor(myHighlightProp,r,g,b);
1729 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1730 myPreselectProp->SetColor(r,g,b);
1734 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1735 ::GetColor(myPreselectProp,r,g,b);
1739 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1740 return myEdgeProp->GetLineWidth();
1744 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1745 myEdgeProp->SetLineWidth(theVal);
1747 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1748 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1754 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1755 my0DProp->SetPointSize(theVal);
1759 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1760 return my0DProp->GetPointSize();
1763 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1765 return myVisualObj->GetElemDimension( theObjId );
1770 IsImplicitFunctionUsed() const
1772 return myBaseActor->IsImplicitFunctionUsed();
1776 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1778 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1779 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1781 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1783 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1785 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1786 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1788 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1789 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1791 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1792 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1793 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1794 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1798 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1801 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1802 myCippingPlaneCont.push_back(thePlane);
1803 if(!IsImplicitFunctionUsed())
1804 SetImplicitFunctionUsed(true);
1805 myNodeActor->UpdateLabels();
1807 return myCippingPlaneCont.size();
1812 RemoveAllClippingPlanes()
1814 myImplicitBoolean->GetFunction()->RemoveAllItems();
1815 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1816 myCippingPlaneCont.clear();
1817 SetImplicitFunctionUsed(false);
1818 myNodeActor->UpdateLabels();
1823 GetNumberOfClippingPlanes()
1825 return myCippingPlaneCont.size();
1830 GetClippingPlane(vtkIdType theID)
1832 if(theID >= myCippingPlaneCont.size())
1834 return myCippingPlaneCont[theID].Get();
1837 void SMESH_ActorDef::UpdateScalarBar()
1839 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1843 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1845 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1846 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1848 aScalarBarTitleProp->SetFontFamilyToArial();
1850 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1852 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1853 if ( f.family() == "Arial" )
1854 aScalarBarTitleProp->SetFontFamilyToArial();
1855 else if ( f.family() == "Courier" )
1856 aScalarBarTitleProp->SetFontFamilyToCourier();
1857 else if ( f.family() == "Times" )
1858 aScalarBarTitleProp->SetFontFamilyToTimes();
1861 aScalarBarTitleProp->BoldOn();
1863 aScalarBarTitleProp->BoldOff();
1866 aScalarBarTitleProp->ItalicOn();
1868 aScalarBarTitleProp->ItalicOff();
1871 aScalarBarTitleProp->ShadowOn();
1873 aScalarBarTitleProp->ShadowOff();
1876 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1877 aScalarBarTitleProp->Delete();
1879 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1881 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1882 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1884 aScalarBarLabelProp->SetFontFamilyToArial();
1885 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1887 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1888 if( f.family() == "Arial" )
1889 aScalarBarLabelProp->SetFontFamilyToArial();
1890 else if( f.family() == "Courier" )
1891 aScalarBarLabelProp->SetFontFamilyToCourier();
1892 else if( f.family() == "Times" )
1893 aScalarBarLabelProp->SetFontFamilyToTimes();
1896 aScalarBarLabelProp->BoldOn();
1898 aScalarBarLabelProp->BoldOff();
1901 aScalarBarLabelProp->ItalicOn();
1903 aScalarBarLabelProp->ItalicOff();
1906 aScalarBarLabelProp->ShadowOn();
1908 aScalarBarLabelProp->ShadowOff();
1911 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1912 aScalarBarLabelProp->Delete();
1914 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1915 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1917 myScalarBarActor->SetOrientationToHorizontal();
1919 myScalarBarActor->SetOrientationToVertical();
1922 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1923 if( mgr->hasValue( "SMESH", name + "x" ) )
1924 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1926 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1927 if( mgr->hasValue( "SMESH", name + "y" ) )
1928 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1929 myScalarBarActor->SetPosition( aXVal, aYVal );
1931 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1932 if( mgr->hasValue( "SMESH", name + "width" ) )
1933 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1934 myScalarBarActor->SetWidth( aWVal );
1936 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1937 if( mgr->hasValue( "SMESH", name + "height" ) )
1938 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1939 myScalarBarActor->SetHeight( aHVal );
1942 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1943 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1944 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1947 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1948 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1949 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
1951 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
1952 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
1954 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
1955 myScalarBarActor->SetDistributionColoringType(coloringType);
1957 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
1958 QColor(255, 255, 255));
1960 rgb[0]= distributionColor.red()/255.;
1961 rgb[1]= distributionColor.green()/255.;
1962 rgb[2]= distributionColor.blue()/255.;
1963 myScalarBarActor->SetDistributionColor(rgb);
1968 void SMESH_ActorDef::UpdateDistribution()
1970 if(SMESH::Controls::NumericalFunctor* fun =
1971 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
1973 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
1974 std::vector<int> nbEvents;
1975 std::vector<double> funValues;
1976 SMESH_VisualObjDef::TEntityList elems;
1977 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
1978 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
1979 std::vector<int> elemIds;
1980 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
1981 elemIds.push_back( (*e)->GetID());
1982 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1983 double * range = lookupTable->GetRange();
1984 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
1985 myScalarBarActor->SetDistribution(nbEvents);
1989 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
1992 case SMESH_Actor::eLines :
1993 myHighlitableActor->SetQuadraticArcMode(false);
1994 my2DActor->SetQuadraticArcMode(false);
1995 my1DActor->SetQuadraticArcMode(false);
1997 case SMESH_Actor::eArcs :
1998 myHighlitableActor->SetQuadraticArcMode(true);
1999 if(GetRepresentation() != SMESH_Actor::ePoint) {
2000 my2DActor->SetQuadraticArcMode(true);
2001 my1DActor->SetQuadraticArcMode(true);
2010 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2012 if(myHighlitableActor->GetQuadraticArcMode())
2013 return SMESH_Actor::eArcs;
2015 return SMESH_Actor::eLines;
2018 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2020 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2021 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2022 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2025 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2027 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2028 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2029 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2030 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2033 #ifndef DISABLE_PLOT2DVIEWER
2034 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2037 my2dHistogram->clearAllPoints();
2039 if(SMESH::Controls::NumericalFunctor* fun =
2040 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2043 if(!my2dHistogram) {
2044 my2dHistogram = new SPlot2d_Histogram();
2045 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2046 my2dHistogram->setIO(anIO);
2049 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2050 std::vector<int> nbEvents;
2051 std::vector<double> funValues;
2052 SMESH_VisualObjDef::TEntityList elems;
2053 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2054 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2055 std::vector<int> elemIds;
2057 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2058 elemIds.push_back( (*e)->GetID());
2060 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2061 double * range = lookupTable->GetRange();
2062 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2064 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2065 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2067 if(funValues.size() >= 2)
2068 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2072 //Color of the histogram
2073 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2074 my2dHistogram->setAutoAssign(true);
2077 myScalarBarActor->GetDistributionColor(rgb);
2078 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2079 my2dHistogram->setColor(aColor);
2083 return my2dHistogram;