00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "SMESH_ActorDef.h"
00029 #include "SMESH_ActorUtils.h"
00030 #include "SMESH_DeviceActor.h"
00031 #include "SMESH_ObjectDef.h"
00032 #include "SMESH_ControlsDef.hxx"
00033 #include "SMDS_UnstructuredGrid.hxx"
00034 #include "SMESH_ScalarBarActor.h"
00035 #include "VTKViewer_CellCenters.h"
00036 #include "VTKViewer_DataSetMapper.h"
00037 #include "VTKViewer_ExtractUnstructuredGrid.h"
00038 #include "VTKViewer_FramedTextActor.h"
00039 #include "SALOME_InteractiveObject.hxx"
00040
00041 #include "SUIT_Session.h"
00042 #include "SUIT_ResourceMgr.h"
00043
00044 #ifndef DISABLE_PLOT2DVIEWER
00045 #include <SPlot2d_Histogram.h>
00046 #endif
00047
00048 #include <vtkProperty.h>
00049 #include <vtkTimeStamp.h>
00050 #include <vtkObjectFactory.h>
00051 #include <vtkShrinkPolyData.h>
00052 #include <vtkMergeFilter.h>
00053
00054 #include <vtkMatrix4x4.h>
00055 #include <vtkUnstructuredGrid.h>
00056 #include <vtkPointData.h>
00057 #include <vtkCellData.h>
00058
00059 #include <vtkMapper.h>
00060 #include <vtkRenderer.h>
00061
00062 #include <vtkCell.h>
00063 #include <vtkIdList.h>
00064 #include <vtkIntArray.h>
00065
00066 #include <vtkActor2D.h>
00067 #include <vtkProperty2D.h>
00068 #include <vtkPolyData.h>
00069 #include <vtkMaskPoints.h>
00070 #include <vtkTextProperty.h>
00071 #include <vtkLabeledDataMapper.h>
00072 #include <vtkSelectVisiblePoints.h>
00073
00074 #include <vtkLookupTable.h>
00075
00076 #include <vtkMath.h>
00077 #include <vtkPlane.h>
00078 #include <vtkImplicitBoolean.h>
00079 #include <vtkImplicitFunctionCollection.h>
00080
00081 #include <vtkConfigure.h>
00082 #if !defined(VTK_XVERSION)
00083 #define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
00084 #endif
00085
00086 #include "utilities.h"
00087
00088 #ifdef _DEBUG_
00089 static int MYDEBUG = 1;
00090 #else
00091 static int MYDEBUG = 1;
00092 #endif
00093
00094 static int aLineWidthInc = 2;
00095
00096
00097 SMESH_ActorDef* SMESH_ActorDef::New(){
00098 return new SMESH_ActorDef();
00099 }
00100
00101
00102 SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj,
00103 const char* theEntry,
00104 const char* theName,
00105 int theIsClear)
00106 {
00107 SMESH_ActorDef* anActor = NULL;
00108 if(theVisualObj->IsValid() ) {
00109 anActor = SMESH_ActorDef::New();
00110 if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){
00111 anActor->Delete();
00112 anActor = NULL;
00113 }
00114 if( anActor )
00115 anActor->UpdateScalarBar();
00116 }
00117 return anActor;
00118 }
00119
00120
00121 SMESH_ActorDef::SMESH_ActorDef()
00122 {
00123 if(MYDEBUG) MESSAGE("SMESH_ActorDef - "<<this);
00124
00125 myTimeStamp = vtkTimeStamp::New();
00126
00127 myIsPointsVisible = false;
00128
00129 myIsShrinkable = false;
00130 myIsShrunk = false;
00131
00132 myIsFacesOriented = false;
00133
00134 myControlsPrecision = -1;
00135 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
00136
00137 if ( mgr && mgr->booleanValue( "SMESH", "use_precision", false ) )
00138 myControlsPrecision = mgr->integerValue( "SMESH", "controls_precision", -1);
00139
00140 vtkFloatingPointType aElem0DSize = SMESH::GetFloat("SMESH:elem0d_size",5);
00141 vtkFloatingPointType aLineWidth = SMESH::GetFloat("SMESH:element_width",1);
00142
00143 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
00144 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
00145
00146
00147
00148 vtkFloatingPointType anRGB[3] = {1,1,1};
00149 mySurfaceProp = vtkProperty::New();
00150 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
00151 mySurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
00152
00153 myBackSurfaceProp = vtkProperty::New();
00154 SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) );
00155 myBackSurfaceProp->SetColor( anRGB[0], anRGB[1], anRGB[2] );
00156
00157 my2DActor = SMESH_DeviceActor::New();
00158 my2DActor->SetUserMatrix(aMatrix);
00159 my2DActor->PickableOff();
00160 my2DActor->SetProperty(mySurfaceProp);
00161 my2DActor->SetBackfaceProperty(myBackSurfaceProp);
00162 my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00163 aFilter = my2DActor->GetExtractUnstructuredGrid();
00164 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00165 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
00166 aFilter->RegisterCellsWithType(VTK_POLYGON);
00167 aFilter->RegisterCellsWithType(VTK_QUAD);
00168 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
00169 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
00170
00171 my2DExtProp = vtkProperty::New();
00172 my2DExtProp->DeepCopy(mySurfaceProp);
00173 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
00174 anRGB[0] = 1 - anRGB[0];
00175 anRGB[1] = 1 - anRGB[1];
00176 anRGB[2] = 1 - anRGB[2];
00177 my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00178
00179 my2DExtActor = SMESH_DeviceActor::New();
00180 my2DExtActor->SetUserMatrix(aMatrix);
00181 my2DExtActor->PickableOff();
00182 my2DExtActor->SetProperty(my2DExtProp);
00183 my2DExtActor->SetBackfaceProperty(my2DExtProp);
00184 my2DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
00185 aFilter = my2DExtActor->GetExtractUnstructuredGrid();
00186 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
00187 aFilter->RegisterCellsWithType(VTK_POLYGON);
00188 aFilter->RegisterCellsWithType(VTK_QUAD);
00189 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
00190 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
00191
00192 my3DActor = SMESH_DeviceActor::New();
00193 my3DActor->SetUserMatrix(aMatrix);
00194 my3DActor->PickableOff();
00195 my3DActor->SetProperty(mySurfaceProp);
00196 my3DActor->SetBackfaceProperty(myBackSurfaceProp);
00197 my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00198 aFilter = my3DActor->GetExtractUnstructuredGrid();
00199 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00200 aFilter->RegisterCellsWithType(VTK_TETRA);
00201 aFilter->RegisterCellsWithType(VTK_VOXEL);
00202 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
00203 aFilter->RegisterCellsWithType(VTK_WEDGE);
00204 aFilter->RegisterCellsWithType(VTK_PYRAMID);
00205 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
00206 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
00207 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
00208 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
00209 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
00210
00211 MESSAGE("RegisterCellsWithType(VTK_POLYHEDRON)");
00212 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
00213
00214
00215 my3DExtActor = SMESH_DeviceActor::New();
00216 my3DExtActor->SetUserMatrix(aMatrix);
00217 my3DExtActor->PickableOff();
00218 my3DExtActor->SetProperty(my2DExtProp);
00219 my3DExtActor->SetBackfaceProperty(my2DExtProp);
00220 my3DExtActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00221 aFilter = my3DExtActor->GetExtractUnstructuredGrid();
00222 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00223 aFilter->RegisterCellsWithType(VTK_TETRA);
00224 aFilter->RegisterCellsWithType(VTK_VOXEL);
00225 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
00226 aFilter->RegisterCellsWithType(VTK_WEDGE);
00227 aFilter->RegisterCellsWithType(VTK_PYRAMID);
00228 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
00229 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
00230 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
00231 aFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
00232 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
00233 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
00234
00235
00236
00237 myEdgeProp = vtkProperty::New();
00238 myEdgeProp->SetAmbient(1.0);
00239 myEdgeProp->SetDiffuse(0.0);
00240 myEdgeProp->SetSpecular(0.0);
00241 SMESH::GetColor( "SMESH", "outline_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
00242 myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00243 myEdgeProp->SetLineWidth(aLineWidth);
00244
00245 my1DActor = SMESH_DeviceActor::New();
00246 my1DActor->SetUserMatrix(aMatrix);
00247 my1DActor->PickableOff();
00248 my1DActor->SetHighlited(true);
00249 my1DActor->SetProperty(myEdgeProp);
00250 my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00251 aFilter = my1DActor->GetExtractUnstructuredGrid();
00252 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00253 aFilter->RegisterCellsWithType(VTK_LINE);
00254 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
00255
00256 my1DProp = vtkProperty::New();
00257 my1DProp->DeepCopy(myEdgeProp);
00258 my1DProp->SetLineWidth(aLineWidth + aLineWidthInc);
00259 my1DProp->SetPointSize(aElem0DSize);
00260
00261 my1DExtProp = vtkProperty::New();
00262 my1DExtProp->DeepCopy(myEdgeProp);
00263 anRGB[0] = 1 - anRGB[0];
00264 anRGB[1] = 1 - anRGB[1];
00265 anRGB[2] = 1 - anRGB[2];
00266 my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00267 my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc);
00268 my1DExtProp->SetPointSize(aElem0DSize);
00269
00270 my1DExtActor = SMESH_DeviceActor::New();
00271 my1DExtActor->SetUserMatrix(aMatrix);
00272 my1DExtActor->PickableOff();
00273 my1DExtActor->SetHighlited(true);
00274 my1DExtActor->SetVisibility(false);
00275 my1DExtActor->SetProperty(my1DExtProp);
00276 my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe);
00277 aFilter = my1DExtActor->GetExtractUnstructuredGrid();
00278 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00279 aFilter->RegisterCellsWithType(VTK_LINE);
00280 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
00281
00282
00283
00284
00285 my0DProp = vtkProperty::New();
00286 SMESH::GetColor( "SMESH", "elem0d_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 0 ) );
00287 my0DProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00288 my0DProp->SetPointSize(aElem0DSize);
00289
00290 my0DActor = SMESH_DeviceActor::New();
00291 my0DActor->SetUserMatrix(aMatrix);
00292 my0DActor->SetStoreClippingMapping(true);
00293 my0DActor->PickableOff();
00294 my0DActor->SetVisibility(false);
00295 my0DActor->SetProperty(my0DProp);
00296 my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
00297 aFilter = my0DActor->GetExtractUnstructuredGrid();
00298
00299 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
00300 aFilter->RegisterCellsWithType(VTK_VERTEX);
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00320
00321
00322
00323
00324
00325
00326 myNodeProp = vtkProperty::New();
00327 SMESH::GetColor( "SMESH", "node_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 0, 0 ) );
00328 myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00329
00330 myNodeActor = SMESH_DeviceActor::New();
00331 myNodeActor->SetUserMatrix(aMatrix);
00332 myNodeActor->SetStoreClippingMapping(true);
00333 myNodeActor->PickableOff();
00334 myNodeActor->SetVisibility(false);
00335 myNodeActor->SetProperty(myNodeProp);
00336 myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
00337 aFilter = myNodeActor->GetExtractUnstructuredGrid();
00338 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
00339
00340 myNodeExtProp = vtkProperty::New();
00341 myNodeExtProp->DeepCopy(myNodeProp);
00342 anRGB[0] = 1 - anRGB[0];
00343 anRGB[1] = 1 - anRGB[1];
00344 anRGB[2] = 1 - anRGB[2];
00345 myNodeExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00346
00347 myNodeExtActor = SMESH_DeviceActor::New();
00348 myNodeExtActor->SetUserMatrix(aMatrix);
00349 myNodeExtActor->SetStoreClippingMapping(true);
00350 myNodeExtActor->PickableOff();
00351 myNodeExtActor->SetHighlited(true);
00352 myNodeExtActor->SetVisibility(false);
00353 myNodeExtActor->SetProperty(myNodeExtProp);
00354 myNodeExtActor->SetRepresentation(SMESH_DeviceActor::ePoint);
00355 aFilter = myNodeExtActor->GetExtractUnstructuredGrid();
00356 aFilter->SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
00357 aFilter->RegisterCellsWithType(VTK_VERTEX);
00358
00359
00360
00361
00362 myBaseActor = SMESH_DeviceActor::New();
00363 myBaseActor->SetUserMatrix(aMatrix);
00364 myBaseActor->SetStoreGemetryMapping(true);
00365 myBaseActor->GetProperty()->SetOpacity(0.0);
00366
00367 myPickableActor = myBaseActor;
00368
00369 myMapper = VTKViewer_DataSetMapper::New();
00370 myMapper->SetInput( myPickableActor->GetUnstructuredGrid() );
00371
00372 myHighlightProp = vtkProperty::New();
00373 myHighlightProp->SetAmbient(1.0);
00374 myHighlightProp->SetDiffuse(0.0);
00375 myHighlightProp->SetSpecular(0.0);
00376 SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
00377 myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00378 myHighlightProp->SetPointSize(aElem0DSize);
00379 myHighlightProp->SetRepresentation(1);
00380
00381 myPreselectProp = vtkProperty::New();
00382 myPreselectProp->SetAmbient(1.0);
00383 myPreselectProp->SetDiffuse(0.0);
00384 myPreselectProp->SetSpecular(0.0);
00385 SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) );
00386 myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]);
00387 myPreselectProp->SetPointSize(aElem0DSize);
00388 myPreselectProp->SetRepresentation(1);
00389
00390 myHighlitableActor = SMESH_DeviceActor::New();
00391 myHighlitableActor->SetUserMatrix(aMatrix);
00392 myHighlitableActor->PickableOff();
00393 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
00394
00395 aMatrix->Delete();
00396
00397 myName = "";
00398 myIO = NULL;
00399
00400 myControlMode = eNone;
00401 myControlActor = my2DActor;
00402
00403
00404
00405 myLookupTable = vtkLookupTable::New();
00406
00407
00408 myLookupTable->SetHueRange(0.667,0.0);
00409
00410 myScalarBarActor = SMESH_ScalarBarActor::New();
00411 myScalarBarActor->SetVisibility(false);
00412 myScalarBarActor->SetLookupTable(myLookupTable);
00413
00414
00415
00416
00417
00418
00419 mgr = SUIT_Session::session()->resourceMgr();
00420 if( !mgr )
00421 return;
00422
00423
00424
00425 myPointsNumDataSet = vtkUnstructuredGrid::New();
00426
00427 myPtsMaskPoints = vtkMaskPoints::New();
00428 myPtsMaskPoints->SetInput(myPointsNumDataSet);
00429 myPtsMaskPoints->SetOnRatio(1);
00430
00431 myPtsSelectVisiblePoints = vtkSelectVisiblePoints::New();
00432 myPtsSelectVisiblePoints->SetInput(myPtsMaskPoints->GetOutput());
00433 myPtsSelectVisiblePoints->SelectInvisibleOff();
00434 myPtsSelectVisiblePoints->SetTolerance(0.1);
00435
00436 myPtsLabeledDataMapper = vtkLabeledDataMapper::New();
00437 myPtsLabeledDataMapper->SetInput(myPtsSelectVisiblePoints->GetOutput());
00438 #if (VTK_XVERSION < 0x050200)
00439 myPtsLabeledDataMapper->SetLabelFormat("%g");
00440 #endif
00441 myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
00442
00443 vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
00444 aPtsTextProp->SetFontFamilyToTimes();
00445 static int aPointsFontSize = 10;
00446 aPtsTextProp->SetFontSize(aPointsFontSize);
00447 aPtsTextProp->SetBold(1);
00448 aPtsTextProp->SetItalic(0);
00449 aPtsTextProp->SetShadow(0);
00450 myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
00451 aPtsTextProp->Delete();
00452
00453 myEntityMode = eAllEntity;
00454
00455 myIsPointsLabeled = false;
00456
00457 myPointLabels = vtkActor2D::New();
00458 myPointLabels->SetMapper(myPtsLabeledDataMapper);
00459 myPointLabels->GetProperty()->SetColor(1,1,1);
00460 myPointLabels->SetVisibility(myIsPointsLabeled);
00461
00462
00463
00464
00465 myCellsNumDataSet = vtkUnstructuredGrid::New();
00466
00467 myCellCenters = VTKViewer_CellCenters::New();
00468 myCellCenters->SetInput(myCellsNumDataSet);
00469
00470 myClsMaskPoints = vtkMaskPoints::New();
00471 myClsMaskPoints->SetInput(myCellCenters->GetOutput());
00472 myClsMaskPoints->SetOnRatio(1);
00473
00474 myClsSelectVisiblePoints = vtkSelectVisiblePoints::New();
00475 myClsSelectVisiblePoints->SetInput(myClsMaskPoints->GetOutput());
00476 myClsSelectVisiblePoints->SelectInvisibleOff();
00477 myClsSelectVisiblePoints->SetTolerance(0.1);
00478
00479 myClsLabeledDataMapper = vtkLabeledDataMapper::New();
00480 myClsLabeledDataMapper->SetInput(myClsSelectVisiblePoints->GetOutput());
00481 #if (VTK_XVERSION < 0x050200)
00482 myClsLabeledDataMapper->SetLabelFormat("%g");
00483 #endif
00484 myClsLabeledDataMapper->SetLabelModeToLabelScalars();
00485
00486 vtkTextProperty* aClsTextProp = vtkTextProperty::New();
00487 aClsTextProp->SetFontFamilyToTimes();
00488 static int aCellsFontSize = 12;
00489 aClsTextProp->SetFontSize(aCellsFontSize);
00490 aClsTextProp->SetBold(1);
00491 aClsTextProp->SetItalic(0);
00492 aClsTextProp->SetShadow(0);
00493 myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
00494 aClsTextProp->Delete();
00495
00496 myIsCellsLabeled = false;
00497
00498 myCellsLabels = vtkActor2D::New();
00499 myCellsLabels->SetMapper(myClsLabeledDataMapper);
00500 myCellsLabels->GetProperty()->SetColor(0,1,0);
00501 myCellsLabels->SetVisibility(myIsCellsLabeled);
00502
00503
00504 myImplicitBoolean = vtkImplicitBoolean::New();
00505 myImplicitBoolean->SetOperationTypeToIntersection();
00506
00507
00508
00509
00510
00511 int aQuadratic2DMode = mgr->integerValue( "SMESH", "quadratic_mode", 0);
00512 if(aQuadratic2DMode == 0){
00513 myHighlitableActor->SetQuadraticArcMode(false);
00514 my2DActor->SetQuadraticArcMode(false);
00515 my1DActor->SetQuadraticArcMode(false);
00516 }
00517 else if(aQuadratic2DMode == 1){
00518 myHighlitableActor->SetQuadraticArcMode(true);
00519 my2DActor->SetQuadraticArcMode(true);
00520 my1DActor->SetQuadraticArcMode(true);
00521 }
00522
00523 int aQuadraticAngle = mgr->integerValue( "SMESH", "max_angle", 2);
00524 myHighlitableActor->SetQuadraticArcAngle(aQuadraticAngle);
00525 my2DActor->SetQuadraticArcAngle(aQuadraticAngle);
00526
00527
00528 SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) );
00529 myNameActor->SetBackgroundColor(anRGB[0], anRGB[1], anRGB[2]);
00530 SMESH::GetColor( "SMESH", "group_name_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
00531 myNameActor->SetForegroundColor(anRGB[0], anRGB[1], anRGB[2]);
00532
00533 #ifndef DISABLE_PLOT2DVIEWER
00534 my2dHistogram = 0;
00535 #endif
00536
00537 }
00538
00539
00540 SMESH_ActorDef::~SMESH_ActorDef()
00541 {
00542 if(MYDEBUG) MESSAGE("~SMESH_ActorDef - "<<this);
00543
00544 #ifndef DISABLE_PLOT2DVIEWER
00545 if(my2dHistogram) {
00546 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
00547 delete my2dHistogram;
00548 }
00549 #endif
00550
00551
00552 this->InvokeEvent( SMESH::DeleteActorEvent, NULL );
00553
00554 myScalarBarActor->Delete();
00555 myLookupTable->Delete();
00556
00557 mySurfaceProp->Delete();
00558 myBackSurfaceProp->Delete();
00559
00560 myEdgeProp->Delete();
00561 myHighlightProp->Delete();
00562 myPreselectProp->Delete();
00563
00564 myNodeProp->Delete();
00565 myNodeExtProp->Delete();
00566
00567 my0DProp->Delete();
00568 my0DActor->Delete();
00569
00570
00571
00572
00573 my1DProp->Delete();
00574 my1DActor->Delete();
00575
00576 my1DExtProp->Delete();
00577 my1DExtActor->Delete();
00578
00579 my2DActor->Delete();
00580 my2DExtProp->Delete();
00581 my2DExtActor->Delete();
00582 my3DActor->Delete();
00583 my3DExtActor->Delete();
00584
00585 myNodeActor->Delete();
00586 myBaseActor->Delete();
00587
00588 myNodeExtActor->Delete();
00589
00590 myHighlitableActor->Delete();
00591
00592
00593
00594 myPointsNumDataSet->Delete();
00595
00596
00597
00598 myPtsLabeledDataMapper->Delete();
00599
00600
00601
00602 myPtsSelectVisiblePoints->Delete();
00603
00604
00605
00606 myPtsMaskPoints->Delete();
00607
00608 myPointLabels->Delete();
00609
00610
00611
00612
00613 myCellsNumDataSet->Delete();
00614
00615 myClsLabeledDataMapper->RemoveAllInputs();
00616 myClsLabeledDataMapper->Delete();
00617
00618
00619
00620 myClsSelectVisiblePoints->Delete();
00621
00622
00623
00624 myClsMaskPoints->Delete();
00625
00626
00627
00628 myCellCenters->Delete();
00629
00630 myCellsLabels->Delete();
00631
00632 myImplicitBoolean->Delete();
00633
00634 myMapper->Delete();
00635
00636 myTimeStamp->Delete();
00637 }
00638
00639
00640 void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
00641 {
00642 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
00643
00644 myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints();
00645
00646 if ( myIsPointsLabeled )
00647 {
00648 myPointsNumDataSet->ShallowCopy(aGrid);
00649 vtkDataSet *aDataSet = myPointsNumDataSet;
00650
00651 int aNbElem = aDataSet->GetNumberOfPoints();
00652
00653 vtkIntArray *anArray = vtkIntArray::New();
00654 anArray->SetNumberOfValues( aNbElem );
00655
00656 for ( vtkIdType anId = 0; anId < aNbElem; anId++ )
00657 {
00658 int aSMDSId = myVisualObj->GetNodeObjId( anId );
00659 anArray->SetValue( anId, aSMDSId );
00660 }
00661
00662 aDataSet->GetPointData()->SetScalars( anArray );
00663 anArray->Delete();
00664 myPtsMaskPoints->SetInput( aDataSet );
00665 myPointLabels->SetVisibility( GetVisibility() );
00666 }
00667 else
00668 {
00669 myPointLabels->SetVisibility( false );
00670 }
00671 SetRepresentation(GetRepresentation());
00672 myTimeStamp->Modified();
00673 }
00674
00675
00676 void SMESH_ActorDef::SetCellsLabeled(bool theIsCellsLabeled)
00677 {
00678 vtkUnstructuredGrid* aGrid = GetUnstructuredGrid();
00679 myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints();
00680 if(myIsCellsLabeled){
00681 myCellsNumDataSet->ShallowCopy(aGrid);
00682 vtkDataSet *aDataSet = myCellsNumDataSet;
00683 int aNbElem = aDataSet->GetNumberOfCells();
00684 vtkIntArray *anArray = vtkIntArray::New();
00685 anArray->SetNumberOfValues(aNbElem);
00686 for(int anId = 0; anId < aNbElem; anId++){
00687 int aSMDSId = myVisualObj->GetElemObjId(anId);
00688 anArray->SetValue(anId,aSMDSId);
00689 }
00690 aDataSet->GetCellData()->SetScalars(anArray);
00691 myCellCenters->SetInput(aDataSet);
00692 myCellsLabels->SetVisibility(GetVisibility());
00693 }else{
00694 myCellsLabels->SetVisibility(false);
00695 }
00696 myTimeStamp->Modified();
00697 }
00698
00699
00700 void SMESH_ActorDef::SetFacesOriented(bool theIsFacesOriented)
00701 {
00702 myIsFacesOriented = theIsFacesOriented;
00703
00704 my2DActor->SetFacesOriented(theIsFacesOriented);
00705 my3DActor->SetFacesOriented(theIsFacesOriented);
00706
00707 myTimeStamp->Modified();
00708 }
00709
00710 bool SMESH_ActorDef::GetFacesOriented()
00711 {
00712 return myIsFacesOriented;
00713 }
00714
00715 void SMESH_ActorDef::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
00716 {
00717 my2DActor->SetFacesOrientationColor( theColor );
00718 my3DActor->SetFacesOrientationColor( theColor );
00719 }
00720
00721 void SMESH_ActorDef::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
00722 {
00723 my3DActor->GetFacesOrientationColor( theColor );
00724 }
00725
00726 void SMESH_ActorDef::SetFacesOrientationScale(vtkFloatingPointType theScale)
00727 {
00728 my2DActor->SetFacesOrientationScale( theScale );
00729 my3DActor->SetFacesOrientationScale( theScale );
00730 }
00731
00732 vtkFloatingPointType SMESH_ActorDef::GetFacesOrientationScale()
00733 {
00734 return my3DActor->GetFacesOrientationScale();
00735 }
00736
00737 void SMESH_ActorDef::SetFacesOrientation3DVectors(bool theState)
00738 {
00739 my2DActor->SetFacesOrientation3DVectors( theState );
00740 my3DActor->SetFacesOrientation3DVectors( theState );
00741 }
00742
00743 bool SMESH_ActorDef::GetFacesOrientation3DVectors()
00744 {
00745 return my3DActor->GetFacesOrientation3DVectors();
00746 }
00747
00748
00749 void
00750 SMESH_ActorDef::
00751 SetControlMode(eControl theMode)
00752 {
00753 SetControlMode(theMode,true);
00754 }
00755
00756
00757 void
00758 SMESH_ActorDef::
00759 SetControlMode(eControl theMode,
00760 bool theCheckEntityMode)
00761 {
00762 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
00763 if( !mgr )
00764 return;
00765
00766 myControlMode = eNone;
00767 theCheckEntityMode &= mgr->booleanValue( "SMESH", "display_entity", false );
00768
00769 my0DActor->GetMapper()->SetScalarVisibility(false);
00770 my1DActor->GetMapper()->SetScalarVisibility(false);
00771 my2DActor->GetMapper()->SetScalarVisibility(false);
00772 my3DActor->GetMapper()->SetScalarVisibility(false);
00773 myScalarBarActor->SetVisibility(false);
00774
00775 bool anIsScalarVisible = theMode > eNone;
00776
00777 if(anIsScalarVisible) {
00778 switch(theMode) {
00779 case eLength:
00780 {
00781 SMESH::Controls::Length* aControl = new SMESH::Controls::Length();
00782 aControl->SetPrecision( myControlsPrecision );
00783 myFunctor.reset( aControl );
00784 myControlActor = my1DActor;
00785 break;
00786 }
00787 case eLength2D:
00788 {
00789 myFunctor.reset(new SMESH::Controls::Length2D());
00790 myControlActor = my2DActor;
00791 break;
00792 }
00793 case eFreeBorders:
00794 myFunctor.reset(new SMESH::Controls::FreeBorders());
00795 myControlActor = my1DActor;
00796 break;
00797 case eFreeEdges:
00798 myFunctor.reset(new SMESH::Controls::FreeEdges());
00799 myControlActor = my2DActor;
00800 break;
00801 case eFreeNodes:
00802 myFunctor.reset(new SMESH::Controls::FreeNodes());
00803 myControlActor = myNodeActor;
00804 break;
00805 case eFreeFaces:
00806 myFunctor.reset(new SMESH::Controls::FreeFaces());
00807 myControlActor = my2DActor;
00808 break;
00809 case eBareBorderFace:
00810 myFunctor.reset(new SMESH::Controls::BareBorderFace());
00811 myControlActor = my2DActor;
00812 break;
00813 case eOverConstrainedFace:
00814 myFunctor.reset(new SMESH::Controls::OverConstrainedFace());
00815 myControlActor = my2DActor;
00816 break;
00817 case eMultiConnection:
00818 myFunctor.reset(new SMESH::Controls::MultiConnection());
00819 myControlActor = my1DActor;
00820 break;
00821 case eMultiConnection2D:
00822 myFunctor.reset(new SMESH::Controls::MultiConnection2D());
00823 myControlActor = my2DActor;
00824 break;
00825 case eArea:
00826 {
00827 SMESH::Controls::Area* aControl = new SMESH::Controls::Area();
00828 aControl->SetPrecision( myControlsPrecision );
00829 myFunctor.reset( aControl );
00830 myControlActor = my2DActor;
00831 break;
00832 }
00833 case eTaper:
00834 {
00835 SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper();
00836 aControl->SetPrecision( myControlsPrecision );
00837 myFunctor.reset( aControl );
00838 myControlActor = my2DActor;
00839 break;
00840 }
00841 case eAspectRatio:
00842 {
00843 SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio();
00844 aControl->SetPrecision( myControlsPrecision );
00845 myFunctor.reset( aControl );
00846 myControlActor = my2DActor;
00847 break;
00848 }
00849 case eAspectRatio3D:
00850 {
00851 SMESH::Controls::AspectRatio3D* aControl = new SMESH::Controls::AspectRatio3D();
00852 aControl->SetPrecision( myControlsPrecision );
00853 myFunctor.reset( aControl );
00854 myControlActor = my3DActor;
00855 break;
00856 }
00857 case eVolume3D:
00858 {
00859 SMESH::Controls::Volume* aControl = new SMESH::Controls::Volume();
00860 aControl->SetPrecision( myControlsPrecision );
00861 myFunctor.reset( aControl );
00862 myControlActor = my3DActor;
00863 break;
00864 }
00865 case eMaxElementLength2D:
00866 {
00867 SMESH::Controls::MaxElementLength2D* aControl = new SMESH::Controls::MaxElementLength2D();
00868 aControl->SetPrecision( myControlsPrecision );
00869 myFunctor.reset( aControl );
00870 myControlActor = my2DActor;
00871 break;
00872 }
00873 case eMaxElementLength3D:
00874 {
00875 SMESH::Controls::MaxElementLength3D* aControl = new SMESH::Controls::MaxElementLength3D();
00876 aControl->SetPrecision( myControlsPrecision );
00877 myFunctor.reset( aControl );
00878 myControlActor = my3DActor;
00879 break;
00880 }
00881 case eBareBorderVolume:
00882 {
00883 myFunctor.reset(new SMESH::Controls::BareBorderVolume());
00884 myControlActor = my3DActor;
00885 break;
00886 }
00887 case eOverConstrainedVolume:
00888 {
00889 myFunctor.reset(new SMESH::Controls::OverConstrainedVolume());
00890 myControlActor = my3DActor;
00891 break;
00892 }
00893 case eMinimumAngle:
00894 {
00895 SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle();
00896 aControl->SetPrecision( myControlsPrecision );
00897 myFunctor.reset( aControl );
00898 myControlActor = my2DActor;
00899 break;
00900 }
00901 case eWarping:
00902 {
00903 SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping();
00904 aControl->SetPrecision( myControlsPrecision );
00905 myFunctor.reset( aControl );
00906 myControlActor = my2DActor;
00907 break;
00908 }
00909 case eSkew:
00910 {
00911 SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew();
00912 aControl->SetPrecision( myControlsPrecision );
00913 myFunctor.reset( aControl );
00914 myControlActor = my2DActor;
00915 break;
00916 }
00917 default:
00918 return;
00919 }
00920
00921 vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid();
00922 vtkIdType aNbCells = aGrid->GetNumberOfCells();
00923 if(aNbCells){
00924 myControlMode = theMode;
00925 switch(myControlMode){
00926 case eFreeNodes:
00927 myNodeExtActor->SetExtControlMode(myFunctor);
00928 break;
00929 case eFreeEdges:
00930 case eFreeBorders:
00931 my1DExtActor->SetExtControlMode(myFunctor);
00932 break;
00933 case eFreeFaces:
00934 case eBareBorderFace:
00935 case eOverConstrainedFace:
00936 my2DExtActor->SetExtControlMode(myFunctor);
00937 break;
00938 case eBareBorderVolume:
00939 case eOverConstrainedVolume:
00940 my3DExtActor->SetExtControlMode(myFunctor);
00941 break;
00942 case eLength2D:
00943 case eMultiConnection2D:
00944 my1DExtActor->SetExtControlMode(myFunctor,myScalarBarActor,myLookupTable);
00945 UpdateDistribution();
00946 break;
00947 default:
00948 myControlActor->SetControlMode(myFunctor,myScalarBarActor,myLookupTable);
00949 UpdateDistribution();
00950 }
00951 }
00952
00953 if(theCheckEntityMode){
00954 if(myControlActor == my1DActor)
00955 SetEntityMode(eEdges);
00956 else if(myControlActor == my2DActor){
00957 switch(myControlMode){
00958 case eLength2D:
00959 case eFreeEdges:
00960 case eFreeFaces:
00961 case eMultiConnection2D:
00962
00963 SetEntityMode(eFaces);
00964 break;
00965 default:
00966 SetEntityMode(eFaces);
00967 }
00968 }else if(myControlActor == my3DActor)
00969 SetEntityMode(eVolumes);
00970 }
00971
00972 }
00973 else {
00974 if(theCheckEntityMode)
00975 myEntityMode = eAllEntity;
00976 myFunctor.reset();
00977 }
00978
00979 SetRepresentation(GetRepresentation());
00980
00981 myTimeStamp->Modified();
00982 Modified();
00983 }
00984
00985
00986 void SMESH_ActorDef::AddToRender(vtkRenderer* theRenderer){
00987 theRenderer->AddActor(myNodeActor);
00988 theRenderer->AddActor(myBaseActor);
00989
00990 theRenderer->AddActor(myNodeExtActor);
00991
00992 my3DActor->AddToRender(theRenderer);
00993 my3DExtActor->AddToRender(theRenderer);
00994 my2DActor->AddToRender(theRenderer);
00995 my2DExtActor->AddToRender(theRenderer);
00996
00997 theRenderer->AddActor(my1DActor);
00998 theRenderer->AddActor(my1DExtActor);
00999
01000 theRenderer->AddActor(my0DActor);
01001
01002
01003 theRenderer->AddActor(myHighlitableActor);
01004
01005 theRenderer->AddActor2D(myScalarBarActor);
01006
01007 myPtsSelectVisiblePoints->SetRenderer(theRenderer);
01008 myClsSelectVisiblePoints->SetRenderer(theRenderer);
01009
01010 theRenderer->AddActor2D(myPointLabels);
01011 theRenderer->AddActor2D(myCellsLabels);
01012
01013
01014
01015 SALOME_Actor::AddToRender(theRenderer);
01016 }
01017
01018 void SMESH_ActorDef::RemoveFromRender(vtkRenderer* theRenderer){
01019 SALOME_Actor::RemoveFromRender(theRenderer);
01020
01021 theRenderer->RemoveActor(myNodeActor);
01022 theRenderer->RemoveActor(myBaseActor);
01023
01024 theRenderer->RemoveActor(myNodeExtActor);
01025
01026 theRenderer->RemoveActor(myHighlitableActor);
01027
01028 theRenderer->RemoveActor(my0DActor);
01029
01030
01031 theRenderer->RemoveActor(my1DActor);
01032 theRenderer->RemoveActor(my1DExtActor);
01033
01034 my2DActor->RemoveFromRender(theRenderer);
01035 my2DExtActor->RemoveFromRender(theRenderer);
01036 my3DActor->RemoveFromRender(theRenderer);
01037 my3DExtActor->RemoveFromRender(theRenderer);
01038
01039 theRenderer->RemoveActor(myScalarBarActor);
01040 theRenderer->RemoveActor(myPointLabels);
01041 theRenderer->RemoveActor(myCellsLabels);
01042 }
01043
01044
01045 bool SMESH_ActorDef::Init(TVisualObjPtr theVisualObj,
01046 const char* theEntry,
01047 const char* theName,
01048 int theIsClear)
01049 {
01050 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName);
01051 setIO(anIO);
01052 setName(theName);
01053
01054 myVisualObj = theVisualObj;
01055 myVisualObj->Update(theIsClear);
01056
01057 myNodeActor->Init(myVisualObj,myImplicitBoolean);
01058 myBaseActor->Init(myVisualObj,myImplicitBoolean);
01059
01060 myHighlitableActor->Init(myVisualObj,myImplicitBoolean);
01061
01062 myNodeExtActor->Init(myVisualObj,myImplicitBoolean);
01063
01064 my0DActor->Init(myVisualObj,myImplicitBoolean);
01065
01066
01067 my1DActor->Init(myVisualObj,myImplicitBoolean);
01068 my1DExtActor->Init(myVisualObj,myImplicitBoolean);
01069
01070 my2DActor->Init(myVisualObj,myImplicitBoolean);
01071 my2DExtActor->Init(myVisualObj,myImplicitBoolean);
01072 my3DActor->Init(myVisualObj,myImplicitBoolean);
01073 my3DExtActor->Init(myVisualObj,myImplicitBoolean);
01074
01075 my0DActor->GetMapper()->SetLookupTable(myLookupTable);
01076
01077
01078 my1DActor->GetMapper()->SetLookupTable(myLookupTable);
01079 my1DExtActor->GetMapper()->SetLookupTable(myLookupTable);
01080
01081 my2DActor->GetMapper()->SetLookupTable(myLookupTable);
01082 my2DExtActor->GetMapper()->SetLookupTable(myLookupTable);
01083 my3DActor->GetMapper()->SetLookupTable(myLookupTable);
01084 my3DExtActor->GetMapper()->SetLookupTable(myLookupTable);
01085
01086 vtkFloatingPointType aFactor, aUnits;
01087 my2DActor->GetPolygonOffsetParameters(aFactor,aUnits);
01088 my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75);
01089 my2DExtActor->SetPolygonOffsetParameters(aFactor,aUnits*0.5);
01090
01091 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
01092 if( !mgr )
01093 return false;
01094
01095
01096 SetIsShrunkable(true);
01097
01098 SetShrinkFactor( SMESH::GetFloat( "SMESH:shrink_coeff", 75 ) / 100. );
01099
01100 int aMode = mgr->integerValue( "SMESH", "display_mode" );
01101 SetRepresentation(-1);
01102
01103 if(aMode == 0){
01104 SetRepresentation(eEdge);
01105 }else if(aMode == 1){
01106 SetRepresentation(eSurface);
01107 }else if(aMode == 2){
01108 SetRepresentation(ePoint);
01109 }
01110
01111 if(aMode == 3){
01112 SetShrink();
01113 }
01114
01115 if( dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01116 SetIsDisplayNameActor( true );
01117
01118 int aMarkerType = mgr->integerValue( "SMESH", "type_of_marker", 1 );
01119 int aMarkerScale = mgr->integerValue( "SMESH", "marker_scale", 9 );
01120 SetMarkerStd( (VTK::MarkerType)aMarkerType, (VTK::MarkerScale)aMarkerScale );
01121
01122 myTimeStamp->Modified();
01123 Modified();
01124 return true;
01125 }
01126
01127
01128 vtkFloatingPointType* SMESH_ActorDef::GetBounds(){
01129 return myNodeActor->GetBounds();
01130 }
01131
01132
01133 vtkDataSet* SMESH_ActorDef::GetInput(){
01134 return GetUnstructuredGrid();
01135 }
01136
01137
01138 void SMESH_ActorDef::SetTransform(VTKViewer_Transform* theTransform){
01139 Superclass::SetTransform(theTransform);
01140
01141 myNodeActor->SetTransform(theTransform);
01142 myBaseActor->SetTransform(theTransform);
01143
01144 myHighlitableActor->SetTransform(theTransform);
01145
01146 myNodeExtActor->SetTransform(theTransform);
01147
01148 my0DActor->SetTransform(theTransform);
01149
01150
01151 my1DActor->SetTransform(theTransform);
01152 my1DExtActor->SetTransform(theTransform);
01153
01154 my2DActor->SetTransform(theTransform);
01155 my2DExtActor->SetTransform(theTransform);
01156 my3DActor->SetTransform(theTransform);
01157 my3DExtActor->SetTransform(theTransform);
01158
01159 Modified();
01160 }
01161
01162
01163 void SMESH_ActorDef::SetMapper(vtkMapper* theMapper){
01164 vtkLODActor::SetMapper(theMapper);
01165 }
01166
01167
01168 void SMESH_ActorDef::ShallowCopy(vtkProp *prop){
01169 SALOME_Actor::ShallowCopy(prop);
01170 }
01171
01172
01173 vtkMapper* SMESH_ActorDef::GetMapper(){
01174 return myMapper;
01175 }
01176
01177
01178 vtkUnstructuredGrid* SMESH_ActorDef::GetUnstructuredGrid(){
01179 return myVisualObj->GetUnstructuredGrid();
01180 }
01181
01182
01183 bool SMESH_ActorDef::IsInfinitive(){
01184 vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid();
01185 aDataSet->Update();
01186 myIsInfinite = aDataSet->GetNumberOfCells() == 0 ||
01187 ( aDataSet->GetNumberOfCells() == 1 &&
01188 aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX );
01189 return SALOME_Actor::IsInfinitive();
01190 }
01191
01192
01193 void SMESH_ActorDef::SetIsShrunkable(bool theShrunkable){
01194 if ( myIsShrinkable == theShrunkable )
01195 return;
01196 myIsShrinkable = theShrunkable;
01197 Modified();
01198 }
01199
01200 vtkFloatingPointType SMESH_ActorDef::GetShrinkFactor(){
01201 return myBaseActor->GetShrinkFactor();
01202 }
01203
01204 void SMESH_ActorDef::SetShrinkFactor(vtkFloatingPointType theValue){
01205 myBaseActor->SetShrinkFactor(theValue);
01206
01207 my1DActor->SetShrinkFactor(theValue);
01208 my1DExtActor->SetShrinkFactor(theValue);
01209
01210 my2DActor->SetShrinkFactor(theValue);
01211 my2DExtActor->SetShrinkFactor(theValue);
01212 my3DActor->SetShrinkFactor(theValue);
01213 my3DExtActor->SetShrinkFactor(theValue);
01214
01215 Modified();
01216 }
01217
01218 void SMESH_ActorDef::SetShrink(){
01219 if(!myIsShrinkable) return;
01220
01221 myBaseActor->SetShrink();
01222
01223 my1DActor->SetShrink();
01224 my1DExtActor->SetShrink();
01225
01226 my2DActor->SetShrink();
01227 my2DExtActor->SetShrink();
01228 my3DActor->SetShrink();
01229 my3DExtActor->SetShrink();
01230
01231 myIsShrunk = true;
01232 Modified();
01233 }
01234
01235 void SMESH_ActorDef::UnShrink(){
01236 if(!myIsShrunk) return;
01237
01238 myBaseActor->UnShrink();
01239
01240 my1DActor->UnShrink();
01241 my1DExtActor->UnShrink();
01242
01243 my2DActor->UnShrink();
01244 my2DExtActor->UnShrink();
01245 my3DActor->UnShrink();
01246 my3DExtActor->UnShrink();
01247
01248 myIsShrunk = false;
01249 Modified();
01250 }
01251
01252
01253 int SMESH_ActorDef::GetNodeObjId(int theVtkID){
01254 return myPickableActor->GetNodeObjId(theVtkID);
01255 }
01256
01257 vtkFloatingPointType* SMESH_ActorDef::GetNodeCoord(int theObjID){
01258 return myPickableActor->GetNodeCoord(theObjID);
01259 }
01260
01261
01262 int SMESH_ActorDef::GetElemObjId(int theVtkID){
01263 return myPickableActor->GetElemObjId(theVtkID);
01264 }
01265
01266 vtkCell* SMESH_ActorDef::GetElemCell(int theObjID){
01267 return myPickableActor->GetElemCell(theObjID);
01268 }
01269
01270
01271 void SMESH_ActorDef::SetVisibility(int theMode){
01272 SetVisibility(theMode,true);
01273 }
01274
01275
01276 void SMESH_ActorDef::SetVisibility(int theMode, bool theIsUpdateRepersentation){
01277 SALOME_Actor::SetVisibility(theMode);
01278
01279 myNodeActor->VisibilityOff();
01280 myBaseActor->VisibilityOff();
01281
01282 myNodeExtActor->VisibilityOff();
01283
01284 my0DActor->VisibilityOff();
01285
01286
01287 my1DActor->VisibilityOff();
01288 my1DExtActor->VisibilityOff();
01289
01290 my2DActor->VisibilityOff();
01291 my2DExtActor->VisibilityOff();
01292 my3DActor->VisibilityOff();
01293 my3DExtActor->VisibilityOff();
01294
01295 myScalarBarActor->VisibilityOff();
01296 myPointLabels->VisibilityOff();
01297 myCellsLabels->VisibilityOff();
01298
01299 if(GetVisibility()){
01300 if(theIsUpdateRepersentation)
01301 SetRepresentation(GetRepresentation());
01302
01303 if(myControlMode != eNone){
01304 switch(myControlMode){
01305 case eFreeNodes:
01306 myNodeExtActor->VisibilityOn();
01307 break;
01308 case eFreeEdges:
01309 case eFreeBorders:
01310 my1DExtActor->VisibilityOn();
01311 break;
01312 case eFreeFaces:
01313 case eBareBorderFace:
01314 case eOverConstrainedFace:
01315 my2DExtActor->VisibilityOn();
01316 break;
01317 case eBareBorderVolume:
01318 case eOverConstrainedVolume:
01319 my3DExtActor->VisibilityOn();
01320 break;
01321 case eLength2D:
01322 case eMultiConnection2D:
01323 my1DExtActor->VisibilityOn();
01324 default:
01325 if(myControlActor->GetUnstructuredGrid()->GetNumberOfCells())
01326 myScalarBarActor->VisibilityOn();
01327 }
01328 }
01329
01330 if(myRepresentation != ePoint)
01331 myPickableActor->VisibilityOn();
01332 else {
01333 myNodeActor->VisibilityOn();
01334 }
01335
01336 if(myEntityMode & e0DElements){
01337 my0DActor->VisibilityOn();
01338 }
01339
01340 if(myEntityMode & eEdges && GetRepresentation() != ePoint){
01341 my1DActor->VisibilityOn();
01342 }
01343
01344 if(myEntityMode & eFaces && GetRepresentation() != ePoint){
01345 my2DActor->VisibilityOn();
01346 }
01347
01348 if(myEntityMode & eVolumes && GetRepresentation() != ePoint){
01349 my3DActor->VisibilityOn();
01350 }
01351
01352 if(myIsPointsLabeled){
01353 myPointLabels->VisibilityOn();
01354 myNodeActor->VisibilityOn();
01355 }
01356
01357 if(myIsCellsLabeled)
01358 myCellsLabels->VisibilityOn();
01359 }
01360 #ifndef DISABLE_PLOT2DVIEWER
01361 else
01362 SMESH::ProcessIn2DViewers(this,SMESH::RemoveFrom2dViewer);
01363 #endif
01364 UpdateHighlight();
01365 Modified();
01366 }
01367
01368
01369 void SMESH_ActorDef::SetEntityMode(unsigned int theMode)
01370 {
01371 myEntityState = eAllEntity;
01372
01373 if(!myVisualObj->GetNbEntities(SMDSAbs_0DElement)) {
01374 myEntityState &= ~e0DElements;
01375 theMode &= ~e0DElements;
01376 }
01377
01378 if(!myVisualObj->GetNbEntities(SMDSAbs_Edge)) {
01379 myEntityState &= ~eEdges;
01380 theMode &= ~eEdges;
01381 }
01382
01383 if(!myVisualObj->GetNbEntities(SMDSAbs_Face)) {
01384 myEntityState &= ~eFaces;
01385 theMode &= ~eFaces;
01386 }
01387
01388 if(!myVisualObj->GetNbEntities(SMDSAbs_Volume)) {
01389 myEntityState &= ~eVolumes;
01390 theMode &= ~eVolumes;
01391 }
01392
01393 if (!theMode) {
01394 if(myVisualObj->GetNbEntities(SMDSAbs_0DElement))
01395 theMode |= e0DElements;
01396
01397 if(myVisualObj->GetNbEntities(SMDSAbs_Edge))
01398 theMode |= eEdges;
01399
01400 if(myVisualObj->GetNbEntities(SMDSAbs_Face))
01401 theMode |= eFaces;
01402
01403 if(myVisualObj->GetNbEntities(SMDSAbs_Volume))
01404 theMode |= eVolumes;
01405 }
01406
01407 myBaseActor->myGeomFilter->SetInside(myEntityMode != myEntityState);
01408
01409 myEntityMode = theMode;
01410 VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
01411 aFilter = myBaseActor->GetExtractUnstructuredGrid();
01412 aFilter->ClearRegisteredCellsWithType();
01413 aFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
01414
01415 VTKViewer_ExtractUnstructuredGrid* aHightFilter = myHighlitableActor->GetExtractUnstructuredGrid();
01416 aHightFilter->ClearRegisteredCellsWithType();
01417 aHightFilter->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
01418
01419 if (myEntityMode & e0DElements) {
01420 if (MYDEBUG) MESSAGE("0D ELEMENTS");
01421 aFilter->RegisterCellsWithType(VTK_VERTEX);
01422 aHightFilter->RegisterCellsWithType(VTK_VERTEX);
01423 }
01424
01425 if (myEntityMode & eEdges) {
01426 if (MYDEBUG) MESSAGE("EDGES");
01427 aFilter->RegisterCellsWithType(VTK_LINE);
01428 aFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
01429
01430 aHightFilter->RegisterCellsWithType(VTK_LINE);
01431 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_EDGE);
01432 }
01433
01434 if (myEntityMode & eFaces) {
01435 if (MYDEBUG) MESSAGE("FACES");
01436 aFilter->RegisterCellsWithType(VTK_TRIANGLE);
01437 aFilter->RegisterCellsWithType(VTK_POLYGON);
01438 aFilter->RegisterCellsWithType(VTK_QUAD);
01439 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
01440 aFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
01441
01442 aHightFilter->RegisterCellsWithType(VTK_TRIANGLE);
01443 aHightFilter->RegisterCellsWithType(VTK_POLYGON);
01444 aHightFilter->RegisterCellsWithType(VTK_QUAD);
01445 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TRIANGLE);
01446 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_QUAD);
01447 }
01448
01449 if (myEntityMode & eVolumes) {
01450 if (MYDEBUG) MESSAGE("VOLUMES");
01451 aFilter->RegisterCellsWithType(VTK_TETRA);
01452 aFilter->RegisterCellsWithType(VTK_VOXEL);
01453 aFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
01454 aFilter->RegisterCellsWithType(VTK_WEDGE);
01455 aFilter->RegisterCellsWithType(VTK_PYRAMID);
01456 aFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
01457 aFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
01458 aFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
01459 aFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
01460
01461 aFilter->RegisterCellsWithType(VTK_POLYHEDRON);
01462
01463
01464 aHightFilter->RegisterCellsWithType(VTK_TETRA);
01465 aHightFilter->RegisterCellsWithType(VTK_VOXEL);
01466 aHightFilter->RegisterCellsWithType(VTK_HEXAHEDRON);
01467 aHightFilter->RegisterCellsWithType(VTK_WEDGE);
01468 aHightFilter->RegisterCellsWithType(VTK_PYRAMID);
01469 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_TETRA);
01470 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_HEXAHEDRON);
01471 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_WEDGE);
01472 aHightFilter->RegisterCellsWithType(VTK_QUADRATIC_PYRAMID);
01473 aHightFilter->RegisterCellsWithType(VTK_CONVEX_POINT_SET);
01474
01475 aHightFilter->RegisterCellsWithType(VTK_POLYHEDRON);
01476
01477 }
01478 aFilter->Update();
01479 if (MYDEBUG) MESSAGE(aFilter->GetOutput()->GetNumberOfCells());
01480 SetVisibility(GetVisibility(),false);
01481 }
01482
01483 void SMESH_ActorDef::SetRepresentation (int theMode)
01484 {
01485 int aNbEdges = myVisualObj->GetNbEntities(SMDSAbs_Edge);
01486 int aNbFaces = myVisualObj->GetNbEntities(SMDSAbs_Face);
01487 int aNbVolumes = myVisualObj->GetNbEntities(SMDSAbs_Volume);
01488
01489 if (theMode < 0) {
01490 myRepresentation = eSurface;
01491 if (!aNbFaces && !aNbVolumes && aNbEdges) {
01492 myRepresentation = eEdge;
01493 } else if (!aNbFaces && !aNbVolumes && !aNbEdges) {
01494 myRepresentation = ePoint;
01495 }
01496 } else {
01497 switch (theMode) {
01498 case eEdge:
01499 if (!aNbFaces && !aNbVolumes && !aNbEdges) return;
01500 break;
01501 case eSurface:
01502 if (!aNbFaces && !aNbVolumes) return;
01503 break;
01504 }
01505 myRepresentation = theMode;
01506 }
01507
01508 if (!GetUnstructuredGrid()->GetNumberOfCells())
01509 myRepresentation = ePoint;
01510
01511 if (myIsShrunk) {
01512 if (myRepresentation == ePoint) {
01513 UnShrink();
01514 myIsShrunk = true;
01515 } else {
01516 SetShrink();
01517 }
01518 }
01519
01520 myPickableActor = myBaseActor;
01521 myNodeActor->SetVisibility(false);
01522 myNodeExtActor->SetVisibility(false);
01523 vtkProperty *aProp = NULL, *aBackProp = NULL;
01524 SMESH_DeviceActor::EReperesent aReperesent = SMESH_DeviceActor::EReperesent(-1);
01525 SMESH_Actor::EQuadratic2DRepresentation aQuadraticMode = GetQuadratic2DRepresentation();
01526 switch (myRepresentation) {
01527 case ePoint:
01528 myPickableActor = myNodeActor;
01529 myNodeActor->SetVisibility(true);
01530 aQuadraticMode = SMESH_Actor::eLines;
01531 aProp = aBackProp = myNodeProp;
01532 aReperesent = SMESH_DeviceActor::ePoint;
01533 break;
01534 case eEdge:
01535 aProp = aBackProp = myEdgeProp;
01536 aReperesent = SMESH_DeviceActor::eInsideframe;
01537 break;
01538 case eSurface:
01539 aProp = mySurfaceProp;
01540 aBackProp = myBackSurfaceProp;
01541 aReperesent = SMESH_DeviceActor::eSurface;
01542 break;
01543 }
01544
01545 my2DActor->SetProperty(aProp);
01546 my2DActor->SetBackfaceProperty(aBackProp);
01547 my2DActor->SetRepresentation(aReperesent);
01548
01549 if(aQuadraticMode == SMESH_Actor::eLines)
01550 my2DActor->SetQuadraticArcMode(false);
01551 else if(aQuadraticMode == SMESH_Actor::eArcs)
01552 my2DActor->SetQuadraticArcMode(true);
01553
01554 my2DExtActor->SetRepresentation(aReperesent);
01555
01556 my3DActor->SetProperty(aProp);
01557 my3DActor->SetBackfaceProperty(aBackProp);
01558 my3DActor->SetRepresentation(aReperesent);
01559
01560
01561 my1DExtActor->SetVisibility(false);
01562 my2DExtActor->SetVisibility(false);
01563 my3DExtActor->SetVisibility(false);
01564
01565
01566
01567
01568 my0DActor->SetRepresentation(aReperesent);
01569
01570
01571 switch(myControlMode){
01572 case eLength:
01573 case eMultiConnection:
01574 aProp = aBackProp = my1DProp;
01575 if(myRepresentation != ePoint)
01576 aReperesent = SMESH_DeviceActor::eInsideframe;
01577 break;
01578 }
01579
01580 if(aQuadraticMode == SMESH_Actor::eLines)
01581 my1DActor->SetQuadraticArcMode(false);
01582 else if(aQuadraticMode == SMESH_Actor::eArcs)
01583 my1DActor->SetQuadraticArcMode(true);
01584
01585 my1DActor->SetProperty(aProp);
01586 my1DActor->SetBackfaceProperty(aBackProp);
01587 my1DActor->SetRepresentation(aReperesent);
01588
01589 my1DExtActor->SetRepresentation(aReperesent);
01590
01591 if(myIsPointsVisible)
01592 myPickableActor = myNodeActor;
01593 if(GetPointRepresentation())
01594 myNodeActor->SetVisibility(true);
01595
01596 SetMapper(myPickableActor->GetMapper());
01597
01598 SetVisibility(GetVisibility(),false);
01599
01600 Modified();
01601 }
01602
01603
01604 void SMESH_ActorDef::SetPointRepresentation(bool theIsPointsVisible){
01605 if ( myIsPointsVisible == theIsPointsVisible )
01606 return;
01607 myIsPointsVisible = theIsPointsVisible;
01608 SetRepresentation(GetRepresentation());
01609 }
01610
01611 bool SMESH_ActorDef::GetPointRepresentation(){
01612 return myIsPointsVisible || myIsPointsLabeled;
01613 }
01614
01615
01616 void SMESH_ActorDef::UpdateHighlight(){
01617 myHighlitableActor->SetVisibility(false);
01618 myHighlitableActor->SetHighlited(false);
01619
01620 if(myIsHighlighted){
01621 myHighlitableActor->SetProperty(myHighlightProp);
01622 }else if(myIsPreselected){
01623 myHighlitableActor->SetProperty(myPreselectProp);
01624 }
01625
01626 bool anIsVisible = GetVisibility();
01627
01628 if(myIsHighlighted || myIsPreselected){
01629 if(GetUnstructuredGrid()->GetNumberOfCells()){
01630 myHighlitableActor->SetHighlited(anIsVisible);
01631 myHighlitableActor->SetVisibility(anIsVisible);
01632 myHighlitableActor->GetExtractUnstructuredGrid()->
01633 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::eCells);
01634 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe);
01635 }else if(myRepresentation == ePoint || GetPointRepresentation()){
01636 myHighlitableActor->SetHighlited(anIsVisible);
01637 myHighlitableActor->GetExtractUnstructuredGrid()->
01638 SetModeOfExtraction(VTKViewer_ExtractUnstructuredGrid::ePoints);
01639 myHighlitableActor->SetVisibility(anIsVisible);
01640 myHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint);
01641
01642 VTK::MarkerType aMarkerType = GetMarkerType();
01643 if(aMarkerType != VTK::MT_USER)
01644 myHighlitableActor->SetMarkerStd(aMarkerType, GetMarkerScale());
01645 else
01646 myHighlitableActor->SetMarkerTexture(GetMarkerTexture(), myMarkerTexture);
01647 }
01648 }
01649 }
01650
01651
01652 void SMESH_ActorDef::highlight(bool theHighlight){
01653 if ( myIsHighlighted == theHighlight )
01654 return;
01655 myIsHighlighted = theHighlight;
01656 UpdateHighlight();
01657 }
01658
01659
01660 void SMESH_ActorDef::SetPreSelected(bool thePreselect){
01661 if ( myIsPreselected == thePreselect )
01662 return;
01663 myIsPreselected = thePreselect;
01664 UpdateHighlight();
01665 }
01666
01667
01668
01669 int SMESH_ActorDef::RenderOpaqueGeometry(vtkViewport *vp)
01670 {
01671 if (myPickableActor->GetIsOpaque())
01672 {
01673 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
01674 this->Render(ren);
01675 return 1;
01676 }
01677 return 0;
01678 }
01679
01680
01681 int SMESH_ActorDef::RenderTranslucentGeometry(vtkViewport *vp)
01682 {
01683 if (!myPickableActor->GetIsOpaque())
01684 {
01685 vtkRenderer *ren = static_cast<vtkRenderer *>(vp);
01686 this->Render(ren);
01687 return 1;
01688 }
01689 return 0;
01690 }
01691
01692
01693 void SMESH_ActorDef::Render(vtkRenderer *ren){
01694 unsigned long aTime = myTimeStamp->GetMTime();
01695 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
01696 unsigned long aClippingTime = myImplicitBoolean->GetMTime();
01697 if(anObjTime > aTime || aClippingTime > aTime)
01698 Update();
01699 }
01700
01701
01702 void SMESH_ActorDef::Update(){
01703 if(MYDEBUG) MESSAGE("SMESH_ActorDef::Update");
01704
01705 if(GetControlMode() != eNone) {
01706 unsigned long aTime = myTimeStamp->GetMTime();
01707 unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime();
01708 if (anObjTime > aTime)
01709 SetControlMode(GetControlMode(),false);
01710 }
01711 if(myIsPointsLabeled){
01712 SetPointsLabeled(myIsPointsLabeled);
01713 }
01714 if(myIsCellsLabeled){
01715 SetCellsLabeled(myIsCellsLabeled);
01716 }
01717 if(myIsFacesOriented){
01718 SetFacesOriented(myIsFacesOriented);
01719 }
01720 SetEntityMode(GetEntityMode());
01721 SetVisibility(GetVisibility());
01722
01723 myTimeStamp->Modified();
01724 Modified();
01725 }
01726
01727
01728 void SMESH_ActorDef::ReleaseGraphicsResources(vtkWindow *renWin){
01729 SALOME_Actor::ReleaseGraphicsResources(renWin);
01730
01731 myPickableActor->ReleaseGraphicsResources(renWin);
01732 }
01733
01734
01735 static void GetColor(vtkProperty *theProperty, vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01736 vtkFloatingPointType* aColor = theProperty->GetColor();
01737 r = aColor[0];
01738 g = aColor[1];
01739 b = aColor[2];
01740 }
01741
01742
01743 void SMESH_ActorDef::SetOpacity(vtkFloatingPointType theValue){
01744 mySurfaceProp->SetOpacity(theValue);
01745 myBackSurfaceProp->SetOpacity(theValue);
01746 myEdgeProp->SetOpacity(theValue);
01747 myNodeProp->SetOpacity(theValue);
01748
01749 my1DProp->SetOpacity(theValue);
01750 }
01751
01752
01753 vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
01754 return mySurfaceProp->GetOpacity();
01755 }
01756
01757
01758 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01759 mySurfaceProp->SetColor(r,g,b);
01760 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01761 if( aGroupObj->GetElementType() == SMDSAbs_Face ||
01762 aGroupObj->GetElementType() == SMDSAbs_Volume )
01763 myNameActor->SetBackgroundColor(r,g,b);
01764 Modified();
01765 }
01766
01767 void SMESH_ActorDef::GetSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01768 ::GetColor(mySurfaceProp,r,g,b);
01769 my2DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
01770 }
01771
01772 void SMESH_ActorDef::SetBackSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01773 myBackSurfaceProp->SetColor(r,g,b);
01774 Modified();
01775 }
01776
01777 void SMESH_ActorDef::GetBackSufaceColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01778 ::GetColor(myBackSurfaceProp,r,g,b);
01779 }
01780
01781 void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01782 myEdgeProp->SetColor(r,g,b);
01783 my1DProp->SetColor(r,g,b);
01784 my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
01785 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01786 if( aGroupObj->GetElementType() == SMDSAbs_Edge )
01787 myNameActor->SetBackgroundColor(r,g,b);
01788 Modified();
01789 }
01790
01791 void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01792 ::GetColor(myEdgeProp,r,g,b);
01793 }
01794
01795 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01796 myNodeProp->SetColor(r,g,b);
01797 myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
01798 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01799 if( aGroupObj->GetElementType() == SMDSAbs_Node )
01800 myNameActor->SetBackgroundColor(r,g,b);
01801 Modified();
01802 }
01803
01804 void SMESH_ActorDef::GetNodeColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01805 ::GetColor(myNodeProp,r,g,b);
01806 }
01807
01808 void SMESH_ActorDef::Set0DColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01809 my0DProp->SetColor(r,g,b);
01810 if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
01811 if( aGroupObj->GetElementType() == SMDSAbs_0DElement )
01812 myNameActor->SetBackgroundColor(r,g,b);
01813 Modified();
01814 }
01815
01816 void SMESH_ActorDef::Get0DColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01817 ::GetColor(my0DProp,r,g,b);
01818 }
01819
01820 void SMESH_ActorDef::SetHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01821 myHighlightProp->SetColor(r,g,b);
01822 Modified();
01823 }
01824
01825 void SMESH_ActorDef::GetHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01826 ::GetColor(myHighlightProp,r,g,b);
01827 }
01828
01829 void SMESH_ActorDef::SetPreHighlightColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
01830 myPreselectProp->SetColor(r,g,b);
01831 Modified();
01832 }
01833
01834 void SMESH_ActorDef::GetPreHighlightColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b){
01835 ::GetColor(myPreselectProp,r,g,b);
01836 }
01837
01838
01839 vtkFloatingPointType SMESH_ActorDef::GetLineWidth(){
01840 return myEdgeProp->GetLineWidth();
01841 }
01842
01843
01844 void SMESH_ActorDef::SetLineWidth(vtkFloatingPointType theVal){
01845 myEdgeProp->SetLineWidth(theVal);
01846
01847 my1DProp->SetLineWidth(theVal + aLineWidthInc);
01848 my1DExtProp->SetLineWidth(theVal + aLineWidthInc);
01849
01850 Modified();
01851 }
01852
01853
01854 void SMESH_ActorDef::Set0DSize(vtkFloatingPointType theVal){
01855 my0DProp->SetPointSize(theVal);
01856 Modified();
01857 }
01858
01859 vtkFloatingPointType SMESH_ActorDef::Get0DSize(){
01860 return my0DProp->GetPointSize();
01861 }
01862
01863 int SMESH_ActorDef::GetObjDimension( const int theObjId )
01864 {
01865 return myVisualObj->GetElemDimension( theObjId );
01866 }
01867
01868 bool
01869 SMESH_ActorDef::
01870 IsImplicitFunctionUsed() const
01871 {
01872 return myBaseActor->IsImplicitFunctionUsed();
01873 }
01874
01875 void
01876 SMESH_ActorDef::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
01877 {
01878 myNodeActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01879 myBaseActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01880
01881 myHighlitableActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01882
01883 myNodeExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01884
01885 my0DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01886
01887
01888 my1DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01889 my1DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01890
01891 my2DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01892 my2DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01893 my3DActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01894 my3DExtActor->SetImplicitFunctionUsed(theIsImplicitFunctionUsed);
01895 }
01896
01897 vtkIdType
01898 SMESH_ActorDef::AddClippingPlane(vtkPlane* thePlane)
01899 {
01900 if(thePlane){
01901 myImplicitBoolean->GetFunction()->AddItem(thePlane);
01902 myCippingPlaneCont.push_back(thePlane);
01903 if(!IsImplicitFunctionUsed())
01904 SetImplicitFunctionUsed(true);
01905 }
01906 return myCippingPlaneCont.size();
01907 }
01908
01909 void
01910 SMESH_ActorDef::
01911 RemoveAllClippingPlanes()
01912 {
01913 myImplicitBoolean->GetFunction()->RemoveAllItems();
01914 myImplicitBoolean->GetFunction()->Modified();
01915 myCippingPlaneCont.clear();
01916 SetImplicitFunctionUsed(false);
01917 }
01918
01919 vtkIdType
01920 SMESH_ActorDef::
01921 GetNumberOfClippingPlanes()
01922 {
01923 return myCippingPlaneCont.size();
01924 }
01925
01926 vtkPlane*
01927 SMESH_ActorDef::
01928 GetClippingPlane(vtkIdType theID)
01929 {
01930 if(theID >= myCippingPlaneCont.size())
01931 return NULL;
01932 return myCippingPlaneCont[theID].Get();
01933 }
01934
01935 void SMESH_ActorDef::UpdateScalarBar()
01936 {
01937 SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr();
01938 if( !mgr )
01939 return;
01940
01941 vtkTextProperty* aScalarBarTitleProp = vtkTextProperty::New();
01942
01943 QColor aTColor = mgr->colorValue( "SMESH", "scalar_bar_title_color", QColor( 255, 255, 255 ) );
01944 aScalarBarTitleProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
01945
01946 aScalarBarTitleProp->SetFontFamilyToArial();
01947
01948 if ( mgr->hasValue( "SMESH", "scalar_bar_title_font" ) )
01949 {
01950 QFont f = mgr->fontValue( "SMESH", "scalar_bar_title_font" );
01951 if ( f.family() == "Arial" )
01952 aScalarBarTitleProp->SetFontFamilyToArial();
01953 else if ( f.family() == "Courier" )
01954 aScalarBarTitleProp->SetFontFamilyToCourier();
01955 else if ( f.family() == "Times" )
01956 aScalarBarTitleProp->SetFontFamilyToTimes();
01957
01958 if ( f.bold() )
01959 aScalarBarTitleProp->BoldOn();
01960 else
01961 aScalarBarTitleProp->BoldOff();
01962
01963 if ( f.italic() )
01964 aScalarBarTitleProp->ItalicOn();
01965 else
01966 aScalarBarTitleProp->ItalicOff();
01967
01968 if ( f.overline() )
01969 aScalarBarTitleProp->ShadowOn();
01970 else
01971 aScalarBarTitleProp->ShadowOff();
01972 }
01973
01974 myScalarBarActor->SetTitleTextProperty( aScalarBarTitleProp );
01975 aScalarBarTitleProp->Delete();
01976
01977 vtkTextProperty* aScalarBarLabelProp = vtkTextProperty::New();
01978
01979 aTColor = mgr->colorValue( "SMESH", "scalar_bar_label_color", QColor( 255, 255, 255 ) );
01980 aScalarBarLabelProp->SetColor( aTColor.red()/255., aTColor.green()/255., aTColor.blue()/255. );
01981
01982 aScalarBarLabelProp->SetFontFamilyToArial();
01983 if( mgr->hasValue( "SMESH", "scalar_bar_label_font" ) )
01984 {
01985 QFont f = mgr->fontValue( "SMESH", "scalar_bar_label_font" );
01986 if( f.family() == "Arial" )
01987 aScalarBarLabelProp->SetFontFamilyToArial();
01988 else if( f.family() == "Courier" )
01989 aScalarBarLabelProp->SetFontFamilyToCourier();
01990 else if( f.family() == "Times" )
01991 aScalarBarLabelProp->SetFontFamilyToTimes();
01992
01993 if ( f.bold() )
01994 aScalarBarLabelProp->BoldOn();
01995 else
01996 aScalarBarLabelProp->BoldOff();
01997
01998 if ( f.italic() )
01999 aScalarBarLabelProp->ItalicOn();
02000 else
02001 aScalarBarLabelProp->ItalicOff();
02002
02003 if( f.overline() )
02004 aScalarBarLabelProp->ShadowOn();
02005 else
02006 aScalarBarLabelProp->ShadowOff();
02007 }
02008
02009 myScalarBarActor->SetLabelTextProperty( aScalarBarLabelProp );
02010 aScalarBarLabelProp->Delete();
02011
02012 bool horiz = ( mgr->integerValue( "SMESH", "scalar_bar_orientation" ) == 1 );
02013 QString name = QString( "scalar_bar_%1_" ).arg( horiz ? "horizontal" : "vertical" );
02014 if( horiz )
02015 myScalarBarActor->SetOrientationToHorizontal();
02016 else
02017 myScalarBarActor->SetOrientationToVertical();
02018
02019
02020 vtkFloatingPointType aXVal = horiz ? 0.20 : 0.01;
02021 if( mgr->hasValue( "SMESH", name + "x" ) )
02022 aXVal = mgr->doubleValue( "SMESH", name + "x", aXVal );
02023
02024 vtkFloatingPointType aYVal = horiz ? 0.01 : 0.1;
02025 if( mgr->hasValue( "SMESH", name + "y" ) )
02026 aYVal = mgr->doubleValue( "SMESH", name + "y", aYVal );
02027 myScalarBarActor->SetPosition( aXVal, aYVal );
02028
02029 vtkFloatingPointType aWVal = horiz ? 0.60 : 0.10;
02030 if( mgr->hasValue( "SMESH", name + "width" ) )
02031 aWVal = mgr->doubleValue( "SMESH", name + "width", aWVal );
02032 myScalarBarActor->SetWidth( aWVal );
02033
02034 vtkFloatingPointType aHVal = horiz ? 0.12 : 0.80;
02035 if( mgr->hasValue( "SMESH", name + "height" ) )
02036 aHVal = mgr->doubleValue( "SMESH", name + "height", aHVal );
02037 myScalarBarActor->SetHeight( aHVal );
02038
02039 int anIntVal = 5;
02040 if( mgr->hasValue( "SMESH", "scalar_bar_num_labels" ) )
02041 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_labels", anIntVal );
02042 myScalarBarActor->SetNumberOfLabels( anIntVal == 0 ? 5: anIntVal );
02043
02044 anIntVal = 64;
02045 if( mgr->hasValue( "SMESH", "scalar_bar_num_colors" ) )
02046 anIntVal = mgr->integerValue( "SMESH", "scalar_bar_num_colors", anIntVal );
02047 myScalarBarActor->SetMaximumNumberOfColors( anIntVal == 0 ? 64 : anIntVal );
02048
02049 bool distributionVisibility = mgr->booleanValue("SMESH","distribution_visibility");
02050 myScalarBarActor->SetDistributionVisibility(distributionVisibility);
02051
02052 int coloringType = mgr->integerValue("SMESH", "distribution_coloring_type", 0);
02053 myScalarBarActor->SetDistributionColoringType(coloringType);
02054
02055 QColor distributionColor = mgr->colorValue("SMESH", "distribution_color",
02056 QColor(255, 255, 255));
02057 double rgb[3];
02058 rgb[0]= distributionColor.red()/255.;
02059 rgb[1]= distributionColor.green()/255.;
02060 rgb[2]= distributionColor.blue()/255.;
02061 myScalarBarActor->SetDistributionColor(rgb);
02062
02063
02064 }
02065
02066 void SMESH_ActorDef::UpdateDistribution()
02067 {
02068 if(SMESH::Controls::NumericalFunctor* fun =
02069 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
02070 {
02071 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
02072 std::vector<int> nbEvents;
02073 std::vector<double> funValues;
02074 SMESH_VisualObjDef::TEntityList elems;
02075 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
02076 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
02077 std::vector<int> elemIds;
02078 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
02079 elemIds.push_back( (*e)->GetID());
02080 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
02081 double * range = lookupTable->GetRange();
02082 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
02083 myScalarBarActor->SetDistribution(nbEvents);
02084 }
02085 }
02086
02087 void SMESH_ActorDef::SetQuadratic2DRepresentation(EQuadratic2DRepresentation theMode)
02088 {
02089 switch(theMode) {
02090 case SMESH_Actor::eLines :
02091 myHighlitableActor->SetQuadraticArcMode(false);
02092 my2DActor->SetQuadraticArcMode(false);
02093 my1DActor->SetQuadraticArcMode(false);
02094 break;
02095 case SMESH_Actor::eArcs :
02096 myHighlitableActor->SetQuadraticArcMode(true);
02097 if(GetRepresentation() != SMESH_Actor::ePoint) {
02098 my2DActor->SetQuadraticArcMode(true);
02099 my1DActor->SetQuadraticArcMode(true);
02100 }
02101 break;
02102 default:
02103 break;
02104 }
02105 }
02106
02107
02108 SMESH_Actor::EQuadratic2DRepresentation SMESH_ActorDef::GetQuadratic2DRepresentation()
02109 {
02110 if(myHighlitableActor->GetQuadraticArcMode())
02111 return SMESH_Actor::eArcs;
02112 else
02113 return SMESH_Actor::eLines;
02114 }
02115
02116 void SMESH_ActorDef::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
02117 {
02118 SALOME_Actor::SetMarkerStd( theMarkerType, theMarkerScale );
02119 myNodeActor->SetMarkerStd( theMarkerType, theMarkerScale );
02120 myNodeExtActor->SetMarkerStd( theMarkerType, theMarkerScale );
02121 }
02122
02123 void SMESH_ActorDef::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
02124 {
02125 SALOME_Actor::SetMarkerTexture( theMarkerId, theMarkerTexture );
02126 myNodeActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
02127 myNodeExtActor->SetMarkerTexture( theMarkerId, theMarkerTexture );
02128 myMarkerTexture = theMarkerTexture;
02129 }
02130
02131 #ifndef DISABLE_PLOT2DVIEWER
02132 SPlot2d_Histogram* SMESH_ActorDef::UpdatePlot2Histogram() {
02133
02134 if(my2dHistogram)
02135 my2dHistogram->clearAllPoints();
02136
02137 if(SMESH::Controls::NumericalFunctor* fun =
02138 dynamic_cast<SMESH::Controls::NumericalFunctor*>(myFunctor.get()))
02139 {
02140
02141 if(!my2dHistogram) {
02142 my2dHistogram = new SPlot2d_Histogram();
02143 Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(getIO()->getEntry(),"SMESH",getName());
02144 my2dHistogram->setIO(anIO);
02145 }
02146
02147 int nbIntervals = myScalarBarActor->GetMaximumNumberOfColors();
02148 std::vector<int> nbEvents;
02149 std::vector<double> funValues;
02150 SMESH_VisualObjDef::TEntityList elems;
02151 if ( ! dynamic_cast<SMESH_MeshObj*>(myVisualObj.get()))
02152 dynamic_cast<SMESH_VisualObjDef*>(myVisualObj.get())->GetEntities( fun->GetType(), elems );
02153 std::vector<int> elemIds;
02154
02155 for ( SMESH_VisualObjDef::TEntityList::iterator e = elems.begin(); e != elems.end(); ++e)
02156 elemIds.push_back( (*e)->GetID());
02157
02158 vtkLookupTable* lookupTable = static_cast<vtkLookupTable*>(myScalarBarActor->GetLookupTable());
02159 double * range = lookupTable->GetRange();
02160 fun->GetHistogram(nbIntervals, nbEvents, funValues, elemIds, range);
02161
02162 for ( int i = 0; i < std::min( nbEvents.size(), funValues.size() -1 ); i++ )
02163 my2dHistogram->addPoint(funValues[i] + (funValues[i+1] - funValues[i])/2.0, static_cast<double>(nbEvents[i]));
02164
02165 if(funValues.size() >= 2)
02166 my2dHistogram->setWidth((funValues[1] - funValues[0]) * 0.8) ;
02167
02168 }
02169
02170
02171 if(myScalarBarActor->GetDistributionColoringType() == SMESH_MULTICOLOR_TYPE)
02172 my2dHistogram->setAutoAssign(true);
02173 else {
02174 double rgb[3];
02175 myScalarBarActor->GetDistributionColor(rgb);
02176 QColor aColor = QColor( (int)( rgb[0]*255 ), (int)( rgb[1]*255 ), (int)( rgb[2]*255 ) );
02177 my2dHistogram->setColor(aColor);
02178
02179 }
02180
02181 return my2dHistogram;
02182 }
02183 #endif