Back to index

salome-geom  6.5.0
EntityGUI_SketcherDlg.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 // 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 DlgRef_4Spin;
00053 class GeometryGUI;
00054 
00055 #ifndef COORD_MIN
00056 #  define COORD_MIN -1e+15
00057 #  define COORD_MAX +1e+15
00058 #  define MAX_NUMBER 100000
00059 #  define DBL_DIGITS_DISPLAY 16
00060 #endif // COORD_MIN
00061 
00062 //=================================================================================
00063 // class    : EntityGUI_Dlg
00064 // purpose  :
00065 //=================================================================================
00066 class EntityGUI_SketcherDlg : public QDialog, GEOMBase_Helper
00067 { 
00068   Q_OBJECT
00069 
00070 public:
00071   EntityGUI_SketcherDlg( GeometryGUI*, QWidget* = 0, bool = false, Qt::WindowFlags = 0,
00072                          const double = -1 );
00073   ~EntityGUI_SketcherDlg();
00074 
00075   bool eventFilter (QObject* object, QEvent* event);
00076   
00077   bool                               acceptMouseEvent() const;  // called by EntityGUI::OnMousePress()
00078   void                               OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt&, bool isStart = true );             
00079 
00080 protected:
00081   void                               initSpinBox( SalomeApp_DoubleSpinBox*, 
00082                                                   double, double, double = 0.1, 
00083                                                   const char* quantity = "length_precision" );
00084 
00085   // redefined from GEOMBase_Helper
00086   virtual GEOM::GEOM_IOperations_ptr createOperation();
00087   virtual bool                       isValid( QString& );
00088   virtual bool                       execute( ObjectList& );
00089   virtual void                       addSubshapesToStudy();
00090   
00091   void                               closeEvent( QCloseEvent* );
00092   void                               keyPressEvent( QKeyEvent* );
00093 
00094 private:
00095   void                               Init();
00096   void                               enterEvent( QEvent* );
00097   void                               InitClick();
00098   void                               setEnabledUndo( bool );
00099   void                               setEnabledRedo( bool );
00100     
00101   QString                            GetNewCommand( QString& );
00102 
00103   virtual void                       displayPreview( GEOM::GEOM_Object_ptr,
00104                                                      const bool = false,
00105                                                      const bool = false,
00106                                                      const bool = true,
00107                                                      const double = -1,
00108                                                      const int  = -1,
00109                                                      const int  = -1);
00110   
00111   void                               displayPntPreview( const double = 0.0,
00112                                                         const double = 0.0,
00113                                                         bool /*append*/ = true,
00114                                                         bool /*update*/ = true
00115                                                       );
00116 
00117   bool                               createShapes( GEOM::GEOM_Object_ptr,
00118                                                    TopoDS_Shape&,
00119                                                    TopoDS_Shape& );
00120   int                                getPnt1ConstructorId() const;
00121   int                                getPnt2ConstructorId() const;
00122   void                               OnFirstPoint();
00123   void                               OnNextPoint(); 
00124 
00125 
00126 private:
00127   int                                myConstructorId;
00128   int                                myConstructorDirId;
00129   int                                myConstructorPntId;
00130   int                                mySketchType;
00131   int                                mySketchState;
00132 
00133   bool                               myIsAllAdded;
00134   bool                               myIsApply;
00135   bool                               autoApply;
00136 
00137   QLineEdit*                         myEditCurrentArgument;   /* Current LineEdit */
00138 
00139   QStringList                        myCommand;
00140   QStringList                        myUndoCommand;
00141 
00142   QStringList                        myParameters;
00143   QStringList                        myUndoParameters;
00144 
00145   Standard_Real                      myX, myY, myDX, myDY;
00146   Standard_Real                      myX1, myY1, myX2, myY2;
00147   Standard_Real                      myXc, myYc, myDXc, myDYc;
00148   Standard_Real                      myLength, myAngle, myRadius;
00149   Standard_Real                      myLastX1, myLastY1;
00150   Standard_Real                      myLastX2, myLastY2;
00151 
00152   QString                            myXStr, myYStr, myDXStr, myDYStr;
00153   QString                            myX1Str, myY1Str, myX2Str, myY2Str;
00154   QString                            myXcStr, myYcStr, myDXcStr, myDYcStr;
00155   QString                            myLengthStr, myAngleStr, myRadiusStr;
00156   QString                            myLastX1Str, myLastY1Str;
00157   QString                            myLastX2Str, myLastY2Str;                            
00158 
00159   EntityGUI_Skeleton*                MainWidget;
00160 
00161   EntityGUI_Point*                   GroupPt;
00162   EntityGUI_Point*                   GroupPt2;
00163   EntityGUI_Dir1*                    GroupD1;
00164   EntityGUI_Dir2*                    GroupD2;
00165 
00166   EntityGUI_1Sel*                    Group1Sel;
00167   EntityGUI_2Sel1Check*              Group2Sel;
00168   EntityGUI_1Sel1Spin1Check*         Group1Sel1Spin; 
00169   EntityGUI_1Spin*                   Group1Spin;
00170   EntityGUI_2Spin*                   Group2Spin;
00171   EntityGUI_3Spin1Check*             Group3Spin;
00172   EntityGUI_4Spin1Check*             Group4Spin;
00173   DlgRef_4Spin*                      GroupRect;
00174 
00175   QLabel*                            myErrLabel;
00176 
00177   QGroupBox*                         GroupBox1;
00178   QComboBox*                         ComboBox1;
00179   QPushButton*                       planeButton;
00180   QPushButton*                       selButton;
00181   
00182   QLineEdit*                         WPlaneLineEdit;
00183 
00184   GeometryGUI*                       myGeometryGUI;
00185 
00186   QString                            myHelpFileName;
00187   
00188   double                             myLineWidth;
00189 
00190   QList<gp_Ax3>                      myLCSList;
00191   GEOM::GEOM_Object_var              myGlobalCS;
00192   GEOM::GEOM_Object_var              myWPlane;
00193   QList< GEOM::GEOM_Object_var >     myWPlaneList;
00194 
00195   int                                myCheckFlag;
00196   
00197   TopAbs_ShapeEnum                   myNeedType;
00198 
00199 private:
00200   enum SketchState { FIRST_POINT, NEXT_POINT };
00201   
00202   enum SketchType { PT_ABS, PT_RELATIVE, PT_SEL,
00203                     PT_ABS_RADIUS,PT_REL_RADIUS,PT_SEL_RADIUS,
00204                     PT_ABS_CENTER,PT_REL_CENTER,PT_SEL_CENTER,
00205                     DIR_ANGLE_LENGTH, DIR_ANGLE_X, DIR_ANGLE_Y,
00206                     DIR_PER_LENGTH, DIR_PER_X, DIR_PER_Y,
00207                     DIR_TAN_LENGTH, DIR_TAN_X, DIR_TAN_Y,
00208                     DIR_DXDY_LENGTH, DIR_DXDY_X, DIR_DXDY_Y };
00209   
00210 private slots:
00211   void                               ClickOnEnd();
00212   void                               ClickOnCancel();
00213   bool                               ClickOnApply();
00214   void                               ClickOnUndo();
00215   void                               ClickOnRedo();
00216   void                               ClickOnHelp();
00217   void                               LineEditReturnPressed();
00218   void                               SelectionIntoArgument();
00219   void                               SetEditCurrentArgument();
00220   void                               DeactivateActiveDialog();
00221   void                               ActivateThisDialog();
00222   void                               TypeClicked( int );
00223   void                               RectClicked();
00224   void                               DestClicked( int );
00225   void                               PointClicked( int );
00226   void                               Point2Clicked( int );
00227   void                               Dir1Clicked( int );
00228   void                               Dir2Clicked( int );
00229   void                               CheckBoxClicked( int );
00230   void                               ValueChangedInSpinBox( double );
00231   void                               SetDoubleSpinBoxStep( double );
00232   void                               AddLocalCS( GEOM::GEOM_Object_var );
00233   void                               FindLocalCS();
00234   gp_Ax3                             GetActiveLocalCS();
00235   gp_Ax3                             WPlaneToLCS( GEOM::GEOM_Object_var );
00236   void                               ActivateLocalCS();
00237 };
00238 
00239 #endif // ENTITYGUI_SKETCHERDLG_H