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_ActorUtils.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ControlsDef.hxx"
34 #include "SMESH_DeviceActor.h"
35 #include "SMESH_NodeLabelActor.h"
36 #include "SMESH_ObjectDef.h"
37 #include "SMESH_SVTKActor.h"
38 #include "SMESH_ScalarBarActor.h"
41 #include <SALOME_InteractiveObject.hxx>
42 #include <SUIT_ResourceMgr.h>
43 #include <SUIT_Session.h>
44 #include <VTKViewer_ExtractUnstructuredGrid.h>
45 #include <VTKViewer_FramedTextActor.h>
47 #ifndef DISABLE_PLOT2DVIEWER
48 #include <SPlot2d_Histogram.h>
51 #include <vtkProperty.h>
52 #include <vtkTimeStamp.h>
53 #include <vtkObjectFactory.h>
54 #include <vtkShrinkPolyData.h>
55 #include <vtkMergeFilter.h>
57 #include <vtkMatrix4x4.h>
58 #include <vtkUnstructuredGrid.h>
59 #include <vtkPointData.h>
60 #include <vtkCellData.h>
62 #include <vtkMapper.h>
63 #include <vtkRenderer.h>
66 #include <vtkIdList.h>
67 #include <vtkIntArray.h>
69 #include <vtkActor2D.h>
70 #include <vtkProperty2D.h>
71 #include <vtkPolyData.h>
72 #include <vtkTextProperty.h>
74 #include <vtkLookupTable.h>
78 #include <vtkPlaneCollection.h>
79 #include <vtkImplicitBoolean.h>
80 #include <vtkImplicitFunctionCollection.h>
82 #include "utilities.h"
85 static int MYDEBUG = 0;
87 static int MYDEBUG = 0;
90 static int aLineWidthInc = 2;
93 SMESH_ActorDef* SMESH_ActorDef::New(){
94 return new SMESH_ActorDef();
98 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
103 SMESH_ActorDef* anActor = NULL;
104 if(theVisualObj->IsValid() ) {
105 anActor = SMESH_ActorDef::New();
106 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
111 anActor->UpdateScalarBar();
117 SMESH_ActorDef::SMESH_ActorDef()
119 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
121 SALOME_Actor::SetVisibility(false); // avoid update of pipelines
123 myBaseActor = SMESH_DeviceActor::New();
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
128 myIsEntityModeCache = false;
129 myRepresentationCache = 0;
131 myHighlightActor = SMESH_SVTKActor::New();
132 myHighlightActor->Delete(); // vtkSmartPointer!
133 myHighlightActor->Initialize();
135 myPreHighlightActor = SMESH_SVTKActor::New();
136 myPreHighlightActor->Delete();
137 myPreHighlightActor->Initialize();
139 myIsShrinkable = false;
142 myIsFacesOriented = false;
144 myControlsPrecision = -1;
145 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
147 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
148 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
150 double aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
151 double aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
152 double aBallElemScale = SMESH::GetFloat("SMESH:ball_elem_scale",1.0);
153 double aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
154 double aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
156 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
158 bool anItalicNd = false;
159 bool aShadowNd = false;
161 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
162 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
163 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
164 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
165 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
167 anItalicNd = f.italic();
168 aShadowNd = f.overline();
169 aSizeNd = f.pointSize();
171 double anRGBNd[3] = {1,1,1};
172 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
174 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
176 bool anItalicEl = false;
177 bool aShadowEl = false;
179 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
180 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
181 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
182 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
183 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
185 anItalicEl = f.italic();
186 aShadowEl = f.overline();
187 aSizeEl = f.pointSize();
189 double anRGBEl[3] = {0,1,0};
190 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
192 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
193 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
195 //Definition 2D and 3D devices of the actor
196 //-----------------------------------------
197 double anRGB[3] = {1,1,1};
198 mySurfaceProp = vtkProperty::New();
201 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
202 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
203 myDeltaBrightness = delta;
205 myBackSurfaceProp = vtkProperty::New();
206 bfc = Qtx::mainColorToSecondary(ffc, delta);
207 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
209 myNormalVProp = vtkProperty::New();
210 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
211 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
212 myDeltaVBrightness = delta;
214 myReversedVProp = vtkProperty::New();
215 bfc = Qtx::mainColorToSecondary(ffc, delta);
216 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
218 my2DActor = SMESH_CellLabelActor::New();
219 my2DActor->SetStoreClippingMapping(true);
220 my2DActor->SetUserMatrix(aMatrix);
221 my2DActor->PickableOff();
222 my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
223 my2DActor->SetProperty(mySurfaceProp);
224 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
225 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
226 aFilter = my2DActor->GetExtractUnstructuredGrid();
227 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
228 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
229 aFilter->RegisterCellsWithType(VTK_QUAD);
230 aFilter->RegisterCellsWithType(VTK_POLYGON);
231 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
232 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
233 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
234 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
235 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
237 my2DExtProp = vtkProperty::New();
238 my2DExtProp->DeepCopy(mySurfaceProp);
239 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
240 anRGB[0] = 1 - anRGB[0];
241 anRGB[1] = 1 - anRGB[1];
242 anRGB[2] = 1 - anRGB[2];
243 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
245 my2DExtActor = SMESH_DeviceActor::New();
246 my2DExtActor->SetUserMatrix(aMatrix);
247 my2DExtActor->PickableOff();
248 my2DExtActor->SetProperty(my2DExtProp);
249 my2DExtActor->SetBackfaceProperty(my2DExtProp);
250 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
251 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
252 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
253 aFilter->RegisterCellsWithType(VTK_QUAD);
254 aFilter->RegisterCellsWithType(VTK_POLYGON);
255 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
256 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
257 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
258 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
259 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
261 my3DActor = SMESH_CellLabelActor::New();
262 my3DActor->SetStoreClippingMapping(true);
263 my3DActor->SetUserMatrix(aMatrix);
264 my3DActor->PickableOff();
265 my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
266 my3DActor->SetProperty(myNormalVProp);
267 my3DActor->SetBackfaceProperty(myReversedVProp);
268 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
269 my3DActor->SetCoincident3DAllowed(true);
270 aFilter = my3DActor->GetExtractUnstructuredGrid();
271 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
272 aFilter->RegisterCellsWithType(VTK_TETRA);
273 aFilter->RegisterCellsWithType(VTK_VOXEL);
274 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
275 aFilter->RegisterCellsWithType(VTK_WEDGE);
276 aFilter->RegisterCellsWithType(VTK_PYRAMID);
277 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
278 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
279 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
280 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
281 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
282 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
283 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
284 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
285 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
287 my3DExtProp = vtkProperty::New();
288 my3DExtProp->DeepCopy(myNormalVProp);
289 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
290 anRGB[0] = 1 - anRGB[0];
291 anRGB[1] = 1 - anRGB[1];
292 anRGB[2] = 1 - anRGB[2];
293 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
295 my3DExtActor = SMESH_DeviceActor::New();
296 my3DExtActor->SetUserMatrix(aMatrix);
297 my3DExtActor->PickableOff();
298 my3DExtActor->SetProperty(my3DExtProp);
299 my3DExtActor->SetBackfaceProperty(my3DExtProp);
300 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
301 my3DExtActor->SetCoincident3DAllowed(true);
302 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
303 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
304 aFilter->RegisterCellsWithType(VTK_TETRA);
305 aFilter->RegisterCellsWithType(VTK_VOXEL);
306 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
307 aFilter->RegisterCellsWithType(VTK_WEDGE);
308 aFilter->RegisterCellsWithType(VTK_PYRAMID);
309 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
310 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
311 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
312 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
313 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
314 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
315 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
316 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
317 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
319 //Definition 1D device of the actor
320 //---------------------------------
321 myEdgeProp = vtkProperty::New();
322 myEdgeProp->SetAmbient(1.0);
323 myEdgeProp->SetDiffuse(0.0);
324 myEdgeProp->SetSpecular(0.0);
325 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
326 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
327 myEdgeProp->SetLineWidth(aLineWidth);
329 // my1DActor is used to
331 // - show controls on all edges (eg Length)
332 // since edges are shown by myHighlitableActor
333 my1DActor = SMESH_CellLabelActor::New();
334 my1DActor->SetStoreClippingMapping(true);
335 my1DActor->SetUserMatrix(aMatrix);
336 my1DActor->PickableOff();
337 my1DActor->SetHighlited(true);
338 my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
339 my1DActor->SetProperty(myEdgeProp);
340 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
341 aFilter = my1DActor->GetExtractUnstructuredGrid();
342 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
343 aFilter->RegisterCellsWithType(VTK_LINE);
344 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
346 my1DProp = vtkProperty::New();
347 my1DProp->DeepCopy(myEdgeProp);
348 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
349 my1DProp->SetPointSize(aElem0DSize);
351 my1DExtProp = vtkProperty::New();
352 my1DExtProp->DeepCopy(myEdgeProp);
353 anRGB[0] = 1 - anRGB[0];
354 anRGB[1] = 1 - anRGB[1];
355 anRGB[2] = 1 - anRGB[2];
356 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
357 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
358 my1DExtProp->SetPointSize(aElem0DSize);
360 // my1DExtActor is used to show filtered edges or links between nodes
361 my1DExtActor = SMESH_DeviceActor::New();
362 my1DExtActor->SetUserMatrix(aMatrix);
363 my1DExtActor->PickableOff();
364 my1DExtActor->SetHighlited(true);
365 my1DExtActor->SetVisibility(false);
366 my1DExtActor->SetProperty(my1DExtProp);
367 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
368 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
369 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
370 aFilter->RegisterCellsWithType(VTK_LINE);
371 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
374 //Definition 0D device of the actor (0d elements)
375 //-----------------------------------------------
376 my0DProp = vtkProperty::New();
377 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
378 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
379 my0DProp->SetPointSize(aElem0DSize);
381 my0DActor = SMESH_CellLabelActor::New();
382 my0DActor->SetUserMatrix(aMatrix);
383 my0DActor->SetStoreClippingMapping(true);
384 my0DActor->PickableOff();
385 my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
386 my0DActor->SetVisibility(false);
387 my0DActor->SetProperty(my0DProp);
388 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
389 aFilter = my0DActor->GetExtractUnstructuredGrid();
390 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
391 aFilter->RegisterCellsWithType(VTK_VERTEX);
393 //Definition 0D device of the actor (ball elements)
394 //-----------------------------------------------
395 myBallProp = vtkProperty::New();
396 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
397 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
398 myBallProp->SetPointSize(aBallElemSize);
400 myBallActor = SMESH_CellLabelActor::New();
401 myBallActor->SetUserMatrix(aMatrix);
402 myBallActor->SetStoreClippingMapping(true);
403 myBallActor->PickableOff();
404 myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
405 myBallActor->SetVisibility(false);
406 myBallActor->SetProperty(myBallProp);
407 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
408 myBallActor->SetBallEnabled(true);
409 aFilter = myBallActor->GetExtractUnstructuredGrid();
410 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
411 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
413 //my0DExtProp = vtkProperty::New();
414 //my0DExtProp->DeepCopy(my0DProp);
415 //anRGB[0] = 1 - anRGB[0];
416 //anRGB[1] = 1 - anRGB[1];
417 //anRGB[2] = 1 - anRGB[2];
418 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
419 //my0DExtProp->SetPointSize(aElem0DSize);
421 //my0DExtActor = SMESH_DeviceActor::New();
422 //my0DExtActor->SetUserMatrix(aMatrix);
423 //my0DExtActor->SetStoreClippingMapping(true);
424 //my0DExtActor->PickableOff();
425 //my0DExtActor->SetHighlited(true);
426 //my0DExtActor->SetVisibility(false);
427 //my0DExtActor->SetProperty(my0DExtProp);
428 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
429 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
430 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
431 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
432 //aFilter->RegisterCellsWithType(VTK_VERTEX);
435 //Definition 0D device of the actor (nodes)
436 //-----------------------------------------
437 myNodeProp = vtkProperty::New();
438 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
439 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
441 myNodeActor = SMESH_NodeLabelActor::New();
442 myNodeActor->SetUserMatrix(aMatrix);
443 myNodeActor->SetStoreClippingMapping(true);
444 myNodeActor->PickableOff();
445 myNodeActor->SetVisibility(false);
446 myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
447 myNodeActor->SetProperty(myNodeProp);
448 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
449 aFilter = myNodeActor->GetExtractUnstructuredGrid();
450 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
452 myNodeExtProp = vtkProperty::New();
453 myNodeExtProp->DeepCopy(myNodeProp);
454 anRGB[0] = 1 - anRGB[0];
455 anRGB[1] = 1 - anRGB[1];
456 anRGB[2] = 1 - anRGB[2];
457 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
459 myNodeExtActor = SMESH_DeviceActor::New();
460 myNodeExtActor->SetUserMatrix(aMatrix);
461 myNodeExtActor->SetStoreClippingMapping(true);
462 myNodeExtActor->PickableOff();
463 myNodeExtActor->SetHighlited(true);
464 myNodeExtActor->SetVisibility(false);
465 myNodeExtActor->SetProperty(myNodeExtProp);
466 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
467 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
468 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
469 aFilter->RegisterCellsWithType(VTK_VERTEX);
471 //Definition of Pickable and Highlitable engines
472 //----------------------------------------------
474 myBaseActor->SetUserMatrix(aMatrix);
475 myBaseActor->SetStoreIDMapping(true);
476 myBaseActor->SetStoreClippingMapping(true);
477 myBaseActor->SetStoreGemetryMapping(true);
478 myBaseActor->GetProperty()->SetOpacity(0.0);
479 myPickableActor = myBaseActor;
481 myHighlightProp = vtkProperty::New();
482 myHighlightProp->SetAmbient(1.0);
483 myHighlightProp->SetDiffuse(0.0);
484 myHighlightProp->SetSpecular(0.0);
485 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
486 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
487 myHighlightProp->SetPointSize(aElem0DSize); // ??
488 myHighlightProp->SetLineWidth(aLineWidth);
489 myHighlightProp->SetRepresentation(1);
491 myOutLineProp = vtkProperty::New();
492 myOutLineProp->SetAmbient(1.0);
493 myOutLineProp->SetDiffuse(0.0);
494 myOutLineProp->SetSpecular(0.0);
495 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
496 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
497 myOutLineProp->SetLineWidth(aOutlineWidth);
498 myOutLineProp->SetRepresentation(1);
500 myPreselectProp = vtkProperty::New();
501 myPreselectProp->SetAmbient(1.0);
502 myPreselectProp->SetDiffuse(0.0);
503 myPreselectProp->SetSpecular(0.0);
504 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
505 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
506 myPreselectProp->SetPointSize(aElem0DSize); // ??
507 myPreselectProp->SetLineWidth(aLineWidth);
508 myPreselectProp->SetRepresentation(1);
510 myHighlitableActor = SMESH_DeviceActor::New();
511 myHighlitableActor->SetUserMatrix(aMatrix);
512 myHighlitableActor->PickableOff();
513 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
514 myHighlitableActor->SetCoincident3DAllowed(true);
521 myControlMode = eNone;
522 myControlActor = my2DActor;
524 //Definition of myScalarBarActor
525 //------------------------------
526 myLookupTable = vtkLookupTable::New();
527 //Fix for Bug PAL5195 - SMESH764:
528 //Controls - Aspect Ratio: incorrect colors of the best and worst values
529 myLookupTable->SetHueRange(0.667,0.0);
531 myScalarBarActor = SMESH_ScalarBarActor::New();
532 myScalarBarActor->SetVisibility(false);
533 myScalarBarActor->SetLookupTable(myLookupTable);
536 //Incorrect "Min value" in Scalar Bar in Mesh:
537 // myScalarBarActor->SetLabelFormat("%.4g");
538 // changes was commented because of regression bug IPAL 19981
540 mgr = SUIT_Session::session()->resourceMgr();
544 myEntityMode = eAllEntity;
545 myEntityModeCache = eAllEntity;
548 myImplicitBoolean = vtkImplicitBoolean::New();
549 myImplicitBoolean->SetOperationTypeToIntersection();
551 myPlaneCollection = vtkPlaneCollection::New();
553 //Quadratic 2D elements representation
554 //-----------------------------------------------------------------------------
555 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
556 if(aQuadratic2DMode == 0){
557 myHighlitableActor->SetQuadraticArcMode(false);
558 my2DActor->SetQuadraticArcMode(false);
559 my1DActor->SetQuadraticArcMode(false);
561 else if(aQuadratic2DMode == 1){
562 myHighlitableActor->SetQuadraticArcMode(true);
563 my2DActor->SetQuadraticArcMode(true);
564 my1DActor->SetQuadraticArcMode(true);
567 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
568 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
569 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
571 // Set colors of the name actor
572 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
573 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
574 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
575 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
577 #ifndef DISABLE_PLOT2DVIEWER
581 SetBallSize(aBallElemSize);
582 SetBallScale(aBallElemScale);
583 Set0DSize(aElem0DSize);
587 SMESH_ActorDef::~SMESH_ActorDef()
589 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
591 // Please keep the order same as one in the header file
593 myTimeStamp->Delete();
595 myScalarBarActor->Delete();
596 myLookupTable->Delete();
598 mySurfaceProp->Delete();
599 myBackSurfaceProp->Delete();
600 myNormalVProp->Delete();
601 myReversedVProp->Delete();
602 myEdgeProp->Delete();
603 myNodeProp->Delete();
605 myNodeActor->Delete();
606 myBaseActor->Delete();
607 //myPickableActor->Delete(); myPickableActor == myBaseActor
609 myHighlightProp->Delete();
610 myOutLineProp->Delete();
611 myPreselectProp->Delete();
613 myHighlitableActor->Delete();
615 my2DExtProp->Delete();
616 my3DExtProp->Delete();
618 my2DExtActor->Delete();
620 my3DExtActor->Delete();
621 // myControlActor->Delete(); myControlActor == my2DActor
623 myNodeExtProp->Delete();
624 myNodeExtActor->Delete();
628 my1DExtProp->Delete();
629 my1DExtActor->Delete();
633 myBallProp->Delete();
634 myBallActor->Delete();
635 //my0DExtProp->Delete();
636 //my0DExtActor->Delete();
638 myImplicitBoolean->Delete();
639 myPlaneCollection->Delete();
641 #ifndef DISABLE_PLOT2DVIEWER
643 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
644 delete my2dHistogram;
649 void SMESH_ActorDef::Delete()
651 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
652 // from the actor's destructor) will be thrown before removing the actor's observers,
653 // that is done inside the Superclass::Delete() method but before the destructor itself
654 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
655 // The event is caught by SMESHGUI::ProcessEvents() static method.
656 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
658 Superclass::Delete();
661 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
664 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
665 SetRepresentation(GetRepresentation());
666 myTimeStamp->Modified();
670 void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
671 bool theBold, bool theItalic, bool theShadow,
672 double r, double g, double b )
675 myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
676 SetRepresentation( GetRepresentation() );
677 myTimeStamp->Modified();
681 void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
682 bool theBold, bool theItalic, bool theShadow,
683 double r, double g, double b )
686 my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
689 my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
690 SetRepresentation( GetRepresentation() );
691 myTimeStamp->Modified();
694 my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
695 SetRepresentation( GetRepresentation() );
696 myTimeStamp->Modified();
699 my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
700 SetRepresentation( GetRepresentation() );
701 myTimeStamp->Modified();
704 myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
705 SetRepresentation( GetRepresentation() );
706 myTimeStamp->Modified();
710 bool SMESH_ActorDef::GetPointsLabeled()
712 return myNodeActor && myNodeActor->GetPointsLabeled();
715 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
718 my3DActor->SetCellsLabeled(theIsCellsLabeled);
721 my2DActor->SetCellsLabeled(theIsCellsLabeled);
724 my1DActor->SetCellsLabeled(theIsCellsLabeled);
727 my0DActor->SetCellsLabeled(theIsCellsLabeled);
730 myBallActor->SetCellsLabeled(theIsCellsLabeled);
732 myTimeStamp->Modified();
736 bool SMESH_ActorDef::GetCellsLabeled()
740 result = result || my3DActor->GetCellsLabeled();
743 result = result || my2DActor->GetCellsLabeled();
746 result = result || my1DActor->GetCellsLabeled();
749 result = result || my0DActor->GetCellsLabeled();
752 result = result || myBallActor->GetCellsLabeled();
758 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
760 myIsFacesOriented = theIsFacesOriented;
762 my2DActor->SetFacesOriented(theIsFacesOriented);
763 my3DActor->SetFacesOriented(theIsFacesOriented);
765 myTimeStamp->Modified();
768 bool SMESH_ActorDef::GetFacesOriented()
770 return myIsFacesOriented;
773 void SMESH_ActorDef::SetFacesOrientationColor(double r,double g,double b)
775 my2DActor->SetFacesOrientationColor( r, g, b );
776 my3DActor->SetFacesOrientationColor( r, g, b );
779 void SMESH_ActorDef::GetFacesOrientationColor(double& r,double& g,double& b)
781 my3DActor->GetFacesOrientationColor( r, g, b );
784 void SMESH_ActorDef::SetFacesOrientationScale(double theScale)
786 my2DActor->SetFacesOrientationScale( theScale );
787 my3DActor->SetFacesOrientationScale( theScale );
790 double SMESH_ActorDef::GetFacesOrientationScale()
792 return my3DActor->GetFacesOrientationScale();
795 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
797 my2DActor->SetFacesOrientation3DVectors( theState );
798 my3DActor->SetFacesOrientation3DVectors( theState );
801 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
803 return my3DActor->GetFacesOrientation3DVectors();
807 void SMESH_ActorDef::SetControlMode(eControl theMode)
809 SetControlMode(theMode,true);
813 void SMESH_ActorDef::SetControlMode( eControl theMode, bool theCheckEntityMode )
815 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
816 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
817 lookupTable->SetScale(VTK_SCALE_LINEAR);
819 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
823 //myControlMode = eNone;
824 myControlMode = theMode;
825 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
827 my0DActor->GetMapper()->SetScalarVisibility(false);
828 my1DActor->GetMapper()->SetScalarVisibility(false);
829 my2DActor->GetMapper()->SetScalarVisibility(false);
830 my3DActor->GetMapper()->SetScalarVisibility(false);
831 myBallActor->GetMapper()->SetScalarVisibility(false);
832 myScalarBarActor->SetVisibility(false);
834 bool anIsScalarVisible = theMode > eNone;
836 if(anIsScalarVisible) {
840 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
841 aControl->SetPrecision( myControlsPrecision );
842 myFunctor.reset( aControl );
843 myControlActor = my1DActor;
847 myFunctor.reset(new SMESH::Controls::Length2D());
848 myControlActor = my2DActor;
851 myFunctor.reset(new SMESH::Controls::FreeBorders());
852 myControlActor = my1DActor;
855 myFunctor.reset(new SMESH::Controls::FreeEdges());
856 myControlActor = my2DActor;
859 myFunctor.reset(new SMESH::Controls::FreeNodes());
860 myControlActor = myNodeActor;
863 myFunctor.reset(new SMESH::Controls::FreeFaces());
864 myControlActor = my2DActor;
866 case eCoincidentNodes:
868 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
869 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
870 cn->SetTolerance( tol );
872 myControlActor = myNodeActor;
875 case eCoincidentElems1D:
876 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
877 myControlActor = my1DActor;
879 case eCoincidentElems2D:
880 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
881 myControlActor = my2DActor;
883 case eCoincidentElems3D:
884 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
885 myControlActor = my3DActor;
887 case eBareBorderFace:
888 myFunctor.reset(new SMESH::Controls::BareBorderFace());
889 myControlActor = my2DActor;
891 case eOverConstrainedFace:
892 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
893 myControlActor = my2DActor;
895 case eMultiConnection:
896 myFunctor.reset(new SMESH::Controls::MultiConnection());
897 myControlActor = my1DActor;
899 case eMultiConnection2D:
900 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
901 myControlActor = my2DActor;
905 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
906 aControl->SetPrecision( myControlsPrecision );
907 myFunctor.reset( aControl );
908 myControlActor = my2DActor;
913 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
914 aControl->SetPrecision( myControlsPrecision );
915 myFunctor.reset( aControl );
916 myControlActor = my2DActor;
921 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
922 aControl->SetPrecision( myControlsPrecision );
923 myFunctor.reset( aControl );
924 myControlActor = my2DActor;
929 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
930 aControl->SetPrecision( myControlsPrecision );
931 myFunctor.reset( aControl );
932 myControlActor = my3DActor;
937 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
938 aControl->SetPrecision( myControlsPrecision );
939 myFunctor.reset( aControl );
940 myControlActor = my3DActor;
943 case eMaxElementLength2D:
945 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
946 aControl->SetPrecision( myControlsPrecision );
947 myFunctor.reset( aControl );
948 myControlActor = my2DActor;
951 case eMaxElementLength3D:
953 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
954 aControl->SetPrecision( myControlsPrecision );
955 myFunctor.reset( aControl );
956 myControlActor = my3DActor;
961 SMESH::Controls::Deflection2D* aControl = new SMESH::Controls::Deflection2D();
962 aControl->SetPrecision( myControlsPrecision );
963 myFunctor.reset( aControl );
964 myControlActor = my2DActor;
967 case eBareBorderVolume:
969 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
970 myControlActor = my3DActor;
973 case eOverConstrainedVolume:
975 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
976 myControlActor = my3DActor;
981 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
982 aControl->SetPrecision( myControlsPrecision );
983 myFunctor.reset( aControl );
984 myControlActor = my2DActor;
989 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
990 aControl->SetPrecision( myControlsPrecision );
991 myFunctor.reset( aControl );
992 myControlActor = my2DActor;
997 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
998 aControl->SetPrecision( myControlsPrecision );
999 myFunctor.reset( aControl );
1000 myControlActor = my2DActor;
1003 case eNodeConnectivityNb:
1005 myFunctor.reset( new SMESH::Controls::NodeConnectivityNumber() );
1006 myControlActor = myNodeActor;
1013 int aNbCells = myFunctor ? myVisualObj->GetNbEntities( myFunctor->GetType() ) : 0;
1014 bool aShowOnlyScalarBarTitle = false;
1016 //myControlMode = theMode;
1017 switch(myControlMode){
1019 case eCoincidentNodes:
1020 myNodeExtActor->SetExtControlMode(myFunctor);
1021 aShowOnlyScalarBarTitle = true;
1025 case eCoincidentElems1D:
1026 my1DExtActor->SetExtControlMode(myFunctor);
1027 aShowOnlyScalarBarTitle = true;
1030 case eBareBorderFace:
1031 case eOverConstrainedFace:
1032 case eCoincidentElems2D:
1033 my2DExtActor->SetExtControlMode(myFunctor);
1034 aShowOnlyScalarBarTitle = true;
1036 case eBareBorderVolume:
1037 case eOverConstrainedVolume:
1038 case eCoincidentElems3D:
1039 my3DExtActor->SetExtControlMode(myFunctor);
1040 aShowOnlyScalarBarTitle = true;
1043 case eMultiConnection2D:
1044 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
1045 UpdateDistribution();
1048 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
1049 UpdateDistribution();
1051 myScalarBarActor->SetTitleOnlyVisibility(aShowOnlyScalarBarTitle);
1054 if(theCheckEntityMode) {
1055 // if(myControlActor == myNodeActor) {
1056 // if ( myControlMode == eNodeConnectivityNb ) {
1057 // if (!myIsEntityModeCache){
1058 // myEntityModeCache = GetEntityMode();
1059 // myIsEntityModeCache=true;
1061 // SetEntityMode(0);
1064 if(myControlActor == my1DActor) {
1065 if (!myIsEntityModeCache){
1066 myEntityModeCache = GetEntityMode();
1067 myIsEntityModeCache=true;
1069 SetEntityMode(eEdges);
1071 else if(myControlActor == my2DActor) {
1072 if (!myIsEntityModeCache){
1073 myEntityModeCache = GetEntityMode();
1074 myIsEntityModeCache=true;
1076 SetEntityMode(eFaces);
1078 else if(myControlActor == my3DActor) {
1079 if (!myIsEntityModeCache){
1080 myEntityModeCache = GetEntityMode();
1081 myIsEntityModeCache=true;
1083 SetEntityMode(eVolumes);
1086 QString aTitle = QString(myScalarBarActor->GetTitle());
1087 aTitle.replace(QRegExp("(:\\s).*"),"\\1"+ QString::number(GetNumberControlEntities()));
1088 myScalarBarActor->SetTitle(aTitle.toLatin1().constData());
1092 if(theCheckEntityMode){
1093 myEntityMode = myEntityModeCache;
1094 myIsEntityModeCache = false;
1099 SetRepresentation(GetRepresentation());
1101 myTimeStamp->Modified();
1104 lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
1105 double * range = lookupTable->GetRange();
1107 if (isLogarithmic && range[0] > 1e-07 && range[1] > 1e-07)
1108 lookupTable->SetScale(VTK_SCALE_LOG10);
1113 int SMESH_ActorDef::GetNumberControlEntities()
1115 SMESH_DeviceActor* anAct = NULL;
1116 switch(myControlMode){
1118 case eCoincidentNodes:
1119 anAct = myNodeExtActor;
1123 case eCoincidentElems1D:
1124 anAct = my1DExtActor;
1127 case eBareBorderFace:
1128 case eOverConstrainedFace:
1129 case eCoincidentElems2D:
1130 anAct = my2DExtActor;
1132 case eBareBorderVolume:
1133 case eOverConstrainedVolume:
1134 case eCoincidentElems3D:
1135 anAct = my3DExtActor;
1139 return (anAct) ? anAct->GetUnstructuredGrid()->GetNumberOfCells() : -1;
1142 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer)
1144 if ( !mySelector || !mySelector->IsSelectionEnabled() )
1146 myBaseActor->SetUnstructuredGrid( NULL );
1147 //myHighlitableActor->SetUnstructuredGrid( NULL );
1149 theRenderer->AddActor(myBaseActor);
1150 theRenderer->AddActor(myNodeExtActor);
1151 theRenderer->AddActor(my1DExtActor);
1153 my3DActor ->AddToRender(theRenderer);
1154 my3DExtActor->AddToRender(theRenderer);
1155 my2DActor ->AddToRender(theRenderer);
1156 my2DExtActor->AddToRender(theRenderer);
1157 myNodeActor ->AddToRender(theRenderer);
1158 my1DActor ->AddToRender(theRenderer);
1159 my0DActor ->AddToRender(theRenderer);
1160 myBallActor ->AddToRender(theRenderer);
1162 theRenderer->AddActor(myHighlitableActor);
1164 theRenderer->AddActor2D(myScalarBarActor);
1166 // the superclass' method should be called at the end
1167 // (in particular, for correct work of selection)
1168 SALOME_Actor::AddToRender(theRenderer);
1171 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer)
1173 SALOME_Actor::RemoveFromRender(theRenderer);
1175 theRenderer->RemoveActor(myBaseActor);
1177 theRenderer->RemoveActor(myNodeExtActor);
1179 theRenderer->RemoveActor(myHighlitableActor);
1181 //theRenderer->RemoveActor(my0DExtActor);
1183 theRenderer->RemoveActor(my1DExtActor);
1185 my2DActor->RemoveFromRender(theRenderer);
1186 my2DExtActor->RemoveFromRender(theRenderer);
1187 my3DActor->RemoveFromRender(theRenderer);
1188 my3DExtActor->RemoveFromRender(theRenderer);
1189 myNodeActor->RemoveFromRender(theRenderer);
1190 my0DActor->RemoveFromRender(theRenderer);
1191 myBallActor->RemoveFromRender(theRenderer);
1192 my1DActor->RemoveFromRender(theRenderer);
1194 theRenderer->RemoveActor(myScalarBarActor);
1198 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1199 const char* theEntry,
1200 const char* theName,
1203 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1207 myVisualObj = theVisualObj;
1208 myVisualObj->Update(theIsClear);
1210 SMESH_SVTKActor::SafeDownCast(myHighlightActor)->SetVisualObject(myVisualObj);
1211 SMESH_SVTKActor::SafeDownCast(myPreHighlightActor)->SetVisualObject(myVisualObj);
1213 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1214 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1216 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1218 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1220 my0DActor->Init(myVisualObj,myImplicitBoolean);
1221 myBallActor->Init(myVisualObj,myImplicitBoolean);
1222 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1224 my1DActor->Init(myVisualObj,myImplicitBoolean);
1225 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1227 my2DActor->Init(myVisualObj,myImplicitBoolean);
1228 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1229 my3DActor->Init(myVisualObj,myImplicitBoolean);
1230 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1232 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1233 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1234 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1236 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1237 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1239 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1240 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1241 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1242 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1244 double aFactor, aUnits;
1245 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1246 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1247 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1248 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1250 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1254 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1255 SetIsShrunkable(true);
1257 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1259 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1260 SetRepresentation(-1);
1263 SetRepresentation(eEdge);
1264 }else if(aMode == 1){
1265 SetRepresentation(eSurface);
1266 }else if(aMode == 2){
1267 SetRepresentation(ePoint);
1274 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1275 SetIsDisplayNameActor( true );
1277 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1278 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1279 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1281 myTimeStamp->Modified();
1287 double* SMESH_ActorDef::GetBounds()
1289 if ( GetNumberOfClippingPlanes() + myPlaneCollection->GetNumberOfItems() > 0 )
1290 return myNodeActor->GetBounds();
1291 return myVisualObj->GetUnstructuredGrid()->GetPoints()->GetBounds();
1295 vtkDataSet* SMESH_ActorDef::GetInput()
1297 return GetUnstructuredGrid();
1301 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform)
1303 Superclass::SetTransform(theTransform);
1305 myNodeActor->SetTransform(theTransform);
1306 myBaseActor->SetTransform(theTransform);
1308 myHighlitableActor->SetTransform(theTransform);
1310 myNodeExtActor->SetTransform(theTransform);
1312 my0DActor->SetTransform(theTransform);
1313 myBallActor->SetTransform(theTransform);
1314 //my0DExtActor->SetTransform(theTransform);
1316 my1DActor->SetTransform(theTransform);
1317 my1DExtActor->SetTransform(theTransform);
1319 my2DActor->SetTransform(theTransform);
1320 my2DExtActor->SetTransform(theTransform);
1321 my3DActor->SetTransform(theTransform);
1322 my3DExtActor->SetTransform(theTransform);
1328 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper)
1330 vtkLODActor::SetMapper(theMapper);
1334 void SMESH_ActorDef::ShallowCopy(vtkProp *prop)
1336 SALOME_Actor::ShallowCopy(prop);
1340 vtkMapper* SMESH_ActorDef::GetMapper()
1342 return myPickableActor->GetMapper();
1346 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid()
1348 return myVisualObj->GetUnstructuredGrid();
1352 bool SMESH_ActorDef::IsInfinitive()
1354 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1355 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1356 ( aDataSet->GetNumberOfCells() == 1 &&
1357 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1358 return SALOME_Actor::IsInfinitive();
1362 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable)
1364 if ( myIsShrinkable == theShrunkable )
1366 myIsShrinkable = theShrunkable;
1370 double SMESH_ActorDef::GetShrinkFactor()
1372 return myBaseActor->GetShrinkFactor();
1375 void SMESH_ActorDef::SetShrinkFactor(double theValue)
1377 myBaseActor->SetShrinkFactor(theValue);
1379 my1DActor->SetShrinkFactor(theValue);
1380 my1DExtActor->SetShrinkFactor(theValue);
1382 my2DActor->SetShrinkFactor(theValue);
1383 my2DExtActor->SetShrinkFactor(theValue);
1384 my3DActor->SetShrinkFactor(theValue);
1385 my3DExtActor->SetShrinkFactor(theValue);
1386 my3DExtActor->SetShrinkFactor(theValue);
1387 myHighlitableActor->SetShrinkFactor(theValue);
1392 void SMESH_ActorDef::SetShrink()
1394 if(!myIsShrinkable) return;
1396 myBaseActor->SetShrink();
1398 my1DActor->SetShrink();
1399 my1DExtActor->SetShrink();
1401 my2DActor->SetShrink();
1402 my2DExtActor->SetShrink();
1403 my3DActor->SetShrink();
1404 my3DExtActor->SetShrink();
1405 myHighlitableActor->SetShrink();
1411 void SMESH_ActorDef::UnShrink()
1413 if(!myIsShrunk) return;
1415 myBaseActor->UnShrink();
1417 my1DActor->UnShrink();
1418 my1DExtActor->UnShrink();
1420 my2DActor->UnShrink();
1421 my2DExtActor->UnShrink();
1422 my3DActor->UnShrink();
1423 my3DExtActor->UnShrink();
1424 myHighlitableActor->UnShrink();
1431 int SMESH_ActorDef::GetNodeObjId(int theVtkID)
1433 return myPickableActor->GetNodeObjId(theVtkID);
1436 double* SMESH_ActorDef::GetNodeCoord(int theObjID)
1438 return myPickableActor->GetNodeCoord(theObjID);
1441 int SMESH_ActorDef::GetNodeVtkId(int theObjID)
1443 return myPickableActor->GetNodeVtkId(theObjID);
1446 int SMESH_ActorDef::GetElemObjId(int theVtkID)
1448 return myPickableActor->GetElemObjId(theVtkID);
1451 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID)
1453 return myPickableActor->GetElemCell(theObjID);
1457 void SMESH_ActorDef::SetVisibility(int theMode)
1459 SetVisibility(theMode,true);
1463 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation)
1465 SALOME_Actor::SetVisibility(theMode);
1467 myNodeActor->VisibilityOff();
1468 myBaseActor->VisibilityOff();
1470 myNodeExtActor->VisibilityOff();
1472 my0DActor->VisibilityOff();
1473 myBallActor->VisibilityOff();
1474 //my0DExtActor->VisibilityOff();
1476 my1DActor->VisibilityOff();
1477 my1DExtActor->VisibilityOff();
1479 my2DActor->VisibilityOff();
1480 my2DExtActor->VisibilityOff();
1481 my3DActor->VisibilityOff();
1482 my3DExtActor->VisibilityOff();
1484 myScalarBarActor->VisibilityOff();
1486 if ( GetVisibility() ) {
1487 if ( theIsUpdateRepersentation )
1488 SetRepresentation(GetRepresentation());
1490 if(myControlMode != eNone) {
1491 switch(myControlMode) {
1493 case eCoincidentNodes:
1494 myNodeExtActor->VisibilityOn();
1497 case eMultiConnection:
1498 my1DActor->VisibilityOn();
1502 case eCoincidentElems1D:
1504 case eMultiConnection2D:
1505 my1DExtActor->VisibilityOn();
1508 case eBareBorderFace:
1509 case eOverConstrainedFace:
1510 case eCoincidentElems2D:
1511 my2DExtActor->VisibilityOn();
1513 case eBareBorderVolume:
1514 case eOverConstrainedVolume:
1515 case eCoincidentElems3D:
1516 my3DExtActor->VisibilityOn();
1520 if ( myFunctor && myVisualObj->GetNbEntities( myFunctor->GetType() ))
1521 myScalarBarActor->VisibilityOn();
1524 myPickableActor->VisibilityOn();
1526 if ( GetRepresentation() != ePoint )
1528 if(myEntityMode & e0DElements ){
1529 my0DActor->VisibilityOn();
1531 if(myEntityMode & eBallElem ){
1532 myBallActor->VisibilityOn();
1534 if(myEntityMode & eEdges && GetCellsLabeled() ){ // my1DActor shows labels only
1535 my1DActor->VisibilityOn();
1537 if(myEntityMode & eFaces ){
1538 my2DActor->VisibilityOn();
1540 if(myEntityMode & eVolumes ){
1541 my3DActor->VisibilityOn();
1545 if(myNodeActor->GetPointsLabeled()) {
1546 myNodeActor->UpdateLabels();
1547 myNodeActor->VisibilityOn();
1550 my0DActor->UpdateLabels();
1553 myBallActor->UpdateLabels();
1556 my1DActor->UpdateLabels();
1559 my2DActor->UpdateLabels();
1562 my3DActor->UpdateLabels();
1564 #ifndef DISABLE_PLOT2DVIEWER
1566 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1573 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1575 unsigned int anObjectEntities = eAllEntity; // entities present in my object
1577 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1578 anObjectEntities &= ~e0DElements;
1579 theMode &= ~e0DElements;
1582 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1583 anObjectEntities &= ~eBallElem;
1584 theMode &= ~eBallElem;
1587 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1588 anObjectEntities &= ~eEdges;
1592 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1593 anObjectEntities &= ~eFaces;
1597 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1598 anObjectEntities &= ~eVolumes;
1599 theMode &= ~eVolumes;
1603 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1604 theMode |= e0DElements;
1606 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1607 theMode |= eBallElem;
1609 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1612 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1615 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1616 theMode |= eVolumes;
1619 myBaseActor->myGeomFilter->SetInside(myEntityMode != anObjectEntities);
1621 if ( anObjectEntities == 0 && myRepresentation != ePoint ) // no elements, show nodes
1623 myRepresentationCache = GetRepresentation();
1624 SetRepresentation( ePoint );
1627 if ( myEntityMode != theMode )
1629 myEntityMode = theMode; // entities to show
1631 // Set cell types to extract
1633 VTKViewer_ExtractUnstructuredGrid* aFilter = myBaseActor->GetExtractUnstructuredGrid();
1634 VTKViewer_ExtractUnstructuredGrid* aHltFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1635 aFilter->ClearRegisteredCellsWithType();
1636 aHltFilter->ClearRegisteredCellsWithType();
1638 bool isPassAll = ( myEntityMode == anObjectEntities && myEntityMode );
1641 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1642 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
1646 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1647 aHltFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1649 if (myEntityMode & e0DElements) {
1650 aFilter->RegisterCellsWithType(VTK_VERTEX);
1651 aHltFilter->RegisterCellsWithType(VTK_VERTEX);
1654 if (myEntityMode & eBallElem) {
1655 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1658 if (myEntityMode & eEdges) {
1659 aFilter->RegisterCellsWithType(VTK_LINE);
1660 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1662 aHltFilter->RegisterCellsWithType(VTK_LINE);
1663 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1666 if (myEntityMode & eFaces) {
1667 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1668 aFilter->RegisterCellsWithType(VTK_QUAD);
1669 aFilter->RegisterCellsWithType(VTK_POLYGON);
1670 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1671 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1672 aFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1673 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1674 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1676 aHltFilter->RegisterCellsWithType(VTK_TRIANGLE);
1677 aHltFilter->RegisterCellsWithType(VTK_QUAD);
1678 aHltFilter->RegisterCellsWithType(VTK_POLYGON);
1679 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1680 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1681 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_POLYGON);
1682 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1683 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_TRIANGLE);
1686 if (myEntityMode & eVolumes) {
1687 aFilter->RegisterCellsWithType(VTK_TETRA);
1688 aFilter->RegisterCellsWithType(VTK_VOXEL);
1689 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1690 aFilter->RegisterCellsWithType(VTK_WEDGE);
1691 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1692 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1693 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1694 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1695 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1696 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1697 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1698 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1699 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1700 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1702 aHltFilter->RegisterCellsWithType(VTK_TETRA);
1703 aHltFilter->RegisterCellsWithType(VTK_VOXEL);
1704 aHltFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1705 aHltFilter->RegisterCellsWithType(VTK_WEDGE);
1706 aHltFilter->RegisterCellsWithType(VTK_PYRAMID);
1707 aHltFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1708 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1709 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1710 aHltFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1711 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1712 aHltFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUADRATIC_WEDGE);
1713 aHltFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1714 aHltFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1715 aHltFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1718 if ( GetVisibility() )
1720 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1723 SetVisibility( GetVisibility(), myRepresentationCache != 0 );
1726 void SMESH_ActorDef::SetRepresentation (int theMode)
1728 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1729 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1730 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1731 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1732 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1734 if ( myRepresentationCache && aNbEdges + aNbFaces + aNbVolumes + aNb0Ds + aNbBalls )
1736 theMode = myRepresentationCache;
1737 if ( theMode == eSurface && aNbFaces + aNbVolumes == 0 )
1740 myRepresentationCache = 0;
1744 myRepresentation = eSurface;
1745 if (!aNbFaces && !aNbVolumes && !aNbBalls && aNbEdges) {
1746 myRepresentation = eEdge;
1747 } else if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNbBalls) {
1748 myRepresentation = ePoint;
1753 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1756 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1759 myRepresentation = theMode;
1762 if (!GetUnstructuredGrid()->GetNumberOfCells())
1763 myRepresentation = ePoint;
1766 if (myRepresentation == ePoint) {
1774 myPickableActor = myBaseActor;
1775 vtkProperty *aProp = NULL, *aBackProp = NULL;
1776 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1777 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1778 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1779 switch (myRepresentation) {
1781 myPickableActor = myNodeActor;
1782 aQuadraticMode = SMESH_Actor::eLines;
1783 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1784 aReperesent = SMESH_DeviceActor::ePoint;
1787 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1788 aReperesent = SMESH_DeviceActor::eInsideframe;
1791 aProp = mySurfaceProp;
1792 aBackProp = myBackSurfaceProp;
1793 aPropVN = myNormalVProp;
1794 aPropVR = myReversedVProp;
1795 aReperesent = SMESH_DeviceActor::eSurface;
1799 if ( myRepresentation != ePoint )
1801 my2DActor->SetProperty(aProp);
1802 my2DActor->SetBackfaceProperty(aBackProp);
1803 my2DActor->SetRepresentation(aReperesent);
1805 if(aQuadraticMode == SMESH_Actor::eLines)
1806 my2DActor->SetQuadraticArcMode(false);
1807 else if(aQuadraticMode == SMESH_Actor::eArcs)
1808 my2DActor->SetQuadraticArcMode(true);
1810 my2DExtActor->SetRepresentation(aReperesent);
1812 my3DActor->SetProperty(aPropVN);
1813 my3DActor->SetBackfaceProperty(aPropVR);
1814 my3DActor->SetRepresentation(aReperesent);
1816 my0DActor->SetRepresentation(aReperesent);
1817 myBallActor->SetRepresentation(aReperesent);
1819 switch ( myControlMode ) {
1821 case eMultiConnection:
1822 aProp = aBackProp = my1DProp;
1823 if ( myRepresentation != ePoint )
1824 aReperesent = SMESH_DeviceActor::eInsideframe;
1829 if(aQuadraticMode == SMESH_Actor::eLines)
1830 my1DActor->SetQuadraticArcMode(false);
1831 else if(aQuadraticMode == SMESH_Actor::eArcs)
1832 my1DActor->SetQuadraticArcMode(true);
1834 my1DActor->SetProperty(aProp);
1835 my1DActor->SetBackfaceProperty(aBackProp);
1836 my1DActor->SetRepresentation(aReperesent);
1838 my1DExtActor->SetRepresentation(aReperesent);
1841 if(myIsPointsVisible)
1842 myPickableActor = myNodeActor;
1844 SetMapper(myPickableActor->GetMapper());
1846 SetVisibility(GetVisibility(),false);
1852 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible)
1854 if ( myIsPointsVisible == theIsPointsVisible )
1856 myIsPointsVisible = theIsPointsVisible;
1857 SetRepresentation(GetRepresentation());
1860 bool SMESH_ActorDef::GetPointRepresentation()
1862 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1866 void SMESH_ActorDef::UpdateHighlight()
1868 myHighlitableActor->SetHighlited(false);
1869 myHighlitableActor->SetVisibility(false);
1870 bool anIsVisible = GetVisibility();
1872 switch(myRepresentation){
1873 case SMESH_DeviceActor::eSurface:
1874 case SMESH_DeviceActor::eWireframe:
1876 if(myIsHighlighted) {
1877 myHighlitableActor->SetProperty(myHighlightProp);
1878 }else if(myIsPreselected){
1879 myHighlitableActor->SetProperty(myPreselectProp);
1880 } else if(anIsVisible){
1881 (myRepresentation == eSurface) ?
1882 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1884 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1885 myHighlitableActor->SetHighlited(anIsVisible);
1886 myHighlitableActor->GetExtractUnstructuredGrid()->
1887 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1888 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1890 myHighlitableActor->SetVisibility(anIsVisible);
1893 case SMESH_DeviceActor::ePoint:
1895 if(myIsHighlighted) {
1896 myNodeActor->SetProperty(myHighlightProp);
1897 }else if(myIsPreselected) {
1898 myNodeActor->SetProperty(myPreselectProp);
1899 } else if(anIsVisible) {
1900 myNodeActor->SetProperty(myNodeProp);
1902 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1903 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1904 myNodeActor->GetProperty()->Modified();
1910 void SMESH_ActorDef::EnableSelection( bool enable )
1912 // selection in the Viewer enabled/disabled
1913 if ( enable && ! myBaseActor->myExtractUnstructuredGrid->GetInput() )
1915 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1916 //myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
1917 myBaseActor->myExtractUnstructuredGrid->Update();
1918 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1920 if ( !enable && myBaseActor->myExtractUnstructuredGrid->GetInput() )
1922 myBaseActor->SetUnstructuredGrid( NULL );
1923 //myHighlitableActor->SetUnstructuredGrid( NULL );
1924 myBaseActor->myExtractUnstructuredGrid->Update();
1925 //myHighlitableActor->myExtractUnstructuredGrid->Update();
1929 void SMESH_ActorDef::highlight(bool theHighlight)
1931 if ( myIsHighlighted == theHighlight )
1933 myIsHighlighted = theHighlight;
1938 void SMESH_ActorDef::SetPreSelected(bool thePreselect)
1940 if ( myIsPreselected == thePreselect )
1942 myIsPreselected = thePreselect;
1948 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1950 if (myPickableActor->GetIsOpaque())
1952 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1960 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1962 if (!myPickableActor->GetIsOpaque())
1964 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1972 void SMESH_ActorDef::Render(vtkRenderer *ren)
1974 vtkMTimeType aTime = myTimeStamp->GetMTime();
1975 vtkMTimeType anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1976 vtkMTimeType aClippingTime = myImplicitBoolean->GetMTime();
1977 if(anObjTime > aTime || aClippingTime > aTime)
1982 void SMESH_ActorDef::Update()
1984 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1986 myVisualObj->Update();
1988 if(GetControlMode() != eNone) {
1989 unsigned long aTime = myTimeStamp->GetMTime();
1990 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1991 if (anObjTime > aTime)
1992 SetControlMode(GetControlMode(),false);
1996 myNodeActor->UpdateLabels();
1999 my0DActor->UpdateLabels();
2002 myBallActor->UpdateLabels();
2005 my1DActor->UpdateLabels();
2008 my2DActor->UpdateLabels();
2011 my3DActor->UpdateLabels();
2013 if(myIsFacesOriented){
2014 SetFacesOriented(myIsFacesOriented);
2017 // if(myVisualObj->GetEntitiesFlag()) { IPAL53915
2018 // myEntityMode |= myVisualObj->GetEntitiesState();
2021 SetEntityMode(GetEntityMode());
2022 SetVisibility(GetVisibility());
2024 myTimeStamp->Modified();
2029 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin)
2031 SALOME_Actor::ReleaseGraphicsResources(renWin);
2033 myPickableActor->ReleaseGraphicsResources(renWin);
2037 static void GetColor(vtkProperty *theProperty, double& r,double& g,double& b)
2039 double* aColor = theProperty->GetColor();
2046 void SMESH_ActorDef::SetOpacity(double theValue)
2048 mySurfaceProp->SetOpacity(theValue);
2049 myBackSurfaceProp->SetOpacity(theValue);
2050 myNormalVProp->SetOpacity(theValue);
2051 myReversedVProp->SetOpacity(theValue);
2052 myEdgeProp->SetOpacity(theValue);
2053 myOutLineProp->SetOpacity(theValue);
2054 myNodeProp->SetOpacity(theValue);
2056 my1DProp->SetOpacity(theValue);
2057 my0DProp->SetOpacity(theValue);
2058 myBallProp->SetOpacity(theValue);
2062 double SMESH_ActorDef::GetOpacity()
2064 return mySurfaceProp->GetOpacity();
2068 void SMESH_ActorDef::SetSufaceColor(double r,double g,double b, int delta)
2070 mySurfaceProp->SetColor(r,g,b);
2071 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2072 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2073 if( aGroupObj->GetElementType() == SMDSAbs_Face )
2074 myNameActor->SetBackgroundColor(r,g,b);
2076 myDeltaBrightness = delta;
2077 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2078 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2082 void SMESH_ActorDef::GetSufaceColor(double& r,double& g,double& b, int& delta)
2084 ::GetColor(mySurfaceProp,r,g,b);
2085 delta = myDeltaBrightness;
2088 void SMESH_ActorDef::SetVolumeColor(double r,double g,double b, int delta)
2090 myNormalVProp->SetColor(r,g,b);
2091 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2092 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2093 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
2094 myNameActor->SetBackgroundColor(r,g,b);
2096 myDeltaVBrightness = delta;
2097 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
2098 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
2102 void SMESH_ActorDef::GetVolumeColor(double& r,double& g,double& b, int& delta)
2104 ::GetColor(myNormalVProp,r,g,b);
2105 delta = myDeltaVBrightness;
2108 void SMESH_ActorDef::SetEdgeColor(double r,double g,double b)
2110 myEdgeProp->SetColor(r,g,b);
2111 my1DProp->SetColor(r,g,b);
2112 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2113 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2114 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
2115 myNameActor->SetBackgroundColor(r,g,b);
2119 void SMESH_ActorDef::GetEdgeColor(double& r,double& g,double& b)
2121 ::GetColor(myEdgeProp,r,g,b);
2124 void SMESH_ActorDef::SetOutlineColor(double r,double g,double b)
2126 myOutLineProp->SetColor(r,g,b);
2130 void SMESH_ActorDef::GetOutlineColor(double& r,double& g,double& b)
2132 ::GetColor(myOutLineProp,r,g,b);
2136 void SMESH_ActorDef::SetNodeColor(double r,double g,double b)
2138 myNodeProp->SetColor(r,g,b);
2139 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
2140 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2141 if( aGroupObj->GetElementType() == SMDSAbs_Node )
2142 myNameActor->SetBackgroundColor(r,g,b);
2146 void SMESH_ActorDef::GetNodeColor(double& r,double& g,double& b)
2148 ::GetColor(myNodeProp,r,g,b);
2151 void SMESH_ActorDef::Set0DColor(double r,double g,double b)
2153 my0DProp->SetColor(r,g,b);
2154 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2155 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
2156 myNameActor->SetBackgroundColor(r,g,b);
2160 void SMESH_ActorDef::Get0DColor(double& r,double& g,double& b)
2162 ::GetColor(my0DProp,r,g,b);
2165 void SMESH_ActorDef::SetBallColor(double r,double g,double b)
2167 myBallProp->SetColor(r,g,b);
2168 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
2169 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
2170 myNameActor->SetBackgroundColor(r,g,b);
2174 void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b)
2176 ::GetColor(myBallProp,r,g,b);
2179 void SMESH_ActorDef::SetHighlightColor(double r,double g,double b)
2181 myHighlightProp->SetColor(r,g,b);
2185 void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b)
2187 ::GetColor(myHighlightProp,r,g,b);
2190 void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b)
2192 myPreselectProp->SetColor(r,g,b);
2196 void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b)
2198 ::GetColor(myPreselectProp,r,g,b);
2202 double SMESH_ActorDef::GetLineWidth()
2204 return myEdgeProp->GetLineWidth();
2208 void SMESH_ActorDef::SetLineWidth(double theVal)
2210 myEdgeProp->SetLineWidth(theVal);
2212 my1DProp->SetLineWidth(theVal + aLineWidthInc);
2213 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
2214 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
2215 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
2216 myOutLineProp->SetLineWidth(theVal);
2217 myHighlightProp->SetLineWidth(theVal);
2218 myPreselectProp->SetLineWidth(theVal);
2222 double SMESH_ActorDef::GetOutlineWidth()
2224 return myOutLineProp->GetLineWidth();
2227 void SMESH_ActorDef::SetOutlineWidth(double theVal)
2229 myOutLineProp->SetLineWidth(theVal);
2233 void SMESH_ActorDef::Set0DSize(double theVal)
2235 my0DProp->SetPointSize(theVal);
2236 myHighlightProp->SetPointSize(theVal);
2237 myPreselectProp->SetPointSize(theVal);
2239 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2240 aCustom->Set0DSize(theVal);
2242 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2243 aCustom->Set0DSize(theVal);
2249 double SMESH_ActorDef::Get0DSize()
2251 return my0DProp->GetPointSize();
2254 void SMESH_ActorDef::SetBallSize(double theVal)
2256 myBallProp->SetPointSize(theVal);
2258 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2259 aCustom->SetBallSize(theVal);
2261 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2262 aCustom->SetBallSize(theVal);
2268 double SMESH_ActorDef::GetBallSize()
2270 return myBallProp->GetPointSize();
2273 double SMESH_ActorDef::GetBallScale()
2275 return myBallActor->GetBallScale();
2278 void SMESH_ActorDef::SetBallScale( double theVal )
2280 myBallActor->SetBallScale( theVal );
2281 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2282 aCustom->SetBallScale(theVal);
2284 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2285 aCustom->SetBallScale(theVal);
2291 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2293 return myVisualObj->GetElemDimension( theObjId );
2296 bool SMESH_ActorDef::IsImplicitFunctionUsed() const
2298 return myBaseActor->IsImplicitFunctionUsed();
2301 void SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2303 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2304 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2306 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2308 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2310 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2311 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2312 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2314 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2315 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2317 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2318 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2319 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2320 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2323 vtkIdType SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2326 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2327 myCippingPlaneCont.push_back(thePlane);
2328 if(!IsImplicitFunctionUsed())
2329 SetImplicitFunctionUsed(true);
2330 myNodeActor->UpdateLabels();
2332 return myCippingPlaneCont.size();
2335 void SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2338 myPlaneCollection->AddItem( thePlane );
2341 void SMESH_ActorDef::SetOpenGLClippingPlane()
2343 // before use this method you must add clipping planes using method
2344 // SMESH_ActorDef::AddOpenGLClippingPlane(vtkPlane* thePlane)
2345 if( !myPlaneCollection->GetNumberOfItems() )
2348 // It is necessary to set plane collection for each mapper of actor
2349 // and update current inputs of mapper
2350 myNodeActor->SetPlaneCollection( myPlaneCollection );
2351 myNodeActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2353 myBaseActor->SetPlaneCollection( myPlaneCollection );
2354 myBaseActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2356 myHighlitableActor->SetPlaneCollection( myPlaneCollection );
2357 myHighlitableActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2359 if ( !mySelector || !mySelector->IsSelectionEnabled() )
2361 myBaseActor->SetUnstructuredGrid( NULL );
2362 //myHighlitableActor->SetUnstructuredGrid( NULL );
2364 my1DActor->SetPlaneCollection( myPlaneCollection );
2365 my1DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2367 my2DActor->SetPlaneCollection( myPlaneCollection );
2368 my2DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2370 myNodeExtActor->SetPlaneCollection( myPlaneCollection );
2371 myNodeExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2373 my0DActor->SetPlaneCollection( myPlaneCollection );
2374 my0DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2376 myBallActor->SetPlaneCollection( myPlaneCollection );
2377 myBallActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2379 my1DExtActor->SetPlaneCollection( myPlaneCollection );
2380 my1DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2382 my2DExtActor->SetPlaneCollection( myPlaneCollection );
2383 my2DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2385 my3DActor->SetPlaneCollection( myPlaneCollection );
2386 my3DActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2388 my3DExtActor->SetPlaneCollection( myPlaneCollection );
2389 my3DExtActor->SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
2397 void SMESH_ActorDef::RemoveAllClippingPlanes()
2399 myPlaneCollection->RemoveAllItems();
2400 myImplicitBoolean->GetFunction()->RemoveAllItems();
2401 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2402 myCippingPlaneCont.clear();
2403 SetImplicitFunctionUsed(false);
2404 myNodeActor->UpdateLabels();
2407 vtkIdType SMESH_ActorDef::GetNumberOfClippingPlanes()
2409 return myCippingPlaneCont.size();
2412 vtkPlane* SMESH_ActorDef::GetClippingPlane(vtkIdType theID)
2414 if ( theID >= (vtkIdType)myCippingPlaneCont.size() )
2416 return myCippingPlaneCont[theID].Get();
2419 void SMESH_ActorDef::UpdateScalarBar()
2421 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2425 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2427 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2428 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2430 aScalarBarTitleProp->SetFontFamilyToArial();
2432 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2434 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2435 if ( f.family() == "Arial" )
2436 aScalarBarTitleProp->SetFontFamilyToArial();
2437 else if ( f.family() == "Courier" )
2438 aScalarBarTitleProp->SetFontFamilyToCourier();
2439 else if ( f.family() == "Times" )
2440 aScalarBarTitleProp->SetFontFamilyToTimes();
2443 aScalarBarTitleProp->BoldOn();
2445 aScalarBarTitleProp->BoldOff();
2448 aScalarBarTitleProp->ItalicOn();
2450 aScalarBarTitleProp->ItalicOff();
2453 aScalarBarTitleProp->ShadowOn();
2455 aScalarBarTitleProp->ShadowOff();
2458 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2459 aScalarBarTitleProp->Delete();
2461 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2463 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2464 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2466 aScalarBarLabelProp->SetFontFamilyToArial();
2467 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2469 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2470 if( f.family() == "Arial" )
2471 aScalarBarLabelProp->SetFontFamilyToArial();
2472 else if( f.family() == "Courier" )
2473 aScalarBarLabelProp->SetFontFamilyToCourier();
2474 else if( f.family() == "Times" )
2475 aScalarBarLabelProp->SetFontFamilyToTimes();
2478 aScalarBarLabelProp->BoldOn();
2480 aScalarBarLabelProp->BoldOff();
2483 aScalarBarLabelProp->ItalicOn();
2485 aScalarBarLabelProp->ItalicOff();
2488 aScalarBarLabelProp->ShadowOn();
2490 aScalarBarLabelProp->ShadowOff();
2493 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2494 aScalarBarLabelProp->Delete();
2496 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2497 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2499 myScalarBarActor->SetOrientationToHorizontal();
2501 myScalarBarActor->SetOrientationToVertical();
2504 double aXVal = horiz ? 0.20 : 0.01;
2505 if( mgr->hasValue( "SMESH", name + "x" ) )
2506 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2508 double aYVal = horiz ? 0.01 : 0.1;
2509 if( mgr->hasValue( "SMESH", name + "y" ) )
2510 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2511 myScalarBarActor->SetPosition( aXVal, aYVal );
2513 double aWVal = horiz ? 0.60 : 0.10;
2514 if( mgr->hasValue( "SMESH", name + "width" ) )
2515 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2516 myScalarBarActor->SetWidth( aWVal );
2518 double aHVal = horiz ? 0.12 : 0.80;
2519 if( mgr->hasValue( "SMESH", name + "height" ) )
2520 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2521 myScalarBarActor->SetHeight( aHVal );
2524 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2525 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2526 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2529 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2530 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2531 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2533 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2534 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2536 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2537 myScalarBarActor->SetDistributionColoringType(coloringType);
2539 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2540 QColor(255, 255, 255));
2542 rgb[0]= distributionColor.red()/255.;
2543 rgb[1]= distributionColor.green()/255.;
2544 rgb[2]= distributionColor.blue()/255.;
2545 myScalarBarActor->SetDistributionColor(rgb);
2550 void SMESH_ActorDef::UpdateDistribution()
2552 if(SMESH::Controls::NumericalFunctor* fun =
2553 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2555 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2556 std::vector<int> nbEvents;
2557 std::vector<double> funValues;
2558 SMESH_VisualObjDef::TEntityList elems;
2559 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2560 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2561 std::vector<int> elemIds; elemIds.reserve( elems.size() );
2562 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2563 elemIds.push_back( (*e)->GetID());
2564 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2565 double * range = lookupTable->GetRange();
2566 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2567 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2568 myScalarBarActor->SetDistribution(nbEvents);
2572 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2575 case SMESH_Actor::eLines :
2576 myHighlitableActor->SetQuadraticArcMode(false);
2577 my2DActor->SetQuadraticArcMode(false);
2578 my1DActor->SetQuadraticArcMode(false);
2580 case SMESH_Actor::eArcs :
2581 myHighlitableActor->SetQuadraticArcMode(true);
2582 if(GetRepresentation() != SMESH_Actor::ePoint) {
2583 my2DActor->SetQuadraticArcMode(true);
2584 my1DActor->SetQuadraticArcMode(true);
2593 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2595 if(myHighlitableActor->GetQuadraticArcMode())
2596 return SMESH_Actor::eArcs;
2598 return SMESH_Actor::eLines;
2601 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2603 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2604 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2605 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2608 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2610 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2611 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2612 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2613 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2616 #ifndef DISABLE_PLOT2DVIEWER
2617 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram()
2620 my2dHistogram->clearAllPoints();
2622 if(SMESH::Controls::NumericalFunctor* fun =
2623 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2626 if(!my2dHistogram) {
2627 my2dHistogram = new SPlot2d_Histogram();
2628 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2629 my2dHistogram->setIO(anIO);
2632 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2633 std::vector<int> nbEvents;
2634 std::vector<double> funValues;
2635 SMESH_VisualObjDef::TEntityList elems;
2636 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2637 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2638 std::vector<int> elemIds;
2640 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2641 elemIds.push_back( (*e)->GetID());
2643 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2644 double * range = lookupTable->GetRange();
2645 bool isLogarithmic = lookupTable->GetScale() == VTK_SCALE_LOG10;
2646 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range, isLogarithmic);
2648 for ( size_t i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2649 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2651 if(funValues.size() >= 2)
2652 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2656 //Color of the histogram
2657 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2658 my2dHistogram->setAutoAssign(true);
2661 myScalarBarActor->GetDistributionColor(rgb);
2662 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2663 my2dHistogram->setColor(aColor);
2667 return my2dHistogram;