1 // SMESH OBJECT : interactive object for SMESH visualization
3 // Copyright (C) 2003 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
24 // File : SMESH_Actor.cxx
25 // Author : Nicolas REJNERI
30 #include "SMESH_ActorDef.h"
31 #include "SMESH_ActorUtils.h"
32 #include "SMESH_DeviceActor.h"
33 #include "SMESH_ControlsDef.hxx"
34 #include "VTKViewer_ExtractUnstructuredGrid.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();
123 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
124 myControlsPrecision = (long)SMESH::GetFloat( "SMESH", "controls_precision", -1 );
126 vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
127 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
129 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
130 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
132 //Definition 2D and 3D divices of the actor
133 //-----------------------------------------
134 vtkFloatingPointType anRGB[3] = {1,1,1};
135 mySurfaceProp = vtkProperty::New();
136 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
137 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
139 myBackSurfaceProp = vtkProperty::New();
140 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
141 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
143 my2DActor = SMESH_DeviceActor::New();
144 my2DActor->SetUserMatrix(aMatrix);
145 my2DActor->PickableOff();
146 my2DActor->SetProperty(mySurfaceProp);
147 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
148 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
149 aFilter = my2DActor->GetExtractUnstructuredGrid();
150 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
151 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
152 aFilter->RegisterCellsWithType(VTK_POLYGON);
153 aFilter->RegisterCellsWithType(VTK_QUAD);
154 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
155 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
157 my3DActor = SMESH_DeviceActor::New();
158 my3DActor->SetUserMatrix(aMatrix);
159 my3DActor->PickableOff();
160 my3DActor->SetProperty(mySurfaceProp);
161 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
162 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
163 aFilter = my3DActor->GetExtractUnstructuredGrid();
164 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
165 aFilter->RegisterCellsWithType(VTK_TETRA);
166 aFilter->RegisterCellsWithType(VTK_VOXEL);
167 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
168 aFilter->RegisterCellsWithType(VTK_WEDGE);
169 aFilter->RegisterCellsWithType(VTK_PYRAMID);
170 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
171 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
172 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
173 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
175 //Definition 1D divice of the actor
176 //---------------------------------
177 myEdgeProp = vtkProperty::New();
178 myEdgeProp->SetAmbient(1.0);
179 myEdgeProp->SetDiffuse(0.0);
180 myEdgeProp->SetSpecular(0.0);
181 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
182 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
183 myEdgeProp->SetLineWidth(aLineWidth);
185 my1DActor = SMESH_DeviceActor::New();
186 my1DActor->SetUserMatrix(aMatrix);
187 my1DActor->PickableOff();
188 my1DActor->SetHighlited(true);
189 my1DActor->SetProperty(myEdgeProp);
190 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
191 aFilter = my1DActor->GetExtractUnstructuredGrid();
192 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
193 aFilter->RegisterCellsWithType(VTK_LINE);
194 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
196 my1DProp = vtkProperty::New();
197 my1DProp->DeepCopy(myEdgeProp);
198 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
199 my1DProp->SetPointSize(aPointSize);
201 my1DExtProp = vtkProperty::New();
202 my1DExtProp->DeepCopy(myEdgeProp);
203 anRGB[0] = 1 - anRGB[0];
204 anRGB[1] = 1 - anRGB[1];
205 anRGB[2] = 1 - anRGB[2];
206 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
207 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
208 my1DExtProp->SetPointSize(aPointSize + aPointSizeInc);
210 my1DExtActor = SMESH_DeviceActor::New();
211 my1DExtActor->SetUserMatrix(aMatrix);
212 my1DExtActor->PickableOff();
213 my1DExtActor->SetHighlited(true);
214 my1DExtActor->SetVisibility(false);
215 my1DExtActor->SetProperty(my1DExtProp);
216 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
217 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
218 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
219 aFilter->RegisterCellsWithType(VTK_LINE);
220 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
223 //Definition 0D divice of the actor
224 //---------------------------------
225 myNodeProp = vtkProperty::New();
226 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
227 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
228 myNodeProp->SetPointSize(aPointSize);
230 myNodeActor = SMESH_DeviceActor::New();
231 myNodeActor->SetUserMatrix(aMatrix);
232 myNodeActor->SetStoreClippingMapping(true);
233 myNodeActor->PickableOff();
234 myNodeActor->SetVisibility(false);
235 myNodeActor->SetProperty(myNodeProp);
236 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
237 aFilter = myNodeActor->GetExtractUnstructuredGrid();
238 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
241 //Definition of Pickable and Highlitable engines
242 //----------------------------------------------
244 myBaseActor = SMESH_DeviceActor::New();
245 myBaseActor->SetUserMatrix(aMatrix);
246 myBaseActor->SetStoreGemetryMapping(true);
247 myBaseActor->GetProperty()->SetOpacity(0.0);
249 myPickableActor = myBaseActor;
251 myHighlightProp = vtkProperty::New();
252 myHighlightProp->SetAmbient(1.0);
253 myHighlightProp->SetDiffuse(0.0);
254 myHighlightProp->SetSpecular(0.0);
255 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
256 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
257 myHighlightProp->SetPointSize(aPointSize);
258 myHighlightProp->SetRepresentation(1);
260 myPreselectProp = vtkProperty::New();
261 myPreselectProp->SetAmbient(1.0);
262 myPreselectProp->SetDiffuse(0.0);
263 myPreselectProp->SetSpecular(0.0);
264 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
265 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
266 myPreselectProp->SetPointSize(aPointSize);
267 myPreselectProp->SetRepresentation(1);
269 myHighlitableActor = SMESH_DeviceActor::New();
270 myHighlitableActor->SetUserMatrix(aMatrix);
271 myHighlitableActor->PickableOff();
272 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
277 myControlMode = eNone;
278 myControlActor = my2DActor;
280 //Definition of myScalarBarActor
281 //------------------------------
282 myLookupTable = vtkLookupTable::New();
283 //Fix for Bug PAL5195 - SMESH764:
284 //Controls - Aspect Ratio: incorrect colors of the best and worst values
285 myLookupTable->SetHueRange(0.667,0.0);
287 myScalarBarActor = vtkScalarBarActor::New();
288 myScalarBarActor->SetVisibility(false);
289 myScalarBarActor->SetLookupTable(myLookupTable);
292 //Incorrect "Min value" in Scalar Bar in Mesh:
293 // myScalarBarActor->SetLabelFormat("%.4g");
294 // changes was commented because of regression bug IPAL 19981
296 mgr = SUIT_Session::session()->resourceMgr();
300 //Definition of points numbering pipeline
301 //---------------------------------------
302 myPointsNumDataSet = vtkUnstructuredGrid::New();
304 myPtsMaskPoints = vtkMaskPoints::New();
305 myPtsMaskPoints->SetInput(myPointsNumDataSet);
306 myPtsMaskPoints->SetOnRatio(1);
308 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
309 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
310 myPtsSelectVisiblePoints->SelectInvisibleOff();
311 myPtsSelectVisiblePoints->SetTolerance(0.1);
313 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
314 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
315 myPtsLabeledDataMapper->SetLabelFormat("%g");
316 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
318 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
319 aPtsTextProp->SetFontFamilyToTimes();
320 static int aPointsFontSize = 10;
321 aPtsTextProp->SetFontSize(aPointsFontSize);
322 aPtsTextProp->SetBold(1);
323 aPtsTextProp->SetItalic(0);
324 aPtsTextProp->SetShadow(0);
325 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
326 aPtsTextProp->Delete();
328 myEntityMode = eAllEntity;
330 myIsPointsLabeled = false;
332 myPointLabels = vtkActor2D::New();
333 myPointLabels->SetMapper(myPtsLabeledDataMapper);
334 myPointLabels->GetProperty()->SetColor(1,1,1);
335 myPointLabels->SetVisibility(myIsPointsLabeled);
338 //Definition of cells numbering pipeline
339 //---------------------------------------
340 myCellsNumDataSet = vtkUnstructuredGrid::New();
342 myCellCenters = vtkCellCenters::New();
343 myCellCenters->SetInput(myCellsNumDataSet);
345 myClsMaskPoints = vtkMaskPoints::New();
346 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
347 myClsMaskPoints->SetOnRatio(1);
349 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
350 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
351 myClsSelectVisiblePoints->SelectInvisibleOff();
352 myClsSelectVisiblePoints->SetTolerance(0.1);
354 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
355 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
356 myClsLabeledDataMapper->SetLabelFormat("%g");
357 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
359 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
360 aClsTextProp->SetFontFamilyToTimes();
361 static int aCellsFontSize = 12;
362 aClsTextProp->SetFontSize(aCellsFontSize);
363 aClsTextProp->SetBold(1);
364 aClsTextProp->SetItalic(0);
365 aClsTextProp->SetShadow(0);
366 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
367 aClsTextProp->Delete();
369 myIsCellsLabeled = false;
371 myCellsLabels = vtkActor2D::New();
372 myCellsLabels->SetMapper(myClsLabeledDataMapper);
373 myCellsLabels->GetProperty()->SetColor(0,1,0);
374 myCellsLabels->SetVisibility(myIsCellsLabeled);
377 myImplicitBoolean = vtkImplicitBoolean::New();
378 myImplicitBoolean->SetOperationTypeToIntersection();
382 SMESH_ActorDef::~SMESH_ActorDef()
384 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
386 myScalarBarActor->Delete();
387 myLookupTable->Delete();
389 mySurfaceProp->Delete();
390 myBackSurfaceProp->Delete();
392 myEdgeProp->Delete();
393 myHighlightProp->Delete();
394 myPreselectProp->Delete();
396 myNodeProp->Delete();
401 my1DExtProp->Delete();
402 my1DExtActor->Delete();
407 myNodeActor->Delete();
408 myBaseActor->Delete();
410 myHighlitableActor->Delete();
412 //Deleting of pints numbering pipeline
413 //---------------------------------------
414 myPointsNumDataSet->Delete();
416 // commented: porting to vtk 5.0
417 // myPtsLabeledDataMapper->RemoveAllInputs();
418 myPtsLabeledDataMapper->Delete();
420 // commented: porting to vtk 5.0
421 // myPtsSelectVisiblePoints->UnRegisterAllOutputs();
422 myPtsSelectVisiblePoints->Delete();
424 // commented: porting to vtk 5.0
425 // myPtsMaskPoints->UnRegisterAllOutputs();
426 myPtsMaskPoints->Delete();
428 myPointLabels->Delete();
431 //Deleting of cells numbering pipeline
432 //---------------------------------------
433 myCellsNumDataSet->Delete();
435 myClsLabeledDataMapper->RemoveAllInputs();
436 myClsLabeledDataMapper->Delete();
438 // commented: porting to vtk 5.0
439 // myClsSelectVisiblePoints->UnRegisterAllOutputs();
440 myClsSelectVisiblePoints->Delete();
442 // commented: porting to vtk 5.0
443 // myClsMaskPoints->UnRegisterAllOutputs();
444 myClsMaskPoints->Delete();
446 // commented: porting to vtk 5.0
447 // myCellCenters->UnRegisterAllOutputs();
448 myCellCenters->Delete();
450 myCellsLabels->Delete();
452 myImplicitBoolean->Delete();
454 myTimeStamp->Delete();
458 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
460 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
461 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
463 if ( myIsPointsLabeled )
465 myPointsNumDataSet->ShallowCopy(aGrid);
466 vtkDataSet *aDataSet = myPointsNumDataSet;
468 int aNbElem = aDataSet->GetNumberOfPoints();
470 vtkIntArray *anArray = vtkIntArray::New();
471 anArray->SetNumberOfValues( aNbElem );
473 for ( int anId = 0; anId < aNbElem; anId++ )
475 int aSMDSId = myVisualObj->GetNodeObjId( anId );
476 anArray->SetValue( anId, aSMDSId );
479 aDataSet->GetPointData()->SetScalars( anArray );
481 myPtsMaskPoints->SetInput( aDataSet );
482 myPointLabels->SetVisibility( GetVisibility() );
486 myPointLabels->SetVisibility( false );
488 SetRepresentation(GetRepresentation());
489 myTimeStamp->Modified();
493 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
495 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
496 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
497 if(myIsCellsLabeled){
498 myCellsNumDataSet->ShallowCopy(aGrid);
499 vtkDataSet *aDataSet = myCellsNumDataSet;
500 int aNbElem = aDataSet->GetNumberOfCells();
501 vtkIntArray *anArray = vtkIntArray::New();
502 anArray->SetNumberOfValues(aNbElem);
503 for(int anId = 0; anId < aNbElem; anId++){
504 int aSMDSId = myVisualObj->GetElemObjId(anId);
505 anArray->SetValue(anId,aSMDSId);
507 aDataSet->GetCellData()->SetScalars(anArray);
508 myCellCenters->SetInput(aDataSet);
509 myCellsLabels->SetVisibility(GetVisibility());
511 myCellsLabels->SetVisibility(false);
513 myTimeStamp->Modified();
517 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
519 myIsFacesOriented = theIsFacesOriented;
521 my2DActor->SetFacesOriented(theIsFacesOriented);
522 my3DActor->SetFacesOriented(theIsFacesOriented);
524 myTimeStamp->Modified();
527 bool SMESH_ActorDef::GetFacesOriented()
529 return myIsFacesOriented;
535 SetControlMode(eControl theMode)
537 SetControlMode(theMode,true);
543 SetControlMode(eControl theMode,
544 bool theCheckEntityMode)
546 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
550 myControlMode = eNone;
551 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
553 my1DActor->GetMapper()->SetScalarVisibility(false);
554 my2DActor->GetMapper()->SetScalarVisibility(false);
555 my3DActor->GetMapper()->SetScalarVisibility(false);
556 myScalarBarActor->SetVisibility(false);
558 bool anIsScalarVisible = theMode > eNone;
560 if(anIsScalarVisible){
561 SMESH::Controls::FunctorPtr aFunctor;
565 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
566 aControl->SetPrecision( myControlsPrecision );
567 aFunctor.reset( aControl );
568 myControlActor = my1DActor;
573 aFunctor.reset(new SMESH::Controls::Length2D());
574 myControlActor = my2DActor;
578 aFunctor.reset(new SMESH::Controls::FreeBorders());
579 myControlActor = my1DActor;
582 aFunctor.reset(new SMESH::Controls::FreeEdges());
583 myControlActor = my2DActor;
585 case eMultiConnection:
586 aFunctor.reset(new SMESH::Controls::MultiConnection());
587 myControlActor = my1DActor;
589 case eMultiConnection2D:
590 aFunctor.reset(new SMESH::Controls::MultiConnection2D());
591 myControlActor = my2DActor;
595 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
596 aControl->SetPrecision( myControlsPrecision );
597 aFunctor.reset( aControl );
598 myControlActor = my2DActor;
603 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
604 aControl->SetPrecision( myControlsPrecision );
605 aFunctor.reset( aControl );
606 myControlActor = my2DActor;
611 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
612 aControl->SetPrecision( myControlsPrecision );
613 aFunctor.reset( aControl );
614 myControlActor = my2DActor;
619 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
620 aControl->SetPrecision( myControlsPrecision );
621 aFunctor.reset( aControl );
622 myControlActor = my3DActor;
627 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
628 aControl->SetPrecision( myControlsPrecision );
629 aFunctor.reset( aControl );
630 myControlActor = my3DActor;
635 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
636 aControl->SetPrecision( myControlsPrecision );
637 aFunctor.reset( aControl );
638 myControlActor = my2DActor;
643 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
644 aControl->SetPrecision( myControlsPrecision );
645 aFunctor.reset( aControl );
646 myControlActor = my2DActor;
651 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
652 aControl->SetPrecision( myControlsPrecision );
653 aFunctor.reset( aControl );
654 myControlActor = my2DActor;
661 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
662 vtkIdType aNbCells = aGrid->GetNumberOfCells();
664 myControlMode = theMode;
665 switch(myControlMode){
668 my1DExtActor->SetExtControlMode(aFunctor);
671 case eMultiConnection2D:
672 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
675 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
679 if(theCheckEntityMode){
680 if(myControlActor == my1DActor)
681 SetEntityMode(eEdges);
682 else if(myControlActor == my2DActor){
683 switch(myControlMode){
686 case eMultiConnection2D:
687 //SetEntityMode(eEdges);
688 SetEntityMode(eFaces);
691 SetEntityMode(eFaces);
693 }else if(myControlActor == my3DActor)
694 SetEntityMode(eVolumes);
697 }else if(theCheckEntityMode){
698 myEntityMode = eAllEntity;
701 SetRepresentation(GetRepresentation());
703 myTimeStamp->Modified();
708 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
709 SALOME_Actor::AddToRender(theRenderer);
711 theRenderer->AddActor(myNodeActor);
712 theRenderer->AddActor(myBaseActor);
714 my3DActor->AddToRender(theRenderer);
715 my2DActor->AddToRender(theRenderer);
717 theRenderer->AddActor(my1DActor);
718 theRenderer->AddActor(my1DExtActor);
720 theRenderer->AddActor(myHighlitableActor);
722 theRenderer->AddActor2D(myScalarBarActor);
724 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
725 myClsSelectVisiblePoints->SetRenderer(theRenderer);
727 theRenderer->AddActor2D(myPointLabels);
728 theRenderer->AddActor2D(myCellsLabels);
731 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
732 SALOME_Actor::RemoveFromRender(theRenderer);
734 theRenderer->RemoveActor(myNodeActor);
735 theRenderer->RemoveActor(myBaseActor);
737 theRenderer->RemoveActor(myHighlitableActor);
739 theRenderer->RemoveActor(my1DActor);
740 theRenderer->RemoveActor(my1DExtActor);
742 my2DActor->RemoveFromRender(theRenderer);
743 my3DActor->RemoveFromRender(theRenderer);
745 theRenderer->RemoveActor(myScalarBarActor);
746 theRenderer->RemoveActor(myPointLabels);
747 theRenderer->RemoveActor(myCellsLabels);
751 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
752 const char* theEntry,
756 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
760 myVisualObj = theVisualObj;
761 myVisualObj->Update(theIsClear);
763 myNodeActor->Init(myVisualObj,myImplicitBoolean);
764 myBaseActor->Init(myVisualObj,myImplicitBoolean);
766 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
768 my1DActor->Init(myVisualObj,myImplicitBoolean);
769 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
771 my2DActor->Init(myVisualObj,myImplicitBoolean);
772 my3DActor->Init(myVisualObj,myImplicitBoolean);
774 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
775 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
777 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
778 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
780 vtkFloatingPointType aFactor, aUnits;
781 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
782 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
784 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
788 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
789 SetIsShrunkable(true);
791 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
793 int aMode = mgr->integerValue( "SMESH", "display_mode" );
794 SetRepresentation(-1);
797 SetRepresentation(eEdge);
798 }else if(aMode == 1){
799 SetRepresentation(eSurface);
800 }else if(aMode == 2){
801 SetRepresentation(ePoint);
808 myTimeStamp->Modified();
814 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
815 return myNodeActor->GetBounds();
819 vtkDataSet* SMESH_ActorDef::GetInput(){
820 return GetUnstructuredGrid();
824 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
825 Superclass::SetTransform(theTransform);
827 myNodeActor->SetTransform(theTransform);
828 myBaseActor->SetTransform(theTransform);
830 myHighlitableActor->SetTransform(theTransform);
832 my1DActor->SetTransform(theTransform);
833 my1DExtActor->SetTransform(theTransform);
835 my2DActor->SetTransform(theTransform);
836 my3DActor->SetTransform(theTransform);
842 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
843 vtkLODActor::SetMapper(theMapper);
847 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
848 SALOME_Actor::ShallowCopy(prop);
852 vtkMapper* SMESH_ActorDef::GetMapper(){
853 return myPickableActor->GetMapper();
857 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
858 return myVisualObj->GetUnstructuredGrid();
862 bool SMESH_ActorDef::IsInfinitive(){
863 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
865 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
866 aDataSet->GetNumberOfCells() == 1 &&
867 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX;
868 return SALOME_Actor::IsInfinitive();
872 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
873 if ( myIsShrinkable == theShrunkable )
875 myIsShrinkable = theShrunkable;
879 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
880 return myBaseActor->GetShrinkFactor();
883 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
884 myBaseActor->SetShrinkFactor(theValue);
886 my1DActor->SetShrinkFactor(theValue);
887 my1DExtActor->SetShrinkFactor(theValue);
889 my2DActor->SetShrinkFactor(theValue);
890 my3DActor->SetShrinkFactor(theValue);
895 void SMESH_ActorDef::SetShrink(){
896 if(!myIsShrinkable) return;
898 myBaseActor->SetShrink();
900 my1DActor->SetShrink();
901 my1DExtActor->SetShrink();
903 my2DActor->SetShrink();
904 my3DActor->SetShrink();
910 void SMESH_ActorDef::UnShrink(){
911 if(!myIsShrunk) return;
913 myBaseActor->UnShrink();
915 my1DActor->UnShrink();
916 my1DExtActor->UnShrink();
918 my2DActor->UnShrink();
919 my3DActor->UnShrink();
926 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
927 return myPickableActor->GetNodeObjId(theVtkID);
930 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
931 return myPickableActor->GetNodeCoord(theObjID);
935 int SMESH_ActorDef::GetElemObjId(int theVtkID){
936 return myPickableActor->GetElemObjId(theVtkID);
939 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
940 return myPickableActor->GetElemCell(theObjID);
944 void SMESH_ActorDef::SetVisibility(int theMode){
945 SetVisibility(theMode,true);
949 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
950 SALOME_Actor::SetVisibility(theMode);
952 myNodeActor->VisibilityOff();
953 myBaseActor->VisibilityOff();
955 my1DActor->VisibilityOff();
956 my1DExtActor->VisibilityOff();
958 my2DActor->VisibilityOff();
959 my3DActor->VisibilityOff();
961 myScalarBarActor->VisibilityOff();
962 myPointLabels->VisibilityOff();
963 myCellsLabels->VisibilityOff();
966 if(theIsUpdateRepersentation)
967 SetRepresentation(GetRepresentation());
969 if(myControlMode != eNone){
970 switch(myControlMode){
973 my1DExtActor->VisibilityOn();
976 case eMultiConnection2D:
977 my1DExtActor->VisibilityOn();
979 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
980 myScalarBarActor->VisibilityOn();
984 if(myRepresentation != ePoint)
985 myPickableActor->VisibilityOn();
987 myNodeActor->VisibilityOn();
990 if(myEntityMode & eEdges){
991 my1DActor->VisibilityOn();
994 if(myEntityMode & eFaces){
995 my2DActor->VisibilityOn();
998 if(myEntityMode & eVolumes){
999 my3DActor->VisibilityOn();
1002 if(myIsPointsLabeled){
1003 myPointLabels->VisibilityOn();
1004 myNodeActor->VisibilityOn();
1007 if(myIsCellsLabeled)
1008 myCellsLabels->VisibilityOn();
1015 void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
1016 myEntityState = eAllEntity;
1018 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)){
1019 myEntityState &= ~eEdges;
1023 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)){
1024 myEntityState &= ~eFaces;
1028 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)){
1029 myEntityState &= ~eVolumes;
1030 theMode &= ~eVolumes;
1034 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1037 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1040 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1041 theMode |= eVolumes;
1044 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1046 myEntityMode = theMode;
1047 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1048 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1049 aFilter->ClearRegisteredCellsWithType();
1050 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1052 if(myEntityMode & eEdges){
1053 if (MYDEBUG) MESSAGE("EDGES");
1054 aFilter->RegisterCellsWithType(VTK_LINE);
1055 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1058 if(myEntityMode & eFaces){
1059 if (MYDEBUG) MESSAGE("FACES");
1060 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1061 aFilter->RegisterCellsWithType(VTK_POLYGON);
1062 aFilter->RegisterCellsWithType(VTK_QUAD);
1063 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1064 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1067 if(myEntityMode & eVolumes){
1068 if (MYDEBUG) MESSAGE("VOLUMES");
1069 aFilter->RegisterCellsWithType(VTK_TETRA);
1070 aFilter->RegisterCellsWithType(VTK_VOXEL);
1071 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1072 aFilter->RegisterCellsWithType(VTK_WEDGE);
1073 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1074 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1075 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1076 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
1077 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1080 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1081 SetVisibility(GetVisibility(),false);
1084 void SMESH_ActorDef::SetRepresentation(int theMode){
1085 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1086 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1087 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1089 myRepresentation = eSurface;
1090 if(!aNbFaces && !aNbVolumes && aNbEdges){
1091 myRepresentation = eEdge;
1092 }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1093 myRepresentation = ePoint;
1098 if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1101 if(!aNbFaces && !aNbVolumes) return;
1104 myRepresentation = theMode;
1107 if(!GetUnstructuredGrid()->GetNumberOfCells())
1108 myRepresentation = ePoint;
1111 if(myRepresentation == ePoint){
1119 myPickableActor = myBaseActor;
1120 myNodeActor->SetVisibility(false);
1121 vtkProperty *aProp = NULL, *aBackProp = NULL;
1122 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1123 switch(myRepresentation){
1125 myPickableActor = myNodeActor;
1126 myNodeActor->SetVisibility(true);
1128 aProp = aBackProp = myNodeProp;
1129 aReperesent = SMESH_DeviceActor::ePoint;
1132 aProp = aBackProp = myEdgeProp;
1133 aReperesent = SMESH_DeviceActor::eInsideframe;
1136 aProp = mySurfaceProp;
1137 aBackProp = myBackSurfaceProp;
1138 aReperesent = SMESH_DeviceActor::eSurface;
1142 my2DActor->SetProperty(aProp);
1143 my2DActor->SetBackfaceProperty(aBackProp);
1144 my2DActor->SetRepresentation(aReperesent);
1146 my3DActor->SetProperty(aProp);
1147 my3DActor->SetBackfaceProperty(aBackProp);
1148 my3DActor->SetRepresentation(aReperesent);
1150 my1DExtActor->SetVisibility(false);
1152 switch(myControlMode){
1154 case eMultiConnection:
1155 aProp = aBackProp = my1DProp;
1156 if(myRepresentation != ePoint)
1157 aReperesent = SMESH_DeviceActor::eInsideframe;
1161 my1DActor->SetProperty(aProp);
1162 my1DActor->SetBackfaceProperty(aBackProp);
1163 my1DActor->SetRepresentation(aReperesent);
1165 my1DExtActor->SetRepresentation(aReperesent);
1167 if(myIsPointsVisible)
1168 myPickableActor = myNodeActor;
1169 if(GetPointRepresentation())
1170 myNodeActor->SetVisibility(true);
1172 SetMapper(myPickableActor->GetMapper());
1174 SetVisibility(GetVisibility(),false);
1180 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1181 if ( myIsPointsVisible == theIsPointsVisible )
1183 myIsPointsVisible = theIsPointsVisible;
1184 SetRepresentation(GetRepresentation());
1187 bool SMESH_ActorDef::GetPointRepresentation(){
1188 return myIsPointsVisible || myIsPointsLabeled;
1192 void SMESH_ActorDef::UpdateHighlight(){
1193 myHighlitableActor->SetVisibility(false);
1194 myHighlitableActor->SetHighlited(false);
1196 if(myIsHighlighted){
1197 myHighlitableActor->SetProperty(myHighlightProp);
1198 }else if(myIsPreselected){
1199 myHighlitableActor->SetProperty(myPreselectProp);
1202 bool anIsVisible = GetVisibility();
1204 if(myIsHighlighted || myIsPreselected){
1205 if(GetUnstructuredGrid()->GetNumberOfCells()){
1206 myHighlitableActor->SetHighlited(anIsVisible);
1207 myHighlitableActor->SetVisibility(anIsVisible);
1208 myHighlitableActor->GetExtractUnstructuredGrid()->
1209 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1210 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1211 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1212 myHighlitableActor->SetHighlited(anIsVisible);
1213 myHighlitableActor->GetExtractUnstructuredGrid()->
1214 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1215 myHighlitableActor->SetVisibility(anIsVisible);
1216 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1222 void SMESH_ActorDef::highlight(bool theHighlight){
1223 if ( myIsHighlighted == theHighlight )
1225 myIsHighlighted = theHighlight;
1230 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1231 if ( myIsPreselected == thePreselect )
1233 myIsPreselected = thePreselect;
1239 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1241 if (myPickableActor->GetIsOpaque())
1243 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1251 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1253 if (!myPickableActor->GetIsOpaque())
1255 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1263 void SMESH_ActorDef::Render(vtkRenderer *ren){
1264 unsigned long aTime = myTimeStamp->GetMTime();
1265 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1266 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1267 if(anObjTime > aTime || aClippingTime > aTime)
1272 void SMESH_ActorDef::Update(){
1273 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1275 if(GetControlMode() != eNone) {
1276 unsigned long aTime = myTimeStamp->GetMTime();
1277 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1278 if (anObjTime > aTime)
1279 SetControlMode(GetControlMode(),false);
1281 if(myIsPointsLabeled){
1282 SetPointsLabeled(myIsPointsLabeled);
1284 if(myIsCellsLabeled){
1285 SetCellsLabeled(myIsCellsLabeled);
1287 if(myIsFacesOriented){
1288 SetFacesOriented(myIsFacesOriented);
1290 SetEntityMode(GetEntityMode());
1291 SetVisibility(GetVisibility());
1293 myTimeStamp->Modified();
1298 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1299 SALOME_Actor::ReleaseGraphicsResources(renWin);
1301 myPickableActor->ReleaseGraphicsResources(renWin);
1305 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1306 vtkFloatingPointType* aColor = theProperty->GetColor();
1313 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1314 mySurfaceProp->SetOpacity(theValue);
1315 myBackSurfaceProp->SetOpacity(theValue);
1316 myEdgeProp->SetOpacity(theValue);
1317 myNodeProp->SetOpacity(theValue);
1319 my1DProp->SetOpacity(theValue);
1323 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1324 return mySurfaceProp->GetOpacity();
1328 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1329 mySurfaceProp->SetColor(r,g,b);
1333 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1334 ::GetColor(mySurfaceProp,r,g,b);
1337 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1338 myBackSurfaceProp->SetColor(r,g,b);
1342 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1343 ::GetColor(myBackSurfaceProp,r,g,b);
1346 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1347 myEdgeProp->SetColor(r,g,b);
1348 my1DProp->SetColor(r,g,b);
1349 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1353 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1354 ::GetColor(myEdgeProp,r,g,b);
1357 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1358 myNodeProp->SetColor(r,g,b);
1362 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1363 ::GetColor(myNodeProp,r,g,b);
1366 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1367 myHighlightProp->SetColor(r,g,b);
1371 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1372 ::GetColor(myHighlightProp,r,g,b);
1375 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1376 myPreselectProp->SetColor(r,g,b);
1380 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1381 ::GetColor(myPreselectProp,r,g,b);
1385 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1386 return myEdgeProp->GetLineWidth();
1390 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1391 myEdgeProp->SetLineWidth(theVal);
1393 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1394 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1400 void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){
1401 myNodeProp->SetPointSize(theVal);
1402 myHighlightProp->SetPointSize(theVal);
1403 myPreselectProp->SetPointSize(theVal);
1405 my1DProp->SetPointSize(theVal + aPointSizeInc);
1406 my1DExtProp->SetPointSize(theVal + aPointSizeInc);
1411 vtkFloatingPointType SMESH_ActorDef::GetNodeSize(){
1412 return myNodeProp->GetPointSize();
1415 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1417 return myVisualObj->GetElemDimension( theObjId );
1422 IsImplicitFunctionUsed() const
1424 return myBaseActor->IsImplicitFunctionUsed();
1429 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1431 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1432 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1434 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1436 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1437 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1439 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1440 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1445 AddClippingPlane(vtkPlane* thePlane)
1448 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1449 myCippingPlaneCont.push_back(thePlane);
1450 if(!IsImplicitFunctionUsed())
1451 SetImplicitFunctionUsed(true);
1453 return myCippingPlaneCont.size();
1458 RemoveAllClippingPlanes()
1460 myImplicitBoolean->GetFunction()->RemoveAllItems();
1461 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1462 myCippingPlaneCont.clear();
1463 SetImplicitFunctionUsed(false);
1468 GetNumberOfClippingPlanes()
1470 return myCippingPlaneCont.size();
1475 GetClippingPlane(vtkIdType theID)
1477 if(theID >= myCippingPlaneCont.size())
1479 return myCippingPlaneCont[theID].Get();
1483 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1484 vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1485 vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1487 vtkFloatingPointType aBounds[6];
1488 theDataSet->GetBounds(aBounds);
1490 //Enlarge bounds in order to avoid conflicts of precision
1491 for(int i = 0; i < 6; i += 2){
1492 static double EPS = 1.0E-3;
1493 vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1494 aBounds[i] -= aDelta;
1495 aBounds[i+1] += aDelta;
1498 vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1499 {aBounds[1],aBounds[2],aBounds[4]},
1500 {aBounds[0],aBounds[3],aBounds[4]},
1501 {aBounds[1],aBounds[3],aBounds[4]},
1502 {aBounds[0],aBounds[2],aBounds[5]},
1503 {aBounds[1],aBounds[2],aBounds[5]},
1504 {aBounds[0],aBounds[3],aBounds[5]},
1505 {aBounds[1],aBounds[3],aBounds[5]}};
1507 int aMaxId = 0, aMinId = aMaxId;
1508 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1509 theMinBoundPrj = theMaxBoundPrj;
1510 for(int i = 1; i < 8; i++){
1511 vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1512 if(theMaxBoundPrj < aTmp){
1513 theMaxBoundPrj = aTmp;
1516 if(theMinBoundPrj > aTmp){
1517 theMinBoundPrj = aTmp;
1521 vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1522 theMinPnt[0] = aMinPnt[0];
1523 theMinPnt[1] = aMinPnt[1];
1524 theMinPnt[2] = aMinPnt[2];
1528 static void DistanceToPosition(vtkDataSet* theDataSet,
1529 vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1531 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1532 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1533 vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1534 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1535 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1536 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1540 static void PositionToDistance(vtkDataSet* theDataSet,
1541 vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1543 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1544 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1545 vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1546 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1550 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1552 thePlane->SetNormal(theDir);
1553 vtkFloatingPointType anOrigin[3];
1554 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1555 thePlane->SetOrigin(anOrigin);
1559 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1561 thePlane->GetNormal(theDir);
1563 vtkFloatingPointType anOrigin[3];
1564 thePlane->GetOrigin(anOrigin);
1565 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1568 void SMESH_ActorDef::UpdateScalarBar()
1570 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1574 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1576 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1577 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1579 aScalarBarTitleProp->SetFontFamilyToArial();
1581 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1583 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1584 if ( f.family() == "Arial" )
1585 aScalarBarTitleProp->SetFontFamilyToArial();
1586 else if ( f.family() == "Courier" )
1587 aScalarBarTitleProp->SetFontFamilyToCourier();
1588 else if ( f.family() == "Times" )
1589 aScalarBarTitleProp->SetFontFamilyToTimes();
1592 aScalarBarTitleProp->BoldOn();
1594 aScalarBarTitleProp->BoldOff();
1597 aScalarBarTitleProp->ItalicOn();
1599 aScalarBarTitleProp->ItalicOff();
1601 if ( f.underline() )
1602 aScalarBarTitleProp->ShadowOn();
1604 aScalarBarTitleProp->ShadowOff();
1607 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1608 aScalarBarTitleProp->Delete();
1610 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1612 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1613 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1615 aScalarBarLabelProp->SetFontFamilyToArial();
1616 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1618 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
1619 if( f.family() == "Arial" )
1620 aScalarBarLabelProp->SetFontFamilyToArial();
1621 else if( f.family() == "Courier" )
1622 aScalarBarLabelProp->SetFontFamilyToCourier();
1623 else if( f.family() == "Times" )
1624 aScalarBarLabelProp->SetFontFamilyToTimes();
1627 aScalarBarLabelProp->BoldOn();
1629 aScalarBarLabelProp->BoldOff();
1632 aScalarBarLabelProp->ItalicOn();
1634 aScalarBarLabelProp->ItalicOff();
1637 aScalarBarLabelProp->ShadowOn();
1639 aScalarBarLabelProp->ShadowOff();
1642 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1643 aScalarBarLabelProp->Delete();
1645 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1646 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1648 myScalarBarActor->SetOrientationToHorizontal();
1650 myScalarBarActor->SetOrientationToVertical();
1653 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1654 if( mgr->hasValue( "SMESH", name + "x" ) )
1655 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1657 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1658 if( mgr->hasValue( "SMESH", name + "y" ) )
1659 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1660 myScalarBarActor->SetPosition( aXVal, aYVal );
1662 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1663 if( mgr->hasValue( "SMESH", name + "width" ) )
1664 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1665 myScalarBarActor->SetWidth( aWVal );
1667 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1668 if( mgr->hasValue( "SMESH", name + "height" ) )
1669 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1670 myScalarBarActor->SetHeight( aHVal );
1673 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1674 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1675 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1678 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1679 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1680 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );