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:
696 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
697 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
698 cn->SetTolerance( tol );
700 myControlActor = myNodeActor;
703 case eCoincidentElems1D:
704 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
705 myControlActor = my1DActor;
707 case eCoincidentElems2D:
708 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
709 myControlActor = my2DActor;
711 case eCoincidentElems3D:
712 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
713 myControlActor = my3DActor;
715 case eBareBorderFace:
716 myFunctor.reset(new SMESH::Controls::BareBorderFace());
717 myControlActor = my2DActor;
719 case eOverConstrainedFace:
720 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
721 myControlActor = my2DActor;
723 case eMultiConnection:
724 myFunctor.reset(new SMESH::Controls::MultiConnection());
725 myControlActor = my1DActor;
727 case eMultiConnection2D:
728 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
729 myControlActor = my2DActor;
733 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
734 aControl->SetPrecision( myControlsPrecision );
735 myFunctor.reset( aControl );
736 myControlActor = my2DActor;
741 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
742 aControl->SetPrecision( myControlsPrecision );
743 myFunctor.reset( aControl );
744 myControlActor = my2DActor;
749 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
750 aControl->SetPrecision( myControlsPrecision );
751 myFunctor.reset( aControl );
752 myControlActor = my2DActor;
757 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
758 aControl->SetPrecision( myControlsPrecision );
759 myFunctor.reset( aControl );
760 myControlActor = my3DActor;
765 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
766 aControl->SetPrecision( myControlsPrecision );
767 myFunctor.reset( aControl );
768 myControlActor = my3DActor;
771 case eMaxElementLength2D:
773 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
774 aControl->SetPrecision( myControlsPrecision );
775 myFunctor.reset( aControl );
776 myControlActor = my2DActor;
779 case eMaxElementLength3D:
781 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
782 aControl->SetPrecision( myControlsPrecision );
783 myFunctor.reset( aControl );
784 myControlActor = my3DActor;
787 case eBareBorderVolume:
789 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
790 myControlActor = my3DActor;
793 case eOverConstrainedVolume:
795 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
796 myControlActor = my3DActor;
801 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
802 aControl->SetPrecision( myControlsPrecision );
803 myFunctor.reset( aControl );
804 myControlActor = my2DActor;
809 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
810 aControl->SetPrecision( myControlsPrecision );
811 myFunctor.reset( aControl );
812 myControlActor = my2DActor;
817 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
818 aControl->SetPrecision( myControlsPrecision );
819 myFunctor.reset( aControl );
820 myControlActor = my2DActor;
827 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
828 vtkIdType aNbCells = aGrid->GetNumberOfCells();
830 myControlMode = theMode;
831 switch(myControlMode){
833 case eCoincidentNodes:
834 myNodeExtActor->SetExtControlMode(myFunctor);
838 case eCoincidentElems1D:
839 my1DExtActor->SetExtControlMode(myFunctor);
842 case eBareBorderFace:
843 case eOverConstrainedFace:
844 case eCoincidentElems2D:
845 my2DExtActor->SetExtControlMode(myFunctor);
847 case eBareBorderVolume:
848 case eOverConstrainedVolume:
849 case eCoincidentElems3D:
850 my3DExtActor->SetExtControlMode(myFunctor);
853 case eMultiConnection2D:
854 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
855 UpdateDistribution();
858 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
859 UpdateDistribution();
863 if(theCheckEntityMode) {
864 if(myControlActor == my1DActor) {
865 if (!myIsEntityModeCache){
866 myEntityModeCache = GetEntityMode();
867 myIsEntityModeCache=true;
869 SetEntityMode(eEdges);
871 else if(myControlActor == my2DActor) {
872 switch(myControlMode) {
876 case eMultiConnection2D:
877 if (!myIsEntityModeCache){
878 myEntityModeCache = GetEntityMode();
879 myIsEntityModeCache=true;
881 SetEntityMode(eFaces);
884 if (!myIsEntityModeCache){
885 myEntityModeCache = GetEntityMode();
886 myIsEntityModeCache=true;
888 SetEntityMode(eFaces);
890 }else if(myControlActor == my3DActor) {
891 if (!myIsEntityModeCache){
892 myEntityModeCache = GetEntityMode();
893 myIsEntityModeCache=true;
895 SetEntityMode(eVolumes);
901 if(theCheckEntityMode){
902 myEntityMode = myEntityModeCache;
903 myIsEntityModeCache = false;
908 SetRepresentation(GetRepresentation());
910 myTimeStamp->Modified();
916 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
917 theRenderer->AddActor(myBaseActor);
918 theRenderer->AddActor(myNodeExtActor);
919 theRenderer->AddActor(my1DExtActor);
921 my3DActor->AddToRender(theRenderer);
922 my3DExtActor->AddToRender(theRenderer);
923 my2DActor->AddToRender(theRenderer);
924 my2DExtActor->AddToRender(theRenderer);
925 myNodeActor->AddToRender(theRenderer);
926 my1DActor->AddToRender(theRenderer);
927 my0DActor->AddToRender(theRenderer);
928 //theRenderer->AddActor(my0DExtActor);
930 theRenderer->AddActor(myHighlitableActor);
932 theRenderer->AddActor2D(myScalarBarActor);
934 // the superclass' method should be called at the end
935 // (in particular, for correct work of selection)
936 SALOME_Actor::AddToRender(theRenderer);
939 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
940 SALOME_Actor::RemoveFromRender(theRenderer);
942 theRenderer->RemoveActor(myBaseActor);
944 theRenderer->RemoveActor(myNodeExtActor);
946 theRenderer->RemoveActor(myHighlitableActor);
948 //theRenderer->RemoveActor(my0DExtActor);
950 theRenderer->RemoveActor(my1DExtActor);
952 my2DActor->RemoveFromRender(theRenderer);
953 my2DExtActor->RemoveFromRender(theRenderer);
954 my3DActor->RemoveFromRender(theRenderer);
955 my3DExtActor->RemoveFromRender(theRenderer);
956 myNodeActor->RemoveFromRender(theRenderer);
957 my0DActor->RemoveFromRender(theRenderer);
958 my1DActor->RemoveFromRender(theRenderer);
960 theRenderer->RemoveActor(myScalarBarActor);
964 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
965 const char* theEntry,
969 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
973 myVisualObj = theVisualObj;
974 myVisualObj->Update(theIsClear);
976 myNodeActor->Init(myVisualObj,myImplicitBoolean);
977 myBaseActor->Init(myVisualObj,myImplicitBoolean);
979 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
981 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
983 my0DActor->Init(myVisualObj,myImplicitBoolean);
984 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
986 my1DActor->Init(myVisualObj,myImplicitBoolean);
987 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
989 my2DActor->Init(myVisualObj,myImplicitBoolean);
990 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
991 my3DActor->Init(myVisualObj,myImplicitBoolean);
992 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
994 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
995 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
997 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
998 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1000 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1001 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1002 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1003 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1005 vtkFloatingPointType aFactor, aUnits;
1006 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1007 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1008 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1010 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1014 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1015 SetIsShrunkable(true);
1017 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1019 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1020 SetRepresentation(-1);
1023 SetRepresentation(eEdge);
1024 }else if(aMode == 1){
1025 SetRepresentation(eSurface);
1026 }else if(aMode == 2){
1027 SetRepresentation(ePoint);
1034 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1035 SetIsDisplayNameActor( true );
1037 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1038 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1039 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1041 myTimeStamp->Modified();
1047 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1048 return myNodeActor->GetBounds();
1052 vtkDataSet* SMESH_ActorDef::GetInput(){
1053 return GetUnstructuredGrid();
1057 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1058 Superclass::SetTransform(theTransform);
1060 myNodeActor->SetTransform(theTransform);
1061 myBaseActor->SetTransform(theTransform);
1063 myHighlitableActor->SetTransform(theTransform);
1065 myNodeExtActor->SetTransform(theTransform);
1067 my0DActor->SetTransform(theTransform);
1068 //my0DExtActor->SetTransform(theTransform);
1070 my1DActor->SetTransform(theTransform);
1071 my1DExtActor->SetTransform(theTransform);
1073 my2DActor->SetTransform(theTransform);
1074 my2DExtActor->SetTransform(theTransform);
1075 my3DActor->SetTransform(theTransform);
1076 my3DExtActor->SetTransform(theTransform);
1082 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1083 vtkLODActor::SetMapper(theMapper);
1087 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1088 SALOME_Actor::ShallowCopy(prop);
1092 vtkMapper* SMESH_ActorDef::GetMapper(){
1093 return myPickableActor->GetMapper();
1097 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1098 return myVisualObj->GetUnstructuredGrid();
1102 bool SMESH_ActorDef::IsInfinitive(){
1103 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1105 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1106 ( aDataSet->GetNumberOfCells() == 1 &&
1107 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1108 return SALOME_Actor::IsInfinitive();
1112 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1113 if ( myIsShrinkable == theShrunkable )
1115 myIsShrinkable = theShrunkable;
1119 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1120 return myBaseActor->GetShrinkFactor();
1123 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1124 myBaseActor->SetShrinkFactor(theValue);
1126 my1DActor->SetShrinkFactor(theValue);
1127 my1DExtActor->SetShrinkFactor(theValue);
1129 my2DActor->SetShrinkFactor(theValue);
1130 my2DExtActor->SetShrinkFactor(theValue);
1131 my3DActor->SetShrinkFactor(theValue);
1132 my3DExtActor->SetShrinkFactor(theValue);
1133 my3DExtActor->SetShrinkFactor(theValue);
1134 myHighlitableActor->SetShrinkFactor(theValue);
1139 void SMESH_ActorDef::SetShrink(){
1140 if(!myIsShrinkable) return;
1142 myBaseActor->SetShrink();
1144 my1DActor->SetShrink();
1145 my1DExtActor->SetShrink();
1147 my2DActor->SetShrink();
1148 my2DExtActor->SetShrink();
1149 my3DActor->SetShrink();
1150 my3DExtActor->SetShrink();
1151 myHighlitableActor->SetShrink();
1157 void SMESH_ActorDef::UnShrink(){
1158 if(!myIsShrunk) return;
1160 myBaseActor->UnShrink();
1162 my1DActor->UnShrink();
1163 my1DExtActor->UnShrink();
1165 my2DActor->UnShrink();
1166 my2DExtActor->UnShrink();
1167 my3DActor->UnShrink();
1168 my3DExtActor->UnShrink();
1169 myHighlitableActor->UnShrink();
1176 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1177 return myPickableActor->GetNodeObjId(theVtkID);
1180 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1181 return myPickableActor->GetNodeCoord(theObjID);
1185 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1186 return myPickableActor->GetElemObjId(theVtkID);
1189 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1190 return myPickableActor->GetElemCell(theObjID);
1194 void SMESH_ActorDef::SetVisibility(int theMode){
1195 SetVisibility(theMode,true);
1199 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1200 SALOME_Actor::SetVisibility(theMode);
1202 myNodeActor->VisibilityOff();
1203 myBaseActor->VisibilityOff();
1205 myNodeExtActor->VisibilityOff();
1207 my0DActor->VisibilityOff();
1208 //my0DExtActor->VisibilityOff();
1210 my1DActor->VisibilityOff();
1211 my1DExtActor->VisibilityOff();
1213 my2DActor->VisibilityOff();
1214 my2DExtActor->VisibilityOff();
1215 my3DActor->VisibilityOff();
1216 my3DExtActor->VisibilityOff();
1218 myScalarBarActor->VisibilityOff();
1220 if(GetVisibility()){
1221 if(theIsUpdateRepersentation)
1222 SetRepresentation(GetRepresentation());
1224 if(myControlMode != eNone){
1225 switch(myControlMode){
1227 case eCoincidentNodes:
1228 myNodeExtActor->VisibilityOn();
1232 case eCoincidentElems1D:
1234 case eMultiConnection2D:
1235 my1DExtActor->VisibilityOn();
1238 case eBareBorderFace:
1239 case eOverConstrainedFace:
1240 case eCoincidentElems2D:
1241 my2DExtActor->VisibilityOn();
1243 case eBareBorderVolume:
1244 case eOverConstrainedVolume:
1245 case eCoincidentElems3D:
1246 my3DExtActor->VisibilityOn();
1249 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1250 myScalarBarActor->VisibilityOn();
1254 if(myRepresentation != ePoint)
1255 myPickableActor->VisibilityOn();
1257 myNodeActor->VisibilityOn();
1260 if(myEntityMode & e0DElements){
1261 my0DActor->VisibilityOn();
1264 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1265 my1DActor->VisibilityOn();
1268 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1269 my2DActor->VisibilityOn();
1272 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1273 my3DActor->VisibilityOn();
1276 if(myNodeActor->GetPointsLabeled()){
1277 myNodeActor->VisibilityOn();
1281 my0DActor->UpdateLabels();
1284 my1DActor->UpdateLabels();
1287 my2DActor->UpdateLabels();
1290 my3DActor->UpdateLabels();
1292 #ifndef DISABLE_PLOT2DVIEWER
1294 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1301 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1303 myEntityState = eAllEntity;
1305 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1306 myEntityState &= ~e0DElements;
1307 theMode &= ~e0DElements;
1310 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1311 myEntityState &= ~eEdges;
1315 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1316 myEntityState &= ~eFaces;
1320 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1321 myEntityState &= ~eVolumes;
1322 theMode &= ~eVolumes;
1326 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1327 theMode |= e0DElements;
1329 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1332 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1335 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1336 theMode |= eVolumes;
1339 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1341 myEntityMode = theMode;
1342 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1343 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1344 aFilter->ClearRegisteredCellsWithType();
1345 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1347 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1348 aHightFilter->ClearRegisteredCellsWithType();
1349 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1351 if (myEntityMode & e0DElements) {
1352 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1353 aFilter->RegisterCellsWithType(VTK_VERTEX);
1354 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1357 if (myEntityMode & eEdges) {
1358 if (MYDEBUG) MESSAGE("EDGES");
1359 aFilter->RegisterCellsWithType(VTK_LINE);
1360 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1362 aHightFilter->RegisterCellsWithType(VTK_LINE);
1363 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1366 if (myEntityMode & eFaces) {
1367 if (MYDEBUG) MESSAGE("FACES");
1368 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1369 aFilter->RegisterCellsWithType(VTK_POLYGON);
1370 aFilter->RegisterCellsWithType(VTK_QUAD);
1371 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1372 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1373 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1375 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1376 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1377 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1378 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1379 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1380 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1383 if (myEntityMode & eVolumes) {
1384 if (MYDEBUG) MESSAGE("VOLUMES");
1385 aFilter->RegisterCellsWithType(VTK_TETRA);
1386 aFilter->RegisterCellsWithType(VTK_VOXEL);
1387 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1388 aFilter->RegisterCellsWithType(VTK_WEDGE);
1389 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1390 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1391 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1392 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1393 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1394 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1395 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1396 //#ifdef VTK_HAVE_POLYHEDRON
1397 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1400 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1401 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1402 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1403 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1404 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1405 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1406 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1407 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1408 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1409 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1410 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1411 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1412 //#ifdef VTK_HAVE_POLYHEDRON
1413 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1417 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1418 SetVisibility(GetVisibility(),false);
1421 void SMESH_ActorDef::SetRepresentation (int theMode)
1423 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1424 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1425 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1428 myRepresentation = eSurface;
1429 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1430 myRepresentation = eEdge;
1431 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1432 myRepresentation = ePoint;
1437 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1440 if (!aNbFaces && !aNbVolumes) return;
1443 myRepresentation = theMode;
1446 if (!GetUnstructuredGrid()->GetNumberOfCells())
1447 myRepresentation = ePoint;
1450 if (myRepresentation == ePoint) {
1458 myPickableActor = myBaseActor;
1459 myNodeActor->SetVisibility(false);
1460 myNodeExtActor->SetVisibility(false);
1461 vtkProperty *aProp = NULL, *aBackProp = NULL;
1462 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1463 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1464 switch (myRepresentation) {
1466 myPickableActor = myNodeActor;
1467 myNodeActor->SetVisibility(true);
1468 aQuadraticMode = SMESH_Actor::eLines;
1469 aProp = aBackProp = myNodeProp;
1470 aReperesent = SMESH_DeviceActor::ePoint;
1473 aProp = aBackProp = myEdgeProp;
1474 aReperesent = SMESH_DeviceActor::eInsideframe;
1477 aProp = mySurfaceProp;
1478 aBackProp = myBackSurfaceProp;
1479 aReperesent = SMESH_DeviceActor::eSurface;
1483 my2DActor->SetProperty(aProp);
1484 my2DActor->SetBackfaceProperty(aBackProp);
1485 my2DActor->SetRepresentation(aReperesent);
1487 if(aQuadraticMode == SMESH_Actor::eLines)
1488 my2DActor->SetQuadraticArcMode(false);
1489 else if(aQuadraticMode == SMESH_Actor::eArcs)
1490 my2DActor->SetQuadraticArcMode(true);
1492 my2DExtActor->SetRepresentation(aReperesent);
1494 my3DActor->SetProperty(aProp);
1495 my3DActor->SetBackfaceProperty(aBackProp);
1496 my3DActor->SetRepresentation(aReperesent);
1498 //my0DExtActor->SetVisibility(false);
1499 my1DExtActor->SetVisibility(false);
1500 my2DExtActor->SetVisibility(false);
1501 my3DExtActor->SetVisibility(false);
1504 //my0DActor->SetProperty(aProp);
1505 //my0DActor->SetBackfaceProperty(aBackProp);
1506 my0DActor->SetRepresentation(aReperesent);
1507 //my0DExtActor->SetRepresentation(aReperesent);
1509 switch(myControlMode){
1511 case eMultiConnection:
1512 aProp = aBackProp = my1DProp;
1513 if(myRepresentation != ePoint)
1514 aReperesent = SMESH_DeviceActor::eInsideframe;
1518 if(aQuadraticMode == SMESH_Actor::eLines)
1519 my1DActor->SetQuadraticArcMode(false);
1520 else if(aQuadraticMode == SMESH_Actor::eArcs)
1521 my1DActor->SetQuadraticArcMode(true);
1523 my1DActor->SetProperty(aProp);
1524 my1DActor->SetBackfaceProperty(aBackProp);
1525 my1DActor->SetRepresentation(aReperesent);
1527 my1DExtActor->SetRepresentation(aReperesent);
1529 if(myIsPointsVisible)
1530 myPickableActor = myNodeActor;
1531 if(GetPointRepresentation())
1532 myNodeActor->SetVisibility(true);
1534 SetMapper(myPickableActor->GetMapper());
1536 SetVisibility(GetVisibility(),false);
1542 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1543 if ( myIsPointsVisible == theIsPointsVisible )
1545 myIsPointsVisible = theIsPointsVisible;
1546 SetRepresentation(GetRepresentation());
1549 bool SMESH_ActorDef::GetPointRepresentation(){
1550 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1554 void SMESH_ActorDef::UpdateHighlight(){
1555 myHighlitableActor->SetHighlited(false);
1556 myHighlitableActor->SetVisibility(false);
1558 bool anIsVisible = GetVisibility();
1560 switch(myRepresentation){
1561 case SMESH_DeviceActor::eSurface:
1562 case SMESH_DeviceActor::eWireframe:
1564 if(myIsHighlighted) {
1565 myHighlitableActor->SetProperty(myHighlightProp);
1566 }else if(myIsPreselected){
1567 myHighlitableActor->SetProperty(myPreselectProp);
1568 } else if(anIsVisible){
1569 (myRepresentation == eSurface) ?
1570 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1572 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1573 myHighlitableActor->SetHighlited(anIsVisible);
1574 myHighlitableActor->GetExtractUnstructuredGrid()->
1575 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1576 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1578 myHighlitableActor->SetVisibility(anIsVisible);
1581 case SMESH_DeviceActor::ePoint:
1583 if(myIsHighlighted) {
1584 myNodeActor->SetProperty(myHighlightProp);
1585 }else if(myIsPreselected) {
1586 myNodeActor->SetProperty(myPreselectProp);
1587 } else if(anIsVisible) {
1588 myNodeActor->SetProperty(myNodeProp);
1590 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1591 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1598 void SMESH_ActorDef::highlight(bool theHighlight){
1599 if ( myIsHighlighted == theHighlight )
1601 myIsHighlighted = theHighlight;
1606 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1607 if ( myIsPreselected == thePreselect )
1609 myIsPreselected = thePreselect;
1615 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1617 if (myPickableActor->GetIsOpaque())
1619 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1627 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1629 if (!myPickableActor->GetIsOpaque())
1631 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1639 void SMESH_ActorDef::Render(vtkRenderer *ren){
1640 unsigned long aTime = myTimeStamp->GetMTime();
1641 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1642 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1643 if(anObjTime > aTime || aClippingTime > aTime)
1648 void SMESH_ActorDef::Update(){
1649 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1651 if(GetControlMode() != eNone) {
1652 unsigned long aTime = myTimeStamp->GetMTime();
1653 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1654 if (anObjTime > aTime)
1655 SetControlMode(GetControlMode(),false);
1659 myNodeActor->UpdateLabels();
1662 my0DActor->UpdateLabels();
1665 my1DActor->UpdateLabels();
1668 my2DActor->UpdateLabels();
1671 my3DActor->UpdateLabels();
1673 if(myIsFacesOriented){
1674 SetFacesOriented(myIsFacesOriented);
1677 if(myVisualObj->GetEntitiesFlag()) {
1678 myEntityMode |= myVisualObj->GetEntitiesState();
1681 SetEntityMode(GetEntityMode());
1682 SetVisibility(GetVisibility());
1684 myTimeStamp->Modified();
1689 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1690 SALOME_Actor::ReleaseGraphicsResources(renWin);
1692 myPickableActor->ReleaseGraphicsResources(renWin);
1696 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1697 vtkFloatingPointType* aColor = theProperty->GetColor();
1704 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1705 mySurfaceProp->SetOpacity(theValue);
1706 myBackSurfaceProp->SetOpacity(theValue);
1707 myEdgeProp->SetOpacity(theValue);
1708 myNodeProp->SetOpacity(theValue);
1710 my1DProp->SetOpacity(theValue);
1714 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1715 return mySurfaceProp->GetOpacity();
1719 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1720 mySurfaceProp->SetColor(r,g,b);
1721 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1722 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1723 aGroupObj->GetElementType() == SMDSAbs_Volume )
1724 myNameActor->SetBackgroundColor(r,g,b);
1726 myDeltaBrightness = delta;
1727 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1728 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1732 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1733 ::GetColor(mySurfaceProp,r,g,b);
1734 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1735 delta = myDeltaBrightness;
1738 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1739 myEdgeProp->SetColor(r,g,b);
1740 my1DProp->SetColor(r,g,b);
1741 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1742 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1743 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1744 myNameActor->SetBackgroundColor(r,g,b);
1748 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1749 ::GetColor(myEdgeProp,r,g,b);
1752 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1753 myOutLineProp->SetColor(r,g,b);
1757 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1758 ::GetColor(myOutLineProp,r,g,b);
1762 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1763 myNodeProp->SetColor(r,g,b);
1764 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1765 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1766 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1767 myNameActor->SetBackgroundColor(r,g,b);
1771 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1772 ::GetColor(myNodeProp,r,g,b);
1775 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1776 my0DProp->SetColor(r,g,b);
1777 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1778 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1779 myNameActor->SetBackgroundColor(r,g,b);
1783 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1784 ::GetColor(my0DProp,r,g,b);
1787 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1788 myHighlightProp->SetColor(r,g,b);
1792 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1793 ::GetColor(myHighlightProp,r,g,b);
1796 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1797 myPreselectProp->SetColor(r,g,b);
1801 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1802 ::GetColor(myPreselectProp,r,g,b);
1806 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1807 return myEdgeProp->GetLineWidth();
1811 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1812 myEdgeProp->SetLineWidth(theVal);
1814 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1815 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1821 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1822 my0DProp->SetPointSize(theVal);
1826 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1827 return my0DProp->GetPointSize();
1830 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1832 return myVisualObj->GetElemDimension( theObjId );
1837 IsImplicitFunctionUsed() const
1839 return myBaseActor->IsImplicitFunctionUsed();
1843 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1845 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1846 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1848 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1850 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1852 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1853 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1855 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1856 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1858 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1859 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1860 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1861 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1865 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1868 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1869 myCippingPlaneCont.push_back(thePlane);
1870 if(!IsImplicitFunctionUsed())
1871 SetImplicitFunctionUsed(true);
1872 myNodeActor->UpdateLabels();
1874 return myCippingPlaneCont.size();
1879 RemoveAllClippingPlanes()
1881 myImplicitBoolean->GetFunction()->RemoveAllItems();
1882 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1883 myCippingPlaneCont.clear();
1884 SetImplicitFunctionUsed(false);
1885 myNodeActor->UpdateLabels();
1890 GetNumberOfClippingPlanes()
1892 return myCippingPlaneCont.size();
1897 GetClippingPlane(vtkIdType theID)
1899 if(theID >= myCippingPlaneCont.size())
1901 return myCippingPlaneCont[theID].Get();
1904 void SMESH_ActorDef::UpdateScalarBar()
1906 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1910 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1912 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1913 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1915 aScalarBarTitleProp->SetFontFamilyToArial();
1917 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1919 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1920 if ( f.family() == "Arial" )
1921 aScalarBarTitleProp->SetFontFamilyToArial();
1922 else if ( f.family() == "Courier" )
1923 aScalarBarTitleProp->SetFontFamilyToCourier();
1924 else if ( f.family() == "Times" )
1925 aScalarBarTitleProp->SetFontFamilyToTimes();
1928 aScalarBarTitleProp->BoldOn();
1930 aScalarBarTitleProp->BoldOff();
1933 aScalarBarTitleProp->ItalicOn();
1935 aScalarBarTitleProp->ItalicOff();
1938 aScalarBarTitleProp->ShadowOn();
1940 aScalarBarTitleProp->ShadowOff();
1943 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1944 aScalarBarTitleProp->Delete();
1946 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1948 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1949 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1951 aScalarBarLabelProp->SetFontFamilyToArial();
1952 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1954 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1955 if( f.family() == "Arial" )
1956 aScalarBarLabelProp->SetFontFamilyToArial();
1957 else if( f.family() == "Courier" )
1958 aScalarBarLabelProp->SetFontFamilyToCourier();
1959 else if( f.family() == "Times" )
1960 aScalarBarLabelProp->SetFontFamilyToTimes();
1963 aScalarBarLabelProp->BoldOn();
1965 aScalarBarLabelProp->BoldOff();
1968 aScalarBarLabelProp->ItalicOn();
1970 aScalarBarLabelProp->ItalicOff();
1973 aScalarBarLabelProp->ShadowOn();
1975 aScalarBarLabelProp->ShadowOff();
1978 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1979 aScalarBarLabelProp->Delete();
1981 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1982 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1984 myScalarBarActor->SetOrientationToHorizontal();
1986 myScalarBarActor->SetOrientationToVertical();
1989 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1990 if( mgr->hasValue( "SMESH", name + "x" ) )
1991 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1993 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1994 if( mgr->hasValue( "SMESH", name + "y" ) )
1995 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1996 myScalarBarActor->SetPosition( aXVal, aYVal );
1998 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1999 if( mgr->hasValue( "SMESH", name + "width" ) )
2000 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2001 myScalarBarActor->SetWidth( aWVal );
2003 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2004 if( mgr->hasValue( "SMESH", name + "height" ) )
2005 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2006 myScalarBarActor->SetHeight( aHVal );
2009 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2010 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2011 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2014 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2015 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2016 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2018 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2019 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2021 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2022 myScalarBarActor->SetDistributionColoringType(coloringType);
2024 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2025 QColor(255, 255, 255));
2027 rgb[0]= distributionColor.red()/255.;
2028 rgb[1]= distributionColor.green()/255.;
2029 rgb[2]= distributionColor.blue()/255.;
2030 myScalarBarActor->SetDistributionColor(rgb);
2035 void SMESH_ActorDef::UpdateDistribution()
2037 if(SMESH::Controls::NumericalFunctor* fun =
2038 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2040 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2041 std::vector<int> nbEvents;
2042 std::vector<double> funValues;
2043 SMESH_VisualObjDef::TEntityList elems;
2044 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2045 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2046 std::vector<int> elemIds;
2047 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2048 elemIds.push_back( (*e)->GetID());
2049 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2050 double * range = lookupTable->GetRange();
2051 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2052 myScalarBarActor->SetDistribution(nbEvents);
2056 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2059 case SMESH_Actor::eLines :
2060 myHighlitableActor->SetQuadraticArcMode(false);
2061 my2DActor->SetQuadraticArcMode(false);
2062 my1DActor->SetQuadraticArcMode(false);
2064 case SMESH_Actor::eArcs :
2065 myHighlitableActor->SetQuadraticArcMode(true);
2066 if(GetRepresentation() != SMESH_Actor::ePoint) {
2067 my2DActor->SetQuadraticArcMode(true);
2068 my1DActor->SetQuadraticArcMode(true);
2077 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2079 if(myHighlitableActor->GetQuadraticArcMode())
2080 return SMESH_Actor::eArcs;
2082 return SMESH_Actor::eLines;
2085 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2087 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2088 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2089 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2092 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2094 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2095 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2096 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2097 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2100 #ifndef DISABLE_PLOT2DVIEWER
2101 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2104 my2dHistogram->clearAllPoints();
2106 if(SMESH::Controls::NumericalFunctor* fun =
2107 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2110 if(!my2dHistogram) {
2111 my2dHistogram = new SPlot2d_Histogram();
2112 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2113 my2dHistogram->setIO(anIO);
2116 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2117 std::vector<int> nbEvents;
2118 std::vector<double> funValues;
2119 SMESH_VisualObjDef::TEntityList elems;
2120 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2121 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2122 std::vector<int> elemIds;
2124 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2125 elemIds.push_back( (*e)->GetID());
2127 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2128 double * range = lookupTable->GetRange();
2129 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2131 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2132 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2134 if(funValues.size() >= 2)
2135 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2139 //Color of the histogram
2140 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2141 my2dHistogram->setAutoAssign(true);
2144 myScalarBarActor->GetDistributionColor(rgb);
2145 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2146 my2dHistogram->setColor(aColor);
2150 return my2dHistogram;