1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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"
30 #include "SMDS_UnstructuredGrid.hxx"
31 #include "SMESH_ActorProps.h"
32 #include "SMESH_ActorUtils.h"
33 #include "SMESH_CellLabelActor.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMESH_DeviceActor.h"
36 #include "SMESH_NodeLabelActor.h"
37 #include "SMESH_ObjectDef.h"
38 #include "SMESH_SVTKActor.h"
39 #include "SMESH_ScalarBarActor.h"
42 #include <SALOME_InteractiveObject.hxx>
43 #include <SUIT_ResourceMgr.h>
44 #include <SUIT_Session.h>
45 #include <VTKViewer_ExtractUnstructuredGrid.h>
46 #include <VTKViewer_FramedTextActor.h>
48 #ifndef DISABLE_PLOT2DVIEWER
49 #include <SPlot2d_Histogram.h>
52 #include <vtkProperty.h>
53 #include <vtkTimeStamp.h>
54 #include <vtkObjectFactory.h>
55 #include <vtkShrinkPolyData.h>
56 #include <vtkMergeFilter.h>
58 #include <vtkMatrix4x4.h>
59 #include <vtkUnstructuredGrid.h>
60 #include <vtkPointData.h>
61 #include <vtkCellData.h>
63 #include <vtkMapper.h>
64 #include <vtkRenderer.h>
67 #include <vtkIdList.h>
68 #include <vtkIntArray.h>
70 #include <vtkActor2D.h>
71 #include <vtkProperty2D.h>
72 #include <vtkPolyData.h>
73 #include <vtkTextProperty.h>
75 #include <vtkLookupTable.h>
79 #include <vtkPlaneCollection.h>
80 #include <vtkImplicitBoolean.h>
81 #include <vtkImplicitFunctionCollection.h>
83 #include "utilities.h"
86 static int MYDEBUG = 0;
88 static int MYDEBUG = 0;
91 SMESH_ActorDef* SMESH_ActorDef::New(){
92 return new SMESH_ActorDef();
96 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
101 SMESH_ActorDef* anActor = NULL;
102 if(theVisualObj->IsValid() ) {
103 anActor = SMESH_ActorDef::New();
104 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
109 anActor->UpdateScalarBar();
115 SMESH_ActorDef::SMESH_ActorDef()
117 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
119 SALOME_Actor::SetVisibility(false); // avoid update of pipelines
121 myBaseActor = SMESH_DeviceActor::New();
123 myTimeStamp = vtkTimeStamp::New();
125 myIsPointsVisible = false;
126 myIsEntityModeCache = false;
127 myRepresentationCache = 0;
129 myHighlightActor = SMESH_SVTKActor::New();
130 myHighlightActor->Delete(); // vtkSmartPointer!
131 myHighlightActor->Initialize();
133 myPreHighlightActor = SMESH_SVTKActor::New();
134 myPreHighlightActor->Delete();
135 myPreHighlightActor->Initialize();
137 myIsShrinkable = false;
140 myIsFacesOriented = false;
142 int controlsIncrement = SMESH_ActorProps::props()->controlsIncrement();
143 int selectionIncrement = SMESH_ActorProps::props()->selectionIncrement();
145 myControlsPrecision = -1;
146 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
148 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
149 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
151 double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
152 double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
153 double aBallElemScale = SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
154 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
155 double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
157 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
159 bool anItalicNd = false;
160 bool aShadowNd = false;
162 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
163 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
164 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
165 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
166 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
168 anItalicNd = f.italic();
169 aShadowNd = f.overline();
170 aSizeNd = f.pointSize();
172 double anRGBNd[3] = {1,1,1};
173 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
175 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
177 bool anItalicEl = false;
178 bool aShadowEl = false;
180 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
181 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
182 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
183 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
184 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
186 anItalicEl = f.italic();
187 aShadowEl = f.overline();
188 aSizeEl = f.pointSize();
190 double anRGBEl[3] = {0,1,0};
191 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
193 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
194 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
196 //Definition 2D and 3D devices of the actor
197 //-----------------------------------------
198 double anRGB[3] = {1,1,1};
199 mySurfaceProp = vtkProperty::New();
202 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
203 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
204 myDeltaBrightness = delta;
206 myBackSurfaceProp = vtkProperty::New();
207 bfc = Qtx::mainColorToSecondary(ffc, delta);
208 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
210 myNormalVProp = vtkProperty::New();
211 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
212 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
213 myDeltaVBrightness = delta;
215 myReversedVProp = vtkProperty::New();
216 bfc = Qtx::mainColorToSecondary(ffc, delta);
217 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
219 my2DActor = SMESH_CellLabelActor::New();
220 my2DActor->SetStoreClippingMapping(true);
221 my2DActor->SetUserMatrix(aMatrix);
222 my2DActor->PickableOff();
223 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
224 my2DActor->SetProperty(mySurfaceProp);
225 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
226 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
227 aFilter = my2DActor->GetExtractUnstructuredGrid();
228 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
229 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
230 aFilter->RegisterCellsWithType(VTK_QUAD);
231 aFilter->RegisterCellsWithType(VTK_POLYGON);
232 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
233 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
234 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
235 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
236 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
238 my2DExtProp = vtkProperty::New();
239 my2DExtProp->DeepCopy(mySurfaceProp);
240 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
241 anRGB[0] = 1 - anRGB[0];
242 anRGB[1] = 1 - anRGB[1];
243 anRGB[2] = 1 - anRGB[2];
244 my2DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
245 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
247 my2DExtActor = SMESH_DeviceActor::New();
248 my2DExtActor->SetUserMatrix(aMatrix);
249 my2DExtActor->PickableOff();
250 my2DExtActor->SetProperty(my2DExtProp);
251 my2DExtActor->SetBackfaceProperty(my2DExtProp);
252 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
253 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
254 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
255 aFilter->RegisterCellsWithType(VTK_QUAD);
256 aFilter->RegisterCellsWithType(VTK_POLYGON);
257 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
258 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
259 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
260 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
261 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
263 my3DActor = SMESH_CellLabelActor::New();
264 my3DActor->SetStoreClippingMapping(true);
265 my3DActor->SetUserMatrix(aMatrix);
266 my3DActor->PickableOff();
267 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
268 my3DActor->SetProperty(myNormalVProp);
269 my3DActor->SetBackfaceProperty(myReversedVProp);
270 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
271 my3DActor->SetCoincident3DAllowed(true);
272 aFilter = my3DActor->GetExtractUnstructuredGrid();
273 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
274 aFilter->RegisterCellsWithType(VTK_TETRA);
275 aFilter->RegisterCellsWithType(VTK_VOXEL);
276 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
277 aFilter->RegisterCellsWithType(VTK_WEDGE);
278 aFilter->RegisterCellsWithType(VTK_PYRAMID);
279 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
280 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
281 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
282 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
283 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
284 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
285 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
286 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
287 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
289 my3DExtProp = vtkProperty::New();
290 my3DExtProp->DeepCopy(myNormalVProp);
291 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
292 anRGB[0] = 1 - anRGB[0];
293 anRGB[1] = 1 - anRGB[1];
294 anRGB[2] = 1 - anRGB[2];
295 my3DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
296 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
298 my3DExtActor = SMESH_DeviceActor::New();
299 my3DExtActor->SetUserMatrix(aMatrix);
300 my3DExtActor->PickableOff();
301 my3DExtActor->SetProperty(my3DExtProp);
302 my3DExtActor->SetBackfaceProperty(my3DExtProp);
303 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
304 my3DExtActor->SetCoincident3DAllowed(true);
305 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
306 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
307 aFilter->RegisterCellsWithType(VTK_TETRA);
308 aFilter->RegisterCellsWithType(VTK_VOXEL);
309 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
310 aFilter->RegisterCellsWithType(VTK_WEDGE);
311 aFilter->RegisterCellsWithType(VTK_PYRAMID);
312 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
313 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
314 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
315 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
316 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
317 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
318 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
319 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
320 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
322 //Definition 1D device of the actor
323 //---------------------------------
324 myEdgeProp = vtkProperty::New();
325 myEdgeProp->SetAmbient(1.0);
326 myEdgeProp->SetDiffuse(0.0);
327 myEdgeProp->SetSpecular(0.0);
328 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
329 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
330 myEdgeProp->SetLineWidth(aLineWidth);
332 // my1DActor is used to
334 // - show controls on all edges (eg Length)
335 // since edges are shown by myHighlitableActor
336 my1DActor = SMESH_CellLabelActor::New();
337 my1DActor->SetStoreClippingMapping(true);
338 my1DActor->SetUserMatrix(aMatrix);
339 my1DActor->PickableOff();
340 my1DActor->SetHighlited(true);
341 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
342 my1DActor->SetProperty(myEdgeProp);
343 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
344 aFilter = my1DActor->GetExtractUnstructuredGrid();
345 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
346 aFilter->RegisterCellsWithType(VTK_LINE);
347 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
349 my1DProp = vtkProperty::New();
350 my1DProp->DeepCopy(myEdgeProp);
351 my1DProp->SetLineWidth(aLineWidth + controlsIncrement);
352 my1DProp->SetPointSize(aElem0DSize);
354 my1DExtProp = vtkProperty::New();
355 my1DExtProp->DeepCopy(myEdgeProp);
356 anRGB[0] = 1 - anRGB[0];
357 anRGB[1] = 1 - anRGB[1];
358 anRGB[2] = 1 - anRGB[2];
359 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
360 my1DExtProp->SetLineWidth(aLineWidth + controlsIncrement);
361 my1DExtProp->SetPointSize(aElem0DSize);
363 // my1DExtActor is used to show filtered edges or links between nodes
364 my1DExtActor = SMESH_DeviceActor::New();
365 my1DExtActor->SetUserMatrix(aMatrix);
366 my1DExtActor->PickableOff();
367 my1DExtActor->SetHighlited(true);
368 my1DExtActor->SetVisibility(false);
369 my1DExtActor->SetProperty(my1DExtProp);
370 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
371 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
372 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
373 aFilter->RegisterCellsWithType(VTK_LINE);
374 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
377 //Definition 0D device of the actor (0d elements)
378 //-----------------------------------------------
379 my0DProp = vtkProperty::New();
380 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
381 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
382 my0DProp->SetPointSize(aElem0DSize);
384 my0DActor = SMESH_CellLabelActor::New();
385 my0DActor->SetUserMatrix(aMatrix);
386 my0DActor->SetStoreClippingMapping(true);
387 my0DActor->PickableOff();
388 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
389 my0DActor->SetVisibility(false);
390 my0DActor->SetProperty(my0DProp);
391 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
392 aFilter = my0DActor->GetExtractUnstructuredGrid();
393 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
394 aFilter->RegisterCellsWithType(VTK_VERTEX);
396 //Definition 0D device of the actor (ball elements)
397 //-----------------------------------------------
398 myBallProp = vtkProperty::New();
399 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
400 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
401 myBallProp->SetPointSize(aBallElemSize);
403 myBallActor = SMESH_CellLabelActor::New();
404 myBallActor->SetUserMatrix(aMatrix);
405 myBallActor->SetStoreClippingMapping(true);
406 myBallActor->PickableOff();
407 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
408 myBallActor->SetVisibility(false);
409 myBallActor->SetProperty(myBallProp);
410 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
411 myBallActor->SetBallEnabled(true);
412 aFilter = myBallActor->GetExtractUnstructuredGrid();
413 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
414 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
416 //my0DExtProp = vtkProperty::New();
417 //my0DExtProp->DeepCopy(my0DProp);
418 //anRGB[0] = 1 - anRGB[0];
419 //anRGB[1] = 1 - anRGB[1];
420 //anRGB[2] = 1 - anRGB[2];
421 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
422 //my0DExtProp->SetPointSize(aElem0DSize);
424 //my0DExtActor = SMESH_DeviceActor::New();
425 //my0DExtActor->SetUserMatrix(aMatrix);
426 //my0DExtActor->SetStoreClippingMapping(true);
427 //my0DExtActor->PickableOff();
428 //my0DExtActor->SetHighlited(true);
429 //my0DExtActor->SetVisibility(false);
430 //my0DExtActor->SetProperty(my0DExtProp);
431 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
432 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
433 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
434 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
435 //aFilter->RegisterCellsWithType(VTK_VERTEX);
438 //Definition 0D device of the actor (nodes)
439 //-----------------------------------------
440 myNodeProp = vtkProperty::New();
441 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
442 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
444 myNodeActor = SMESH_NodeLabelActor::New();
445 myNodeActor->SetUserMatrix(aMatrix);
446 myNodeActor->SetStoreClippingMapping(true);
447 myNodeActor->PickableOff();
448 myNodeActor->SetVisibility(false);
449 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
450 myNodeActor->SetProperty(myNodeProp);
451 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
452 aFilter = myNodeActor->GetExtractUnstructuredGrid();
453 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
455 myNodeExtProp = vtkProperty::New();
456 myNodeExtProp->DeepCopy(myNodeProp);
457 anRGB[0] = 1 - anRGB[0];
458 anRGB[1] = 1 - anRGB[1];
459 anRGB[2] = 1 - anRGB[2];
460 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
462 myNodeExtActor = SMESH_DeviceActor::New();
463 myNodeExtActor->SetUserMatrix(aMatrix);
464 myNodeExtActor->SetStoreClippingMapping(true);
465 myNodeExtActor->PickableOff();
466 myNodeExtActor->SetHighlited(true);
467 myNodeExtActor->SetVisibility(false);
468 myNodeExtActor->SetProperty(myNodeExtProp);
469 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
470 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
471 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
472 aFilter->RegisterCellsWithType(VTK_VERTEX);
474 //Definition of Pickable and Highlitable engines
475 //----------------------------------------------
477 myBaseActor->SetUserMatrix(aMatrix);
478 myBaseActor->SetStoreIDMapping(true);
479 myBaseActor->SetStoreClippingMapping(true);
480 myBaseActor->SetStoreGemetryMapping(true);
481 myBaseActor->GetProperty()->SetOpacity(0.0);
482 myPickableActor = myBaseActor;
484 myHighlightProp = vtkProperty::New();
485 myHighlightProp->SetAmbient(1.0);
486 myHighlightProp->SetDiffuse(0.0);
487 myHighlightProp->SetSpecular(0.0);
488 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
489 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
490 myHighlightProp->SetPointSize(aElem0DSize); // ??
491 myHighlightProp->SetLineWidth(aLineWidth + selectionIncrement);
492 myHighlightProp->SetRepresentation(1);
494 myOutLineProp = vtkProperty::New();
495 myOutLineProp->SetAmbient(1.0);
496 myOutLineProp->SetDiffuse(0.0);
497 myOutLineProp->SetSpecular(0.0);
498 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
499 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
500 myOutLineProp->SetLineWidth(aOutlineWidth);
501 myOutLineProp->SetRepresentation(1);
503 myPreselectProp = vtkProperty::New();
504 myPreselectProp->SetAmbient(1.0);
505 myPreselectProp->SetDiffuse(0.0);
506 myPreselectProp->SetSpecular(0.0);
507 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
508 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
509 myPreselectProp->SetPointSize(aElem0DSize); // ??
510 myPreselectProp->SetLineWidth(aLineWidth + selectionIncrement);
511 myPreselectProp->SetRepresentation(1);
513 myHighlitableActor = SMESH_DeviceActor::New();
514 myHighlitableActor->SetUserMatrix(aMatrix);
515 myHighlitableActor->PickableOff();
516 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
517 myHighlitableActor->SetCoincident3DAllowed(true);
524 myControlMode = eNone;
525 myControlActor = my2DActor;
527 //Definition of myScalarBarActor
528 //------------------------------
529 myLookupTable = vtkLookupTable::New();
530 //Fix for Bug PAL5195 - SMESH764:
531 //Controls - Aspect Ratio: incorrect colors of the best and worst values
532 myLookupTable->SetHueRange(0.667,0.0);
534 myScalarBarActor = SMESH_ScalarBarActor::New();
535 myScalarBarActor->SetVisibility(false);
536 myScalarBarActor->SetLookupTable(myLookupTable);
539 //Incorrect "Min value" in Scalar Bar in Mesh:
540 // myScalarBarActor->SetLabelFormat("%.4g");
541 // changes was commented because of regression bug IPAL 19981
543 mgr = SUIT_Session::session()->resourceMgr();
547 myEntityMode = eAllEntity;
548 myEntityModeCache = eAllEntity;
551 myImplicitBoolean = vtkImplicitBoolean::New();
552 myImplicitBoolean->SetOperationTypeToIntersection();
554 myPlaneCollection = vtkPlaneCollection::New();
556 //Quadratic 2D elements representation
557 //-----------------------------------------------------------------------------
558 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
559 if(aQuadratic2DMode == 0){
560 myHighlitableActor->SetQuadraticArcMode(false);
561 my2DActor->SetQuadraticArcMode(false);
562 my1DActor->SetQuadraticArcMode(false);
564 else if(aQuadratic2DMode == 1){
565 myHighlitableActor->SetQuadraticArcMode(true);
566 my2DActor->SetQuadraticArcMode(true);
567 my1DActor->SetQuadraticArcMode(true);
570 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
571 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
572 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
574 // Set colors of the name actor
575 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
576 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
577 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
578 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
580 #ifndef DISABLE_PLOT2DVIEWER
584 SetBallSize(aBallElemSize);
585 SetBallScale(aBallElemScale);
586 Set0DSize(aElem0DSize);
590 SMESH_ActorDef::~SMESH_ActorDef()
592 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
594 // Please keep the order same as one in the header file
596 myTimeStamp->Delete();
598 myScalarBarActor->Delete();
599 myLookupTable->Delete();
601 mySurfaceProp->Delete();
602 myBackSurfaceProp->Delete();
603 myNormalVProp->Delete();
604 myReversedVProp->Delete();
605 myEdgeProp->Delete();
606 myNodeProp->Delete();
608 myNodeActor->Delete();
609 myBaseActor->Delete();
610 //myPickableActor->Delete(); myPickableActor == myBaseActor
612 myHighlightProp->Delete();
613 myOutLineProp->Delete();
614 myPreselectProp->Delete();
616 myHighlitableActor->Delete();
618 my2DExtProp->Delete();
619 my3DExtProp->Delete();
621 my2DExtActor->Delete();
623 my3DExtActor->Delete();
624 // myControlActor->Delete(); myControlActor == my2DActor
626 myNodeExtProp->Delete();
627 myNodeExtActor->Delete();
631 my1DExtProp->Delete();
632 my1DExtActor->Delete();
636 myBallProp->Delete();
637 myBallActor->Delete();
638 //my0DExtProp->Delete();
639 //my0DExtActor->Delete();
641 myImplicitBoolean->Delete();
642 myPlaneCollection->Delete();
644 #ifndef DISABLE_PLOT2DVIEWER
646 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
647 delete my2dHistogram;
652 void SMESH_ActorDef::Delete()
654 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
655 // from the actor's destructor) will be thrown before removing the actor's observers,
656 // that is done inside the Superclass::Delete() method but before the destructor itself
657 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
658 // The event is caught by SMESHGUI::ProcessEvents() static method.
659 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
661 Superclass::Delete();
664 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
667 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
668 SetRepresentation(GetRepresentation());
669 myTimeStamp->Modified();
673 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
674 bool theBold, bool theItalic, bool theShadow,
675 double r, double g, double b )
678 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
679 SetRepresentation( GetRepresentation() );
680 myTimeStamp->Modified();
684 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
685 bool theBold, bool theItalic, bool theShadow,
686 double r, double g, double b )
689 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
692 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
693 SetRepresentation( GetRepresentation() );
694 myTimeStamp->Modified();
697 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
698 SetRepresentation( GetRepresentation() );
699 myTimeStamp->Modified();
702 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
703 SetRepresentation( GetRepresentation() );
704 myTimeStamp->Modified();
707 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
708 SetRepresentation( GetRepresentation() );
709 myTimeStamp->Modified();
713 bool SMESH_ActorDef::GetPointsLabeled()
715 return myNodeActor && myNodeActor->GetPointsLabeled();
718 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
721 my3DActor->SetCellsLabeled(theIsCellsLabeled);
724 my2DActor->SetCellsLabeled(theIsCellsLabeled);
727 my1DActor->SetCellsLabeled(theIsCellsLabeled);
730 my0DActor->SetCellsLabeled(theIsCellsLabeled);
733 myBallActor->SetCellsLabeled(theIsCellsLabeled);
735 myTimeStamp->Modified();
739 bool SMESH_ActorDef::GetCellsLabeled()
743 result = result || my3DActor->GetCellsLabeled();
746 result = result || my2DActor->GetCellsLabeled();
749 result = result || my1DActor->GetCellsLabeled();
752 result = result || my0DActor->GetCellsLabeled();
755 result = result || myBallActor->GetCellsLabeled();
761 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
763 myIsFacesOriented = theIsFacesOriented;
765 my2DActor->SetFacesOriented(theIsFacesOriented);
766 my3DActor->SetFacesOriented(theIsFacesOriented);
768 myTimeStamp->Modified();
771 bool SMESH_ActorDef::GetFacesOriented()
773 return myIsFacesOriented;
776 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
778 my2DActor->SetFacesOrientationColor( r, g, b );
779 my3DActor->SetFacesOrientationColor( r, g, b );
782 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
784 my3DActor->GetFacesOrientationColor( r, g, b );
787 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
789 my2DActor->SetFacesOrientationScale( theScale );
790 my3DActor->SetFacesOrientationScale( theScale );
793 double SMESH_ActorDef::GetFacesOrientationScale()
795 return my3DActor->GetFacesOrientationScale();
798 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
800 my2DActor->SetFacesOrientation3DVectors( theState );
801 my3DActor->SetFacesOrientation3DVectors( theState );
804 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
806 return my3DActor->GetFacesOrientation3DVectors();
810 void SMESH_ActorDef::SetControl(SMESH::Controls::FunctorPtr theFunctor)
812 myFunctor = theFunctor;
814 SetControlMode( eNone, true );
816 SetControlMode( eCustomControl, true );
819 void SMESH_ActorDef::SetControlMode(eControl theMode)
821 SetControlMode(theMode,true);
824 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
826 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
827 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
828 lookupTable->SetScale(VTK_SCALE_LINEAR);
830 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
834 //myControlMode = eNone;
835 myControlMode = theMode;
836 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
838 my0DActor->GetMapper()->SetScalarVisibility(false);
839 my1DActor->GetMapper()->SetScalarVisibility(false);
840 my2DActor->GetMapper()->SetScalarVisibility(false);
841 my3DActor->GetMapper()->SetScalarVisibility(false);
842 myBallActor->GetMapper()->SetScalarVisibility(false);
843 myScalarBarActor->SetVisibility(false);
845 bool anIsScalarVisible = theMode > eNone;
847 if(anIsScalarVisible) {
851 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
852 aControl->SetPrecision( myControlsPrecision );
853 myFunctor.reset( aControl );
854 myControlActor = my1DActor;
858 myFunctor.reset(new SMESH::Controls::Length2D());
859 myControlActor = my2DActor;
862 myFunctor.reset(new SMESH::Controls::FreeBorders());
863 myControlActor = my1DActor;
866 myFunctor.reset(new SMESH::Controls::FreeEdges());
867 myControlActor = my2DActor;
870 myFunctor.reset(new SMESH::Controls::FreeNodes());
871 myControlActor = myNodeActor;
874 myFunctor.reset(new SMESH::Controls::FreeFaces());
875 myControlActor = my2DActor;
877 case eCoincidentNodes:
879 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
880 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
881 cn->SetTolerance( tol );
883 myControlActor = myNodeActor;
886 case eCoincidentElems1D:
887 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
888 myControlActor = my1DActor;
890 case eCoincidentElems2D:
891 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
892 myControlActor = my2DActor;
894 case eCoincidentElems3D:
895 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
896 myControlActor = my3DActor;
898 case eBareBorderFace:
899 myFunctor.reset(new SMESH::Controls::BareBorderFace());
900 myControlActor = my2DActor;
902 case eOverConstrainedFace:
903 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
904 myControlActor = my2DActor;
906 case eMultiConnection:
907 myFunctor.reset(new SMESH::Controls::MultiConnection());
908 myControlActor = my1DActor;
910 case eMultiConnection2D:
911 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
912 myControlActor = my2DActor;
916 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
917 aControl->SetPrecision( myControlsPrecision );
918 myFunctor.reset( aControl );
919 myControlActor = my2DActor;
924 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
925 aControl->SetPrecision( myControlsPrecision );
926 myFunctor.reset( aControl );
927 myControlActor = my2DActor;
932 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
933 aControl->SetPrecision( myControlsPrecision );
934 myFunctor.reset( aControl );
935 myControlActor = my2DActor;
940 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
941 aControl->SetPrecision( myControlsPrecision );
942 myFunctor.reset( aControl );
943 myControlActor = my3DActor;
948 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
949 aControl->SetPrecision( myControlsPrecision );
950 myFunctor.reset( aControl );
951 myControlActor = my3DActor;
954 case eMaxElementLength2D:
956 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
957 aControl->SetPrecision( myControlsPrecision );
958 myFunctor.reset( aControl );
959 myControlActor = my2DActor;
962 case eMaxElementLength3D:
964 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
965 aControl->SetPrecision( myControlsPrecision );
966 myFunctor.reset( aControl );
967 myControlActor = my3DActor;
972 SMESH::Controls::Deflection2D* aControl = new SMESH::Controls::Deflection2D();
973 aControl->SetPrecision( myControlsPrecision );
974 myFunctor.reset( aControl );
975 myControlActor = my2DActor;
978 case eBareBorderVolume:
980 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
981 myControlActor = my3DActor;
984 case eOverConstrainedVolume:
986 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
987 myControlActor = my3DActor;
992 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
993 aControl->SetPrecision( myControlsPrecision );
994 myFunctor.reset( aControl );
995 myControlActor = my2DActor;
1000 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
1001 aControl->SetPrecision( myControlsPrecision );
1002 myFunctor.reset( aControl );
1003 myControlActor = my2DActor;
1008 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
1009 aControl->SetPrecision( myControlsPrecision );
1010 myFunctor.reset( aControl );
1011 myControlActor = my2DActor;
1014 case eNodeConnectivityNb:
1016 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1017 myControlActor = myNodeActor;
1020 case eCustomControl:
1024 switch ( myFunctor->GetType() ) {
1025 case SMDSAbs_Node : myControlActor = myNodeActor; break;
1026 case SMDSAbs_Edge : myControlActor = my1DActor; break;
1027 case SMDSAbs_Face : myControlActor = my2DActor; break;
1028 case SMDSAbs_Volume : myControlActor = my3DActor; break;
1037 int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1038 bool aShowOnlyScalarBarTitle = false;
1040 //myControlMode = theMode;
1041 switch(myControlMode){
1043 case eCoincidentNodes:
1044 myNodeExtActor->SetExtControlMode(myFunctor);
1045 aShowOnlyScalarBarTitle = true;
1049 case eCoincidentElems1D:
1050 my1DExtActor->SetExtControlMode(myFunctor);
1051 aShowOnlyScalarBarTitle = true;
1054 case eBareBorderFace:
1055 case eOverConstrainedFace:
1056 case eCoincidentElems2D:
1057 my2DExtActor->SetExtControlMode(myFunctor);
1058 aShowOnlyScalarBarTitle = true;
1060 case eBareBorderVolume:
1061 case eOverConstrainedVolume:
1062 case eCoincidentElems3D:
1063 my3DExtActor->SetExtControlMode(myFunctor);
1064 aShowOnlyScalarBarTitle = true;
1067 case eMultiConnection2D:
1068 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1069 UpdateDistribution();
1072 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1073 UpdateDistribution();
1075 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1078 if(theCheckEntityMode) {
1079 // if(myControlActor == myNodeActor) {
1080 // if ( myControlMode == eNodeConnectivityNb ) {
1081 // if (!myIsEntityModeCache){
1082 // myEntityModeCache = GetEntityMode();
1083 // myIsEntityModeCache=true;
1085 // SetEntityMode(0);
1088 if(myControlActor == my1DActor) {
1089 if (!myIsEntityModeCache){
1090 myEntityModeCache = GetEntityMode();
1091 myIsEntityModeCache=true;
1093 SetEntityMode(eEdges);
1095 else if(myControlActor == my2DActor) {
1096 if (!myIsEntityModeCache){
1097 myEntityModeCache = GetEntityMode();
1098 myIsEntityModeCache=true;
1100 SetEntityMode(eFaces);
1102 else if(myControlActor == my3DActor) {
1103 if (!myIsEntityModeCache){
1104 myEntityModeCache = GetEntityMode();
1105 myIsEntityModeCache=true;
1107 SetEntityMode(eVolumes);
1110 QString aTitle = QString(myScalarBarActor->GetTitle());
1111 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1112 myScalarBarActor->SetTitle(aTitle.toUtf8().constData());
1116 if(theCheckEntityMode){
1117 myEntityMode = myEntityModeCache;
1118 myIsEntityModeCache = false;
1123 SetRepresentation(GetRepresentation());
1125 myTimeStamp->Modified();
1128 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1129 double * range = lookupTable->GetRange();
1131 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1132 lookupTable->SetScale(VTK_SCALE_LOG10);
1137 int SMESH_ActorDef::GetNumberControlEntities()
1139 SMESH_DeviceActor* anAct = NULL;
1140 switch(myControlMode){
1142 case eCoincidentNodes:
1143 anAct = myNodeExtActor;
1147 case eCoincidentElems1D:
1148 anAct = my1DExtActor;
1151 case eBareBorderFace:
1152 case eOverConstrainedFace:
1153 case eCoincidentElems2D:
1154 anAct = my2DExtActor;
1156 case eBareBorderVolume:
1157 case eOverConstrainedVolume:
1158 case eCoincidentElems3D:
1159 anAct = my3DExtActor;
1163 return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1166 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1168 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1170 myBaseActor->SetUnstructuredGrid( NULL );
1171 //myHighlitableActor->SetUnstructuredGrid( NULL );
1173 theRenderer->AddActor(myBaseActor);
1174 theRenderer->AddActor(myNodeExtActor);
1175 theRenderer->AddActor(my1DExtActor);
1177 my3DActor ->AddToRender(theRenderer);
1178 my3DExtActor->AddToRender(theRenderer);
1179 my2DActor ->AddToRender(theRenderer);
1180 my2DExtActor->AddToRender(theRenderer);
1181 myNodeActor ->AddToRender(theRenderer);
1182 my1DActor ->AddToRender(theRenderer);
1183 my0DActor ->AddToRender(theRenderer);
1184 myBallActor ->AddToRender(theRenderer);
1186 theRenderer->AddActor(myHighlitableActor);
1188 theRenderer->AddActor2D(myScalarBarActor);
1190 // the superclass' method should be called at the end
1191 // (in particular, for correct work of selection)
1192 SALOME_Actor::AddToRender(theRenderer);
1195 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1197 SALOME_Actor::RemoveFromRender(theRenderer);
1199 theRenderer->RemoveActor(myBaseActor);
1201 theRenderer->RemoveActor(myNodeExtActor);
1203 theRenderer->RemoveActor(myHighlitableActor);
1205 //theRenderer->RemoveActor(my0DExtActor);
1207 theRenderer->RemoveActor(my1DExtActor);
1209 my2DActor->RemoveFromRender(theRenderer);
1210 my2DExtActor->RemoveFromRender(theRenderer);
1211 my3DActor->RemoveFromRender(theRenderer);
1212 my3DExtActor->RemoveFromRender(theRenderer);
1213 myNodeActor->RemoveFromRender(theRenderer);
1214 my0DActor->RemoveFromRender(theRenderer);
1215 myBallActor->RemoveFromRender(theRenderer);
1216 my1DActor->RemoveFromRender(theRenderer);
1218 theRenderer->RemoveActor(myScalarBarActor);
1222 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1223 const char* theEntry,
1224 const char* theName,
1227 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1231 myVisualObj = theVisualObj;
1232 myVisualObj->Update(theIsClear);
1234 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1235 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1237 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1238 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1240 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1242 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1244 my0DActor->Init(myVisualObj,myImplicitBoolean);
1245 myBallActor->Init(myVisualObj,myImplicitBoolean);
1246 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1248 my1DActor->Init(myVisualObj,myImplicitBoolean);
1249 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1251 my2DActor->Init(myVisualObj,myImplicitBoolean);
1252 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1253 my3DActor->Init(myVisualObj,myImplicitBoolean);
1254 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1256 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1257 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1258 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1260 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1261 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1263 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1264 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1265 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1266 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1268 double aFactor, aUnits;
1269 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1270 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1271 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1272 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1274 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1278 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1279 SetIsShrunkable(true);
1281 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1283 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1284 SetRepresentation(-1);
1287 SetRepresentation(eEdge);
1288 }else if(aMode == 1){
1289 SetRepresentation(eSurface);
1290 }else if(aMode == 2){
1291 SetRepresentation(ePoint);
1298 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1299 SetIsDisplayNameActor( true );
1301 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1302 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1303 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1305 myTimeStamp->Modified();
1311 double* SMESH_ActorDef::GetBounds()
1313 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1314 return myNodeActor->GetBounds();
1315 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1319 vtkDataSet* SMESH_ActorDef::GetInput()
1321 return GetUnstructuredGrid();
1325 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1327 Superclass::SetTransform(theTransform);
1329 myNodeActor->SetTransform(theTransform);
1330 myBaseActor->SetTransform(theTransform);
1332 myHighlitableActor->SetTransform(theTransform);
1334 myNodeExtActor->SetTransform(theTransform);
1336 my0DActor->SetTransform(theTransform);
1337 myBallActor->SetTransform(theTransform);
1338 //my0DExtActor->SetTransform(theTransform);
1340 my1DActor->SetTransform(theTransform);
1341 my1DExtActor->SetTransform(theTransform);
1343 my2DActor->SetTransform(theTransform);
1344 my2DExtActor->SetTransform(theTransform);
1345 my3DActor->SetTransform(theTransform);
1346 my3DExtActor->SetTransform(theTransform);
1352 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1354 vtkLODActor::SetMapper(theMapper);
1358 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1360 SALOME_Actor::ShallowCopy(prop);
1364 vtkMapper* SMESH_ActorDef::GetMapper()
1366 return myPickableActor->GetMapper();
1370 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1372 return myVisualObj->GetUnstructuredGrid();
1376 bool SMESH_ActorDef::IsInfinitive()
1378 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1379 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1380 ( aDataSet->GetNumberOfCells() == 1 &&
1381 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1382 return SALOME_Actor::IsInfinitive();
1386 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1388 if ( myIsShrinkable == theShrunkable )
1390 myIsShrinkable = theShrunkable;
1394 double SMESH_ActorDef::GetShrinkFactor()
1396 return myBaseActor->GetShrinkFactor();
1399 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1401 myBaseActor->SetShrinkFactor(theValue);
1403 my1DActor->SetShrinkFactor(theValue);
1404 my1DExtActor->SetShrinkFactor(theValue);
1406 my2DActor->SetShrinkFactor(theValue);
1407 my2DExtActor->SetShrinkFactor(theValue);
1408 my3DActor->SetShrinkFactor(theValue);
1409 my3DExtActor->SetShrinkFactor(theValue);
1410 my3DExtActor->SetShrinkFactor(theValue);
1411 myHighlitableActor->SetShrinkFactor(theValue);
1416 void SMESH_ActorDef::SetShrink()
1418 if(!myIsShrinkable) return;
1420 myBaseActor->SetShrink();
1422 my1DActor->SetShrink();
1423 my1DExtActor->SetShrink();
1425 my2DActor->SetShrink();
1426 my2DExtActor->SetShrink();
1427 my3DActor->SetShrink();
1428 my3DExtActor->SetShrink();
1429 myHighlitableActor->SetShrink();
1435 void SMESH_ActorDef::UnShrink()
1437 if(!myIsShrunk) return;
1439 myBaseActor->UnShrink();
1441 my1DActor->UnShrink();
1442 my1DExtActor->UnShrink();
1444 my2DActor->UnShrink();
1445 my2DExtActor->UnShrink();
1446 my3DActor->UnShrink();
1447 my3DExtActor->UnShrink();
1448 myHighlitableActor->UnShrink();
1455 int SMESH_ActorDef::GetNodeObjId(int theVtkID)
1457 return myPickableActor->GetNodeObjId(theVtkID);
1460 double* SMESH_ActorDef::GetNodeCoord(int theObjID)
1462 return myPickableActor->GetNodeCoord(theObjID);
1465 int SMESH_ActorDef::GetNodeVtkId(int theObjID)
1467 return myPickableActor->GetNodeVtkId(theObjID);
1470 int SMESH_ActorDef::GetElemObjId(int theVtkID)
1472 return myPickableActor->GetElemObjId(theVtkID);
1475 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID)
1477 return myPickableActor->GetElemCell(theObjID);
1481 void SMESH_ActorDef::SetVisibility(int theMode)
1483 SetVisibility(theMode,true);
1487 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1489 SALOME_Actor::SetVisibility(theMode);
1491 myNodeActor->VisibilityOff();
1492 myBaseActor->VisibilityOff();
1494 myNodeExtActor->VisibilityOff();
1496 my0DActor->VisibilityOff();
1497 myBallActor->VisibilityOff();
1498 //my0DExtActor->VisibilityOff();
1500 my1DActor->VisibilityOff();
1501 my1DExtActor->VisibilityOff();
1503 my2DActor->VisibilityOff();
1504 my2DExtActor->VisibilityOff();
1505 my3DActor->VisibilityOff();
1506 my3DExtActor->VisibilityOff();
1508 myScalarBarActor->VisibilityOff();
1510 if ( GetVisibility() ) {
1511 if ( theIsUpdateRepersentation )
1512 SetRepresentation(GetRepresentation());
1514 if(myControlMode != eNone) {
1515 switch(myControlMode) {
1517 case eCoincidentNodes:
1518 myNodeExtActor->VisibilityOn();
1521 case eMultiConnection:
1522 my1DActor->VisibilityOn();
1526 case eCoincidentElems1D:
1528 case eMultiConnection2D:
1529 my1DExtActor->VisibilityOn();
1532 case eBareBorderFace:
1533 case eOverConstrainedFace:
1534 case eCoincidentElems2D:
1535 my2DExtActor->VisibilityOn();
1537 case eBareBorderVolume:
1538 case eOverConstrainedVolume:
1539 case eCoincidentElems3D:
1540 my3DExtActor->VisibilityOn();
1544 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1545 myScalarBarActor->VisibilityOn();
1548 myPickableActor->VisibilityOn();
1550 if ( GetRepresentation() != ePoint )
1552 if(myEntityMode & e0DElements ){
1553 my0DActor->VisibilityOn();
1555 if(myEntityMode & eBallElem ){
1556 myBallActor->VisibilityOn();
1558 if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
1559 my1DActor->VisibilityOn();
1561 if(myEntityMode & eFaces ){
1562 my2DActor->VisibilityOn();
1564 if(myEntityMode & eVolumes ){
1565 my3DActor->VisibilityOn();
1569 if(myNodeActor->GetPointsLabeled()) {
1570 myNodeActor->UpdateLabels();
1571 myNodeActor->VisibilityOn();
1574 my0DActor->UpdateLabels();
1577 myBallActor->UpdateLabels();
1580 my1DActor->UpdateLabels();
1583 my2DActor->UpdateLabels();
1586 my3DActor->UpdateLabels();
1588 #ifndef DISABLE_PLOT2DVIEWER
1590 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1597 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1599 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1601 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1602 anObjectEntities &= ~e0DElements;
1603 theMode &= ~e0DElements;
1606 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1607 anObjectEntities &= ~eBallElem;
1608 theMode &= ~eBallElem;
1611 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1612 anObjectEntities &= ~eEdges;
1616 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1617 anObjectEntities &= ~eFaces;
1621 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1622 anObjectEntities &= ~eVolumes;
1623 theMode &= ~eVolumes;
1627 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1628 theMode |= e0DElements;
1630 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1631 theMode |= eBallElem;
1633 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1636 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1639 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1640 theMode |= eVolumes;
1643 myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1645 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1647 myRepresentationCache = GetRepresentation();
1648 SetRepresentation( ePoint );
1651 if ( myEntityMode != theMode )
1653 myEntityMode = theMode; // entities to show
1655 // Set cell types to extract
1657 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
1658 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1659 aFilter->ClearRegisteredCellsWithType();
1660 aHltFilter->ClearRegisteredCellsWithType();
1662 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
1665 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1666 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1670 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1671 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1673 if (myEntityMode & e0DElements) {
1674 aFilter->RegisterCellsWithType(VTK_VERTEX);
1675 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
1678 if (myEntityMode & eBallElem) {
1679 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1682 if (myEntityMode & eEdges) {
1683 aFilter->RegisterCellsWithType(VTK_LINE);
1684 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1686 aHltFilter->RegisterCellsWithType(VTK_LINE);
1687 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1690 if (myEntityMode & eFaces) {
1691 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1692 aFilter->RegisterCellsWithType(VTK_QUAD);
1693 aFilter->RegisterCellsWithType(VTK_POLYGON);
1694 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1695 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1696 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1697 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1698 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1700 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
1701 aHltFilter->RegisterCellsWithType(VTK_QUAD);
1702 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
1703 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1704 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1705 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1706 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1707 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1710 if (myEntityMode & eVolumes) {
1711 aFilter->RegisterCellsWithType(VTK_TETRA);
1712 aFilter->RegisterCellsWithType(VTK_VOXEL);
1713 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1714 aFilter->RegisterCellsWithType(VTK_WEDGE);
1715 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1716 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1717 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1718 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1719 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1720 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1721 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1722 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1723 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1724 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1726 aHltFilter->RegisterCellsWithType(VTK_TETRA);
1727 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
1728 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1729 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
1730 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
1731 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1732 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1733 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1734 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1735 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1736 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1737 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1738 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1739 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1742 if ( GetVisibility() )
1744 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1747 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1750 void SMESH_ActorDef::SetRepresentation (int theMode)
1752 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1753 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1754 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1755 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1756 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1758 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1760 theMode = myRepresentationCache;
1761 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1764 myRepresentationCache = 0;
1768 myRepresentation = eSurface;
1769 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1770 myRepresentation = eEdge;
1771 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1772 myRepresentation = ePoint;
1777 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1780 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1783 myRepresentation = theMode;
1786 if (!GetUnstructuredGrid()->GetNumberOfCells())
1787 myRepresentation = ePoint;
1790 if (myRepresentation == ePoint) {
1798 myPickableActor = myBaseActor;
1799 vtkProperty *aProp = NULL, *aBackProp = NULL;
1800 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1801 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1802 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1803 switch (myRepresentation) {
1805 myPickableActor = myNodeActor;
1806 aQuadraticMode = SMESH_Actor::eLines;
1807 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1808 aReperesent = SMESH_DeviceActor::ePoint;
1811 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1812 aReperesent = SMESH_DeviceActor::eInsideframe;
1815 aProp = mySurfaceProp;
1816 aBackProp = myBackSurfaceProp;
1817 aPropVN = myNormalVProp;
1818 aPropVR = myReversedVProp;
1819 aReperesent = SMESH_DeviceActor::eSurface;
1823 if ( myRepresentation != ePoint )
1825 my2DActor->SetProperty(aProp);
1826 my2DActor->SetBackfaceProperty(aBackProp);
1827 my2DActor->SetRepresentation(aReperesent);
1829 if(aQuadraticMode == SMESH_Actor::eLines)
1830 my2DActor->SetQuadraticArcMode(false);
1831 else if(aQuadraticMode == SMESH_Actor::eArcs)
1832 my2DActor->SetQuadraticArcMode(true);
1834 my2DExtActor->SetRepresentation(aReperesent);
1836 my3DActor->SetProperty(aPropVN);
1837 my3DActor->SetBackfaceProperty(aPropVR);
1838 my3DActor->SetRepresentation(aReperesent);
1840 my0DActor->SetRepresentation(aReperesent);
1841 myBallActor->SetRepresentation(aReperesent);
1843 switch ( myControlMode ) {
1845 case eMultiConnection:
1846 aProp = aBackProp = my1DProp;
1847 if ( myRepresentation != ePoint )
1848 aReperesent = SMESH_DeviceActor::eInsideframe;
1853 if(aQuadraticMode == SMESH_Actor::eLines)
1854 my1DActor->SetQuadraticArcMode(false);
1855 else if(aQuadraticMode == SMESH_Actor::eArcs)
1856 my1DActor->SetQuadraticArcMode(true);
1858 my1DActor->SetProperty(aProp);
1859 my1DActor->SetBackfaceProperty(aBackProp);
1860 my1DActor->SetRepresentation(aReperesent);
1862 my1DExtActor->SetRepresentation(aReperesent);
1865 if(myIsPointsVisible)
1866 myPickableActor = myNodeActor;
1868 SetMapper(myPickableActor->GetMapper());
1870 SetVisibility(GetVisibility(),false);
1876 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1878 if ( myIsPointsVisible == theIsPointsVisible )
1880 myIsPointsVisible = theIsPointsVisible;
1881 SetRepresentation(GetRepresentation());
1884 bool SMESH_ActorDef::GetPointRepresentation()
1886 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1890 void SMESH_ActorDef::UpdateHighlight()
1892 myHighlitableActor->SetHighlited(false);
1893 myHighlitableActor->SetVisibility(false);
1894 bool anIsVisible = GetVisibility();
1896 switch(myRepresentation){
1897 case SMESH_DeviceActor::eSurface:
1898 case SMESH_DeviceActor::eWireframe:
1900 if(myIsHighlighted) {
1901 myHighlitableActor->SetProperty(myHighlightProp);
1902 }else if(myIsPreselected){
1903 myHighlitableActor->SetProperty(myPreselectProp);
1904 } else if(anIsVisible){
1905 (myRepresentation == eSurface) ?
1906 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1908 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1909 myHighlitableActor->SetHighlited(anIsVisible);
1910 myHighlitableActor->GetExtractUnstructuredGrid()->
1911 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1912 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1914 myHighlitableActor->SetVisibility(anIsVisible);
1917 case SMESH_DeviceActor::ePoint:
1919 if(myIsHighlighted) {
1920 myNodeActor->SetProperty(myHighlightProp);
1921 }else if(myIsPreselected) {
1922 myNodeActor->SetProperty(myPreselectProp);
1923 } else if(anIsVisible) {
1924 myNodeActor->SetProperty(myNodeProp);
1926 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1927 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1928 myNodeActor->GetProperty()->Modified();
1934 void SMESH_ActorDef::EnableSelection( bool enable )
1936 // selection in the Viewer enabled/disabled
1937 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1939 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1940 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1941 myBaseActor->myExtractUnstructuredGrid->Update();
1942 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1944 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1946 myBaseActor->SetUnstructuredGrid( NULL );
1947 //myHighlitableActor->SetUnstructuredGrid( NULL );
1948 myBaseActor->myExtractUnstructuredGrid->Update();
1949 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1953 void SMESH_ActorDef::highlight(bool theHighlight)
1955 if ( myIsHighlighted == theHighlight )
1957 myIsHighlighted = theHighlight;
1962 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1964 if ( myIsPreselected == thePreselect )
1966 myIsPreselected = thePreselect;
1972 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1974 if (myPickableActor->GetIsOpaque())
1976 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1984 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1986 if (!myPickableActor->GetIsOpaque())
1988 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1996 void SMESH_ActorDef::Render(vtkRenderer *ren)
1998 vtkMTimeType aTime = myTimeStamp->GetMTime();
1999 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
2000 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
2001 if(anObjTime > aTime || aClippingTime > aTime)
2006 void SMESH_ActorDef::Update()
2008 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
2010 myVisualObj->Update();
2012 if(GetControlMode() != eNone) {
2013 unsigned long aTime = myTimeStamp->GetMTime();
2014 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
2015 if (anObjTime > aTime)
2016 SetControlMode(GetControlMode(),false);
2020 myNodeActor->UpdateLabels();
2023 my0DActor->UpdateLabels();
2026 myBallActor->UpdateLabels();
2029 my1DActor->UpdateLabels();
2032 my2DActor->UpdateLabels();
2035 my3DActor->UpdateLabels();
2037 if(myIsFacesOriented){
2038 SetFacesOriented(myIsFacesOriented);
2041 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
2042 // myEntityMode |= myVisualObj->GetEntitiesState();
2045 SetEntityMode(GetEntityMode());
2046 SetVisibility(GetVisibility());
2048 myTimeStamp->Modified();
2053 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2055 SALOME_Actor::ReleaseGraphicsResources(renWin);
2057 myPickableActor->ReleaseGraphicsResources(renWin);
2061 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2063 double* aColor = theProperty->GetColor();
2070 void SMESH_ActorDef::SetOpacity(double theValue)
2072 mySurfaceProp->SetOpacity(theValue);
2073 myBackSurfaceProp->SetOpacity(theValue);
2074 myNormalVProp->SetOpacity(theValue);
2075 myReversedVProp->SetOpacity(theValue);
2076 myEdgeProp->SetOpacity(theValue);
2077 myOutLineProp->SetOpacity(theValue);
2078 myNodeProp->SetOpacity(theValue);
2080 my1DProp->SetOpacity(theValue);
2081 my0DProp->SetOpacity(theValue);
2082 myBallProp->SetOpacity(theValue);
2086 double SMESH_ActorDef::GetOpacity()
2088 return mySurfaceProp->GetOpacity();
2092 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2094 mySurfaceProp->SetColor(r,g,b);
2095 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2096 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2097 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2098 myNameActor->SetBackgroundColor(r,g,b);
2100 myDeltaBrightness = delta;
2101 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2102 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2106 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2108 ::GetColor(mySurfaceProp,r,g,b);
2109 delta = myDeltaBrightness;
2112 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2114 myNormalVProp->SetColor(r,g,b);
2115 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2116 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2117 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2118 myNameActor->SetBackgroundColor(r,g,b);
2120 myDeltaVBrightness = delta;
2121 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2122 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2126 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2128 ::GetColor(myNormalVProp,r,g,b);
2129 delta = myDeltaVBrightness;
2132 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2134 myEdgeProp->SetColor(r,g,b);
2135 my1DProp->SetColor(r,g,b);
2136 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2137 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2138 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2139 myNameActor->SetBackgroundColor(r,g,b);
2143 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2145 ::GetColor(myEdgeProp,r,g,b);
2148 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2150 myOutLineProp->SetColor(r,g,b);
2154 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2156 ::GetColor(myOutLineProp,r,g,b);
2160 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2162 myNodeProp->SetColor(r,g,b);
2163 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2164 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2165 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2166 myNameActor->SetBackgroundColor(r,g,b);
2170 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2172 ::GetColor(myNodeProp,r,g,b);
2175 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2177 my0DProp->SetColor(r,g,b);
2178 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2179 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2180 myNameActor->SetBackgroundColor(r,g,b);
2184 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2186 ::GetColor(my0DProp,r,g,b);
2189 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2191 myBallProp->SetColor(r,g,b);
2192 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2193 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2194 myNameActor->SetBackgroundColor(r,g,b);
2198 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2200 ::GetColor(myBallProp,r,g,b);
2203 void SMESH_ActorDef::UpdateSelectionProps()
2205 QColor selectionColor = SMESH_ActorProps::props()->selectionColor();
2206 QColor highlightColor = SMESH_ActorProps::props()->highlightColor();
2207 int selectionIncrement = SMESH_ActorProps::props()->selectionIncrement();
2208 double width = GetLineWidth();
2209 myHighlightProp->SetColor(selectionColor.redF(), selectionColor.greenF(), selectionColor.blueF());
2210 myHighlightProp->SetLineWidth(width + selectionIncrement);
2211 myPreselectProp->SetColor(highlightColor.redF(), highlightColor.greenF(), highlightColor.blueF());
2212 myPreselectProp->SetLineWidth(width + selectionIncrement);
2216 double SMESH_ActorDef::GetLineWidth()
2218 return myEdgeProp->GetLineWidth();
2222 void SMESH_ActorDef::SetLineWidth(double theVal)
2224 int controlsIncrement = SMESH_ActorProps::props()->controlsIncrement();
2225 int selectionIncrement = SMESH_ActorProps::props()->selectionIncrement();
2227 myEdgeProp->SetLineWidth(theVal);
2229 my1DProp->SetLineWidth(theVal + controlsIncrement);
2230 my1DExtProp->SetLineWidth(theVal + controlsIncrement);
2231 my2DExtProp->SetLineWidth(theVal + controlsIncrement);
2232 my3DExtProp->SetLineWidth(theVal + controlsIncrement);
2233 myHighlightProp->SetLineWidth(theVal + selectionIncrement);
2234 myPreselectProp->SetLineWidth(theVal + selectionIncrement);
2238 double SMESH_ActorDef::GetOutlineWidth()
2240 return myOutLineProp->GetLineWidth();
2243 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2245 myOutLineProp->SetLineWidth(theVal);
2249 void SMESH_ActorDef::Set0DSize(double theVal)
2251 my0DProp->SetPointSize(theVal);
2252 myHighlightProp->SetPointSize(theVal);
2253 myPreselectProp->SetPointSize(theVal);
2255 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2256 aCustom->Set0DSize(theVal);
2258 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2259 aCustom->Set0DSize(theVal);
2265 double SMESH_ActorDef::Get0DSize()
2267 return my0DProp->GetPointSize();
2270 void SMESH_ActorDef::SetBallSize(double theVal)
2272 myBallProp->SetPointSize(theVal);
2274 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2275 aCustom->SetBallSize(theVal);
2277 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2278 aCustom->SetBallSize(theVal);
2284 double SMESH_ActorDef::GetBallSize()
2286 return myBallProp->GetPointSize();
2289 double SMESH_ActorDef::GetBallScale()
2291 return myBallActor->GetBallScale();
2294 void SMESH_ActorDef::SetBallScale( double theVal )
2296 myBallActor->SetBallScale( theVal );
2297 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2298 aCustom->SetBallScale(theVal);
2300 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2301 aCustom->SetBallScale(theVal);
2307 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2309 return myVisualObj->GetElemDimension( theObjId );
2312 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2314 return myBaseActor->IsImplicitFunctionUsed();
2317 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2319 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2320 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2322 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2324 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2326 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2327 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2328 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2330 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2331 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2333 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2334 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2335 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2336 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2339 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2342 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2343 myCippingPlaneCont.push_back(thePlane);
2344 if(!IsImplicitFunctionUsed())
2345 SetImplicitFunctionUsed(true);
2346 myNodeActor->UpdateLabels();
2348 return myCippingPlaneCont.size();
2351 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2354 myPlaneCollection->AddItem( thePlane );
2357 void SMESH_ActorDef::SetOpenGLClippingPlane()
2359 // before use this method you must add clipping planes using method
2360 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2361 if( !myPlaneCollection->GetNumberOfItems() )
2364 // It is necessary to set plane collection for each mapper of actor
2365 // and update current inputs of mapper
2366 myNodeActor->SetPlaneCollection( myPlaneCollection );
2367 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2369 myBaseActor->SetPlaneCollection( myPlaneCollection );
2370 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2372 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2373 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2375 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2377 myBaseActor->SetUnstructuredGrid( NULL );
2378 //myHighlitableActor->SetUnstructuredGrid( NULL );
2380 my1DActor->SetPlaneCollection( myPlaneCollection );
2381 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2383 my2DActor->SetPlaneCollection( myPlaneCollection );
2384 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2386 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2387 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2389 my0DActor->SetPlaneCollection( myPlaneCollection );
2390 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2392 myBallActor->SetPlaneCollection( myPlaneCollection );
2393 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2395 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2396 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2398 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2399 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2401 my3DActor->SetPlaneCollection( myPlaneCollection );
2402 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2404 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2405 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2413 void SMESH_ActorDef::RemoveAllClippingPlanes()
2415 myPlaneCollection->RemoveAllItems();
2416 myImplicitBoolean->GetFunction()->RemoveAllItems();
2417 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2418 myCippingPlaneCont.clear();
2419 SetImplicitFunctionUsed(false);
2420 myNodeActor->UpdateLabels();
2423 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2425 return myCippingPlaneCont.size();
2428 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2430 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2432 return myCippingPlaneCont[theID].Get();
2435 void SMESH_ActorDef::UpdateScalarBar()
2437 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2441 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2443 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2444 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2446 aScalarBarTitleProp->SetFontFamilyToArial();
2448 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2450 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2451 if ( f.family() == "Arial" )
2452 aScalarBarTitleProp->SetFontFamilyToArial();
2453 else if ( f.family() == "Courier" )
2454 aScalarBarTitleProp->SetFontFamilyToCourier();
2455 else if ( f.family() == "Times" )
2456 aScalarBarTitleProp->SetFontFamilyToTimes();
2459 aScalarBarTitleProp->BoldOn();
2461 aScalarBarTitleProp->BoldOff();
2464 aScalarBarTitleProp->ItalicOn();
2466 aScalarBarTitleProp->ItalicOff();
2469 aScalarBarTitleProp->ShadowOn();
2471 aScalarBarTitleProp->ShadowOff();
2474 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2475 aScalarBarTitleProp->Delete();
2477 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2479 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2480 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2482 aScalarBarLabelProp->SetFontFamilyToArial();
2483 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2485 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2486 if( f.family() == "Arial" )
2487 aScalarBarLabelProp->SetFontFamilyToArial();
2488 else if( f.family() == "Courier" )
2489 aScalarBarLabelProp->SetFontFamilyToCourier();
2490 else if( f.family() == "Times" )
2491 aScalarBarLabelProp->SetFontFamilyToTimes();
2494 aScalarBarLabelProp->BoldOn();
2496 aScalarBarLabelProp->BoldOff();
2499 aScalarBarLabelProp->ItalicOn();
2501 aScalarBarLabelProp->ItalicOff();
2504 aScalarBarLabelProp->ShadowOn();
2506 aScalarBarLabelProp->ShadowOff();
2509 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2510 aScalarBarLabelProp->Delete();
2512 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2513 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2515 myScalarBarActor->SetOrientationToHorizontal();
2517 myScalarBarActor->SetOrientationToVertical();
2520 double aXVal = horiz ? 0.20 : 0.01;
2521 if( mgr->hasValue( "SMESH", name + "x" ) )
2522 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2524 double aYVal = horiz ? 0.01 : 0.1;
2525 if( mgr->hasValue( "SMESH", name + "y" ) )
2526 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2527 myScalarBarActor->SetPosition( aXVal, aYVal );
2529 double aWVal = horiz ? 0.60 : 0.10;
2530 if( mgr->hasValue( "SMESH", name + "width" ) )
2531 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2532 myScalarBarActor->SetWidth( aWVal );
2534 double aHVal = horiz ? 0.12 : 0.80;
2535 if( mgr->hasValue( "SMESH", name + "height" ) )
2536 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2537 myScalarBarActor->SetHeight( aHVal );
2540 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2541 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2542 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2545 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2546 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2547 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2549 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2550 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2552 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2553 myScalarBarActor->SetDistributionColoringType(coloringType);
2555 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2556 QColor(255, 255, 255));
2558 rgb[0]= distributionColor.red()/255.;
2559 rgb[1]= distributionColor.green()/255.;
2560 rgb[2]= distributionColor.blue()/255.;
2561 myScalarBarActor->SetDistributionColor(rgb);
2566 void SMESH_ActorDef::UpdateDistribution()
2568 if(SMESH::Controls::NumericalFunctor* fun =
2569 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2571 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2572 std::vector<int> nbEvents;
2573 std::vector<double> funValues;
2574 SMESH_VisualObjDef::TEntityList elems;
2575 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2576 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2577 std::vector<int> elemIds; elemIds.reserve( elems.size() );
2578 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2579 elemIds.push_back( (*e)->GetID());
2580 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2581 double * range = lookupTable->GetRange();
2582 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2583 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2584 myScalarBarActor->SetDistribution(nbEvents);
2588 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2591 case SMESH_Actor::eLines :
2592 myHighlitableActor->SetQuadraticArcMode(false);
2593 my2DActor->SetQuadraticArcMode(false);
2594 my1DActor->SetQuadraticArcMode(false);
2596 case SMESH_Actor::eArcs :
2597 myHighlitableActor->SetQuadraticArcMode(true);
2598 if(GetRepresentation() != SMESH_Actor::ePoint) {
2599 my2DActor->SetQuadraticArcMode(true);
2600 my1DActor->SetQuadraticArcMode(true);
2609 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2611 if(myHighlitableActor->GetQuadraticArcMode())
2612 return SMESH_Actor::eArcs;
2614 return SMESH_Actor::eLines;
2617 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2619 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2620 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2621 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2624 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2626 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2627 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2628 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2629 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2632 #ifndef DISABLE_PLOT2DVIEWER
2633 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2636 my2dHistogram->clearAllPoints();
2638 if(SMESH::Controls::NumericalFunctor* fun =
2639 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2642 if(!my2dHistogram) {
2643 my2dHistogram = new SPlot2d_Histogram();
2644 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2645 my2dHistogram->setIO(anIO);
2648 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2649 std::vector<int> nbEvents;
2650 std::vector<double> funValues;
2651 SMESH_VisualObjDef::TEntityList elems;
2652 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2653 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2654 std::vector<int> elemIds;
2656 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2657 elemIds.push_back( (*e)->GetID());
2659 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2660 double * range = lookupTable->GetRange();
2661 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2662 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2664 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2665 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2667 if(funValues.size() >= 2)
2668 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2672 //Color of the histogram
2673 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2674 my2dHistogram->setAutoAssign(true);
2677 myScalarBarActor->GetDistributionColor(rgb);
2678 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2679 my2dHistogram->setColor(aColor);
2683 return my2dHistogram;