]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCKGUI/HEXABLOCKGUI.hxx
Salome HOME
Livraison IHM Hexa7
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI.hxx
1 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef _HEXABLOCKGUI_HXX_
21 #define _HEXABLOCKGUI_HXX_
22
23 #include <iostream>
24 #include <map>
25 #include <set>
26
27 #include <QTreeView>
28 #include <QModelIndex>
29 #include <QDockWidget>
30
31
32 #include "klinkitemselectionmodel.hxx"
33
34 #include <OB_Browser.h>
35 #include <SalomeApp_Module.h>
36 #include <SalomeApp_DataObject.h>
37
38 #include <LightApp_SelectionMgr.h>
39 #include <LightApp_DataModel.h>
40 #include <SOCC_Prs.h>
41 #include <SALOMEconfig.h>
42
43 #include "HEXABLOCKGUI_Resource.hxx"
44 #include "HEXABLOCKGUI_OCCSelector.h"
45 #include "hexa_base.hxx"
46
47
48 // #include CORBA_CLIENT_HEADER(HEXABLOCK_Gen)  // Abu Juin 2013
49
50 namespace HEXABLOCK
51 {
52   namespace GUI
53   {
54     class VtkDocumentGraphicView;
55     class OccGraphicView;
56     class GraphicViewsHandler;
57 //    class DocumentDelegate;
58     class DocumentModel;
59     class PatternDataModel;
60 //    class PatternBuilderModel;
61     class AssociationsModel;
62     class GroupsModel;
63     class MeshModel;
64     class PatternDataSelectionModel;
65 //    class PatternBuilderSelectionModel;
66     class GroupsSelectionModel;
67     class MeshSelectionModel;
68
69     class HexaBaseDialog;
70     class VertexDialog;
71     class EdgeDialog;
72     class QuadDialog;
73     class HexaDialog;
74     class VectorDialog;
75     class CylinderDialog;
76     class PipeDialog;
77     class MakeGridDialog;
78     class MakeCylinderDialog;
79     class MakePipeDialog;
80     class MakeCylindersDialog;
81     class MakePipesDialog;
82     class RemoveHexaDialog;
83     class PrismQuadDialog;
84     class JoinQuadDialog;
85     class MergeDialog;
86     class DisconnectDialog;
87     class CutEdgeDialog;
88     class MakeTransformationDialog;
89     class MakeSymmetryDialog;
90     class PerformTransformationDialog;
91     class PerformSymmetryDialog;
92     typedef class MyBasicGUI_PointDlg VertexAssocDialog;
93     class EdgeAssocDialog;
94     class QuadAssocDialog;
95     class GroupDialog;
96     class LawDialog;
97     class PropagationDialog;
98     class ComputeMeshDialog;
99     class ReplaceHexaDialog;
100     class QuadRevolutionDialog;
101     class MakeHemiSphereDialog;
102     class ModelInfoDialog;
103     class AddShapeDialog;
104   }
105 }
106
107 class HEXABLOCKGUI_Resource;//SUIT_ResourceMgr;
108 class SalomeApp_Study;
109 class SalomeApp_Application;
110 class SUIT_ViewWindow;
111 class SVTK_ViewWindow;
112 class OCCViewer_ViewWindow;
113 class LightApp_VTKSelector;
114
115
116 class HexaExport HEXABLOCKGUI : public SalomeApp_Module
117 {
118   Q_OBJECT
119
120   friend class HEXABLOCKGUI_Resource;
121
122 public:
123   HEXABLOCKGUI();
124   virtual ~HEXABLOCKGUI();
125
126   enum ViewType {
127       VTK,
128       OCC,
129       UNKNOWN
130   };
131
132   static SalomeApp_Study*         activeStudy();
133
134   // static HEXABLOCK_ORB::HEXABLOCK_Gen_ptr InitHEXABLOCKGen( SalomeApp_Application* );
135   static LightApp_SelectionMgr*   selectionMgr();
136   static SALOMEDS::Study_var  ClientStudyToStudy (_PTR(Study) theStudy);
137   static ViewType getActiveViewType();
138   static HEXABLOCKGUI*  getInstance();
139
140   //add an object in the study
141   void addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
142                          QMap<QString, QString>& docShapesEntry,
143                          QMap<QString, QString>& docShapesName);
144
145   static HEXABLOCK::GUI::VtkDocumentGraphicView* currentDocGView;
146   static HEXABLOCK::GUI::OccGraphicView* currentOccGView;
147   static bool assocInProgress;
148   static SalomeApp_Application* myApplication;
149
150   virtual void initialize( CAM_Application* app);
151
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 QString  engineIOR() const;
156
157   virtual void viewManagers(QStringList& list) const;
158   virtual void setResource(SUIT_ResourceMgr* r);
159   virtual void createPreferences();
160   virtual void preferencesChanged( const QString& sect, const QString& name );
161   virtual void studyActivated();
162
163   ///Returns a new HEXA_NS::Document and it's entry in the study
164   std::pair <QString, HEXA_NS::Document*> newHexaDocument();
165
166   //------------------------------------
167   void createAndFillDockWidget();
168   void createActions();
169   void createMenus();
170   void createTools();
171
172   void initialMenus();
173   void showAllMenus();
174   void updateSelectors();
175
176   void switchModel(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview);
177   void switchOnGraphicView(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview);
178   void switchOffGraphicView(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview,
179                               bool saveCurrentDlg = true);
180   void showDockWidgets(bool isVisible);
181
182   HEXABLOCK::GUI::VtkDocumentGraphicView* getCurrentVtkGraphicView() const { return currentDocGView; }
183   HEXABLOCK::GUI::VtkDocumentGraphicView* getOrCreateDocument(SalomeApp_DataObject* studyObject);
184   HEXABLOCK::GUI::VtkDocumentGraphicView* getDocGViewByEntry(const QString& entry) const
185   {
186       return ( (docs.contains(entry) ? docs[entry] : NULL ) );
187   }
188   HEXABLOCK::GUI::DocumentModel* getCurrentModel();
189   HEXABLOCK::GUI::HexaBaseDialog* getDlgBox(HEXABLOCK::GUI::VtkDocumentGraphicView* view);
190   QTreeView* getPatternDataTreeView() const { return _patternDataTreeView; }
191   QTreeView* getPatternGeomTreeView() const { return _patternGeomTreeView; }
192
193   void showVertexInfoDialog(HEXA_NS::Vertex* vertex);
194   void showEdgeInfoDialog(HEXA_NS::Edge* edge);
195   void showQuadInfoDialog(HEXA_NS::Quad* quad);
196   void showHexaInfoDialog(HEXA_NS::Hexa* hexa);
197   void showVectorInfoDialog(HEXA_NS::Vector* vector);
198   void showGroupInfoDialog(HEXA_NS::Group* group);
199   void showLawInfoDialog(HEXA_NS::Law* law);
200   void showPropagationInfoDialog(HEXA_NS::Propagation* propagation);
201
202 public slots:
203   bool deactivateModule( SUIT_Study* theStudy);
204   bool activateModule( SUIT_Study* theStudy);
205   void onObjectBrowserClick(const QModelIndex& index);
206
207   void showDocumentMenus(bool show);
208   void showPatternMenus(bool show);
209   void showAssociationMenus(bool show);
210   void showGroupsMenus(bool show);
211   void showMeshMenus(bool show);
212
213 protected slots:
214   void onWindowActivated( SUIT_ViewWindow* svw);
215   void onWindowClosed( SUIT_ViewWindow* svw);
216
217   virtual void                        onViewManagerAdded( SUIT_ViewManager* );
218   virtual void                        onViewManagerRemoved( SUIT_ViewManager* );
219
220   void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
221   void showActor();
222   void hideActor();
223   void showOnlyActor();
224
225 protected:
226   bool createSComponent();
227   virtual bool eventFilter(QObject *obj, QEvent *event);
228
229   void _showDialogBox( HEXABLOCK::GUI::HexaBaseDialog* diag );
230   HEXABLOCK::GUI::HexaBaseDialog* currentDialog;
231
232   SOCC_Prs* lastOccPrs;
233   HEXABLOCK::GUI::VtkDocumentGraphicView* lastVtkDocGView;
234
235   HEXABLOCKGUI_Resource* _myresource;
236   static int _oldStudyId;
237   // static HEXABLOCK_ORB::HEXABLOCK_Gen_var _hexaEngine;  // Hexa6 TODo
238 private slots:
239
240   void slot_modelChanged(const QModelIndex &topLeft, const QModelIndex  &bottomRight);
241
242   void treeContextMenu(const QPoint& aPosition);
243
244   void test_association();
245   void test();
246
247   void newDocument();
248   void loadDocument( const QString &path = QString() );
249   void saveDocument();
250
251   // new
252   void addVertex();
253   void addEdge();
254   void addQuad();
255   void addHexa();
256
257   void addVector();
258 //  void addCylinder();
259 //  void addPipe();
260   void makeGrid();
261   void makeCylinder();
262   void makePipe();
263   void makeCylinders();
264   void makePipes();
265
266   void makeHemiSphere();  // NEW HEXA3
267
268   void removeHexa();
269   void prismQuad();
270   void joinQuad();
271   void merge();
272   void disconnectElts();
273   void cutEdge();
274   void makeTransformation();
275   void makeSymmetry();
276   void performTransformation();
277   void performSymmetry();
278
279   void replaceHexa();    // NEW HEXA3
280   void quadRevolution(); // NEW HEXA3
281
282
283   void assocVertex();
284   void assocEdge();
285   void assocQuad();
286
287   void addGroup();
288   void removeGroup (); //CS_TODO
289   void addLaw();
290   void removeLaw();
291   void setPropagation();
292   void computeMesh();
293
294   //show the current model's information (nb vertex, edge, ... and more)
295   void showModelInfo();
296
297   //associate a shape to a document
298   void addShape();
299
300   //Clears associations of a single element (VERTEX, EDGE, QUAD, ...)
301   void clearAssociations();
302
303   //Clears associations under a tree (VERTEX_TREE, EDGE_TREE, ...)
304   void clearAllAssociations();
305
306   void showAssociations();
307
308 private:
309
310   QList<HEXABLOCKGUI_OCCSelector*>  myOCCSelectors;
311   QList<LightApp_VTKSelector*> myVTKSelectors;
312
313
314   QStringList getQuickDirList();
315   void clearDialogs();
316
317   SOCC_Prs* getOccPrs(HEXABLOCK::GUI::VtkDocumentGraphicView* docGView)
318   {
319       if (docGView == NULL)
320           return NULL;
321       if (!occPrs.contains(docGView))
322           occPrs[docGView] = new SOCC_Prs();
323       return occPrs[docGView];
324   }
325
326   // -------------------------------------------------------------------------------------------------
327   //          MainWindow presentation
328   // -------------------------------------------------------------------------------------------------
329   QDockWidget *_dwPattern;       // Hexablock model edition
330   QDockWidget *_dwAssociation;   // Hexablock association edition
331   QDockWidget *_dwGroups;        // Hexablock groups edition
332   QDockWidget *_dwMesh;          // Hexablock meshing edtion
333   QDockWidget *_dwObjectBrowser; // Salome study
334   QDockWidget *_dwInputPanel;    // user Input
335
336
337   // ** Elements creation and modification Dialogs **
338
339   // Dialog Box ( to keep persistent values )
340   HEXABLOCK::GUI::VertexDialog*                 _vertexDiag;
341   HEXABLOCK::GUI::EdgeDialog*                   _edgeDiag;
342   HEXABLOCK::GUI::QuadDialog*                   _quadDiag;
343   HEXABLOCK::GUI::HexaDialog*                   _hexaDiag;
344   HEXABLOCK::GUI::VectorDialog*                 _vectorDiag;
345   HEXABLOCK::GUI::CylinderDialog*               _cylinderDiag;
346   HEXABLOCK::GUI::PipeDialog*                   _pipeDiag;
347   HEXABLOCK::GUI::MakeGridDialog*               _makeGridDiag;
348   HEXABLOCK::GUI::MakeCylinderDialog*           _makeCylinderDiag;
349   HEXABLOCK::GUI::MakePipeDialog*               _makePipeDiag;
350   HEXABLOCK::GUI::MakeCylindersDialog*          _makeCylindersDiag;
351   HEXABLOCK::GUI::MakePipesDialog*              _makePipesDiag;
352   HEXABLOCK::GUI::RemoveHexaDialog*             _removeHexaDiag;
353   HEXABLOCK::GUI::PrismQuadDialog*              _prismQuadDiag;
354   HEXABLOCK::GUI::JoinQuadDialog*               _joinQuadDiag;
355   HEXABLOCK::GUI::MergeDialog*                  _mergeDiag;
356   HEXABLOCK::GUI::DisconnectDialog*             _disconnectDiag;
357   HEXABLOCK::GUI::CutEdgeDialog*                _cutEdgeDiag;
358   HEXABLOCK::GUI::MakeTransformationDialog*     _makeTransformationDiag;
359   HEXABLOCK::GUI::MakeSymmetryDialog*           _makeSymmetryDiag;
360   HEXABLOCK::GUI::PerformTransformationDialog*  _performTransformationDiag;
361   HEXABLOCK::GUI::PerformSymmetryDialog*        _performSymmetryDiag;
362   HEXABLOCK::GUI::VertexAssocDialog*            _vertexAssocDiag;
363   HEXABLOCK::GUI::EdgeAssocDialog*              _edgeAssocDiag;
364   HEXABLOCK::GUI::QuadAssocDialog*              _quadAssocDiag;
365   HEXABLOCK::GUI::GroupDialog*                  _groupDiag;
366   HEXABLOCK::GUI::LawDialog*                    _lawDiag;
367   HEXABLOCK::GUI::PropagationDialog*            _propagationDiag;
368   HEXABLOCK::GUI::ComputeMeshDialog*            _computeMeshDiag;
369   HEXABLOCK::GUI::ReplaceHexaDialog*            _replaceHexaDiag;
370   HEXABLOCK::GUI::QuadRevolutionDialog*         _quadRevolutionDiag;
371   HEXABLOCK::GUI::MakeHemiSphereDialog*         _makeHemiSphereDiag;
372   HEXABLOCK::GUI::ModelInfoDialog*              _modelInfoDiag;
373   HEXABLOCK::GUI::AddShapeDialog*               _addShapeDiag;
374
375   // ** Elements information dialogs **
376   HEXABLOCK::GUI::VertexDialog*                 _vertexInfoDialog;
377   HEXABLOCK::GUI::EdgeDialog*                   _edgeInfoDialog;
378   HEXABLOCK::GUI::QuadDialog*                   _quadInfoDialog;
379   HEXABLOCK::GUI::HexaDialog*                   _hexaInfoDialog;
380   HEXABLOCK::GUI::VectorDialog*                 _vectorInfoDialog;
381   HEXABLOCK::GUI::GroupDialog*                  _groupInfoDialog;
382   HEXABLOCK::GUI::LawDialog*                    _lawInfoDialog;
383   HEXABLOCK::GUI::PropagationDialog*            _propagationInfoDialog;
384
385
386   std::set<HEXABLOCK::GUI::HexaBaseDialog*> currentModelDialogs;
387   // Actions
388   int _menuId;
389   // Object Browser
390   QAction *_newAct;
391   QAction *_importAct;
392   QAction *_saveAct;
393   QAction *_testAct;
394
395   // Pattern Data
396   QAction *_addVertex;
397   QAction *_addEdge;
398   QAction *_addQuad;
399   QAction *_addHexa;
400
401   // Pattern Builder
402   QAction *_addVector;
403 //  QAction *_addCylinder;
404 //  QAction *_addPipe;
405   QAction *_makeGrid; //Cartesian, Cylindrical, Spherical
406   QAction *_makeCylinder;
407   QAction *_makePipe;
408   QAction *_makeCylinders;
409   QAction *_makePipes;
410
411   QAction *_makeHemiSphere; // NEW HEXA3
412
413
414   // Pattern Data Edition
415   QAction *_removeHexa;
416   QAction *_prismQuad;
417   QAction *_joinQuad;
418   QAction *_merge;//   QAction *_mergeVertices; //   QAction *_mergeEdges;
419   QAction *_disconnect;
420   QAction *_cutEdge;
421   QAction *_makeTransformation; //   QAction *_makeTranslation;
422   QAction *_makeSymmetry;
423   QAction *_performTransformation;
424   QAction *_performSymmetry;
425
426   QAction *_replaceHexa;    // NEW HEXA3
427   QAction *_quadRevolution; // NEW HEXA3
428
429   // Pattern Data Association
430   QAction *_assocVertex;
431   QAction *_assocEdge;
432   QAction *_assocQuad;
433
434   // Group
435   QAction *_addGroup;
436   QAction *_removeGroup ; //CS_TODO
437
438   // Law
439   QAction *_addLaw;
440   QAction *_removeLaw;
441
442   // Propagation
443   QAction *_setPropagation;
444
445   // Meshing
446   QAction *_computeMesh;
447   QAction* _showModelInfoAct;
448   QAction* _addShapeAct;
449
450
451   QAction* _sep1; // tmonin
452   QAction* _sep2; // tmonin
453   QAction* _sep3; // tmonin
454   QAction* _sep4; // ...... tparti
455
456   // -------------------------------------------------------------------------------------------------
457   //          Model/View implementation
458   // -------------------------------------------------------------------------------------------------
459
460   HEXABLOCK::GUI::AssociationsModel   *_associationsModel;    // sub-part of DocumentModel
461
462   //      VIEW      VIEW      VIEW      VIEW      VIEW      VIEW      VIEW      VIEW      VIEW      VIEW
463   QTreeView* _patternDataTreeView;    //  document's pattern : 1 ( only one view )
464 //  QTreeView* _patternBuilderTreeView; //  document's pattern : 1 ( only one view )
465   QTreeView* _patternGeomTreeView; // the geometries' tree view
466   QTreeView* _associationTreeView;    //  document's association : 1 ( only one view )
467   QTreeView* _groupsTreeView; //  document's groups
468   QTreeView* _meshTreeView;   //  document's mesh property: 1 ( only one view )
469
470   //      DELEGATE      DELEGATE      DELEGATE      DELEGATE      DELEGATE      DELEGATE      DELEGATE
471 //  HEXABLOCK::GUI::DocumentDelegate    *_treeViewDelegate;  // specific editor for each item of the tree
472
473   HEXABLOCK::GUI::GraphicViewsHandler*  graphicViewsHandler; //vtk views hanlder (create, close, ...)
474
475   //  SALOME   SALOME    SALOME   SALOME     SALOME     SALOME     SALOME     SALOME     SALOME     SALOME
476   QMap<QString, HEXABLOCK::GUI::VtkDocumentGraphicView*>  docs; //  key = entry
477   QMap<HEXABLOCK::GUI::VtkDocumentGraphicView*, HEXABLOCK::GUI::HexaBaseDialog*>  gViewDlgBox; //  key = entry
478   QMap<HEXABLOCK::GUI::VtkDocumentGraphicView*, SOCC_Prs*> occPrs;
479
480   bool _isSaved;
481   bool moduleActivatedOnce;
482
483   QDir* loadDocLastPath;
484   QDir* saveDocLastPath;
485
486   void testDocument();
487   void test_make_cart_grid();
488   void test_make_elmts_transform();
489
490   QString       addDocInStudy (HEXA_NS::Document* doc);  // Hexa6
491   HEXA_NS::Hex* hexa_root;                               // Hexa6
492 };
493
494 #endif