1 // Copyright (C) 2007-2008 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
22 // SMESH OBJECT : interactive object for SMESH visualization
23 // File : SMESH_Actor.cxx
24 // Author : Nicolas REJNERI
28 #include "SMESH_ActorDef.h"
29 #include "SMESH_ActorUtils.h"
30 #include "SMESH_DeviceActor.h"
31 #include "SMESH_ObjectDef.h"
32 #include "SMESH_ControlsDef.hxx"
33 #include "VTKViewer_ExtractUnstructuredGrid.h"
34 #include "VTKViewer_FramedTextActor.h"
35 #include "SALOME_InteractiveObject.hxx"
37 #include "SUIT_Session.h"
38 #include "SUIT_ResourceMgr.h"
40 #include <vtkProperty.h>
41 #include <vtkTimeStamp.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkShrinkPolyData.h>
44 #include <vtkMergeFilter.h>
46 #include <vtkMatrix4x4.h>
47 #include <vtkUnstructuredGrid.h>
48 #include <vtkPointData.h>
49 #include <vtkCellData.h>
51 #include <vtkMapper.h>
52 #include <vtkRenderer.h>
55 #include <vtkIdList.h>
56 #include <vtkIntArray.h>
58 #include <vtkActor2D.h>
59 #include <vtkProperty2D.h>
60 #include <vtkPolyData.h>
61 #include <vtkMaskPoints.h>
62 #include <vtkCellCenters.h>
63 #include <vtkTextProperty.h>
64 #include <vtkLabeledDataMapper.h>
65 #include <vtkSelectVisiblePoints.h>
67 #include <vtkScalarBarActor.h>
68 #include <vtkLookupTable.h>
72 #include <vtkImplicitBoolean.h>
73 #include <vtkImplicitFunctionCollection.h>
75 #include "utilities.h"
78 static int MYDEBUG = 1;
80 static int MYDEBUG = 0;
83 static int aLineWidthInc = 2;
84 static int aPointSizeInc = 2;
87 SMESH_ActorDef* SMESH_ActorDef::New(){
88 return new SMESH_ActorDef();
92 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
97 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
98 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
103 anActor->UpdateScalarBar();
108 SMESH_ActorDef::SMESH_ActorDef()
110 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
112 myTimeStamp = vtkTimeStamp::New();
114 myIsPointsVisible = false;
116 myIsShrinkable = false;
119 myIsFacesOriented = false;
121 myControlsPrecision = -1;
122 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
124 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
125 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
127 vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
128 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
130 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
131 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
133 //Definition 2D and 3D divices of the actor
134 //-----------------------------------------
135 vtkFloatingPointType anRGB[3] = {1,1,1};
136 mySurfaceProp = vtkProperty::New();
137 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
138 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
140 myBackSurfaceProp = vtkProperty::New();
141 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
142 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
144 my2DActor = SMESH_DeviceActor::New();
145 my2DActor->SetUserMatrix(aMatrix);
146 my2DActor->PickableOff();
147 my2DActor->SetProperty(mySurfaceProp);
148 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
149 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
150 aFilter = my2DActor->GetExtractUnstructuredGrid();
151 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
152 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
153 aFilter->RegisterCellsWithType(VTK_POLYGON);
154 aFilter->RegisterCellsWithType(VTK_QUAD);
155 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
156 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
158 my2DExtProp = vtkProperty::New();
159 my2DExtProp->DeepCopy(mySurfaceProp);
160 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
161 anRGB[0] = 1 - anRGB[0];
162 anRGB[1] = 1 - anRGB[1];
163 anRGB[2] = 1 - anRGB[2];
164 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
166 my2DExtActor = SMESH_DeviceActor::New();
167 my2DExtActor->SetUserMatrix(aMatrix);
168 my2DExtActor->PickableOff();
169 my2DExtActor->SetProperty(my2DExtProp);
170 my2DExtActor->SetBackfaceProperty(my2DExtProp);
171 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
172 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
173 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
174 aFilter->RegisterCellsWithType(VTK_POLYGON);
175 aFilter->RegisterCellsWithType(VTK_QUAD);
176 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
177 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
179 my3DActor = SMESH_DeviceActor::New();
180 my3DActor->SetUserMatrix(aMatrix);
181 my3DActor->PickableOff();
182 my3DActor->SetProperty(mySurfaceProp);
183 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
184 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
185 aFilter = my3DActor->GetExtractUnstructuredGrid();
186 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
187 aFilter->RegisterCellsWithType(VTK_TETRA);
188 aFilter->RegisterCellsWithType(VTK_VOXEL);
189 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
190 aFilter->RegisterCellsWithType(VTK_WEDGE);
191 aFilter->RegisterCellsWithType(VTK_PYRAMID);
192 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
193 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
194 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
195 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
197 //Definition 1D divice of the actor
198 //---------------------------------
199 myEdgeProp = vtkProperty::New();
200 myEdgeProp->SetAmbient(1.0);
201 myEdgeProp->SetDiffuse(0.0);
202 myEdgeProp->SetSpecular(0.0);
203 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
204 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
205 myEdgeProp->SetLineWidth(aLineWidth);
207 my1DActor = SMESH_DeviceActor::New();
208 my1DActor->SetUserMatrix(aMatrix);
209 my1DActor->PickableOff();
210 my1DActor->SetHighlited(true);
211 my1DActor->SetProperty(myEdgeProp);
212 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
213 aFilter = my1DActor->GetExtractUnstructuredGrid();
214 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
215 aFilter->RegisterCellsWithType(VTK_LINE);
216 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
218 my1DProp = vtkProperty::New();
219 my1DProp->DeepCopy(myEdgeProp);
220 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
221 my1DProp->SetPointSize(aPointSize);
223 my1DExtProp = vtkProperty::New();
224 my1DExtProp->DeepCopy(myEdgeProp);
225 anRGB[0] = 1 - anRGB[0];
226 anRGB[1] = 1 - anRGB[1];
227 anRGB[2] = 1 - anRGB[2];
228 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
229 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
230 my1DExtProp->SetPointSize(aPointSize + aPointSizeInc);
232 my1DExtActor = SMESH_DeviceActor::New();
233 my1DExtActor->SetUserMatrix(aMatrix);
234 my1DExtActor->PickableOff();
235 my1DExtActor->SetHighlited(true);
236 my1DExtActor->SetVisibility(false);
237 my1DExtActor->SetProperty(my1DExtProp);
238 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
239 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
240 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
241 aFilter->RegisterCellsWithType(VTK_LINE);
242 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
245 //Definition 0D divice of the actor
246 //---------------------------------
247 myNodeProp = vtkProperty::New();
248 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
249 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
250 myNodeProp->SetPointSize(aPointSize);
252 myNodeActor = SMESH_DeviceActor::New();
253 myNodeActor->SetUserMatrix(aMatrix);
254 myNodeActor->SetStoreClippingMapping(true);
255 myNodeActor->PickableOff();
256 myNodeActor->SetVisibility(false);
257 myNodeActor->SetProperty(myNodeProp);
258 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
259 aFilter = myNodeActor->GetExtractUnstructuredGrid();
260 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
262 myNodeExtProp = vtkProperty::New();
263 myNodeExtProp->DeepCopy(myNodeProp);
264 anRGB[0] = 1 - anRGB[0];
265 anRGB[1] = 1 - anRGB[1];
266 anRGB[2] = 1 - anRGB[2];
267 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
268 myNodeExtProp->SetPointSize(aPointSize);
270 myNodeExtActor = SMESH_DeviceActor::New();
271 myNodeExtActor->SetUserMatrix(aMatrix);
272 myNodeExtActor->SetStoreClippingMapping(true);
273 myNodeExtActor->PickableOff();
274 myNodeExtActor->SetHighlited(true);
275 myNodeExtActor->SetVisibility(false);
276 myNodeExtActor->SetProperty(myNodeExtProp);
277 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
278 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
279 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
280 aFilter->RegisterCellsWithType(VTK_VERTEX);
282 //Definition of Pickable and Highlitable engines
283 //----------------------------------------------
285 myBaseActor = SMESH_DeviceActor::New();
286 myBaseActor->SetUserMatrix(aMatrix);
287 myBaseActor->SetStoreGemetryMapping(true);
288 myBaseActor->GetProperty()->SetOpacity(0.0);
290 myPickableActor = myBaseActor;
292 myHighlightProp = vtkProperty::New();
293 myHighlightProp->SetAmbient(1.0);
294 myHighlightProp->SetDiffuse(0.0);
295 myHighlightProp->SetSpecular(0.0);
296 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
297 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
298 myHighlightProp->SetPointSize(aPointSize);
299 myHighlightProp->SetRepresentation(1);
301 myPreselectProp = vtkProperty::New();
302 myPreselectProp->SetAmbient(1.0);
303 myPreselectProp->SetDiffuse(0.0);
304 myPreselectProp->SetSpecular(0.0);
305 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
306 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
307 myPreselectProp->SetPointSize(aPointSize);
308 myPreselectProp->SetRepresentation(1);
310 myHighlitableActor = SMESH_DeviceActor::New();
311 myHighlitableActor->SetUserMatrix(aMatrix);
312 myHighlitableActor->PickableOff();
313 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
318 myControlMode = eNone;
319 myControlActor = my2DActor;
321 //Definition of myScalarBarActor
322 //------------------------------
323 myLookupTable = vtkLookupTable::New();
324 //Fix for Bug PAL5195 - SMESH764:
325 //Controls - Aspect Ratio: incorrect colors of the best and worst values
326 myLookupTable->SetHueRange(0.667,0.0);
328 myScalarBarActor = vtkScalarBarActor::New();
329 myScalarBarActor->SetVisibility(false);
330 myScalarBarActor->SetLookupTable(myLookupTable);
333 //Incorrect "Min value" in Scalar Bar in Mesh:
334 // myScalarBarActor->SetLabelFormat("%.4g");
335 // changes was commented because of regression bug IPAL 19981
337 mgr = SUIT_Session::session()->resourceMgr();
341 //Definition of points numbering pipeline
342 //---------------------------------------
343 myPointsNumDataSet = vtkUnstructuredGrid::New();
345 myPtsMaskPoints = vtkMaskPoints::New();
346 myPtsMaskPoints->SetInput(myPointsNumDataSet);
347 myPtsMaskPoints->SetOnRatio(1);
349 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
350 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
351 myPtsSelectVisiblePoints->SelectInvisibleOff();
352 myPtsSelectVisiblePoints->SetTolerance(0.1);
354 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
355 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
356 myPtsLabeledDataMapper->SetLabelFormat("%g");
357 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
359 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
360 aPtsTextProp->SetFontFamilyToTimes();
361 static int aPointsFontSize = 10;
362 aPtsTextProp->SetFontSize(aPointsFontSize);
363 aPtsTextProp->SetBold(1);
364 aPtsTextProp->SetItalic(0);
365 aPtsTextProp->SetShadow(0);
366 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
367 aPtsTextProp->Delete();
369 myEntityMode = eAllEntity;
371 myIsPointsLabeled = false;
373 myPointLabels = vtkActor2D::New();
374 myPointLabels->SetMapper(myPtsLabeledDataMapper);
375 myPointLabels->GetProperty()->SetColor(1,1,1);
376 myPointLabels->SetVisibility(myIsPointsLabeled);
379 //Definition of cells numbering pipeline
380 //---------------------------------------
381 myCellsNumDataSet = vtkUnstructuredGrid::New();
383 myCellCenters = vtkCellCenters::New();
384 myCellCenters->SetInput(myCellsNumDataSet);
386 myClsMaskPoints = vtkMaskPoints::New();
387 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
388 myClsMaskPoints->SetOnRatio(1);
390 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
391 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
392 myClsSelectVisiblePoints->SelectInvisibleOff();
393 myClsSelectVisiblePoints->SetTolerance(0.1);
395 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
396 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
397 myClsLabeledDataMapper->SetLabelFormat("%g");
398 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
400 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
401 aClsTextProp->SetFontFamilyToTimes();
402 static int aCellsFontSize = 12;
403 aClsTextProp->SetFontSize(aCellsFontSize);
404 aClsTextProp->SetBold(1);
405 aClsTextProp->SetItalic(0);
406 aClsTextProp->SetShadow(0);
407 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
408 aClsTextProp->Delete();
410 myIsCellsLabeled = false;
412 myCellsLabels = vtkActor2D::New();
413 myCellsLabels->SetMapper(myClsLabeledDataMapper);
414 myCellsLabels->GetProperty()->SetColor(0,1,0);
415 myCellsLabels->SetVisibility(myIsCellsLabeled);
418 myImplicitBoolean = vtkImplicitBoolean::New();
419 myImplicitBoolean->SetOperationTypeToIntersection();
421 // Set color of the name actor
422 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
423 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
427 SMESH_ActorDef::~SMESH_ActorDef()
429 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
431 myScalarBarActor->Delete();
432 myLookupTable->Delete();
434 mySurfaceProp->Delete();
435 myBackSurfaceProp->Delete();
437 myEdgeProp->Delete();
438 myHighlightProp->Delete();
439 myPreselectProp->Delete();
441 myNodeProp->Delete();
442 myNodeExtProp->Delete();
447 my1DExtProp->Delete();
448 my1DExtActor->Delete();
451 my2DExtProp->Delete();
452 my2DExtActor->Delete();
455 myNodeActor->Delete();
456 myBaseActor->Delete();
458 myNodeExtActor->Delete();
460 myHighlitableActor->Delete();
462 //Deleting of pints numbering pipeline
463 //---------------------------------------
464 myPointsNumDataSet->Delete();
466 // commented: porting to vtk 5.0
467 // myPtsLabeledDataMapper->RemoveAllInputs();
468 myPtsLabeledDataMapper->Delete();
470 // commented: porting to vtk 5.0
471 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
472 myPtsSelectVisiblePoints->Delete();
474 // commented: porting to vtk 5.0
475 // myPtsMaskPoints->UnRegisterAllOutputs();
476 myPtsMaskPoints->Delete();
478 myPointLabels->Delete();
481 //Deleting of cells numbering pipeline
482 //---------------------------------------
483 myCellsNumDataSet->Delete();
485 myClsLabeledDataMapper->RemoveAllInputs();
486 myClsLabeledDataMapper->Delete();
488 // commented: porting to vtk 5.0
489 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
490 myClsSelectVisiblePoints->Delete();
492 // commented: porting to vtk 5.0
493 // myClsMaskPoints->UnRegisterAllOutputs();
494 myClsMaskPoints->Delete();
496 // commented: porting to vtk 5.0
497 // myCellCenters->UnRegisterAllOutputs();
498 myCellCenters->Delete();
500 myCellsLabels->Delete();
502 myImplicitBoolean->Delete();
504 myTimeStamp->Delete();
508 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
510 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
511 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
513 if ( myIsPointsLabeled )
515 myPointsNumDataSet->ShallowCopy(aGrid);
516 vtkDataSet *aDataSet = myPointsNumDataSet;
518 int aNbElem = aDataSet->GetNumberOfPoints();
520 vtkIntArray *anArray = vtkIntArray::New();
521 anArray->SetNumberOfValues( aNbElem );
523 for ( int anId = 0; anId < aNbElem; anId++ )
525 int aSMDSId = myVisualObj->GetNodeObjId( anId );
526 anArray->SetValue( anId, aSMDSId );
529 aDataSet->GetPointData()->SetScalars( anArray );
531 myPtsMaskPoints->SetInput( aDataSet );
532 myPointLabels->SetVisibility( GetVisibility() );
536 myPointLabels->SetVisibility( false );
538 SetRepresentation(GetRepresentation());
539 myTimeStamp->Modified();
543 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
545 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
546 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
547 if(myIsCellsLabeled){
548 myCellsNumDataSet->ShallowCopy(aGrid);
549 vtkDataSet *aDataSet = myCellsNumDataSet;
550 int aNbElem = aDataSet->GetNumberOfCells();
551 vtkIntArray *anArray = vtkIntArray::New();
552 anArray->SetNumberOfValues(aNbElem);
553 for(int anId = 0; anId < aNbElem; anId++){
554 int aSMDSId = myVisualObj->GetElemObjId(anId);
555 anArray->SetValue(anId,aSMDSId);
557 aDataSet->GetCellData()->SetScalars(anArray);
558 myCellCenters->SetInput(aDataSet);
559 myCellsLabels->SetVisibility(GetVisibility());
561 myCellsLabels->SetVisibility(false);
563 myTimeStamp->Modified();
567 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
569 myIsFacesOriented = theIsFacesOriented;
571 my2DActor->SetFacesOriented(theIsFacesOriented);
572 my3DActor->SetFacesOriented(theIsFacesOriented);
574 myTimeStamp->Modified();
577 bool SMESH_ActorDef::GetFacesOriented()
579 return myIsFacesOriented;
585 SetControlMode(eControl theMode)
587 SetControlMode(theMode,true);
593 SetControlMode(eControl theMode,
594 bool theCheckEntityMode)
596 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
600 myControlMode = eNone;
601 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
603 my1DActor->GetMapper()->SetScalarVisibility(false);
604 my2DActor->GetMapper()->SetScalarVisibility(false);
605 my3DActor->GetMapper()->SetScalarVisibility(false);
606 myScalarBarActor->SetVisibility(false);
608 bool anIsScalarVisible = theMode > eNone;
610 if(anIsScalarVisible){
611 SMESH::Controls::FunctorPtr aFunctor;
615 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
616 aControl->SetPrecision( myControlsPrecision );
617 aFunctor.reset( aControl );
618 myControlActor = my1DActor;
623 aFunctor.reset(new SMESH::Controls::Length2D());
624 myControlActor = my2DActor;
628 aFunctor.reset(new SMESH::Controls::FreeBorders());
629 myControlActor = my1DActor;
632 aFunctor.reset(new SMESH::Controls::FreeEdges());
633 myControlActor = my2DActor;
636 aFunctor.reset(new SMESH::Controls::FreeNodes());
637 myControlActor = myNodeActor;
640 aFunctor.reset(new SMESH::Controls::FreeFaces());
641 myControlActor = my2DActor;
643 case eMultiConnection:
644 aFunctor.reset(new SMESH::Controls::MultiConnection());
645 myControlActor = my1DActor;
647 case eMultiConnection2D:
648 aFunctor.reset(new SMESH::Controls::MultiConnection2D());
649 myControlActor = my2DActor;
653 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
654 aControl->SetPrecision( myControlsPrecision );
655 aFunctor.reset( aControl );
656 myControlActor = my2DActor;
661 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
662 aControl->SetPrecision( myControlsPrecision );
663 aFunctor.reset( aControl );
664 myControlActor = my2DActor;
669 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
670 aControl->SetPrecision( myControlsPrecision );
671 aFunctor.reset( aControl );
672 myControlActor = my2DActor;
677 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
678 aControl->SetPrecision( myControlsPrecision );
679 aFunctor.reset( aControl );
680 myControlActor = my3DActor;
685 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
686 aControl->SetPrecision( myControlsPrecision );
687 aFunctor.reset( aControl );
688 myControlActor = my3DActor;
693 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
694 aControl->SetPrecision( myControlsPrecision );
695 aFunctor.reset( aControl );
696 myControlActor = my2DActor;
701 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
702 aControl->SetPrecision( myControlsPrecision );
703 aFunctor.reset( aControl );
704 myControlActor = my2DActor;
709 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
710 aControl->SetPrecision( myControlsPrecision );
711 aFunctor.reset( aControl );
712 myControlActor = my2DActor;
719 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
720 vtkIdType aNbCells = aGrid->GetNumberOfCells();
722 myControlMode = theMode;
723 switch(myControlMode){
725 myNodeExtActor->SetExtControlMode(aFunctor);
729 my1DExtActor->SetExtControlMode(aFunctor);
732 my2DExtActor->SetExtControlMode(aFunctor);
735 case eMultiConnection2D:
736 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
739 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
743 if(theCheckEntityMode){
744 if(myControlActor == my1DActor)
745 SetEntityMode(eEdges);
746 else if(myControlActor == my2DActor){
747 switch(myControlMode){
751 case eMultiConnection2D:
752 //SetEntityMode(eEdges);
753 SetEntityMode(eFaces);
756 SetEntityMode(eFaces);
758 }else if(myControlActor == my3DActor)
759 SetEntityMode(eVolumes);
762 }else if(theCheckEntityMode){
763 myEntityMode = eAllEntity;
766 SetRepresentation(GetRepresentation());
768 myTimeStamp->Modified();
773 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
774 SALOME_Actor::AddToRender(theRenderer);
776 theRenderer->AddActor(myNodeActor);
777 theRenderer->AddActor(myBaseActor);
779 theRenderer->AddActor(myNodeExtActor);
781 my3DActor->AddToRender(theRenderer);
782 my2DActor->AddToRender(theRenderer);
783 my2DExtActor->AddToRender(theRenderer);
785 theRenderer->AddActor(my1DActor);
786 theRenderer->AddActor(my1DExtActor);
788 theRenderer->AddActor(myHighlitableActor);
790 theRenderer->AddActor2D(myScalarBarActor);
792 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
793 myClsSelectVisiblePoints->SetRenderer(theRenderer);
795 theRenderer->AddActor2D(myPointLabels);
796 theRenderer->AddActor2D(myCellsLabels);
799 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
800 SALOME_Actor::RemoveFromRender(theRenderer);
802 theRenderer->RemoveActor(myNodeActor);
803 theRenderer->RemoveActor(myBaseActor);
805 theRenderer->RemoveActor(myNodeExtActor);
807 theRenderer->RemoveActor(myHighlitableActor);
809 theRenderer->RemoveActor(my1DActor);
810 theRenderer->RemoveActor(my1DExtActor);
812 my2DActor->RemoveFromRender(theRenderer);
813 my2DExtActor->RemoveFromRender(theRenderer);
814 my3DActor->RemoveFromRender(theRenderer);
816 theRenderer->RemoveActor(myScalarBarActor);
817 theRenderer->RemoveActor(myPointLabels);
818 theRenderer->RemoveActor(myCellsLabels);
822 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
823 const char* theEntry,
827 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
831 myVisualObj = theVisualObj;
832 myVisualObj->Update(theIsClear);
834 myNodeActor->Init(myVisualObj,myImplicitBoolean);
835 myBaseActor->Init(myVisualObj,myImplicitBoolean);
837 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
839 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
841 my1DActor->Init(myVisualObj,myImplicitBoolean);
842 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
844 my2DActor->Init(myVisualObj,myImplicitBoolean);
845 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
846 my3DActor->Init(myVisualObj,myImplicitBoolean);
848 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
849 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
851 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
852 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
853 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
855 vtkFloatingPointType aFactor, aUnits;
856 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
857 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
858 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
860 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
864 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
865 SetIsShrunkable(true);
867 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
869 int aMode = mgr->integerValue( "SMESH", "display_mode" );
870 SetRepresentation(-1);
873 SetRepresentation(eEdge);
874 }else if(aMode == 1){
875 SetRepresentation(eSurface);
876 }else if(aMode == 2){
877 SetRepresentation(ePoint);
884 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
885 SetIsDisplayNameActor( true );
887 myTimeStamp->Modified();
893 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
894 return myNodeActor->GetBounds();
898 vtkDataSet* SMESH_ActorDef::GetInput(){
899 return GetUnstructuredGrid();
903 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
904 Superclass::SetTransform(theTransform);
906 myNodeActor->SetTransform(theTransform);
907 myBaseActor->SetTransform(theTransform);
909 myHighlitableActor->SetTransform(theTransform);
911 myNodeExtActor->SetTransform(theTransform);
913 my1DActor->SetTransform(theTransform);
914 my1DExtActor->SetTransform(theTransform);
916 my2DActor->SetTransform(theTransform);
917 my2DExtActor->SetTransform(theTransform);
918 my3DActor->SetTransform(theTransform);
924 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
925 vtkLODActor::SetMapper(theMapper);
929 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
930 SALOME_Actor::ShallowCopy(prop);
934 vtkMapper* SMESH_ActorDef::GetMapper(){
935 return myPickableActor->GetMapper();
939 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
940 return myVisualObj->GetUnstructuredGrid();
944 bool SMESH_ActorDef::IsInfinitive(){
945 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
947 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
948 aDataSet->GetNumberOfCells() == 1 &&
949 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX;
950 return SALOME_Actor::IsInfinitive();
954 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
955 if ( myIsShrinkable == theShrunkable )
957 myIsShrinkable = theShrunkable;
961 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
962 return myBaseActor->GetShrinkFactor();
965 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
966 myBaseActor->SetShrinkFactor(theValue);
968 my1DActor->SetShrinkFactor(theValue);
969 my1DExtActor->SetShrinkFactor(theValue);
971 my2DActor->SetShrinkFactor(theValue);
972 my2DExtActor->SetShrinkFactor(theValue);
973 my3DActor->SetShrinkFactor(theValue);
978 void SMESH_ActorDef::SetShrink(){
979 if(!myIsShrinkable) return;
981 myBaseActor->SetShrink();
983 my1DActor->SetShrink();
984 my1DExtActor->SetShrink();
986 my2DActor->SetShrink();
987 my2DExtActor->SetShrink();
988 my3DActor->SetShrink();
994 void SMESH_ActorDef::UnShrink(){
995 if(!myIsShrunk) return;
997 myBaseActor->UnShrink();
999 my1DActor->UnShrink();
1000 my1DExtActor->UnShrink();
1002 my2DActor->UnShrink();
1003 my2DExtActor->UnShrink();
1004 my3DActor->UnShrink();
1011 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
1012 return myPickableActor->GetNodeObjId(theVtkID);
1015 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
1016 return myPickableActor->GetNodeCoord(theObjID);
1020 int SMESH_ActorDef::GetElemObjId(int theVtkID){
1021 return myPickableActor->GetElemObjId(theVtkID);
1024 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
1025 return myPickableActor->GetElemCell(theObjID);
1029 void SMESH_ActorDef::SetVisibility(int theMode){
1030 SetVisibility(theMode,true);
1034 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
1035 SALOME_Actor::SetVisibility(theMode);
1037 myNodeActor->VisibilityOff();
1038 myBaseActor->VisibilityOff();
1040 myNodeExtActor->VisibilityOff();
1042 my1DActor->VisibilityOff();
1043 my1DExtActor->VisibilityOff();
1045 my2DActor->VisibilityOff();
1046 my2DExtActor->VisibilityOff();
1047 my3DActor->VisibilityOff();
1049 myScalarBarActor->VisibilityOff();
1050 myPointLabels->VisibilityOff();
1051 myCellsLabels->VisibilityOff();
1053 if(GetVisibility()){
1054 if(theIsUpdateRepersentation)
1055 SetRepresentation(GetRepresentation());
1057 if(myControlMode != eNone){
1058 switch(myControlMode){
1060 myNodeExtActor->VisibilityOn();
1064 my1DExtActor->VisibilityOn();
1067 my2DExtActor->VisibilityOn();
1070 case eMultiConnection2D:
1071 my1DExtActor->VisibilityOn();
1073 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
1074 myScalarBarActor->VisibilityOn();
1078 if(myRepresentation != ePoint)
1079 myPickableActor->VisibilityOn();
1081 myNodeActor->VisibilityOn();
1084 if(myEntityMode & eEdges){
1085 my1DActor->VisibilityOn();
1088 if(myEntityMode & eFaces){
1089 my2DActor->VisibilityOn();
1092 if(myEntityMode & eVolumes){
1093 my3DActor->VisibilityOn();
1096 if(myIsPointsLabeled){
1097 myPointLabels->VisibilityOn();
1098 myNodeActor->VisibilityOn();
1101 if(myIsCellsLabeled)
1102 myCellsLabels->VisibilityOn();
1109 void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
1110 myEntityState = eAllEntity;
1112 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)){
1113 myEntityState &= ~eEdges;
1117 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)){
1118 myEntityState &= ~eFaces;
1122 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)){
1123 myEntityState &= ~eVolumes;
1124 theMode &= ~eVolumes;
1128 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1131 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1134 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1135 theMode |= eVolumes;
1138 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1140 myEntityMode = theMode;
1141 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1142 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1143 aFilter->ClearRegisteredCellsWithType();
1144 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1146 if(myEntityMode & eEdges){
1147 if (MYDEBUG) MESSAGE("EDGES");
1148 aFilter->RegisterCellsWithType(VTK_LINE);
1149 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1152 if(myEntityMode & eFaces){
1153 if (MYDEBUG) MESSAGE("FACES");
1154 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1155 aFilter->RegisterCellsWithType(VTK_POLYGON);
1156 aFilter->RegisterCellsWithType(VTK_QUAD);
1157 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1158 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1161 if(myEntityMode & eVolumes){
1162 if (MYDEBUG) MESSAGE("VOLUMES");
1163 aFilter->RegisterCellsWithType(VTK_TETRA);
1164 aFilter->RegisterCellsWithType(VTK_VOXEL);
1165 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1166 aFilter->RegisterCellsWithType(VTK_WEDGE);
1167 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1168 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1169 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1170 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1171 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1174 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1175 SetVisibility(GetVisibility(),false);
1178 void SMESH_ActorDef::SetRepresentation(int theMode){
1179 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1180 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1181 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1183 myRepresentation = eSurface;
1184 if(!aNbFaces && !aNbVolumes && aNbEdges){
1185 myRepresentation = eEdge;
1186 }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1187 myRepresentation = ePoint;
1192 if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1195 if(!aNbFaces && !aNbVolumes) return;
1198 myRepresentation = theMode;
1201 if(!GetUnstructuredGrid()->GetNumberOfCells())
1202 myRepresentation = ePoint;
1205 if(myRepresentation == ePoint){
1213 myPickableActor = myBaseActor;
1214 myNodeActor->SetVisibility(false);
1215 myNodeExtActor->SetVisibility(false);
1216 vtkProperty *aProp = NULL, *aBackProp = NULL;
1217 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1218 switch(myRepresentation){
1220 myPickableActor = myNodeActor;
1221 myNodeActor->SetVisibility(true);
1223 aProp = aBackProp = myNodeProp;
1224 aReperesent = SMESH_DeviceActor::ePoint;
1227 aProp = aBackProp = myEdgeProp;
1228 aReperesent = SMESH_DeviceActor::eInsideframe;
1231 aProp = mySurfaceProp;
1232 aBackProp = myBackSurfaceProp;
1233 aReperesent = SMESH_DeviceActor::eSurface;
1237 my2DActor->SetProperty(aProp);
1238 my2DActor->SetBackfaceProperty(aBackProp);
1239 my2DActor->SetRepresentation(aReperesent);
1241 my2DExtActor->SetRepresentation(aReperesent);
1243 my3DActor->SetProperty(aProp);
1244 my3DActor->SetBackfaceProperty(aBackProp);
1245 my3DActor->SetRepresentation(aReperesent);
1247 my1DExtActor->SetVisibility(false);
1248 my2DExtActor->SetVisibility(false);
1250 switch(myControlMode){
1252 case eMultiConnection:
1253 aProp = aBackProp = my1DProp;
1254 if(myRepresentation != ePoint)
1255 aReperesent = SMESH_DeviceActor::eInsideframe;
1259 my1DActor->SetProperty(aProp);
1260 my1DActor->SetBackfaceProperty(aBackProp);
1261 my1DActor->SetRepresentation(aReperesent);
1263 my1DExtActor->SetRepresentation(aReperesent);
1265 if(myIsPointsVisible)
1266 myPickableActor = myNodeActor;
1267 if(GetPointRepresentation())
1268 myNodeActor->SetVisibility(true);
1270 SetMapper(myPickableActor->GetMapper());
1272 SetVisibility(GetVisibility(),false);
1278 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1279 if ( myIsPointsVisible == theIsPointsVisible )
1281 myIsPointsVisible = theIsPointsVisible;
1282 SetRepresentation(GetRepresentation());
1285 bool SMESH_ActorDef::GetPointRepresentation(){
1286 return myIsPointsVisible || myIsPointsLabeled;
1290 void SMESH_ActorDef::UpdateHighlight(){
1291 myHighlitableActor->SetVisibility(false);
1292 myHighlitableActor->SetHighlited(false);
1294 if(myIsHighlighted){
1295 myHighlitableActor->SetProperty(myHighlightProp);
1296 }else if(myIsPreselected){
1297 myHighlitableActor->SetProperty(myPreselectProp);
1300 bool anIsVisible = GetVisibility();
1302 if(myIsHighlighted || myIsPreselected){
1303 if(GetUnstructuredGrid()->GetNumberOfCells()){
1304 myHighlitableActor->SetHighlited(anIsVisible);
1305 myHighlitableActor->SetVisibility(anIsVisible);
1306 myHighlitableActor->GetExtractUnstructuredGrid()->
1307 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1308 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1309 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1310 myHighlitableActor->SetHighlited(anIsVisible);
1311 myHighlitableActor->GetExtractUnstructuredGrid()->
1312 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1313 myHighlitableActor->SetVisibility(anIsVisible);
1314 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1320 void SMESH_ActorDef::highlight(bool theHighlight){
1321 if ( myIsHighlighted == theHighlight )
1323 myIsHighlighted = theHighlight;
1328 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1329 if ( myIsPreselected == thePreselect )
1331 myIsPreselected = thePreselect;
1337 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1339 if (myPickableActor->GetIsOpaque())
1341 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1349 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1351 if (!myPickableActor->GetIsOpaque())
1353 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1361 void SMESH_ActorDef::Render(vtkRenderer *ren){
1362 unsigned long aTime = myTimeStamp->GetMTime();
1363 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1364 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1365 if(anObjTime > aTime || aClippingTime > aTime)
1370 void SMESH_ActorDef::Update(){
1371 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1373 if(GetControlMode() != eNone) {
1374 unsigned long aTime = myTimeStamp->GetMTime();
1375 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1376 if (anObjTime > aTime)
1377 SetControlMode(GetControlMode(),false);
1379 if(myIsPointsLabeled){
1380 SetPointsLabeled(myIsPointsLabeled);
1382 if(myIsCellsLabeled){
1383 SetCellsLabeled(myIsCellsLabeled);
1385 if(myIsFacesOriented){
1386 SetFacesOriented(myIsFacesOriented);
1388 SetEntityMode(GetEntityMode());
1389 SetVisibility(GetVisibility());
1391 myTimeStamp->Modified();
1396 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1397 SALOME_Actor::ReleaseGraphicsResources(renWin);
1399 myPickableActor->ReleaseGraphicsResources(renWin);
1403 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1404 vtkFloatingPointType* aColor = theProperty->GetColor();
1411 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1412 mySurfaceProp->SetOpacity(theValue);
1413 myBackSurfaceProp->SetOpacity(theValue);
1414 myEdgeProp->SetOpacity(theValue);
1415 myNodeProp->SetOpacity(theValue);
1417 my1DProp->SetOpacity(theValue);
1421 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1422 return mySurfaceProp->GetOpacity();
1426 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1427 mySurfaceProp->SetColor(r,g,b);
1428 myNameActor->SetBackgroundColor(r,g,b);
1432 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1433 ::GetColor(mySurfaceProp,r,g,b);
1434 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1437 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1438 myBackSurfaceProp->SetColor(r,g,b);
1442 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1443 ::GetColor(myBackSurfaceProp,r,g,b);
1446 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1447 myEdgeProp->SetColor(r,g,b);
1448 my1DProp->SetColor(r,g,b);
1449 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1453 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1454 ::GetColor(myEdgeProp,r,g,b);
1457 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1458 myNodeProp->SetColor(r,g,b);
1459 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1463 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1464 ::GetColor(myNodeProp,r,g,b);
1467 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1468 myHighlightProp->SetColor(r,g,b);
1472 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1473 ::GetColor(myHighlightProp,r,g,b);
1476 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1477 myPreselectProp->SetColor(r,g,b);
1481 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1482 ::GetColor(myPreselectProp,r,g,b);
1486 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1487 return myEdgeProp->GetLineWidth();
1491 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1492 myEdgeProp->SetLineWidth(theVal);
1494 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1495 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1501 void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){
1502 myNodeProp->SetPointSize(theVal);
1503 myNodeExtProp->SetPointSize(theVal);
1504 myHighlightProp->SetPointSize(theVal);
1505 myPreselectProp->SetPointSize(theVal);
1507 my1DProp->SetPointSize(theVal + aPointSizeInc);
1508 my1DExtProp->SetPointSize(theVal + aPointSizeInc);
1513 vtkFloatingPointType SMESH_ActorDef::GetNodeSize(){
1514 return myNodeProp->GetPointSize();
1517 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1519 return myVisualObj->GetElemDimension( theObjId );
1524 IsImplicitFunctionUsed() const
1526 return myBaseActor->IsImplicitFunctionUsed();
1531 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1533 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1534 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1536 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1538 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1540 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1541 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1543 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1544 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1545 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1550 AddClippingPlane(vtkPlane* thePlane)
1553 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1554 myCippingPlaneCont.push_back(thePlane);
1555 if(!IsImplicitFunctionUsed())
1556 SetImplicitFunctionUsed(true);
1558 return myCippingPlaneCont.size();
1563 RemoveAllClippingPlanes()
1565 myImplicitBoolean->GetFunction()->RemoveAllItems();
1566 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1567 myCippingPlaneCont.clear();
1568 SetImplicitFunctionUsed(false);
1573 GetNumberOfClippingPlanes()
1575 return myCippingPlaneCont.size();
1580 GetClippingPlane(vtkIdType theID)
1582 if(theID >= myCippingPlaneCont.size())
1584 return myCippingPlaneCont[theID].Get();
1588 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1589 vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1590 vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1592 vtkFloatingPointType aBounds[6];
1593 theDataSet->GetBounds(aBounds);
1595 //Enlarge bounds in order to avoid conflicts of precision
1596 for(int i = 0; i < 6; i += 2){
1597 static double EPS = 1.0E-3;
1598 vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1599 aBounds[i] -= aDelta;
1600 aBounds[i+1] += aDelta;
1603 vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1604 {aBounds[1],aBounds[2],aBounds[4]},
1605 {aBounds[0],aBounds[3],aBounds[4]},
1606 {aBounds[1],aBounds[3],aBounds[4]},
1607 {aBounds[0],aBounds[2],aBounds[5]},
1608 {aBounds[1],aBounds[2],aBounds[5]},
1609 {aBounds[0],aBounds[3],aBounds[5]},
1610 {aBounds[1],aBounds[3],aBounds[5]}};
1612 int aMaxId = 0, aMinId = aMaxId;
1613 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1614 theMinBoundPrj = theMaxBoundPrj;
1615 for(int i = 1; i < 8; i++){
1616 vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1617 if(theMaxBoundPrj < aTmp){
1618 theMaxBoundPrj = aTmp;
1621 if(theMinBoundPrj > aTmp){
1622 theMinBoundPrj = aTmp;
1626 vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1627 theMinPnt[0] = aMinPnt[0];
1628 theMinPnt[1] = aMinPnt[1];
1629 theMinPnt[2] = aMinPnt[2];
1633 static void DistanceToPosition(vtkDataSet* theDataSet,
1634 vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1636 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1637 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1638 vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1639 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1640 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1641 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1645 static void PositionToDistance(vtkDataSet* theDataSet,
1646 vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1648 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1649 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1650 vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1651 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1655 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1657 thePlane->SetNormal(theDir);
1658 vtkFloatingPointType anOrigin[3];
1659 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1660 thePlane->SetOrigin(anOrigin);
1664 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1666 thePlane->GetNormal(theDir);
1668 vtkFloatingPointType anOrigin[3];
1669 thePlane->GetOrigin(anOrigin);
1670 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1673 void SMESH_ActorDef::UpdateScalarBar()
1675 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1679 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1681 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1682 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1684 aScalarBarTitleProp->SetFontFamilyToArial();
1686 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1688 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1689 if ( f.family() == "Arial" )
1690 aScalarBarTitleProp->SetFontFamilyToArial();
1691 else if ( f.family() == "Courier" )
1692 aScalarBarTitleProp->SetFontFamilyToCourier();
1693 else if ( f.family() == "Times" )
1694 aScalarBarTitleProp->SetFontFamilyToTimes();
1697 aScalarBarTitleProp->BoldOn();
1699 aScalarBarTitleProp->BoldOff();
1702 aScalarBarTitleProp->ItalicOn();
1704 aScalarBarTitleProp->ItalicOff();
1707 aScalarBarTitleProp->ShadowOn();
1709 aScalarBarTitleProp->ShadowOff();
1712 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1713 aScalarBarTitleProp->Delete();
1715 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1717 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1718 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1720 aScalarBarLabelProp->SetFontFamilyToArial();
1721 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1723 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1724 if( f.family() == "Arial" )
1725 aScalarBarLabelProp->SetFontFamilyToArial();
1726 else if( f.family() == "Courier" )
1727 aScalarBarLabelProp->SetFontFamilyToCourier();
1728 else if( f.family() == "Times" )
1729 aScalarBarLabelProp->SetFontFamilyToTimes();
1732 aScalarBarLabelProp->BoldOn();
1734 aScalarBarLabelProp->BoldOff();
1737 aScalarBarLabelProp->ItalicOn();
1739 aScalarBarLabelProp->ItalicOff();
1742 aScalarBarLabelProp->ShadowOn();
1744 aScalarBarLabelProp->ShadowOff();
1747 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1748 aScalarBarLabelProp->Delete();
1750 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1751 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1753 myScalarBarActor->SetOrientationToHorizontal();
1755 myScalarBarActor->SetOrientationToVertical();
1758 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1759 if( mgr->hasValue( "SMESH", name + "x" ) )
1760 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1762 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1763 if( mgr->hasValue( "SMESH", name + "y" ) )
1764 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1765 myScalarBarActor->SetPosition( aXVal, aYVal );
1767 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1768 if( mgr->hasValue( "SMESH", name + "width" ) )
1769 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1770 myScalarBarActor->SetWidth( aWVal );
1772 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1773 if( mgr->hasValue( "SMESH", name + "height" ) )
1774 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1775 myScalarBarActor->SetHeight( aHVal );
1778 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1779 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1780 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1783 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1784 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1785 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );