1 // Copyright (C) 2007-2012 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"
40 #include "SMESH_SVTKActor.h"
42 #include "SUIT_Session.h"
43 #include "SUIT_ResourceMgr.h"
47 #ifndef DISABLE_PLOT2DVIEWER
48 #include <SPlot2d_Histogram.h>
51 #include <vtkProperty.h>
52 #include <vtkTimeStamp.h>
53 #include <vtkObjectFactory.h>
54 #include <vtkShrinkPolyData.h>
55 #include <vtkMergeFilter.h>
57 #include <vtkMatrix4x4.h>
58 #include <vtkUnstructuredGrid.h>
59 #include <vtkPointData.h>
60 #include <vtkCellData.h>
62 #include <vtkMapper.h>
63 #include <vtkRenderer.h>
66 #include <vtkIdList.h>
67 #include <vtkIntArray.h>
69 #include <vtkActor2D.h>
70 #include <vtkProperty2D.h>
71 #include <vtkPolyData.h>
72 #include <vtkTextProperty.h>
74 #include <vtkLookupTable.h>
78 #include <vtkImplicitBoolean.h>
79 #include <vtkImplicitFunctionCollection.h>
81 #include <vtkConfigure.h>
82 #if !defined(VTK_XVERSION)
83 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
86 #include "utilities.h"
89 static int MYDEBUG = 1;
91 static int MYDEBUG = 1;
94 static int aLineWidthInc = 2;
97 SMESH_ActorDef* SMESH_ActorDef::New(){
98 return new SMESH_ActorDef();
102 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
103 const char* theEntry,
107 SMESH_ActorDef* anActor = NULL;
108 if(theVisualObj->IsValid() ) {
109 anActor = SMESH_ActorDef::New();
110 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
115 anActor->UpdateScalarBar();
121 SMESH_ActorDef::SMESH_ActorDef()
123 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
124 myBaseActor = SMESH_DeviceActor::New();
126 myTimeStamp = vtkTimeStamp::New();
128 myIsPointsVisible = false;
129 myIsEntityModeCache = false;
131 myHighlightActor = SMESH_SVTKActor::New();
132 myHighlightActor->Initialize();
134 myPreHighlightActor = SMESH_SVTKActor::New();
135 myPreHighlightActor->Initialize();
137 myIsShrinkable = false;
140 myIsFacesOriented = false;
142 myControlsPrecision = -1;
143 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
145 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
146 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
148 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
149 vtkFloatingPointType aBallElemSize = SMESH::GetFloat("SMESH:ball_elem_size",10);
150 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
151 vtkFloatingPointType aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
153 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
154 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
156 //Definition 2D and 3D devices of the actor
157 //-----------------------------------------
158 vtkFloatingPointType anRGB[3] = {1,1,1};
159 mySurfaceProp = vtkProperty::New();
162 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
163 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
164 myDeltaBrightness = delta;
166 myBackSurfaceProp = vtkProperty::New();
167 bfc = Qtx::mainColorToSecondary(ffc, delta);
168 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
170 myNormalVProp = vtkProperty::New();
171 SMESH::GetColor( "SMESH", "volume_color", ffc, delta, "255,0,170|-100" );
172 myNormalVProp->SetColor( ffc.redF(), ffc.greenF(), ffc.blueF() );
173 myDeltaVBrightness = delta;
175 myReversedVProp = vtkProperty::New();
176 bfc = Qtx::mainColorToSecondary(ffc, delta);
177 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
179 my2DActor = SMESH_CellLabelActor::New();
180 my2DActor->SetStoreGemetryMapping(true);
181 my2DActor->SetUserMatrix(aMatrix);
182 my2DActor->PickableOff();
183 my2DActor->SetProperty(mySurfaceProp);
184 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
185 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
186 aFilter = my2DActor->GetExtractUnstructuredGrid();
187 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
188 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
189 aFilter->RegisterCellsWithType(VTK_POLYGON);
190 aFilter->RegisterCellsWithType(VTK_QUAD);
191 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
192 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
193 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
195 my2DExtProp = vtkProperty::New();
196 my2DExtProp->DeepCopy(mySurfaceProp);
197 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
198 anRGB[0] = 1 - anRGB[0];
199 anRGB[1] = 1 - anRGB[1];
200 anRGB[2] = 1 - anRGB[2];
201 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
203 my2DExtActor = SMESH_DeviceActor::New();
204 my2DExtActor->SetUserMatrix(aMatrix);
205 my2DExtActor->PickableOff();
206 my2DExtActor->SetProperty(my2DExtProp);
207 my2DExtActor->SetBackfaceProperty(my2DExtProp);
208 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
209 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
210 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
211 aFilter->RegisterCellsWithType(VTK_POLYGON);
212 aFilter->RegisterCellsWithType(VTK_QUAD);
213 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
214 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
215 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
217 my3DActor = SMESH_CellLabelActor::New();
218 my3DActor->SetStoreGemetryMapping(true);
219 my3DActor->SetUserMatrix(aMatrix);
220 my3DActor->PickableOff();
221 my3DActor->SetProperty(myNormalVProp);
222 my3DActor->SetBackfaceProperty(myReversedVProp);
223 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
224 my3DActor->SetCoincident3DAllowed(true);
225 aFilter = my3DActor->GetExtractUnstructuredGrid();
226 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
227 aFilter->RegisterCellsWithType(VTK_TETRA);
228 aFilter->RegisterCellsWithType(VTK_VOXEL);
229 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
230 aFilter->RegisterCellsWithType(VTK_WEDGE);
231 aFilter->RegisterCellsWithType(VTK_PYRAMID);
232 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
233 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
234 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
235 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
236 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
237 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
238 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
239 //#ifdef VTK_HAVE_POLYHEDRON
240 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
241 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
244 my3DExtProp = vtkProperty::New();
245 my3DExtProp->DeepCopy(myNormalVProp);
246 SMESH::GetColor( "SMESH", "volume_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 170 ) );
247 anRGB[0] = 1 - anRGB[0];
248 anRGB[1] = 1 - anRGB[1];
249 anRGB[2] = 1 - anRGB[2];
250 my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
252 my3DExtActor = SMESH_DeviceActor::New();
253 my3DExtActor->SetUserMatrix(aMatrix);
254 my3DExtActor->PickableOff();
255 my3DExtActor->SetProperty(my3DExtProp);
256 my3DExtActor->SetBackfaceProperty(my3DExtProp);
257 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
258 my3DExtActor->SetCoincident3DAllowed(true);
259 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
260 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
261 aFilter->RegisterCellsWithType(VTK_TETRA);
262 aFilter->RegisterCellsWithType(VTK_VOXEL);
263 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
264 aFilter->RegisterCellsWithType(VTK_WEDGE);
265 aFilter->RegisterCellsWithType(VTK_PYRAMID);
266 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
267 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
268 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
269 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
270 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
271 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
272 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
273 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
275 //Definition 1D device of the actor
276 //---------------------------------
277 myEdgeProp = vtkProperty::New();
278 myEdgeProp->SetAmbient(1.0);
279 myEdgeProp->SetDiffuse(0.0);
280 myEdgeProp->SetSpecular(0.0);
281 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
282 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
283 myEdgeProp->SetLineWidth(aLineWidth);
285 my1DActor = SMESH_CellLabelActor::New();
286 my1DActor->SetStoreGemetryMapping(true);
287 my1DActor->SetUserMatrix(aMatrix);
288 my1DActor->PickableOff();
289 my1DActor->SetHighlited(true);
290 my1DActor->SetProperty(myEdgeProp);
291 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
292 aFilter = my1DActor->GetExtractUnstructuredGrid();
293 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
294 aFilter->RegisterCellsWithType(VTK_LINE);
295 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
297 my1DProp = vtkProperty::New();
298 my1DProp->DeepCopy(myEdgeProp);
299 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
300 my1DProp->SetPointSize(aElem0DSize);
302 my1DExtProp = vtkProperty::New();
303 my1DExtProp->DeepCopy(myEdgeProp);
304 anRGB[0] = 1 - anRGB[0];
305 anRGB[1] = 1 - anRGB[1];
306 anRGB[2] = 1 - anRGB[2];
307 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
308 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
309 my1DExtProp->SetPointSize(aElem0DSize);
311 my1DExtActor = SMESH_DeviceActor::New();
312 my1DExtActor->SetUserMatrix(aMatrix);
313 my1DExtActor->PickableOff();
314 my1DExtActor->SetHighlited(true);
315 my1DExtActor->SetVisibility(false);
316 my1DExtActor->SetProperty(my1DExtProp);
317 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
318 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
319 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
320 aFilter->RegisterCellsWithType(VTK_LINE);
321 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
324 //Definition 0D device of the actor (0d elements)
325 //-----------------------------------------------
326 my0DProp = vtkProperty::New();
327 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
328 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
329 my0DProp->SetPointSize(aElem0DSize);
331 my0DActor = SMESH_CellLabelActor::New();
332 my0DActor->SetUserMatrix(aMatrix);
333 my0DActor->SetStoreGemetryMapping(true);
334 my0DActor->PickableOff();
335 my0DActor->SetVisibility(false);
336 my0DActor->SetProperty(my0DProp);
337 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
338 aFilter = my0DActor->GetExtractUnstructuredGrid();
339 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
340 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
341 aFilter->RegisterCellsWithType(VTK_VERTEX);
343 //Definition 0D device of the actor (ball elements)
344 //-----------------------------------------------
345 myBallProp = vtkProperty::New();
346 SMESH::GetColor( "SMESH", "ball_elem_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 85, 255 ) );
347 myBallProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
348 myBallProp->SetPointSize(aBallElemSize);
350 myBallActor = SMESH_CellLabelActor::New();
351 myBallActor->SetUserMatrix(aMatrix);
352 myBallActor->SetStoreGemetryMapping(true);
353 myBallActor->PickableOff();
354 myBallActor->SetVisibility(false);
355 myBallActor->SetProperty(myBallProp);
356 myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
357 aFilter = myBallActor->GetExtractUnstructuredGrid();
358 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
359 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
361 //my0DExtProp = vtkProperty::New();
362 //my0DExtProp->DeepCopy(my0DProp);
363 //anRGB[0] = 1 - anRGB[0];
364 //anRGB[1] = 1 - anRGB[1];
365 //anRGB[2] = 1 - anRGB[2];
366 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
367 //my0DExtProp->SetPointSize(aElem0DSize);
369 //my0DExtActor = SMESH_DeviceActor::New();
370 //my0DExtActor->SetUserMatrix(aMatrix);
371 //my0DExtActor->SetStoreClippingMapping(true);
372 //my0DExtActor->PickableOff();
373 //my0DExtActor->SetHighlited(true);
374 //my0DExtActor->SetVisibility(false);
375 //my0DExtActor->SetProperty(my0DExtProp);
376 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
377 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
378 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
379 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
380 //aFilter->RegisterCellsWithType(VTK_VERTEX);
383 //Definition 0D device of the actor (nodes)
384 //-----------------------------------------
385 myNodeProp = vtkProperty::New();
386 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
387 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
389 myNodeActor = SMESH_NodeLabelActor::New();
390 myNodeActor->SetUserMatrix(aMatrix);
391 myNodeActor->SetStoreClippingMapping(true);
392 myNodeActor->PickableOff();
393 myNodeActor->SetVisibility(false);
394 myNodeActor->SetProperty(myNodeProp);
395 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
396 aFilter = myNodeActor->GetExtractUnstructuredGrid();
397 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
399 myNodeExtProp = vtkProperty::New();
400 myNodeExtProp->DeepCopy(myNodeProp);
401 anRGB[0] = 1 - anRGB[0];
402 anRGB[1] = 1 - anRGB[1];
403 anRGB[2] = 1 - anRGB[2];
404 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
406 myNodeExtActor = SMESH_DeviceActor::New();
407 myNodeExtActor->SetUserMatrix(aMatrix);
408 myNodeExtActor->SetStoreClippingMapping(true);
409 myNodeExtActor->PickableOff();
410 myNodeExtActor->SetHighlited(true);
411 myNodeExtActor->SetVisibility(false);
412 myNodeExtActor->SetProperty(myNodeExtProp);
413 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
414 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
415 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
416 aFilter->RegisterCellsWithType(VTK_VERTEX);
418 //Definition of Pickable and Highlitable engines
419 //----------------------------------------------
421 myBaseActor->SetUserMatrix(aMatrix);
422 myBaseActor->SetStoreGemetryMapping(true);
423 myBaseActor->GetProperty()->SetOpacity(0.0);
424 myPickableActor = myBaseActor;
426 myHighlightProp = vtkProperty::New();
427 myHighlightProp->SetAmbient(1.0);
428 myHighlightProp->SetDiffuse(0.0);
429 myHighlightProp->SetSpecular(0.0);
430 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
431 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
432 myHighlightProp->SetPointSize(aElem0DSize); // ??
433 myHighlightProp->SetLineWidth(aLineWidth);
434 myHighlightProp->SetRepresentation(1);
436 myBallHighlightProp = vtkProperty::New();
437 myBallHighlightProp->DeepCopy(myHighlightProp);
438 myBallHighlightProp->SetPointSize(aBallElemSize);
441 myOutLineProp = vtkProperty::New();
442 myOutLineProp->SetAmbient(1.0);
443 myOutLineProp->SetDiffuse(0.0);
444 myOutLineProp->SetSpecular(0.0);
445 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
446 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
447 myOutLineProp->SetLineWidth(aOutlineWidth);
448 myOutLineProp->SetRepresentation(1);
450 myPreselectProp = vtkProperty::New();
451 myPreselectProp->SetAmbient(1.0);
452 myPreselectProp->SetDiffuse(0.0);
453 myPreselectProp->SetSpecular(0.0);
454 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
455 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
456 myPreselectProp->SetPointSize(aElem0DSize); // ??
457 myPreselectProp->SetLineWidth(aLineWidth);
458 myPreselectProp->SetRepresentation(1);
460 myBallPreselectProp = vtkProperty::New();
461 myBallPreselectProp->DeepCopy(myPreselectProp);
462 myBallPreselectProp->SetPointSize(aBallElemSize);
464 myHighlitableActor = SMESH_DeviceActor::New();
465 myHighlitableActor->SetUserMatrix(aMatrix);
466 myHighlitableActor->PickableOff();
467 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
468 myHighlitableActor->SetCoincident3DAllowed(true);
475 myControlMode = eNone;
476 myControlActor = my2DActor;
478 //Definition of myScalarBarActor
479 //------------------------------
480 myLookupTable = vtkLookupTable::New();
481 //Fix for Bug PAL5195 - SMESH764:
482 //Controls - Aspect Ratio: incorrect colors of the best and worst values
483 myLookupTable->SetHueRange(0.667,0.0);
485 myScalarBarActor = SMESH_ScalarBarActor::New();
486 myScalarBarActor->SetVisibility(false);
487 myScalarBarActor->SetLookupTable(myLookupTable);
490 //Incorrect "Min value" in Scalar Bar in Mesh:
491 // myScalarBarActor->SetLabelFormat("%.4g");
492 // changes was commented because of regression bug IPAL 19981
494 mgr = SUIT_Session::session()->resourceMgr();
498 myEntityMode = eAllEntity;
499 myEntityModeCache = eAllEntity;
502 myImplicitBoolean = vtkImplicitBoolean::New();
503 myImplicitBoolean->SetOperationTypeToIntersection();
505 //Quadratic 2D elements representation
506 //-----------------------------------------------------------------------------
507 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
508 if(aQuadratic2DMode == 0){
509 myHighlitableActor->SetQuadraticArcMode(false);
510 my2DActor->SetQuadraticArcMode(false);
511 my1DActor->SetQuadraticArcMode(false);
513 else if(aQuadratic2DMode == 1){
514 myHighlitableActor->SetQuadraticArcMode(true);
515 my2DActor->SetQuadraticArcMode(true);
516 my1DActor->SetQuadraticArcMode(true);
519 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
520 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
521 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
523 // Set colors of the name actor
524 SMESH::GetColor( "SMESH", "default_grp_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
525 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
526 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
527 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
529 #ifndef DISABLE_PLOT2DVIEWER
533 SetBallSize(aBallElemSize);
534 Set0DSize(aElem0DSize);
538 SMESH_ActorDef::~SMESH_ActorDef()
540 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
542 #ifndef DISABLE_PLOT2DVIEWER
544 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
545 delete my2dHistogram;
549 myScalarBarActor->Delete();
550 myLookupTable->Delete();
552 mySurfaceProp->Delete();
553 myBackSurfaceProp->Delete();
554 myNormalVProp->Delete();
555 myReversedVProp->Delete();
556 myOutLineProp->Delete();
558 myEdgeProp->Delete();
559 myHighlightProp->Delete();
560 myPreselectProp->Delete();
562 myNodeProp->Delete();
563 myNodeExtProp->Delete();
567 myBallActor->Delete();
569 //my0DExtProp->Delete();
570 //my0DExtActor->Delete();
575 my1DExtProp->Delete();
576 my1DExtActor->Delete();
579 my2DExtProp->Delete();
580 my2DExtActor->Delete();
582 my3DExtProp->Delete();
583 my3DExtActor->Delete();
585 myNodeActor->Delete();
586 myBaseActor->Delete();
588 myNodeExtActor->Delete();
589 myHighlitableActor->Delete();
591 myImplicitBoolean->Delete();
593 myTimeStamp->Delete();
594 myBallHighlightProp->Delete();
595 myBallPreselectProp->Delete();
599 void SMESH_ActorDef::Delete()
601 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
602 // from the actor's destructor) will be thrown before removing the actor's observers,
603 // that is done inside the Superclass::Delete() method but before the destructor itself
604 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
605 // The event is caught by SMESHGUI::ProcessEvents() static method.
606 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
608 Superclass::Delete();
611 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
614 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
615 SetRepresentation(GetRepresentation());
616 myTimeStamp->Modified();
620 bool SMESH_ActorDef::GetPointsLabeled() {
621 return myNodeActor && myNodeActor->GetPointsLabeled();
624 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
627 my3DActor->SetCellsLabeled(theIsCellsLabeled);
630 my2DActor->SetCellsLabeled(theIsCellsLabeled);
633 my1DActor->SetCellsLabeled(theIsCellsLabeled);
636 my0DActor->SetCellsLabeled(theIsCellsLabeled);
639 myBallActor->SetCellsLabeled(theIsCellsLabeled);
641 myTimeStamp->Modified();
645 bool SMESH_ActorDef::GetCellsLabeled() {
648 result = result || my3DActor->GetCellsLabeled();
651 result = result || my2DActor->GetCellsLabeled();
654 result = result || my1DActor->GetCellsLabeled();
657 result = result || my0DActor->GetCellsLabeled();
660 result = result || myBallActor->GetCellsLabeled();
666 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
668 myIsFacesOriented = theIsFacesOriented;
670 my2DActor->SetFacesOriented(theIsFacesOriented);
671 my3DActor->SetFacesOriented(theIsFacesOriented);
673 myTimeStamp->Modified();
676 bool SMESH_ActorDef::GetFacesOriented()
678 return myIsFacesOriented;
681 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
683 my2DActor->SetFacesOrientationColor( r, g, b );
684 my3DActor->SetFacesOrientationColor( r, g, b );
687 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
689 my3DActor->GetFacesOrientationColor( r, g, b );
692 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
694 my2DActor->SetFacesOrientationScale( theScale );
695 my3DActor->SetFacesOrientationScale( theScale );
698 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
700 return my3DActor->GetFacesOrientationScale();
703 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
705 my2DActor->SetFacesOrientation3DVectors( theState );
706 my3DActor->SetFacesOrientation3DVectors( theState );
709 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
711 return my3DActor->GetFacesOrientation3DVectors();
717 SetControlMode(eControl theMode)
719 SetControlMode(theMode,true);
725 SetControlMode(eControl theMode,
726 bool theCheckEntityMode)
728 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
732 myControlMode = eNone;
733 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
735 my0DActor->GetMapper()->SetScalarVisibility(false);
736 my1DActor->GetMapper()->SetScalarVisibility(false);
737 my2DActor->GetMapper()->SetScalarVisibility(false);
738 my3DActor->GetMapper()->SetScalarVisibility(false);
739 myBallActor->GetMapper()->SetScalarVisibility(false);
740 myScalarBarActor->SetVisibility(false);
742 bool anIsScalarVisible = theMode > eNone;
744 if(anIsScalarVisible) {
748 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
749 aControl->SetPrecision( myControlsPrecision );
750 myFunctor.reset( aControl );
751 myControlActor = my1DActor;
756 myFunctor.reset(new SMESH::Controls::Length2D());
757 myControlActor = my2DActor;
761 myFunctor.reset(new SMESH::Controls::FreeBorders());
762 myControlActor = my1DActor;
765 myFunctor.reset(new SMESH::Controls::FreeEdges());
766 myControlActor = my2DActor;
769 myFunctor.reset(new SMESH::Controls::FreeNodes());
770 myControlActor = myNodeActor;
773 myFunctor.reset(new SMESH::Controls::FreeFaces());
774 myControlActor = my2DActor;
776 case eCoincidentNodes:
778 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
779 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
780 cn->SetTolerance( tol );
782 myControlActor = myNodeActor;
785 case eCoincidentElems1D:
786 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
787 myControlActor = my1DActor;
789 case eCoincidentElems2D:
790 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
791 myControlActor = my2DActor;
793 case eCoincidentElems3D:
794 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
795 myControlActor = my3DActor;
797 case eBareBorderFace:
798 myFunctor.reset(new SMESH::Controls::BareBorderFace());
799 myControlActor = my2DActor;
801 case eOverConstrainedFace:
802 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
803 myControlActor = my2DActor;
805 case eMultiConnection:
806 myFunctor.reset(new SMESH::Controls::MultiConnection());
807 myControlActor = my1DActor;
809 case eMultiConnection2D:
810 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
811 myControlActor = my2DActor;
815 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
816 aControl->SetPrecision( myControlsPrecision );
817 myFunctor.reset( aControl );
818 myControlActor = my2DActor;
823 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
824 aControl->SetPrecision( myControlsPrecision );
825 myFunctor.reset( aControl );
826 myControlActor = my2DActor;
831 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
832 aControl->SetPrecision( myControlsPrecision );
833 myFunctor.reset( aControl );
834 myControlActor = my2DActor;
839 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
840 aControl->SetPrecision( myControlsPrecision );
841 myFunctor.reset( aControl );
842 myControlActor = my3DActor;
847 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
848 aControl->SetPrecision( myControlsPrecision );
849 myFunctor.reset( aControl );
850 myControlActor = my3DActor;
853 case eMaxElementLength2D:
855 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
856 aControl->SetPrecision( myControlsPrecision );
857 myFunctor.reset( aControl );
858 myControlActor = my2DActor;
861 case eMaxElementLength3D:
863 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
864 aControl->SetPrecision( myControlsPrecision );
865 myFunctor.reset( aControl );
866 myControlActor = my3DActor;
869 case eBareBorderVolume:
871 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
872 myControlActor = my3DActor;
875 case eOverConstrainedVolume:
877 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
878 myControlActor = my3DActor;
883 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
884 aControl->SetPrecision( myControlsPrecision );
885 myFunctor.reset( aControl );
886 myControlActor = my2DActor;
891 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
892 aControl->SetPrecision( myControlsPrecision );
893 myFunctor.reset( aControl );
894 myControlActor = my2DActor;
899 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
900 aControl->SetPrecision( myControlsPrecision );
901 myFunctor.reset( aControl );
902 myControlActor = my2DActor;
909 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
910 vtkIdType aNbCells = aGrid->GetNumberOfCells();
912 myControlMode = theMode;
913 switch(myControlMode){
915 case eCoincidentNodes:
916 myNodeExtActor->SetExtControlMode(myFunctor);
920 case eCoincidentElems1D:
921 my1DExtActor->SetExtControlMode(myFunctor);
924 case eBareBorderFace:
925 case eOverConstrainedFace:
926 case eCoincidentElems2D:
927 my2DExtActor->SetExtControlMode(myFunctor);
929 case eBareBorderVolume:
930 case eOverConstrainedVolume:
931 case eCoincidentElems3D:
932 my3DExtActor->SetExtControlMode(myFunctor);
935 case eMultiConnection2D:
936 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
937 UpdateDistribution();
940 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
941 UpdateDistribution();
945 if(theCheckEntityMode) {
946 if(myControlActor == my1DActor) {
947 if (!myIsEntityModeCache){
948 myEntityModeCache = GetEntityMode();
949 myIsEntityModeCache=true;
951 SetEntityMode(eEdges);
953 else if(myControlActor == my2DActor) {
954 switch(myControlMode) {
958 case eMultiConnection2D:
959 if (!myIsEntityModeCache){
960 myEntityModeCache = GetEntityMode();
961 myIsEntityModeCache=true;
963 SetEntityMode(eFaces);
966 if (!myIsEntityModeCache){
967 myEntityModeCache = GetEntityMode();
968 myIsEntityModeCache=true;
970 SetEntityMode(eFaces);
972 }else if(myControlActor == my3DActor) {
973 if (!myIsEntityModeCache){
974 myEntityModeCache = GetEntityMode();
975 myIsEntityModeCache=true;
977 SetEntityMode(eVolumes);
983 if(theCheckEntityMode){
984 myEntityMode = myEntityModeCache;
985 myIsEntityModeCache = false;
990 SetRepresentation(GetRepresentation());
992 myTimeStamp->Modified();
998 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
1000 //myHighlightActor->AddToRender(theRenderer);
1002 theRenderer->AddActor(myBaseActor);
1003 theRenderer->AddActor(myNodeExtActor);
1004 theRenderer->AddActor(my1DExtActor);
1006 my3DActor ->AddToRender(theRenderer);
1007 my3DExtActor->AddToRender(theRenderer);
1008 my2DActor ->AddToRender(theRenderer);
1009 my2DExtActor->AddToRender(theRenderer);
1010 myNodeActor ->AddToRender(theRenderer);
1011 my1DActor ->AddToRender(theRenderer);
1012 my0DActor ->AddToRender(theRenderer);
1013 myBallActor ->AddToRender(theRenderer);
1014 //theRenderer->AddActor(my0DExtActor);
1016 theRenderer->AddActor(myHighlitableActor);
1018 theRenderer->AddActor2D(myScalarBarActor);
1020 // the superclass' method should be called at the end
1021 // (in particular, for correct work of selection)
1022 SALOME_Actor::AddToRender(theRenderer);
1025 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
1026 SALOME_Actor::RemoveFromRender(theRenderer);
1028 theRenderer->RemoveActor(myBaseActor);
1030 theRenderer->RemoveActor(myNodeExtActor);
1032 theRenderer->RemoveActor(myHighlitableActor);
1034 //theRenderer->RemoveActor(my0DExtActor);
1036 theRenderer->RemoveActor(my1DExtActor);
1038 my2DActor->RemoveFromRender(theRenderer);
1039 my2DExtActor->RemoveFromRender(theRenderer);
1040 my3DActor->RemoveFromRender(theRenderer);
1041 my3DExtActor->RemoveFromRender(theRenderer);
1042 myNodeActor->RemoveFromRender(theRenderer);
1043 my0DActor->RemoveFromRender(theRenderer);
1044 myBallActor->RemoveFromRender(theRenderer);
1045 my1DActor->RemoveFromRender(theRenderer);
1047 theRenderer->RemoveActor(myScalarBarActor);
1051 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
1052 const char* theEntry,
1053 const char* theName,
1056 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
1060 myVisualObj = theVisualObj;
1061 myVisualObj->Update(theIsClear);
1063 myNodeActor->Init(myVisualObj,myImplicitBoolean);
1064 myBaseActor->Init(myVisualObj,myImplicitBoolean);
1066 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
1068 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
1070 my0DActor->Init(myVisualObj,myImplicitBoolean);
1071 myBallActor->Init(myVisualObj,myImplicitBoolean);
1072 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1074 my1DActor->Init(myVisualObj,myImplicitBoolean);
1075 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1077 my2DActor->Init(myVisualObj,myImplicitBoolean);
1078 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1079 my3DActor->Init(myVisualObj,myImplicitBoolean);
1080 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1082 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1083 myBallActor->GetMapper()->SetLookupTable(myLookupTable);
1084 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1086 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1087 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1089 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1090 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1091 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1092 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1094 vtkFloatingPointType aFactor, aUnits;
1095 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1096 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1097 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1098 my3DActor->SetPolygonOffsetParameters(2*aFactor,aUnits);
1100 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1104 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1105 SetIsShrunkable(true);
1107 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1109 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1110 SetRepresentation(-1);
1113 SetRepresentation(eEdge);
1114 }else if(aMode == 1){
1115 SetRepresentation(eSurface);
1116 }else if(aMode == 2){
1117 SetRepresentation(ePoint);
1124 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1125 SetIsDisplayNameActor( true );
1127 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1128 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1129 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1131 myTimeStamp->Modified();
1137 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1138 return myNodeActor->GetBounds();
1142 vtkDataSet* SMESH_ActorDef::GetInput(){
1143 return GetUnstructuredGrid();
1147 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1148 Superclass::SetTransform(theTransform);
1150 myNodeActor->SetTransform(theTransform);
1151 myBaseActor->SetTransform(theTransform);
1153 myHighlitableActor->SetTransform(theTransform);
1155 myNodeExtActor->SetTransform(theTransform);
1157 my0DActor->SetTransform(theTransform);
1158 myBallActor->SetTransform(theTransform);
1159 //my0DExtActor->SetTransform(theTransform);
1161 my1DActor->SetTransform(theTransform);
1162 my1DExtActor->SetTransform(theTransform);
1164 my2DActor->SetTransform(theTransform);
1165 my2DExtActor->SetTransform(theTransform);
1166 my3DActor->SetTransform(theTransform);
1167 my3DExtActor->SetTransform(theTransform);
1173 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1174 vtkLODActor::SetMapper(theMapper);
1178 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1179 SALOME_Actor::ShallowCopy(prop);
1183 vtkMapper* SMESH_ActorDef::GetMapper(){
1184 return myPickableActor->GetMapper();
1188 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1189 return myVisualObj->GetUnstructuredGrid();
1193 bool SMESH_ActorDef::IsInfinitive(){
1194 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1196 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1197 ( aDataSet->GetNumberOfCells() == 1 &&
1198 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1199 return SALOME_Actor::IsInfinitive();
1203 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1204 if ( myIsShrinkable == theShrunkable )
1206 myIsShrinkable = theShrunkable;
1210 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1211 return myBaseActor->GetShrinkFactor();
1214 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1215 myBaseActor->SetShrinkFactor(theValue);
1217 my1DActor->SetShrinkFactor(theValue);
1218 my1DExtActor->SetShrinkFactor(theValue);
1220 my2DActor->SetShrinkFactor(theValue);
1221 my2DExtActor->SetShrinkFactor(theValue);
1222 my3DActor->SetShrinkFactor(theValue);
1223 my3DExtActor->SetShrinkFactor(theValue);
1224 my3DExtActor->SetShrinkFactor(theValue);
1225 myHighlitableActor->SetShrinkFactor(theValue);
1230 void SMESH_ActorDef::SetShrink(){
1231 if(!myIsShrinkable) return;
1233 myBaseActor->SetShrink();
1235 my1DActor->SetShrink();
1236 my1DExtActor->SetShrink();
1238 my2DActor->SetShrink();
1239 my2DExtActor->SetShrink();
1240 my3DActor->SetShrink();
1241 my3DExtActor->SetShrink();
1242 myHighlitableActor->SetShrink();
1248 void SMESH_ActorDef::UnShrink(){
1249 if(!myIsShrunk) return;
1251 myBaseActor->UnShrink();
1253 my1DActor->UnShrink();
1254 my1DExtActor->UnShrink();
1256 my2DActor->UnShrink();
1257 my2DExtActor->UnShrink();
1258 my3DActor->UnShrink();
1259 my3DExtActor->UnShrink();
1260 myHighlitableActor->UnShrink();
1267 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1268 return myPickableActor->GetNodeObjId(theVtkID);
1271 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1272 return myPickableActor->GetNodeCoord(theObjID);
1276 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1277 return myPickableActor->GetElemObjId(theVtkID);
1280 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1281 return myPickableActor->GetElemCell(theObjID);
1285 void SMESH_ActorDef::SetVisibility(int theMode){
1286 SetVisibility(theMode,true);
1290 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1291 SALOME_Actor::SetVisibility(theMode);
1293 myNodeActor->VisibilityOff();
1294 myBaseActor->VisibilityOff();
1296 myNodeExtActor->VisibilityOff();
1298 my0DActor->VisibilityOff();
1299 myBallActor->VisibilityOff();
1300 //my0DExtActor->VisibilityOff();
1302 my1DActor->VisibilityOff();
1303 my1DExtActor->VisibilityOff();
1305 my2DActor->VisibilityOff();
1306 my2DExtActor->VisibilityOff();
1307 my3DActor->VisibilityOff();
1308 my3DExtActor->VisibilityOff();
1310 myScalarBarActor->VisibilityOff();
1312 if(GetVisibility()){
1313 if(theIsUpdateRepersentation)
1314 SetRepresentation(GetRepresentation());
1316 if(myControlMode != eNone){
1317 switch(myControlMode){
1319 case eCoincidentNodes:
1320 myNodeExtActor->VisibilityOn();
1324 case eCoincidentElems1D:
1325 my1DExtActor->VisibilityOn();
1328 case eBareBorderFace:
1329 case eOverConstrainedFace:
1330 case eCoincidentElems2D:
1331 my2DExtActor->VisibilityOn();
1333 case eBareBorderVolume:
1334 case eOverConstrainedVolume:
1335 case eCoincidentElems3D:
1336 my3DExtActor->VisibilityOn();
1339 case eMultiConnection2D:
1340 my1DExtActor->VisibilityOn();
1342 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1343 myScalarBarActor->VisibilityOn();
1347 if(myRepresentation != ePoint)
1348 myPickableActor->VisibilityOn();
1350 myNodeActor->VisibilityOn();
1353 if(myEntityMode & e0DElements && GetRepresentation() != ePoint ){
1354 my0DActor->VisibilityOn();
1356 if(myEntityMode & eBallElem && GetRepresentation() != ePoint ){
1357 myBallActor->VisibilityOn();
1360 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1361 my1DActor->VisibilityOn();
1364 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1365 my2DActor->VisibilityOn();
1368 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1369 my3DActor->VisibilityOn();
1372 if(myNodeActor->GetPointsLabeled()){
1373 myNodeActor->VisibilityOn();
1377 my0DActor->UpdateLabels();
1380 myBallActor->UpdateLabels();
1383 my1DActor->UpdateLabels();
1386 my2DActor->UpdateLabels();
1389 my3DActor->UpdateLabels();
1391 #ifndef DISABLE_PLOT2DVIEWER
1393 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1400 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1402 myEntityState = eAllEntity;
1404 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1405 myEntityState &= ~e0DElements;
1406 theMode &= ~e0DElements;
1409 if(!myVisualObj->GetNbEntities(SMDSAbs_Ball)) {
1410 myEntityState &= ~eBallElem;
1411 theMode &= ~eBallElem;
1414 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1415 myEntityState &= ~eEdges;
1419 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1420 myEntityState &= ~eFaces;
1424 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1425 myEntityState &= ~eVolumes;
1426 theMode &= ~eVolumes;
1430 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1431 theMode |= e0DElements;
1433 if(myVisualObj->GetNbEntities(SMDSAbs_Ball))
1434 theMode |= eBallElem;
1436 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1439 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1442 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1443 theMode |= eVolumes;
1446 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1448 myEntityMode = theMode;
1449 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1450 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1451 aFilter->ClearRegisteredCellsWithType();
1452 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1454 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1455 aHightFilter->ClearRegisteredCellsWithType();
1456 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1458 if (myEntityMode & e0DElements) {
1459 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1460 aFilter->RegisterCellsWithType(VTK_VERTEX);
1461 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1464 if (myEntityMode & eBallElem) {
1465 aFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1466 aHightFilter->RegisterCellsWithType(VTK_POLY_VERTEX);
1469 if (myEntityMode & eEdges) {
1470 if (MYDEBUG) MESSAGE("EDGES");
1471 aFilter->RegisterCellsWithType(VTK_LINE);
1472 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1474 aHightFilter->RegisterCellsWithType(VTK_LINE);
1475 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1478 if (myEntityMode & eFaces) {
1479 if (MYDEBUG) MESSAGE("FACES");
1480 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1481 aFilter->RegisterCellsWithType(VTK_POLYGON);
1482 aFilter->RegisterCellsWithType(VTK_QUAD);
1483 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1484 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1485 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1487 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1488 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1489 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1490 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1491 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1492 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1495 if (myEntityMode & eVolumes) {
1496 if (MYDEBUG) MESSAGE("VOLUMES");
1497 aFilter->RegisterCellsWithType(VTK_TETRA);
1498 aFilter->RegisterCellsWithType(VTK_VOXEL);
1499 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1500 aFilter->RegisterCellsWithType(VTK_WEDGE);
1501 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1502 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1503 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1504 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1505 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1506 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1507 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1508 //#ifdef VTK_HAVE_POLYHEDRON
1509 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1512 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1513 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1514 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1515 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1516 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1517 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1518 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1519 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1520 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1521 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1522 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1523 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1524 //#ifdef VTK_HAVE_POLYHEDRON
1525 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1529 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1530 SetVisibility(GetVisibility(),false);
1533 void SMESH_ActorDef::SetRepresentation (int theMode)
1535 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1536 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1537 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1538 int aNb0Ds = myVisualObj->GetNbEntities(SMDSAbs_0DElement);
1539 int aNbBalls = myVisualObj->GetNbEntities(SMDSAbs_Ball);
1542 myRepresentation = eSurface;
1543 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1544 myRepresentation = eEdge;
1545 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1546 myRepresentation = ePoint;
1551 if (!aNbFaces && !aNbVolumes && !aNbEdges && !aNb0Ds && !aNbBalls) return;
1554 if (!aNbFaces && !aNbVolumes && !aNb0Ds && !aNbBalls) return;
1557 myRepresentation = theMode;
1560 if (!GetUnstructuredGrid()->GetNumberOfCells())
1561 myRepresentation = ePoint;
1564 if (myRepresentation == ePoint) {
1572 myPickableActor = myBaseActor;
1573 myNodeActor->SetVisibility(false);
1574 myNodeExtActor->SetVisibility(false);
1575 vtkProperty *aProp = NULL, *aBackProp = NULL;
1576 vtkProperty *aPropVN = NULL, *aPropVR = NULL;
1577 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1578 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1579 switch (myRepresentation) {
1581 myPickableActor = myNodeActor;
1582 myNodeActor->SetVisibility(true);
1583 aQuadraticMode = SMESH_Actor::eLines;
1584 aProp = aBackProp = aPropVN = aPropVR = myNodeProp;
1585 aReperesent = SMESH_DeviceActor::ePoint;
1588 aProp = aBackProp = aPropVN = aPropVR = myEdgeProp;
1589 aReperesent = SMESH_DeviceActor::eInsideframe;
1592 aProp = mySurfaceProp;
1593 aBackProp = myBackSurfaceProp;
1594 aPropVN = myNormalVProp;
1595 aPropVR = myReversedVProp;
1596 aReperesent = SMESH_DeviceActor::eSurface;
1600 my2DActor->SetProperty(aProp);
1601 my2DActor->SetBackfaceProperty(aBackProp);
1602 my2DActor->SetRepresentation(aReperesent);
1604 if(aQuadraticMode == SMESH_Actor::eLines)
1605 my2DActor->SetQuadraticArcMode(false);
1606 else if(aQuadraticMode == SMESH_Actor::eArcs)
1607 my2DActor->SetQuadraticArcMode(true);
1609 my2DExtActor->SetRepresentation(aReperesent);
1611 my3DActor->SetProperty(aPropVN);
1612 my3DActor->SetBackfaceProperty(aPropVR);
1613 my3DActor->SetRepresentation(aReperesent);
1615 //my0DExtActor->SetVisibility(false);
1616 my1DExtActor->SetVisibility(false);
1617 my2DExtActor->SetVisibility(false);
1618 my3DExtActor->SetVisibility(false);
1621 //my0DActor->SetProperty(aProp);
1622 //my0DActor->SetBackfaceProperty(aBackProp);
1623 my0DActor->SetRepresentation(aReperesent);
1624 myBallActor->SetRepresentation(aReperesent);
1625 //my0DExtActor->SetRepresentation(aReperesent);
1627 switch(myControlMode){
1629 case eMultiConnection:
1630 aProp = aBackProp = my1DProp;
1631 if(myRepresentation != ePoint)
1632 aReperesent = SMESH_DeviceActor::eInsideframe;
1636 if(aQuadraticMode == SMESH_Actor::eLines)
1637 my1DActor->SetQuadraticArcMode(false);
1638 else if(aQuadraticMode == SMESH_Actor::eArcs)
1639 my1DActor->SetQuadraticArcMode(true);
1641 my1DActor->SetProperty(aProp);
1642 my1DActor->SetBackfaceProperty(aBackProp);
1643 my1DActor->SetRepresentation(aReperesent);
1645 my1DExtActor->SetRepresentation(aReperesent);
1647 if(myIsPointsVisible)
1648 myPickableActor = myNodeActor;
1649 if(GetPointRepresentation())
1650 myNodeActor->SetVisibility(true);
1652 SetMapper(myPickableActor->GetMapper());
1654 SetVisibility(GetVisibility(),false);
1660 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1661 if ( myIsPointsVisible == theIsPointsVisible )
1663 myIsPointsVisible = theIsPointsVisible;
1664 SetRepresentation(GetRepresentation());
1667 bool SMESH_ActorDef::GetPointRepresentation(){
1668 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1672 void SMESH_ActorDef::UpdateHighlight(){
1673 myHighlitableActor->SetHighlited(false);
1674 myHighlitableActor->SetVisibility(false);
1676 bool anIsVisible = GetVisibility();
1678 switch(myRepresentation){
1679 case SMESH_DeviceActor::eSurface:
1680 case SMESH_DeviceActor::eWireframe:
1682 if(myIsHighlighted) {
1683 myHighlitableActor->SetProperty(myHighlightProp);
1684 myBallActor->SetProperty(myBallHighlightProp);
1685 }else if(myIsPreselected){
1686 myHighlitableActor->SetProperty(myPreselectProp);
1687 myBallActor->SetProperty(myBallPreselectProp);
1688 } else if(anIsVisible){
1689 myBallActor->SetProperty(myBallProp);
1690 (myRepresentation == eSurface) ?
1691 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1693 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1694 myHighlitableActor->SetHighlited(anIsVisible);
1695 myHighlitableActor->GetExtractUnstructuredGrid()->
1696 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1697 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1699 myHighlitableActor->SetVisibility(anIsVisible);
1702 case SMESH_DeviceActor::ePoint:
1704 if(myIsHighlighted) {
1705 myNodeActor->SetProperty(myHighlightProp);
1706 }else if(myIsPreselected) {
1707 myNodeActor->SetProperty(myPreselectProp);
1708 } else if(anIsVisible) {
1709 myNodeActor->SetProperty(myNodeProp);
1711 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1712 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1719 void SMESH_ActorDef::highlight(bool theHighlight){
1720 if ( myIsHighlighted == theHighlight )
1722 myIsHighlighted = theHighlight;
1727 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1728 if ( myIsPreselected == thePreselect )
1730 myIsPreselected = thePreselect;
1736 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1738 if (myPickableActor->GetIsOpaque())
1740 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1748 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1750 if (!myPickableActor->GetIsOpaque())
1752 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1760 void SMESH_ActorDef::Render(vtkRenderer *ren){
1761 unsigned long aTime = myTimeStamp->GetMTime();
1762 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1763 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1764 if(anObjTime > aTime || aClippingTime > aTime)
1769 void SMESH_ActorDef::Update(){
1770 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1772 if(GetControlMode() != eNone) {
1773 unsigned long aTime = myTimeStamp->GetMTime();
1774 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1775 if (anObjTime > aTime)
1776 SetControlMode(GetControlMode(),false);
1780 myNodeActor->UpdateLabels();
1783 my0DActor->UpdateLabels();
1786 myBallActor->UpdateLabels();
1789 my1DActor->UpdateLabels();
1792 my2DActor->UpdateLabels();
1795 my3DActor->UpdateLabels();
1797 if(myIsFacesOriented){
1798 SetFacesOriented(myIsFacesOriented);
1801 if(myVisualObj->GetEntitiesFlag()) {
1802 myEntityMode |= myVisualObj->GetEntitiesState();
1805 SetEntityMode(GetEntityMode());
1806 SetVisibility(GetVisibility());
1808 myTimeStamp->Modified();
1813 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1814 SALOME_Actor::ReleaseGraphicsResources(renWin);
1816 myPickableActor->ReleaseGraphicsResources(renWin);
1820 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1821 vtkFloatingPointType* aColor = theProperty->GetColor();
1828 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1829 mySurfaceProp->SetOpacity(theValue);
1830 myBackSurfaceProp->SetOpacity(theValue);
1831 myNormalVProp->SetOpacity(theValue);
1832 myReversedVProp->SetOpacity(theValue);
1833 myEdgeProp->SetOpacity(theValue);
1834 myOutLineProp->SetOpacity(theValue);
1835 myNodeProp->SetOpacity(theValue);
1837 my1DProp->SetOpacity(theValue);
1838 my0DProp->SetOpacity(theValue);
1839 myBallProp->SetOpacity(theValue);
1843 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1844 return mySurfaceProp->GetOpacity();
1848 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1849 mySurfaceProp->SetColor(r,g,b);
1850 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1851 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1852 if( aGroupObj->GetElementType() == SMDSAbs_Face )
1853 myNameActor->SetBackgroundColor(r,g,b);
1855 myDeltaBrightness = delta;
1856 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1857 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1861 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1862 ::GetColor(mySurfaceProp,r,g,b);
1863 delta = myDeltaBrightness;
1866 void SMESH_ActorDef::SetVolumeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1867 myNormalVProp->SetColor(r,g,b);
1868 my3DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1869 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1870 if( aGroupObj->GetElementType() == SMDSAbs_Volume )
1871 myNameActor->SetBackgroundColor(r,g,b);
1873 myDeltaVBrightness = delta;
1874 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1875 myReversedVProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1879 void SMESH_ActorDef::GetVolumeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1880 ::GetColor(myNormalVProp,r,g,b);
1881 delta = myDeltaVBrightness;
1884 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1885 myEdgeProp->SetColor(r,g,b);
1886 my1DProp->SetColor(r,g,b);
1887 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1888 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1889 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1890 myNameActor->SetBackgroundColor(r,g,b);
1894 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1895 ::GetColor(myEdgeProp,r,g,b);
1898 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1899 myOutLineProp->SetColor(r,g,b);
1903 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1904 ::GetColor(myOutLineProp,r,g,b);
1908 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1909 myNodeProp->SetColor(r,g,b);
1910 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1911 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1912 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1913 myNameActor->SetBackgroundColor(r,g,b);
1917 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1918 ::GetColor(myNodeProp,r,g,b);
1921 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1922 my0DProp->SetColor(r,g,b);
1923 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1924 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1925 myNameActor->SetBackgroundColor(r,g,b);
1929 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1930 ::GetColor(my0DProp,r,g,b);
1933 void SMESH_ActorDef::SetBallColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1934 myBallProp->SetColor(r,g,b);
1935 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1936 if( aGroupObj->GetElementType() == SMDSAbs_Ball )
1937 myNameActor->SetBackgroundColor(r,g,b);
1941 void SMESH_ActorDef::GetBallColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1942 ::GetColor(myBallProp,r,g,b);
1945 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1946 myHighlightProp->SetColor(r,g,b);
1947 myBallHighlightProp->SetColor(r,g,b);
1951 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1952 ::GetColor(myHighlightProp,r,g,b);
1955 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1956 myPreselectProp->SetColor(r,g,b);
1957 myBallPreselectProp->SetColor(r,g,b);
1961 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1962 ::GetColor(myPreselectProp,r,g,b);
1966 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1967 return myEdgeProp->GetLineWidth();
1971 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1972 myEdgeProp->SetLineWidth(theVal);
1974 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1975 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1976 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
1977 my3DExtProp->SetLineWidth(theVal + aLineWidthInc);
1978 myOutLineProp->SetLineWidth(theVal);
1979 myHighlightProp->SetLineWidth(theVal);
1980 myPreselectProp->SetLineWidth(theVal);
1984 vtkFloatingPointType SMESH_ActorDef::GetOutlineWidth()
1986 return myOutLineProp->GetLineWidth();
1989 void SMESH_ActorDef::SetOutlineWidth(vtkFloatingPointType theVal)
1991 myOutLineProp->SetLineWidth(theVal);
1995 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1996 my0DProp->SetPointSize(theVal);
1997 myHighlightProp->SetPointSize(theVal);
1998 myPreselectProp->SetPointSize(theVal);
2000 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2001 aCustom->Set0DSize(theVal);
2003 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2004 aCustom->Set0DSize(theVal);
2010 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
2011 return my0DProp->GetPointSize();
2014 void SMESH_ActorDef::SetBallSize(vtkFloatingPointType theVal){
2015 myBallProp->SetPointSize(theVal);
2016 myBallHighlightProp->SetPointSize(theVal);
2017 myBallPreselectProp->SetPointSize(theVal);
2018 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myHighlightActor )) {
2019 aCustom->SetBallSize(theVal);
2021 if(SMESH_SVTKActor* aCustom = SMESH_SVTKActor::SafeDownCast( myPreHighlightActor )) {
2022 aCustom->SetBallSize(theVal);
2028 vtkFloatingPointType SMESH_ActorDef::GetBallSize(){
2029 return myBallProp->GetPointSize();
2032 int SMESH_ActorDef::GetObjDimension( const int theObjId )
2034 return myVisualObj->GetElemDimension( theObjId );
2039 IsImplicitFunctionUsed() const
2041 return myBaseActor->IsImplicitFunctionUsed();
2045 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
2047 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2048 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2050 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2052 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2054 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2055 myBallActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2056 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2058 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2059 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2061 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2062 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2063 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2064 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
2068 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
2071 myImplicitBoolean->GetFunction()->AddItem(thePlane);
2072 myCippingPlaneCont.push_back(thePlane);
2073 if(!IsImplicitFunctionUsed())
2074 SetImplicitFunctionUsed(true);
2075 myNodeActor->UpdateLabels();
2077 return myCippingPlaneCont.size();
2082 RemoveAllClippingPlanes()
2084 myImplicitBoolean->GetFunction()->RemoveAllItems();
2085 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
2086 myCippingPlaneCont.clear();
2087 SetImplicitFunctionUsed(false);
2088 myNodeActor->UpdateLabels();
2093 GetNumberOfClippingPlanes()
2095 return myCippingPlaneCont.size();
2100 GetClippingPlane(vtkIdType theID)
2102 if(theID >= myCippingPlaneCont.size())
2104 return myCippingPlaneCont[theID].Get();
2107 void SMESH_ActorDef::UpdateScalarBar()
2109 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
2113 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
2115 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
2116 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2118 aScalarBarTitleProp->SetFontFamilyToArial();
2120 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
2122 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
2123 if ( f.family() == "Arial" )
2124 aScalarBarTitleProp->SetFontFamilyToArial();
2125 else if ( f.family() == "Courier" )
2126 aScalarBarTitleProp->SetFontFamilyToCourier();
2127 else if ( f.family() == "Times" )
2128 aScalarBarTitleProp->SetFontFamilyToTimes();
2131 aScalarBarTitleProp->BoldOn();
2133 aScalarBarTitleProp->BoldOff();
2136 aScalarBarTitleProp->ItalicOn();
2138 aScalarBarTitleProp->ItalicOff();
2141 aScalarBarTitleProp->ShadowOn();
2143 aScalarBarTitleProp->ShadowOff();
2146 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
2147 aScalarBarTitleProp->Delete();
2149 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
2151 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
2152 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
2154 aScalarBarLabelProp->SetFontFamilyToArial();
2155 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
2157 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
2158 if( f.family() == "Arial" )
2159 aScalarBarLabelProp->SetFontFamilyToArial();
2160 else if( f.family() == "Courier" )
2161 aScalarBarLabelProp->SetFontFamilyToCourier();
2162 else if( f.family() == "Times" )
2163 aScalarBarLabelProp->SetFontFamilyToTimes();
2166 aScalarBarLabelProp->BoldOn();
2168 aScalarBarLabelProp->BoldOff();
2171 aScalarBarLabelProp->ItalicOn();
2173 aScalarBarLabelProp->ItalicOff();
2176 aScalarBarLabelProp->ShadowOn();
2178 aScalarBarLabelProp->ShadowOff();
2181 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
2182 aScalarBarLabelProp->Delete();
2184 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2185 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2187 myScalarBarActor->SetOrientationToHorizontal();
2189 myScalarBarActor->SetOrientationToVertical();
2192 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2193 if( mgr->hasValue( "SMESH", name + "x" ) )
2194 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2196 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2197 if( mgr->hasValue( "SMESH", name + "y" ) )
2198 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2199 myScalarBarActor->SetPosition( aXVal, aYVal );
2201 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2202 if( mgr->hasValue( "SMESH", name + "width" ) )
2203 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2204 myScalarBarActor->SetWidth( aWVal );
2206 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2207 if( mgr->hasValue( "SMESH", name + "height" ) )
2208 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2209 myScalarBarActor->SetHeight( aHVal );
2212 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2213 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2214 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2217 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2218 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2219 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2221 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2222 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2224 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2225 myScalarBarActor->SetDistributionColoringType(coloringType);
2227 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2228 QColor(255, 255, 255));
2230 rgb[0]= distributionColor.red()/255.;
2231 rgb[1]= distributionColor.green()/255.;
2232 rgb[2]= distributionColor.blue()/255.;
2233 myScalarBarActor->SetDistributionColor(rgb);
2238 void SMESH_ActorDef::UpdateDistribution()
2240 if(SMESH::Controls::NumericalFunctor* fun =
2241 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2243 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2244 std::vector<int> nbEvents;
2245 std::vector<double> funValues;
2246 SMESH_VisualObjDef::TEntityList elems;
2247 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2248 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2249 std::vector<int> elemIds;
2250 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2251 elemIds.push_back( (*e)->GetID());
2252 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2253 double * range = lookupTable->GetRange();
2254 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2255 myScalarBarActor->SetDistribution(nbEvents);
2259 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2262 case SMESH_Actor::eLines :
2263 myHighlitableActor->SetQuadraticArcMode(false);
2264 my2DActor->SetQuadraticArcMode(false);
2265 my1DActor->SetQuadraticArcMode(false);
2267 case SMESH_Actor::eArcs :
2268 myHighlitableActor->SetQuadraticArcMode(true);
2269 if(GetRepresentation() != SMESH_Actor::ePoint) {
2270 my2DActor->SetQuadraticArcMode(true);
2271 my1DActor->SetQuadraticArcMode(true);
2280 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2282 if(myHighlitableActor->GetQuadraticArcMode())
2283 return SMESH_Actor::eArcs;
2285 return SMESH_Actor::eLines;
2288 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2290 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2291 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2292 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2295 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2297 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2298 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2299 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2300 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2303 #ifndef DISABLE_PLOT2DVIEWER
2304 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2307 my2dHistogram->clearAllPoints();
2309 if(SMESH::Controls::NumericalFunctor* fun =
2310 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2313 if(!my2dHistogram) {
2314 my2dHistogram = new SPlot2d_Histogram();
2315 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2316 my2dHistogram->setIO(anIO);
2319 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2320 std::vector<int> nbEvents;
2321 std::vector<double> funValues;
2322 SMESH_VisualObjDef::TEntityList elems;
2323 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2324 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2325 std::vector<int> elemIds;
2327 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2328 elemIds.push_back( (*e)->GetID());
2330 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2331 double * range = lookupTable->GetRange();
2332 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2334 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2335 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2337 if(funValues.size() >= 2)
2338 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2342 //Color of the histogram
2343 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2344 my2dHistogram->setAutoAssign(true);
2347 myScalarBarActor->GetDistributionColor(rgb);
2348 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2349 my2dHistogram->setColor(aColor);
2353 return my2dHistogram;