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);
175 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
177 my2DExtProp = vtkProperty::New();
178 my2DExtProp->DeepCopy(mySurfaceProp);
179 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
180 anRGB[0] = 1 - anRGB[0];
181 anRGB[1] = 1 - anRGB[1];
182 anRGB[2] = 1 - anRGB[2];
183 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
185 my2DExtActor = SMESH_DeviceActor::New();
186 my2DExtActor->SetUserMatrix(aMatrix);
187 my2DExtActor->PickableOff();
188 my2DExtActor->SetProperty(my2DExtProp);
189 my2DExtActor->SetBackfaceProperty(my2DExtProp);
190 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
191 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
192 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
193 aFilter->RegisterCellsWithType(VTK_POLYGON);
194 aFilter->RegisterCellsWithType(VTK_QUAD);
195 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
196 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
197 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
199 my3DActor = SMESH_CellLabelActor::New();
200 my3DActor->SetStoreGemetryMapping(true);
201 my3DActor->SetUserMatrix(aMatrix);
202 my3DActor->PickableOff();
203 my3DActor->SetProperty(mySurfaceProp);
204 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
205 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
206 aFilter = my3DActor->GetExtractUnstructuredGrid();
207 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
208 aFilter->RegisterCellsWithType(VTK_TETRA);
209 aFilter->RegisterCellsWithType(VTK_VOXEL);
210 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
211 aFilter->RegisterCellsWithType(VTK_WEDGE);
212 aFilter->RegisterCellsWithType(VTK_PYRAMID);
213 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
214 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
215 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
216 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
217 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
218 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
219 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
220 //#ifdef VTK_HAVE_POLYHEDRON
221 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
222 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
225 my3DExtActor = SMESH_DeviceActor::New();
226 my3DExtActor->SetUserMatrix(aMatrix);
227 my3DExtActor->PickableOff();
228 my3DExtActor->SetProperty(my2DExtProp);
229 my3DExtActor->SetBackfaceProperty(my2DExtProp);
230 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
231 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
232 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
233 aFilter->RegisterCellsWithType(VTK_TETRA);
234 aFilter->RegisterCellsWithType(VTK_VOXEL);
235 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
236 aFilter->RegisterCellsWithType(VTK_WEDGE);
237 aFilter->RegisterCellsWithType(VTK_PYRAMID);
238 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
239 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
240 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
241 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
242 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
243 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
244 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
245 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
247 //Definition 1D device of the actor
248 //---------------------------------
249 myEdgeProp = vtkProperty::New();
250 myEdgeProp->SetAmbient(1.0);
251 myEdgeProp->SetDiffuse(0.0);
252 myEdgeProp->SetSpecular(0.0);
253 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
254 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
255 myEdgeProp->SetLineWidth(aLineWidth);
257 my1DActor = SMESH_CellLabelActor::New();
258 my1DActor->SetStoreGemetryMapping(true);
259 my1DActor->SetUserMatrix(aMatrix);
260 my1DActor->PickableOff();
261 my1DActor->SetHighlited(true);
262 my1DActor->SetProperty(myEdgeProp);
263 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
264 aFilter = my1DActor->GetExtractUnstructuredGrid();
265 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
266 aFilter->RegisterCellsWithType(VTK_LINE);
267 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
269 my1DProp = vtkProperty::New();
270 my1DProp->DeepCopy(myEdgeProp);
271 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
272 my1DProp->SetPointSize(aElem0DSize);
274 my1DExtProp = vtkProperty::New();
275 my1DExtProp->DeepCopy(myEdgeProp);
276 anRGB[0] = 1 - anRGB[0];
277 anRGB[1] = 1 - anRGB[1];
278 anRGB[2] = 1 - anRGB[2];
279 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
280 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
281 my1DExtProp->SetPointSize(aElem0DSize);
283 my1DExtActor = SMESH_DeviceActor::New();
284 my1DExtActor->SetUserMatrix(aMatrix);
285 my1DExtActor->PickableOff();
286 my1DExtActor->SetHighlited(true);
287 my1DExtActor->SetVisibility(false);
288 my1DExtActor->SetProperty(my1DExtProp);
289 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
290 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
291 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
292 aFilter->RegisterCellsWithType(VTK_LINE);
293 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
296 //Definition 0D device of the actor (0d elements)
297 //-----------------------------------------------
298 my0DProp = vtkProperty::New();
299 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
300 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
301 my0DProp->SetPointSize(aElem0DSize);
303 my0DActor = SMESH_CellLabelActor::New();
304 my0DActor->SetUserMatrix(aMatrix);
305 my0DActor->SetStoreGemetryMapping(true);
306 my0DActor->PickableOff();
307 my0DActor->SetVisibility(false);
308 my0DActor->SetProperty(my0DProp);
309 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
310 aFilter = my0DActor->GetExtractUnstructuredGrid();
311 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
312 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
313 aFilter->RegisterCellsWithType(VTK_VERTEX);
315 //my0DExtProp = vtkProperty::New();
316 //my0DExtProp->DeepCopy(my0DProp);
317 //anRGB[0] = 1 - anRGB[0];
318 //anRGB[1] = 1 - anRGB[1];
319 //anRGB[2] = 1 - anRGB[2];
320 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
321 //my0DExtProp->SetPointSize(aElem0DSize);
323 //my0DExtActor = SMESH_DeviceActor::New();
324 //my0DExtActor->SetUserMatrix(aMatrix);
325 //my0DExtActor->SetStoreClippingMapping(true);
326 //my0DExtActor->PickableOff();
327 //my0DExtActor->SetHighlited(true);
328 //my0DExtActor->SetVisibility(false);
329 //my0DExtActor->SetProperty(my0DExtProp);
330 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
331 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
332 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
333 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
334 //aFilter->RegisterCellsWithType(VTK_VERTEX);
337 //Definition 0D device of the actor (nodes)
338 //-----------------------------------------
339 myNodeProp = vtkProperty::New();
340 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
341 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
343 myNodeActor = SMESH_NodeLabelActor::New();
344 myNodeActor->SetUserMatrix(aMatrix);
345 myNodeActor->SetStoreClippingMapping(true);
346 myNodeActor->PickableOff();
347 myNodeActor->SetVisibility(false);
348 myNodeActor->SetProperty(myNodeProp);
349 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
350 aFilter = myNodeActor->GetExtractUnstructuredGrid();
351 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
353 myNodeExtProp = vtkProperty::New();
354 myNodeExtProp->DeepCopy(myNodeProp);
355 anRGB[0] = 1 - anRGB[0];
356 anRGB[1] = 1 - anRGB[1];
357 anRGB[2] = 1 - anRGB[2];
358 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
360 myNodeExtActor = SMESH_DeviceActor::New();
361 myNodeExtActor->SetUserMatrix(aMatrix);
362 myNodeExtActor->SetStoreClippingMapping(true);
363 myNodeExtActor->PickableOff();
364 myNodeExtActor->SetHighlited(true);
365 myNodeExtActor->SetVisibility(false);
366 myNodeExtActor->SetProperty(myNodeExtProp);
367 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
368 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
369 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
370 aFilter->RegisterCellsWithType(VTK_VERTEX);
372 //Definition of Pickable and Highlitable engines
373 //----------------------------------------------
375 myBaseActor->SetUserMatrix(aMatrix);
376 myBaseActor->SetStoreGemetryMapping(true);
377 myBaseActor->GetProperty()->SetOpacity(0.0);
378 myPickableActor = myBaseActor;
380 myHighlightProp = vtkProperty::New();
381 myHighlightProp->SetAmbient(1.0);
382 myHighlightProp->SetDiffuse(0.0);
383 myHighlightProp->SetSpecular(0.0);
384 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
385 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
386 myHighlightProp->SetPointSize(aElem0DSize); // ??
387 myHighlightProp->SetRepresentation(1);
389 myOutLineProp = vtkProperty::New();
390 myOutLineProp->SetAmbient(1.0);
391 myOutLineProp->SetDiffuse(0.0);
392 myOutLineProp->SetSpecular(0.0);
393 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
394 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
395 myOutLineProp->SetPointSize(aElem0DSize); // ??
396 myOutLineProp->SetRepresentation(1);
398 myPreselectProp = vtkProperty::New();
399 myPreselectProp->SetAmbient(1.0);
400 myPreselectProp->SetDiffuse(0.0);
401 myPreselectProp->SetSpecular(0.0);
402 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
403 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
404 myPreselectProp->SetPointSize(aElem0DSize); // ??
405 myPreselectProp->SetRepresentation(1);
407 myHighlitableActor = SMESH_DeviceActor::New();
408 myHighlitableActor->SetUserMatrix(aMatrix);
409 myHighlitableActor->PickableOff();
410 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
417 myControlMode = eNone;
418 myControlActor = my2DActor;
420 //Definition of myScalarBarActor
421 //------------------------------
422 myLookupTable = vtkLookupTable::New();
423 //Fix for Bug PAL5195 - SMESH764:
424 //Controls - Aspect Ratio: incorrect colors of the best and worst values
425 myLookupTable->SetHueRange(0.667,0.0);
427 myScalarBarActor = SMESH_ScalarBarActor::New();
428 myScalarBarActor->SetVisibility(false);
429 myScalarBarActor->SetLookupTable(myLookupTable);
432 //Incorrect "Min value" in Scalar Bar in Mesh:
433 // myScalarBarActor->SetLabelFormat("%.4g");
434 // changes was commented because of regression bug IPAL 19981
436 mgr = SUIT_Session::session()->resourceMgr();
440 myEntityMode = eAllEntity;
441 myEntityModeCache = eAllEntity;
444 myImplicitBoolean = vtkImplicitBoolean::New();
445 myImplicitBoolean->SetOperationTypeToIntersection();
447 //Quadratic 2D elements representation
448 //-----------------------------------------------------------------------------
449 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
450 if(aQuadratic2DMode == 0){
451 myHighlitableActor->SetQuadraticArcMode(false);
452 my2DActor->SetQuadraticArcMode(false);
453 my1DActor->SetQuadraticArcMode(false);
455 else if(aQuadratic2DMode == 1){
456 myHighlitableActor->SetQuadraticArcMode(true);
457 my2DActor->SetQuadraticArcMode(true);
458 my1DActor->SetQuadraticArcMode(true);
461 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
462 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
463 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
465 // Set colors of the name actor
466 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
467 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
468 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
469 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
471 #ifndef DISABLE_PLOT2DVIEWER
478 SMESH_ActorDef::~SMESH_ActorDef()
480 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
482 #ifndef DISABLE_PLOT2DVIEWER
484 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
485 delete my2dHistogram;
489 // caught by SMESHGUI::ProcessEvents() static method
490 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
492 myScalarBarActor->Delete();
493 myLookupTable->Delete();
495 mySurfaceProp->Delete();
496 myBackSurfaceProp->Delete();
497 myOutLineProp->Delete();
499 myEdgeProp->Delete();
500 myHighlightProp->Delete();
501 myPreselectProp->Delete();
503 myNodeProp->Delete();
504 myNodeExtProp->Delete();
509 //my0DExtProp->Delete();
510 //my0DExtActor->Delete();
515 my1DExtProp->Delete();
516 my1DExtActor->Delete();
519 my2DExtProp->Delete();
520 my2DExtActor->Delete();
522 my3DExtActor->Delete();
524 myNodeActor->Delete();
525 myBaseActor->Delete();
527 myNodeExtActor->Delete();
528 myHighlitableActor->Delete();
530 myImplicitBoolean->Delete();
532 myTimeStamp->Delete();
536 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
539 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
540 SetRepresentation(GetRepresentation());
541 myTimeStamp->Modified();
545 bool SMESH_ActorDef::GetPointsLabeled() {
546 return myNodeActor && myNodeActor->GetPointsLabeled();
549 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
552 my3DActor->SetCellsLabeled(theIsCellsLabeled);
555 my2DActor->SetCellsLabeled(theIsCellsLabeled);
558 my1DActor->SetCellsLabeled(theIsCellsLabeled);
561 my0DActor->SetCellsLabeled(theIsCellsLabeled);
563 myTimeStamp->Modified();
567 bool SMESH_ActorDef::GetCellsLabeled() {
570 result = result || my3DActor->GetCellsLabeled();
573 result = result || my2DActor->GetCellsLabeled();
576 result = result || my1DActor->GetCellsLabeled();
579 result = result || my0DActor->GetCellsLabeled();
585 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
587 myIsFacesOriented = theIsFacesOriented;
589 my2DActor->SetFacesOriented(theIsFacesOriented);
590 my3DActor->SetFacesOriented(theIsFacesOriented);
592 myTimeStamp->Modified();
595 bool SMESH_ActorDef::GetFacesOriented()
597 return myIsFacesOriented;
600 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
602 my2DActor->SetFacesOrientationColor( theColor );
603 my3DActor->SetFacesOrientationColor( theColor );
606 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
608 my3DActor->GetFacesOrientationColor( theColor );
611 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
613 my2DActor->SetFacesOrientationScale( theScale );
614 my3DActor->SetFacesOrientationScale( theScale );
617 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
619 return my3DActor->GetFacesOrientationScale();
622 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
624 my2DActor->SetFacesOrientation3DVectors( theState );
625 my3DActor->SetFacesOrientation3DVectors( theState );
628 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
630 return my3DActor->GetFacesOrientation3DVectors();
636 SetControlMode(eControl theMode)
638 SetControlMode(theMode,true);
644 SetControlMode(eControl theMode,
645 bool theCheckEntityMode)
647 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
651 myControlMode = eNone;
652 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
654 my0DActor->GetMapper()->SetScalarVisibility(false);
655 my1DActor->GetMapper()->SetScalarVisibility(false);
656 my2DActor->GetMapper()->SetScalarVisibility(false);
657 my3DActor->GetMapper()->SetScalarVisibility(false);
658 myScalarBarActor->SetVisibility(false);
660 bool anIsScalarVisible = theMode > eNone;
662 if(anIsScalarVisible) {
666 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
667 aControl->SetPrecision( myControlsPrecision );
668 myFunctor.reset( aControl );
669 myControlActor = my1DActor;
674 myFunctor.reset(new SMESH::Controls::Length2D());
675 myControlActor = my2DActor;
679 myFunctor.reset(new SMESH::Controls::FreeBorders());
680 myControlActor = my1DActor;
683 myFunctor.reset(new SMESH::Controls::FreeEdges());
684 myControlActor = my2DActor;
687 myFunctor.reset(new SMESH::Controls::FreeNodes());
688 myControlActor = myNodeActor;
691 myFunctor.reset(new SMESH::Controls::FreeFaces());
692 myControlActor = my2DActor;
694 case eCoincidentNodes:
695 myFunctor.reset(new SMESH::Controls::CoincidentNodes());
696 myControlActor = myNodeActor;
698 case eCoincidentElems1D:
699 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
700 myControlActor = my1DActor;
702 case eCoincidentElems2D:
703 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
704 myControlActor = my2DActor;
706 case eCoincidentElems3D:
707 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
708 myControlActor = my3DActor;
710 case eBareBorderFace:
711 myFunctor.reset(new SMESH::Controls::BareBorderFace());
712 myControlActor = my2DActor;
714 case eOverConstrainedFace:
715 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
716 myControlActor = my2DActor;
718 case eMultiConnection:
719 myFunctor.reset(new SMESH::Controls::MultiConnection());
720 myControlActor = my1DActor;
722 case eMultiConnection2D:
723 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
724 myControlActor = my2DActor;
728 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
729 aControl->SetPrecision( myControlsPrecision );
730 myFunctor.reset( aControl );
731 myControlActor = my2DActor;
736 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
737 aControl->SetPrecision( myControlsPrecision );
738 myFunctor.reset( aControl );
739 myControlActor = my2DActor;
744 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
745 aControl->SetPrecision( myControlsPrecision );
746 myFunctor.reset( aControl );
747 myControlActor = my2DActor;
752 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
753 aControl->SetPrecision( myControlsPrecision );
754 myFunctor.reset( aControl );
755 myControlActor = my3DActor;
760 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
761 aControl->SetPrecision( myControlsPrecision );
762 myFunctor.reset( aControl );
763 myControlActor = my3DActor;
766 case eMaxElementLength2D:
768 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
769 aControl->SetPrecision( myControlsPrecision );
770 myFunctor.reset( aControl );
771 myControlActor = my2DActor;
774 case eMaxElementLength3D:
776 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
777 aControl->SetPrecision( myControlsPrecision );
778 myFunctor.reset( aControl );
779 myControlActor = my3DActor;
782 case eBareBorderVolume:
784 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
785 myControlActor = my3DActor;
788 case eOverConstrainedVolume:
790 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
791 myControlActor = my3DActor;
796 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
797 aControl->SetPrecision( myControlsPrecision );
798 myFunctor.reset( aControl );
799 myControlActor = my2DActor;
804 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
805 aControl->SetPrecision( myControlsPrecision );
806 myFunctor.reset( aControl );
807 myControlActor = my2DActor;
812 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
813 aControl->SetPrecision( myControlsPrecision );
814 myFunctor.reset( aControl );
815 myControlActor = my2DActor;
822 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
823 vtkIdType aNbCells = aGrid->GetNumberOfCells();
825 myControlMode = theMode;
826 switch(myControlMode){
828 case eCoincidentNodes:
829 myNodeExtActor->SetExtControlMode(myFunctor);
833 case eCoincidentElems1D:
834 my1DExtActor->SetExtControlMode(myFunctor);
837 case eBareBorderFace:
838 case eOverConstrainedFace:
839 case eCoincidentElems2D:
840 my2DExtActor->SetExtControlMode(myFunctor);
842 case eBareBorderVolume:
843 case eOverConstrainedVolume:
844 case eCoincidentElems3D:
845 my3DExtActor->SetExtControlMode(myFunctor);
848 case eMultiConnection2D:
849 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
850 UpdateDistribution();
853 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
854 UpdateDistribution();
858 if(theCheckEntityMode) {
859 if(myControlActor == my1DActor) {
860 if (!myIsEntityModeCache){
861 myEntityModeCache = GetEntityMode();
862 myIsEntityModeCache=true;
864 SetEntityMode(eEdges);
866 else if(myControlActor == my2DActor) {
867 switch(myControlMode) {
871 case eMultiConnection2D:
872 if (!myIsEntityModeCache){
873 myEntityModeCache = GetEntityMode();
874 myIsEntityModeCache=true;
876 SetEntityMode(eFaces);
879 if (!myIsEntityModeCache){
880 myEntityModeCache = GetEntityMode();
881 myIsEntityModeCache=true;
883 SetEntityMode(eFaces);
885 }else if(myControlActor == my3DActor) {
886 if (!myIsEntityModeCache){
887 myEntityModeCache = GetEntityMode();
888 myIsEntityModeCache=true;
890 SetEntityMode(eVolumes);
896 if(theCheckEntityMode){
897 myEntityMode = myEntityModeCache;
898 myIsEntityModeCache = false;
903 SetRepresentation(GetRepresentation());
905 myTimeStamp->Modified();
911 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
912 theRenderer->AddActor(myBaseActor);
913 theRenderer->AddActor(myNodeExtActor);
914 theRenderer->AddActor(my1DExtActor);
916 my3DActor->AddToRender(theRenderer);
917 my3DExtActor->AddToRender(theRenderer);
918 my2DActor->AddToRender(theRenderer);
919 my2DExtActor->AddToRender(theRenderer);
920 myNodeActor->AddToRender(theRenderer);
921 my1DActor->AddToRender(theRenderer);
922 my0DActor->AddToRender(theRenderer);
923 //theRenderer->AddActor(my0DExtActor);
925 theRenderer->AddActor(myHighlitableActor);
927 theRenderer->AddActor2D(myScalarBarActor);
929 // the superclass' method should be called at the end
930 // (in particular, for correct work of selection)
931 SALOME_Actor::AddToRender(theRenderer);
934 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
935 SALOME_Actor::RemoveFromRender(theRenderer);
937 theRenderer->RemoveActor(myBaseActor);
939 theRenderer->RemoveActor(myNodeExtActor);
941 theRenderer->RemoveActor(myHighlitableActor);
943 //theRenderer->RemoveActor(my0DExtActor);
945 theRenderer->RemoveActor(my1DExtActor);
947 my2DActor->RemoveFromRender(theRenderer);
948 my2DExtActor->RemoveFromRender(theRenderer);
949 my3DActor->RemoveFromRender(theRenderer);
950 my3DExtActor->RemoveFromRender(theRenderer);
951 myNodeActor->RemoveFromRender(theRenderer);
952 my0DActor->RemoveFromRender(theRenderer);
953 my1DActor->RemoveFromRender(theRenderer);
955 theRenderer->RemoveActor(myScalarBarActor);
959 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
960 const char* theEntry,
964 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
968 myVisualObj = theVisualObj;
969 myVisualObj->Update(theIsClear);
971 myNodeActor->Init(myVisualObj,myImplicitBoolean);
972 myBaseActor->Init(myVisualObj,myImplicitBoolean);
974 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
976 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
978 my0DActor->Init(myVisualObj,myImplicitBoolean);
979 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
981 my1DActor->Init(myVisualObj,myImplicitBoolean);
982 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
984 my2DActor->Init(myVisualObj,myImplicitBoolean);
985 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
986 my3DActor->Init(myVisualObj,myImplicitBoolean);
987 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
989 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
990 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
992 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
993 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
995 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
996 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
997 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
998 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1000 vtkFloatingPointType aFactor, aUnits;
1001 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1002 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1003 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1005 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1009 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1010 SetIsShrunkable(true);
1012 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1014 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1015 SetRepresentation(-1);
1018 SetRepresentation(eEdge);
1019 }else if(aMode == 1){
1020 SetRepresentation(eSurface);
1021 }else if(aMode == 2){
1022 SetRepresentation(ePoint);
1029 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1030 SetIsDisplayNameActor( true );
1032 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1033 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1034 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1036 myTimeStamp->Modified();
1042 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1043 return myNodeActor->GetBounds();
1047 vtkDataSet* SMESH_ActorDef::GetInput(){
1048 return GetUnstructuredGrid();
1052 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1053 Superclass::SetTransform(theTransform);
1055 myNodeActor->SetTransform(theTransform);
1056 myBaseActor->SetTransform(theTransform);
1058 myHighlitableActor->SetTransform(theTransform);
1060 myNodeExtActor->SetTransform(theTransform);
1062 my0DActor->SetTransform(theTransform);
1063 //my0DExtActor->SetTransform(theTransform);
1065 my1DActor->SetTransform(theTransform);
1066 my1DExtActor->SetTransform(theTransform);
1068 my2DActor->SetTransform(theTransform);
1069 my2DExtActor->SetTransform(theTransform);
1070 my3DActor->SetTransform(theTransform);
1071 my3DExtActor->SetTransform(theTransform);
1077 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1078 vtkLODActor::SetMapper(theMapper);
1082 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1083 SALOME_Actor::ShallowCopy(prop);
1087 vtkMapper* SMESH_ActorDef::GetMapper(){
1088 return myPickableActor->GetMapper();
1092 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1093 return myVisualObj->GetUnstructuredGrid();
1097 bool SMESH_ActorDef::IsInfinitive(){
1098 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1100 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1101 ( aDataSet->GetNumberOfCells() == 1 &&
1102 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1103 return SALOME_Actor::IsInfinitive();
1107 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1108 if ( myIsShrinkable == theShrunkable )
1110 myIsShrinkable = theShrunkable;
1114 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1115 return myBaseActor->GetShrinkFactor();
1118 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1119 myBaseActor->SetShrinkFactor(theValue);
1121 my1DActor->SetShrinkFactor(theValue);
1122 my1DExtActor->SetShrinkFactor(theValue);
1124 my2DActor->SetShrinkFactor(theValue);
1125 my2DExtActor->SetShrinkFactor(theValue);
1126 my3DActor->SetShrinkFactor(theValue);
1127 my3DExtActor->SetShrinkFactor(theValue);
1128 my3DExtActor->SetShrinkFactor(theValue);
1129 myHighlitableActor->SetShrinkFactor(theValue);
1134 void SMESH_ActorDef::SetShrink(){
1135 if(!myIsShrinkable) return;
1137 myBaseActor->SetShrink();
1139 my1DActor->SetShrink();
1140 my1DExtActor->SetShrink();
1142 my2DActor->SetShrink();
1143 my2DExtActor->SetShrink();
1144 my3DActor->SetShrink();
1145 my3DExtActor->SetShrink();
1146 myHighlitableActor->SetShrink();
1152 void SMESH_ActorDef::UnShrink(){
1153 if(!myIsShrunk) return;
1155 myBaseActor->UnShrink();
1157 my1DActor->UnShrink();
1158 my1DExtActor->UnShrink();
1160 my2DActor->UnShrink();
1161 my2DExtActor->UnShrink();
1162 my3DActor->UnShrink();
1163 my3DExtActor->UnShrink();
1164 myHighlitableActor->UnShrink();
1171 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1172 return myPickableActor->GetNodeObjId(theVtkID);
1175 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1176 return myPickableActor->GetNodeCoord(theObjID);
1180 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1181 return myPickableActor->GetElemObjId(theVtkID);
1184 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1185 return myPickableActor->GetElemCell(theObjID);
1189 void SMESH_ActorDef::SetVisibility(int theMode){
1190 SetVisibility(theMode,true);
1194 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1195 SALOME_Actor::SetVisibility(theMode);
1197 myNodeActor->VisibilityOff();
1198 myBaseActor->VisibilityOff();
1200 myNodeExtActor->VisibilityOff();
1202 my0DActor->VisibilityOff();
1203 //my0DExtActor->VisibilityOff();
1205 my1DActor->VisibilityOff();
1206 my1DExtActor->VisibilityOff();
1208 my2DActor->VisibilityOff();
1209 my2DExtActor->VisibilityOff();
1210 my3DActor->VisibilityOff();
1211 my3DExtActor->VisibilityOff();
1213 myScalarBarActor->VisibilityOff();
1215 if(GetVisibility()){
1216 if(theIsUpdateRepersentation)
1217 SetRepresentation(GetRepresentation());
1219 if(myControlMode != eNone){
1220 switch(myControlMode){
1222 case eCoincidentNodes:
1223 myNodeExtActor->VisibilityOn();
1227 case eCoincidentElems1D:
1229 case eMultiConnection2D:
1230 my1DExtActor->VisibilityOn();
1233 case eBareBorderFace:
1234 case eOverConstrainedFace:
1235 case eCoincidentElems2D:
1236 my2DExtActor->VisibilityOn();
1238 case eBareBorderVolume:
1239 case eOverConstrainedVolume:
1240 case eCoincidentElems3D:
1241 my3DExtActor->VisibilityOn();
1244 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1245 myScalarBarActor->VisibilityOn();
1249 if(myRepresentation != ePoint)
1250 myPickableActor->VisibilityOn();
1252 myNodeActor->VisibilityOn();
1255 if(myEntityMode & e0DElements){
1256 my0DActor->VisibilityOn();
1259 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1260 my1DActor->VisibilityOn();
1263 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1264 my2DActor->VisibilityOn();
1267 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1268 my3DActor->VisibilityOn();
1271 if(myNodeActor->GetPointsLabeled()){
1272 myNodeActor->VisibilityOn();
1276 my0DActor->UpdateLabels();
1279 my1DActor->UpdateLabels();
1282 my2DActor->UpdateLabels();
1285 my3DActor->UpdateLabels();
1287 #ifndef DISABLE_PLOT2DVIEWER
1289 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1296 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1298 myEntityState = eAllEntity;
1300 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1301 myEntityState &= ~e0DElements;
1302 theMode &= ~e0DElements;
1305 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1306 myEntityState &= ~eEdges;
1310 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1311 myEntityState &= ~eFaces;
1315 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1316 myEntityState &= ~eVolumes;
1317 theMode &= ~eVolumes;
1321 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1322 theMode |= e0DElements;
1324 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1327 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1330 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1331 theMode |= eVolumes;
1334 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1336 myEntityMode = theMode;
1337 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1338 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1339 aFilter->ClearRegisteredCellsWithType();
1340 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1342 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1343 aHightFilter->ClearRegisteredCellsWithType();
1344 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1346 if (myEntityMode & e0DElements) {
1347 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1348 aFilter->RegisterCellsWithType(VTK_VERTEX);
1349 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1352 if (myEntityMode & eEdges) {
1353 if (MYDEBUG) MESSAGE("EDGES");
1354 aFilter->RegisterCellsWithType(VTK_LINE);
1355 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1357 aHightFilter->RegisterCellsWithType(VTK_LINE);
1358 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1361 if (myEntityMode & eFaces) {
1362 if (MYDEBUG) MESSAGE("FACES");
1363 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1364 aFilter->RegisterCellsWithType(VTK_POLYGON);
1365 aFilter->RegisterCellsWithType(VTK_QUAD);
1366 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1367 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1368 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1370 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1371 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1372 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1373 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1374 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1375 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1378 if (myEntityMode & eVolumes) {
1379 if (MYDEBUG) MESSAGE("VOLUMES");
1380 aFilter->RegisterCellsWithType(VTK_TETRA);
1381 aFilter->RegisterCellsWithType(VTK_VOXEL);
1382 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1383 aFilter->RegisterCellsWithType(VTK_WEDGE);
1384 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1385 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1386 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1387 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1388 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1389 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1390 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1391 //#ifdef VTK_HAVE_POLYHEDRON
1392 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1395 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1396 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1397 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1398 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1399 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1400 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1401 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1402 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1403 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1404 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1405 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1406 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1407 //#ifdef VTK_HAVE_POLYHEDRON
1408 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1412 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1413 SetVisibility(GetVisibility(),false);
1416 void SMESH_ActorDef::SetRepresentation (int theMode)
1418 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1419 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1420 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1423 myRepresentation = eSurface;
1424 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1425 myRepresentation = eEdge;
1426 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1427 myRepresentation = ePoint;
1432 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1435 if (!aNbFaces && !aNbVolumes) return;
1438 myRepresentation = theMode;
1441 if (!GetUnstructuredGrid()->GetNumberOfCells())
1442 myRepresentation = ePoint;
1445 if (myRepresentation == ePoint) {
1453 myPickableActor = myBaseActor;
1454 myNodeActor->SetVisibility(false);
1455 myNodeExtActor->SetVisibility(false);
1456 vtkProperty *aProp = NULL, *aBackProp = NULL;
1457 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1458 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1459 switch (myRepresentation) {
1461 myPickableActor = myNodeActor;
1462 myNodeActor->SetVisibility(true);
1463 aQuadraticMode = SMESH_Actor::eLines;
1464 aProp = aBackProp = myNodeProp;
1465 aReperesent = SMESH_DeviceActor::ePoint;
1468 aProp = aBackProp = myEdgeProp;
1469 aReperesent = SMESH_DeviceActor::eInsideframe;
1472 aProp = mySurfaceProp;
1473 aBackProp = myBackSurfaceProp;
1474 aReperesent = SMESH_DeviceActor::eSurface;
1478 my2DActor->SetProperty(aProp);
1479 my2DActor->SetBackfaceProperty(aBackProp);
1480 my2DActor->SetRepresentation(aReperesent);
1482 if(aQuadraticMode == SMESH_Actor::eLines)
1483 my2DActor->SetQuadraticArcMode(false);
1484 else if(aQuadraticMode == SMESH_Actor::eArcs)
1485 my2DActor->SetQuadraticArcMode(true);
1487 my2DExtActor->SetRepresentation(aReperesent);
1489 my3DActor->SetProperty(aProp);
1490 my3DActor->SetBackfaceProperty(aBackProp);
1491 my3DActor->SetRepresentation(aReperesent);
1493 //my0DExtActor->SetVisibility(false);
1494 my1DExtActor->SetVisibility(false);
1495 my2DExtActor->SetVisibility(false);
1496 my3DExtActor->SetVisibility(false);
1499 //my0DActor->SetProperty(aProp);
1500 //my0DActor->SetBackfaceProperty(aBackProp);
1501 my0DActor->SetRepresentation(aReperesent);
1502 //my0DExtActor->SetRepresentation(aReperesent);
1504 switch(myControlMode){
1506 case eMultiConnection:
1507 aProp = aBackProp = my1DProp;
1508 if(myRepresentation != ePoint)
1509 aReperesent = SMESH_DeviceActor::eInsideframe;
1513 if(aQuadraticMode == SMESH_Actor::eLines)
1514 my1DActor->SetQuadraticArcMode(false);
1515 else if(aQuadraticMode == SMESH_Actor::eArcs)
1516 my1DActor->SetQuadraticArcMode(true);
1518 my1DActor->SetProperty(aProp);
1519 my1DActor->SetBackfaceProperty(aBackProp);
1520 my1DActor->SetRepresentation(aReperesent);
1522 my1DExtActor->SetRepresentation(aReperesent);
1524 if(myIsPointsVisible)
1525 myPickableActor = myNodeActor;
1526 if(GetPointRepresentation())
1527 myNodeActor->SetVisibility(true);
1529 SetMapper(myPickableActor->GetMapper());
1531 SetVisibility(GetVisibility(),false);
1537 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1538 if ( myIsPointsVisible == theIsPointsVisible )
1540 myIsPointsVisible = theIsPointsVisible;
1541 SetRepresentation(GetRepresentation());
1544 bool SMESH_ActorDef::GetPointRepresentation(){
1545 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1549 void SMESH_ActorDef::UpdateHighlight(){
1550 myHighlitableActor->SetHighlited(false);
1551 myHighlitableActor->SetVisibility(false);
1553 bool anIsVisible = GetVisibility();
1555 switch(myRepresentation){
1556 case SMESH_DeviceActor::eSurface:
1557 case SMESH_DeviceActor::eWireframe:
1559 if(myIsHighlighted) {
1560 myHighlitableActor->SetProperty(myHighlightProp);
1561 }else if(myIsPreselected){
1562 myHighlitableActor->SetProperty(myPreselectProp);
1563 } else if(anIsVisible){
1564 (myRepresentation == eSurface) ?
1565 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1567 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1568 myHighlitableActor->SetHighlited(anIsVisible);
1569 myHighlitableActor->GetExtractUnstructuredGrid()->
1570 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1571 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1573 myHighlitableActor->SetVisibility(anIsVisible);
1576 case SMESH_DeviceActor::ePoint:
1578 if(myIsHighlighted) {
1579 myNodeActor->SetProperty(myHighlightProp);
1580 }else if(myIsPreselected) {
1581 myNodeActor->SetProperty(myPreselectProp);
1582 } else if(anIsVisible) {
1583 myNodeActor->SetProperty(myNodeProp);
1585 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1586 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1593 void SMESH_ActorDef::highlight(bool theHighlight){
1594 if ( myIsHighlighted == theHighlight )
1596 myIsHighlighted = theHighlight;
1601 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1602 if ( myIsPreselected == thePreselect )
1604 myIsPreselected = thePreselect;
1610 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1612 if (myPickableActor->GetIsOpaque())
1614 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1622 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1624 if (!myPickableActor->GetIsOpaque())
1626 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1634 void SMESH_ActorDef::Render(vtkRenderer *ren){
1635 unsigned long aTime = myTimeStamp->GetMTime();
1636 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1637 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1638 if(anObjTime > aTime || aClippingTime > aTime)
1643 void SMESH_ActorDef::Update(){
1644 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1646 if(GetControlMode() != eNone) {
1647 unsigned long aTime = myTimeStamp->GetMTime();
1648 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1649 if (anObjTime > aTime)
1650 SetControlMode(GetControlMode(),false);
1654 myNodeActor->UpdateLabels();
1657 my0DActor->UpdateLabels();
1660 my1DActor->UpdateLabels();
1663 my2DActor->UpdateLabels();
1666 my3DActor->UpdateLabels();
1668 if(myIsFacesOriented){
1669 SetFacesOriented(myIsFacesOriented);
1672 if(myVisualObj->GetEntitiesFlag()) {
1673 myEntityMode |= myVisualObj->GetEntitiesState();
1676 SetEntityMode(GetEntityMode());
1677 SetVisibility(GetVisibility());
1679 myTimeStamp->Modified();
1684 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1685 SALOME_Actor::ReleaseGraphicsResources(renWin);
1687 myPickableActor->ReleaseGraphicsResources(renWin);
1691 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1692 vtkFloatingPointType* aColor = theProperty->GetColor();
1699 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1700 mySurfaceProp->SetOpacity(theValue);
1701 myBackSurfaceProp->SetOpacity(theValue);
1702 myEdgeProp->SetOpacity(theValue);
1703 myNodeProp->SetOpacity(theValue);
1705 my1DProp->SetOpacity(theValue);
1709 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1710 return mySurfaceProp->GetOpacity();
1714 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1715 mySurfaceProp->SetColor(r,g,b);
1716 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1717 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1718 aGroupObj->GetElementType() == SMDSAbs_Volume )
1719 myNameActor->SetBackgroundColor(r,g,b);
1721 myDeltaBrightness = delta;
1722 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1723 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1727 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1728 ::GetColor(mySurfaceProp,r,g,b);
1729 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1730 delta = myDeltaBrightness;
1733 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1734 myEdgeProp->SetColor(r,g,b);
1735 my1DProp->SetColor(r,g,b);
1736 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1737 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1738 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1739 myNameActor->SetBackgroundColor(r,g,b);
1743 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1744 ::GetColor(myEdgeProp,r,g,b);
1747 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1748 myOutLineProp->SetColor(r,g,b);
1752 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1753 ::GetColor(myOutLineProp,r,g,b);
1757 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1758 myNodeProp->SetColor(r,g,b);
1759 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1760 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1761 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1762 myNameActor->SetBackgroundColor(r,g,b);
1766 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1767 ::GetColor(myNodeProp,r,g,b);
1770 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1771 my0DProp->SetColor(r,g,b);
1772 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1773 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1774 myNameActor->SetBackgroundColor(r,g,b);
1778 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1779 ::GetColor(my0DProp,r,g,b);
1782 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1783 myHighlightProp->SetColor(r,g,b);
1787 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1788 ::GetColor(myHighlightProp,r,g,b);
1791 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1792 myPreselectProp->SetColor(r,g,b);
1796 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1797 ::GetColor(myPreselectProp,r,g,b);
1801 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1802 return myEdgeProp->GetLineWidth();
1806 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1807 myEdgeProp->SetLineWidth(theVal);
1809 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1810 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1816 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1817 my0DProp->SetPointSize(theVal);
1821 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1822 return my0DProp->GetPointSize();
1825 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1827 return myVisualObj->GetElemDimension( theObjId );
1832 IsImplicitFunctionUsed() const
1834 return myBaseActor->IsImplicitFunctionUsed();
1838 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1840 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1841 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1843 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1845 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1847 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1848 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1850 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1851 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1853 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1854 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1855 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1856 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1860 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1863 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1864 myCippingPlaneCont.push_back(thePlane);
1865 if(!IsImplicitFunctionUsed())
1866 SetImplicitFunctionUsed(true);
1867 myNodeActor->UpdateLabels();
1869 return myCippingPlaneCont.size();
1874 RemoveAllClippingPlanes()
1876 myImplicitBoolean->GetFunction()->RemoveAllItems();
1877 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1878 myCippingPlaneCont.clear();
1879 SetImplicitFunctionUsed(false);
1880 myNodeActor->UpdateLabels();
1885 GetNumberOfClippingPlanes()
1887 return myCippingPlaneCont.size();
1892 GetClippingPlane(vtkIdType theID)
1894 if(theID >= myCippingPlaneCont.size())
1896 return myCippingPlaneCont[theID].Get();
1899 void SMESH_ActorDef::UpdateScalarBar()
1901 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1905 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1907 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1908 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1910 aScalarBarTitleProp->SetFontFamilyToArial();
1912 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1914 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1915 if ( f.family() == "Arial" )
1916 aScalarBarTitleProp->SetFontFamilyToArial();
1917 else if ( f.family() == "Courier" )
1918 aScalarBarTitleProp->SetFontFamilyToCourier();
1919 else if ( f.family() == "Times" )
1920 aScalarBarTitleProp->SetFontFamilyToTimes();
1923 aScalarBarTitleProp->BoldOn();
1925 aScalarBarTitleProp->BoldOff();
1928 aScalarBarTitleProp->ItalicOn();
1930 aScalarBarTitleProp->ItalicOff();
1933 aScalarBarTitleProp->ShadowOn();
1935 aScalarBarTitleProp->ShadowOff();
1938 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1939 aScalarBarTitleProp->Delete();
1941 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1943 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1944 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1946 aScalarBarLabelProp->SetFontFamilyToArial();
1947 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1949 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1950 if( f.family() == "Arial" )
1951 aScalarBarLabelProp->SetFontFamilyToArial();
1952 else if( f.family() == "Courier" )
1953 aScalarBarLabelProp->SetFontFamilyToCourier();
1954 else if( f.family() == "Times" )
1955 aScalarBarLabelProp->SetFontFamilyToTimes();
1958 aScalarBarLabelProp->BoldOn();
1960 aScalarBarLabelProp->BoldOff();
1963 aScalarBarLabelProp->ItalicOn();
1965 aScalarBarLabelProp->ItalicOff();
1968 aScalarBarLabelProp->ShadowOn();
1970 aScalarBarLabelProp->ShadowOff();
1973 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1974 aScalarBarLabelProp->Delete();
1976 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1977 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1979 myScalarBarActor->SetOrientationToHorizontal();
1981 myScalarBarActor->SetOrientationToVertical();
1984 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1985 if( mgr->hasValue( "SMESH", name + "x" ) )
1986 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1988 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1989 if( mgr->hasValue( "SMESH", name + "y" ) )
1990 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1991 myScalarBarActor->SetPosition( aXVal, aYVal );
1993 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1994 if( mgr->hasValue( "SMESH", name + "width" ) )
1995 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1996 myScalarBarActor->SetWidth( aWVal );
1998 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1999 if( mgr->hasValue( "SMESH", name + "height" ) )
2000 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2001 myScalarBarActor->SetHeight( aHVal );
2004 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2005 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2006 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2009 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2010 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2011 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2013 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2014 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2016 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2017 myScalarBarActor->SetDistributionColoringType(coloringType);
2019 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2020 QColor(255, 255, 255));
2022 rgb[0]= distributionColor.red()/255.;
2023 rgb[1]= distributionColor.green()/255.;
2024 rgb[2]= distributionColor.blue()/255.;
2025 myScalarBarActor->SetDistributionColor(rgb);
2030 void SMESH_ActorDef::UpdateDistribution()
2032 if(SMESH::Controls::NumericalFunctor* fun =
2033 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2035 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2036 std::vector<int> nbEvents;
2037 std::vector<double> funValues;
2038 SMESH_VisualObjDef::TEntityList elems;
2039 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2040 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2041 std::vector<int> elemIds;
2042 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2043 elemIds.push_back( (*e)->GetID());
2044 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2045 double * range = lookupTable->GetRange();
2046 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2047 myScalarBarActor->SetDistribution(nbEvents);
2051 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2054 case SMESH_Actor::eLines :
2055 myHighlitableActor->SetQuadraticArcMode(false);
2056 my2DActor->SetQuadraticArcMode(false);
2057 my1DActor->SetQuadraticArcMode(false);
2059 case SMESH_Actor::eArcs :
2060 myHighlitableActor->SetQuadraticArcMode(true);
2061 if(GetRepresentation() != SMESH_Actor::ePoint) {
2062 my2DActor->SetQuadraticArcMode(true);
2063 my1DActor->SetQuadraticArcMode(true);
2072 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2074 if(myHighlitableActor->GetQuadraticArcMode())
2075 return SMESH_Actor::eArcs;
2077 return SMESH_Actor::eLines;
2080 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2082 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2083 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2084 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2087 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2089 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2090 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2091 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2092 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2095 #ifndef DISABLE_PLOT2DVIEWER
2096 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2099 my2dHistogram->clearAllPoints();
2101 if(SMESH::Controls::NumericalFunctor* fun =
2102 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2105 if(!my2dHistogram) {
2106 my2dHistogram = new SPlot2d_Histogram();
2107 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2108 my2dHistogram->setIO(anIO);
2111 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2112 std::vector<int> nbEvents;
2113 std::vector<double> funValues;
2114 SMESH_VisualObjDef::TEntityList elems;
2115 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2116 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2117 std::vector<int> elemIds;
2119 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2120 elemIds.push_back( (*e)->GetID());
2122 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2123 double * range = lookupTable->GetRange();
2124 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2126 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2127 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2129 if(funValues.size() >= 2)
2130 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2134 //Color of the histogram
2135 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2136 my2dHistogram->setAutoAssign(true);
2139 myScalarBarActor->GetDistributionColor(rgb);
2140 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2141 my2dHistogram->setColor(aColor);
2145 return my2dHistogram;