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:
1248 case eMultiConnection2D:
1249 my1DExtActor->VisibilityOn();
1252 case eBareBorderFace:
1253 case eOverConstrainedFace:
1254 case eCoincidentElems2D:
1255 my2DExtActor->VisibilityOn();
1257 case eBareBorderVolume:
1258 case eOverConstrainedVolume:
1259 case eCoincidentElems3D:
1260 my3DExtActor->VisibilityOn();
1263 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1264 myScalarBarActor->VisibilityOn();
1268 if(myRepresentation != ePoint)
1269 myPickableActor->VisibilityOn();
1271 myNodeActor->VisibilityOn();
1274 if(myEntityMode & e0DElements){
1275 my0DActor->VisibilityOn();
1278 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1279 my1DActor->VisibilityOn();
1282 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1283 my2DActor->VisibilityOn();
1286 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1287 my3DActor->VisibilityOn();
1290 if(myNodeActor->GetPointsLabeled()){
1291 myNodeActor->VisibilityOn();
1295 my0DActor->UpdateLabels();
1298 my1DActor->UpdateLabels();
1301 my2DActor->UpdateLabels();
1304 my3DActor->UpdateLabels();
1306 #ifndef DISABLE_PLOT2DVIEWER
1308 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1315 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1317 myEntityState = eAllEntity;
1319 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1320 myEntityState &= ~e0DElements;
1321 theMode &= ~e0DElements;
1324 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1325 myEntityState &= ~eEdges;
1329 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1330 myEntityState &= ~eFaces;
1334 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1335 myEntityState &= ~eVolumes;
1336 theMode &= ~eVolumes;
1340 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1341 theMode |= e0DElements;
1343 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1346 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1349 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1350 theMode |= eVolumes;
1353 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1355 myEntityMode = theMode;
1356 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1357 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1358 aFilter->ClearRegisteredCellsWithType();
1359 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1361 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1362 aHightFilter->ClearRegisteredCellsWithType();
1363 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1365 if (myEntityMode & e0DElements) {
1366 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1367 aFilter->RegisterCellsWithType(VTK_VERTEX);
1368 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1371 if (myEntityMode & eEdges) {
1372 if (MYDEBUG) MESSAGE("EDGES");
1373 aFilter->RegisterCellsWithType(VTK_LINE);
1374 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1376 aHightFilter->RegisterCellsWithType(VTK_LINE);
1377 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1380 if (myEntityMode & eFaces) {
1381 if (MYDEBUG) MESSAGE("FACES");
1382 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1383 aFilter->RegisterCellsWithType(VTK_POLYGON);
1384 aFilter->RegisterCellsWithType(VTK_QUAD);
1385 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1386 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1387 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1389 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1390 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1391 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1392 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1393 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1394 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1397 if (myEntityMode & eVolumes) {
1398 if (MYDEBUG) MESSAGE("VOLUMES");
1399 aFilter->RegisterCellsWithType(VTK_TETRA);
1400 aFilter->RegisterCellsWithType(VTK_VOXEL);
1401 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1402 aFilter->RegisterCellsWithType(VTK_WEDGE);
1403 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1404 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1405 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1406 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1407 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1408 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1409 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1410 //#ifdef VTK_HAVE_POLYHEDRON
1411 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1414 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1415 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1416 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1417 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1418 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1419 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1420 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1421 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1422 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1423 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1424 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1425 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1426 //#ifdef VTK_HAVE_POLYHEDRON
1427 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1431 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1432 SetVisibility(GetVisibility(),false);
1435 void SMESH_ActorDef::SetRepresentation (int theMode)
1437 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1438 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1439 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1442 myRepresentation = eSurface;
1443 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1444 myRepresentation = eEdge;
1445 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1446 myRepresentation = ePoint;
1451 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1454 if (!aNbFaces && !aNbVolumes) return;
1457 myRepresentation = theMode;
1460 if (!GetUnstructuredGrid()->GetNumberOfCells())
1461 myRepresentation = ePoint;
1464 if (myRepresentation == ePoint) {
1472 myPickableActor = myBaseActor;
1473 myNodeActor->SetVisibility(false);
1474 myNodeExtActor->SetVisibility(false);
1475 vtkProperty *aProp = NULL, *aBackProp = NULL;
1476 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1477 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1478 switch (myRepresentation) {
1480 myPickableActor = myNodeActor;
1481 myNodeActor->SetVisibility(true);
1482 aQuadraticMode = SMESH_Actor::eLines;
1483 aProp = aBackProp = myNodeProp;
1484 aReperesent = SMESH_DeviceActor::ePoint;
1487 aProp = aBackProp = myEdgeProp;
1488 aReperesent = SMESH_DeviceActor::eInsideframe;
1491 aProp = mySurfaceProp;
1492 aBackProp = myBackSurfaceProp;
1493 aReperesent = SMESH_DeviceActor::eSurface;
1497 my2DActor->SetProperty(aProp);
1498 my2DActor->SetBackfaceProperty(aBackProp);
1499 my2DActor->SetRepresentation(aReperesent);
1501 if(aQuadraticMode == SMESH_Actor::eLines)
1502 my2DActor->SetQuadraticArcMode(false);
1503 else if(aQuadraticMode == SMESH_Actor::eArcs)
1504 my2DActor->SetQuadraticArcMode(true);
1506 my2DExtActor->SetRepresentation(aReperesent);
1508 my3DActor->SetProperty(aProp);
1509 my3DActor->SetBackfaceProperty(aBackProp);
1510 my3DActor->SetRepresentation(aReperesent);
1512 //my0DExtActor->SetVisibility(false);
1513 my1DExtActor->SetVisibility(false);
1514 my2DExtActor->SetVisibility(false);
1515 my3DExtActor->SetVisibility(false);
1518 //my0DActor->SetProperty(aProp);
1519 //my0DActor->SetBackfaceProperty(aBackProp);
1520 my0DActor->SetRepresentation(aReperesent);
1521 //my0DExtActor->SetRepresentation(aReperesent);
1523 switch(myControlMode){
1525 case eMultiConnection:
1526 aProp = aBackProp = my1DProp;
1527 if(myRepresentation != ePoint)
1528 aReperesent = SMESH_DeviceActor::eInsideframe;
1532 if(aQuadraticMode == SMESH_Actor::eLines)
1533 my1DActor->SetQuadraticArcMode(false);
1534 else if(aQuadraticMode == SMESH_Actor::eArcs)
1535 my1DActor->SetQuadraticArcMode(true);
1537 my1DActor->SetProperty(aProp);
1538 my1DActor->SetBackfaceProperty(aBackProp);
1539 my1DActor->SetRepresentation(aReperesent);
1541 my1DExtActor->SetRepresentation(aReperesent);
1543 if(myIsPointsVisible)
1544 myPickableActor = myNodeActor;
1545 if(GetPointRepresentation())
1546 myNodeActor->SetVisibility(true);
1548 SetMapper(myPickableActor->GetMapper());
1550 SetVisibility(GetVisibility(),false);
1556 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1557 if ( myIsPointsVisible == theIsPointsVisible )
1559 myIsPointsVisible = theIsPointsVisible;
1560 SetRepresentation(GetRepresentation());
1563 bool SMESH_ActorDef::GetPointRepresentation(){
1564 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1568 void SMESH_ActorDef::UpdateHighlight(){
1569 myHighlitableActor->SetHighlited(false);
1570 myHighlitableActor->SetVisibility(false);
1572 bool anIsVisible = GetVisibility();
1574 switch(myRepresentation){
1575 case SMESH_DeviceActor::eSurface:
1576 case SMESH_DeviceActor::eWireframe:
1578 if(myIsHighlighted) {
1579 myHighlitableActor->SetProperty(myHighlightProp);
1580 }else if(myIsPreselected){
1581 myHighlitableActor->SetProperty(myPreselectProp);
1582 } else if(anIsVisible){
1583 (myRepresentation == eSurface) ?
1584 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1586 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1587 myHighlitableActor->SetHighlited(anIsVisible);
1588 myHighlitableActor->GetExtractUnstructuredGrid()->
1589 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1590 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1592 myHighlitableActor->SetVisibility(anIsVisible);
1595 case SMESH_DeviceActor::ePoint:
1597 if(myIsHighlighted) {
1598 myNodeActor->SetProperty(myHighlightProp);
1599 }else if(myIsPreselected) {
1600 myNodeActor->SetProperty(myPreselectProp);
1601 } else if(anIsVisible) {
1602 myNodeActor->SetProperty(myNodeProp);
1604 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1605 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1612 void SMESH_ActorDef::highlight(bool theHighlight){
1613 if ( myIsHighlighted == theHighlight )
1615 myIsHighlighted = theHighlight;
1620 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1621 if ( myIsPreselected == thePreselect )
1623 myIsPreselected = thePreselect;
1629 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1631 if (myPickableActor->GetIsOpaque())
1633 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1641 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1643 if (!myPickableActor->GetIsOpaque())
1645 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1653 void SMESH_ActorDef::Render(vtkRenderer *ren){
1654 unsigned long aTime = myTimeStamp->GetMTime();
1655 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1656 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1657 if(anObjTime > aTime || aClippingTime > aTime)
1662 void SMESH_ActorDef::Update(){
1663 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1665 if(GetControlMode() != eNone) {
1666 unsigned long aTime = myTimeStamp->GetMTime();
1667 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1668 if (anObjTime > aTime)
1669 SetControlMode(GetControlMode(),false);
1673 myNodeActor->UpdateLabels();
1676 my0DActor->UpdateLabels();
1679 my1DActor->UpdateLabels();
1682 my2DActor->UpdateLabels();
1685 my3DActor->UpdateLabels();
1687 if(myIsFacesOriented){
1688 SetFacesOriented(myIsFacesOriented);
1691 if(myVisualObj->GetEntitiesFlag()) {
1692 myEntityMode |= myVisualObj->GetEntitiesState();
1695 SetEntityMode(GetEntityMode());
1696 SetVisibility(GetVisibility());
1698 myTimeStamp->Modified();
1703 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1704 SALOME_Actor::ReleaseGraphicsResources(renWin);
1706 myPickableActor->ReleaseGraphicsResources(renWin);
1710 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1711 vtkFloatingPointType* aColor = theProperty->GetColor();
1718 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1719 mySurfaceProp->SetOpacity(theValue);
1720 myBackSurfaceProp->SetOpacity(theValue);
1721 myEdgeProp->SetOpacity(theValue);
1722 myNodeProp->SetOpacity(theValue);
1724 my1DProp->SetOpacity(theValue);
1728 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1729 return mySurfaceProp->GetOpacity();
1733 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1734 mySurfaceProp->SetColor(r,g,b);
1735 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1736 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1737 aGroupObj->GetElementType() == SMDSAbs_Volume )
1738 myNameActor->SetBackgroundColor(r,g,b);
1740 myDeltaBrightness = delta;
1741 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1742 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1746 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1747 ::GetColor(mySurfaceProp,r,g,b);
1748 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1749 delta = myDeltaBrightness;
1752 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1753 myEdgeProp->SetColor(r,g,b);
1754 my1DProp->SetColor(r,g,b);
1755 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1756 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1757 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1758 myNameActor->SetBackgroundColor(r,g,b);
1762 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1763 ::GetColor(myEdgeProp,r,g,b);
1766 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1767 myOutLineProp->SetColor(r,g,b);
1771 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1772 ::GetColor(myOutLineProp,r,g,b);
1776 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1777 myNodeProp->SetColor(r,g,b);
1778 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1779 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1780 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1781 myNameActor->SetBackgroundColor(r,g,b);
1785 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1786 ::GetColor(myNodeProp,r,g,b);
1789 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1790 my0DProp->SetColor(r,g,b);
1791 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1792 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1793 myNameActor->SetBackgroundColor(r,g,b);
1797 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1798 ::GetColor(my0DProp,r,g,b);
1801 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1802 myHighlightProp->SetColor(r,g,b);
1806 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1807 ::GetColor(myHighlightProp,r,g,b);
1810 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1811 myPreselectProp->SetColor(r,g,b);
1815 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1816 ::GetColor(myPreselectProp,r,g,b);
1820 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1821 return myEdgeProp->GetLineWidth();
1825 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1826 myEdgeProp->SetLineWidth(theVal);
1828 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1829 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1830 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
1831 myOutLineProp->SetLineWidth(theVal);
1832 myHighlightProp->SetLineWidth(theVal);
1833 myPreselectProp->SetLineWidth(theVal);
1838 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1839 my0DProp->SetPointSize(theVal);
1843 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1844 return my0DProp->GetPointSize();
1847 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1849 return myVisualObj->GetElemDimension( theObjId );
1854 IsImplicitFunctionUsed() const
1856 return myBaseActor->IsImplicitFunctionUsed();
1860 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1862 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1863 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1865 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1867 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1869 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1870 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1872 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1873 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1875 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1876 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1877 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1878 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1882 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1885 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1886 myCippingPlaneCont.push_back(thePlane);
1887 if(!IsImplicitFunctionUsed())
1888 SetImplicitFunctionUsed(true);
1889 myNodeActor->UpdateLabels();
1891 return myCippingPlaneCont.size();
1896 RemoveAllClippingPlanes()
1898 myImplicitBoolean->GetFunction()->RemoveAllItems();
1899 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1900 myCippingPlaneCont.clear();
1901 SetImplicitFunctionUsed(false);
1902 myNodeActor->UpdateLabels();
1907 GetNumberOfClippingPlanes()
1909 return myCippingPlaneCont.size();
1914 GetClippingPlane(vtkIdType theID)
1916 if(theID >= myCippingPlaneCont.size())
1918 return myCippingPlaneCont[theID].Get();
1921 void SMESH_ActorDef::UpdateScalarBar()
1923 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1927 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1929 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1930 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1932 aScalarBarTitleProp->SetFontFamilyToArial();
1934 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1936 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1937 if ( f.family() == "Arial" )
1938 aScalarBarTitleProp->SetFontFamilyToArial();
1939 else if ( f.family() == "Courier" )
1940 aScalarBarTitleProp->SetFontFamilyToCourier();
1941 else if ( f.family() == "Times" )
1942 aScalarBarTitleProp->SetFontFamilyToTimes();
1945 aScalarBarTitleProp->BoldOn();
1947 aScalarBarTitleProp->BoldOff();
1950 aScalarBarTitleProp->ItalicOn();
1952 aScalarBarTitleProp->ItalicOff();
1955 aScalarBarTitleProp->ShadowOn();
1957 aScalarBarTitleProp->ShadowOff();
1960 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1961 aScalarBarTitleProp->Delete();
1963 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1965 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1966 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1968 aScalarBarLabelProp->SetFontFamilyToArial();
1969 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1971 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1972 if( f.family() == "Arial" )
1973 aScalarBarLabelProp->SetFontFamilyToArial();
1974 else if( f.family() == "Courier" )
1975 aScalarBarLabelProp->SetFontFamilyToCourier();
1976 else if( f.family() == "Times" )
1977 aScalarBarLabelProp->SetFontFamilyToTimes();
1980 aScalarBarLabelProp->BoldOn();
1982 aScalarBarLabelProp->BoldOff();
1985 aScalarBarLabelProp->ItalicOn();
1987 aScalarBarLabelProp->ItalicOff();
1990 aScalarBarLabelProp->ShadowOn();
1992 aScalarBarLabelProp->ShadowOff();
1995 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1996 aScalarBarLabelProp->Delete();
1998 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1999 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
2001 myScalarBarActor->SetOrientationToHorizontal();
2003 myScalarBarActor->SetOrientationToVertical();
2006 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
2007 if( mgr->hasValue( "SMESH", name + "x" ) )
2008 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2010 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2011 if( mgr->hasValue( "SMESH", name + "y" ) )
2012 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2013 myScalarBarActor->SetPosition( aXVal, aYVal );
2015 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2016 if( mgr->hasValue( "SMESH", name + "width" ) )
2017 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2018 myScalarBarActor->SetWidth( aWVal );
2020 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2021 if( mgr->hasValue( "SMESH", name + "height" ) )
2022 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2023 myScalarBarActor->SetHeight( aHVal );
2026 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2027 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2028 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2031 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2032 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2033 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2035 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2036 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2038 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2039 myScalarBarActor->SetDistributionColoringType(coloringType);
2041 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2042 QColor(255, 255, 255));
2044 rgb[0]= distributionColor.red()/255.;
2045 rgb[1]= distributionColor.green()/255.;
2046 rgb[2]= distributionColor.blue()/255.;
2047 myScalarBarActor->SetDistributionColor(rgb);
2052 void SMESH_ActorDef::UpdateDistribution()
2054 if(SMESH::Controls::NumericalFunctor* fun =
2055 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2057 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2058 std::vector<int> nbEvents;
2059 std::vector<double> funValues;
2060 SMESH_VisualObjDef::TEntityList elems;
2061 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2062 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2063 std::vector<int> elemIds;
2064 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2065 elemIds.push_back( (*e)->GetID());
2066 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2067 double * range = lookupTable->GetRange();
2068 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2069 myScalarBarActor->SetDistribution(nbEvents);
2073 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2076 case SMESH_Actor::eLines :
2077 myHighlitableActor->SetQuadraticArcMode(false);
2078 my2DActor->SetQuadraticArcMode(false);
2079 my1DActor->SetQuadraticArcMode(false);
2081 case SMESH_Actor::eArcs :
2082 myHighlitableActor->SetQuadraticArcMode(true);
2083 if(GetRepresentation() != SMESH_Actor::ePoint) {
2084 my2DActor->SetQuadraticArcMode(true);
2085 my1DActor->SetQuadraticArcMode(true);
2094 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2096 if(myHighlitableActor->GetQuadraticArcMode())
2097 return SMESH_Actor::eArcs;
2099 return SMESH_Actor::eLines;
2102 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2104 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2105 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2106 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2109 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2111 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2112 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2113 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2114 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2117 #ifndef DISABLE_PLOT2DVIEWER
2118 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2121 my2dHistogram->clearAllPoints();
2123 if(SMESH::Controls::NumericalFunctor* fun =
2124 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2127 if(!my2dHistogram) {
2128 my2dHistogram = new SPlot2d_Histogram();
2129 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2130 my2dHistogram->setIO(anIO);
2133 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2134 std::vector<int> nbEvents;
2135 std::vector<double> funValues;
2136 SMESH_VisualObjDef::TEntityList elems;
2137 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2138 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2139 std::vector<int> elemIds;
2141 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2142 elemIds.push_back( (*e)->GetID());
2144 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2145 double * range = lookupTable->GetRange();
2146 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2148 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2149 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2151 if(funValues.size() >= 2)
2152 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2156 //Color of the histogram
2157 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2158 my2dHistogram->setAutoAssign(true);
2161 myScalarBarActor->GetDistributionColor(rgb);
2162 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2163 my2dHistogram->setColor(aColor);
2167 return my2dHistogram;