From 52805d02153831bcf68c46d19567bcb5dcdf2cee Mon Sep 17 00:00:00 2001 From: asv Date: Fri, 7 Apr 2006 13:51:40 +0000 Subject: [PATCH] Clipping plane create in GUI state restoring is OrientedPlane class instead of vtkPlane. --- src/VISUGUI/VisuGUI_ClippingDlg.cxx | 216 +++++++++++++--------------- src/VISUGUI/VisuGUI_ClippingDlg.h | 48 +++++++ src/VISUGUI/VisuGUI_Module.cxx | 11 +- 3 files changed, 157 insertions(+), 118 deletions(-) diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index 656fb80f..bb1359ce 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -103,134 +103,124 @@ namespace VISU { //class : OrientedPlane //purpose : //================================================================================= -class OrientedPlane: public vtkPlane +OrientedPlane* OrientedPlane::New() { - SVTK_ViewWindow* myViewWindow; - - vtkDataSetMapper* myMapper; - -public: - static OrientedPlane * New() { - return new OrientedPlane(); - } - static OrientedPlane * New (SVTK_ViewWindow* vw) { - return new OrientedPlane(vw); - } - vtkTypeMacro(OrientedPlane, vtkPlane); - - - VISU::Orientation myOrientation; - vtkFloatingPointType myDistance; - double myAngle[2]; - - vtkPlaneSource* myPlaneSource; - SALOME_Actor *myActor; - - void SetOrientation(VISU::Orientation theOrientation) {myOrientation = theOrientation;} - VISU::Orientation GetOrientation() {return myOrientation;} - - void SetDistance(vtkFloatingPointType theDistance) - { - myDistance = theDistance; - } - vtkFloatingPointType GetDistance() - { - return myDistance; - } - - void ShallowCopy(OrientedPlane* theOrientedPlane){ - SetNormal(theOrientedPlane->GetNormal()); - SetOrigin(theOrientedPlane->GetOrigin()); - - myOrientation = theOrientedPlane->GetOrientation(); - myDistance = theOrientedPlane->GetDistance(); - - myAngle[0] = theOrientedPlane->myAngle[0]; - myAngle[1] = theOrientedPlane->myAngle[1]; - - myPlaneSource->SetNormal(theOrientedPlane->myPlaneSource->GetNormal()); - myPlaneSource->SetOrigin(theOrientedPlane->myPlaneSource->GetOrigin()); - myPlaneSource->SetPoint1(theOrientedPlane->myPlaneSource->GetPoint1()); - myPlaneSource->SetPoint2(theOrientedPlane->myPlaneSource->GetPoint2()); - } + return new OrientedPlane(); +} -protected: - OrientedPlane(SVTK_ViewWindow* vw): - myOrientation(VISU::XY), - myDistance(0.5), - myViewWindow(vw) - { - Init(); - myViewWindow->AddActor(myActor); - } +OrientedPlane* OrientedPlane::New (SVTK_ViewWindow* vw) +{ + return new OrientedPlane(vw); +} - OrientedPlane(): - myOrientation(VISU::XY), - myDistance(0.5), - myViewWindow(NULL) - { - Init(); - } +void OrientedPlane::SetOrientation(VISU::Orientation theOrientation) +{ + myOrientation = theOrientation; +} - void Init(){ - myPlaneSource = vtkPlaneSource::New(); +VISU::Orientation OrientedPlane::GetOrientation() +{ + return myOrientation; +} - myAngle[0] = myAngle[1] = 0.0; +void OrientedPlane::SetDistance(float theDistance) +{ + myDistance = theDistance; +} - // Create and display actor - myMapper = vtkDataSetMapper::New(); - myMapper->SetInput(myPlaneSource->GetOutput()); +float OrientedPlane::GetDistance() +{ + return myDistance; +} - myActor = SALOME_Actor::New(); - myActor->VisibilityOff(); - myActor->PickableOff(); - myActor->SetInfinitive(true); - myActor->SetMapper(myMapper); +void OrientedPlane::ShallowCopy(OrientedPlane* theOrientedPlane) +{ + SetNormal(theOrientedPlane->GetNormal()); + SetOrigin(theOrientedPlane->GetOrigin()); + + myOrientation = theOrientedPlane->GetOrientation(); + myDistance = theOrientedPlane->GetDistance(); + + myAngle[0] = theOrientedPlane->myAngle[0]; + myAngle[1] = theOrientedPlane->myAngle[1]; + + myPlaneSource->SetNormal(theOrientedPlane->myPlaneSource->GetNormal()); + myPlaneSource->SetOrigin(theOrientedPlane->myPlaneSource->GetOrigin()); + myPlaneSource->SetPoint1(theOrientedPlane->myPlaneSource->GetPoint1()); + myPlaneSource->SetPoint2(theOrientedPlane->myPlaneSource->GetPoint2()); +} - vtkProperty* aProp = vtkProperty::New(); - vtkFloatingPointType anRGB[3]; +OrientedPlane::OrientedPlane(SVTK_ViewWindow* vw): + myOrientation(VISU::XY), + myDistance(0.5), + myViewWindow(vw) +{ + Init(); + myViewWindow->AddActor(myActor); +} - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); +OrientedPlane::OrientedPlane(): + myOrientation(VISU::XY), + myDistance(0.5), + myViewWindow(NULL) +{ + Init(); +} - QColor aFillColor = aResourceMgr->colorValue("SMESH", "fill_color", QColor(0, 170, 255)); - anRGB[0] = aFillColor.red()/255.; - anRGB[1] = aFillColor.green()/255.; - anRGB[2] = aFillColor.blue()/255.; - aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - aProp->SetOpacity(0.75); - myActor->SetProperty(aProp); - aProp->Delete(); - - vtkProperty* aBackProp = vtkProperty::New(); - QColor aBackFaceColor = aResourceMgr->colorValue("SMESH", "backface_color", QColor(0, 0, 255));//@ - anRGB[0] = aBackFaceColor.red()/255.; - anRGB[1] = aBackFaceColor.green()/255.; - anRGB[2] = aBackFaceColor.blue()/255.; - aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - aBackProp->SetOpacity(0.75); - myActor->SetBackfaceProperty(aBackProp); - aBackProp->Delete(); - } +void OrientedPlane::Init() +{ + myPlaneSource = vtkPlaneSource::New(); + + myAngle[0] = myAngle[1] = 0.0; - ~OrientedPlane() - { - if (myViewWindow) - myViewWindow->RemoveActor(myActor); + // Create and display actor + myMapper = vtkDataSetMapper::New(); + myMapper->SetInput(myPlaneSource->GetOutput()); - myActor->Delete(); + myActor = SALOME_Actor::New(); + myActor->VisibilityOff(); + myActor->PickableOff(); + myActor->SetInfinitive(true); + myActor->SetMapper(myMapper); + + vtkProperty* aProp = vtkProperty::New(); + float anRGB[3]; + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + + QColor aFillColor = aResourceMgr->colorValue("SMESH", "fill_color", QColor(0, 170, 255)); + anRGB[0] = aFillColor.red()/255.; + anRGB[1] = aFillColor.green()/255.; + anRGB[2] = aFillColor.blue()/255.; + aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + aProp->SetOpacity(0.75); + myActor->SetProperty(aProp); + aProp->Delete(); + + vtkProperty* aBackProp = vtkProperty::New(); + QColor aBackFaceColor = aResourceMgr->colorValue("SMESH", "backface_color", QColor(0, 0, 255));//@ + anRGB[0] = aBackFaceColor.red()/255.; + anRGB[1] = aBackFaceColor.green()/255.; + anRGB[2] = aBackFaceColor.blue()/255.; + aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + aBackProp->SetOpacity(0.75); + myActor->SetBackfaceProperty(aBackProp); + aBackProp->Delete(); +} - myMapper->RemoveAllInputs(); - myMapper->Delete(); +OrientedPlane::~OrientedPlane() +{ + if (myViewWindow) + myViewWindow->RemoveActor(myActor); - myPlaneSource->UnRegisterAllOutputs(); - myPlaneSource->Delete(); - }; + myActor->Delete(); -private: - // Not implemented. - OrientedPlane(const OrientedPlane&); - void operator=(const OrientedPlane&); -}; + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myPlaneSource->UnRegisterAllOutputs(); + myPlaneSource->Delete(); +} struct TSetVisiblity { TSetVisiblity(int theIsVisible): myIsVisible(theIsVisible){} diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.h b/src/VISUGUI/VisuGUI_ClippingDlg.h index 7fe98099..1be49179 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.h +++ b/src/VISUGUI/VisuGUI_ClippingDlg.h @@ -45,12 +45,19 @@ class QHButtonGroup; class QSpinBox; class QTabWidget; +class SALOME_Actor; + class QtxDblSpinBox; +class SVTK_ViewWindow; + class LightApp_SelectionMgr; class VisuGUI; +class vtkPlaneSource; +class vtkDataSetMapper; + class OrientedPlane; namespace VISU { @@ -61,6 +68,47 @@ namespace VISU { enum Orientation {XY, YZ, ZX}; }; +//================================================================================= +//class : OrientedPlane +//purpose : +//================================================================================= +class OrientedPlane: public vtkPlane +{ + SVTK_ViewWindow* myViewWindow; + vtkDataSetMapper* myMapper; + +public: + static OrientedPlane* New(); + static OrientedPlane* New (SVTK_ViewWindow* vw); + + vtkTypeMacro(OrientedPlane, vtkPlane); + + VISU::Orientation myOrientation; + float myDistance; + double myAngle[2]; + + vtkPlaneSource* myPlaneSource; + SALOME_Actor* myActor; + + void SetOrientation(VISU::Orientation theOrientation); + VISU::Orientation GetOrientation(); + + void SetDistance(float theDistance); + float GetDistance(); + + void ShallowCopy(OrientedPlane* theOrientedPlane); + +protected: + OrientedPlane(); + OrientedPlane(SVTK_ViewWindow* vw); + ~OrientedPlane(); + + void Init(); + +private: + OrientedPlane(const OrientedPlane&); + void operator=(const OrientedPlane&); +}; //================================================================================= // class : VisuGUI_ClippingDlg diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index e8c0645f..2cdff7b2 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -59,6 +59,7 @@ #include "VISU_Event.h" #include "VisuGUI_Prs3dTools.h" +#include "VisuGUI_ClippingDlg.h" #include "VISU_GaussPoints_i.hh" #include "VISU_GaussPtsAct.h" @@ -1935,10 +1936,9 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint) VISU::Prs3d_i* prs = vActor->GetPrs3d(); if ( !prs ) continue; - if ( val == "Off" ) { - prs->RemoveAllClippingPlanes(); - } - else { + + prs->RemoveAllClippingPlanes(); + if ( val != "Off" ) { QStringList vals = QStringList::split( gDigitsSep, val ); if ( vals.count() == 6 ) { // format check: 6 float values vtkFloatingPointType normal[3], origin[3]; @@ -1946,10 +1946,11 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint) normal[x] = vals[x].toFloat(); origin[x] = vals[x+3].toFloat(); } - vtkPlane* plane = vtkPlane::New(); + OrientedPlane* plane = OrientedPlane::New(); plane->SetNormal( normal ); plane->SetOrigin( origin ); prs->AddClippingPlane( plane ); + plane->Delete(); } } } -- 2.39.2