00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SMESHGUI_FILTERDLG_H
00028 #define SMESHGUI_FILTERDLG_H
00029
00030
00031 #include "SMESH_SMESHGUI.hxx"
00032
00033
00034 #include <QWidget>
00035 #include <QDialog>
00036 #include <QMap>
00037 #include <QList>
00038
00039
00040 #include <SALOME_DataMapOfIOMapOfInteger.hxx>
00041 #include <SVTK_Selection.h>
00042
00043
00044 #include <SALOMEconfig.h>
00045 #include CORBA_SERVER_HEADER(SMESH_Filter)
00046 #include CORBA_SERVER_HEADER(SMESH_Mesh)
00047
00048 class QFrame;
00049 class QButtonGroup;
00050 class QCheckBox;
00051 class QGroupBox;
00052 class QPushButton;
00053 class QTableWidget;
00054 class QTableWidgetItem;
00055 class QStackedWidget;
00056 class LightApp_SelectionMgr;
00057 class SMESHGUI;
00058 class SMESHGUI_FilterLibraryDlg;
00059 class SVTK_Selector;
00060
00069 class SMESHGUI_EXPORT SMESHGUI_FilterTable : public QWidget
00070 {
00071 Q_OBJECT
00072
00073 class Table;
00074 class ComboItem;
00075 class IntSpinItem;
00076 class DoubleSpinItem;
00077 class CheckItem;
00078 class AdditionalWidget;
00079 class ComboDelegate;
00080
00081 typedef QMap<int, Table*> TableMap;
00082
00083 public:
00084 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const int );
00085 SMESHGUI_FilterTable( SMESHGUI*, QWidget*, const QList<int>& );
00086 virtual ~SMESHGUI_FilterTable();
00087
00088 void Init( const QList<int>& );
00089
00090 QGroupBox* GetTableGrp();
00091
00092 bool IsValid( const bool = true, const int = -1 ) const;
00093 int GetType() const;
00094 void SetType(const int);
00095 void RestorePreviousEntityType();
00096 int NumRows( const int = -1 ) const;
00097 void Clear( const int = -1 );
00098 void SetEditable( const bool );
00099 void SetEnabled( const bool );
00100 void SetLibsEnabled( const bool );
00101 bool IsEditable() const;
00102
00103 int GetCriterionType( const int, const int = -1 ) const;
00104
00105 void GetCriterion( const int,
00106 SMESH::Filter::Criterion&,
00107 const int = -1 ) const;
00108
00109 void SetCriterion( const int,
00110 const SMESH::Filter::Criterion&,
00111 const int = -1 );
00112
00113 void AddCriterion( const SMESH::Filter::Criterion&,
00114 const int = -1 );
00115
00116 void Copy( const SMESHGUI_FilterTable* );
00117 void SetValidity( const bool );
00118
00119 bool CurrentCell( int&, int& ) const;
00120 void SetThreshold( const int,
00121 const QString&,
00122 const int = -1 );
00123
00124 bool GetThreshold( const int,
00125 QString&,
00126 const int = -1 );
00127
00128 void SetID( const int,
00129 const QString&,
00130 const int = -1 );
00131
00132 bool GetID( const int,
00133 QString&,
00134 const int = -1 );
00135
00136 void Update();
00137
00138 signals:
00139 void CopyFromClicked();
00140 void AddToClicked();
00141 void EntityTypeChanged( const int );
00142 void NeedValidation();
00143 void CriterionChanged( const int, const int );
00144 void CurrentChanged( int, int );
00145
00146 private slots:
00147 void onAddBtn();
00148 void onInsertBtn();
00149 void onRemoveBtn();
00150 void onClearBtn();
00151 void onCopyFromBtn();
00152 void onAddToBtn();
00153 void onCriterionChanged( int, int );
00154 void onEntityType( int );
00155 void onCurrentChanged( int, int );
00156
00157 private:
00158 void addRow( Table*, const int, const bool = true );
00159 QTableWidgetItem* getCriterionItem( const int ) const;
00160 QTableWidgetItem* getCompareItem() const;
00161 QTableWidgetItem* getUnaryItem() const;
00162 QTableWidgetItem* getBinaryItem() const;
00163 const QMap<int, QString>& getCriteria( const int ) const;
00164 const QMap<int, QString>& getCompare() const;
00165 Table* createTable( QWidget*, const int );
00166 QWidget* createAdditionalFrame( QWidget* );
00167 int getFirstSelectedRow() const;
00168 void onCriterionChanged( const int, const int, const int );
00169
00170 void updateBtnState();
00171 void removeAdditionalWidget( QTableWidget*, const int );
00172 void updateAdditionalWidget();
00173 const char* getPrecision( const int );
00174
00175 const QMap<int, QString>& getSupportedTypes() const;
00176
00177 private:
00178 SMESHGUI* mySMESHGUI;
00179
00180 QGroupBox* myTableGrp;
00181 QWidget* mySwitchTableGrp;
00182
00183 TableMap myTables;
00184 QPushButton* myAddBtn;
00185 QPushButton* myInsertBtn;
00186 QPushButton* myRemoveBtn;
00187 QPushButton* myClearBtn;
00188 QPushButton* myCopyFromBtn;
00189 QPushButton* myAddToBtn;
00190
00191 QGroupBox* myEntityTypeBox;
00192 QButtonGroup* myEntityTypeGrp;
00193 int myEntityType;
00194 int myIsValid;
00195 bool myIsLocked;
00196
00197 SMESHGUI_FilterLibraryDlg* myLibDlg;
00198
00199 QStackedWidget* myWgStack;
00200
00201 QMap<QTableWidgetItem*, AdditionalWidget*> myAddWidgets;
00202 };
00203
00204
00210 class SMESHGUI_FilterDlg : public QDialog
00211 {
00212 Q_OBJECT
00213
00214
00215 enum { Mesh, Selection, Dialog, None };
00216
00217
00218 enum { BTN_OK, BTN_Apply, BTN_Close, BTN_Help };
00219
00220 public:
00221 SMESHGUI_FilterDlg( SMESHGUI*, const QList<int>& );
00222 SMESHGUI_FilterDlg( SMESHGUI*, const int );
00223 virtual ~SMESHGUI_FilterDlg();
00224
00225 void Init( const QList<int>& );
00226 void Init( const int );
00227
00228 void SetSelection();
00229 void SetMesh (SMESH::SMESH_Mesh_var);
00230 void SetSourceWg( QWidget*, const bool initOnApply = true );
00231
00232 static SMESH::Filter::Criterion createCriterion();
00233
00234 signals:
00235
00236 void Accepted();
00237
00238 private slots:
00239
00240 void onOk();
00241 bool onApply();
00242 void onClose();
00243 void onHelp();
00244 void onDeactivate();
00245 void onSelectionDone();
00246 void onCriterionChanged( const int, const int );
00247 void onCurrentChanged( int, int );
00248
00249 private:
00250
00251 void construct( const QList<int>& );
00252
00253 void closeEvent( QCloseEvent* );
00254 void enterEvent( QEvent* );
00255 void keyPressEvent( QKeyEvent* );
00256
00257
00258 QWidget* createButtonFrame( QWidget* );
00259 QWidget* createMainFrame( QWidget* );
00260 QWidget* createSourceGroup( QWidget* );
00261 void updateMainButtons();
00262
00263
00264 bool isValid() const;
00265 bool createFilter( const int );
00266 void insertFilterInViewer();
00267 void selectInViewer( const int, const QList<int>& );
00268 void filterSource( const int, QList<int>& );
00269 void filterSelectionSource( const int, QList<int>& );
00270 void getIdsFromWg( const QWidget*, QList<int>& ) const;
00271 void setIdsToWg( QWidget*, const QList<int>& );
00272 Selection_Mode getSelMode( const int ) const;
00273 void updateSelection();
00274
00275 private:
00276
00277 QWidget* myMainFrame;
00278 QButtonGroup* mySourceGrp;
00279
00280 QCheckBox* mySetInViewer;
00281
00282 QMap<int, QPushButton*> myButtons;
00283
00284 SMESHGUI_FilterTable* myTable;
00285
00286
00287 QList<int> myTypes;
00288 SMESHGUI* mySMESHGUI;
00289 LightApp_SelectionMgr* mySelectionMgr;
00290 SVTK_Selector* mySelector;
00291 SMESH::SMESH_Mesh_var myMesh;
00292 bool myInitSourceWgOnApply;
00293 QWidget* mySourceWg;
00294
00295 SALOME_DataMapOfIOMapOfInteger myIObjects;
00296 bool myIsSelectionChanged;
00297 QMap< int, SMESH::Filter_var > myFilter;
00298 QMap< int, bool > myInsertState;
00299 QMap< int, int > myApplyToState;
00300
00301 QString myHelpFileName;
00302 };
00303
00304 #endif // SMESHGUI_FILTERDLG_H