]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Clipping plane create in GUI state restoring is OrientedPlane class instead of vtkPlane.
authorasv <asv@opencascade.com>
Fri, 7 Apr 2006 13:51:40 +0000 (13:51 +0000)
committerasv <asv@opencascade.com>
Fri, 7 Apr 2006 13:51:40 +0000 (13:51 +0000)
src/VISUGUI/VisuGUI_ClippingDlg.cxx
src/VISUGUI/VisuGUI_ClippingDlg.h
src/VISUGUI/VisuGUI_Module.cxx

index 656fb80ff74d43c7db9f6c44bbb773ed3f68feee..bb1359ce7552c6ded6898fc1322acc4349ad1551 100644 (file)
@@ -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){}
index 7fe980993a119ced3d97a10082dfbc721e0cfa52..1be49179890c001de011d5358552d6b87a8b74f7 100644 (file)
@@ -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
index e8c0645f525ba65b1b84da1b29d164c765b331af..2cdff7b2a770fb9914c793cdd475906313e6717c 100644 (file)
@@ -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();
              }
            }
          }