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 // caught by SMESHGUI::ProcessEvents() static method
496 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
498 myScalarBarActor->Delete();
499 myLookupTable->Delete();
501 mySurfaceProp->Delete();
502 myBackSurfaceProp->Delete();
503 myOutLineProp->Delete();
505 myEdgeProp->Delete();
506 myHighlightProp->Delete();
507 myPreselectProp->Delete();
509 myNodeProp->Delete();
510 myNodeExtProp->Delete();
515 //my0DExtProp->Delete();
516 //my0DExtActor->Delete();
521 my1DExtProp->Delete();
522 my1DExtActor->Delete();
525 my2DExtProp->Delete();
526 my2DExtActor->Delete();
528 my3DExtActor->Delete();
530 myNodeActor->Delete();
531 myBaseActor->Delete();
533 myNodeExtActor->Delete();
534 myHighlitableActor->Delete();
536 myImplicitBoolean->Delete();
538 myTimeStamp->Delete();
542 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
545 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
546 SetRepresentation(GetRepresentation());
547 myTimeStamp->Modified();
551 bool SMESH_ActorDef::GetPointsLabeled() {
552 return myNodeActor && myNodeActor->GetPointsLabeled();
555 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
558 my3DActor->SetCellsLabeled(theIsCellsLabeled);
561 my2DActor->SetCellsLabeled(theIsCellsLabeled);
564 my1DActor->SetCellsLabeled(theIsCellsLabeled);
567 my0DActor->SetCellsLabeled(theIsCellsLabeled);
569 myTimeStamp->Modified();
573 bool SMESH_ActorDef::GetCellsLabeled() {
576 result = result || my3DActor->GetCellsLabeled();
579 result = result || my2DActor->GetCellsLabeled();
582 result = result || my1DActor->GetCellsLabeled();
585 result = result || my0DActor->GetCellsLabeled();
591 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
593 myIsFacesOriented = theIsFacesOriented;
595 my2DActor->SetFacesOriented(theIsFacesOriented);
596 my3DActor->SetFacesOriented(theIsFacesOriented);
598 myTimeStamp->Modified();
601 bool SMESH_ActorDef::GetFacesOriented()
603 return myIsFacesOriented;
606 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
608 my2DActor->SetFacesOrientationColor( theColor );
609 my3DActor->SetFacesOrientationColor( theColor );
612 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
614 my3DActor->GetFacesOrientationColor( theColor );
617 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
619 my2DActor->SetFacesOrientationScale( theScale );
620 my3DActor->SetFacesOrientationScale( theScale );
623 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
625 return my3DActor->GetFacesOrientationScale();
628 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
630 my2DActor->SetFacesOrientation3DVectors( theState );
631 my3DActor->SetFacesOrientation3DVectors( theState );
634 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
636 return my3DActor->GetFacesOrientation3DVectors();
642 SetControlMode(eControl theMode)
644 SetControlMode(theMode,true);
650 SetControlMode(eControl theMode,
651 bool theCheckEntityMode)
653 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
657 myControlMode = eNone;
658 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
660 my0DActor->GetMapper()->SetScalarVisibility(false);
661 my1DActor->GetMapper()->SetScalarVisibility(false);
662 my2DActor->GetMapper()->SetScalarVisibility(false);
663 my3DActor->GetMapper()->SetScalarVisibility(false);
664 myScalarBarActor->SetVisibility(false);
666 bool anIsScalarVisible = theMode > eNone;
668 if(anIsScalarVisible) {
672 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
673 aControl->SetPrecision( myControlsPrecision );
674 myFunctor.reset( aControl );
675 myControlActor = my1DActor;
680 myFunctor.reset(new SMESH::Controls::Length2D());
681 myControlActor = my2DActor;
685 myFunctor.reset(new SMESH::Controls::FreeBorders());
686 myControlActor = my1DActor;
689 myFunctor.reset(new SMESH::Controls::FreeEdges());
690 myControlActor = my2DActor;
693 myFunctor.reset(new SMESH::Controls::FreeNodes());
694 myControlActor = myNodeActor;
697 myFunctor.reset(new SMESH::Controls::FreeFaces());
698 myControlActor = my2DActor;
700 case eCoincidentNodes:
702 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
703 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
704 cn->SetTolerance( tol );
706 myControlActor = myNodeActor;
709 case eCoincidentElems1D:
710 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
711 myControlActor = my1DActor;
713 case eCoincidentElems2D:
714 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
715 myControlActor = my2DActor;
717 case eCoincidentElems3D:
718 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
719 myControlActor = my3DActor;
721 case eBareBorderFace:
722 myFunctor.reset(new SMESH::Controls::BareBorderFace());
723 myControlActor = my2DActor;
725 case eOverConstrainedFace:
726 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
727 myControlActor = my2DActor;
729 case eMultiConnection:
730 myFunctor.reset(new SMESH::Controls::MultiConnection());
731 myControlActor = my1DActor;
733 case eMultiConnection2D:
734 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
735 myControlActor = my2DActor;
739 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
740 aControl->SetPrecision( myControlsPrecision );
741 myFunctor.reset( aControl );
742 myControlActor = my2DActor;
747 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
748 aControl->SetPrecision( myControlsPrecision );
749 myFunctor.reset( aControl );
750 myControlActor = my2DActor;
755 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
756 aControl->SetPrecision( myControlsPrecision );
757 myFunctor.reset( aControl );
758 myControlActor = my2DActor;
763 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
764 aControl->SetPrecision( myControlsPrecision );
765 myFunctor.reset( aControl );
766 myControlActor = my3DActor;
771 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
772 aControl->SetPrecision( myControlsPrecision );
773 myFunctor.reset( aControl );
774 myControlActor = my3DActor;
777 case eMaxElementLength2D:
779 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
780 aControl->SetPrecision( myControlsPrecision );
781 myFunctor.reset( aControl );
782 myControlActor = my2DActor;
785 case eMaxElementLength3D:
787 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
788 aControl->SetPrecision( myControlsPrecision );
789 myFunctor.reset( aControl );
790 myControlActor = my3DActor;
793 case eBareBorderVolume:
795 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
796 myControlActor = my3DActor;
799 case eOverConstrainedVolume:
801 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
802 myControlActor = my3DActor;
807 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
808 aControl->SetPrecision( myControlsPrecision );
809 myFunctor.reset( aControl );
810 myControlActor = my2DActor;
815 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
816 aControl->SetPrecision( myControlsPrecision );
817 myFunctor.reset( aControl );
818 myControlActor = my2DActor;
823 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
824 aControl->SetPrecision( myControlsPrecision );
825 myFunctor.reset( aControl );
826 myControlActor = my2DActor;
833 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
834 vtkIdType aNbCells = aGrid->GetNumberOfCells();
836 myControlMode = theMode;
837 switch(myControlMode){
839 case eCoincidentNodes:
840 myNodeExtActor->SetExtControlMode(myFunctor);
844 case eCoincidentElems1D:
845 my1DExtActor->SetExtControlMode(myFunctor);
848 case eBareBorderFace:
849 case eOverConstrainedFace:
850 case eCoincidentElems2D:
851 my2DExtActor->SetExtControlMode(myFunctor);
853 case eBareBorderVolume:
854 case eOverConstrainedVolume:
855 case eCoincidentElems3D:
856 my3DExtActor->SetExtControlMode(myFunctor);
859 case eMultiConnection2D:
860 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
861 UpdateDistribution();
864 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
865 UpdateDistribution();
869 if(theCheckEntityMode) {
870 if(myControlActor == my1DActor) {
871 if (!myIsEntityModeCache){
872 myEntityModeCache = GetEntityMode();
873 myIsEntityModeCache=true;
875 SetEntityMode(eEdges);
877 else if(myControlActor == my2DActor) {
878 switch(myControlMode) {
882 case eMultiConnection2D:
883 if (!myIsEntityModeCache){
884 myEntityModeCache = GetEntityMode();
885 myIsEntityModeCache=true;
887 SetEntityMode(eFaces);
890 if (!myIsEntityModeCache){
891 myEntityModeCache = GetEntityMode();
892 myIsEntityModeCache=true;
894 SetEntityMode(eFaces);
896 }else if(myControlActor == my3DActor) {
897 if (!myIsEntityModeCache){
898 myEntityModeCache = GetEntityMode();
899 myIsEntityModeCache=true;
901 SetEntityMode(eVolumes);
907 if(theCheckEntityMode){
908 myEntityMode = myEntityModeCache;
909 myIsEntityModeCache = false;
914 SetRepresentation(GetRepresentation());
916 myTimeStamp->Modified();
922 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
923 theRenderer->AddActor(myBaseActor);
924 theRenderer->AddActor(myNodeExtActor);
925 theRenderer->AddActor(my1DExtActor);
927 my3DActor->AddToRender(theRenderer);
928 my3DExtActor->AddToRender(theRenderer);
929 my2DActor->AddToRender(theRenderer);
930 my2DExtActor->AddToRender(theRenderer);
931 myNodeActor->AddToRender(theRenderer);
932 my1DActor->AddToRender(theRenderer);
933 my0DActor->AddToRender(theRenderer);
934 //theRenderer->AddActor(my0DExtActor);
936 theRenderer->AddActor(myHighlitableActor);
938 theRenderer->AddActor2D(myScalarBarActor);
940 // the superclass' method should be called at the end
941 // (in particular, for correct work of selection)
942 SALOME_Actor::AddToRender(theRenderer);
945 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
946 SALOME_Actor::RemoveFromRender(theRenderer);
948 theRenderer->RemoveActor(myBaseActor);
950 theRenderer->RemoveActor(myNodeExtActor);
952 theRenderer->RemoveActor(myHighlitableActor);
954 //theRenderer->RemoveActor(my0DExtActor);
956 theRenderer->RemoveActor(my1DExtActor);
958 my2DActor->RemoveFromRender(theRenderer);
959 my2DExtActor->RemoveFromRender(theRenderer);
960 my3DActor->RemoveFromRender(theRenderer);
961 my3DExtActor->RemoveFromRender(theRenderer);
962 myNodeActor->RemoveFromRender(theRenderer);
963 my0DActor->RemoveFromRender(theRenderer);
964 my1DActor->RemoveFromRender(theRenderer);
966 theRenderer->RemoveActor(myScalarBarActor);
970 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
971 const char* theEntry,
975 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
979 myVisualObj = theVisualObj;
980 myVisualObj->Update(theIsClear);
982 myNodeActor->Init(myVisualObj,myImplicitBoolean);
983 myBaseActor->Init(myVisualObj,myImplicitBoolean);
985 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
987 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
989 my0DActor->Init(myVisualObj,myImplicitBoolean);
990 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
992 my1DActor->Init(myVisualObj,myImplicitBoolean);
993 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
995 my2DActor->Init(myVisualObj,myImplicitBoolean);
996 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
997 my3DActor->Init(myVisualObj,myImplicitBoolean);
998 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
1000 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
1001 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1003 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1004 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1006 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1007 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1008 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1009 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1011 vtkFloatingPointType aFactor, aUnits;
1012 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1013 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1014 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1016 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1020 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1021 SetIsShrunkable(true);
1023 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1025 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1026 SetRepresentation(-1);
1029 SetRepresentation(eEdge);
1030 }else if(aMode == 1){
1031 SetRepresentation(eSurface);
1032 }else if(aMode == 2){
1033 SetRepresentation(ePoint);
1040 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1041 SetIsDisplayNameActor( true );
1043 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1044 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1045 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1047 myTimeStamp->Modified();
1053 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1054 return myNodeActor->GetBounds();
1058 vtkDataSet* SMESH_ActorDef::GetInput(){
1059 return GetUnstructuredGrid();
1063 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1064 Superclass::SetTransform(theTransform);
1066 myNodeActor->SetTransform(theTransform);
1067 myBaseActor->SetTransform(theTransform);
1069 myHighlitableActor->SetTransform(theTransform);
1071 myNodeExtActor->SetTransform(theTransform);
1073 my0DActor->SetTransform(theTransform);
1074 //my0DExtActor->SetTransform(theTransform);
1076 my1DActor->SetTransform(theTransform);
1077 my1DExtActor->SetTransform(theTransform);
1079 my2DActor->SetTransform(theTransform);
1080 my2DExtActor->SetTransform(theTransform);
1081 my3DActor->SetTransform(theTransform);
1082 my3DExtActor->SetTransform(theTransform);
1088 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1089 vtkLODActor::SetMapper(theMapper);
1093 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1094 SALOME_Actor::ShallowCopy(prop);
1098 vtkMapper* SMESH_ActorDef::GetMapper(){
1099 return myPickableActor->GetMapper();
1103 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1104 return myVisualObj->GetUnstructuredGrid();
1108 bool SMESH_ActorDef::IsInfinitive(){
1109 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1111 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1112 ( aDataSet->GetNumberOfCells() == 1 &&
1113 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1114 return SALOME_Actor::IsInfinitive();
1118 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1119 if ( myIsShrinkable == theShrunkable )
1121 myIsShrinkable = theShrunkable;
1125 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1126 return myBaseActor->GetShrinkFactor();
1129 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1130 myBaseActor->SetShrinkFactor(theValue);
1132 my1DActor->SetShrinkFactor(theValue);
1133 my1DExtActor->SetShrinkFactor(theValue);
1135 my2DActor->SetShrinkFactor(theValue);
1136 my2DExtActor->SetShrinkFactor(theValue);
1137 my3DActor->SetShrinkFactor(theValue);
1138 my3DExtActor->SetShrinkFactor(theValue);
1139 my3DExtActor->SetShrinkFactor(theValue);
1140 myHighlitableActor->SetShrinkFactor(theValue);
1145 void SMESH_ActorDef::SetShrink(){
1146 if(!myIsShrinkable) return;
1148 myBaseActor->SetShrink();
1150 my1DActor->SetShrink();
1151 my1DExtActor->SetShrink();
1153 my2DActor->SetShrink();
1154 my2DExtActor->SetShrink();
1155 my3DActor->SetShrink();
1156 my3DExtActor->SetShrink();
1157 myHighlitableActor->SetShrink();
1163 void SMESH_ActorDef::UnShrink(){
1164 if(!myIsShrunk) return;
1166 myBaseActor->UnShrink();
1168 my1DActor->UnShrink();
1169 my1DExtActor->UnShrink();
1171 my2DActor->UnShrink();
1172 my2DExtActor->UnShrink();
1173 my3DActor->UnShrink();
1174 my3DExtActor->UnShrink();
1175 myHighlitableActor->UnShrink();
1182 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1183 return myPickableActor->GetNodeObjId(theVtkID);
1186 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1187 return myPickableActor->GetNodeCoord(theObjID);
1191 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1192 return myPickableActor->GetElemObjId(theVtkID);
1195 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1196 return myPickableActor->GetElemCell(theObjID);
1200 void SMESH_ActorDef::SetVisibility(int theMode){
1201 SetVisibility(theMode,true);
1205 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1206 SALOME_Actor::SetVisibility(theMode);
1208 myNodeActor->VisibilityOff();
1209 myBaseActor->VisibilityOff();
1211 myNodeExtActor->VisibilityOff();
1213 my0DActor->VisibilityOff();
1214 //my0DExtActor->VisibilityOff();
1216 my1DActor->VisibilityOff();
1217 my1DExtActor->VisibilityOff();
1219 my2DActor->VisibilityOff();
1220 my2DExtActor->VisibilityOff();
1221 my3DActor->VisibilityOff();
1222 my3DExtActor->VisibilityOff();
1224 myScalarBarActor->VisibilityOff();
1226 if(GetVisibility()){
1227 if(theIsUpdateRepersentation)
1228 SetRepresentation(GetRepresentation());
1230 if(myControlMode != eNone){
1231 switch(myControlMode){
1233 case eCoincidentNodes:
1234 myNodeExtActor->VisibilityOn();
1238 case eCoincidentElems1D:
1240 case eMultiConnection2D:
1241 my1DExtActor->VisibilityOn();
1244 case eBareBorderFace:
1245 case eOverConstrainedFace:
1246 case eCoincidentElems2D:
1247 my2DExtActor->VisibilityOn();
1249 case eBareBorderVolume:
1250 case eOverConstrainedVolume:
1251 case eCoincidentElems3D:
1252 my3DExtActor->VisibilityOn();
1255 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1256 myScalarBarActor->VisibilityOn();
1260 if(myRepresentation != ePoint)
1261 myPickableActor->VisibilityOn();
1263 myNodeActor->VisibilityOn();
1266 if(myEntityMode & e0DElements){
1267 my0DActor->VisibilityOn();
1270 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1271 my1DActor->VisibilityOn();
1274 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1275 my2DActor->VisibilityOn();
1278 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1279 my3DActor->VisibilityOn();
1282 if(myNodeActor->GetPointsLabeled()){
1283 myNodeActor->VisibilityOn();
1287 my0DActor->UpdateLabels();
1290 my1DActor->UpdateLabels();
1293 my2DActor->UpdateLabels();
1296 my3DActor->UpdateLabels();
1298 #ifndef DISABLE_PLOT2DVIEWER
1300 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1307 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1309 myEntityState = eAllEntity;
1311 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1312 myEntityState &= ~e0DElements;
1313 theMode &= ~e0DElements;
1316 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1317 myEntityState &= ~eEdges;
1321 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1322 myEntityState &= ~eFaces;
1326 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1327 myEntityState &= ~eVolumes;
1328 theMode &= ~eVolumes;
1332 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1333 theMode |= e0DElements;
1335 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1338 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1341 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1342 theMode |= eVolumes;
1345 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1347 myEntityMode = theMode;
1348 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1349 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1350 aFilter->ClearRegisteredCellsWithType();
1351 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1353 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1354 aHightFilter->ClearRegisteredCellsWithType();
1355 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1357 if (myEntityMode & e0DElements) {
1358 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1359 aFilter->RegisterCellsWithType(VTK_VERTEX);
1360 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1363 if (myEntityMode & eEdges) {
1364 if (MYDEBUG) MESSAGE("EDGES");
1365 aFilter->RegisterCellsWithType(VTK_LINE);
1366 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1368 aHightFilter->RegisterCellsWithType(VTK_LINE);
1369 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1372 if (myEntityMode & eFaces) {
1373 if (MYDEBUG) MESSAGE("FACES");
1374 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1375 aFilter->RegisterCellsWithType(VTK_POLYGON);
1376 aFilter->RegisterCellsWithType(VTK_QUAD);
1377 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1378 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1379 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1381 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1382 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1383 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1384 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1385 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1386 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1389 if (myEntityMode & eVolumes) {
1390 if (MYDEBUG) MESSAGE("VOLUMES");
1391 aFilter->RegisterCellsWithType(VTK_TETRA);
1392 aFilter->RegisterCellsWithType(VTK_VOXEL);
1393 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1394 aFilter->RegisterCellsWithType(VTK_WEDGE);
1395 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1396 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1397 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1398 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1399 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1400 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1401 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1402 //#ifdef VTK_HAVE_POLYHEDRON
1403 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1406 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1407 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1408 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1409 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1410 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1411 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1412 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1413 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1414 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1415 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1416 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1417 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1418 //#ifdef VTK_HAVE_POLYHEDRON
1419 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1423 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1424 SetVisibility(GetVisibility(),false);
1427 void SMESH_ActorDef::SetRepresentation (int theMode)
1429 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1430 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1431 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1434 myRepresentation = eSurface;
1435 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1436 myRepresentation = eEdge;
1437 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1438 myRepresentation = ePoint;
1443 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1446 if (!aNbFaces && !aNbVolumes) return;
1449 myRepresentation = theMode;
1452 if (!GetUnstructuredGrid()->GetNumberOfCells())
1453 myRepresentation = ePoint;
1456 if (myRepresentation == ePoint) {
1464 myPickableActor = myBaseActor;
1465 myNodeActor->SetVisibility(false);
1466 myNodeExtActor->SetVisibility(false);
1467 vtkProperty *aProp = NULL, *aBackProp = NULL;
1468 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1469 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1470 switch (myRepresentation) {
1472 myPickableActor = myNodeActor;
1473 myNodeActor->SetVisibility(true);
1474 aQuadraticMode = SMESH_Actor::eLines;
1475 aProp = aBackProp = myNodeProp;
1476 aReperesent = SMESH_DeviceActor::ePoint;
1479 aProp = aBackProp = myEdgeProp;
1480 aReperesent = SMESH_DeviceActor::eInsideframe;
1483 aProp = mySurfaceProp;
1484 aBackProp = myBackSurfaceProp;
1485 aReperesent = SMESH_DeviceActor::eSurface;
1489 my2DActor->SetProperty(aProp);
1490 my2DActor->SetBackfaceProperty(aBackProp);
1491 my2DActor->SetRepresentation(aReperesent);
1493 if(aQuadraticMode == SMESH_Actor::eLines)
1494 my2DActor->SetQuadraticArcMode(false);
1495 else if(aQuadraticMode == SMESH_Actor::eArcs)
1496 my2DActor->SetQuadraticArcMode(true);
1498 my2DExtActor->SetRepresentation(aReperesent);
1500 my3DActor->SetProperty(aProp);
1501 my3DActor->SetBackfaceProperty(aBackProp);
1502 my3DActor->SetRepresentation(aReperesent);
1504 //my0DExtActor->SetVisibility(false);
1505 my1DExtActor->SetVisibility(false);
1506 my2DExtActor->SetVisibility(false);
1507 my3DExtActor->SetVisibility(false);
1510 //my0DActor->SetProperty(aProp);
1511 //my0DActor->SetBackfaceProperty(aBackProp);
1512 my0DActor->SetRepresentation(aReperesent);
1513 //my0DExtActor->SetRepresentation(aReperesent);
1515 switch(myControlMode){
1517 case eMultiConnection:
1518 aProp = aBackProp = my1DProp;
1519 if(myRepresentation != ePoint)
1520 aReperesent = SMESH_DeviceActor::eInsideframe;
1524 if(aQuadraticMode == SMESH_Actor::eLines)
1525 my1DActor->SetQuadraticArcMode(false);
1526 else if(aQuadraticMode == SMESH_Actor::eArcs)
1527 my1DActor->SetQuadraticArcMode(true);
1529 my1DActor->SetProperty(aProp);
1530 my1DActor->SetBackfaceProperty(aBackProp);
1531 my1DActor->SetRepresentation(aReperesent);
1533 my1DExtActor->SetRepresentation(aReperesent);
1535 if(myIsPointsVisible)
1536 myPickableActor = myNodeActor;
1537 if(GetPointRepresentation())
1538 myNodeActor->SetVisibility(true);
1540 SetMapper(myPickableActor->GetMapper());
1542 SetVisibility(GetVisibility(),false);
1548 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1549 if ( myIsPointsVisible == theIsPointsVisible )
1551 myIsPointsVisible = theIsPointsVisible;
1552 SetRepresentation(GetRepresentation());
1555 bool SMESH_ActorDef::GetPointRepresentation(){
1556 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1560 void SMESH_ActorDef::UpdateHighlight(){
1561 myHighlitableActor->SetHighlited(false);
1562 myHighlitableActor->SetVisibility(false);
1564 bool anIsVisible = GetVisibility();
1566 switch(myRepresentation){
1567 case SMESH_DeviceActor::eSurface:
1568 case SMESH_DeviceActor::eWireframe:
1570 if(myIsHighlighted) {
1571 myHighlitableActor->SetProperty(myHighlightProp);
1572 }else if(myIsPreselected){
1573 myHighlitableActor->SetProperty(myPreselectProp);
1574 } else if(anIsVisible){
1575 (myRepresentation == eSurface) ?
1576 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1578 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1579 myHighlitableActor->SetHighlited(anIsVisible);
1580 myHighlitableActor->GetExtractUnstructuredGrid()->
1581 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1582 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1584 myHighlitableActor->SetVisibility(anIsVisible);
1587 case SMESH_DeviceActor::ePoint:
1589 if(myIsHighlighted) {
1590 myNodeActor->SetProperty(myHighlightProp);
1591 }else if(myIsPreselected) {
1592 myNodeActor->SetProperty(myPreselectProp);
1593 } else if(anIsVisible) {
1594 myNodeActor->SetProperty(myNodeProp);
1596 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1597 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1604 void SMESH_ActorDef::highlight(bool theHighlight){
1605 if ( myIsHighlighted == theHighlight )
1607 myIsHighlighted = theHighlight;
1612 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1613 if ( myIsPreselected == thePreselect )
1615 myIsPreselected = thePreselect;
1621 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1623 if (myPickableActor->GetIsOpaque())
1625 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1633 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1635 if (!myPickableActor->GetIsOpaque())
1637 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1645 void SMESH_ActorDef::Render(vtkRenderer *ren){
1646 unsigned long aTime = myTimeStamp->GetMTime();
1647 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1648 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1649 if(anObjTime > aTime || aClippingTime > aTime)
1654 void SMESH_ActorDef::Update(){
1655 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1657 if(GetControlMode() != eNone) {
1658 unsigned long aTime = myTimeStamp->GetMTime();
1659 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1660 if (anObjTime > aTime)
1661 SetControlMode(GetControlMode(),false);
1665 myNodeActor->UpdateLabels();
1668 my0DActor->UpdateLabels();
1671 my1DActor->UpdateLabels();
1674 my2DActor->UpdateLabels();
1677 my3DActor->UpdateLabels();
1679 if(myIsFacesOriented){
1680 SetFacesOriented(myIsFacesOriented);
1683 if(myVisualObj->GetEntitiesFlag()) {
1684 myEntityMode |= myVisualObj->GetEntitiesState();
1687 SetEntityMode(GetEntityMode());
1688 SetVisibility(GetVisibility());
1690 myTimeStamp->Modified();
1695 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1696 SALOME_Actor::ReleaseGraphicsResources(renWin);
1698 myPickableActor->ReleaseGraphicsResources(renWin);
1702 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1703 vtkFloatingPointType* aColor = theProperty->GetColor();
1710 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1711 mySurfaceProp->SetOpacity(theValue);
1712 myBackSurfaceProp->SetOpacity(theValue);
1713 myEdgeProp->SetOpacity(theValue);
1714 myNodeProp->SetOpacity(theValue);
1716 my1DProp->SetOpacity(theValue);
1720 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1721 return mySurfaceProp->GetOpacity();
1725 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1726 mySurfaceProp->SetColor(r,g,b);
1727 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1728 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1729 aGroupObj->GetElementType() == SMDSAbs_Volume )
1730 myNameActor->SetBackgroundColor(r,g,b);
1732 myDeltaBrightness = delta;
1733 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1734 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1738 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1739 ::GetColor(mySurfaceProp,r,g,b);
1740 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1741 delta = myDeltaBrightness;
1744 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1745 myEdgeProp->SetColor(r,g,b);
1746 my1DProp->SetColor(r,g,b);
1747 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1748 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1749 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1750 myNameActor->SetBackgroundColor(r,g,b);
1754 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1755 ::GetColor(myEdgeProp,r,g,b);
1758 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1759 myOutLineProp->SetColor(r,g,b);
1763 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1764 ::GetColor(myOutLineProp,r,g,b);
1768 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1769 myNodeProp->SetColor(r,g,b);
1770 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1771 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1772 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1773 myNameActor->SetBackgroundColor(r,g,b);
1777 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1778 ::GetColor(myNodeProp,r,g,b);
1781 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1782 my0DProp->SetColor(r,g,b);
1783 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1784 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1785 myNameActor->SetBackgroundColor(r,g,b);
1789 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1790 ::GetColor(my0DProp,r,g,b);
1793 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1794 myHighlightProp->SetColor(r,g,b);
1798 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1799 ::GetColor(myHighlightProp,r,g,b);
1802 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1803 myPreselectProp->SetColor(r,g,b);
1807 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1808 ::GetColor(myPreselectProp,r,g,b);
1812 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1813 return myEdgeProp->GetLineWidth();
1817 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1818 myEdgeProp->SetLineWidth(theVal);
1820 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1821 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1822 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
1823 myOutLineProp->SetLineWidth(theVal);
1824 myHighlightProp->SetLineWidth(theVal);
1825 myPreselectProp->SetLineWidth(theVal);
1830 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1831 my0DProp->SetPointSize(theVal);
1835 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1836 return my0DProp->GetPointSize();
1839 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1841 return myVisualObj->GetElemDimension( theObjId );
1846 IsImplicitFunctionUsed() const
1848 return myBaseActor->IsImplicitFunctionUsed();
1852 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1854 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1855 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1857 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1859 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1861 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1862 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1864 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1865 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1867 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1868 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1869 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1870 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1874 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1877 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1878 myCippingPlaneCont.push_back(thePlane);
1879 if(!IsImplicitFunctionUsed())
1880 SetImplicitFunctionUsed(true);
1881 myNodeActor->UpdateLabels();
1883 return myCippingPlaneCont.size();
1888 RemoveAllClippingPlanes()
1890 myImplicitBoolean->GetFunction()->RemoveAllItems();
1891 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1892 myCippingPlaneCont.clear();
1893 SetImplicitFunctionUsed(false);
1894 myNodeActor->UpdateLabels();
1899 GetNumberOfClippingPlanes()
1901 return myCippingPlaneCont.size();
1906 GetClippingPlane(vtkIdType theID)
1908 if(theID >= myCippingPlaneCont.size())
1910 return myCippingPlaneCont[theID].Get();
1913 void SMESH_ActorDef::UpdateScalarBar()
1915 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1919 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1921 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1922 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1924 aScalarBarTitleProp->SetFontFamilyToArial();
1926 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1928 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1929 if ( f.family() == "Arial" )
1930 aScalarBarTitleProp->SetFontFamilyToArial();
1931 else if ( f.family() == "Courier" )
1932 aScalarBarTitleProp->SetFontFamilyToCourier();
1933 else if ( f.family() == "Times" )
1934 aScalarBarTitleProp->SetFontFamilyToTimes();
1937 aScalarBarTitleProp->BoldOn();
1939 aScalarBarTitleProp->BoldOff();
1942 aScalarBarTitleProp->ItalicOn();
1944 aScalarBarTitleProp->ItalicOff();
1947 aScalarBarTitleProp->ShadowOn();
1949 aScalarBarTitleProp->ShadowOff();
1952 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1953 aScalarBarTitleProp->Delete();
1955 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1957 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1958 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1960 aScalarBarLabelProp->SetFontFamilyToArial();
1961 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1963 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1964 if( f.family() == "Arial" )
1965 aScalarBarLabelProp->SetFontFamilyToArial();
1966 else if( f.family() == "Courier" )
1967 aScalarBarLabelProp->SetFontFamilyToCourier();
1968 else if( f.family() == "Times" )
1969 aScalarBarLabelProp->SetFontFamilyToTimes();
1972 aScalarBarLabelProp->BoldOn();
1974 aScalarBarLabelProp->BoldOff();
1977 aScalarBarLabelProp->ItalicOn();
1979 aScalarBarLabelProp->ItalicOff();
1982 aScalarBarLabelProp->ShadowOn();
1984 aScalarBarLabelProp->ShadowOff();
1987 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1988 aScalarBarLabelProp->Delete();
1990 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1991 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1993 myScalarBarActor->SetOrientationToHorizontal();
1995 myScalarBarActor->SetOrientationToVertical();
1998 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1999 if( mgr->hasValue( "SMESH", name + "x" ) )
2000 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
2002 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2003 if( mgr->hasValue( "SMESH", name + "y" ) )
2004 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2005 myScalarBarActor->SetPosition( aXVal, aYVal );
2007 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2008 if( mgr->hasValue( "SMESH", name + "width" ) )
2009 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2010 myScalarBarActor->SetWidth( aWVal );
2012 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2013 if( mgr->hasValue( "SMESH", name + "height" ) )
2014 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2015 myScalarBarActor->SetHeight( aHVal );
2018 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2019 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2020 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2023 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2024 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2025 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2027 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2028 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2030 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2031 myScalarBarActor->SetDistributionColoringType(coloringType);
2033 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2034 QColor(255, 255, 255));
2036 rgb[0]= distributionColor.red()/255.;
2037 rgb[1]= distributionColor.green()/255.;
2038 rgb[2]= distributionColor.blue()/255.;
2039 myScalarBarActor->SetDistributionColor(rgb);
2044 void SMESH_ActorDef::UpdateDistribution()
2046 if(SMESH::Controls::NumericalFunctor* fun =
2047 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2049 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2050 std::vector<int> nbEvents;
2051 std::vector<double> funValues;
2052 SMESH_VisualObjDef::TEntityList elems;
2053 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2054 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2055 std::vector<int> elemIds;
2056 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2057 elemIds.push_back( (*e)->GetID());
2058 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2059 double * range = lookupTable->GetRange();
2060 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2061 myScalarBarActor->SetDistribution(nbEvents);
2065 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2068 case SMESH_Actor::eLines :
2069 myHighlitableActor->SetQuadraticArcMode(false);
2070 my2DActor->SetQuadraticArcMode(false);
2071 my1DActor->SetQuadraticArcMode(false);
2073 case SMESH_Actor::eArcs :
2074 myHighlitableActor->SetQuadraticArcMode(true);
2075 if(GetRepresentation() != SMESH_Actor::ePoint) {
2076 my2DActor->SetQuadraticArcMode(true);
2077 my1DActor->SetQuadraticArcMode(true);
2086 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2088 if(myHighlitableActor->GetQuadraticArcMode())
2089 return SMESH_Actor::eArcs;
2091 return SMESH_Actor::eLines;
2094 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2096 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2097 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2098 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2101 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2103 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2104 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2105 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2106 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2109 #ifndef DISABLE_PLOT2DVIEWER
2110 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2113 my2dHistogram->clearAllPoints();
2115 if(SMESH::Controls::NumericalFunctor* fun =
2116 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2119 if(!my2dHistogram) {
2120 my2dHistogram = new SPlot2d_Histogram();
2121 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2122 my2dHistogram->setIO(anIO);
2125 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2126 std::vector<int> nbEvents;
2127 std::vector<double> funValues;
2128 SMESH_VisualObjDef::TEntityList elems;
2129 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2130 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2131 std::vector<int> elemIds;
2133 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2134 elemIds.push_back( (*e)->GetID());
2136 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2137 double * range = lookupTable->GetRange();
2138 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2140 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2141 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2143 if(funValues.size() >= 2)
2144 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2148 //Color of the histogram
2149 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2150 my2dHistogram->setAutoAssign(true);
2153 myScalarBarActor->GetDistributionColor(rgb);
2154 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2155 my2dHistogram->setColor(aColor);
2159 return my2dHistogram;