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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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"
36 #include "SUIT_Session.h"
37 #include "SUIT_ResourceMgr.h"
39 #include <qstringlist.h>
41 #include <vtkProperty.h>
42 #include <vtkTimeStamp.h>
43 #include <vtkObjectFactory.h>
44 #include <vtkShrinkPolyData.h>
45 #include <vtkMergeFilter.h>
47 #include <vtkMatrix4x4.h>
48 #include <vtkUnstructuredGrid.h>
49 #include <vtkPointData.h>
50 #include <vtkCellData.h>
52 #include <vtkMapper.h>
53 #include <vtkRenderer.h>
56 #include <vtkIdList.h>
57 #include <vtkIntArray.h>
59 #include <vtkActor2D.h>
60 #include <vtkProperty2D.h>
61 #include <vtkPolyData.h>
62 #include <vtkMaskPoints.h>
63 #include <vtkCellCenters.h>
64 #include <vtkTextProperty.h>
65 #include <vtkLabeledDataMapper.h>
66 #include <vtkSelectVisiblePoints.h>
68 #include <vtkScalarBarActor.h>
69 #include <vtkLookupTable.h>
73 #include <vtkImplicitBoolean.h>
74 #include <vtkImplicitFunctionCollection.h>
76 #include "utilities.h"
79 static int MYDEBUG = 1;
81 static int MYDEBUG = 0;
84 static int aLineWidthInc = 2;
85 static int aPointSizeInc = 2;
88 SMESH_ActorDef* SMESH_ActorDef::New(){
89 return new SMESH_ActorDef();
93 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
98 SMESH_ActorDef* anActor = SMESH_ActorDef::New();
99 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
104 anActor->UpdateScalarBar();
109 SMESH_ActorDef::SMESH_ActorDef()
111 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
113 myTimeStamp = vtkTimeStamp::New();
115 myIsPointsVisible = false;
117 myIsShrinkable = false;
120 myControlsPrecision = -1;
121 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
122 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
123 myControlsPrecision = (long)SMESH::GetFloat( "SMESH", "controls_precision", -1 );
125 vtkFloatingPointType aPointSize = SMESH::GetFloat("SMESH:node_size",3);
126 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
128 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
129 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
131 //Definition 2D and 3D divices of the actor
132 //-----------------------------------------
133 vtkFloatingPointType anRGB[3] = {1,1,1};
134 mySurfaceProp = vtkProperty::New();
135 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
136 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
138 myBackSurfaceProp = vtkProperty::New();
139 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
140 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
142 my2DActor = SMESH_DeviceActor::New();
143 my2DActor->SetUserMatrix(aMatrix);
144 my2DActor->PickableOff();
145 my2DActor->SetProperty(mySurfaceProp);
146 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
147 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
148 aFilter = my2DActor->GetExtractUnstructuredGrid();
149 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
150 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
151 aFilter->RegisterCellsWithType(VTK_POLYGON);
152 aFilter->RegisterCellsWithType(VTK_QUAD);
153 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
154 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
156 my3DActor = SMESH_DeviceActor::New();
157 my3DActor->SetUserMatrix(aMatrix);
158 my3DActor->PickableOff();
159 my3DActor->SetProperty(mySurfaceProp);
160 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
161 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
162 aFilter = my3DActor->GetExtractUnstructuredGrid();
163 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
164 aFilter->RegisterCellsWithType(VTK_TETRA);
165 aFilter->RegisterCellsWithType(VTK_VOXEL);
166 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
167 aFilter->RegisterCellsWithType(VTK_WEDGE);
168 aFilter->RegisterCellsWithType(VTK_PYRAMID);
169 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
170 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
171 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
173 //Definition 1D divice of the actor
174 //---------------------------------
175 myEdgeProp = vtkProperty::New();
176 myEdgeProp->SetAmbient(1.0);
177 myEdgeProp->SetDiffuse(0.0);
178 myEdgeProp->SetSpecular(0.0);
179 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
180 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
181 myEdgeProp->SetLineWidth(aLineWidth);
183 my1DActor = SMESH_DeviceActor::New();
184 my1DActor->SetUserMatrix(aMatrix);
185 my1DActor->PickableOff();
186 my1DActor->SetHighlited(true);
187 my1DActor->SetProperty(myEdgeProp);
188 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
189 aFilter = my1DActor->GetExtractUnstructuredGrid();
190 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
191 aFilter->RegisterCellsWithType(VTK_LINE);
192 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
194 my1DProp = vtkProperty::New();
195 my1DProp->DeepCopy(myEdgeProp);
196 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
197 my1DProp->SetPointSize(aPointSize);
199 my1DExtProp = vtkProperty::New();
200 my1DExtProp->DeepCopy(myEdgeProp);
201 anRGB[0] = 1 - anRGB[0];
202 anRGB[1] = 1 - anRGB[1];
203 anRGB[2] = 1 - anRGB[2];
204 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
205 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
206 my1DExtProp->SetPointSize(aPointSize + aPointSizeInc);
208 my1DExtActor = SMESH_DeviceActor::New();
209 my1DExtActor->SetUserMatrix(aMatrix);
210 my1DExtActor->PickableOff();
211 my1DExtActor->SetHighlited(true);
212 my1DExtActor->SetVisibility(false);
213 my1DExtActor->SetProperty(my1DExtProp);
214 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
215 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
216 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
217 aFilter->RegisterCellsWithType(VTK_LINE);
218 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
221 //Definition 0D divice of the actor
222 //---------------------------------
223 myNodeProp = vtkProperty::New();
224 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
225 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
226 myNodeProp->SetPointSize(aPointSize);
228 myNodeActor = SMESH_DeviceActor::New();
229 myNodeActor->SetUserMatrix(aMatrix);
230 myNodeActor->SetStoreClippingMapping(true);
231 myNodeActor->PickableOff();
232 myNodeActor->SetVisibility(false);
233 myNodeActor->SetProperty(myNodeProp);
234 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
235 aFilter = myNodeActor->GetExtractUnstructuredGrid();
236 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
239 //Definition of Pickable and Highlitable engines
240 //----------------------------------------------
242 myBaseActor = SMESH_DeviceActor::New();
243 myBaseActor->SetUserMatrix(aMatrix);
244 myBaseActor->SetStoreGemetryMapping(true);
245 myBaseActor->GetProperty()->SetOpacity(0.0);
247 myPickableActor = myBaseActor;
249 myHighlightProp = vtkProperty::New();
250 myHighlightProp->SetAmbient(1.0);
251 myHighlightProp->SetDiffuse(0.0);
252 myHighlightProp->SetSpecular(0.0);
253 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
254 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
255 myHighlightProp->SetPointSize(aPointSize);
256 myHighlightProp->SetRepresentation(1);
258 myPreselectProp = vtkProperty::New();
259 myPreselectProp->SetAmbient(1.0);
260 myPreselectProp->SetDiffuse(0.0);
261 myPreselectProp->SetSpecular(0.0);
262 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
263 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
264 myPreselectProp->SetPointSize(aPointSize);
265 myPreselectProp->SetRepresentation(1);
267 myHighlitableActor = SMESH_DeviceActor::New();
268 myHighlitableActor->SetUserMatrix(aMatrix);
269 myHighlitableActor->PickableOff();
270 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
275 myControlMode = eNone;
276 myControlActor = my2DActor;
278 //Definition of myScalarBarActor
279 //------------------------------
280 myLookupTable = vtkLookupTable::New();
281 //Fix for Bug PAL5195 - SMESH764:
282 //Controls - Aspect Ratio: incorrect colors of the best and worst values
283 myLookupTable->SetHueRange(0.667,0.0);
285 myScalarBarActor = vtkScalarBarActor::New();
286 myScalarBarActor->SetVisibility(false);
287 myScalarBarActor->SetLookupTable(myLookupTable);
289 mgr = SUIT_Session::session()->resourceMgr();
293 //Definition of points numbering pipeline
294 //---------------------------------------
295 myPointsNumDataSet = vtkUnstructuredGrid::New();
297 myPtsMaskPoints = vtkMaskPoints::New();
298 myPtsMaskPoints->SetInput(myPointsNumDataSet);
299 myPtsMaskPoints->SetOnRatio(1);
301 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
302 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
303 myPtsSelectVisiblePoints->SelectInvisibleOff();
304 myPtsSelectVisiblePoints->SetTolerance(0.1);
306 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
307 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
308 myPtsLabeledDataMapper->SetLabelFormat("%g");
309 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
311 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
312 aPtsTextProp->SetFontFamilyToTimes();
313 static int aPointsFontSize = 10;
314 aPtsTextProp->SetFontSize(aPointsFontSize);
315 aPtsTextProp->SetBold(1);
316 aPtsTextProp->SetItalic(0);
317 aPtsTextProp->SetShadow(0);
318 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
319 aPtsTextProp->Delete();
321 myEntityMode = eAllEntity;
323 myIsPointsLabeled = false;
325 myPointLabels = vtkActor2D::New();
326 myPointLabels->SetMapper(myPtsLabeledDataMapper);
327 myPointLabels->GetProperty()->SetColor(1,1,1);
328 myPointLabels->SetVisibility(myIsPointsLabeled);
331 //Definition of cells numbering pipeline
332 //---------------------------------------
333 myCellsNumDataSet = vtkUnstructuredGrid::New();
335 myCellCenters = vtkCellCenters::New();
336 myCellCenters->SetInput(myCellsNumDataSet);
338 myClsMaskPoints = vtkMaskPoints::New();
339 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
340 myClsMaskPoints->SetOnRatio(1);
342 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
343 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
344 myClsSelectVisiblePoints->SelectInvisibleOff();
345 myClsSelectVisiblePoints->SetTolerance(0.1);
347 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
348 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
349 myClsLabeledDataMapper->SetLabelFormat("%g");
350 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
352 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
353 aClsTextProp->SetFontFamilyToTimes();
354 static int aCellsFontSize = 12;
355 aClsTextProp->SetFontSize(aCellsFontSize);
356 aClsTextProp->SetBold(1);
357 aClsTextProp->SetItalic(0);
358 aClsTextProp->SetShadow(0);
359 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
360 aClsTextProp->Delete();
362 myIsCellsLabeled = false;
364 myCellsLabels = vtkActor2D::New();
365 myCellsLabels->SetMapper(myClsLabeledDataMapper);
366 myCellsLabels->GetProperty()->SetColor(0,1,0);
367 myCellsLabels->SetVisibility(myIsCellsLabeled);
370 myImplicitBoolean = vtkImplicitBoolean::New();
371 myImplicitBoolean->SetOperationTypeToIntersection();
375 SMESH_ActorDef::~SMESH_ActorDef()
377 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
379 myScalarBarActor->Delete();
380 myLookupTable->Delete();
382 mySurfaceProp->Delete();
383 myBackSurfaceProp->Delete();
385 myEdgeProp->Delete();
386 myHighlightProp->Delete();
387 myPreselectProp->Delete();
389 myNodeProp->Delete();
394 my1DExtProp->Delete();
395 my1DExtActor->Delete();
400 myNodeActor->Delete();
401 myBaseActor->Delete();
403 myHighlitableActor->Delete();
405 //Deleting of pints numbering pipeline
406 //---------------------------------------
407 myPointsNumDataSet->Delete();
409 myPtsLabeledDataMapper->RemoveAllInputs();
410 myPtsLabeledDataMapper->Delete();
412 myPtsSelectVisiblePoints->UnRegisterAllOutputs();
413 myPtsSelectVisiblePoints->Delete();
415 myPtsMaskPoints->UnRegisterAllOutputs();
416 myPtsMaskPoints->Delete();
418 myPointLabels->Delete();
421 //Deleting of cells numbering pipeline
422 //---------------------------------------
423 myCellsNumDataSet->Delete();
425 myClsLabeledDataMapper->RemoveAllInputs();
426 myClsLabeledDataMapper->Delete();
428 myClsSelectVisiblePoints->UnRegisterAllOutputs();
429 myClsSelectVisiblePoints->Delete();
431 myClsMaskPoints->UnRegisterAllOutputs();
432 myClsMaskPoints->Delete();
434 myCellCenters->UnRegisterAllOutputs();
435 myCellCenters->Delete();
437 myCellsLabels->Delete();
439 myImplicitBoolean->Delete();
441 myTimeStamp->Delete();
445 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
447 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
448 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
450 if ( myIsPointsLabeled )
452 myPointsNumDataSet->ShallowCopy(aGrid);
453 vtkDataSet *aDataSet = myPointsNumDataSet;
455 int aNbElem = aDataSet->GetNumberOfPoints();
457 vtkIntArray *anArray = vtkIntArray::New();
458 anArray->SetNumberOfValues( aNbElem );
460 for ( int anId = 0; anId < aNbElem; anId++ )
462 int aSMDSId = myVisualObj->GetNodeObjId( anId );
463 anArray->SetValue( anId, aSMDSId );
466 aDataSet->GetPointData()->SetScalars( anArray );
468 myPtsMaskPoints->SetInput( aDataSet );
469 myPointLabels->SetVisibility( GetVisibility() );
473 myPointLabels->SetVisibility( false );
475 SetRepresentation(GetRepresentation());
476 myTimeStamp->Modified();
480 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
482 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
483 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
484 if(myIsCellsLabeled){
485 myCellsNumDataSet->ShallowCopy(aGrid);
486 vtkDataSet *aDataSet = myCellsNumDataSet;
487 int aNbElem = aDataSet->GetNumberOfCells();
488 vtkIntArray *anArray = vtkIntArray::New();
489 anArray->SetNumberOfValues(aNbElem);
490 for(int anId = 0; anId < aNbElem; anId++){
491 int aSMDSId = myVisualObj->GetElemObjId(anId);
492 anArray->SetValue(anId,aSMDSId);
494 aDataSet->GetCellData()->SetScalars(anArray);
495 myCellCenters->SetInput(aDataSet);
496 myCellsLabels->SetVisibility(GetVisibility());
498 myCellsLabels->SetVisibility(false);
500 myTimeStamp->Modified();
506 SetControlMode(eControl theMode)
508 SetControlMode(theMode,true);
514 SetControlMode(eControl theMode,
515 bool theCheckEntityMode)
517 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
521 myControlMode = eNone;
522 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
524 my1DActor->GetMapper()->SetScalarVisibility(false);
525 my2DActor->GetMapper()->SetScalarVisibility(false);
526 my3DActor->GetMapper()->SetScalarVisibility(false);
527 myScalarBarActor->SetVisibility(false);
529 bool anIsScalarVisible = theMode > eNone;
531 if(anIsScalarVisible){
532 SMESH::Controls::FunctorPtr aFunctor;
536 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
537 aControl->SetPrecision( myControlsPrecision );
538 aFunctor.reset( aControl );
539 myControlActor = my1DActor;
544 aFunctor.reset(new SMESH::Controls::Length2D());
545 myControlActor = my2DActor;
549 aFunctor.reset(new SMESH::Controls::FreeBorders());
550 myControlActor = my1DActor;
553 aFunctor.reset(new SMESH::Controls::FreeEdges());
554 myControlActor = my2DActor;
556 case eMultiConnection:
557 aFunctor.reset(new SMESH::Controls::MultiConnection());
558 myControlActor = my1DActor;
560 case eMultiConnection2D:
561 aFunctor.reset(new SMESH::Controls::MultiConnection2D());
562 myControlActor = my2DActor;
566 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
567 aControl->SetPrecision( myControlsPrecision );
568 aFunctor.reset( aControl );
569 myControlActor = my2DActor;
574 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
575 aControl->SetPrecision( myControlsPrecision );
576 aFunctor.reset( aControl );
577 myControlActor = my2DActor;
582 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
583 aControl->SetPrecision( myControlsPrecision );
584 aFunctor.reset( aControl );
585 myControlActor = my2DActor;
590 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
591 aControl->SetPrecision( myControlsPrecision );
592 aFunctor.reset( aControl );
593 myControlActor = my3DActor;
598 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
599 aControl->SetPrecision( myControlsPrecision );
600 aFunctor.reset( aControl );
601 myControlActor = my3DActor;
606 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
607 aControl->SetPrecision( myControlsPrecision );
608 aFunctor.reset( aControl );
609 myControlActor = my2DActor;
614 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
615 aControl->SetPrecision( myControlsPrecision );
616 aFunctor.reset( aControl );
617 myControlActor = my2DActor;
622 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
623 aControl->SetPrecision( myControlsPrecision );
624 aFunctor.reset( aControl );
625 myControlActor = my2DActor;
632 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
633 vtkIdType aNbCells = aGrid->GetNumberOfCells();
635 myControlMode = theMode;
636 switch(myControlMode){
639 my1DExtActor->SetExtControlMode(aFunctor);
642 case eMultiConnection2D:
643 my1DExtActor->SetExtControlMode(aFunctor,myScalarBarActor,myLookupTable);
646 myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable);
650 if(theCheckEntityMode){
651 if(myControlActor == my1DActor)
652 SetEntityMode(eEdges);
653 else if(myControlActor == my2DActor){
654 switch(myControlMode){
657 case eMultiConnection2D:
658 //SetEntityMode(eEdges);
659 SetEntityMode(eFaces);
662 SetEntityMode(eFaces);
664 }else if(myControlActor == my3DActor)
665 SetEntityMode(eVolumes);
668 }else if(theCheckEntityMode){
669 myEntityMode = eAllEntity;
672 SetRepresentation(GetRepresentation());
674 myTimeStamp->Modified();
679 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
680 SALOME_Actor::AddToRender(theRenderer);
682 theRenderer->AddActor(myNodeActor);
683 theRenderer->AddActor(myBaseActor);
685 theRenderer->AddActor(my3DActor);
686 theRenderer->AddActor(my2DActor);
688 theRenderer->AddActor(my1DActor);
689 theRenderer->AddActor(my1DExtActor);
691 theRenderer->AddActor(myHighlitableActor);
693 theRenderer->AddActor2D(myScalarBarActor);
695 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
696 myClsSelectVisiblePoints->SetRenderer(theRenderer);
698 theRenderer->AddActor2D(myPointLabels);
699 theRenderer->AddActor2D(myCellsLabels);
702 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
703 SALOME_Actor::RemoveFromRender(theRenderer);
705 theRenderer->RemoveActor(myNodeActor);
706 theRenderer->RemoveActor(myBaseActor);
708 theRenderer->RemoveActor(myHighlitableActor);
710 theRenderer->RemoveActor(my1DActor);
711 theRenderer->RemoveActor(my1DExtActor);
713 theRenderer->RemoveActor(my2DActor);
714 theRenderer->RemoveActor(my3DActor);
716 theRenderer->RemoveActor(myScalarBarActor);
717 theRenderer->RemoveActor(myPointLabels);
718 theRenderer->RemoveActor(myCellsLabels);
722 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
723 const char* theEntry,
727 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
731 myVisualObj = theVisualObj;
732 myVisualObj->Update(theIsClear);
734 myNodeActor->Init(myVisualObj,myImplicitBoolean);
735 myBaseActor->Init(myVisualObj,myImplicitBoolean);
737 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
739 my1DActor->Init(myVisualObj,myImplicitBoolean);
740 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
742 my2DActor->Init(myVisualObj,myImplicitBoolean);
743 my3DActor->Init(myVisualObj,myImplicitBoolean);
745 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
746 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
748 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
749 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
751 vtkFloatingPointType aFactor, aUnits;
752 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
753 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
755 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
759 //SetIsShrunkable(theGrid->GetNumberOfCells() > 10);
760 SetIsShrunkable(true);
762 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 0.75 ) );
764 int aMode = mgr->integerValue( "SMESH", "display_mode" );
765 SetRepresentation(-1);
768 SetRepresentation(eEdge);
769 }else if(aMode == 1){
770 SetRepresentation(eSurface);
771 }else if(aMode == 2){
772 SetRepresentation(ePoint);
779 myTimeStamp->Modified();
785 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
786 return myNodeActor->GetBounds();
790 vtkDataSet* SMESH_ActorDef::GetInput(){
791 return GetUnstructuredGrid();
795 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
796 Superclass::SetTransform(theTransform);
798 myNodeActor->SetTransform(theTransform);
799 myBaseActor->SetTransform(theTransform);
801 myHighlitableActor->SetTransform(theTransform);
803 my1DActor->SetTransform(theTransform);
804 my1DExtActor->SetTransform(theTransform);
806 my2DActor->SetTransform(theTransform);
807 my3DActor->SetTransform(theTransform);
813 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
814 vtkLODActor::SetMapper(theMapper);
818 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
819 SALOME_Actor::ShallowCopy(prop);
823 vtkMapper* SMESH_ActorDef::GetMapper(){
824 return myPickableActor->GetMapper();
828 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
829 return myVisualObj->GetUnstructuredGrid();
833 bool SMESH_ActorDef::IsInfinitive(){
834 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
836 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
837 aDataSet->GetNumberOfCells() == 1 &&
838 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX;
839 return SALOME_Actor::IsInfinitive();
843 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
844 if ( myIsShrinkable == theShrunkable )
846 myIsShrinkable = theShrunkable;
850 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
851 return myBaseActor->GetShrinkFactor();
854 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
855 myBaseActor->SetShrinkFactor(theValue);
857 my1DActor->SetShrinkFactor(theValue);
858 my1DExtActor->SetShrinkFactor(theValue);
860 my2DActor->SetShrinkFactor(theValue);
861 my3DActor->SetShrinkFactor(theValue);
866 void SMESH_ActorDef::SetShrink(){
867 if(!myIsShrinkable) return;
869 myBaseActor->SetShrink();
871 my1DActor->SetShrink();
872 my1DExtActor->SetShrink();
874 my2DActor->SetShrink();
875 my3DActor->SetShrink();
881 void SMESH_ActorDef::UnShrink(){
882 if(!myIsShrunk) return;
884 myBaseActor->UnShrink();
886 my1DActor->UnShrink();
887 my1DExtActor->UnShrink();
889 my2DActor->UnShrink();
890 my3DActor->UnShrink();
897 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
898 return myPickableActor->GetNodeObjId(theVtkID);
901 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
902 return myPickableActor->GetNodeCoord(theObjID);
906 int SMESH_ActorDef::GetElemObjId(int theVtkID){
907 return myPickableActor->GetElemObjId(theVtkID);
910 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
911 return myPickableActor->GetElemCell(theObjID);
915 void SMESH_ActorDef::SetVisibility(int theMode){
916 SetVisibility(theMode,true);
920 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
921 SALOME_Actor::SetVisibility(theMode);
923 myNodeActor->VisibilityOff();
924 myBaseActor->VisibilityOff();
926 my1DActor->VisibilityOff();
927 my1DExtActor->VisibilityOff();
929 my2DActor->VisibilityOff();
930 my3DActor->VisibilityOff();
932 myScalarBarActor->VisibilityOff();
933 myPointLabels->VisibilityOff();
934 myCellsLabels->VisibilityOff();
937 if(theIsUpdateRepersentation)
938 SetRepresentation(GetRepresentation());
940 if(myControlMode != eNone){
941 switch(myControlMode){
944 my1DExtActor->VisibilityOn();
947 case eMultiConnection2D:
948 my1DExtActor->VisibilityOn();
950 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
951 myScalarBarActor->VisibilityOn();
955 if(myRepresentation != ePoint)
956 myPickableActor->VisibilityOn();
958 myNodeActor->VisibilityOn();
961 if(myEntityMode & eEdges){
962 my1DActor->VisibilityOn();
965 if(myEntityMode & eFaces){
966 my2DActor->VisibilityOn();
969 if(myEntityMode & eVolumes){
970 my3DActor->VisibilityOn();
973 if(myIsPointsLabeled){
974 myPointLabels->VisibilityOn();
975 myNodeActor->VisibilityOn();
979 myCellsLabels->VisibilityOn();
986 void SMESH_ActorDef::SetEntityMode(unsigned int theMode){
987 myEntityState = eAllEntity;
989 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)){
990 myEntityState &= ~eEdges;
994 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)){
995 myEntityState &= ~eFaces;
999 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)){
1000 myEntityState &= ~eVolumes;
1001 theMode &= ~eVolumes;
1005 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
1008 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
1011 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
1012 theMode |= eVolumes;
1015 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
1017 myEntityMode = theMode;
1018 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
1019 aFilter = myBaseActor->GetExtractUnstructuredGrid();
1020 aFilter->ClearRegisteredCellsWithType();
1021 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
1023 if(myEntityMode & eEdges){
1024 if (MYDEBUG) MESSAGE("EDGES");
1025 aFilter->RegisterCellsWithType(VTK_LINE);
1026 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
1029 if(myEntityMode & eFaces){
1030 if (MYDEBUG) MESSAGE("FACES");
1031 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
1032 aFilter->RegisterCellsWithType(VTK_POLYGON);
1033 aFilter->RegisterCellsWithType(VTK_QUAD);
1034 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
1035 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
1038 if(myEntityMode & eVolumes){
1039 if (MYDEBUG) MESSAGE("VOLUMES");
1040 aFilter->RegisterCellsWithType(VTK_TETRA);
1041 aFilter->RegisterCellsWithType(VTK_VOXEL);
1042 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
1043 aFilter->RegisterCellsWithType(VTK_WEDGE);
1044 aFilter->RegisterCellsWithType(VTK_PYRAMID);
1045 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
1046 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
1047 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
1050 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
1051 SetVisibility(GetVisibility(),false);
1054 void SMESH_ActorDef::SetRepresentation(int theMode){
1055 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
1056 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
1057 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
1059 myRepresentation = eSurface;
1060 if(!aNbFaces && !aNbVolumes && aNbEdges){
1061 myRepresentation = eEdge;
1062 }else if(!aNbFaces && !aNbVolumes && !aNbEdges){
1063 myRepresentation = ePoint;
1068 if(!aNbFaces && !aNbVolumes && !aNbEdges) return;
1071 if(!aNbFaces && !aNbVolumes) return;
1074 myRepresentation = theMode;
1077 if(!GetUnstructuredGrid()->GetNumberOfCells())
1078 myRepresentation = ePoint;
1081 if(myRepresentation == ePoint){
1089 myPickableActor = myBaseActor;
1090 myNodeActor->SetVisibility(false);
1091 vtkProperty *aProp = NULL, *aBackProp = NULL;
1092 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
1093 switch(myRepresentation){
1095 myPickableActor = myNodeActor;
1096 myNodeActor->SetVisibility(true);
1098 aProp = aBackProp = myNodeProp;
1099 aReperesent = SMESH_DeviceActor::ePoint;
1102 aProp = aBackProp = myEdgeProp;
1103 aReperesent = SMESH_DeviceActor::eInsideframe;
1106 aProp = mySurfaceProp;
1107 aBackProp = myBackSurfaceProp;
1108 aReperesent = SMESH_DeviceActor::eSurface;
1112 my2DActor->SetProperty(aProp);
1113 my2DActor->SetBackfaceProperty(aBackProp);
1114 my2DActor->SetRepresentation(aReperesent);
1116 my3DActor->SetProperty(aProp);
1117 my3DActor->SetBackfaceProperty(aBackProp);
1118 my3DActor->SetRepresentation(aReperesent);
1120 my1DExtActor->SetVisibility(false);
1122 switch(myControlMode){
1124 case eMultiConnection:
1125 aProp = aBackProp = my1DProp;
1126 if(myRepresentation != ePoint)
1127 aReperesent = SMESH_DeviceActor::eInsideframe;
1131 my1DActor->SetProperty(aProp);
1132 my1DActor->SetBackfaceProperty(aBackProp);
1133 my1DActor->SetRepresentation(aReperesent);
1135 my1DExtActor->SetRepresentation(aReperesent);
1137 if(myIsPointsVisible)
1138 myPickableActor = myNodeActor;
1139 if(GetPointRepresentation())
1140 myNodeActor->SetVisibility(true);
1142 SetMapper(myPickableActor->GetMapper());
1144 SetVisibility(GetVisibility(),false);
1150 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
1151 if ( myIsPointsVisible == theIsPointsVisible )
1153 myIsPointsVisible = theIsPointsVisible;
1154 SetRepresentation(GetRepresentation());
1157 bool SMESH_ActorDef::GetPointRepresentation(){
1158 return myIsPointsVisible || myIsPointsLabeled;
1162 void SMESH_ActorDef::UpdateHighlight(){
1163 myHighlitableActor->SetVisibility(false);
1164 myHighlitableActor->SetHighlited(false);
1166 if(myIsHighlighted){
1167 myHighlitableActor->SetProperty(myHighlightProp);
1168 }else if(myIsPreselected){
1169 myHighlitableActor->SetProperty(myPreselectProp);
1172 bool anIsVisible = GetVisibility();
1174 if(myIsHighlighted || myIsPreselected){
1175 if(GetUnstructuredGrid()->GetNumberOfCells()){
1176 myHighlitableActor->SetHighlited(anIsVisible);
1177 myHighlitableActor->SetVisibility(anIsVisible);
1178 myHighlitableActor->GetExtractUnstructuredGrid()->
1179 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
1180 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
1181 }else if(myRepresentation == ePoint || GetPointRepresentation()){
1182 myHighlitableActor->SetHighlited(anIsVisible);
1183 myHighlitableActor->SetVisibility(anIsVisible);
1184 myHighlitableActor->GetExtractUnstructuredGrid()->
1185 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
1186 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
1192 void SMESH_ActorDef::highlight(bool theHighlight){
1193 if ( myIsHighlighted == theHighlight )
1195 myIsHighlighted = theHighlight;
1200 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
1201 if ( myIsPreselected == thePreselect )
1203 myIsPreselected = thePreselect;
1209 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
1211 if (myPickableActor->GetIsOpaque())
1213 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1221 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
1223 if (!myPickableActor->GetIsOpaque())
1225 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
1233 void SMESH_ActorDef::Render(vtkRenderer *ren){
1234 unsigned long aTime = myTimeStamp->GetMTime();
1235 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1236 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
1237 if(anObjTime > aTime || aClippingTime > aTime)
1242 void SMESH_ActorDef::Update(){
1243 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
1245 if(GetControlMode() != eNone) {
1246 unsigned long aTime = myTimeStamp->GetMTime();
1247 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
1248 if (anObjTime > aTime)
1249 SetControlMode(GetControlMode(),false);
1251 if(myIsPointsLabeled){
1252 SetPointsLabeled(myIsPointsLabeled);
1254 if(myIsCellsLabeled){
1255 SetCellsLabeled(myIsCellsLabeled);
1257 SetEntityMode(GetEntityMode());
1258 SetVisibility(GetVisibility());
1260 myTimeStamp->Modified();
1265 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
1266 SALOME_Actor::ReleaseGraphicsResources(renWin);
1268 myPickableActor->ReleaseGraphicsResources(renWin);
1272 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1273 vtkFloatingPointType* aColor = theProperty->GetColor();
1280 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
1281 mySurfaceProp->SetOpacity(theValue);
1282 myBackSurfaceProp->SetOpacity(theValue);
1283 myEdgeProp->SetOpacity(theValue);
1284 myNodeProp->SetOpacity(theValue);
1286 my1DProp->SetOpacity(theValue);
1290 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
1291 return mySurfaceProp->GetOpacity();
1295 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1296 mySurfaceProp->SetColor(r,g,b);
1300 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1301 ::GetColor(mySurfaceProp,r,g,b);
1304 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1305 myBackSurfaceProp->SetColor(r,g,b);
1309 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1310 ::GetColor(myBackSurfaceProp,r,g,b);
1313 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1314 myEdgeProp->SetColor(r,g,b);
1315 my1DProp->SetColor(r,g,b);
1316 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
1320 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1321 ::GetColor(myEdgeProp,r,g,b);
1324 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1325 myNodeProp->SetColor(r,g,b);
1329 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1330 ::GetColor(myNodeProp,r,g,b);
1333 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1334 myHighlightProp->SetColor(r,g,b);
1338 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1339 ::GetColor(myHighlightProp,r,g,b);
1342 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
1343 myPreselectProp->SetColor(r,g,b);
1347 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
1348 ::GetColor(myPreselectProp,r,g,b);
1352 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
1353 return myEdgeProp->GetLineWidth();
1357 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
1358 myEdgeProp->SetLineWidth(theVal);
1360 my1DProp->SetLineWidth(theVal + aLineWidthInc);
1361 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
1367 void SMESH_ActorDef::SetNodeSize(vtkFloatingPointType theVal){
1368 myNodeProp->SetPointSize(theVal);
1369 myHighlightProp->SetPointSize(theVal);
1370 myPreselectProp->SetPointSize(theVal);
1372 my1DProp->SetPointSize(theVal + aPointSizeInc);
1373 my1DExtProp->SetPointSize(theVal + aPointSizeInc);
1378 vtkFloatingPointType SMESH_ActorDef::GetNodeSize(){
1379 return myNodeProp->GetPointSize();
1382 int SMESH_ActorDef::GetObjDimension( const int theObjId )
1384 return myVisualObj->GetElemDimension( theObjId );
1389 IsImplicitFunctionUsed() const
1391 return myBaseActor->IsImplicitFunctionUsed();
1396 SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
1398 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1399 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1401 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1403 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1404 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1406 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1407 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
1412 AddClippingPlane(vtkPlane* thePlane)
1415 myImplicitBoolean->GetFunction()->AddItem(thePlane);
1416 myCippingPlaneCont.push_back(thePlane);
1417 if(!IsImplicitFunctionUsed())
1418 SetImplicitFunctionUsed(true);
1420 return myCippingPlaneCont.size();
1425 RemoveAllClippingPlanes()
1427 myImplicitBoolean->GetFunction()->RemoveAllItems();
1428 myImplicitBoolean->GetFunction()->Modified(); // VTK bug
1429 myCippingPlaneCont.clear();
1430 SetImplicitFunctionUsed(false);
1435 GetNumberOfClippingPlanes()
1437 return myCippingPlaneCont.size();
1442 GetClippingPlane(vtkIdType theID)
1444 if(theID >= myCippingPlaneCont.size())
1446 return myCippingPlaneCont[theID].Get();
1450 static void ComputeBoundsParam(vtkDataSet* theDataSet,
1451 vtkFloatingPointType theDirection[3], vtkFloatingPointType theMinPnt[3],
1452 vtkFloatingPointType& theMaxBoundPrj, vtkFloatingPointType& theMinBoundPrj)
1454 vtkFloatingPointType aBounds[6];
1455 theDataSet->GetBounds(aBounds);
1457 //Enlarge bounds in order to avoid conflicts of precision
1458 for(int i = 0; i < 6; i += 2){
1459 static double EPS = 1.0E-3;
1460 vtkFloatingPointType aDelta = (aBounds[i+1] - aBounds[i])*EPS;
1461 aBounds[i] -= aDelta;
1462 aBounds[i+1] += aDelta;
1465 vtkFloatingPointType aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]},
1466 {aBounds[1],aBounds[2],aBounds[4]},
1467 {aBounds[0],aBounds[3],aBounds[4]},
1468 {aBounds[1],aBounds[3],aBounds[4]},
1469 {aBounds[0],aBounds[2],aBounds[5]},
1470 {aBounds[1],aBounds[2],aBounds[5]},
1471 {aBounds[0],aBounds[3],aBounds[5]},
1472 {aBounds[1],aBounds[3],aBounds[5]}};
1474 int aMaxId = 0, aMinId = aMaxId;
1475 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1476 theMinBoundPrj = theMaxBoundPrj;
1477 for(int i = 1; i < 8; i++){
1478 vtkFloatingPointType aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1479 if(theMaxBoundPrj < aTmp){
1480 theMaxBoundPrj = aTmp;
1483 if(theMinBoundPrj > aTmp){
1484 theMinBoundPrj = aTmp;
1488 vtkFloatingPointType *aMinPnt = aBoundPoints[aMaxId];
1489 theMinPnt[0] = aMinPnt[0];
1490 theMinPnt[1] = aMinPnt[1];
1491 theMinPnt[2] = aMinPnt[2];
1495 static void DistanceToPosition(vtkDataSet* theDataSet,
1496 vtkFloatingPointType theDirection[3], vtkFloatingPointType theDist, vtkFloatingPointType thePos[3])
1498 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1499 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1500 vtkFloatingPointType aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1501 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1502 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1503 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1507 static void PositionToDistance(vtkDataSet* theDataSet,
1508 vtkFloatingPointType theDirection[3], vtkFloatingPointType thePos[3], vtkFloatingPointType& theDist)
1510 vtkFloatingPointType aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1511 ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1512 vtkFloatingPointType aPrj = vtkMath::Dot(theDirection,thePos);
1513 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1517 void SMESH_ActorDef::SetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType theDist, vtkPlane* thePlane)
1519 thePlane->SetNormal(theDir);
1520 vtkFloatingPointType anOrigin[3];
1521 ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin);
1522 thePlane->SetOrigin(anOrigin);
1526 void SMESH_ActorDef::GetPlaneParam(vtkFloatingPointType theDir[3], vtkFloatingPointType& theDist, vtkPlane* thePlane)
1528 thePlane->GetNormal(theDir);
1530 vtkFloatingPointType anOrigin[3];
1531 thePlane->GetOrigin(anOrigin);
1532 ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist);
1535 void SMESH_ActorDef::UpdateScalarBar()
1537 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
1541 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
1543 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
1544 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1546 aScalarBarTitleProp->SetFontFamilyToArial();
1548 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
1550 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
1551 if ( f.family() == "Arial" )
1552 aScalarBarTitleProp->SetFontFamilyToArial();
1553 else if ( f.family() == "Courier" )
1554 aScalarBarTitleProp->SetFontFamilyToCourier();
1555 else if ( f.family() == "Times" )
1556 aScalarBarTitleProp->SetFontFamilyToTimes();
1559 aScalarBarTitleProp->BoldOn();
1561 aScalarBarTitleProp->BoldOff();
1564 aScalarBarTitleProp->ItalicOn();
1566 aScalarBarTitleProp->ItalicOff();
1568 if ( f.underline() )
1569 aScalarBarTitleProp->ShadowOn();
1571 aScalarBarTitleProp->ShadowOff();
1574 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
1575 aScalarBarTitleProp->Delete();
1577 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
1579 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
1580 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
1582 aScalarBarLabelProp->SetFontFamilyToArial();
1583 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
1585 QFont f = mgr->stringValue( "SMESH", "scalar_bar_label_font" );
1586 if( f.family() == "Arial" )
1587 aScalarBarLabelProp->SetFontFamilyToArial();
1588 else if( f.family() == "Courier" )
1589 aScalarBarLabelProp->SetFontFamilyToCourier();
1590 else if( f.family() == "Times" )
1591 aScalarBarLabelProp->SetFontFamilyToTimes();
1594 aScalarBarLabelProp->BoldOn();
1596 aScalarBarLabelProp->BoldOff();
1599 aScalarBarLabelProp->ItalicOn();
1601 aScalarBarLabelProp->ItalicOff();
1604 aScalarBarLabelProp->ShadowOn();
1606 aScalarBarLabelProp->ShadowOff();
1609 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
1610 aScalarBarLabelProp->Delete();
1612 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
1613 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
1615 myScalarBarActor->SetOrientationToHorizontal();
1617 myScalarBarActor->SetOrientationToVertical();
1620 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
1621 if( mgr->hasValue( "SMESH", name + "x" ) )
1622 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
1624 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
1625 if( mgr->hasValue( "SMESH", name + "y" ) )
1626 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
1627 myScalarBarActor->SetPosition( aXVal, aYVal );
1629 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
1630 if( mgr->hasValue( "SMESH", name + "width" ) )
1631 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
1632 myScalarBarActor->SetWidth( aWVal );
1634 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
1635 if( mgr->hasValue( "SMESH", name + "height" ) )
1636 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
1637 myScalarBarActor->SetHeight( aHVal );
1640 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
1641 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
1642 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
1645 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
1646 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
1647 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );