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