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"
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 my3DActor->SetCoincident3DAllowed(true);
207 aFilter = my3DActor->GetExtractUnstructuredGrid();
208 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
209 aFilter->RegisterCellsWithType(VTK_TETRA);
210 aFilter->RegisterCellsWithType(VTK_VOXEL);
211 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
212 aFilter->RegisterCellsWithType(VTK_WEDGE);
213 aFilter->RegisterCellsWithType(VTK_PYRAMID);
214 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
215 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
216 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
217 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
218 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
219 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
220 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
221 //#ifdef VTK_HAVE_POLYHEDRON
222 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
223 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
226 my3DExtActor = SMESH_DeviceActor::New();
227 my3DExtActor->SetUserMatrix(aMatrix);
228 my3DExtActor->PickableOff();
229 my3DExtActor->SetProperty(my2DExtProp);
230 my3DExtActor->SetBackfaceProperty(my2DExtProp);
231 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
232 my3DExtActor->SetCoincident3DAllowed(true);
233 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
234 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
235 aFilter->RegisterCellsWithType(VTK_TETRA);
236 aFilter->RegisterCellsWithType(VTK_VOXEL);
237 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
238 aFilter->RegisterCellsWithType(VTK_WEDGE);
239 aFilter->RegisterCellsWithType(VTK_PYRAMID);
240 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
241 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
242 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
243 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
244 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
245 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
246 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
247 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
249 //Definition 1D device of the actor
250 //---------------------------------
251 myEdgeProp = vtkProperty::New();
252 myEdgeProp->SetAmbient(1.0);
253 myEdgeProp->SetDiffuse(0.0);
254 myEdgeProp->SetSpecular(0.0);
255 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
256 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
257 myEdgeProp->SetLineWidth(aLineWidth);
259 my1DActor = SMESH_CellLabelActor::New();
260 my1DActor->SetStoreGemetryMapping(true);
261 my1DActor->SetUserMatrix(aMatrix);
262 my1DActor->PickableOff();
263 my1DActor->SetHighlited(true);
264 my1DActor->SetProperty(myEdgeProp);
265 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
266 aFilter = my1DActor->GetExtractUnstructuredGrid();
267 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
268 aFilter->RegisterCellsWithType(VTK_LINE);
269 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
271 my1DProp = vtkProperty::New();
272 my1DProp->DeepCopy(myEdgeProp);
273 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
274 my1DProp->SetPointSize(aElem0DSize);
276 my1DExtProp = vtkProperty::New();
277 my1DExtProp->DeepCopy(myEdgeProp);
278 anRGB[0] = 1 - anRGB[0];
279 anRGB[1] = 1 - anRGB[1];
280 anRGB[2] = 1 - anRGB[2];
281 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
282 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
283 my1DExtProp->SetPointSize(aElem0DSize);
285 my1DExtActor = SMESH_DeviceActor::New();
286 my1DExtActor->SetUserMatrix(aMatrix);
287 my1DExtActor->PickableOff();
288 my1DExtActor->SetHighlited(true);
289 my1DExtActor->SetVisibility(false);
290 my1DExtActor->SetProperty(my1DExtProp);
291 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
292 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
293 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
294 aFilter->RegisterCellsWithType(VTK_LINE);
295 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
298 //Definition 0D device of the actor (0d elements)
299 //-----------------------------------------------
300 my0DProp = vtkProperty::New();
301 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
302 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
303 my0DProp->SetPointSize(aElem0DSize);
305 my0DActor = SMESH_CellLabelActor::New();
306 my0DActor->SetUserMatrix(aMatrix);
307 my0DActor->SetStoreGemetryMapping(true);
308 my0DActor->PickableOff();
309 my0DActor->SetVisibility(false);
310 my0DActor->SetProperty(my0DProp);
311 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
312 aFilter = my0DActor->GetExtractUnstructuredGrid();
313 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
314 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
315 aFilter->RegisterCellsWithType(VTK_VERTEX);
317 //my0DExtProp = vtkProperty::New();
318 //my0DExtProp->DeepCopy(my0DProp);
319 //anRGB[0] = 1 - anRGB[0];
320 //anRGB[1] = 1 - anRGB[1];
321 //anRGB[2] = 1 - anRGB[2];
322 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
323 //my0DExtProp->SetPointSize(aElem0DSize);
325 //my0DExtActor = SMESH_DeviceActor::New();
326 //my0DExtActor->SetUserMatrix(aMatrix);
327 //my0DExtActor->SetStoreClippingMapping(true);
328 //my0DExtActor->PickableOff();
329 //my0DExtActor->SetHighlited(true);
330 //my0DExtActor->SetVisibility(false);
331 //my0DExtActor->SetProperty(my0DExtProp);
332 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
333 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
334 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
335 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
336 //aFilter->RegisterCellsWithType(VTK_VERTEX);
339 //Definition 0D device of the actor (nodes)
340 //-----------------------------------------
341 myNodeProp = vtkProperty::New();
342 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
343 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
345 myNodeActor = SMESH_NodeLabelActor::New();
346 myNodeActor->SetUserMatrix(aMatrix);
347 myNodeActor->SetStoreClippingMapping(true);
348 myNodeActor->PickableOff();
349 myNodeActor->SetVisibility(false);
350 myNodeActor->SetProperty(myNodeProp);
351 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
352 aFilter = myNodeActor->GetExtractUnstructuredGrid();
353 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
355 myNodeExtProp = vtkProperty::New();
356 myNodeExtProp->DeepCopy(myNodeProp);
357 anRGB[0] = 1 - anRGB[0];
358 anRGB[1] = 1 - anRGB[1];
359 anRGB[2] = 1 - anRGB[2];
360 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
362 myNodeExtActor = SMESH_DeviceActor::New();
363 myNodeExtActor->SetUserMatrix(aMatrix);
364 myNodeExtActor->SetStoreClippingMapping(true);
365 myNodeExtActor->PickableOff();
366 myNodeExtActor->SetHighlited(true);
367 myNodeExtActor->SetVisibility(false);
368 myNodeExtActor->SetProperty(myNodeExtProp);
369 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
370 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
371 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
372 aFilter->RegisterCellsWithType(VTK_VERTEX);
374 //Definition of Pickable and Highlitable engines
375 //----------------------------------------------
377 myBaseActor->SetUserMatrix(aMatrix);
378 myBaseActor->SetStoreGemetryMapping(true);
379 myBaseActor->GetProperty()->SetOpacity(0.0);
380 myPickableActor = myBaseActor;
382 myHighlightProp = vtkProperty::New();
383 myHighlightProp->SetAmbient(1.0);
384 myHighlightProp->SetDiffuse(0.0);
385 myHighlightProp->SetSpecular(0.0);
386 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
387 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
388 myHighlightProp->SetPointSize(aElem0DSize); // ??
389 myHighlightProp->SetLineWidth(aLineWidth);
390 myHighlightProp->SetRepresentation(1);
392 myOutLineProp = vtkProperty::New();
393 myOutLineProp->SetAmbient(1.0);
394 myOutLineProp->SetDiffuse(0.0);
395 myOutLineProp->SetSpecular(0.0);
396 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
397 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
398 myOutLineProp->SetPointSize(aElem0DSize); // ??
399 myOutLineProp->SetLineWidth(aLineWidth);
400 myOutLineProp->SetRepresentation(1);
402 myPreselectProp = vtkProperty::New();
403 myPreselectProp->SetAmbient(1.0);
404 myPreselectProp->SetDiffuse(0.0);
405 myPreselectProp->SetSpecular(0.0);
406 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
407 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
408 myPreselectProp->SetPointSize(aElem0DSize); // ??
409 myPreselectProp->SetLineWidth(aLineWidth);
410 myPreselectProp->SetRepresentation(1);
412 myHighlitableActor = SMESH_DeviceActor::New();
413 myHighlitableActor->SetUserMatrix(aMatrix);
414 myHighlitableActor->PickableOff();
415 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
416 myHighlitableActor->SetCoincident3DAllowed(true);
423 myControlMode = eNone;
424 myControlActor = my2DActor;
426 //Definition of myScalarBarActor
427 //------------------------------
428 myLookupTable = vtkLookupTable::New();
429 //Fix for Bug PAL5195 - SMESH764:
430 //Controls - Aspect Ratio: incorrect colors of the best and worst values
431 myLookupTable->SetHueRange(0.667,0.0);
433 myScalarBarActor = SMESH_ScalarBarActor::New();
434 myScalarBarActor->SetVisibility(false);
435 myScalarBarActor->SetLookupTable(myLookupTable);
438 //Incorrect "Min value" in Scalar Bar in Mesh:
439 // myScalarBarActor->SetLabelFormat("%.4g");
440 // changes was commented because of regression bug IPAL 19981
442 mgr = SUIT_Session::session()->resourceMgr();
446 myEntityMode = eAllEntity;
447 myEntityModeCache = eAllEntity;
450 myImplicitBoolean = vtkImplicitBoolean::New();
451 myImplicitBoolean->SetOperationTypeToIntersection();
453 //Quadratic 2D elements representation
454 //-----------------------------------------------------------------------------
455 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
456 if(aQuadratic2DMode == 0){
457 myHighlitableActor->SetQuadraticArcMode(false);
458 my2DActor->SetQuadraticArcMode(false);
459 my1DActor->SetQuadraticArcMode(false);
461 else if(aQuadratic2DMode == 1){
462 myHighlitableActor->SetQuadraticArcMode(true);
463 my2DActor->SetQuadraticArcMode(true);
464 my1DActor->SetQuadraticArcMode(true);
467 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
468 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
469 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
471 // Set colors of the name actor
472 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
473 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
474 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
475 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
477 #ifndef DISABLE_PLOT2DVIEWER
484 SMESH_ActorDef::~SMESH_ActorDef()
486 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
488 #ifndef DISABLE_PLOT2DVIEWER
490 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
491 delete my2dHistogram;
495 myScalarBarActor->Delete();
496 myLookupTable->Delete();
498 mySurfaceProp->Delete();
499 myBackSurfaceProp->Delete();
500 myOutLineProp->Delete();
502 myEdgeProp->Delete();
503 myHighlightProp->Delete();
504 myPreselectProp->Delete();
506 myNodeProp->Delete();
507 myNodeExtProp->Delete();
512 //my0DExtProp->Delete();
513 //my0DExtActor->Delete();
518 my1DExtProp->Delete();
519 my1DExtActor->Delete();
522 my2DExtProp->Delete();
523 my2DExtActor->Delete();
525 my3DExtActor->Delete();
527 myNodeActor->Delete();
528 myBaseActor->Delete();
530 myNodeExtActor->Delete();
531 myHighlitableActor->Delete();
533 myImplicitBoolean->Delete();
535 myTimeStamp->Delete();
538 void SMESH_ActorDef::Delete()
540 // This is just to guarantee that the DeleteActorEvent (which was previously invoked
541 // from the actor's destructor) will be thrown before removing the actor's observers,
542 // that is done inside the Superclass::Delete() method but before the destructor itself
543 // (see the issue 0021562: EDF SMESH: clipping and delete mesh clipped leads to crash).
544 // The event is caught by SMESHGUI::ProcessEvents() static method.
545 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
547 Superclass::Delete();
550 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
553 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
554 SetRepresentation(GetRepresentation());
555 myTimeStamp->Modified();
559 bool SMESH_ActorDef::GetPointsLabeled() {
560 return myNodeActor && myNodeActor->GetPointsLabeled();
563 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
566 my3DActor->SetCellsLabeled(theIsCellsLabeled);
569 my2DActor->SetCellsLabeled(theIsCellsLabeled);
572 my1DActor->SetCellsLabeled(theIsCellsLabeled);
575 my0DActor->SetCellsLabeled(theIsCellsLabeled);
577 myTimeStamp->Modified();
581 bool SMESH_ActorDef::GetCellsLabeled() {
584 result = result || my3DActor->GetCellsLabeled();
587 result = result || my2DActor->GetCellsLabeled();
590 result = result || my1DActor->GetCellsLabeled();
593 result = result || my0DActor->GetCellsLabeled();
599 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
601 myIsFacesOriented = theIsFacesOriented;
603 my2DActor->SetFacesOriented(theIsFacesOriented);
604 my3DActor->SetFacesOriented(theIsFacesOriented);
606 myTimeStamp->Modified();
609 bool SMESH_ActorDef::GetFacesOriented()
611 return myIsFacesOriented;
614 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
616 my2DActor->SetFacesOrientationColor( theColor );
617 my3DActor->SetFacesOrientationColor( theColor );
620 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
622 my3DActor->GetFacesOrientationColor( theColor );
625 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
627 my2DActor->SetFacesOrientationScale( theScale );
628 my3DActor->SetFacesOrientationScale( theScale );
631 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
633 return my3DActor->GetFacesOrientationScale();
636 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
638 my2DActor->SetFacesOrientation3DVectors( theState );
639 my3DActor->SetFacesOrientation3DVectors( theState );
642 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
644 return my3DActor->GetFacesOrientation3DVectors();
650 SetControlMode(eControl theMode)
652 SetControlMode(theMode,true);
658 SetControlMode(eControl theMode,
659 bool theCheckEntityMode)
661 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
665 myControlMode = eNone;
666 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
668 my0DActor->GetMapper()->SetScalarVisibility(false);
669 my1DActor->GetMapper()->SetScalarVisibility(false);
670 my2DActor->GetMapper()->SetScalarVisibility(false);
671 my3DActor->GetMapper()->SetScalarVisibility(false);
672 myScalarBarActor->SetVisibility(false);
674 bool anIsScalarVisible = theMode > eNone;
676 if(anIsScalarVisible) {
680 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
681 aControl->SetPrecision( myControlsPrecision );
682 myFunctor.reset( aControl );
683 myControlActor = my1DActor;
688 myFunctor.reset(new SMESH::Controls::Length2D());
689 myControlActor = my2DActor;
693 myFunctor.reset(new SMESH::Controls::FreeBorders());
694 myControlActor = my1DActor;
697 myFunctor.reset(new SMESH::Controls::FreeEdges());
698 myControlActor = my2DActor;
701 myFunctor.reset(new SMESH::Controls::FreeNodes());
702 myControlActor = myNodeActor;
705 myFunctor.reset(new SMESH::Controls::FreeFaces());
706 myControlActor = my2DActor;
708 case eCoincidentNodes:
710 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
711 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
712 cn->SetTolerance( tol );
714 myControlActor = myNodeActor;
717 case eCoincidentElems1D:
718 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
719 myControlActor = my1DActor;
721 case eCoincidentElems2D:
722 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
723 myControlActor = my2DActor;
725 case eCoincidentElems3D:
726 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
727 myControlActor = my3DActor;
729 case eBareBorderFace:
730 myFunctor.reset(new SMESH::Controls::BareBorderFace());
731 myControlActor = my2DActor;
733 case eOverConstrainedFace:
734 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
735 myControlActor = my2DActor;
737 case eMultiConnection:
738 myFunctor.reset(new SMESH::Controls::MultiConnection());
739 myControlActor = my1DActor;
741 case eMultiConnection2D:
742 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
743 myControlActor = my2DActor;
747 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
748 aControl->SetPrecision( myControlsPrecision );
749 myFunctor.reset( aControl );
750 myControlActor = my2DActor;
755 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
756 aControl->SetPrecision( myControlsPrecision );
757 myFunctor.reset( aControl );
758 myControlActor = my2DActor;
763 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
764 aControl->SetPrecision( myControlsPrecision );
765 myFunctor.reset( aControl );
766 myControlActor = my2DActor;
771 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
772 aControl->SetPrecision( myControlsPrecision );
773 myFunctor.reset( aControl );
774 myControlActor = my3DActor;
779 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
780 aControl->SetPrecision( myControlsPrecision );
781 myFunctor.reset( aControl );
782 myControlActor = my3DActor;
785 case eMaxElementLength2D:
787 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
788 aControl->SetPrecision( myControlsPrecision );
789 myFunctor.reset( aControl );
790 myControlActor = my2DActor;
793 case eMaxElementLength3D:
795 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
796 aControl->SetPrecision( myControlsPrecision );
797 myFunctor.reset( aControl );
798 myControlActor = my3DActor;
801 case eBareBorderVolume:
803 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
804 myControlActor = my3DActor;
807 case eOverConstrainedVolume:
809 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
810 myControlActor = my3DActor;
815 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
816 aControl->SetPrecision( myControlsPrecision );
817 myFunctor.reset( aControl );
818 myControlActor = my2DActor;
823 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
824 aControl->SetPrecision( myControlsPrecision );
825 myFunctor.reset( aControl );
826 myControlActor = my2DActor;
831 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
832 aControl->SetPrecision( myControlsPrecision );
833 myFunctor.reset( aControl );
834 myControlActor = my2DActor;
841 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
842 vtkIdType aNbCells = aGrid->GetNumberOfCells();
844 myControlMode = theMode;
845 switch(myControlMode){
847 case eCoincidentNodes:
848 myNodeExtActor->SetExtControlMode(myFunctor);
852 case eCoincidentElems1D:
853 my1DExtActor->SetExtControlMode(myFunctor);
856 case eBareBorderFace:
857 case eOverConstrainedFace:
858 case eCoincidentElems2D:
859 my2DExtActor->SetExtControlMode(myFunctor);
861 case eBareBorderVolume:
862 case eOverConstrainedVolume:
863 case eCoincidentElems3D:
864 my3DExtActor->SetExtControlMode(myFunctor);
867 case eMultiConnection2D:
868 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
869 UpdateDistribution();
872 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
873 UpdateDistribution();
877 if(theCheckEntityMode) {
878 if(myControlActor == my1DActor) {
879 if (!myIsEntityModeCache){
880 myEntityModeCache = GetEntityMode();
881 myIsEntityModeCache=true;
883 SetEntityMode(eEdges);
885 else if(myControlActor == my2DActor) {
886 switch(myControlMode) {
890 case eMultiConnection2D:
891 if (!myIsEntityModeCache){
892 myEntityModeCache = GetEntityMode();
893 myIsEntityModeCache=true;
895 SetEntityMode(eFaces);
898 if (!myIsEntityModeCache){
899 myEntityModeCache = GetEntityMode();
900 myIsEntityModeCache=true;
902 SetEntityMode(eFaces);
904 }else if(myControlActor == my3DActor) {
905 if (!myIsEntityModeCache){
906 myEntityModeCache = GetEntityMode();
907 myIsEntityModeCache=true;
909 SetEntityMode(eVolumes);
915 if(theCheckEntityMode){
916 myEntityMode = myEntityModeCache;
917 myIsEntityModeCache = false;
922 SetRepresentation(GetRepresentation());
924 myTimeStamp->Modified();
930 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
931 theRenderer->AddActor(myBaseActor);
932 theRenderer->AddActor(myNodeExtActor);
933 theRenderer->AddActor(my1DExtActor);
935 my3DActor->AddToRender(theRenderer);
936 my3DExtActor->AddToRender(theRenderer);
937 my2DActor->AddToRender(theRenderer);
938 my2DExtActor->AddToRender(theRenderer);
939 myNodeActor->AddToRender(theRenderer);
940 my1DActor->AddToRender(theRenderer);
941 my0DActor->AddToRender(theRenderer);
942 //theRenderer->AddActor(my0DExtActor);
944 theRenderer->AddActor(myHighlitableActor);
946 theRenderer->AddActor2D(myScalarBarActor);
948 // the superclass' method should be called at the end
949 // (in particular, for correct work of selection)
950 SALOME_Actor::AddToRender(theRenderer);
953 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
954 SALOME_Actor::RemoveFromRender(theRenderer);
956 theRenderer->RemoveActor(myBaseActor);
958 theRenderer->RemoveActor(myNodeExtActor);
960 theRenderer->RemoveActor(myHighlitableActor);
962 //theRenderer->RemoveActor(my0DExtActor);
964 theRenderer->RemoveActor(my1DExtActor);
966 my2DActor->RemoveFromRender(theRenderer);
967 my2DExtActor->RemoveFromRender(theRenderer);
968 my3DActor->RemoveFromRender(theRenderer);
969 my3DExtActor->RemoveFromRender(theRenderer);
970 myNodeActor->RemoveFromRender(theRenderer);
971 my0DActor->RemoveFromRender(theRenderer);
972 my1DActor->RemoveFromRender(theRenderer);
974 theRenderer->RemoveActor(myScalarBarActor);
978 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
979 const char* theEntry,
983 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
987 myVisualObj = theVisualObj;
988 myVisualObj->Update(theIsClear);
990 myNodeActor->Init(myVisualObj,myImplicitBoolean);
991 myBaseActor->Init(myVisualObj,myImplicitBoolean);
993 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
995 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
997 my0DActor->Init(myVisualObj,myImplicitBoolean);
998 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
1000 my1DActor->Init(myVisualObj,myImplicitBoolean);
1001 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
1003 my2DActor->Init(myVisualObj,myImplicitBoolean);
1004 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
1005 my3DActor->Init(myVisualObj,myImplicitBoolean);
1006 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1008 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1009 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1011 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1012 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1014 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1015 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1016 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1017 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1019 vtkFloatingPointType aFactor, aUnits;
1020 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1021 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1022 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1024 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1028 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1029 SetIsShrunkable(true);
1031 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1033 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1034 SetRepresentation(-1);
1037 SetRepresentation(eEdge);
1038 }else if(aMode == 1){
1039 SetRepresentation(eSurface);
1040 }else if(aMode == 2){
1041 SetRepresentation(ePoint);
1048 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1049 SetIsDisplayNameActor( true );
1051 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1052 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1053 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1055 myTimeStamp->Modified();
1061 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1062 return myNodeActor->GetBounds();
1066 vtkDataSet* SMESH_ActorDef::GetInput(){
1067 return GetUnstructuredGrid();
1071 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1072 Superclass::SetTransform(theTransform);
1074 myNodeActor->SetTransform(theTransform);
1075 myBaseActor->SetTransform(theTransform);
1077 myHighlitableActor->SetTransform(theTransform);
1079 myNodeExtActor->SetTransform(theTransform);
1081 my0DActor->SetTransform(theTransform);
1082 //my0DExtActor->SetTransform(theTransform);
1084 my1DActor->SetTransform(theTransform);
1085 my1DExtActor->SetTransform(theTransform);
1087 my2DActor->SetTransform(theTransform);
1088 my2DExtActor->SetTransform(theTransform);
1089 my3DActor->SetTransform(theTransform);
1090 my3DExtActor->SetTransform(theTransform);
1096 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1097 vtkLODActor::SetMapper(theMapper);
1101 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1102 SALOME_Actor::ShallowCopy(prop);
1106 vtkMapper* SMESH_ActorDef::GetMapper(){
1107 return myPickableActor->GetMapper();
1111 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1112 return myVisualObj->GetUnstructuredGrid();
1116 bool SMESH_ActorDef::IsInfinitive(){
1117 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1119 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1120 ( aDataSet->GetNumberOfCells() == 1 &&
1121 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1122 return SALOME_Actor::IsInfinitive();
1126 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1127 if ( myIsShrinkable == theShrunkable )
1129 myIsShrinkable = theShrunkable;
1133 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1134 return myBaseActor->GetShrinkFactor();
1137 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1138 myBaseActor->SetShrinkFactor(theValue);
1140 my1DActor->SetShrinkFactor(theValue);
1141 my1DExtActor->SetShrinkFactor(theValue);
1143 my2DActor->SetShrinkFactor(theValue);
1144 my2DExtActor->SetShrinkFactor(theValue);
1145 my3DActor->SetShrinkFactor(theValue);
1146 my3DExtActor->SetShrinkFactor(theValue);
1147 my3DExtActor->SetShrinkFactor(theValue);
1148 myHighlitableActor->SetShrinkFactor(theValue);
1153 void SMESH_ActorDef::SetShrink(){
1154 if(!myIsShrinkable) return;
1156 myBaseActor->SetShrink();
1158 my1DActor->SetShrink();
1159 my1DExtActor->SetShrink();
1161 my2DActor->SetShrink();
1162 my2DExtActor->SetShrink();
1163 my3DActor->SetShrink();
1164 my3DExtActor->SetShrink();
1165 myHighlitableActor->SetShrink();
1171 void SMESH_ActorDef::UnShrink(){
1172 if(!myIsShrunk) return;
1174 myBaseActor->UnShrink();
1176 my1DActor->UnShrink();
1177 my1DExtActor->UnShrink();
1179 my2DActor->UnShrink();
1180 my2DExtActor->UnShrink();
1181 my3DActor->UnShrink();
1182 my3DExtActor->UnShrink();
1183 myHighlitableActor->UnShrink();
1190 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1191 return myPickableActor->GetNodeObjId(theVtkID);
1194 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1195 return myPickableActor->GetNodeCoord(theObjID);
1199 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1200 return myPickableActor->GetElemObjId(theVtkID);
1203 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1204 return myPickableActor->GetElemCell(theObjID);
1208 void SMESH_ActorDef::SetVisibility(int theMode){
1209 SetVisibility(theMode,true);
1213 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1214 SALOME_Actor::SetVisibility(theMode);
1216 myNodeActor->VisibilityOff();
1217 myBaseActor->VisibilityOff();
1219 myNodeExtActor->VisibilityOff();
1221 my0DActor->VisibilityOff();
1222 //my0DExtActor->VisibilityOff();
1224 my1DActor->VisibilityOff();
1225 my1DExtActor->VisibilityOff();
1227 my2DActor->VisibilityOff();
1228 my2DExtActor->VisibilityOff();
1229 my3DActor->VisibilityOff();
1230 my3DExtActor->VisibilityOff();
1232 myScalarBarActor->VisibilityOff();
1234 if(GetVisibility()){
1235 if(theIsUpdateRepersentation)
1236 SetRepresentation(GetRepresentation());
1238 if(myControlMode != eNone){
1239 switch(myControlMode){
1241 case eCoincidentNodes:
1242 myNodeExtActor->VisibilityOn();
1246 case eCoincidentElems1D:
1247 my1DExtActor->VisibilityOn();
1250 case eBareBorderFace:
1251 case eOverConstrainedFace:
1252 case eCoincidentElems2D:
1253 my2DExtActor->VisibilityOn();
1255 case eBareBorderVolume:
1256 case eOverConstrainedVolume:
1257 case eCoincidentElems3D:
1258 my3DExtActor->VisibilityOn();
1261 case eMultiConnection2D:
1262 my1DExtActor->VisibilityOn();
1264 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1265 myScalarBarActor->VisibilityOn();
1269 if(myRepresentation != ePoint)
1270 myPickableActor->VisibilityOn();
1272 myNodeActor->VisibilityOn();
1275 if(myEntityMode & e0DElements){
1276 my0DActor->VisibilityOn();
1279 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1280 my1DActor->VisibilityOn();
1283 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1284 my2DActor->VisibilityOn();
1287 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1288 my3DActor->VisibilityOn();
1291 if(myNodeActor->GetPointsLabeled()){
1292 myNodeActor->VisibilityOn();
1296 my0DActor->UpdateLabels();
1299 my1DActor->UpdateLabels();
1302 my2DActor->UpdateLabels();
1305 my3DActor->UpdateLabels();
1307 #ifndef DISABLE_PLOT2DVIEWER
1309 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1316 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1318 myEntityState = eAllEntity;
1320 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1321 myEntityState &= ~e0DElements;
1322 theMode &= ~e0DElements;
1325 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1326 myEntityState &= ~eEdges;
1330 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1331 myEntityState &= ~eFaces;
1335 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1336 myEntityState &= ~eVolumes;
1337 theMode &= ~eVolumes;
1341 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1342 theMode |= e0DElements;
1344 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1347 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1350 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1351 theMode |= eVolumes;
1354 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1356 myEntityMode = theMode;
1357 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1358 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1359 aFilter->ClearRegisteredCellsWithType();
1360 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1362 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1363 aHightFilter->ClearRegisteredCellsWithType();
1364 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1366 if (myEntityMode & e0DElements) {
1367 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1368 aFilter->RegisterCellsWithType(VTK_VERTEX);
1369 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1372 if (myEntityMode & eEdges) {
1373 if (MYDEBUG) MESSAGE("EDGES");
1374 aFilter->RegisterCellsWithType(VTK_LINE);
1375 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1377 aHightFilter->RegisterCellsWithType(VTK_LINE);
1378 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1381 if (myEntityMode & eFaces) {
1382 if (MYDEBUG) MESSAGE("FACES");
1383 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1384 aFilter->RegisterCellsWithType(VTK_POLYGON);
1385 aFilter->RegisterCellsWithType(VTK_QUAD);
1386 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1387 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1388 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1390 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1391 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1392 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1393 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1394 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1395 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1398 if (myEntityMode & eVolumes) {
1399 if (MYDEBUG) MESSAGE("VOLUMES");
1400 aFilter->RegisterCellsWithType(VTK_TETRA);
1401 aFilter->RegisterCellsWithType(VTK_VOXEL);
1402 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1403 aFilter->RegisterCellsWithType(VTK_WEDGE);
1404 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1405 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1406 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1407 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1408 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1409 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1410 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1411 //#ifdef VTK_HAVE_POLYHEDRON
1412 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1415 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1416 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1417 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1418 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1419 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1420 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1421 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1422 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1423 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1424 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1425 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1426 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1427 //#ifdef VTK_HAVE_POLYHEDRON
1428 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1432 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1433 SetVisibility(GetVisibility(),false);
1436 void SMESH_ActorDef::SetRepresentation (int theMode)
1438 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1439 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1440 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1443 myRepresentation = eSurface;
1444 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1445 myRepresentation = eEdge;
1446 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1447 myRepresentation = ePoint;
1452 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1455 if (!aNbFaces && !aNbVolumes) return;
1458 myRepresentation = theMode;
1461 if (!GetUnstructuredGrid()->GetNumberOfCells())
1462 myRepresentation = ePoint;
1465 if (myRepresentation == ePoint) {
1473 myPickableActor = myBaseActor;
1474 myNodeActor->SetVisibility(false);
1475 myNodeExtActor->SetVisibility(false);
1476 vtkProperty *aProp = NULL, *aBackProp = NULL;
1477 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1478 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1479 switch (myRepresentation) {
1481 myPickableActor = myNodeActor;
1482 myNodeActor->SetVisibility(true);
1483 aQuadraticMode = SMESH_Actor::eLines;
1484 aProp = aBackProp = myNodeProp;
1485 aReperesent = SMESH_DeviceActor::ePoint;
1488 aProp = aBackProp = myEdgeProp;
1489 aReperesent = SMESH_DeviceActor::eInsideframe;
1492 aProp = mySurfaceProp;
1493 aBackProp = myBackSurfaceProp;
1494 aReperesent = SMESH_DeviceActor::eSurface;
1498 my2DActor->SetProperty(aProp);
1499 my2DActor->SetBackfaceProperty(aBackProp);
1500 my2DActor->SetRepresentation(aReperesent);
1502 if(aQuadraticMode == SMESH_Actor::eLines)
1503 my2DActor->SetQuadraticArcMode(false);
1504 else if(aQuadraticMode == SMESH_Actor::eArcs)
1505 my2DActor->SetQuadraticArcMode(true);
1507 my2DExtActor->SetRepresentation(aReperesent);
1509 my3DActor->SetProperty(aProp);
1510 my3DActor->SetBackfaceProperty(aBackProp);
1511 my3DActor->SetRepresentation(aReperesent);
1513 //my0DExtActor->SetVisibility(false);
1514 my1DExtActor->SetVisibility(false);
1515 my2DExtActor->SetVisibility(false);
1516 my3DExtActor->SetVisibility(false);
1519 //my0DActor->SetProperty(aProp);
1520 //my0DActor->SetBackfaceProperty(aBackProp);
1521 my0DActor->SetRepresentation(aReperesent);
1522 //my0DExtActor->SetRepresentation(aReperesent);
1524 switch(myControlMode){
1526 case eMultiConnection:
1527 aProp = aBackProp = my1DProp;
1528 if(myRepresentation != ePoint)
1529 aReperesent = SMESH_DeviceActor::eInsideframe;
1533 if(aQuadraticMode == SMESH_Actor::eLines)
1534 my1DActor->SetQuadraticArcMode(false);
1535 else if(aQuadraticMode == SMESH_Actor::eArcs)
1536 my1DActor->SetQuadraticArcMode(true);
1538 my1DActor->SetProperty(aProp);
1539 my1DActor->SetBackfaceProperty(aBackProp);
1540 my1DActor->SetRepresentation(aReperesent);
1542 my1DExtActor->SetRepresentation(aReperesent);
1544 if(myIsPointsVisible)
1545 myPickableActor = myNodeActor;
1546 if(GetPointRepresentation())
1547 myNodeActor->SetVisibility(true);
1549 SetMapper(myPickableActor->GetMapper());
1551 SetVisibility(GetVisibility(),false);
1557 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1558 if ( myIsPointsVisible == theIsPointsVisible )
1560 myIsPointsVisible = theIsPointsVisible;
1561 SetRepresentation(GetRepresentation());
1564 bool SMESH_ActorDef::GetPointRepresentation(){
1565 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1569 void SMESH_ActorDef::UpdateHighlight(){
1570 myHighlitableActor->SetHighlited(false);
1571 myHighlitableActor->SetVisibility(false);
1573 bool anIsVisible = GetVisibility();
1575 switch(myRepresentation){
1576 case SMESH_DeviceActor::eSurface:
1577 case SMESH_DeviceActor::eWireframe:
1579 if(myIsHighlighted) {
1580 myHighlitableActor->SetProperty(myHighlightProp);
1581 }else if(myIsPreselected){
1582 myHighlitableActor->SetProperty(myPreselectProp);
1583 } else if(anIsVisible){
1584 (myRepresentation == eSurface) ?
1585 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1587 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1588 myHighlitableActor->SetHighlited(anIsVisible);
1589 myHighlitableActor->GetExtractUnstructuredGrid()->
1590 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1591 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1593 myHighlitableActor->SetVisibility(anIsVisible);
1596 case SMESH_DeviceActor::ePoint:
1598 if(myIsHighlighted) {
1599 myNodeActor->SetProperty(myHighlightProp);
1600 }else if(myIsPreselected) {
1601 myNodeActor->SetProperty(myPreselectProp);
1602 } else if(anIsVisible) {
1603 myNodeActor->SetProperty(myNodeProp);
1605 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1606 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1613 void SMESH_ActorDef::highlight(bool theHighlight){
1614 if ( myIsHighlighted == theHighlight )
1616 myIsHighlighted = theHighlight;
1621 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1622 if ( myIsPreselected == thePreselect )
1624 myIsPreselected = thePreselect;
1630 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1632 if (myPickableActor->GetIsOpaque())
1634 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1642 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1644 if (!myPickableActor->GetIsOpaque())
1646 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1654 void SMESH_ActorDef::Render(vtkRenderer *ren){
1655 unsigned long aTime = myTimeStamp->GetMTime();
1656 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1657 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1658 if(anObjTime > aTime || aClippingTime > aTime)
1663 void SMESH_ActorDef::Update(){
1664 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1666 if(GetControlMode() != eNone) {
1667 unsigned long aTime = myTimeStamp->GetMTime();
1668 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1669 if (anObjTime > aTime)
1670 SetControlMode(GetControlMode(),false);
1674 myNodeActor->UpdateLabels();
1677 my0DActor->UpdateLabels();
1680 my1DActor->UpdateLabels();
1683 my2DActor->UpdateLabels();
1686 my3DActor->UpdateLabels();
1688 if(myIsFacesOriented){
1689 SetFacesOriented(myIsFacesOriented);
1692 if(myVisualObj->GetEntitiesFlag()) {
1693 myEntityMode |= myVisualObj->GetEntitiesState();
1696 SetEntityMode(GetEntityMode());
1697 SetVisibility(GetVisibility());
1699 myTimeStamp->Modified();
1704 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1705 SALOME_Actor::ReleaseGraphicsResources(renWin);
1707 myPickableActor->ReleaseGraphicsResources(renWin);
1711 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1712 vtkFloatingPointType* aColor = theProperty->GetColor();
1719 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1720 mySurfaceProp->SetOpacity(theValue);
1721 myBackSurfaceProp->SetOpacity(theValue);
1722 myEdgeProp->SetOpacity(theValue);
1723 myNodeProp->SetOpacity(theValue);
1725 my1DProp->SetOpacity(theValue);
1729 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1730 return mySurfaceProp->GetOpacity();
1734 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1735 mySurfaceProp->SetColor(r,g,b);
1736 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1737 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1738 aGroupObj->GetElementType() == SMDSAbs_Volume )
1739 myNameActor->SetBackgroundColor(r,g,b);
1741 myDeltaBrightness = delta;
1742 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1743 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1747 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1748 ::GetColor(mySurfaceProp,r,g,b);
1749 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1750 delta = myDeltaBrightness;
1753 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1754 myEdgeProp->SetColor(r,g,b);
1755 my1DProp->SetColor(r,g,b);
1756 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1757 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1758 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1759 myNameActor->SetBackgroundColor(r,g,b);
1763 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1764 ::GetColor(myEdgeProp,r,g,b);
1767 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1768 myOutLineProp->SetColor(r,g,b);
1772 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1773 ::GetColor(myOutLineProp,r,g,b);
1777 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1778 myNodeProp->SetColor(r,g,b);
1779 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1780 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1781 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1782 myNameActor->SetBackgroundColor(r,g,b);
1786 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1787 ::GetColor(myNodeProp,r,g,b);
1790 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1791 my0DProp->SetColor(r,g,b);
1792 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1793 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1794 myNameActor->SetBackgroundColor(r,g,b);
1798 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1799 ::GetColor(my0DProp,r,g,b);
1802 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1803 myHighlightProp->SetColor(r,g,b);
1807 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1808 ::GetColor(myHighlightProp,r,g,b);
1811 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1812 myPreselectProp->SetColor(r,g,b);
1816 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1817 ::GetColor(myPreselectProp,r,g,b);
1821 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1822 return myEdgeProp->GetLineWidth();
1826 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1827 myEdgeProp->SetLineWidth(theVal);
1829 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1830 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1831 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
1832 myOutLineProp->SetLineWidth(theVal);
1833 myHighlightProp->SetLineWidth(theVal);
1834 myPreselectProp->SetLineWidth(theVal);
1839 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1840 my0DProp->SetPointSize(theVal);
1844 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1845 return my0DProp->GetPointSize();
1848 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1850 return myVisualObj->GetElemDimension( theObjId );
1855 IsImplicitFunctionUsed() const
1857 return myBaseActor->IsImplicitFunctionUsed();
1861 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1863 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1864 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1866 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1868 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1870 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1871 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1873 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1874 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1876 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1877 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1878 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1879 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1883 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1886 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1887 myCippingPlaneCont.push_back(thePlane);
1888 if(!IsImplicitFunctionUsed())
1889 SetImplicitFunctionUsed(true);
1890 myNodeActor->UpdateLabels();
1892 return myCippingPlaneCont.size();
1897 RemoveAllClippingPlanes()
1899 myImplicitBoolean->GetFunction()->RemoveAllItems();
1900 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1901 myCippingPlaneCont.clear();
1902 SetImplicitFunctionUsed(false);
1903 myNodeActor->UpdateLabels();
1908 GetNumberOfClippingPlanes()
1910 return myCippingPlaneCont.size();
1915 GetClippingPlane(vtkIdType theID)
1917 if(theID >= myCippingPlaneCont.size())
1919 return myCippingPlaneCont[theID].Get();
1922 void SMESH_ActorDef::UpdateScalarBar()
1924 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1928 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1930 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1931 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1933 aScalarBarTitleProp->SetFontFamilyToArial();
1935 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1937 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1938 if ( f.family() == "Arial" )
1939 aScalarBarTitleProp->SetFontFamilyToArial();
1940 else if ( f.family() == "Courier" )
1941 aScalarBarTitleProp->SetFontFamilyToCourier();
1942 else if ( f.family() == "Times" )
1943 aScalarBarTitleProp->SetFontFamilyToTimes();
1946 aScalarBarTitleProp->BoldOn();
1948 aScalarBarTitleProp->BoldOff();
1951 aScalarBarTitleProp->ItalicOn();
1953 aScalarBarTitleProp->ItalicOff();
1956 aScalarBarTitleProp->ShadowOn();
1958 aScalarBarTitleProp->ShadowOff();
1961 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1962 aScalarBarTitleProp->Delete();
1964 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1966 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1967 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1969 aScalarBarLabelProp->SetFontFamilyToArial();
1970 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1972 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1973 if( f.family() == "Arial" )
1974 aScalarBarLabelProp->SetFontFamilyToArial();
1975 else if( f.family() == "Courier" )
1976 aScalarBarLabelProp->SetFontFamilyToCourier();
1977 else if( f.family() == "Times" )
1978 aScalarBarLabelProp->SetFontFamilyToTimes();
1981 aScalarBarLabelProp->BoldOn();
1983 aScalarBarLabelProp->BoldOff();
1986 aScalarBarLabelProp->ItalicOn();
1988 aScalarBarLabelProp->ItalicOff();
1991 aScalarBarLabelProp->ShadowOn();
1993 aScalarBarLabelProp->ShadowOff();
1996 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1997 aScalarBarLabelProp->Delete();
1999 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
2000 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2002 myScalarBarActor->SetOrientationToHorizontal();
2004 myScalarBarActor->SetOrientationToVertical();
2007 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2008 if( mgr->hasValue( "SMESH", name + "x" ) )
2009 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2011 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2012 if( mgr->hasValue( "SMESH", name + "y" ) )
2013 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2014 myScalarBarActor->SetPosition( aXVal, aYVal );
2016 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2017 if( mgr->hasValue( "SMESH", name + "width" ) )
2018 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2019 myScalarBarActor->SetWidth( aWVal );
2021 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2022 if( mgr->hasValue( "SMESH", name + "height" ) )
2023 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2024 myScalarBarActor->SetHeight( aHVal );
2027 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2028 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2029 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2032 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2033 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2034 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2036 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2037 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2039 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2040 myScalarBarActor->SetDistributionColoringType(coloringType);
2042 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2043 QColor(255, 255, 255));
2045 rgb[0]= distributionColor.red()/255.;
2046 rgb[1]= distributionColor.green()/255.;
2047 rgb[2]= distributionColor.blue()/255.;
2048 myScalarBarActor->SetDistributionColor(rgb);
2053 void SMESH_ActorDef::UpdateDistribution()
2055 if(SMESH::Controls::NumericalFunctor* fun =
2056 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2058 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2059 std::vector<int> nbEvents;
2060 std::vector<double> funValues;
2061 SMESH_VisualObjDef::TEntityList elems;
2062 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2063 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2064 std::vector<int> elemIds;
2065 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2066 elemIds.push_back( (*e)->GetID());
2067 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2068 double * range = lookupTable->GetRange();
2069 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2070 myScalarBarActor->SetDistribution(nbEvents);
2074 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2077 case SMESH_Actor::eLines :
2078 myHighlitableActor->SetQuadraticArcMode(false);
2079 my2DActor->SetQuadraticArcMode(false);
2080 my1DActor->SetQuadraticArcMode(false);
2082 case SMESH_Actor::eArcs :
2083 myHighlitableActor->SetQuadraticArcMode(true);
2084 if(GetRepresentation() != SMESH_Actor::ePoint) {
2085 my2DActor->SetQuadraticArcMode(true);
2086 my1DActor->SetQuadraticArcMode(true);
2095 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2097 if(myHighlitableActor->GetQuadraticArcMode())
2098 return SMESH_Actor::eArcs;
2100 return SMESH_Actor::eLines;
2103 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2105 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2106 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2107 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2110 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2112 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2113 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2114 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2115 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2118 #ifndef DISABLE_PLOT2DVIEWER
2119 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2122 my2dHistogram->clearAllPoints();
2124 if(SMESH::Controls::NumericalFunctor* fun =
2125 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2128 if(!my2dHistogram) {
2129 my2dHistogram = new SPlot2d_Histogram();
2130 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2131 my2dHistogram->setIO(anIO);
2134 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2135 std::vector<int> nbEvents;
2136 std::vector<double> funValues;
2137 SMESH_VisualObjDef::TEntityList elems;
2138 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2139 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2140 std::vector<int> elemIds;
2142 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2143 elemIds.push_back( (*e)->GetID());
2145 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2146 double * range = lookupTable->GetRange();
2147 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2149 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2150 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2152 if(funValues.size() >= 2)
2153 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2157 //Color of the histogram
2158 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2159 my2dHistogram->setAutoAssign(true);
2162 myScalarBarActor->GetDistributionColor(rgb);
2163 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2164 my2dHistogram->setColor(aColor);
2168 return my2dHistogram;