1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_NodeLabelActor.h"
32 #include "SMESH_CellLabelActor.h"
33 #include "SMESH_ObjectDef.h"
34 #include "SMESH_ControlsDef.hxx"
35 #include "SMDS_UnstructuredGrid.hxx"
36 #include "SMESH_ScalarBarActor.h"
37 #include "VTKViewer_ExtractUnstructuredGrid.h"
38 #include "VTKViewer_FramedTextActor.h"
39 #include "SALOME_InteractiveObject.hxx"
41 #include "SUIT_Session.h"
42 #include "SUIT_ResourceMgr.h"
46 #ifndef DISABLE_PLOT2DVIEWER
47 #include <SPlot2d_Histogram.h>
50 #include <vtkProperty.h>
51 #include <vtkTimeStamp.h>
52 #include <vtkObjectFactory.h>
53 #include <vtkShrinkPolyData.h>
54 #include <vtkMergeFilter.h>
56 #include <vtkMatrix4x4.h>
57 #include <vtkUnstructuredGrid.h>
58 #include <vtkPointData.h>
59 #include <vtkCellData.h>
61 #include <vtkMapper.h>
62 #include <vtkRenderer.h>
65 #include <vtkIdList.h>
66 #include <vtkIntArray.h>
68 #include <vtkActor2D.h>
69 #include <vtkProperty2D.h>
70 #include <vtkPolyData.h>
71 #include <vtkTextProperty.h>
73 #include <vtkLookupTable.h>
77 #include <vtkImplicitBoolean.h>
78 #include <vtkImplicitFunctionCollection.h>
80 #include <vtkConfigure.h>
81 #if !defined(VTK_XVERSION)
82 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
85 #include "utilities.h"
88 static int MYDEBUG = 1;
90 static int MYDEBUG = 1;
93 static int aLineWidthInc = 2;
96 SMESH_ActorDef* SMESH_ActorDef::New(){
97 return new SMESH_ActorDef();
101 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
102 const char* theEntry,
106 SMESH_ActorDef* anActor = NULL;
107 if(theVisualObj->IsValid() ) {
108 anActor = SMESH_ActorDef::New();
109 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
114 anActor->UpdateScalarBar();
120 SMESH_ActorDef::SMESH_ActorDef()
122 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
123 myBaseActor = SMESH_DeviceActor::New();
125 myTimeStamp = vtkTimeStamp::New();
127 myIsPointsVisible = false;
128 myIsEntityModeCache = false;
130 myIsShrinkable = false;
133 myIsFacesOriented = false;
135 myControlsPrecision = -1;
136 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
138 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
139 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
141 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
142 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
144 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
145 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
147 //Definition 2D and 3D devices of the actor
148 //-----------------------------------------
149 vtkFloatingPointType anRGB[3] = {1,1,1};
150 mySurfaceProp = vtkProperty::New();
153 SMESH::GetColor( "SMESH", "fill_color", ffc, delta, "0,170,255|-100" ) ;
154 mySurfaceProp->SetColor( ffc.red() / 255. , ffc.green() / 255. , ffc.blue() / 255. );
155 myDeltaBrightness = delta;
157 myBackSurfaceProp = vtkProperty::New();
158 bfc = Qtx::mainColorToSecondary(ffc, delta);
159 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
161 my2DActor = SMESH_CellLabelActor::New();
162 my2DActor->SetStoreGemetryMapping(true);
163 my2DActor->SetUserMatrix(aMatrix);
164 my2DActor->PickableOff();
165 my2DActor->SetProperty(mySurfaceProp);
166 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
167 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
168 aFilter = my2DActor->GetExtractUnstructuredGrid();
169 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
170 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
171 aFilter->RegisterCellsWithType(VTK_POLYGON);
172 aFilter->RegisterCellsWithType(VTK_QUAD);
173 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
174 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
175 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
177 my2DExtProp = vtkProperty::New();
178 my2DExtProp->DeepCopy(mySurfaceProp);
179 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
180 anRGB[0] = 1 - anRGB[0];
181 anRGB[1] = 1 - anRGB[1];
182 anRGB[2] = 1 - anRGB[2];
183 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
185 my2DExtActor = SMESH_DeviceActor::New();
186 my2DExtActor->SetUserMatrix(aMatrix);
187 my2DExtActor->PickableOff();
188 my2DExtActor->SetProperty(my2DExtProp);
189 my2DExtActor->SetBackfaceProperty(my2DExtProp);
190 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
191 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
192 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
193 aFilter->RegisterCellsWithType(VTK_POLYGON);
194 aFilter->RegisterCellsWithType(VTK_QUAD);
195 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
196 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
197 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
199 my3DActor = SMESH_CellLabelActor::New();
200 my3DActor->SetStoreGemetryMapping(true);
201 my3DActor->SetUserMatrix(aMatrix);
202 my3DActor->PickableOff();
203 my3DActor->SetProperty(mySurfaceProp);
204 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
205 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
206 aFilter = my3DActor->GetExtractUnstructuredGrid();
207 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
208 aFilter->RegisterCellsWithType(VTK_TETRA);
209 aFilter->RegisterCellsWithType(VTK_VOXEL);
210 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
211 aFilter->RegisterCellsWithType(VTK_WEDGE);
212 aFilter->RegisterCellsWithType(VTK_PYRAMID);
213 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
214 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
215 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
216 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
217 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
218 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
219 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
220 //#ifdef VTK_HAVE_POLYHEDRON
221 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
222 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
225 my3DExtActor = SMESH_DeviceActor::New();
226 my3DExtActor->SetUserMatrix(aMatrix);
227 my3DExtActor->PickableOff();
228 my3DExtActor->SetProperty(my2DExtProp);
229 my3DExtActor->SetBackfaceProperty(my2DExtProp);
230 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
231 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
232 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
233 aFilter->RegisterCellsWithType(VTK_TETRA);
234 aFilter->RegisterCellsWithType(VTK_VOXEL);
235 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
236 aFilter->RegisterCellsWithType(VTK_WEDGE);
237 aFilter->RegisterCellsWithType(VTK_PYRAMID);
238 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
239 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
240 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
241 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
242 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
243 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
244 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
245 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
247 //Definition 1D device of the actor
248 //---------------------------------
249 myEdgeProp = vtkProperty::New();
250 myEdgeProp->SetAmbient(1.0);
251 myEdgeProp->SetDiffuse(0.0);
252 myEdgeProp->SetSpecular(0.0);
253 SMESH::GetColor( "SMESH", "wireframe_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
254 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
255 myEdgeProp->SetLineWidth(aLineWidth);
257 my1DActor = SMESH_CellLabelActor::New();
258 my1DActor->SetStoreGemetryMapping(true);
259 my1DActor->SetUserMatrix(aMatrix);
260 my1DActor->PickableOff();
261 my1DActor->SetHighlited(true);
262 my1DActor->SetProperty(myEdgeProp);
263 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
264 aFilter = my1DActor->GetExtractUnstructuredGrid();
265 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
266 aFilter->RegisterCellsWithType(VTK_LINE);
267 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
269 my1DProp = vtkProperty::New();
270 my1DProp->DeepCopy(myEdgeProp);
271 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
272 my1DProp->SetPointSize(aElem0DSize);
274 my1DExtProp = vtkProperty::New();
275 my1DExtProp->DeepCopy(myEdgeProp);
276 anRGB[0] = 1 - anRGB[0];
277 anRGB[1] = 1 - anRGB[1];
278 anRGB[2] = 1 - anRGB[2];
279 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
280 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
281 my1DExtProp->SetPointSize(aElem0DSize);
283 my1DExtActor = SMESH_DeviceActor::New();
284 my1DExtActor->SetUserMatrix(aMatrix);
285 my1DExtActor->PickableOff();
286 my1DExtActor->SetHighlited(true);
287 my1DExtActor->SetVisibility(false);
288 my1DExtActor->SetProperty(my1DExtProp);
289 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
290 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
291 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
292 aFilter->RegisterCellsWithType(VTK_LINE);
293 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
296 //Definition 0D device of the actor (0d elements)
297 //-----------------------------------------------
298 my0DProp = vtkProperty::New();
299 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
300 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
301 my0DProp->SetPointSize(aElem0DSize);
303 my0DActor = SMESH_CellLabelActor::New();
304 my0DActor->SetUserMatrix(aMatrix);
305 my0DActor->SetStoreGemetryMapping(true);
306 my0DActor->PickableOff();
307 my0DActor->SetVisibility(false);
308 my0DActor->SetProperty(my0DProp);
309 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
310 aFilter = my0DActor->GetExtractUnstructuredGrid();
311 //aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
312 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
313 aFilter->RegisterCellsWithType(VTK_VERTEX);
315 //my0DExtProp = vtkProperty::New();
316 //my0DExtProp->DeepCopy(my0DProp);
317 //anRGB[0] = 1 - anRGB[0];
318 //anRGB[1] = 1 - anRGB[1];
319 //anRGB[2] = 1 - anRGB[2];
320 //my0DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
321 //my0DExtProp->SetPointSize(aElem0DSize);
323 //my0DExtActor = SMESH_DeviceActor::New();
324 //my0DExtActor->SetUserMatrix(aMatrix);
325 //my0DExtActor->SetStoreClippingMapping(true);
326 //my0DExtActor->PickableOff();
327 //my0DExtActor->SetHighlited(true);
328 //my0DExtActor->SetVisibility(false);
329 //my0DExtActor->SetProperty(my0DExtProp);
330 //my0DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
331 //aFilter = my0DExtActor->GetExtractUnstructuredGrid();
332 ////aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
333 //aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
334 //aFilter->RegisterCellsWithType(VTK_VERTEX);
337 //Definition 0D device of the actor (nodes)
338 //-----------------------------------------
339 myNodeProp = vtkProperty::New();
340 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
341 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
343 myNodeActor = SMESH_NodeLabelActor::New();
344 myNodeActor->SetUserMatrix(aMatrix);
345 myNodeActor->SetStoreClippingMapping(true);
346 myNodeActor->PickableOff();
347 myNodeActor->SetVisibility(false);
348 myNodeActor->SetProperty(myNodeProp);
349 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
350 aFilter = myNodeActor->GetExtractUnstructuredGrid();
351 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
353 myNodeExtProp = vtkProperty::New();
354 myNodeExtProp->DeepCopy(myNodeProp);
355 anRGB[0] = 1 - anRGB[0];
356 anRGB[1] = 1 - anRGB[1];
357 anRGB[2] = 1 - anRGB[2];
358 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
360 myNodeExtActor = SMESH_DeviceActor::New();
361 myNodeExtActor->SetUserMatrix(aMatrix);
362 myNodeExtActor->SetStoreClippingMapping(true);
363 myNodeExtActor->PickableOff();
364 myNodeExtActor->SetHighlited(true);
365 myNodeExtActor->SetVisibility(false);
366 myNodeExtActor->SetProperty(myNodeExtProp);
367 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
368 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
369 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
370 aFilter->RegisterCellsWithType(VTK_VERTEX);
372 //Definition of Pickable and Highlitable engines
373 //----------------------------------------------
375 myBaseActor->SetUserMatrix(aMatrix);
376 myBaseActor->SetStoreGemetryMapping(true);
377 myBaseActor->GetProperty()->SetOpacity(0.0);
378 myPickableActor = myBaseActor;
380 myHighlightProp = vtkProperty::New();
381 myHighlightProp->SetAmbient(1.0);
382 myHighlightProp->SetDiffuse(0.0);
383 myHighlightProp->SetSpecular(0.0);
384 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
385 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
386 myHighlightProp->SetPointSize(aElem0DSize); // ??
387 myHighlightProp->SetLineWidth(aLineWidth);
388 myHighlightProp->SetRepresentation(1);
390 myOutLineProp = vtkProperty::New();
391 myOutLineProp->SetAmbient(1.0);
392 myOutLineProp->SetDiffuse(0.0);
393 myOutLineProp->SetSpecular(0.0);
394 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 70, 0 ) );
395 myOutLineProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
396 myOutLineProp->SetPointSize(aElem0DSize); // ??
397 myOutLineProp->SetLineWidth(aLineWidth);
398 myOutLineProp->SetRepresentation(1);
400 myPreselectProp = vtkProperty::New();
401 myPreselectProp->SetAmbient(1.0);
402 myPreselectProp->SetDiffuse(0.0);
403 myPreselectProp->SetSpecular(0.0);
404 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
405 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
406 myPreselectProp->SetPointSize(aElem0DSize); // ??
407 myPreselectProp->SetLineWidth(aLineWidth);
408 myPreselectProp->SetRepresentation(1);
410 myHighlitableActor = SMESH_DeviceActor::New();
411 myHighlitableActor->SetUserMatrix(aMatrix);
412 myHighlitableActor->PickableOff();
413 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
420 myControlMode = eNone;
421 myControlActor = my2DActor;
423 //Definition of myScalarBarActor
424 //------------------------------
425 myLookupTable = vtkLookupTable::New();
426 //Fix for Bug PAL5195 - SMESH764:
427 //Controls - Aspect Ratio: incorrect colors of the best and worst values
428 myLookupTable->SetHueRange(0.667,0.0);
430 myScalarBarActor = SMESH_ScalarBarActor::New();
431 myScalarBarActor->SetVisibility(false);
432 myScalarBarActor->SetLookupTable(myLookupTable);
435 //Incorrect "Min value" in Scalar Bar in Mesh:
436 // myScalarBarActor->SetLabelFormat("%.4g");
437 // changes was commented because of regression bug IPAL 19981
439 mgr = SUIT_Session::session()->resourceMgr();
443 myEntityMode = eAllEntity;
444 myEntityModeCache = eAllEntity;
447 myImplicitBoolean = vtkImplicitBoolean::New();
448 myImplicitBoolean->SetOperationTypeToIntersection();
450 //Quadratic 2D elements representation
451 //-----------------------------------------------------------------------------
452 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
453 if(aQuadratic2DMode == 0){
454 myHighlitableActor->SetQuadraticArcMode(false);
455 my2DActor->SetQuadraticArcMode(false);
456 my1DActor->SetQuadraticArcMode(false);
458 else if(aQuadratic2DMode == 1){
459 myHighlitableActor->SetQuadraticArcMode(true);
460 my2DActor->SetQuadraticArcMode(true);
461 my1DActor->SetQuadraticArcMode(true);
464 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
465 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
466 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
468 // Set colors of the name actor
469 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
470 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
471 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
472 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
474 #ifndef DISABLE_PLOT2DVIEWER
481 SMESH_ActorDef::~SMESH_ActorDef()
483 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
485 #ifndef DISABLE_PLOT2DVIEWER
487 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
488 delete my2dHistogram;
492 // caught by SMESHGUI::ProcessEvents() static method
493 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
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();
539 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
542 myNodeActor->SetPointsLabeled(theIsPointsLabeled);
543 SetRepresentation(GetRepresentation());
544 myTimeStamp->Modified();
548 bool SMESH_ActorDef::GetPointsLabeled() {
549 return myNodeActor && myNodeActor->GetPointsLabeled();
552 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
555 my3DActor->SetCellsLabeled(theIsCellsLabeled);
558 my2DActor->SetCellsLabeled(theIsCellsLabeled);
561 my1DActor->SetCellsLabeled(theIsCellsLabeled);
564 my0DActor->SetCellsLabeled(theIsCellsLabeled);
566 myTimeStamp->Modified();
570 bool SMESH_ActorDef::GetCellsLabeled() {
573 result = result || my3DActor->GetCellsLabeled();
576 result = result || my2DActor->GetCellsLabeled();
579 result = result || my1DActor->GetCellsLabeled();
582 result = result || my0DActor->GetCellsLabeled();
588 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
590 myIsFacesOriented = theIsFacesOriented;
592 my2DActor->SetFacesOriented(theIsFacesOriented);
593 my3DActor->SetFacesOriented(theIsFacesOriented);
595 myTimeStamp->Modified();
598 bool SMESH_ActorDef::GetFacesOriented()
600 return myIsFacesOriented;
603 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
605 my2DActor->SetFacesOrientationColor( theColor );
606 my3DActor->SetFacesOrientationColor( theColor );
609 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
611 my3DActor->GetFacesOrientationColor( theColor );
614 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
616 my2DActor->SetFacesOrientationScale( theScale );
617 my3DActor->SetFacesOrientationScale( theScale );
620 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
622 return my3DActor->GetFacesOrientationScale();
625 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
627 my2DActor->SetFacesOrientation3DVectors( theState );
628 my3DActor->SetFacesOrientation3DVectors( theState );
631 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
633 return my3DActor->GetFacesOrientation3DVectors();
639 SetControlMode(eControl theMode)
641 SetControlMode(theMode,true);
647 SetControlMode(eControl theMode,
648 bool theCheckEntityMode)
650 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
654 myControlMode = eNone;
655 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
657 my0DActor->GetMapper()->SetScalarVisibility(false);
658 my1DActor->GetMapper()->SetScalarVisibility(false);
659 my2DActor->GetMapper()->SetScalarVisibility(false);
660 my3DActor->GetMapper()->SetScalarVisibility(false);
661 myScalarBarActor->SetVisibility(false);
663 bool anIsScalarVisible = theMode > eNone;
665 if(anIsScalarVisible) {
669 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
670 aControl->SetPrecision( myControlsPrecision );
671 myFunctor.reset( aControl );
672 myControlActor = my1DActor;
677 myFunctor.reset(new SMESH::Controls::Length2D());
678 myControlActor = my2DActor;
682 myFunctor.reset(new SMESH::Controls::FreeBorders());
683 myControlActor = my1DActor;
686 myFunctor.reset(new SMESH::Controls::FreeEdges());
687 myControlActor = my2DActor;
690 myFunctor.reset(new SMESH::Controls::FreeNodes());
691 myControlActor = myNodeActor;
694 myFunctor.reset(new SMESH::Controls::FreeFaces());
695 myControlActor = my2DActor;
697 case eCoincidentNodes:
699 SMESH::Controls::CoincidentNodes* cn = new SMESH::Controls::CoincidentNodes();
700 double tol = mgr->doubleValue( "SMESH", "equal_nodes_tolerance", 1e-7 );
701 cn->SetTolerance( tol );
703 myControlActor = myNodeActor;
706 case eCoincidentElems1D:
707 myFunctor.reset(new SMESH::Controls::CoincidentElements1D());
708 myControlActor = my1DActor;
710 case eCoincidentElems2D:
711 myFunctor.reset(new SMESH::Controls::CoincidentElements2D());
712 myControlActor = my2DActor;
714 case eCoincidentElems3D:
715 myFunctor.reset(new SMESH::Controls::CoincidentElements3D());
716 myControlActor = my3DActor;
718 case eBareBorderFace:
719 myFunctor.reset(new SMESH::Controls::BareBorderFace());
720 myControlActor = my2DActor;
722 case eOverConstrainedFace:
723 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
724 myControlActor = my2DActor;
726 case eMultiConnection:
727 myFunctor.reset(new SMESH::Controls::MultiConnection());
728 myControlActor = my1DActor;
730 case eMultiConnection2D:
731 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
732 myControlActor = my2DActor;
736 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
737 aControl->SetPrecision( myControlsPrecision );
738 myFunctor.reset( aControl );
739 myControlActor = my2DActor;
744 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
745 aControl->SetPrecision( myControlsPrecision );
746 myFunctor.reset( aControl );
747 myControlActor = my2DActor;
752 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
753 aControl->SetPrecision( myControlsPrecision );
754 myFunctor.reset( aControl );
755 myControlActor = my2DActor;
760 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
761 aControl->SetPrecision( myControlsPrecision );
762 myFunctor.reset( aControl );
763 myControlActor = my3DActor;
768 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
769 aControl->SetPrecision( myControlsPrecision );
770 myFunctor.reset( aControl );
771 myControlActor = my3DActor;
774 case eMaxElementLength2D:
776 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
777 aControl->SetPrecision( myControlsPrecision );
778 myFunctor.reset( aControl );
779 myControlActor = my2DActor;
782 case eMaxElementLength3D:
784 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
785 aControl->SetPrecision( myControlsPrecision );
786 myFunctor.reset( aControl );
787 myControlActor = my3DActor;
790 case eBareBorderVolume:
792 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
793 myControlActor = my3DActor;
796 case eOverConstrainedVolume:
798 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
799 myControlActor = my3DActor;
804 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
805 aControl->SetPrecision( myControlsPrecision );
806 myFunctor.reset( aControl );
807 myControlActor = my2DActor;
812 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
813 aControl->SetPrecision( myControlsPrecision );
814 myFunctor.reset( aControl );
815 myControlActor = my2DActor;
820 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
821 aControl->SetPrecision( myControlsPrecision );
822 myFunctor.reset( aControl );
823 myControlActor = my2DActor;
830 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
831 vtkIdType aNbCells = aGrid->GetNumberOfCells();
833 myControlMode = theMode;
834 switch(myControlMode){
836 case eCoincidentNodes:
837 myNodeExtActor->SetExtControlMode(myFunctor);
841 case eCoincidentElems1D:
842 my1DExtActor->SetExtControlMode(myFunctor);
845 case eBareBorderFace:
846 case eOverConstrainedFace:
847 case eCoincidentElems2D:
848 my2DExtActor->SetExtControlMode(myFunctor);
850 case eBareBorderVolume:
851 case eOverConstrainedVolume:
852 case eCoincidentElems3D:
853 my3DExtActor->SetExtControlMode(myFunctor);
856 case eMultiConnection2D:
857 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
858 UpdateDistribution();
861 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
862 UpdateDistribution();
866 if(theCheckEntityMode) {
867 if(myControlActor == my1DActor) {
868 if (!myIsEntityModeCache){
869 myEntityModeCache = GetEntityMode();
870 myIsEntityModeCache=true;
872 SetEntityMode(eEdges);
874 else if(myControlActor == my2DActor) {
875 switch(myControlMode) {
879 case eMultiConnection2D:
880 if (!myIsEntityModeCache){
881 myEntityModeCache = GetEntityMode();
882 myIsEntityModeCache=true;
884 SetEntityMode(eFaces);
887 if (!myIsEntityModeCache){
888 myEntityModeCache = GetEntityMode();
889 myIsEntityModeCache=true;
891 SetEntityMode(eFaces);
893 }else if(myControlActor == my3DActor) {
894 if (!myIsEntityModeCache){
895 myEntityModeCache = GetEntityMode();
896 myIsEntityModeCache=true;
898 SetEntityMode(eVolumes);
904 if(theCheckEntityMode){
905 myEntityMode = myEntityModeCache;
906 myIsEntityModeCache = false;
911 SetRepresentation(GetRepresentation());
913 myTimeStamp->Modified();
919 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
920 theRenderer->AddActor(myBaseActor);
921 theRenderer->AddActor(myNodeExtActor);
922 theRenderer->AddActor(my1DExtActor);
924 my3DActor->AddToRender(theRenderer);
925 my3DExtActor->AddToRender(theRenderer);
926 my2DActor->AddToRender(theRenderer);
927 my2DExtActor->AddToRender(theRenderer);
928 myNodeActor->AddToRender(theRenderer);
929 my1DActor->AddToRender(theRenderer);
930 my0DActor->AddToRender(theRenderer);
931 //theRenderer->AddActor(my0DExtActor);
933 theRenderer->AddActor(myHighlitableActor);
935 theRenderer->AddActor2D(myScalarBarActor);
937 // the superclass' method should be called at the end
938 // (in particular, for correct work of selection)
939 SALOME_Actor::AddToRender(theRenderer);
942 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
943 SALOME_Actor::RemoveFromRender(theRenderer);
945 theRenderer->RemoveActor(myBaseActor);
947 theRenderer->RemoveActor(myNodeExtActor);
949 theRenderer->RemoveActor(myHighlitableActor);
951 //theRenderer->RemoveActor(my0DExtActor);
953 theRenderer->RemoveActor(my1DExtActor);
955 my2DActor->RemoveFromRender(theRenderer);
956 my2DExtActor->RemoveFromRender(theRenderer);
957 my3DActor->RemoveFromRender(theRenderer);
958 my3DExtActor->RemoveFromRender(theRenderer);
959 myNodeActor->RemoveFromRender(theRenderer);
960 my0DActor->RemoveFromRender(theRenderer);
961 my1DActor->RemoveFromRender(theRenderer);
963 theRenderer->RemoveActor(myScalarBarActor);
967 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
968 const char* theEntry,
972 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
976 myVisualObj = theVisualObj;
977 myVisualObj->Update(theIsClear);
979 myNodeActor->Init(myVisualObj,myImplicitBoolean);
980 myBaseActor->Init(myVisualObj,myImplicitBoolean);
982 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
984 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
986 my0DActor->Init(myVisualObj,myImplicitBoolean);
987 //my0DExtActor->Init(myVisualObj,myImplicitBoolean);
989 my1DActor->Init(myVisualObj,myImplicitBoolean);
990 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
992 my2DActor->Init(myVisualObj,myImplicitBoolean);
993 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
994 my3DActor->Init(myVisualObj,myImplicitBoolean);
995 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
997 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
998 //my0DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1000 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
1001 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1003 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
1004 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1005 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
1006 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
1008 vtkFloatingPointType aFactor, aUnits;
1009 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
1010 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
1011 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
1013 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1017 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
1018 SetIsShrunkable(true);
1020 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
1022 int aMode = mgr->integerValue( "SMESH", "display_mode" );
1023 SetRepresentation(-1);
1026 SetRepresentation(eEdge);
1027 }else if(aMode == 1){
1028 SetRepresentation(eSurface);
1029 }else if(aMode == 2){
1030 SetRepresentation(ePoint);
1037 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1038 SetIsDisplayNameActor( true );
1040 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 ); // dot
1041 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 ); // 5 pixels
1042 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
1044 myTimeStamp->Modified();
1050 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
1051 return myNodeActor->GetBounds();
1055 vtkDataSet* SMESH_ActorDef::GetInput(){
1056 return GetUnstructuredGrid();
1060 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
1061 Superclass::SetTransform(theTransform);
1063 myNodeActor->SetTransform(theTransform);
1064 myBaseActor->SetTransform(theTransform);
1066 myHighlitableActor->SetTransform(theTransform);
1068 myNodeExtActor->SetTransform(theTransform);
1070 my0DActor->SetTransform(theTransform);
1071 //my0DExtActor->SetTransform(theTransform);
1073 my1DActor->SetTransform(theTransform);
1074 my1DExtActor->SetTransform(theTransform);
1076 my2DActor->SetTransform(theTransform);
1077 my2DExtActor->SetTransform(theTransform);
1078 my3DActor->SetTransform(theTransform);
1079 my3DExtActor->SetTransform(theTransform);
1085 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
1086 vtkLODActor::SetMapper(theMapper);
1090 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
1091 SALOME_Actor::ShallowCopy(prop);
1095 vtkMapper* SMESH_ActorDef::GetMapper(){
1096 return myPickableActor->GetMapper();
1100 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
1101 return myVisualObj->GetUnstructuredGrid();
1105 bool SMESH_ActorDef::IsInfinitive(){
1106 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
1108 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
1109 ( aDataSet->GetNumberOfCells() == 1 &&
1110 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
1111 return SALOME_Actor::IsInfinitive();
1115 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
1116 if ( myIsShrinkable == theShrunkable )
1118 myIsShrinkable = theShrunkable;
1122 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
1123 return myBaseActor->GetShrinkFactor();
1126 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
1127 myBaseActor->SetShrinkFactor(theValue);
1129 my1DActor->SetShrinkFactor(theValue);
1130 my1DExtActor->SetShrinkFactor(theValue);
1132 my2DActor->SetShrinkFactor(theValue);
1133 my2DExtActor->SetShrinkFactor(theValue);
1134 my3DActor->SetShrinkFactor(theValue);
1135 my3DExtActor->SetShrinkFactor(theValue);
1136 my3DExtActor->SetShrinkFactor(theValue);
1137 myHighlitableActor->SetShrinkFactor(theValue);
1142 void SMESH_ActorDef::SetShrink(){
1143 if(!myIsShrinkable) return;
1145 myBaseActor->SetShrink();
1147 my1DActor->SetShrink();
1148 my1DExtActor->SetShrink();
1150 my2DActor->SetShrink();
1151 my2DExtActor->SetShrink();
1152 my3DActor->SetShrink();
1153 my3DExtActor->SetShrink();
1154 myHighlitableActor->SetShrink();
1160 void SMESH_ActorDef::UnShrink(){
1161 if(!myIsShrunk) return;
1163 myBaseActor->UnShrink();
1165 my1DActor->UnShrink();
1166 my1DExtActor->UnShrink();
1168 my2DActor->UnShrink();
1169 my2DExtActor->UnShrink();
1170 my3DActor->UnShrink();
1171 my3DExtActor->UnShrink();
1172 myHighlitableActor->UnShrink();
1179 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1180 return myPickableActor->GetNodeObjId(theVtkID);
1183 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1184 return myPickableActor->GetNodeCoord(theObjID);
1188 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1189 return myPickableActor->GetElemObjId(theVtkID);
1192 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1193 return myPickableActor->GetElemCell(theObjID);
1197 void SMESH_ActorDef::SetVisibility(int theMode){
1198 SetVisibility(theMode,true);
1202 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1203 SALOME_Actor::SetVisibility(theMode);
1205 myNodeActor->VisibilityOff();
1206 myBaseActor->VisibilityOff();
1208 myNodeExtActor->VisibilityOff();
1210 my0DActor->VisibilityOff();
1211 //my0DExtActor->VisibilityOff();
1213 my1DActor->VisibilityOff();
1214 my1DExtActor->VisibilityOff();
1216 my2DActor->VisibilityOff();
1217 my2DExtActor->VisibilityOff();
1218 my3DActor->VisibilityOff();
1219 my3DExtActor->VisibilityOff();
1221 myScalarBarActor->VisibilityOff();
1223 if(GetVisibility()){
1224 if(theIsUpdateRepersentation)
1225 SetRepresentation(GetRepresentation());
1227 if(myControlMode != eNone){
1228 switch(myControlMode){
1230 case eCoincidentNodes:
1231 myNodeExtActor->VisibilityOn();
1235 case eCoincidentElems1D:
1237 case eMultiConnection2D:
1238 my1DExtActor->VisibilityOn();
1241 case eBareBorderFace:
1242 case eOverConstrainedFace:
1243 case eCoincidentElems2D:
1244 my2DExtActor->VisibilityOn();
1246 case eBareBorderVolume:
1247 case eOverConstrainedVolume:
1248 case eCoincidentElems3D:
1249 my3DExtActor->VisibilityOn();
1252 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1253 myScalarBarActor->VisibilityOn();
1257 if(myRepresentation != ePoint)
1258 myPickableActor->VisibilityOn();
1260 myNodeActor->VisibilityOn();
1263 if(myEntityMode & e0DElements){
1264 my0DActor->VisibilityOn();
1267 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
1268 my1DActor->VisibilityOn();
1271 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
1272 my2DActor->VisibilityOn();
1275 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
1276 my3DActor->VisibilityOn();
1279 if(myNodeActor->GetPointsLabeled()){
1280 myNodeActor->VisibilityOn();
1284 my0DActor->UpdateLabels();
1287 my1DActor->UpdateLabels();
1290 my2DActor->UpdateLabels();
1293 my3DActor->UpdateLabels();
1295 #ifndef DISABLE_PLOT2DVIEWER
1297 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
1304 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
1306 myEntityState = eAllEntity;
1308 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
1309 myEntityState &= ~e0DElements;
1310 theMode &= ~e0DElements;
1313 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
1314 myEntityState &= ~eEdges;
1318 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
1319 myEntityState &= ~eFaces;
1323 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
1324 myEntityState &= ~eVolumes;
1325 theMode &= ~eVolumes;
1329 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
1330 theMode |= e0DElements;
1332 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1335 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1338 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1339 theMode |= eVolumes;
1342 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1344 myEntityMode = theMode;
1345 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1346 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1347 aFilter->ClearRegisteredCellsWithType();
1348 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1350 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
1351 aHightFilter->ClearRegisteredCellsWithType();
1352 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1354 if (myEntityMode & e0DElements) {
1355 if (MYDEBUG) MESSAGE("0D ELEMENTS");
1356 aFilter->RegisterCellsWithType(VTK_VERTEX);
1357 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
1360 if (myEntityMode & eEdges) {
1361 if (MYDEBUG) MESSAGE("EDGES");
1362 aFilter->RegisterCellsWithType(VTK_LINE);
1363 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1365 aHightFilter->RegisterCellsWithType(VTK_LINE);
1366 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1369 if (myEntityMode & eFaces) {
1370 if (MYDEBUG) MESSAGE("FACES");
1371 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1372 aFilter->RegisterCellsWithType(VTK_POLYGON);
1373 aFilter->RegisterCellsWithType(VTK_QUAD);
1374 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1375 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1376 aFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1378 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
1379 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
1380 aHightFilter->RegisterCellsWithType(VTK_QUAD);
1381 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1382 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1383 aHightFilter->RegisterCellsWithType(VTK_BIQUADRATIC_QUAD);
1386 if (myEntityMode & eVolumes) {
1387 if (MYDEBUG) MESSAGE("VOLUMES");
1388 aFilter->RegisterCellsWithType(VTK_TETRA);
1389 aFilter->RegisterCellsWithType(VTK_VOXEL);
1390 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1391 aFilter->RegisterCellsWithType(VTK_WEDGE);
1392 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1393 aFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1394 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1395 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1396 aFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1397 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1398 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1399 //#ifdef VTK_HAVE_POLYHEDRON
1400 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1403 aHightFilter->RegisterCellsWithType(VTK_TETRA);
1404 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
1405 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1406 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
1407 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
1408 aHightFilter->RegisterCellsWithType(VTK_HEXAGONAL_PRISM);
1409 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1410 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1411 aHightFilter->RegisterCellsWithType(VTK_TRIQUADRATIC_HEXAHEDRON);
1412 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1413 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
1414 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1415 //#ifdef VTK_HAVE_POLYHEDRON
1416 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
1420 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1421 SetVisibility(GetVisibility(),false);
1424 void SMESH_ActorDef::SetRepresentation (int theMode)
1426 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1427 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1428 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1431 myRepresentation = eSurface;
1432 if (!aNbFaces && !aNbVolumes && aNbEdges) {
1433 myRepresentation = eEdge;
1434 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
1435 myRepresentation = ePoint;
1440 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
1443 if (!aNbFaces && !aNbVolumes) return;
1446 myRepresentation = theMode;
1449 if (!GetUnstructuredGrid()->GetNumberOfCells())
1450 myRepresentation = ePoint;
1453 if (myRepresentation == ePoint) {
1461 myPickableActor = myBaseActor;
1462 myNodeActor->SetVisibility(false);
1463 myNodeExtActor->SetVisibility(false);
1464 vtkProperty *aProp = NULL, *aBackProp = NULL;
1465 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1466 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
1467 switch (myRepresentation) {
1469 myPickableActor = myNodeActor;
1470 myNodeActor->SetVisibility(true);
1471 aQuadraticMode = SMESH_Actor::eLines;
1472 aProp = aBackProp = myNodeProp;
1473 aReperesent = SMESH_DeviceActor::ePoint;
1476 aProp = aBackProp = myEdgeProp;
1477 aReperesent = SMESH_DeviceActor::eInsideframe;
1480 aProp = mySurfaceProp;
1481 aBackProp = myBackSurfaceProp;
1482 aReperesent = SMESH_DeviceActor::eSurface;
1486 my2DActor->SetProperty(aProp);
1487 my2DActor->SetBackfaceProperty(aBackProp);
1488 my2DActor->SetRepresentation(aReperesent);
1490 if(aQuadraticMode == SMESH_Actor::eLines)
1491 my2DActor->SetQuadraticArcMode(false);
1492 else if(aQuadraticMode == SMESH_Actor::eArcs)
1493 my2DActor->SetQuadraticArcMode(true);
1495 my2DExtActor->SetRepresentation(aReperesent);
1497 my3DActor->SetProperty(aProp);
1498 my3DActor->SetBackfaceProperty(aBackProp);
1499 my3DActor->SetRepresentation(aReperesent);
1501 //my0DExtActor->SetVisibility(false);
1502 my1DExtActor->SetVisibility(false);
1503 my2DExtActor->SetVisibility(false);
1504 my3DExtActor->SetVisibility(false);
1507 //my0DActor->SetProperty(aProp);
1508 //my0DActor->SetBackfaceProperty(aBackProp);
1509 my0DActor->SetRepresentation(aReperesent);
1510 //my0DExtActor->SetRepresentation(aReperesent);
1512 switch(myControlMode){
1514 case eMultiConnection:
1515 aProp = aBackProp = my1DProp;
1516 if(myRepresentation != ePoint)
1517 aReperesent = SMESH_DeviceActor::eInsideframe;
1521 if(aQuadraticMode == SMESH_Actor::eLines)
1522 my1DActor->SetQuadraticArcMode(false);
1523 else if(aQuadraticMode == SMESH_Actor::eArcs)
1524 my1DActor->SetQuadraticArcMode(true);
1526 my1DActor->SetProperty(aProp);
1527 my1DActor->SetBackfaceProperty(aBackProp);
1528 my1DActor->SetRepresentation(aReperesent);
1530 my1DExtActor->SetRepresentation(aReperesent);
1532 if(myIsPointsVisible)
1533 myPickableActor = myNodeActor;
1534 if(GetPointRepresentation())
1535 myNodeActor->SetVisibility(true);
1537 SetMapper(myPickableActor->GetMapper());
1539 SetVisibility(GetVisibility(),false);
1545 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1546 if ( myIsPointsVisible == theIsPointsVisible )
1548 myIsPointsVisible = theIsPointsVisible;
1549 SetRepresentation(GetRepresentation());
1552 bool SMESH_ActorDef::GetPointRepresentation(){
1553 return myIsPointsVisible || myNodeActor->GetPointsLabeled();
1557 void SMESH_ActorDef::UpdateHighlight(){
1558 myHighlitableActor->SetHighlited(false);
1559 myHighlitableActor->SetVisibility(false);
1561 bool anIsVisible = GetVisibility();
1563 switch(myRepresentation){
1564 case SMESH_DeviceActor::eSurface:
1565 case SMESH_DeviceActor::eWireframe:
1567 if(myIsHighlighted) {
1568 myHighlitableActor->SetProperty(myHighlightProp);
1569 }else if(myIsPreselected){
1570 myHighlitableActor->SetProperty(myPreselectProp);
1571 } else if(anIsVisible){
1572 (myRepresentation == eSurface) ?
1573 myHighlitableActor->SetProperty(myOutLineProp) : myHighlitableActor->SetProperty(myEdgeProp);
1575 if(GetUnstructuredGrid()->GetNumberOfCells()) {
1576 myHighlitableActor->SetHighlited(anIsVisible);
1577 myHighlitableActor->GetExtractUnstructuredGrid()->
1578 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1579 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1581 myHighlitableActor->SetVisibility(anIsVisible);
1584 case SMESH_DeviceActor::ePoint:
1586 if(myIsHighlighted) {
1587 myNodeActor->SetProperty(myHighlightProp);
1588 }else if(myIsPreselected) {
1589 myNodeActor->SetProperty(myPreselectProp);
1590 } else if(anIsVisible) {
1591 myNodeActor->SetProperty(myNodeProp);
1593 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1594 myNodeActor->GetExtractUnstructuredGrid()->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1601 void SMESH_ActorDef::highlight(bool theHighlight){
1602 if ( myIsHighlighted == theHighlight )
1604 myIsHighlighted = theHighlight;
1609 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1610 if ( myIsPreselected == thePreselect )
1612 myIsPreselected = thePreselect;
1618 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1620 if (myPickableActor->GetIsOpaque())
1622 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1630 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1632 if (!myPickableActor->GetIsOpaque())
1634 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1642 void SMESH_ActorDef::Render(vtkRenderer *ren){
1643 unsigned long aTime = myTimeStamp->GetMTime();
1644 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1645 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1646 if(anObjTime > aTime || aClippingTime > aTime)
1651 void SMESH_ActorDef::Update(){
1652 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1654 if(GetControlMode() != eNone) {
1655 unsigned long aTime = myTimeStamp->GetMTime();
1656 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1657 if (anObjTime > aTime)
1658 SetControlMode(GetControlMode(),false);
1662 myNodeActor->UpdateLabels();
1665 my0DActor->UpdateLabels();
1668 my1DActor->UpdateLabels();
1671 my2DActor->UpdateLabels();
1674 my3DActor->UpdateLabels();
1676 if(myIsFacesOriented){
1677 SetFacesOriented(myIsFacesOriented);
1680 if(myVisualObj->GetEntitiesFlag()) {
1681 myEntityMode |= myVisualObj->GetEntitiesState();
1684 SetEntityMode(GetEntityMode());
1685 SetVisibility(GetVisibility());
1687 myTimeStamp->Modified();
1692 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1693 SALOME_Actor::ReleaseGraphicsResources(renWin);
1695 myPickableActor->ReleaseGraphicsResources(renWin);
1699 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1700 vtkFloatingPointType* aColor = theProperty->GetColor();
1707 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1708 mySurfaceProp->SetOpacity(theValue);
1709 myBackSurfaceProp->SetOpacity(theValue);
1710 myEdgeProp->SetOpacity(theValue);
1711 myNodeProp->SetOpacity(theValue);
1713 my1DProp->SetOpacity(theValue);
1717 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1718 return mySurfaceProp->GetOpacity();
1722 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b, int delta){
1723 mySurfaceProp->SetColor(r,g,b);
1724 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1725 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
1726 aGroupObj->GetElementType() == SMDSAbs_Volume )
1727 myNameActor->SetBackgroundColor(r,g,b);
1729 myDeltaBrightness = delta;
1730 QColor bfc = Qtx::mainColorToSecondary(QColor(int(r*255),int(g*255),int(b*255)), delta);
1731 myBackSurfaceProp->SetColor( bfc.red() / 255. , bfc.green() / 255. , bfc.blue() / 255. );
1735 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b, int& delta){
1736 ::GetColor(mySurfaceProp,r,g,b);
1737 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1738 delta = myDeltaBrightness;
1741 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1742 myEdgeProp->SetColor(r,g,b);
1743 my1DProp->SetColor(r,g,b);
1744 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1745 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1746 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
1747 myNameActor->SetBackgroundColor(r,g,b);
1751 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1752 ::GetColor(myEdgeProp,r,g,b);
1755 void SMESH_ActorDef::SetOutlineColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1756 myOutLineProp->SetColor(r,g,b);
1760 void SMESH_ActorDef::GetOutlineColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1761 ::GetColor(myOutLineProp,r,g,b);
1765 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1766 myNodeProp->SetColor(r,g,b);
1767 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1768 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1769 if( aGroupObj->GetElementType() == SMDSAbs_Node )
1770 myNameActor->SetBackgroundColor(r,g,b);
1774 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1775 ::GetColor(myNodeProp,r,g,b);
1778 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1779 my0DProp->SetColor(r,g,b);
1780 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
1781 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
1782 myNameActor->SetBackgroundColor(r,g,b);
1786 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1787 ::GetColor(my0DProp,r,g,b);
1790 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1791 myHighlightProp->SetColor(r,g,b);
1795 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1796 ::GetColor(myHighlightProp,r,g,b);
1799 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1800 myPreselectProp->SetColor(r,g,b);
1804 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1805 ::GetColor(myPreselectProp,r,g,b);
1809 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1810 return myEdgeProp->GetLineWidth();
1814 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1815 myEdgeProp->SetLineWidth(theVal);
1817 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1818 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1819 my2DExtProp->SetLineWidth(theVal + aLineWidthInc);
1820 myOutLineProp->SetLineWidth(theVal);
1821 myHighlightProp->SetLineWidth(theVal);
1822 myPreselectProp->SetLineWidth(theVal);
1827 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
1828 my0DProp->SetPointSize(theVal);
1832 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
1833 return my0DProp->GetPointSize();
1836 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1838 return myVisualObj->GetElemDimension( theObjId );
1843 IsImplicitFunctionUsed() const
1845 return myBaseActor->IsImplicitFunctionUsed();
1849 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1851 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1852 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1854 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1856 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1858 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1859 //my0DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1861 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1862 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1864 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1865 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1866 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1867 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1871 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
1874 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1875 myCippingPlaneCont.push_back(thePlane);
1876 if(!IsImplicitFunctionUsed())
1877 SetImplicitFunctionUsed(true);
1878 myNodeActor->UpdateLabels();
1880 return myCippingPlaneCont.size();
1885 RemoveAllClippingPlanes()
1887 myImplicitBoolean->GetFunction()->RemoveAllItems();
1888 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1889 myCippingPlaneCont.clear();
1890 SetImplicitFunctionUsed(false);
1891 myNodeActor->UpdateLabels();
1896 GetNumberOfClippingPlanes()
1898 return myCippingPlaneCont.size();
1903 GetClippingPlane(vtkIdType theID)
1905 if(theID >= myCippingPlaneCont.size())
1907 return myCippingPlaneCont[theID].Get();
1910 void SMESH_ActorDef::UpdateScalarBar()
1912 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1916 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1918 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1919 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1921 aScalarBarTitleProp->SetFontFamilyToArial();
1923 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1925 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1926 if ( f.family() == "Arial" )
1927 aScalarBarTitleProp->SetFontFamilyToArial();
1928 else if ( f.family() == "Courier" )
1929 aScalarBarTitleProp->SetFontFamilyToCourier();
1930 else if ( f.family() == "Times" )
1931 aScalarBarTitleProp->SetFontFamilyToTimes();
1934 aScalarBarTitleProp->BoldOn();
1936 aScalarBarTitleProp->BoldOff();
1939 aScalarBarTitleProp->ItalicOn();
1941 aScalarBarTitleProp->ItalicOff();
1944 aScalarBarTitleProp->ShadowOn();
1946 aScalarBarTitleProp->ShadowOff();
1949 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1950 aScalarBarTitleProp->Delete();
1952 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1954 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1955 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1957 aScalarBarLabelProp->SetFontFamilyToArial();
1958 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1960 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1961 if( f.family() == "Arial" )
1962 aScalarBarLabelProp->SetFontFamilyToArial();
1963 else if( f.family() == "Courier" )
1964 aScalarBarLabelProp->SetFontFamilyToCourier();
1965 else if( f.family() == "Times" )
1966 aScalarBarLabelProp->SetFontFamilyToTimes();
1969 aScalarBarLabelProp->BoldOn();
1971 aScalarBarLabelProp->BoldOff();
1974 aScalarBarLabelProp->ItalicOn();
1976 aScalarBarLabelProp->ItalicOff();
1979 aScalarBarLabelProp->ShadowOn();
1981 aScalarBarLabelProp->ShadowOff();
1984 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1985 aScalarBarLabelProp->Delete();
1987 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1988 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1990 myScalarBarActor->SetOrientationToHorizontal();
1992 myScalarBarActor->SetOrientationToVertical();
1995 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1996 if( mgr->hasValue( "SMESH", name + "x" ) )
1997 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1999 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
2000 if( mgr->hasValue( "SMESH", name + "y" ) )
2001 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
2002 myScalarBarActor->SetPosition( aXVal, aYVal );
2004 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
2005 if( mgr->hasValue( "SMESH", name + "width" ) )
2006 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
2007 myScalarBarActor->SetWidth( aWVal );
2009 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
2010 if( mgr->hasValue( "SMESH", name + "height" ) )
2011 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
2012 myScalarBarActor->SetHeight( aHVal );
2015 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
2016 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
2017 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
2020 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
2021 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
2022 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
2024 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
2025 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
2027 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
2028 myScalarBarActor->SetDistributionColoringType(coloringType);
2030 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
2031 QColor(255, 255, 255));
2033 rgb[0]= distributionColor.red()/255.;
2034 rgb[1]= distributionColor.green()/255.;
2035 rgb[2]= distributionColor.blue()/255.;
2036 myScalarBarActor->SetDistributionColor(rgb);
2041 void SMESH_ActorDef::UpdateDistribution()
2043 if(SMESH::Controls::NumericalFunctor* fun =
2044 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2046 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2047 std::vector<int> nbEvents;
2048 std::vector<double> funValues;
2049 SMESH_VisualObjDef::TEntityList elems;
2050 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2051 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2052 std::vector<int> elemIds;
2053 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2054 elemIds.push_back( (*e)->GetID());
2055 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2056 double * range = lookupTable->GetRange();
2057 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2058 myScalarBarActor->SetDistribution(nbEvents);
2062 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
2065 case SMESH_Actor::eLines :
2066 myHighlitableActor->SetQuadraticArcMode(false);
2067 my2DActor->SetQuadraticArcMode(false);
2068 my1DActor->SetQuadraticArcMode(false);
2070 case SMESH_Actor::eArcs :
2071 myHighlitableActor->SetQuadraticArcMode(true);
2072 if(GetRepresentation() != SMESH_Actor::ePoint) {
2073 my2DActor->SetQuadraticArcMode(true);
2074 my1DActor->SetQuadraticArcMode(true);
2083 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
2085 if(myHighlitableActor->GetQuadraticArcMode())
2086 return SMESH_Actor::eArcs;
2088 return SMESH_Actor::eLines;
2091 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
2093 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
2094 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
2095 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
2098 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
2100 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
2101 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2102 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
2103 myMarkerTexture = theMarkerTexture; // for deferred update of myHighlightActor
2106 #ifndef DISABLE_PLOT2DVIEWER
2107 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
2110 my2dHistogram->clearAllPoints();
2112 if(SMESH::Controls::NumericalFunctor* fun =
2113 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
2116 if(!my2dHistogram) {
2117 my2dHistogram = new SPlot2d_Histogram();
2118 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
2119 my2dHistogram->setIO(anIO);
2122 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
2123 std::vector<int> nbEvents;
2124 std::vector<double> funValues;
2125 SMESH_VisualObjDef::TEntityList elems;
2126 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
2127 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
2128 std::vector<int> elemIds;
2130 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
2131 elemIds.push_back( (*e)->GetID());
2133 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
2134 double * range = lookupTable->GetRange();
2135 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
2137 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
2138 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
2140 if(funValues.size() >= 2)
2141 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
2145 //Color of the histogram
2146 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
2147 my2dHistogram->setAutoAssign(true);
2150 myScalarBarActor->GetDistributionColor(rgb);
2151 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
2152 my2dHistogram->setColor(aColor);
2156 return my2dHistogram;