1 // Copyright (C) 2009-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _HEXABLOCKGUI_HXX_
21 #define _HEXABLOCKGUI_HXX_
27 #include <QModelIndex>
28 #include <QDockWidget>
31 #include "klinkitemselectionmodel.hxx"
33 #include <OB_Browser.h>
34 #include <SalomeApp_Module.h>
35 // #include <LightApp_Module.h>
37 #include <LightApp_SelectionMgr.h>
38 #include <LightApp_DataModel.h>
40 #include <SALOMEconfig.h>
43 // #include "MyBasicGUI_PointDlg.hxx"
44 // #include "Resource.hxx"
45 #include "HEXABLOCKGUI_Resource.hxx"
47 #include "GEOMGUI_OCCSelector.h"
52 #include CORBA_CLIENT_HEADER(HEXABLOCK_Gen)
53 // #include CORBA_CLIENT_HEADER(GEOM_Gen)
54 // #include CORBA_CLIENT_HEADER(SMESH_Gen)
61 class DocumentGraphicView;
62 class DocumentDelegate;
64 class PatternDataModel;
65 class PatternBuilderModel;
66 class AssociationsModel;
69 class PatternDataSelectionModel;
70 class PatternBuilderSelectionModel;
71 class GroupsSelectionModel;
72 class MeshSelectionModel;
83 class MakeCylinderDialog;
85 class MakeCylindersDialog;
86 class MakePipesDialog;
87 class RemoveHexaDialog;
88 class PrismQuadDialog;
91 class DisconnectDialog;
93 class MakeTransformationDialog;
94 class MakeSymmetryDialog;
95 class PerformTransformationDialog;
96 class PerformSymmetryDialog;
97 typedef class MyBasicGUI_PointDlg VertexAssocDialog;
98 class EdgeAssocDialog;
99 class QuadAssocDialog;
102 class PropagationDialog;
103 class ComputeMeshDialog;
104 class ReplaceHexaDialog;
105 class QuadRevolutionDialog;
106 class MakeHemiSphereDialog;
110 class HEXABLOCKGUI_Resource;//SUIT_ResourceMgr;
111 class SalomeApp_Study;
112 class SalomeApp_Application;
113 class SUIT_ViewWindow;
114 class SVTK_ViewWindow;
115 class OCCViewer_ViewWindow;
116 class LightApp_VTKSelector;
118 // // SALOME KERNEL includes
119 // #include <SALOMEDS_Study.hxx>
120 // #include <SALOMEDSClient_StudyBuilder.hxx>
121 // #include <SALOMEDSClient_SComponent.hxx>
122 // #include <SALOMEDSClient_ClientFactory.hxx>
123 // #include <SALOMEDSClient_IParameters.hxx>
126 class HEXABLOCKGUI : public SalomeApp_Module
130 friend class HEXABLOCKGUI_Resource;
134 virtual ~HEXABLOCKGUI();
136 static SalomeApp_Study* activeStudy();
138 static HEXABLOCK_ORB::HEXABLOCK_Gen_ptr InitHEXABLOCKGen( SalomeApp_Application* );
139 // static SMESH::SMESH_Gen_ptr InitSMESHGen( SalomeApp_Application* app, const std::string& container = "FactoryServer" );
140 static GEOM::GEOM_Gen_ptr InitGEOMGen( SalomeApp_Application* app, const std::string& container = "FactoryServer" );
142 static LightApp_SelectionMgr* selectionMgr();
145 static SVTK_ViewWindow* currentVtkView;
146 static OCCViewer_ViewWindow* currentOccView;
148 //HEXABLOCK::GUI::DocumentModel*
150 virtual void initialize( CAM_Application* app);
152 virtual bool renameAllowed( const QString& ) const;
153 virtual bool renameObject( const QString& entry, const QString& name);
154 virtual void windows( QMap<int, int>& theMap) const;
155 // virtual LightApp_Displayer* displayer();
156 virtual QString engineIOR() const;
158 virtual void viewManagers(QStringList& list) const;
159 virtual void setResource(SUIT_ResourceMgr* r);
160 virtual void createPreferences();
161 virtual void preferencesChanged( const QString& sect, const QString& name );
162 virtual void studyActivated();
164 //------------------------------------
165 void createAndFillDockWidget();
166 void createActions();
173 // void showBaseMenus(bool show);
174 // void showEditionMenus(bool show);
175 // void showExecMenus(bool show);
176 // void showCommonMenus(bool show);
178 void switchModel(SUIT_ViewWindow *view);
179 void showDockWidgets(bool isVisible);
183 bool deactivateModule( SUIT_Study* theStudy);
184 bool activateModule( SUIT_Study* theStudy);
185 void onObjectBrowserClick(const QModelIndex& index);
187 void showDocumentMenus(bool show);
188 void showPatternMenus(bool show);
189 void showAssociationMenus(bool show);
190 void showGroupsMenus(bool show);
191 void showMeshMenus(bool show);
194 void onWindowActivated( SUIT_ViewWindow* svw);
195 void onWindowClosed( SUIT_ViewWindow* svw);
197 virtual void onViewManagerAdded( SUIT_ViewManager* );
198 virtual void onViewManagerRemoved( SUIT_ViewManager* );
199 // void onTryClose(bool &isClosed, QxScene_ViewWindow* window);
201 void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
204 // virtual CAM_DataModel* createDataModel();
205 bool createSComponent();
206 // virtual bool isSelectionCompatible();
208 void _showDialogBox( HEXABLOCK::GUI::HexaBaseDialog* diag );
211 // bool _selectFromTree;
212 HEXABLOCKGUI_Resource* _myresource;
213 // SUIT_ResourceMgr* _myresource;
214 static int _oldStudyId;
215 static HEXABLOCK_ORB::HEXABLOCK_Gen_var _hexaEngine;
216 // static SMESH::SMESH_Gen_var _smeshEngine;
217 static GEOM::GEOM_Gen_var _geomEngine;
220 void slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
222 void treeContextMenu(const QPoint& aPosition);
224 void test_association();
228 void loadDocument( const QString &path = QString() );
240 // void makeCartesian();
241 // void makeCylindrical();
245 void makeCylinders();
248 // void makeRind(); // NEW HEXA3
249 void makeHemiSphere(); // NEW HEXA3
254 // void mergeVertices();
255 // void mergeEdges();
257 void disconnectElts();
259 // void makeTranslation();
260 void makeTransformation();
262 void performTransformation();
263 void performSymmetry();
265 void replaceHexa(); // NEW HEXA3
266 void quadRevolution(); // NEW HEXA3
274 void removeGroup (); //CS_TODO
277 void setPropagation();
280 //Clears associations of a single element (VERTEX, EDGE, QUAD, ...)
281 void clearAssociations();
283 //Clears associations under a tree (VERTEX_TREE, EDGE_TREE, ...)
284 void clearAllAssociations();
286 void showAssociations();
290 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
291 QList<LightApp_VTKSelector*> myVTKSelectors;
294 QStringList getQuickDirList();
295 HEXABLOCK::GUI::DocumentGraphicView* newGraphicView();
298 // -------------------------------------------------------------------------------------------------
299 // MainWindow presentation
300 // -------------------------------------------------------------------------------------------------
301 QDockWidget *_dwPattern; // Hexablock model edition
302 QDockWidget *_dwAssociation; // Hexablock association edition
303 QDockWidget *_dwGroups; // Hexablock groups edition
304 QDockWidget *_dwMesh; // Hexablock meshing edtion
305 QDockWidget *_dwObjectBrowser; // Salome study
306 QDockWidget *_dwInputPanel; // user Input
308 // Dialog Box ( to keep persistent values )
309 HEXABLOCK::GUI::VertexDialog* _vertexDiag;
310 HEXABLOCK::GUI::EdgeDialog* _edgeDiag;
311 HEXABLOCK::GUI::QuadDialog* _quadDiag;
312 HEXABLOCK::GUI::HexaDialog* _hexaDiag;
313 HEXABLOCK::GUI::VectorDialog* _vectorDiag;
314 HEXABLOCK::GUI::CylinderDialog* _cylinderDiag;
315 HEXABLOCK::GUI::PipeDialog* _pipeDiag;
316 HEXABLOCK::GUI::MakeGridDialog* _makeGridDiag;
317 HEXABLOCK::GUI::MakeCylinderDialog* _makeCylinderDiag;
318 HEXABLOCK::GUI::MakePipeDialog* _makePipeDiag;
319 HEXABLOCK::GUI::MakeCylindersDialog* _makeCylindersDiag;
320 HEXABLOCK::GUI::MakePipesDialog* _makePipesDiag;
321 HEXABLOCK::GUI::RemoveHexaDialog* _removeHexaDiag;
322 HEXABLOCK::GUI::PrismQuadDialog* _prismQuadDiag;
323 HEXABLOCK::GUI::JoinQuadDialog* _joinQuadDiag;
324 HEXABLOCK::GUI::MergeDialog* _mergeDiag;
325 HEXABLOCK::GUI::DisconnectDialog* _disconnectDiag;
326 HEXABLOCK::GUI::CutEdgeDialog* _cutEdgeDiag;
327 HEXABLOCK::GUI::MakeTransformationDialog* _makeTransformationDiag;
328 HEXABLOCK::GUI::MakeSymmetryDialog* _makeSymmetryDiag;
329 HEXABLOCK::GUI::PerformTransformationDialog* _performTransformationDiag;
330 HEXABLOCK::GUI::PerformSymmetryDialog* _performSymmetryDiag;
331 HEXABLOCK::GUI::VertexAssocDialog* _vertexAssocDiag;
332 HEXABLOCK::GUI::EdgeAssocDialog* _edgeAssocDiag;
333 HEXABLOCK::GUI::QuadAssocDialog* _quadAssocDiag;
334 HEXABLOCK::GUI::GroupDialog* _groupDiag;
335 HEXABLOCK::GUI::LawDialog* _lawDiag;
336 HEXABLOCK::GUI::PropagationDialog* _propagationDiag;
337 HEXABLOCK::GUI::ComputeMeshDialog* _computeMeshDiag;
338 HEXABLOCK::GUI::ReplaceHexaDialog* _replaceHexaDiag;
339 HEXABLOCK::GUI::QuadRevolutionDialog* _quadRevolutionDiag;
340 HEXABLOCK::GUI::MakeHemiSphereDialog* _makeHemiSphereDiag;
359 QAction *_addCylinder;
361 QAction *_makeGrid; //Cartesian, Cylindrical, Spherical
362 QAction *_makeCylinder;
364 QAction *_makeCylinders;
367 // QAction *_makeRind; // NEW HEXA3
368 QAction *_makeHemiSphere; // NEW HEXA3
371 // Pattern Data Edition
372 QAction *_removeHexa;
375 QAction *_merge;// QAction *_mergeVertices; // QAction *_mergeEdges;
376 QAction *_disconnect;
378 QAction *_makeTransformation; // QAction *_makeTranslation;
379 QAction *_makeSymmetry;
380 QAction *_performTransformation;
381 QAction *_performSymmetry;
383 QAction *_replaceHexa; // NEW HEXA3
384 QAction *_quadRevolution; // NEW HEXA3
386 // Pattern Data Association
387 QAction *_assocVertex;
393 QAction *_removeGroup ; //CS_TODO
400 QAction *_setPropagation;
403 QAction *_computeMesh;
405 // -------------------------------------------------------------------------------------------------
406 // Model/View implementation
407 // -------------------------------------------------------------------------------------------------
409 // MODEL MODEL MODEL MODEL MODEL MODEL MODEL MODEL MODEL
410 HEXABLOCK::GUI::DocumentModel *_currentModel;// a model for each document : 1..n ( multiple document allowed )
411 HEXABLOCK::GUI::PatternDataModel *_patternDataModel; // sub-part of DocumentModel
412 HEXABLOCK::GUI::PatternBuilderModel *_patternBuilderModel; // sub-part of DocumentModel
413 HEXABLOCK::GUI::AssociationsModel *_associationsModel; // sub-part of DocumentModel
414 HEXABLOCK::GUI::GroupsModel *_groupsModel; // sub-part of DocumentModel
415 HEXABLOCK::GUI::MeshModel *_meshModel; // sub-part of DocumentModel
417 // VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW
418 QTreeView *_patternDataTreeView; // document's pattern : 1 ( only one view )
419 QTreeView *_patternBuilderTreeView; // document's pattern : 1 ( only one view )
420 QTreeView *_associationTreeView; // document's association : 1 ( only one view )
421 QTreeView *_groupsTreeView; // document's groups
422 QTreeView *_meshTreeView; // document's mesh property: 1 ( only one view )
423 HEXABLOCK::GUI::DocumentGraphicView *_currentGraphicView;// graphical view (SVTK view) of the document : 1..n ( multiple view )
425 // DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE
426 HEXABLOCK::GUI::DocumentDelegate *_treeViewDelegate; // specific editor for each item of the tree
428 // SELECTION_MODEL SELECTION_MODEL SELECTION_MODEL SELECTION_MODEL SELECTION_MODEL
429 HEXABLOCK::GUI::PatternDataSelectionModel *_patternDataSelectionModel; // 1..n selection
430 HEXABLOCK::GUI::PatternBuilderSelectionModel *_patternBuilderSelectionModel;// 1..n selection
431 HEXABLOCK::GUI::GroupsSelectionModel *_groupsSelectionModel;
432 HEXABLOCK::GUI::MeshSelectionModel *_meshSelectionModel;
434 // SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME
435 SUIT_ViewManager *_suitVM;
436 std::map<QString, SUIT_ViewWindow*> _salomeViewWindows; // key = entry
438 // SALOME/QT SALOME/QT SALOME/QT SALOME/QT SALOME/QT SALOME/QT
439 std::map<SUIT_ViewWindow*, HEXABLOCK::GUI::DocumentModel*> _documentModels;
440 std::map<SUIT_ViewWindow*, HEXABLOCK::GUI::DocumentGraphicView*> _documentView;
442 // static std::map<HEXABLOCK::GUI::DocumentModel*, SUIT_ViewWindow*> _salomeViews;
449 void test_make_cart_grid();
450 void test_make_elmts_transform();