Back to index

salome-smesh  6.5.0
SMESHGUI_ClippingDlg.h
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // SMESH SMESHGUI : GUI for SMESH component
00024 // File   : SMESHGUI_ClippingDlg.h
00025 // Author : Nicolas REJNERI, Open CASCADE S.A.S.
00026 //
00027 #ifndef SMESHGUI_CLIPPINGDLG_H
00028 #define SMESHGUI_CLIPPINGDLG_H
00029 
00030 // SMESH includes
00031 #include "SMESH_SMESHGUI.hxx"
00032 
00033 // SALOME includes
00034 #include <SVTK_ViewWindow.h>
00035 
00036 // Qt includes
00037 #include <QDialog>
00038 #include <QPointer>
00039 
00040 // VTK includes
00041 #include <vtkPlane.h>
00042 #include <vtkSmartPointer.h>
00043 
00044 // STL includes
00045 #include <list>
00046 #include <map>
00047 #include <vector>
00048 
00049 class QLabel;
00050 class QPushButton;
00051 class QCheckBox;
00052 class QComboBox;
00053 class QListWidget;
00054 class QListWidgetItem;
00055 class SALOME_Actor;
00056 class SMESHGUI;
00057 class SMESH_Actor;
00058 class SMESHGUI_SpinBox;
00059 class vtkActor;
00060 class vtkDataSetMapper;
00061 class vtkPlaneSource;
00062 
00063 namespace SMESH
00064 {
00065   enum Orientation { XY, YZ, ZX };
00066 
00067   class OrientedPlane: public vtkPlane
00068   {
00069     QPointer<SVTK_ViewWindow> myViewWindow;
00070     vtkDataSetMapper* myMapper;
00071 
00072   public:
00073     static OrientedPlane *New();
00074     static OrientedPlane *New(SVTK_ViewWindow* theViewWindow);
00075     vtkTypeMacro (OrientedPlane, vtkPlane);
00076 
00077     SMESH::Orientation myOrientation;
00078     float myDistance;
00079     double myAngle[2];
00080 
00081     vtkPlaneSource* myPlaneSource;
00082     SALOME_Actor *myActor;
00083 
00084     void SetOrientation (SMESH::Orientation theOrientation) { myOrientation = theOrientation; }
00085     SMESH::Orientation GetOrientation() { return myOrientation; }
00086 
00087     void SetDistance (float theDistance) { myDistance = theDistance; }
00088     float GetDistance() { return myDistance; }
00089 
00090     void ShallowCopy (OrientedPlane* theOrientedPlane);
00091 
00092   protected:
00093     OrientedPlane(SVTK_ViewWindow* theViewWindow);
00094     OrientedPlane();
00095 
00096     void Init();
00097 
00098     ~OrientedPlane();
00099   private:
00100     // Not implemented.
00101     OrientedPlane (const OrientedPlane&);
00102     void operator= (const OrientedPlane&);
00103   };
00104 
00105   typedef vtkSmartPointer<OrientedPlane>    TPlane;
00106   typedef std::list<vtkActor*>              TActorList;
00107 
00108   struct TPlaneData
00109   {
00110     TPlaneData( TPlane thePlane,
00111                 TActorList theActorList )
00112     {
00113       Plane = thePlane;
00114       ActorList = theActorList;
00115     }
00116     TPlane     Plane;
00117     TActorList ActorList;
00118   };
00119 
00120   typedef std::vector<TPlane>               TPlaneVector;
00121   typedef std::vector<TPlaneData>           TPlaneDataVector;
00122 };
00123 
00124 //=================================================================================
00125 // class    : SMESHGUI_ClippingDlg
00126 // purpose  :
00127 //=================================================================================
00128 class SMESHGUI_EXPORT SMESHGUI_ClippingDlg : public QDialog
00129 {
00130   Q_OBJECT
00131 
00132 public:
00133   SMESHGUI_ClippingDlg( SMESHGUI*, SVTK_ViewWindow* );
00134   ~SMESHGUI_ClippingDlg();
00135   
00136   double                  getDistance() const;
00137   void                    setDistance( const double );
00138   double                  getRotation1() const;
00139   double                  getRotation2() const;
00140   void                    setRotation( const double, const double );
00141 
00142   // used in SMESHGUI::restoreVisualParameters() to avoid
00143   // declaration of OrientedPlane outside of SMESHGUI_ClippingDlg.cxx
00144   static SMESH::OrientedPlane* AddPlane (SMESH::TActorList          theActorList,
00145                                          SVTK_ViewWindow*           theViewWindow,
00146                                          SMESH::Orientation         theOrientation,
00147                                          double                     theDistance,
00148                                          const vtkFloatingPointType theAngle[2]);
00149 
00150 protected:  
00151   void                    keyPressEvent( QKeyEvent* );
00152 
00153 private:
00154   void                    initializePlaneData();
00155 
00156   void                    synchronize();
00157 
00158   void                    updateActorList();
00159   SMESH::TActorList       getCurrentActors();
00160 
00161   void                    updateActorItem( QListWidgetItem* theItem,
00162                                            bool theUpdateSelectAll,
00163                                            bool theUpdateClippingPlaneMap );
00164 
00165   void                    dumpPlaneData() const;
00166 
00167 private:
00168   SMESHGUI*               mySMESHGUI;
00169   SVTK_ViewWindow*        myViewWindow;
00170   SMESH::TPlaneDataVector myPlanes;
00171   
00172   QComboBox*              ComboBoxPlanes;
00173   QPushButton*            buttonNew;
00174   QPushButton*            buttonDelete;
00175   QListWidget*            ActorList;
00176   QCheckBox*              SelectAllCheckBox;
00177   QLabel*                 TextLabelOrientation;
00178   QComboBox*              ComboBoxOrientation;
00179   QLabel*                 TextLabelDistance;
00180   SMESHGUI_SpinBox*       SpinBoxDistance;
00181   QLabel*                 TextLabelRot1;
00182   SMESHGUI_SpinBox*       SpinBoxRot1;
00183   QLabel*                 TextLabelRot2;
00184   SMESHGUI_SpinBox*       SpinBoxRot2;
00185   QCheckBox*              PreviewCheckBox;
00186   QCheckBox*              AutoApplyCheckBox;
00187   QPushButton*            buttonOk;
00188   QPushButton*            buttonCancel;
00189   QPushButton*            buttonApply;
00190   QPushButton*            buttonHelp;
00191   
00192   bool                    myIsSelectPlane;
00193   QString                 myHelpFileName;
00194 
00195 public slots:
00196   void                    onSelectPlane( int );
00197   void                    ClickOnNew();
00198   void                    ClickOnDelete();
00199   void                    onActorItemChanged( QListWidgetItem* );
00200   void                    onSelectAll( int );
00201   void                    onSelectOrientation( int );
00202   void                    SetCurrentPlaneParam();
00203   void                    OnPreviewToggle( bool );
00204   void                    ClickOnOk();
00205   void                    ClickOnCancel();
00206   void                    ClickOnApply();
00207   void                    ClickOnHelp();
00208 };
00209 
00210 #endif // SMESHGUI_CLIPPINGDLG_H