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 eBareBorderFace:
695 myFunctor.reset(new SMESH::Controls::BareBorderFace());
696 myControlActor = my2DActor;
698 case eOverConstrainedFace:
699 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
700 myControlActor = my2DActor;
702 case eMultiConnection:
703 myFunctor.reset(new SMESH::Controls::MultiConnection());
704 myControlActor = my1DActor;
706 case eMultiConnection2D:
707 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
708 myControlActor = my2DActor;
712 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
713 aControl->SetPrecision( myControlsPrecision );
714 myFunctor.reset( aControl );
715 myControlActor = my2DActor;
720 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
721 aControl->SetPrecision( myControlsPrecision );
722 myFunctor.reset( aControl );
723 myControlActor = my2DActor;
728 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
729 aControl->SetPrecision( myControlsPrecision );
730 myFunctor.reset( aControl );
731 myControlActor = my2DActor;
736 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
737 aControl->SetPrecision( myControlsPrecision );
738 myFunctor.reset( aControl );
739 myControlActor = my3DActor;
744 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
745 aControl->SetPrecision( myControlsPrecision );
746 myFunctor.reset( aControl );
747 myControlActor = my3DActor;
750 case eMaxElementLength2D:
752 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
753 aControl->SetPrecision( myControlsPrecision );
754 myFunctor.reset( aControl );
755 myControlActor = my2DActor;
758 case eMaxElementLength3D:
760 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
761 aControl->SetPrecision( myControlsPrecision );
762 myFunctor.reset( aControl );
763 myControlActor = my3DActor;
766 case eBareBorderVolume:
768 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
769 myControlActor = my3DActor;
772 case eOverConstrainedVolume:
774 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
775 myControlActor = my3DActor;
780 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
781 aControl->SetPrecision( myControlsPrecision );
782 myFunctor.reset( aControl );
783 myControlActor = my2DActor;
788 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
789 aControl->SetPrecision( myControlsPrecision );
790 myFunctor.reset( aControl );
791 myControlActor = my2DActor;
796 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
797 aControl->SetPrecision( myControlsPrecision );
798 myFunctor.reset( aControl );
799 myControlActor = my2DActor;
806 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
807 vtkIdType aNbCells = aGrid->GetNumberOfCells();
809 myControlMode = theMode;
810 switch(myControlMode){
812 myNodeExtActor->SetExtControlMode(myFunctor);
816 my1DExtActor->SetExtControlMode(myFunctor);
819 case eBareBorderFace:
820 case eOverConstrainedFace:
821 my2DExtActor->SetExtControlMode(myFunctor);
823 case eBareBorderVolume:
824 case eOverConstrainedVolume:
825 my3DExtActor->SetExtControlMode(myFunctor);
828 case eMultiConnection2D:
829 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
830 UpdateDistribution();
833 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
834 UpdateDistribution();
838 if(theCheckEntityMode) {
839 if(myControlActor == my1DActor) {
840 if (!myIsEntityModeCache){
841 myEntityModeCache = GetEntityMode();
842 myIsEntityModeCache=true;
844 SetEntityMode(eEdges);
846 else if(myControlActor == my2DActor) {
847 switch(myControlMode) {
851 case eMultiConnection2D:
852 if (!myIsEntityModeCache){
853 myEntityModeCache = GetEntityMode();
854 myIsEntityModeCache=true;
856 SetEntityMode(eFaces);
859 if (!myIsEntityModeCache){
860 myEntityModeCache = GetEntityMode();
861 myIsEntityModeCache=true;
863 SetEntityMode(eFaces);
865 }else if(myControlActor == my3DActor) {
866 if (!myIsEntityModeCache){
867 myEntityModeCache = GetEntityMode();
868 myIsEntityModeCache=true;
870 SetEntityMode(eVolumes);
876 if(theCheckEntityMode){
877 myEntityMode = myEntityModeCache;
878 myIsEntityModeCache = false;
883 SetRepresentation(GetRepresentation());
885 myTimeStamp->Modified();
891 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
892 theRenderer->AddActor(myBaseActor);
893 theRenderer->AddActor(myNodeExtActor);
894 theRenderer->AddActor(my1DExtActor);
896 my3DActor->AddToRender(theRenderer);
897 my3DExtActor->AddToRender(theRenderer);
898 my2DActor->AddToRender(theRenderer);
899 my2DExtActor->AddToRender(theRenderer);
900 myNodeActor->AddToRender(theRenderer);
901 my1DActor->AddToRender(theRenderer);
902 my0DActor->AddToRender(theRenderer);
903 //theRenderer->AddActor(my0DExtActor);
905 theRenderer->AddActor(myHighlitableActor);
907 theRenderer->AddActor2D(myScalarBarActor);
909 // the superclass' method should be called at the end
910 // (in particular, for correct work of selection)
911 SALOME_Actor::AddToRender(theRenderer);
914 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
915 SALOME_Actor::RemoveFromRender(theRenderer);
917 theRenderer->RemoveActor(myBaseActor);
919 theRenderer->RemoveActor(myNodeExtActor);
921 theRenderer->RemoveActor(myHighlitableActor);
923 //theRenderer->RemoveActor(my0DExtActor);
925 theRenderer->RemoveActor(my1DExtActor);
927 my2DActor->RemoveFromRender(theRenderer);
928 my2DExtActor->RemoveFromRender(theRenderer);
929 my3DActor->RemoveFromRender(theRenderer);
930 my3DExtActor->RemoveFromRender(theRenderer);
931 myNodeActor->RemoveFromRender(theRenderer);
932 my0DActor->RemoveFromRender(theRenderer);
933 my1DActor->RemoveFromRender(theRenderer);
935 theRenderer->RemoveActor(myScalarBarActor);
939 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
940 const char* theEntry,
944 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
948 myVisualObj = theVisualObj;
949 myVisualObj->Update(theIsClear);
951 myNodeActor->Init(myVisualObj,myImplicitBoolean);
952 myBaseActor->Init(myVisualObj,myImplicitBoolean);
954 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
956 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
958 my0DActor->Init(myVisualObj,myImplicitBoolean);
959 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
961 my1DActor->Init(myVisualObj,myImplicitBoolean);
962 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
964 my2DActor->Init(myVisualObj,myImplicitBoolean);
965 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
966 my3DActor->Init(myVisualObj,myImplicitBoolean);
967 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
969 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
970 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
972 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
973 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
975 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
976 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
977 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
978 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
980 vtkFloatingPointType aFactor, aUnits;
981 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
982 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
983 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
985 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
989 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
990 SetIsShrunkable(true);
992 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
994 int aMode = mgr->integerValue( "SMESH", "display_mode" );
995 SetRepresentation(-1);
998 SetRepresentation(eEdge);
999 }else if(aMode == 1){
1000 SetRepresentation(eSurface);
1001 }else if(aMode == 2){
1002 SetRepresentation(ePoint);
1009 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1010 SetIsDisplayNameActor( true );
1012 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1013 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1014 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1016 myTimeStamp->Modified();
1022 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1023 return myNodeActor->GetBounds();
1027 vtkDataSet* SMESH_ActorDef::GetInput(){
1028 return GetUnstructuredGrid();
1032 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1033 Superclass::SetTransform(theTransform);
1035 myNodeActor->SetTransform(theTransform);
1036 myBaseActor->SetTransform(theTransform);
1038 myHighlitableActor->SetTransform(theTransform);
1040 myNodeExtActor->SetTransform(theTransform);
1042 my0DActor->SetTransform(theTransform);
1043 //my0DExtActor->SetTransform(theTransform);
1045 my1DActor->SetTransform(theTransform);
1046 my1DExtActor->SetTransform(theTransform);
1048 my2DActor->SetTransform(theTransform);
1049 my2DExtActor->SetTransform(theTransform);
1050 my3DActor->SetTransform(theTransform);
1051 my3DExtActor->SetTransform(theTransform);
1057 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1058 vtkLODActor::SetMapper(theMapper);
1062 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1063 SALOME_Actor::ShallowCopy(prop);
1067 vtkMapper* SMESH_ActorDef::GetMapper(){
1068 return myPickableActor->GetMapper();
1072 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1073 return myVisualObj->GetUnstructuredGrid();
1077 bool SMESH_ActorDef::IsInfinitive(){
1078 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1080 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1081 ( aDataSet->GetNumberOfCells() == 1 &&
1082 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1083 return SALOME_Actor::IsInfinitive();
1087 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1088 if ( myIsShrinkable == theShrunkable )
1090 myIsShrinkable = theShrunkable;
1094 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1095 return myBaseActor->GetShrinkFactor();
1098 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1099 myBaseActor->SetShrinkFactor(theValue);
1101 my1DActor->SetShrinkFactor(theValue);
1102 my1DExtActor->SetShrinkFactor(theValue);
1104 my2DActor->SetShrinkFactor(theValue);
1105 my2DExtActor->SetShrinkFactor(theValue);
1106 my3DActor->SetShrinkFactor(theValue);
1107 my3DExtActor->SetShrinkFactor(theValue);
1108 my3DExtActor->SetShrinkFactor(theValue);
1109 myHighlitableActor->SetShrinkFactor(theValue);
1114 void SMESH_ActorDef::SetShrink(){
1115 if(!myIsShrinkable) return;
1117 myBaseActor->SetShrink();
1119 my1DActor->SetShrink();
1120 my1DExtActor->SetShrink();
1122 my2DActor->SetShrink();
1123 my2DExtActor->SetShrink();
1124 my3DActor->SetShrink();
1125 my3DExtActor->SetShrink();
1126 myHighlitableActor->SetShrink();
1132 void SMESH_ActorDef::UnShrink(){
1133 if(!myIsShrunk) return;
1135 myBaseActor->UnShrink();
1137 my1DActor->UnShrink();
1138 my1DExtActor->UnShrink();
1140 my2DActor->UnShrink();
1141 my2DExtActor->UnShrink();
1142 my3DActor->UnShrink();
1143 my3DExtActor->UnShrink();
1144 myHighlitableActor->UnShrink();
1151 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1152 return myPickableActor->GetNodeObjId(theVtkID);
1155 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1156 return myPickableActor->GetNodeCoord(theObjID);
1160 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1161 return myPickableActor->GetElemObjId(theVtkID);
1164 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1165 return myPickableActor->GetElemCell(theObjID);
1169 void SMESH_ActorDef::SetVisibility(int theMode){
1170 SetVisibility(theMode,true);
1174 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1175 SALOME_Actor::SetVisibility(theMode);
1177 myNodeActor->VisibilityOff();
1178 myBaseActor->VisibilityOff();
1180 myNodeExtActor->VisibilityOff();
1182 my0DActor->VisibilityOff();
1183 //my0DExtActor->VisibilityOff();
1185 my1DActor->VisibilityOff();
1186 my1DExtActor->VisibilityOff();
1188 my2DActor->VisibilityOff();
1189 my2DExtActor->VisibilityOff();
1190 my3DActor->VisibilityOff();
1191 my3DExtActor->VisibilityOff();
1193 myScalarBarActor->VisibilityOff();
1195 if(GetVisibility()){
1196 if(theIsUpdateRepersentation)
1197 SetRepresentation(GetRepresentation());
1199 if(myControlMode != eNone){
1200 switch(myControlMode){
1202 myNodeExtActor->VisibilityOn();
1206 my1DExtActor->VisibilityOn();
1209 case eBareBorderFace:
1210 case eOverConstrainedFace:
1211 my2DExtActor->VisibilityOn();
1213 case eBareBorderVolume:
1214 case eOverConstrainedVolume:
1215 my3DExtActor->VisibilityOn();
1218 case eMultiConnection2D:
1219 my1DExtActor->VisibilityOn();
1221 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1222 myScalarBarActor->VisibilityOn();
1226 if(myRepresentation != ePoint)
1227 myPickableActor->VisibilityOn();
1229 myNodeActor->VisibilityOn();
1232 if(myEntityMode & e0DElements){
1233 my0DActor->VisibilityOn();
1236 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1237 my1DActor->VisibilityOn();
1240 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1241 my2DActor->VisibilityOn();
1244 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1245 my3DActor->VisibilityOn();
1248 if(myNodeActor->GetPointsLabeled()){
1249 myNodeActor->VisibilityOn();
1253 my0DActor->UpdateLabels();
1256 my1DActor->UpdateLabels();
1259 my2DActor->UpdateLabels();
1262 my3DActor->UpdateLabels();
1264 #ifndef DISABLE_PLOT2DVIEWER
1266 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1273 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1275 myEntityState = eAllEntity;
1277 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1278 myEntityState &= ~e0DElements;
1279 theMode &= ~e0DElements;
1282 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1283 myEntityState &= ~eEdges;
1287 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1288 myEntityState &= ~eFaces;
1292 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1293 myEntityState &= ~eVolumes;
1294 theMode &= ~eVolumes;
1298 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1299 theMode |= e0DElements;
1301 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1304 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1307 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1308 theMode |= eVolumes;
1311 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1313 myEntityMode = theMode;
1314 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1315 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1316 aFilter->ClearRegisteredCellsWithType();
1317 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1319 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1320 aHightFilter->ClearRegisteredCellsWithType();
1321 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1323 if (myEntityMode & e0DElements) {
1324 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1325 aFilter->RegisterCellsWithType(VTK_VERTEX);
1326 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1329 if (myEntityMode & eEdges) {
1330 if (MYDEBUG) MESSAGE("EDGES");
1331 aFilter->RegisterCellsWithType(VTK_LINE);
1332 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1334 aHightFilter->RegisterCellsWithType(VTK_LINE);
1335 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1338 if (myEntityMode & eFaces) {
1339 if (MYDEBUG) MESSAGE("FACES");
1340 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1341 aFilter->RegisterCellsWithType(VTK_POLYGON);
1342 aFilter->RegisterCellsWithType(VTK_QUAD);
1343 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1344 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1345 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1347 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1348 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1349 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1350 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1351 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1352 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1355 if (myEntityMode & eVolumes) {
1356 if (MYDEBUG) MESSAGE("VOLUMES");
1357 aFilter->RegisterCellsWithType(VTK_TETRA);
1358 aFilter->RegisterCellsWithType(VTK_VOXEL);
1359 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1360 aFilter->RegisterCellsWithType(VTK_WEDGE);
1361 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1362 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1363 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1364 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1365 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1366 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1367 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1368 //#ifdef VTK_HAVE_POLYHEDRON
1369 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1372 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1373 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1374 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1375 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1376 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1377 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1378 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1379 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1380 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1381 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1382 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1383 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1384 //#ifdef VTK_HAVE_POLYHEDRON
1385 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1389 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1390 SetVisibility(GetVisibility(),false);
1393 void SMESH_ActorDef::SetRepresentation (int theMode)
1395 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1396 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1397 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1400 myRepresentation = eSurface;
1401 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1402 myRepresentation = eEdge;
1403 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1404 myRepresentation = ePoint;
1409 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1412 if (!aNbFaces && !aNbVolumes) return;
1415 myRepresentation = theMode;
1418 if (!GetUnstructuredGrid()->GetNumberOfCells())
1419 myRepresentation = ePoint;
1422 if (myRepresentation == ePoint) {
1430 myPickableActor = myBaseActor;
1431 myNodeActor->SetVisibility(false);
1432 myNodeExtActor->SetVisibility(false);
1433 vtkProperty *aProp = NULL, *aBackProp = NULL;
1434 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1435 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1436 switch (myRepresentation) {
1438 myPickableActor = myNodeActor;
1439 myNodeActor->SetVisibility(true);
1440 aQuadraticMode = SMESH_Actor::eLines;
1441 aProp = aBackProp = myNodeProp;
1442 aReperesent = SMESH_DeviceActor::ePoint;
1445 aProp = aBackProp = myEdgeProp;
1446 aReperesent = SMESH_DeviceActor::eInsideframe;
1449 aProp = mySurfaceProp;
1450 aBackProp = myBackSurfaceProp;
1451 aReperesent = SMESH_DeviceActor::eSurface;
1455 my2DActor->SetProperty(aProp);
1456 my2DActor->SetBackfaceProperty(aBackProp);
1457 my2DActor->SetRepresentation(aReperesent);
1459 if(aQuadraticMode == SMESH_Actor::eLines)
1460 my2DActor->SetQuadraticArcMode(false);
1461 else if(aQuadraticMode == SMESH_Actor::eArcs)
1462 my2DActor->SetQuadraticArcMode(true);
1464 my2DExtActor->SetRepresentation(aReperesent);
1466 my3DActor->SetProperty(aProp);
1467 my3DActor->SetBackfaceProperty(aBackProp);
1468 my3DActor->SetRepresentation(aReperesent);
1470 //my0DExtActor->SetVisibility(false);
1471 my1DExtActor->SetVisibility(false);
1472 my2DExtActor->SetVisibility(false);
1473 my3DExtActor->SetVisibility(false);
1476 //my0DActor->SetProperty(aProp);
1477 //my0DActor->SetBackfaceProperty(aBackProp);
1478 my0DActor->SetRepresentation(aReperesent);
1479 //my0DExtActor->SetRepresentation(aReperesent);
1481 switch(myControlMode){
1483 case eMultiConnection:
1484 aProp = aBackProp = my1DProp;
1485 if(myRepresentation != ePoint)
1486 aReperesent = SMESH_DeviceActor::eInsideframe;
1490 if(aQuadraticMode == SMESH_Actor::eLines)
1491 my1DActor->SetQuadraticArcMode(false);
1492 else if(aQuadraticMode == SMESH_Actor::eArcs)
1493 my1DActor->SetQuadraticArcMode(true);
1495 my1DActor->SetProperty(aProp);
1496 my1DActor->SetBackfaceProperty(aBackProp);
1497 my1DActor->SetRepresentation(aReperesent);
1499 my1DExtActor->SetRepresentation(aReperesent);
1501 if(myIsPointsVisible)
1502 myPickableActor = myNodeActor;
1503 if(GetPointRepresentation())
1504 myNodeActor->SetVisibility(true);
1506 SetMapper(myPickableActor->GetMapper());
1508 SetVisibility(GetVisibility(),false);
1514 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1515 if ( myIsPointsVisible == theIsPointsVisible )
1517 myIsPointsVisible = theIsPointsVisible;
1518 SetRepresentation(GetRepresentation());
1521 bool SMESH_ActorDef::GetPointRepresentation(){
1522 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1526 void SMESH_ActorDef::UpdateHighlight(){
1527 myHighlitableActor->SetHighlited(false);
1528 myHighlitableActor->SetVisibility(false);
1530 bool anIsVisible = GetVisibility();
1532 switch(myRepresentation){
1533 case SMESH_DeviceActor::eSurface:
1534 case SMESH_DeviceActor::eWireframe:
1536 if(myIsHighlighted) {
1537 myHighlitableActor->SetProperty(myHighlightProp);
1538 }else if(myIsPreselected){
1539 myHighlitableActor->SetProperty(myPreselectProp);
1540 } else if(anIsVisible){
1541 (myRepresentation == eSurface) ?
1542 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1544 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1545 myHighlitableActor->SetHighlited(anIsVisible);
1546 myHighlitableActor->GetExtractUnstructuredGrid()->
1547 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1548 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1550 myHighlitableActor->SetVisibility(anIsVisible);
1553 case SMESH_DeviceActor::ePoint:
1555 if(myIsHighlighted) {
1556 myNodeActor->SetProperty(myHighlightProp);
1557 }else if(myIsPreselected) {
1558 myNodeActor->SetProperty(myPreselectProp);
1559 } else if(anIsVisible) {
1560 myNodeActor->SetProperty(myNodeProp);
1562 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1563 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1570 void SMESH_ActorDef::highlight(bool theHighlight){
1571 if ( myIsHighlighted == theHighlight )
1573 myIsHighlighted = theHighlight;
1578 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1579 if ( myIsPreselected == thePreselect )
1581 myIsPreselected = thePreselect;
1587 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1589 if (myPickableActor->GetIsOpaque())
1591 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1599 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1601 if (!myPickableActor->GetIsOpaque())
1603 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1611 void SMESH_ActorDef::Render(vtkRenderer *ren){
1612 unsigned long aTime = myTimeStamp->GetMTime();
1613 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1614 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1615 if(anObjTime > aTime || aClippingTime > aTime)
1620 void SMESH_ActorDef::Update(){
1621 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1623 if(GetControlMode() != eNone) {
1624 unsigned long aTime = myTimeStamp->GetMTime();
1625 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1626 if (anObjTime > aTime)
1627 SetControlMode(GetControlMode(),false);
1631 myNodeActor->UpdateLabels();
1634 my0DActor->UpdateLabels();
1637 my1DActor->UpdateLabels();
1640 my2DActor->UpdateLabels();
1643 my3DActor->UpdateLabels();
1645 if(myIsFacesOriented){
1646 SetFacesOriented(myIsFacesOriented);
1649 if(myVisualObj->GetEntitiesFlag()) {
1650 myEntityMode |= myVisualObj->GetEntitiesState();
1653 SetEntityMode(GetEntityMode());
1654 SetVisibility(GetVisibility());
1656 myTimeStamp->Modified();
1661 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1662 SALOME_Actor::ReleaseGraphicsResources(renWin);
1664 myPickableActor->ReleaseGraphicsResources(renWin);
1668 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1669 vtkFloatingPointType* aColor = theProperty->GetColor();
1676 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1677 mySurfaceProp->SetOpacity(theValue);
1678 myBackSurfaceProp->SetOpacity(theValue);
1679 myEdgeProp->SetOpacity(theValue);
1680 myNodeProp->SetOpacity(theValue);
1682 my1DProp->SetOpacity(theValue);
1686 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1687 return mySurfaceProp->GetOpacity();
1691 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1692 mySurfaceProp->SetColor(r,g,b);
1693 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1694 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1695 aGroupObj->GetElementType() == SMDSAbs_Volume )
1696 myNameActor->SetBackgroundColor(r,g,b);
1698 myDeltaBrightness = delta;
1699 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1700 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1704 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1705 ::GetColor(mySurfaceProp,r,g,b);
1706 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1707 delta = myDeltaBrightness;
1710 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1711 myEdgeProp->SetColor(r,g,b);
1712 my1DProp->SetColor(r,g,b);
1713 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1714 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1715 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1716 myNameActor->SetBackgroundColor(r,g,b);
1720 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1721 ::GetColor(myEdgeProp,r,g,b);
1724 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1725 myOutLineProp->SetColor(r,g,b);
1729 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1730 ::GetColor(myOutLineProp,r,g,b);
1734 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1735 myNodeProp->SetColor(r,g,b);
1736 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1737 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1738 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1739 myNameActor->SetBackgroundColor(r,g,b);
1743 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1744 ::GetColor(myNodeProp,r,g,b);
1747 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1748 my0DProp->SetColor(r,g,b);
1749 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1750 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1751 myNameActor->SetBackgroundColor(r,g,b);
1755 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1756 ::GetColor(my0DProp,r,g,b);
1759 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1760 myHighlightProp->SetColor(r,g,b);
1764 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1765 ::GetColor(myHighlightProp,r,g,b);
1768 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1769 myPreselectProp->SetColor(r,g,b);
1773 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1774 ::GetColor(myPreselectProp,r,g,b);
1778 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1779 return myEdgeProp->GetLineWidth();
1783 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1784 myEdgeProp->SetLineWidth(theVal);
1786 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1787 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1793 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1794 my0DProp->SetPointSize(theVal);
1798 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1799 return my0DProp->GetPointSize();
1802 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1804 return myVisualObj->GetElemDimension( theObjId );
1809 IsImplicitFunctionUsed() const
1811 return myBaseActor->IsImplicitFunctionUsed();
1815 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1817 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1818 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1820 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1822 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1824 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1825 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1827 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1828 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1830 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1831 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1832 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1833 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1837 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1840 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1841 myCippingPlaneCont.push_back(thePlane);
1842 if(!IsImplicitFunctionUsed())
1843 SetImplicitFunctionUsed(true);
1844 myNodeActor->UpdateLabels();
1846 return myCippingPlaneCont.size();
1851 RemoveAllClippingPlanes()
1853 myImplicitBoolean->GetFunction()->RemoveAllItems();
1854 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1855 myCippingPlaneCont.clear();
1856 SetImplicitFunctionUsed(false);
1857 myNodeActor->UpdateLabels();
1862 GetNumberOfClippingPlanes()
1864 return myCippingPlaneCont.size();
1869 GetClippingPlane(vtkIdType theID)
1871 if(theID >= myCippingPlaneCont.size())
1873 return myCippingPlaneCont[theID].Get();
1876 void SMESH_ActorDef::UpdateScalarBar()
1878 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1882 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1884 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1885 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1887 aScalarBarTitleProp->SetFontFamilyToArial();
1889 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1891 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1892 if ( f.family() == "Arial" )
1893 aScalarBarTitleProp->SetFontFamilyToArial();
1894 else if ( f.family() == "Courier" )
1895 aScalarBarTitleProp->SetFontFamilyToCourier();
1896 else if ( f.family() == "Times" )
1897 aScalarBarTitleProp->SetFontFamilyToTimes();
1900 aScalarBarTitleProp->BoldOn();
1902 aScalarBarTitleProp->BoldOff();
1905 aScalarBarTitleProp->ItalicOn();
1907 aScalarBarTitleProp->ItalicOff();
1910 aScalarBarTitleProp->ShadowOn();
1912 aScalarBarTitleProp->ShadowOff();
1915 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1916 aScalarBarTitleProp->Delete();
1918 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1920 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1921 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1923 aScalarBarLabelProp->SetFontFamilyToArial();
1924 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1926 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1927 if( f.family() == "Arial" )
1928 aScalarBarLabelProp->SetFontFamilyToArial();
1929 else if( f.family() == "Courier" )
1930 aScalarBarLabelProp->SetFontFamilyToCourier();
1931 else if( f.family() == "Times" )
1932 aScalarBarLabelProp->SetFontFamilyToTimes();
1935 aScalarBarLabelProp->BoldOn();
1937 aScalarBarLabelProp->BoldOff();
1940 aScalarBarLabelProp->ItalicOn();
1942 aScalarBarLabelProp->ItalicOff();
1945 aScalarBarLabelProp->ShadowOn();
1947 aScalarBarLabelProp->ShadowOff();
1950 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1951 aScalarBarLabelProp->Delete();
1953 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1954 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1956 myScalarBarActor->SetOrientationToHorizontal();
1958 myScalarBarActor->SetOrientationToVertical();
1961 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1962 if( mgr->hasValue( "SMESH", name + "x" ) )
1963 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1965 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1966 if( mgr->hasValue( "SMESH", name + "y" ) )
1967 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1968 myScalarBarActor->SetPosition( aXVal, aYVal );
1970 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1971 if( mgr->hasValue( "SMESH", name + "width" ) )
1972 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1973 myScalarBarActor->SetWidth( aWVal );
1975 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1976 if( mgr->hasValue( "SMESH", name + "height" ) )
1977 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1978 myScalarBarActor->SetHeight( aHVal );
1981 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1982 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1983 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1986 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1987 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1988 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
1990 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
1991 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
1993 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
1994 myScalarBarActor->SetDistributionColoringType(coloringType);
1996 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
1997 QColor(255, 255, 255));
1999 rgb[0]= distributionColor.red()/255.;
2000 rgb[1]= distributionColor.green()/255.;
2001 rgb[2]= distributionColor.blue()/255.;
2002 myScalarBarActor->SetDistributionColor(rgb);
2007 void SMESH_ActorDef::UpdateDistribution()
2009 if(SMESH::Controls::NumericalFunctor* fun =
2010 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2012 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2013 std::vector<int> nbEvents;
2014 std::vector<double> funValues;
2015 SMESH_VisualObjDef::TEntityList elems;
2016 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2017 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2018 std::vector<int> elemIds;
2019 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2020 elemIds.push_back( (*e)->GetID());
2021 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2022 double * range = lookupTable->GetRange();
2023 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2024 myScalarBarActor->SetDistribution(nbEvents);
2028 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2031 case SMESH_Actor::eLines :
2032 myHighlitableActor->SetQuadraticArcMode(false);
2033 my2DActor->SetQuadraticArcMode(false);
2034 my1DActor->SetQuadraticArcMode(false);
2036 case SMESH_Actor::eArcs :
2037 myHighlitableActor->SetQuadraticArcMode(true);
2038 if(GetRepresentation() != SMESH_Actor::ePoint) {
2039 my2DActor->SetQuadraticArcMode(true);
2040 my1DActor->SetQuadraticArcMode(true);
2049 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2051 if(myHighlitableActor->GetQuadraticArcMode())
2052 return SMESH_Actor::eArcs;
2054 return SMESH_Actor::eLines;
2057 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2059 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2060 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2061 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2064 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2066 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2067 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2068 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2069 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2072 #ifndef DISABLE_PLOT2DVIEWER
2073 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2076 my2dHistogram->clearAllPoints();
2078 if(SMESH::Controls::NumericalFunctor* fun =
2079 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2082 if(!my2dHistogram) {
2083 my2dHistogram = new SPlot2d_Histogram();
2084 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2085 my2dHistogram->setIO(anIO);
2088 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2089 std::vector<int> nbEvents;
2090 std::vector<double> funValues;
2091 SMESH_VisualObjDef::TEntityList elems;
2092 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2093 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2094 std::vector<int> elemIds;
2096 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2097 elemIds.push_back( (*e)->GetID());
2099 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2100 double * range = lookupTable->GetRange();
2101 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2103 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2104 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2106 if(funValues.size() >= 2)
2107 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2111 //Color of the histogram
2112 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2113 my2dHistogram->setAutoAssign(true);
2116 myScalarBarActor->GetDistributionColor(rgb);
2117 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2118 my2dHistogram->setColor(aColor);
2122 return my2dHistogram;