1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_NodeLabelActor.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ObjectDef.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMDS_UnstructuredGrid.hxx"
36 #include "SMESH_ScalarBarActor.h"
37 #include "VTKViewer_ExtractUnstructuredGrid.h"
38 #include "VTKViewer_FramedTextActor.h"
39 #include "SALOME_InteractiveObject.hxx"
41 #include "SUIT_Session.h"
42 #include "SUIT_ResourceMgr.h"
46 #ifndef DISABLE_PLOT2DVIEWER
47 #include <SPlot2d_Histogram.h>
50 #include <vtkProperty.h>
51 #include <vtkTimeStamp.h>
52 #include <vtkObjectFactory.h>
53 #include <vtkShrinkPolyData.h>
54 #include <vtkMergeFilter.h>
56 #include <vtkMatrix4x4.h>
57 #include <vtkUnstructuredGrid.h>
58 #include <vtkPointData.h>
59 #include <vtkCellData.h>
61 #include <vtkMapper.h>
62 #include <vtkRenderer.h>
65 #include <vtkIdList.h>
66 #include <vtkIntArray.h>
68 #include <vtkActor2D.h>
69 #include <vtkProperty2D.h>
70 #include <vtkPolyData.h>
71 #include <vtkTextProperty.h>
73 #include <vtkLookupTable.h>
77 #include <vtkImplicitBoolean.h>
78 #include <vtkImplicitFunctionCollection.h>
80 #include <vtkConfigure.h>
81 #if !defined(VTK_XVERSION)
82 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
85 #include "utilities.h"
88 static int MYDEBUG = 1;
90 static int MYDEBUG = 1;
93 static int aLineWidthInc = 2;
96 SMESH_ActorDef* SMESH_ActorDef::New(){
97 return new SMESH_ActorDef();
101 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 const char* theEntry,
106 SMESH_ActorDef* anActor = NULL;
107 if(theVisualObj->IsValid() ) {
108 anActor = SMESH_ActorDef::New();
109 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
114 anActor->UpdateScalarBar();
120 SMESH_ActorDef::SMESH_ActorDef()
122 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
123 myBaseActor = SMESH_DeviceActor::New();
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
128 myIsEntityModeCache = false;
130 myIsShrinkable = false;
133 myIsFacesOriented = false;
135 myControlsPrecision = -1;
136 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
138 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
139 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
141 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
142 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
144 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
145 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
147 //Definition 2D and 3D devices of the actor
148 //-----------------------------------------
149 vtkFloatingPointType anRGB[3] = {1,1,1};
150 mySurfaceProp = vtkProperty::New();
153 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
154 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
155 myDeltaBrightness = delta;
157 myBackSurfaceProp = vtkProperty::New();
158 bfc = Qtx::mainColorToSecondary(ffc, delta);
159 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
161 my2DActor = SMESH_CellLabelActor::New();
162 my2DActor->SetStoreGemetryMapping(true);
163 my2DActor->SetUserMatrix(aMatrix);
164 my2DActor->PickableOff();
165 my2DActor->SetProperty(mySurfaceProp);
166 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
167 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
168 aFilter = my2DActor->GetExtractUnstructuredGrid();
169 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
170 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
171 aFilter->RegisterCellsWithType(VTK_POLYGON);
172 aFilter->RegisterCellsWithType(VTK_QUAD);
173 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
174 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
176 my2DExtProp = vtkProperty::New();
177 my2DExtProp->DeepCopy(mySurfaceProp);
178 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
179 anRGB[0] = 1 - anRGB[0];
180 anRGB[1] = 1 - anRGB[1];
181 anRGB[2] = 1 - anRGB[2];
182 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
184 my2DExtActor = SMESH_DeviceActor::New();
185 my2DExtActor->SetUserMatrix(aMatrix);
186 my2DExtActor->PickableOff();
187 my2DExtActor->SetProperty(my2DExtProp);
188 my2DExtActor->SetBackfaceProperty(my2DExtProp);
189 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
190 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
191 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
192 aFilter->RegisterCellsWithType(VTK_POLYGON);
193 aFilter->RegisterCellsWithType(VTK_QUAD);
194 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
195 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
197 my3DActor = SMESH_CellLabelActor::New();
198 my3DActor->SetStoreGemetryMapping(true);
199 my3DActor->SetUserMatrix(aMatrix);
200 my3DActor->PickableOff();
201 my3DActor->SetProperty(mySurfaceProp);
202 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
203 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
204 aFilter = my3DActor->GetExtractUnstructuredGrid();
205 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
206 aFilter->RegisterCellsWithType(VTK_TETRA);
207 aFilter->RegisterCellsWithType(VTK_VOXEL);
208 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
209 aFilter->RegisterCellsWithType(VTK_WEDGE);
210 aFilter->RegisterCellsWithType(VTK_PYRAMID);
211 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
212 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
213 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
214 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
215 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
216 //#ifdef VTK_HAVE_POLYHEDRON
217 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
218 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
221 my3DExtActor = SMESH_DeviceActor::New();
222 my3DExtActor->SetUserMatrix(aMatrix);
223 my3DExtActor->PickableOff();
224 my3DExtActor->SetProperty(my2DExtProp);
225 my3DExtActor->SetBackfaceProperty(my2DExtProp);
226 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
227 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
228 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
229 aFilter->RegisterCellsWithType(VTK_TETRA);
230 aFilter->RegisterCellsWithType(VTK_VOXEL);
231 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
232 aFilter->RegisterCellsWithType(VTK_WEDGE);
233 aFilter->RegisterCellsWithType(VTK_PYRAMID);
234 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
235 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
236 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
237 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
238 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
239 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
241 //Definition 1D device of the actor
242 //---------------------------------
243 myEdgeProp = vtkProperty::New();
244 myEdgeProp->SetAmbient(1.0);
245 myEdgeProp->SetDiffuse(0.0);
246 myEdgeProp->SetSpecular(0.0);
247 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
248 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
249 myEdgeProp->SetLineWidth(aLineWidth);
251 my1DActor = SMESH_CellLabelActor::New();
252 my1DActor->SetStoreGemetryMapping(true);
253 my1DActor->SetUserMatrix(aMatrix);
254 my1DActor->PickableOff();
255 my1DActor->SetHighlited(true);
256 my1DActor->SetProperty(myEdgeProp);
257 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
258 aFilter = my1DActor->GetExtractUnstructuredGrid();
259 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
260 aFilter->RegisterCellsWithType(VTK_LINE);
261 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
263 my1DProp = vtkProperty::New();
264 my1DProp->DeepCopy(myEdgeProp);
265 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
266 my1DProp->SetPointSize(aElem0DSize);
268 my1DExtProp = vtkProperty::New();
269 my1DExtProp->DeepCopy(myEdgeProp);
270 anRGB[0] = 1 - anRGB[0];
271 anRGB[1] = 1 - anRGB[1];
272 anRGB[2] = 1 - anRGB[2];
273 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
274 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
275 my1DExtProp->SetPointSize(aElem0DSize);
277 my1DExtActor = SMESH_DeviceActor::New();
278 my1DExtActor->SetUserMatrix(aMatrix);
279 my1DExtActor->PickableOff();
280 my1DExtActor->SetHighlited(true);
281 my1DExtActor->SetVisibility(false);
282 my1DExtActor->SetProperty(my1DExtProp);
283 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
284 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
285 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
286 aFilter->RegisterCellsWithType(VTK_LINE);
287 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
290 //Definition 0D device of the actor (0d elements)
291 //-----------------------------------------------
292 my0DProp = vtkProperty::New();
293 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
294 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
295 my0DProp->SetPointSize(aElem0DSize);
297 my0DActor = SMESH_CellLabelActor::New();
298 my0DActor->SetUserMatrix(aMatrix);
299 my0DActor->SetStoreGemetryMapping(true);
300 my0DActor->PickableOff();
301 my0DActor->SetVisibility(false);
302 my0DActor->SetProperty(my0DProp);
303 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
304 aFilter = my0DActor->GetExtractUnstructuredGrid();
305 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
306 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
307 aFilter->RegisterCellsWithType(VTK_VERTEX);
309 //my0DExtProp = vtkProperty::New();
310 //my0DExtProp->DeepCopy(my0DProp);
311 //anRGB[0] = 1 - anRGB[0];
312 //anRGB[1] = 1 - anRGB[1];
313 //anRGB[2] = 1 - anRGB[2];
314 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
315 //my0DExtProp->SetPointSize(aElem0DSize);
317 //my0DExtActor = SMESH_DeviceActor::New();
318 //my0DExtActor->SetUserMatrix(aMatrix);
319 //my0DExtActor->SetStoreClippingMapping(true);
320 //my0DExtActor->PickableOff();
321 //my0DExtActor->SetHighlited(true);
322 //my0DExtActor->SetVisibility(false);
323 //my0DExtActor->SetProperty(my0DExtProp);
324 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
325 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
326 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
327 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
328 //aFilter->RegisterCellsWithType(VTK_VERTEX);
331 //Definition 0D device of the actor (nodes)
332 //-----------------------------------------
333 myNodeProp = vtkProperty::New();
334 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
335 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
337 myNodeActor = SMESH_NodeLabelActor::New();
338 myNodeActor->SetUserMatrix(aMatrix);
339 myNodeActor->SetStoreClippingMapping(true);
340 myNodeActor->PickableOff();
341 myNodeActor->SetVisibility(false);
342 myNodeActor->SetProperty(myNodeProp);
343 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
344 aFilter = myNodeActor->GetExtractUnstructuredGrid();
345 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
347 myNodeExtProp = vtkProperty::New();
348 myNodeExtProp->DeepCopy(myNodeProp);
349 anRGB[0] = 1 - anRGB[0];
350 anRGB[1] = 1 - anRGB[1];
351 anRGB[2] = 1 - anRGB[2];
352 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
354 myNodeExtActor = SMESH_DeviceActor::New();
355 myNodeExtActor->SetUserMatrix(aMatrix);
356 myNodeExtActor->SetStoreClippingMapping(true);
357 myNodeExtActor->PickableOff();
358 myNodeExtActor->SetHighlited(true);
359 myNodeExtActor->SetVisibility(false);
360 myNodeExtActor->SetProperty(myNodeExtProp);
361 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
362 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
363 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
364 aFilter->RegisterCellsWithType(VTK_VERTEX);
366 //Definition of Pickable and Highlitable engines
367 //----------------------------------------------
369 myBaseActor->SetUserMatrix(aMatrix);
370 myBaseActor->SetStoreGemetryMapping(true);
371 myBaseActor->GetProperty()->SetOpacity(0.0);
372 myPickableActor = myBaseActor;
374 myHighlightProp = vtkProperty::New();
375 myHighlightProp->SetAmbient(1.0);
376 myHighlightProp->SetDiffuse(0.0);
377 myHighlightProp->SetSpecular(0.0);
378 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
379 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
380 myHighlightProp->SetPointSize(aElem0DSize); // ??
381 myHighlightProp->SetRepresentation(1);
383 myOutLineProp = vtkProperty::New();
384 myOutLineProp->SetAmbient(1.0);
385 myOutLineProp->SetDiffuse(0.0);
386 myOutLineProp->SetSpecular(0.0);
387 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
388 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
389 myOutLineProp->SetPointSize(aElem0DSize); // ??
390 myOutLineProp->SetRepresentation(1);
392 myPreselectProp = vtkProperty::New();
393 myPreselectProp->SetAmbient(1.0);
394 myPreselectProp->SetDiffuse(0.0);
395 myPreselectProp->SetSpecular(0.0);
396 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
397 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
398 myPreselectProp->SetPointSize(aElem0DSize); // ??
399 myPreselectProp->SetRepresentation(1);
401 myHighlitableActor = SMESH_DeviceActor::New();
402 myHighlitableActor->SetUserMatrix(aMatrix);
403 myHighlitableActor->PickableOff();
404 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
411 myControlMode = eNone;
412 myControlActor = my2DActor;
414 //Definition of myScalarBarActor
415 //------------------------------
416 myLookupTable = vtkLookupTable::New();
417 //Fix for Bug PAL5195 - SMESH764:
418 //Controls - Aspect Ratio: incorrect colors of the best and worst values
419 myLookupTable->SetHueRange(0.667,0.0);
421 myScalarBarActor = SMESH_ScalarBarActor::New();
422 myScalarBarActor->SetVisibility(false);
423 myScalarBarActor->SetLookupTable(myLookupTable);
426 //Incorrect "Min value" in Scalar Bar in Mesh:
427 // myScalarBarActor->SetLabelFormat("%.4g");
428 // changes was commented because of regression bug IPAL 19981
430 mgr = SUIT_Session::session()->resourceMgr();
434 myEntityMode = eAllEntity;
435 myEntityModeCache = eAllEntity;
438 myImplicitBoolean = vtkImplicitBoolean::New();
439 myImplicitBoolean->SetOperationTypeToIntersection();
441 //Quadratic 2D elements representation
442 //-----------------------------------------------------------------------------
443 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
444 if(aQuadratic2DMode == 0){
445 myHighlitableActor->SetQuadraticArcMode(false);
446 my2DActor->SetQuadraticArcMode(false);
447 my1DActor->SetQuadraticArcMode(false);
449 else if(aQuadratic2DMode == 1){
450 myHighlitableActor->SetQuadraticArcMode(true);
451 my2DActor->SetQuadraticArcMode(true);
452 my1DActor->SetQuadraticArcMode(true);
455 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
456 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
457 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
459 // Set colors of the name actor
460 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
461 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
462 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
463 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
465 #ifndef DISABLE_PLOT2DVIEWER
472 SMESH_ActorDef::~SMESH_ActorDef()
474 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
476 #ifndef DISABLE_PLOT2DVIEWER
478 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
479 delete my2dHistogram;
483 // caught by SMESHGUI::ProcessEvents() static method
484 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
486 myScalarBarActor->Delete();
487 myLookupTable->Delete();
489 mySurfaceProp->Delete();
490 myBackSurfaceProp->Delete();
491 myOutLineProp->Delete();
493 myEdgeProp->Delete();
494 myHighlightProp->Delete();
495 myPreselectProp->Delete();
497 myNodeProp->Delete();
498 myNodeExtProp->Delete();
503 //my0DExtProp->Delete();
504 //my0DExtActor->Delete();
509 my1DExtProp->Delete();
510 my1DExtActor->Delete();
513 my2DExtProp->Delete();
514 my2DExtActor->Delete();
516 my3DExtActor->Delete();
518 myNodeActor->Delete();
519 myBaseActor->Delete();
521 myNodeExtActor->Delete();
522 myHighlitableActor->Delete();
524 myImplicitBoolean->Delete();
526 myTimeStamp->Delete();
530 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
533 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
534 SetRepresentation(GetRepresentation());
535 myTimeStamp->Modified();
539 bool SMESH_ActorDef::GetPointsLabeled() {
540 return myNodeActor && myNodeActor->GetPointsLabeled();
543 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
546 my3DActor->SetCellsLabeled(theIsCellsLabeled);
549 my2DActor->SetCellsLabeled(theIsCellsLabeled);
552 my1DActor->SetCellsLabeled(theIsCellsLabeled);
555 my0DActor->SetCellsLabeled(theIsCellsLabeled);
557 myTimeStamp->Modified();
561 bool SMESH_ActorDef::GetCellsLabeled() {
564 result = result || my3DActor->GetCellsLabeled();
567 result = result || my2DActor->GetCellsLabeled();
570 result = result || my1DActor->GetCellsLabeled();
573 result = result || my0DActor->GetCellsLabeled();
579 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
581 myIsFacesOriented = theIsFacesOriented;
583 my2DActor->SetFacesOriented(theIsFacesOriented);
584 my3DActor->SetFacesOriented(theIsFacesOriented);
586 myTimeStamp->Modified();
589 bool SMESH_ActorDef::GetFacesOriented()
591 return myIsFacesOriented;
594 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
596 my2DActor->SetFacesOrientationColor( theColor );
597 my3DActor->SetFacesOrientationColor( theColor );
600 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
602 my3DActor->GetFacesOrientationColor( theColor );
605 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
607 my2DActor->SetFacesOrientationScale( theScale );
608 my3DActor->SetFacesOrientationScale( theScale );
611 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
613 return my3DActor->GetFacesOrientationScale();
616 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
618 my2DActor->SetFacesOrientation3DVectors( theState );
619 my3DActor->SetFacesOrientation3DVectors( theState );
622 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
624 return my3DActor->GetFacesOrientation3DVectors();
630 SetControlMode(eControl theMode)
632 SetControlMode(theMode,true);
638 SetControlMode(eControl theMode,
639 bool theCheckEntityMode)
641 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
645 myControlMode = eNone;
646 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
648 my0DActor->GetMapper()->SetScalarVisibility(false);
649 my1DActor->GetMapper()->SetScalarVisibility(false);
650 my2DActor->GetMapper()->SetScalarVisibility(false);
651 my3DActor->GetMapper()->SetScalarVisibility(false);
652 myScalarBarActor->SetVisibility(false);
654 bool anIsScalarVisible = theMode > eNone;
656 if(anIsScalarVisible) {
660 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
661 aControl->SetPrecision( myControlsPrecision );
662 myFunctor.reset( aControl );
663 myControlActor = my1DActor;
668 myFunctor.reset(new SMESH::Controls::Length2D());
669 myControlActor = my2DActor;
673 myFunctor.reset(new SMESH::Controls::FreeBorders());
674 myControlActor = my1DActor;
677 myFunctor.reset(new SMESH::Controls::FreeEdges());
678 myControlActor = my2DActor;
681 myFunctor.reset(new SMESH::Controls::FreeNodes());
682 myControlActor = myNodeActor;
685 myFunctor.reset(new SMESH::Controls::FreeFaces());
686 myControlActor = my2DActor;
688 case eBareBorderFace:
689 myFunctor.reset(new SMESH::Controls::BareBorderFace());
690 myControlActor = my2DActor;
692 case eOverConstrainedFace:
693 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
694 myControlActor = my2DActor;
696 case eMultiConnection:
697 myFunctor.reset(new SMESH::Controls::MultiConnection());
698 myControlActor = my1DActor;
700 case eMultiConnection2D:
701 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
702 myControlActor = my2DActor;
706 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
707 aControl->SetPrecision( myControlsPrecision );
708 myFunctor.reset( aControl );
709 myControlActor = my2DActor;
714 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
715 aControl->SetPrecision( myControlsPrecision );
716 myFunctor.reset( aControl );
717 myControlActor = my2DActor;
722 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
723 aControl->SetPrecision( myControlsPrecision );
724 myFunctor.reset( aControl );
725 myControlActor = my2DActor;
730 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
731 aControl->SetPrecision( myControlsPrecision );
732 myFunctor.reset( aControl );
733 myControlActor = my3DActor;
738 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
739 aControl->SetPrecision( myControlsPrecision );
740 myFunctor.reset( aControl );
741 myControlActor = my3DActor;
744 case eMaxElementLength2D:
746 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
747 aControl->SetPrecision( myControlsPrecision );
748 myFunctor.reset( aControl );
749 myControlActor = my2DActor;
752 case eMaxElementLength3D:
754 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
755 aControl->SetPrecision( myControlsPrecision );
756 myFunctor.reset( aControl );
757 myControlActor = my3DActor;
760 case eBareBorderVolume:
762 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
763 myControlActor = my3DActor;
766 case eOverConstrainedVolume:
768 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
769 myControlActor = my3DActor;
774 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
775 aControl->SetPrecision( myControlsPrecision );
776 myFunctor.reset( aControl );
777 myControlActor = my2DActor;
782 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
783 aControl->SetPrecision( myControlsPrecision );
784 myFunctor.reset( aControl );
785 myControlActor = my2DActor;
790 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
791 aControl->SetPrecision( myControlsPrecision );
792 myFunctor.reset( aControl );
793 myControlActor = my2DActor;
800 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
801 vtkIdType aNbCells = aGrid->GetNumberOfCells();
803 myControlMode = theMode;
804 switch(myControlMode){
806 myNodeExtActor->SetExtControlMode(myFunctor);
810 my1DExtActor->SetExtControlMode(myFunctor);
813 case eBareBorderFace:
814 case eOverConstrainedFace:
815 my2DExtActor->SetExtControlMode(myFunctor);
817 case eBareBorderVolume:
818 case eOverConstrainedVolume:
819 my3DExtActor->SetExtControlMode(myFunctor);
822 case eMultiConnection2D:
823 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
824 UpdateDistribution();
827 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
828 UpdateDistribution();
832 if(theCheckEntityMode) {
833 if(myControlActor == my1DActor) {
834 if (!myIsEntityModeCache){
835 myEntityModeCache = GetEntityMode();
836 myIsEntityModeCache=true;
838 SetEntityMode(eEdges);
840 else if(myControlActor == my2DActor) {
841 switch(myControlMode) {
845 case eMultiConnection2D:
846 if (!myIsEntityModeCache){
847 myEntityModeCache = GetEntityMode();
848 myIsEntityModeCache=true;
850 SetEntityMode(eFaces);
853 if (!myIsEntityModeCache){
854 myEntityModeCache = GetEntityMode();
855 myIsEntityModeCache=true;
857 SetEntityMode(eFaces);
859 }else if(myControlActor == my3DActor) {
860 if (!myIsEntityModeCache){
861 myEntityModeCache = GetEntityMode();
862 myIsEntityModeCache=true;
864 SetEntityMode(eVolumes);
870 if(theCheckEntityMode){
871 myEntityMode = myEntityModeCache;
872 myIsEntityModeCache = false;
877 SetRepresentation(GetRepresentation());
879 myTimeStamp->Modified();
885 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
886 theRenderer->AddActor(myBaseActor);
887 theRenderer->AddActor(myNodeExtActor);
888 theRenderer->AddActor(my1DExtActor);
890 my3DActor->AddToRender(theRenderer);
891 my3DExtActor->AddToRender(theRenderer);
892 my2DActor->AddToRender(theRenderer);
893 my2DExtActor->AddToRender(theRenderer);
894 myNodeActor->AddToRender(theRenderer);
895 my1DActor->AddToRender(theRenderer);
896 my0DActor->AddToRender(theRenderer);
897 //theRenderer->AddActor(my0DExtActor);
899 theRenderer->AddActor(myHighlitableActor);
901 theRenderer->AddActor2D(myScalarBarActor);
903 // the superclass' method should be called at the end
904 // (in particular, for correct work of selection)
905 SALOME_Actor::AddToRender(theRenderer);
908 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
909 SALOME_Actor::RemoveFromRender(theRenderer);
911 theRenderer->RemoveActor(myBaseActor);
913 theRenderer->RemoveActor(myNodeExtActor);
915 theRenderer->RemoveActor(myHighlitableActor);
917 //theRenderer->RemoveActor(my0DExtActor);
919 theRenderer->RemoveActor(my1DExtActor);
921 my2DActor->RemoveFromRender(theRenderer);
922 my2DExtActor->RemoveFromRender(theRenderer);
923 my3DActor->RemoveFromRender(theRenderer);
924 my3DExtActor->RemoveFromRender(theRenderer);
925 myNodeActor->RemoveFromRender(theRenderer);
926 my0DActor->RemoveFromRender(theRenderer);
927 my1DActor->RemoveFromRender(theRenderer);
929 theRenderer->RemoveActor(myScalarBarActor);
933 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
934 const char* theEntry,
938 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
942 myVisualObj = theVisualObj;
943 myVisualObj->Update(theIsClear);
945 myNodeActor->Init(myVisualObj,myImplicitBoolean);
946 myBaseActor->Init(myVisualObj,myImplicitBoolean);
948 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
950 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
952 my0DActor->Init(myVisualObj,myImplicitBoolean);
953 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
955 my1DActor->Init(myVisualObj,myImplicitBoolean);
956 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
958 my2DActor->Init(myVisualObj,myImplicitBoolean);
959 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
960 my3DActor->Init(myVisualObj,myImplicitBoolean);
961 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
963 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
964 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
966 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
967 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
969 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
970 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
971 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
972 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
974 vtkFloatingPointType aFactor, aUnits;
975 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
976 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
977 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
979 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
983 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
984 SetIsShrunkable(true);
986 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
988 int aMode = mgr->integerValue( "SMESH", "display_mode" );
989 SetRepresentation(-1);
992 SetRepresentation(eEdge);
993 }else if(aMode == 1){
994 SetRepresentation(eSurface);
995 }else if(aMode == 2){
996 SetRepresentation(ePoint);
1003 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1004 SetIsDisplayNameActor( true );
1006 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1007 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1008 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1010 myTimeStamp->Modified();
1016 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1017 return myNodeActor->GetBounds();
1021 vtkDataSet* SMESH_ActorDef::GetInput(){
1022 return GetUnstructuredGrid();
1026 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1027 Superclass::SetTransform(theTransform);
1029 myNodeActor->SetTransform(theTransform);
1030 myBaseActor->SetTransform(theTransform);
1032 myHighlitableActor->SetTransform(theTransform);
1034 myNodeExtActor->SetTransform(theTransform);
1036 my0DActor->SetTransform(theTransform);
1037 //my0DExtActor->SetTransform(theTransform);
1039 my1DActor->SetTransform(theTransform);
1040 my1DExtActor->SetTransform(theTransform);
1042 my2DActor->SetTransform(theTransform);
1043 my2DExtActor->SetTransform(theTransform);
1044 my3DActor->SetTransform(theTransform);
1045 my3DExtActor->SetTransform(theTransform);
1051 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1052 vtkLODActor::SetMapper(theMapper);
1056 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1057 SALOME_Actor::ShallowCopy(prop);
1061 vtkMapper* SMESH_ActorDef::GetMapper(){
1062 return myPickableActor->GetMapper();
1066 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1067 return myVisualObj->GetUnstructuredGrid();
1071 bool SMESH_ActorDef::IsInfinitive(){
1072 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1074 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1075 ( aDataSet->GetNumberOfCells() == 1 &&
1076 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1077 return SALOME_Actor::IsInfinitive();
1081 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1082 if ( myIsShrinkable == theShrunkable )
1084 myIsShrinkable = theShrunkable;
1088 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1089 return myBaseActor->GetShrinkFactor();
1092 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1093 myBaseActor->SetShrinkFactor(theValue);
1095 my1DActor->SetShrinkFactor(theValue);
1096 my1DExtActor->SetShrinkFactor(theValue);
1098 my2DActor->SetShrinkFactor(theValue);
1099 my2DExtActor->SetShrinkFactor(theValue);
1100 my3DActor->SetShrinkFactor(theValue);
1101 my3DExtActor->SetShrinkFactor(theValue);
1102 my3DExtActor->SetShrinkFactor(theValue);
1103 myHighlitableActor->SetShrinkFactor(theValue);
1108 void SMESH_ActorDef::SetShrink(){
1109 if(!myIsShrinkable) return;
1111 myBaseActor->SetShrink();
1113 my1DActor->SetShrink();
1114 my1DExtActor->SetShrink();
1116 my2DActor->SetShrink();
1117 my2DExtActor->SetShrink();
1118 my3DActor->SetShrink();
1119 my3DExtActor->SetShrink();
1120 myHighlitableActor->SetShrink();
1126 void SMESH_ActorDef::UnShrink(){
1127 if(!myIsShrunk) return;
1129 myBaseActor->UnShrink();
1131 my1DActor->UnShrink();
1132 my1DExtActor->UnShrink();
1134 my2DActor->UnShrink();
1135 my2DExtActor->UnShrink();
1136 my3DActor->UnShrink();
1137 my3DExtActor->UnShrink();
1138 myHighlitableActor->UnShrink();
1145 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1146 return myPickableActor->GetNodeObjId(theVtkID);
1149 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1150 return myPickableActor->GetNodeCoord(theObjID);
1154 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1155 return myPickableActor->GetElemObjId(theVtkID);
1158 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1159 return myPickableActor->GetElemCell(theObjID);
1163 void SMESH_ActorDef::SetVisibility(int theMode){
1164 SetVisibility(theMode,true);
1168 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1169 SALOME_Actor::SetVisibility(theMode);
1171 myNodeActor->VisibilityOff();
1172 myBaseActor->VisibilityOff();
1174 myNodeExtActor->VisibilityOff();
1176 my0DActor->VisibilityOff();
1177 //my0DExtActor->VisibilityOff();
1179 my1DActor->VisibilityOff();
1180 my1DExtActor->VisibilityOff();
1182 my2DActor->VisibilityOff();
1183 my2DExtActor->VisibilityOff();
1184 my3DActor->VisibilityOff();
1185 my3DExtActor->VisibilityOff();
1187 myScalarBarActor->VisibilityOff();
1189 if(GetVisibility()){
1190 if(theIsUpdateRepersentation)
1191 SetRepresentation(GetRepresentation());
1193 if(myControlMode != eNone){
1194 switch(myControlMode){
1196 myNodeExtActor->VisibilityOn();
1200 my1DExtActor->VisibilityOn();
1203 case eBareBorderFace:
1204 case eOverConstrainedFace:
1205 my2DExtActor->VisibilityOn();
1207 case eBareBorderVolume:
1208 case eOverConstrainedVolume:
1209 my3DExtActor->VisibilityOn();
1212 case eMultiConnection2D:
1213 my1DExtActor->VisibilityOn();
1215 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1216 myScalarBarActor->VisibilityOn();
1220 if(myRepresentation != ePoint)
1221 myPickableActor->VisibilityOn();
1223 myNodeActor->VisibilityOn();
1226 if(myEntityMode & e0DElements){
1227 my0DActor->VisibilityOn();
1230 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1231 my1DActor->VisibilityOn();
1234 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1235 my2DActor->VisibilityOn();
1238 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1239 my3DActor->VisibilityOn();
1242 if(myNodeActor->GetPointsLabeled()){
1243 myNodeActor->VisibilityOn();
1247 my0DActor->UpdateLabels();
1250 my1DActor->UpdateLabels();
1253 my2DActor->UpdateLabels();
1256 my3DActor->UpdateLabels();
1258 #ifndef DISABLE_PLOT2DVIEWER
1260 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1267 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1269 myEntityState = eAllEntity;
1271 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1272 myEntityState &= ~e0DElements;
1273 theMode &= ~e0DElements;
1276 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1277 myEntityState &= ~eEdges;
1281 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1282 myEntityState &= ~eFaces;
1286 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1287 myEntityState &= ~eVolumes;
1288 theMode &= ~eVolumes;
1292 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1293 theMode |= e0DElements;
1295 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1298 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1301 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1302 theMode |= eVolumes;
1305 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1307 myEntityMode = theMode;
1308 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1309 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1310 aFilter->ClearRegisteredCellsWithType();
1311 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1313 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1314 aHightFilter->ClearRegisteredCellsWithType();
1315 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1317 if (myEntityMode & e0DElements) {
1318 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1319 aFilter->RegisterCellsWithType(VTK_VERTEX);
1320 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1323 if (myEntityMode & eEdges) {
1324 if (MYDEBUG) MESSAGE("EDGES");
1325 aFilter->RegisterCellsWithType(VTK_LINE);
1326 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1328 aHightFilter->RegisterCellsWithType(VTK_LINE);
1329 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1332 if (myEntityMode & eFaces) {
1333 if (MYDEBUG) MESSAGE("FACES");
1334 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1335 aFilter->RegisterCellsWithType(VTK_POLYGON);
1336 aFilter->RegisterCellsWithType(VTK_QUAD);
1337 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1338 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1340 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1341 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1342 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1343 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1344 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1347 if (myEntityMode & eVolumes) {
1348 if (MYDEBUG) MESSAGE("VOLUMES");
1349 aFilter->RegisterCellsWithType(VTK_TETRA);
1350 aFilter->RegisterCellsWithType(VTK_VOXEL);
1351 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1352 aFilter->RegisterCellsWithType(VTK_WEDGE);
1353 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1354 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1355 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1356 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1357 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1358 //#ifdef VTK_HAVE_POLYHEDRON
1359 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1362 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1363 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1364 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1365 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1366 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1367 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1368 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1369 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1370 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1371 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1372 //#ifdef VTK_HAVE_POLYHEDRON
1373 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1377 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1378 SetVisibility(GetVisibility(),false);
1381 void SMESH_ActorDef::SetRepresentation (int theMode)
1383 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1384 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1385 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1388 myRepresentation = eSurface;
1389 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1390 myRepresentation = eEdge;
1391 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1392 myRepresentation = ePoint;
1397 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1400 if (!aNbFaces && !aNbVolumes) return;
1403 myRepresentation = theMode;
1406 if (!GetUnstructuredGrid()->GetNumberOfCells())
1407 myRepresentation = ePoint;
1410 if (myRepresentation == ePoint) {
1418 myPickableActor = myBaseActor;
1419 myNodeActor->SetVisibility(false);
1420 myNodeExtActor->SetVisibility(false);
1421 vtkProperty *aProp = NULL, *aBackProp = NULL;
1422 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1423 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1424 switch (myRepresentation) {
1426 myPickableActor = myNodeActor;
1427 myNodeActor->SetVisibility(true);
1428 aQuadraticMode = SMESH_Actor::eLines;
1429 aProp = aBackProp = myNodeProp;
1430 aReperesent = SMESH_DeviceActor::ePoint;
1433 aProp = aBackProp = myEdgeProp;
1434 aReperesent = SMESH_DeviceActor::eInsideframe;
1437 aProp = mySurfaceProp;
1438 aBackProp = myBackSurfaceProp;
1439 aReperesent = SMESH_DeviceActor::eSurface;
1443 my2DActor->SetProperty(aProp);
1444 my2DActor->SetBackfaceProperty(aBackProp);
1445 my2DActor->SetRepresentation(aReperesent);
1447 if(aQuadraticMode == SMESH_Actor::eLines)
1448 my2DActor->SetQuadraticArcMode(false);
1449 else if(aQuadraticMode == SMESH_Actor::eArcs)
1450 my2DActor->SetQuadraticArcMode(true);
1452 my2DExtActor->SetRepresentation(aReperesent);
1454 my3DActor->SetProperty(aProp);
1455 my3DActor->SetBackfaceProperty(aBackProp);
1456 my3DActor->SetRepresentation(aReperesent);
1458 //my0DExtActor->SetVisibility(false);
1459 my1DExtActor->SetVisibility(false);
1460 my2DExtActor->SetVisibility(false);
1461 my3DExtActor->SetVisibility(false);
1464 //my0DActor->SetProperty(aProp);
1465 //my0DActor->SetBackfaceProperty(aBackProp);
1466 my0DActor->SetRepresentation(aReperesent);
1467 //my0DExtActor->SetRepresentation(aReperesent);
1469 switch(myControlMode){
1471 case eMultiConnection:
1472 aProp = aBackProp = my1DProp;
1473 if(myRepresentation != ePoint)
1474 aReperesent = SMESH_DeviceActor::eInsideframe;
1478 if(aQuadraticMode == SMESH_Actor::eLines)
1479 my1DActor->SetQuadraticArcMode(false);
1480 else if(aQuadraticMode == SMESH_Actor::eArcs)
1481 my1DActor->SetQuadraticArcMode(true);
1483 my1DActor->SetProperty(aProp);
1484 my1DActor->SetBackfaceProperty(aBackProp);
1485 my1DActor->SetRepresentation(aReperesent);
1487 my1DExtActor->SetRepresentation(aReperesent);
1489 if(myIsPointsVisible)
1490 myPickableActor = myNodeActor;
1491 if(GetPointRepresentation())
1492 myNodeActor->SetVisibility(true);
1494 SetMapper(myPickableActor->GetMapper());
1496 SetVisibility(GetVisibility(),false);
1502 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1503 if ( myIsPointsVisible == theIsPointsVisible )
1505 myIsPointsVisible = theIsPointsVisible;
1506 SetRepresentation(GetRepresentation());
1509 bool SMESH_ActorDef::GetPointRepresentation(){
1510 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1514 void SMESH_ActorDef::UpdateHighlight(){
1515 myHighlitableActor->SetHighlited(false);
1516 myHighlitableActor->SetVisibility(false);
1518 bool anIsVisible = GetVisibility();
1520 switch(myRepresentation){
1521 case SMESH_DeviceActor::eSurface:
1522 case SMESH_DeviceActor::eWireframe:
1524 if(myIsHighlighted) {
1525 myHighlitableActor->SetProperty(myHighlightProp);
1526 }else if(myIsPreselected){
1527 myHighlitableActor->SetProperty(myPreselectProp);
1528 } else if(anIsVisible){
1529 (myRepresentation == eSurface) ?
1530 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1532 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1533 myHighlitableActor->SetHighlited(anIsVisible);
1534 myHighlitableActor->GetExtractUnstructuredGrid()->
1535 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1536 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1538 myHighlitableActor->SetVisibility(anIsVisible);
1541 case SMESH_DeviceActor::ePoint:
1543 if(myIsHighlighted) {
1544 myNodeActor->SetProperty(myHighlightProp);
1545 }else if(myIsPreselected) {
1546 myNodeActor->SetProperty(myPreselectProp);
1547 } else if(anIsVisible) {
1548 myNodeActor->SetProperty(myNodeProp);
1550 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1551 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1558 void SMESH_ActorDef::highlight(bool theHighlight){
1559 if ( myIsHighlighted == theHighlight )
1561 myIsHighlighted = theHighlight;
1566 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1567 if ( myIsPreselected == thePreselect )
1569 myIsPreselected = thePreselect;
1575 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1577 if (myPickableActor->GetIsOpaque())
1579 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1587 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1589 if (!myPickableActor->GetIsOpaque())
1591 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1599 void SMESH_ActorDef::Render(vtkRenderer *ren){
1600 unsigned long aTime = myTimeStamp->GetMTime();
1601 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1602 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1603 if(anObjTime > aTime || aClippingTime > aTime)
1608 void SMESH_ActorDef::Update(){
1609 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1611 if(GetControlMode() != eNone) {
1612 unsigned long aTime = myTimeStamp->GetMTime();
1613 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1614 if (anObjTime > aTime)
1615 SetControlMode(GetControlMode(),false);
1619 myNodeActor->UpdateLabels();
1622 my0DActor->UpdateLabels();
1625 my1DActor->UpdateLabels();
1628 my2DActor->UpdateLabels();
1631 my3DActor->UpdateLabels();
1633 if(myIsFacesOriented){
1634 SetFacesOriented(myIsFacesOriented);
1637 if(myVisualObj->GetEntitiesFlag()) {
1638 myEntityMode |= myVisualObj->GetEntitiesState();
1641 SetEntityMode(GetEntityMode());
1642 SetVisibility(GetVisibility());
1644 myTimeStamp->Modified();
1649 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1650 SALOME_Actor::ReleaseGraphicsResources(renWin);
1652 myPickableActor->ReleaseGraphicsResources(renWin);
1656 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1657 vtkFloatingPointType* aColor = theProperty->GetColor();
1664 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1665 mySurfaceProp->SetOpacity(theValue);
1666 myBackSurfaceProp->SetOpacity(theValue);
1667 myEdgeProp->SetOpacity(theValue);
1668 myNodeProp->SetOpacity(theValue);
1670 my1DProp->SetOpacity(theValue);
1674 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1675 return mySurfaceProp->GetOpacity();
1679 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1680 mySurfaceProp->SetColor(r,g,b);
1681 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1682 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1683 aGroupObj->GetElementType() == SMDSAbs_Volume )
1684 myNameActor->SetBackgroundColor(r,g,b);
1686 myDeltaBrightness = delta;
1687 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1688 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1692 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1693 ::GetColor(mySurfaceProp,r,g,b);
1694 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1695 delta = myDeltaBrightness;
1698 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1699 myEdgeProp->SetColor(r,g,b);
1700 my1DProp->SetColor(r,g,b);
1701 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1702 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1703 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1704 myNameActor->SetBackgroundColor(r,g,b);
1708 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1709 ::GetColor(myEdgeProp,r,g,b);
1712 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1713 myOutLineProp->SetColor(r,g,b);
1717 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1718 ::GetColor(myOutLineProp,r,g,b);
1722 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1723 myNodeProp->SetColor(r,g,b);
1724 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1725 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1726 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1727 myNameActor->SetBackgroundColor(r,g,b);
1731 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1732 ::GetColor(myNodeProp,r,g,b);
1735 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1736 my0DProp->SetColor(r,g,b);
1737 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1738 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1739 myNameActor->SetBackgroundColor(r,g,b);
1743 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1744 ::GetColor(my0DProp,r,g,b);
1747 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1748 myHighlightProp->SetColor(r,g,b);
1752 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1753 ::GetColor(myHighlightProp,r,g,b);
1756 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1757 myPreselectProp->SetColor(r,g,b);
1761 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1762 ::GetColor(myPreselectProp,r,g,b);
1766 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1767 return myEdgeProp->GetLineWidth();
1771 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1772 myEdgeProp->SetLineWidth(theVal);
1774 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1775 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1781 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1782 my0DProp->SetPointSize(theVal);
1786 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1787 return my0DProp->GetPointSize();
1790 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1792 return myVisualObj->GetElemDimension( theObjId );
1797 IsImplicitFunctionUsed() const
1799 return myBaseActor->IsImplicitFunctionUsed();
1803 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1805 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1806 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1808 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1810 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1812 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1813 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1815 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1816 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1818 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1819 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1820 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1821 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1825 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1828 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1829 myCippingPlaneCont.push_back(thePlane);
1830 if(!IsImplicitFunctionUsed())
1831 SetImplicitFunctionUsed(true);
1832 myNodeActor->UpdateLabels();
1834 return myCippingPlaneCont.size();
1839 RemoveAllClippingPlanes()
1841 myImplicitBoolean->GetFunction()->RemoveAllItems();
1842 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1843 myCippingPlaneCont.clear();
1844 SetImplicitFunctionUsed(false);
1845 myNodeActor->UpdateLabels();
1850 GetNumberOfClippingPlanes()
1852 return myCippingPlaneCont.size();
1857 GetClippingPlane(vtkIdType theID)
1859 if(theID >= myCippingPlaneCont.size())
1861 return myCippingPlaneCont[theID].Get();
1864 void SMESH_ActorDef::UpdateScalarBar()
1866 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1870 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1872 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1873 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1875 aScalarBarTitleProp->SetFontFamilyToArial();
1877 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1879 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1880 if ( f.family() == "Arial" )
1881 aScalarBarTitleProp->SetFontFamilyToArial();
1882 else if ( f.family() == "Courier" )
1883 aScalarBarTitleProp->SetFontFamilyToCourier();
1884 else if ( f.family() == "Times" )
1885 aScalarBarTitleProp->SetFontFamilyToTimes();
1888 aScalarBarTitleProp->BoldOn();
1890 aScalarBarTitleProp->BoldOff();
1893 aScalarBarTitleProp->ItalicOn();
1895 aScalarBarTitleProp->ItalicOff();
1898 aScalarBarTitleProp->ShadowOn();
1900 aScalarBarTitleProp->ShadowOff();
1903 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1904 aScalarBarTitleProp->Delete();
1906 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1908 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1909 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1911 aScalarBarLabelProp->SetFontFamilyToArial();
1912 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1914 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1915 if( f.family() == "Arial" )
1916 aScalarBarLabelProp->SetFontFamilyToArial();
1917 else if( f.family() == "Courier" )
1918 aScalarBarLabelProp->SetFontFamilyToCourier();
1919 else if( f.family() == "Times" )
1920 aScalarBarLabelProp->SetFontFamilyToTimes();
1923 aScalarBarLabelProp->BoldOn();
1925 aScalarBarLabelProp->BoldOff();
1928 aScalarBarLabelProp->ItalicOn();
1930 aScalarBarLabelProp->ItalicOff();
1933 aScalarBarLabelProp->ShadowOn();
1935 aScalarBarLabelProp->ShadowOff();
1938 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1939 aScalarBarLabelProp->Delete();
1941 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1942 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1944 myScalarBarActor->SetOrientationToHorizontal();
1946 myScalarBarActor->SetOrientationToVertical();
1949 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1950 if( mgr->hasValue( "SMESH", name + "x" ) )
1951 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1953 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1954 if( mgr->hasValue( "SMESH", name + "y" ) )
1955 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1956 myScalarBarActor->SetPosition( aXVal, aYVal );
1958 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1959 if( mgr->hasValue( "SMESH", name + "width" ) )
1960 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1961 myScalarBarActor->SetWidth( aWVal );
1963 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1964 if( mgr->hasValue( "SMESH", name + "height" ) )
1965 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1966 myScalarBarActor->SetHeight( aHVal );
1969 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1970 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1971 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1974 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1975 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1976 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
1978 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
1979 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
1981 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
1982 myScalarBarActor->SetDistributionColoringType(coloringType);
1984 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
1985 QColor(255, 255, 255));
1987 rgb[0]= distributionColor.red()/255.;
1988 rgb[1]= distributionColor.green()/255.;
1989 rgb[2]= distributionColor.blue()/255.;
1990 myScalarBarActor->SetDistributionColor(rgb);
1995 void SMESH_ActorDef::UpdateDistribution()
1997 if(SMESH::Controls::NumericalFunctor* fun =
1998 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2000 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2001 std::vector<int> nbEvents;
2002 std::vector<double> funValues;
2003 SMESH_VisualObjDef::TEntityList elems;
2004 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2005 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2006 std::vector<int> elemIds;
2007 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2008 elemIds.push_back( (*e)->GetID());
2009 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2010 double * range = lookupTable->GetRange();
2011 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2012 myScalarBarActor->SetDistribution(nbEvents);
2016 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2019 case SMESH_Actor::eLines :
2020 myHighlitableActor->SetQuadraticArcMode(false);
2021 my2DActor->SetQuadraticArcMode(false);
2022 my1DActor->SetQuadraticArcMode(false);
2024 case SMESH_Actor::eArcs :
2025 myHighlitableActor->SetQuadraticArcMode(true);
2026 if(GetRepresentation() != SMESH_Actor::ePoint) {
2027 my2DActor->SetQuadraticArcMode(true);
2028 my1DActor->SetQuadraticArcMode(true);
2037 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2039 if(myHighlitableActor->GetQuadraticArcMode())
2040 return SMESH_Actor::eArcs;
2042 return SMESH_Actor::eLines;
2045 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2047 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2048 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2049 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2052 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2054 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2055 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2056 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2057 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2060 #ifndef DISABLE_PLOT2DVIEWER
2061 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2064 my2dHistogram->clearAllPoints();
2066 if(SMESH::Controls::NumericalFunctor* fun =
2067 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2070 if(!my2dHistogram) {
2071 my2dHistogram = new SPlot2d_Histogram();
2072 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2073 my2dHistogram->setIO(anIO);
2076 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2077 std::vector<int> nbEvents;
2078 std::vector<double> funValues;
2079 SMESH_VisualObjDef::TEntityList elems;
2080 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2081 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2082 std::vector<int> elemIds;
2084 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2085 elemIds.push_back( (*e)->GetID());
2087 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2088 double * range = lookupTable->GetRange();
2089 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2091 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2092 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2094 if(funValues.size() >= 2)
2095 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2099 //Color of the histogram
2100 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2101 my2dHistogram->setAutoAssign(true);
2104 myScalarBarActor->GetDistributionColor(rgb);
2105 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2106 my2dHistogram->setColor(aColor);
2110 return my2dHistogram;