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 myNodeExtActor->VisibilityOn();
1226 my1DExtActor->VisibilityOn();
1229 case eBareBorderFace:
1230 case eOverConstrainedFace:
1231 my2DExtActor->VisibilityOn();
1233 case eBareBorderVolume:
1234 case eOverConstrainedVolume:
1235 my3DExtActor->VisibilityOn();
1238 case eMultiConnection2D:
1239 my1DExtActor->VisibilityOn();
1241 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1242 myScalarBarActor->VisibilityOn();
1246 if(myRepresentation != ePoint)
1247 myPickableActor->VisibilityOn();
1249 myNodeActor->VisibilityOn();
1252 if(myEntityMode & e0DElements){
1253 my0DActor->VisibilityOn();
1256 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1257 my1DActor->VisibilityOn();
1260 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1261 my2DActor->VisibilityOn();
1264 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1265 my3DActor->VisibilityOn();
1268 if(myNodeActor->GetPointsLabeled()){
1269 myNodeActor->VisibilityOn();
1273 my0DActor->UpdateLabels();
1276 my1DActor->UpdateLabels();
1279 my2DActor->UpdateLabels();
1282 my3DActor->UpdateLabels();
1284 #ifndef DISABLE_PLOT2DVIEWER
1286 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1293 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1295 myEntityState = eAllEntity;
1297 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1298 myEntityState &= ~e0DElements;
1299 theMode &= ~e0DElements;
1302 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1303 myEntityState &= ~eEdges;
1307 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1308 myEntityState &= ~eFaces;
1312 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1313 myEntityState &= ~eVolumes;
1314 theMode &= ~eVolumes;
1318 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1319 theMode |= e0DElements;
1321 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1324 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1327 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1328 theMode |= eVolumes;
1331 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1333 myEntityMode = theMode;
1334 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1335 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1336 aFilter->ClearRegisteredCellsWithType();
1337 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1339 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1340 aHightFilter->ClearRegisteredCellsWithType();
1341 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1343 if (myEntityMode & e0DElements) {
1344 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1345 aFilter->RegisterCellsWithType(VTK_VERTEX);
1346 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1349 if (myEntityMode & eEdges) {
1350 if (MYDEBUG) MESSAGE("EDGES");
1351 aFilter->RegisterCellsWithType(VTK_LINE);
1352 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1354 aHightFilter->RegisterCellsWithType(VTK_LINE);
1355 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1358 if (myEntityMode & eFaces) {
1359 if (MYDEBUG) MESSAGE("FACES");
1360 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1361 aFilter->RegisterCellsWithType(VTK_POLYGON);
1362 aFilter->RegisterCellsWithType(VTK_QUAD);
1363 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1364 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1365 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1367 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1368 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1369 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1370 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1371 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1372 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1375 if (myEntityMode & eVolumes) {
1376 if (MYDEBUG) MESSAGE("VOLUMES");
1377 aFilter->RegisterCellsWithType(VTK_TETRA);
1378 aFilter->RegisterCellsWithType(VTK_VOXEL);
1379 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1380 aFilter->RegisterCellsWithType(VTK_WEDGE);
1381 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1382 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1383 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1384 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1385 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1386 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1387 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1388 //#ifdef VTK_HAVE_POLYHEDRON
1389 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1392 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1393 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1394 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1395 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1396 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1397 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1398 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1399 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1400 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1401 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1402 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1403 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1404 //#ifdef VTK_HAVE_POLYHEDRON
1405 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1409 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1410 SetVisibility(GetVisibility(),false);
1413 void SMESH_ActorDef::SetRepresentation (int theMode)
1415 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1416 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1417 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1420 myRepresentation = eSurface;
1421 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1422 myRepresentation = eEdge;
1423 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1424 myRepresentation = ePoint;
1429 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1432 if (!aNbFaces && !aNbVolumes) return;
1435 myRepresentation = theMode;
1438 if (!GetUnstructuredGrid()->GetNumberOfCells())
1439 myRepresentation = ePoint;
1442 if (myRepresentation == ePoint) {
1450 myPickableActor = myBaseActor;
1451 myNodeActor->SetVisibility(false);
1452 myNodeExtActor->SetVisibility(false);
1453 vtkProperty *aProp = NULL, *aBackProp = NULL;
1454 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1455 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1456 switch (myRepresentation) {
1458 myPickableActor = myNodeActor;
1459 myNodeActor->SetVisibility(true);
1460 aQuadraticMode = SMESH_Actor::eLines;
1461 aProp = aBackProp = myNodeProp;
1462 aReperesent = SMESH_DeviceActor::ePoint;
1465 aProp = aBackProp = myEdgeProp;
1466 aReperesent = SMESH_DeviceActor::eInsideframe;
1469 aProp = mySurfaceProp;
1470 aBackProp = myBackSurfaceProp;
1471 aReperesent = SMESH_DeviceActor::eSurface;
1475 my2DActor->SetProperty(aProp);
1476 my2DActor->SetBackfaceProperty(aBackProp);
1477 my2DActor->SetRepresentation(aReperesent);
1479 if(aQuadraticMode == SMESH_Actor::eLines)
1480 my2DActor->SetQuadraticArcMode(false);
1481 else if(aQuadraticMode == SMESH_Actor::eArcs)
1482 my2DActor->SetQuadraticArcMode(true);
1484 my2DExtActor->SetRepresentation(aReperesent);
1486 my3DActor->SetProperty(aProp);
1487 my3DActor->SetBackfaceProperty(aBackProp);
1488 my3DActor->SetRepresentation(aReperesent);
1490 //my0DExtActor->SetVisibility(false);
1491 my1DExtActor->SetVisibility(false);
1492 my2DExtActor->SetVisibility(false);
1493 my3DExtActor->SetVisibility(false);
1496 //my0DActor->SetProperty(aProp);
1497 //my0DActor->SetBackfaceProperty(aBackProp);
1498 my0DActor->SetRepresentation(aReperesent);
1499 //my0DExtActor->SetRepresentation(aReperesent);
1501 switch(myControlMode){
1503 case eMultiConnection:
1504 aProp = aBackProp = my1DProp;
1505 if(myRepresentation != ePoint)
1506 aReperesent = SMESH_DeviceActor::eInsideframe;
1510 if(aQuadraticMode == SMESH_Actor::eLines)
1511 my1DActor->SetQuadraticArcMode(false);
1512 else if(aQuadraticMode == SMESH_Actor::eArcs)
1513 my1DActor->SetQuadraticArcMode(true);
1515 my1DActor->SetProperty(aProp);
1516 my1DActor->SetBackfaceProperty(aBackProp);
1517 my1DActor->SetRepresentation(aReperesent);
1519 my1DExtActor->SetRepresentation(aReperesent);
1521 if(myIsPointsVisible)
1522 myPickableActor = myNodeActor;
1523 if(GetPointRepresentation())
1524 myNodeActor->SetVisibility(true);
1526 SetMapper(myPickableActor->GetMapper());
1528 SetVisibility(GetVisibility(),false);
1534 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1535 if ( myIsPointsVisible == theIsPointsVisible )
1537 myIsPointsVisible = theIsPointsVisible;
1538 SetRepresentation(GetRepresentation());
1541 bool SMESH_ActorDef::GetPointRepresentation(){
1542 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1546 void SMESH_ActorDef::UpdateHighlight(){
1547 myHighlitableActor->SetHighlited(false);
1548 myHighlitableActor->SetVisibility(false);
1550 bool anIsVisible = GetVisibility();
1552 switch(myRepresentation){
1553 case SMESH_DeviceActor::eSurface:
1554 case SMESH_DeviceActor::eWireframe:
1556 if(myIsHighlighted) {
1557 myHighlitableActor->SetProperty(myHighlightProp);
1558 }else if(myIsPreselected){
1559 myHighlitableActor->SetProperty(myPreselectProp);
1560 } else if(anIsVisible){
1561 (myRepresentation == eSurface) ?
1562 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1564 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1565 myHighlitableActor->SetHighlited(anIsVisible);
1566 myHighlitableActor->GetExtractUnstructuredGrid()->
1567 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1568 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1570 myHighlitableActor->SetVisibility(anIsVisible);
1573 case SMESH_DeviceActor::ePoint:
1575 if(myIsHighlighted) {
1576 myNodeActor->SetProperty(myHighlightProp);
1577 }else if(myIsPreselected) {
1578 myNodeActor->SetProperty(myPreselectProp);
1579 } else if(anIsVisible) {
1580 myNodeActor->SetProperty(myNodeProp);
1582 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1583 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1590 void SMESH_ActorDef::highlight(bool theHighlight){
1591 if ( myIsHighlighted == theHighlight )
1593 myIsHighlighted = theHighlight;
1598 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1599 if ( myIsPreselected == thePreselect )
1601 myIsPreselected = thePreselect;
1607 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1609 if (myPickableActor->GetIsOpaque())
1611 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1619 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1621 if (!myPickableActor->GetIsOpaque())
1623 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1631 void SMESH_ActorDef::Render(vtkRenderer *ren){
1632 unsigned long aTime = myTimeStamp->GetMTime();
1633 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1634 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1635 if(anObjTime > aTime || aClippingTime > aTime)
1640 void SMESH_ActorDef::Update(){
1641 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1643 if(GetControlMode() != eNone) {
1644 unsigned long aTime = myTimeStamp->GetMTime();
1645 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1646 if (anObjTime > aTime)
1647 SetControlMode(GetControlMode(),false);
1651 myNodeActor->UpdateLabels();
1654 my0DActor->UpdateLabels();
1657 my1DActor->UpdateLabels();
1660 my2DActor->UpdateLabels();
1663 my3DActor->UpdateLabels();
1665 if(myIsFacesOriented){
1666 SetFacesOriented(myIsFacesOriented);
1669 if(myVisualObj->GetEntitiesFlag()) {
1670 myEntityMode |= myVisualObj->GetEntitiesState();
1673 SetEntityMode(GetEntityMode());
1674 SetVisibility(GetVisibility());
1676 myTimeStamp->Modified();
1681 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1682 SALOME_Actor::ReleaseGraphicsResources(renWin);
1684 myPickableActor->ReleaseGraphicsResources(renWin);
1688 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1689 vtkFloatingPointType* aColor = theProperty->GetColor();
1696 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1697 mySurfaceProp->SetOpacity(theValue);
1698 myBackSurfaceProp->SetOpacity(theValue);
1699 myEdgeProp->SetOpacity(theValue);
1700 myNodeProp->SetOpacity(theValue);
1702 my1DProp->SetOpacity(theValue);
1706 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1707 return mySurfaceProp->GetOpacity();
1711 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1712 mySurfaceProp->SetColor(r,g,b);
1713 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1714 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1715 aGroupObj->GetElementType() == SMDSAbs_Volume )
1716 myNameActor->SetBackgroundColor(r,g,b);
1718 myDeltaBrightness = delta;
1719 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1720 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1724 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1725 ::GetColor(mySurfaceProp,r,g,b);
1726 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1727 delta = myDeltaBrightness;
1730 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1731 myEdgeProp->SetColor(r,g,b);
1732 my1DProp->SetColor(r,g,b);
1733 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1734 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1735 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1736 myNameActor->SetBackgroundColor(r,g,b);
1740 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1741 ::GetColor(myEdgeProp,r,g,b);
1744 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1745 myOutLineProp->SetColor(r,g,b);
1749 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1750 ::GetColor(myOutLineProp,r,g,b);
1754 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1755 myNodeProp->SetColor(r,g,b);
1756 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1757 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1758 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1759 myNameActor->SetBackgroundColor(r,g,b);
1763 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1764 ::GetColor(myNodeProp,r,g,b);
1767 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1768 my0DProp->SetColor(r,g,b);
1769 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1770 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1771 myNameActor->SetBackgroundColor(r,g,b);
1775 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1776 ::GetColor(my0DProp,r,g,b);
1779 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1780 myHighlightProp->SetColor(r,g,b);
1784 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1785 ::GetColor(myHighlightProp,r,g,b);
1788 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1789 myPreselectProp->SetColor(r,g,b);
1793 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1794 ::GetColor(myPreselectProp,r,g,b);
1798 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1799 return myEdgeProp->GetLineWidth();
1803 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1804 myEdgeProp->SetLineWidth(theVal);
1806 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1807 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1813 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1814 my0DProp->SetPointSize(theVal);
1818 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1819 return my0DProp->GetPointSize();
1822 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1824 return myVisualObj->GetElemDimension( theObjId );
1829 IsImplicitFunctionUsed() const
1831 return myBaseActor->IsImplicitFunctionUsed();
1835 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1837 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1838 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1840 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1842 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1844 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1845 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1847 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1848 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1850 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1851 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1852 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1853 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1857 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1860 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1861 myCippingPlaneCont.push_back(thePlane);
1862 if(!IsImplicitFunctionUsed())
1863 SetImplicitFunctionUsed(true);
1864 myNodeActor->UpdateLabels();
1866 return myCippingPlaneCont.size();
1871 RemoveAllClippingPlanes()
1873 myImplicitBoolean->GetFunction()->RemoveAllItems();
1874 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1875 myCippingPlaneCont.clear();
1876 SetImplicitFunctionUsed(false);
1877 myNodeActor->UpdateLabels();
1882 GetNumberOfClippingPlanes()
1884 return myCippingPlaneCont.size();
1889 GetClippingPlane(vtkIdType theID)
1891 if(theID >= myCippingPlaneCont.size())
1893 return myCippingPlaneCont[theID].Get();
1896 void SMESH_ActorDef::UpdateScalarBar()
1898 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1902 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1904 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1905 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1907 aScalarBarTitleProp->SetFontFamilyToArial();
1909 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1911 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1912 if ( f.family() == "Arial" )
1913 aScalarBarTitleProp->SetFontFamilyToArial();
1914 else if ( f.family() == "Courier" )
1915 aScalarBarTitleProp->SetFontFamilyToCourier();
1916 else if ( f.family() == "Times" )
1917 aScalarBarTitleProp->SetFontFamilyToTimes();
1920 aScalarBarTitleProp->BoldOn();
1922 aScalarBarTitleProp->BoldOff();
1925 aScalarBarTitleProp->ItalicOn();
1927 aScalarBarTitleProp->ItalicOff();
1930 aScalarBarTitleProp->ShadowOn();
1932 aScalarBarTitleProp->ShadowOff();
1935 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1936 aScalarBarTitleProp->Delete();
1938 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1940 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1941 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1943 aScalarBarLabelProp->SetFontFamilyToArial();
1944 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1946 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1947 if( f.family() == "Arial" )
1948 aScalarBarLabelProp->SetFontFamilyToArial();
1949 else if( f.family() == "Courier" )
1950 aScalarBarLabelProp->SetFontFamilyToCourier();
1951 else if( f.family() == "Times" )
1952 aScalarBarLabelProp->SetFontFamilyToTimes();
1955 aScalarBarLabelProp->BoldOn();
1957 aScalarBarLabelProp->BoldOff();
1960 aScalarBarLabelProp->ItalicOn();
1962 aScalarBarLabelProp->ItalicOff();
1965 aScalarBarLabelProp->ShadowOn();
1967 aScalarBarLabelProp->ShadowOff();
1970 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1971 aScalarBarLabelProp->Delete();
1973 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1974 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1976 myScalarBarActor->SetOrientationToHorizontal();
1978 myScalarBarActor->SetOrientationToVertical();
1981 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1982 if( mgr->hasValue( "SMESH", name + "x" ) )
1983 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1985 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1986 if( mgr->hasValue( "SMESH", name + "y" ) )
1987 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1988 myScalarBarActor->SetPosition( aXVal, aYVal );
1990 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1991 if( mgr->hasValue( "SMESH", name + "width" ) )
1992 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1993 myScalarBarActor->SetWidth( aWVal );
1995 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1996 if( mgr->hasValue( "SMESH", name + "height" ) )
1997 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1998 myScalarBarActor->SetHeight( aHVal );
2001 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2002 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2003 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2006 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2007 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2008 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2010 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2011 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2013 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2014 myScalarBarActor->SetDistributionColoringType(coloringType);
2016 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2017 QColor(255, 255, 255));
2019 rgb[0]= distributionColor.red()/255.;
2020 rgb[1]= distributionColor.green()/255.;
2021 rgb[2]= distributionColor.blue()/255.;
2022 myScalarBarActor->SetDistributionColor(rgb);
2027 void SMESH_ActorDef::UpdateDistribution()
2029 if(SMESH::Controls::NumericalFunctor* fun =
2030 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2032 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2033 std::vector<int> nbEvents;
2034 std::vector<double> funValues;
2035 SMESH_VisualObjDef::TEntityList elems;
2036 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2037 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2038 std::vector<int> elemIds;
2039 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2040 elemIds.push_back( (*e)->GetID());
2041 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2042 double * range = lookupTable->GetRange();
2043 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2044 myScalarBarActor->SetDistribution(nbEvents);
2048 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2051 case SMESH_Actor::eLines :
2052 myHighlitableActor->SetQuadraticArcMode(false);
2053 my2DActor->SetQuadraticArcMode(false);
2054 my1DActor->SetQuadraticArcMode(false);
2056 case SMESH_Actor::eArcs :
2057 myHighlitableActor->SetQuadraticArcMode(true);
2058 if(GetRepresentation() != SMESH_Actor::ePoint) {
2059 my2DActor->SetQuadraticArcMode(true);
2060 my1DActor->SetQuadraticArcMode(true);
2069 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2071 if(myHighlitableActor->GetQuadraticArcMode())
2072 return SMESH_Actor::eArcs;
2074 return SMESH_Actor::eLines;
2077 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2079 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2080 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2081 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2084 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2086 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2087 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2088 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2089 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2092 #ifndef DISABLE_PLOT2DVIEWER
2093 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2096 my2dHistogram->clearAllPoints();
2098 if(SMESH::Controls::NumericalFunctor* fun =
2099 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2102 if(!my2dHistogram) {
2103 my2dHistogram = new SPlot2d_Histogram();
2104 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2105 my2dHistogram->setIO(anIO);
2108 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2109 std::vector<int> nbEvents;
2110 std::vector<double> funValues;
2111 SMESH_VisualObjDef::TEntityList elems;
2112 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2113 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2114 std::vector<int> elemIds;
2116 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2117 elemIds.push_back( (*e)->GetID());
2119 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2120 double * range = lookupTable->GetRange();
2121 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2123 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2124 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2126 if(funValues.size() >= 2)
2127 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2131 //Color of the histogram
2132 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2133 my2dHistogram->setAutoAssign(true);
2136 myScalarBarActor->GetDistributionColor(rgb);
2137 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2138 my2dHistogram->setColor(aColor);
2142 return my2dHistogram;