Back to index

salome-smesh  6.5.0
StdMeshersGUI_CartesianParamCreator.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 // File   : StdMeshersGUI_CartesianParamCreator.h
00024 // Author : Open CASCADE S.A.S.
00025 //
00026 #ifndef STDMESHERSGUI_CartesianParamCreator_H
00027 #define STDMESHERSGUI_CartesianParamCreator_H
00028 
00029 // SMESH includes
00030 #include "SMESH_StdMeshersGUI.hxx"
00031 
00032 #include "StdMeshersGUI_StdHypothesisCreator.h"
00033 
00034 // IDL includes
00035 #include <SALOMEconfig.h>
00036 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00037 #include CORBA_SERVER_HEADER(SMESH_Hypothesis)
00038 
00039 #include <QFrame>
00040 #include <QItemDelegate>
00041 
00042 class SMESHGUI_SpinBox;
00043 class QLineEdit;
00044 class QButtonGroup;
00045 class QTreeWidgetItem;
00046 class QString;
00047 class QWidget;
00048 class QTreeWidget;
00049 class QListWidget;
00050 class QStyleOptionViewItem;
00051 class QModelIndex;
00052 class QAbstractItemModel;
00053 class QListWidgetItem;
00054 
00055 namespace StdMeshersGUI
00056 {
00057   void getFromItem(QTreeWidgetItem * item, double& t0, double& t1, QString& fun );
00058   QTreeWidgetItem* setToItem (double  t0, double  t1, const QString& fun, QTreeWidgetItem* item=0);
00059 
00060   double coordFromItem( QListWidgetItem * );
00061   QListWidgetItem* coordToItem( double coord, QListWidgetItem * item=0);
00062 
00066   class GridAxisTab : public QFrame
00067   {
00068     Q_OBJECT
00069   public:
00070     GridAxisTab( QWidget* parent, const int axisIndex );
00071     ~GridAxisTab() {}
00072 
00073     void setCoordinates( SMESH::double_array_var coords );
00074     void setSpacing( SMESH::string_array_var funs, SMESH::double_array_var points );
00075 
00076     bool checkParams(QString& msg, SMESH::SMESH_Hypothesis_var& hyp) const;
00077     bool isGridBySpacing() const;
00078     SMESH::double_array* getCoordinates();
00079     void getSpacing(SMESH::string_array_out funs, SMESH::double_array_out points) const;
00080 
00081   private slots:
00082     void onInsert();
00083     void onDelete();
00084     void onMode(int);
00085     void onStepChange();
00086     void updateButtons();
00087 
00088   private:
00089 
00090     int               myAxisIndex;
00091     QButtonGroup*     myModeGroup;
00092     QTreeWidget*      mySpacingTreeWdg;
00093     QListWidget*      myCoordList;
00094     QPushButton*      myInsertBtn;
00095     QPushButton*      myDeleteBtn;
00096     SMESHGUI_SpinBox* myStepSpin;
00097     QLabel*           myStepLabel;
00098     double            myStep;
00099   };
00100   /*
00101    * \brief : Custom item delegate
00102    */
00103   class LineDelegate : public QItemDelegate
00104   {
00105     Q_OBJECT
00106   public:
00107     LineDelegate( QWidget* parent );
00108     ~LineDelegate() {}
00109 
00110     QWidget* createEditor( QWidget*, const QStyleOptionViewItem&, const QModelIndex& ) const;
00111     void setEditorData ( QWidget * editor, const QModelIndex & index ) const;
00112     void setModelData( QWidget* editor, QAbstractItemModel* model, const QModelIndex& index ) const;
00113 
00114   private:
00115     QTreeWidget* mySpacingTreeWdg;
00116     QListWidget* myCoordList;
00117   };
00118 }
00119 
00120 class STDMESHERSGUI_EXPORT StdMeshersGUI_CartesianParamCreator : public StdMeshersGUI_StdHypothesisCreator
00121 {
00122   Q_OBJECT
00123 
00124 public:
00125   StdMeshersGUI_CartesianParamCreator( const QString& aHypType );
00126   virtual ~StdMeshersGUI_CartesianParamCreator();
00127 
00128   virtual bool    checkParams( QString& ) const;
00129   virtual QString helpPage() const;
00130 
00131 protected:
00132   virtual QFrame*  buildFrame();
00133   virtual void     retrieveParams() const;
00134   virtual QString  storeParams() const;
00135 
00136 private:
00137   QLineEdit*                  myName;
00138   SMESHGUI_SpinBox*           myThreshold;
00139   StdMeshersGUI::GridAxisTab* myAxisTabs[3];
00140 };
00141 
00142 #endif // STDMESHERSGUI_CartesianParamCreator_H