Version: 6.3.1

src/EntityGUI/EntityGUI_SketcherDlg.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : EntityGUI_SketcherDlg.h
00025 // Author : Damien COQUERET, Open CASCADE S.A.S.
00026 //
00027 #ifndef ENTITYGUI_SKETCHERDLG_H
00028 #define ENTITYGUI_SKETCHERDLG_H
00029 
00030 #include <GEOMBase_Helper.h>
00031 
00032 #include <QGroupBox>
00033 #include <QComboBox>
00034 #include <QDialog>
00035 #include <QLabel>
00036 
00037 #include <gp_Ax3.hxx>
00038 
00039 class QLineEdit;
00040 class SalomeApp_DoubleSpinBox;
00041 class EntityGUI_1Sel;
00042 class EntityGUI_2Sel1Check;
00043 class EntityGUI_1Sel1Spin1Check;
00044 class EntityGUI_1Spin;
00045 class EntityGUI_2Spin;
00046 class EntityGUI_3Spin1Check;
00047 class EntityGUI_4Spin1Check;
00048 class EntityGUI_Point;
00049 class EntityGUI_Dir1;
00050 class EntityGUI_Dir2;
00051 class EntityGUI_Skeleton;
00052 class GeometryGUI;
00053 
00054 #ifndef COORD_MIN
00055 #  define COORD_MIN -1e+15
00056 #  define COORD_MAX +1e+15
00057 #  define MAX_NUMBER 100000
00058 #  define DBL_DIGITS_DISPLAY 16
00059 #endif // COORD_MIN
00060 
00061 //=================================================================================
00062 // class    : EntityGUI_Dlg
00063 // purpose  :
00064 //=================================================================================
00065 class EntityGUI_SketcherDlg : public QDialog, GEOMBase_Helper
00066 { 
00067   Q_OBJECT
00068 
00069 public:
00070   EntityGUI_SketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0,
00071                          const double = 2. );
00072   ~EntityGUI_SketcherDlg();
00073 
00074   bool eventFilter (QObject* object, QEvent* event);
00075 
00076 protected:
00077   void                               initSpinBox( SalomeApp_DoubleSpinBox*, 
00078                                                   double, double, double = 0.1, 
00079                                                   const char* quantity = "length_precision" );
00080 
00081   // redefined from GEOMBase_Helper
00082   virtual GEOM::GEOM_IOperations_ptr createOperation();
00083   virtual bool                       isValid( QString& );
00084   virtual bool                       execute( ObjectList& );
00085 
00086   void                               closeEvent( QCloseEvent* );
00087   void                               keyPressEvent( QKeyEvent* );
00088 
00089 private:
00090   void                               Init();
00091   void                               enterEvent( QEvent* );
00092   void                               InitClick();
00093   void                               setEnabledUndo( bool );
00094   void                               setEnabledRedo( bool );
00095     
00096   QString                            GetNewCommand( QString& );
00097 
00098   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
00099                                                      const bool = false,
00100                                                      const bool = false,
00101                                                      const bool = true,
00102                                                      const double = -1,
00103                                                      const int  = -1,
00104                                                      const int  = -1);
00105 
00106   bool                               createShapes( GEOM::GEOM_Object_ptr,
00107                                                    TopoDS_Shape&,
00108                                                    TopoDS_Shape& );
00109 
00110 private:
00111   int                                myConstructorId;
00112   int                                myConstructorDirId;
00113   int                                myConstructorPntId;
00114   int                                mySketchType;
00115   int                                mySketchState;
00116 
00117   bool                               myIsAllAdded;
00118   bool                               myIsApply;
00119 
00120   QLineEdit*                         myEditCurrentArgument;   /* Current LineEdit */
00121 
00122   QStringList                        myCommand;
00123   QStringList                        myUndoCommand;
00124 
00125   QStringList                        myParameters;
00126   QStringList                        myUndoParameters;
00127 
00128   Standard_Real                      myX, myY, myDX, myDY;
00129   Standard_Real                    myXc, myYc, myDXc, myDYc;
00130   Standard_Real                      myLength, myAngle, myRadius;
00131   Standard_Real                      myLastX1, myLastY1;
00132   Standard_Real                      myLastX2, myLastY2;
00133 
00134   QString                            myXStr, myYStr, myDXStr, myDYStr;
00135   QString                myXcStr, myYcStr, myDXcStr, myDYcStr;
00136   QString                            myLengthStr, myAngleStr, myRadiusStr;
00137   QString                            myLastX1Str, myLastY1Str;
00138   QString                            myLastX2Str, myLastY2Str;                            
00139 
00140   EntityGUI_Skeleton*                MainWidget;
00141 
00142   EntityGUI_Point*                   GroupPt;
00143   EntityGUI_Point*                   GroupPt2;
00144   EntityGUI_Dir1*                    GroupD1;
00145   EntityGUI_Dir2*                    GroupD2;
00146 
00147   EntityGUI_1Sel*                    Group1Sel;
00148   EntityGUI_2Sel1Check*              Group2Sel;
00149   EntityGUI_1Sel1Spin1Check*         Group1Sel1Spin; 
00150   EntityGUI_1Spin*                   Group1Spin;
00151   EntityGUI_2Spin*                   Group2Spin;
00152   EntityGUI_3Spin1Check*             Group3Spin;
00153   EntityGUI_4Spin1Check*             Group4Spin;
00154 
00155   QLabel*                myErrLabel;
00156 
00157   QGroupBox*                         GroupBox1;
00158   QComboBox*                         ComboBox1;
00159   QPushButton*                       planeButton;
00160 
00161   GeometryGUI*                       myGeometryGUI;
00162 
00163   QString                            myHelpFileName;
00164   
00165   double                             myLineWidth;
00166 
00167   QList<gp_Ax3>                      myLCSList;
00168 
00169   int                         myCheckFlag;
00170 
00171 private:
00172   enum SketchState { FIRST_POINT, NEXT_POINT };
00173   
00174   enum SketchType { PT_ABS, PT_RELATIVE, PT_SEL,
00175                     PT_ABS_RADIUS,PT_REL_RADIUS,PT_SEL_RADIUS,
00176                     PT_ABS_CENTER,PT_REL_CENTER,PT_SEL_CENTER,
00177                     DIR_ANGLE_LENGTH, DIR_ANGLE_X, DIR_ANGLE_Y,
00178                     DIR_PER_LENGTH, DIR_PER_X, DIR_PER_Y,
00179                     DIR_TAN_LENGTH, DIR_TAN_X, DIR_TAN_Y,
00180                     DIR_DXDY_LENGTH, DIR_DXDY_X, DIR_DXDY_Y };
00181   
00182 private slots:
00183   void                               ClickOnEnd();
00184   void                               ClickOnCancel();
00185   bool                               ClickOnApply();
00186   void                               ClickOnUndo();
00187   void                               ClickOnRedo();
00188   void                               ClickOnHelp();
00189   void                               LineEditReturnPressed();
00190   void                               SelectionIntoArgument();
00191   void                               SetEditCurrentArgument();
00192   void                               DeactivateActiveDialog();
00193   void                               ActivateThisDialog();
00194   void                               TypeClicked( int );
00195   void                               DestClicked( int );
00196   void                               PointClicked( int );
00197   void                               Point2Clicked( int );
00198   void                               Dir1Clicked( int );
00199   void                               Dir2Clicked( int );
00200   void                               CheckBoxClicked( int );
00201   void                               ValueChangedInSpinBox( double );
00202   void                               SetDoubleSpinBoxStep( double );
00203   void                               FindLocalCS();
00204   gp_Ax3                             GetActiveLocalCS();
00205   void                               ActivateLocalCS();
00206 };
00207 
00208 #endif // ENTITYGUI_SKETCHERDLG_H
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS