1 // Copyright (C) 2009-2016 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, or (at your option) any later version.
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_
23 #include "HEXABLOCKGUI_Export.hxx"
30 #include <QModelIndex>
31 #include <QDockWidget>
33 #include "klinkitemselectionmodel.hxx"
35 #include <OB_Browser.h>
36 #include <SalomeApp_Module.h>
37 #include <SalomeApp_DataObject.h>
39 #include <LightApp_SelectionMgr.h>
40 #include <LightApp_DataModel.h>
42 #include <SALOMEconfig.h>
44 #include "HEXABLOCKGUI_Resource.hxx"
45 #include "HEXABLOCKGUI_OCCSelector.h"
46 #include "hexa_base.hxx"
50 // #include CORBA_CLIENT_HEADER(HEXABLOCK_Gen) // Abu Juin 2013
56 class VtkDocumentGraphicView;
58 class GraphicViewsHandler;
59 // class DocumentDelegate;
61 class PatternDataModel;
62 // class PatternBuilderModel;
63 class AssociationsModel;
66 class PatternDataSelectionModel;
67 // class PatternBuilderSelectionModel;
68 class GroupsSelectionModel;
69 class MeshSelectionModel;
80 class MakeCylinderDialog;
82 class MakeCylindersDialog;
83 class MakePipesDialog;
84 class RemoveHexaDialog;
85 class PrismQuadDialog;
88 class DisconnectDialog;
90 class MakeTransformationDialog;
91 class MakeSymmetryDialog;
92 class PerformTransformationDialog;
93 class PerformSymmetryDialog;
94 typedef class MyBasicGUI_PointDlg VertexAssocDialog;
95 class EdgeAssocDialog;
96 class QuadAssocDialog;
99 class PropagationDialog;
100 class ComputeMeshDialog;
101 class ReplaceHexaDialog;
102 class QuadRevolutionDialog;
103 class MakeHemiSphereDialog;
104 class ModelInfoDialog;
105 class AddShapeDialog;
109 class HEXABLOCKGUI_Resource;//SUIT_ResourceMgr;
110 class SalomeApp_Study;
111 class SalomeApp_Application;
112 class SUIT_ViewWindow;
113 class SVTK_ViewWindow;
114 class OCCViewer_ViewWindow;
115 class LightApp_VTKSelector;
118 class HEXABLOCK_EXPORT HEXABLOCKGUI : public SalomeApp_Module
122 friend class HEXABLOCKGUI_Resource;
126 virtual ~HEXABLOCKGUI();
135 static SalomeApp_Study* activeStudy();
137 // static HEXABLOCK_ORB::HEXABLOCK_Gen_ptr InitHEXABLOCKGen( SalomeApp_Application* );
138 static LightApp_SelectionMgr* selectionMgr();
139 static SALOMEDS::Study_var getStudyServant();
140 static ViewType getActiveViewType();
141 static HEXABLOCKGUI* getInstance();
143 //add an object in the study
144 void addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
145 QMap<QString, QString>& docShapesEntry,
146 QMap<QString, QString>& docShapesName);
148 static HEXABLOCK::GUI::VtkDocumentGraphicView* currentDocGView;
149 static HEXABLOCK::GUI::OccGraphicView* currentOccGView;
150 static bool assocInProgress;
151 static SalomeApp_Application* myApplication;
153 virtual void initialize( CAM_Application* app);
155 virtual bool renameAllowed( const QString& ) const;
156 virtual bool renameObject( const QString& entry, const QString& name);
157 virtual void windows( QMap<int, int>& theMap) const;
158 virtual QString engineIOR() const;
160 virtual void viewManagers(QStringList& list) const;
161 virtual void setResource(SUIT_ResourceMgr* r);
162 virtual void createPreferences();
163 virtual void preferencesChanged( const QString& sect, const QString& name );
165 ///Returns a new HEXA_NS::Document and it's entry in the study
166 std::pair <QString, HEXA_NS::Document*> newHexaDocument();
168 //------------------------------------
169 void createAndFillDockWidget();
170 void createActions();
176 void setAllMenusEnabled(bool enable);
177 void updateSelectors();
179 void switchModel(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview);
180 void switchOnGraphicView(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview);
181 void switchOffGraphicView(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview,
182 bool saveCurrentDlg = true);
183 void showDockWidgets(bool isVisible);
185 HEXABLOCK::GUI::VtkDocumentGraphicView* getCurrentVtkGraphicView() const { return currentDocGView; }
186 HEXABLOCK::GUI::VtkDocumentGraphicView* getOrCreateDocument(SalomeApp_DataObject* studyObject);
187 HEXABLOCK::GUI::VtkDocumentGraphicView* getDocGViewByEntry(const QString& entry) const
189 return ( (docs.contains(entry) ? docs[entry] : NULL ) );
191 HEXABLOCK::GUI::DocumentModel* getCurrentModel();
192 HEXABLOCK::GUI::HexaBaseDialog* getDlgBox(HEXABLOCK::GUI::VtkDocumentGraphicView* view);
193 QTreeView* getPatternDataTreeView() const { return _patternDataTreeView; }
194 QTreeView* getPatternGeomTreeView() const { return _patternGeomTreeView; }
196 void showVertexInfoDialog(HEXA_NS::Vertex* vertex);
197 void showEdgeInfoDialog(HEXA_NS::Edge* edge);
198 void showQuadInfoDialog(HEXA_NS::Quad* quad);
199 void showHexaInfoDialog(HEXA_NS::Hexa* hexa);
200 void showVectorInfoDialog(HEXA_NS::Vector* vector);
201 void showGroupInfoDialog(HEXA_NS::Group* group);
202 void showLawInfoDialog(HEXA_NS::Law* law);
203 void showPropagationInfoDialog(HEXA_NS::Propagation* propagation);
211 bool deactivateModule( SUIT_Study* theStudy);
212 bool activateModule( SUIT_Study* theStudy);
213 void onObjectBrowserClick(const QModelIndex& index);
215 void showDocumentMenus(bool show);
216 void showPatternMenus(bool show);
217 void showAssociationMenus(bool show);
218 void showGroupsMenus(bool show);
219 void showMeshMenus(bool show);
221 void enableDocumentMenus(bool enable);
222 void enablePatternMenus(bool enable);
223 void enableAssociationMenus(bool enable);
224 void enableGroupsMenus(bool enable);
225 void enableMeshMenus(bool enable);
228 void onWindowActivated( SUIT_ViewWindow* svw);
229 void onWindowClosed( SUIT_ViewWindow* svw);
231 virtual void onViewManagerAdded( SUIT_ViewManager* );
232 virtual void onViewManagerRemoved( SUIT_ViewManager* );
234 void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
236 void showOnlyActor();
239 bool createSComponent();
240 virtual bool eventFilter(QObject *obj, QEvent *event);
242 void _showDialogBox( HEXABLOCK::GUI::HexaBaseDialog* diag );
243 HEXABLOCK::GUI::HexaBaseDialog* currentDialog;
245 SOCC_Prs* lastOccPrs;
246 HEXABLOCK::GUI::VtkDocumentGraphicView* lastVtkDocGView;
248 HEXABLOCKGUI_Resource* _myresource;
249 // static HEXABLOCK_ORB::HEXABLOCK_Gen_var _hexaEngine; // Hexa6 TODo
252 void slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
254 void treeContextMenu(const QPoint& aPosition);
256 void test_association();
260 void loadDocument( const QString &path = QString() );
270 // void addCylinder();
275 void makeCylinders();
278 void makeHemiSphere(); // NEW HEXA3
284 void disconnectElts();
286 void makeTransformation();
288 void performTransformation();
289 void performSymmetry();
291 void replaceHexa(); // NEW HEXA3
292 void quadRevolution(); // NEW HEXA3
300 void removeGroup (); //CS_TODO
303 void setPropagation();
306 //show the current model's information (nb vertex, edge, ... and more)
307 void showModelInfo();
309 //associate a shape to a document
312 //Clears associations of a single element (VERTEX, EDGE, QUAD, ...)
313 void clearAssociations();
315 //Clears associations under a tree (VERTEX_TREE, EDGE_TREE, ...)
316 void clearAllAssociations();
318 void showAssociations();
322 QList<HEXABLOCKGUI_OCCSelector*> myOCCSelectors;
323 QList<LightApp_VTKSelector*> myVTKSelectors;
326 QStringList getQuickDirList();
329 SOCC_Prs* getOccPrs(HEXABLOCK::GUI::VtkDocumentGraphicView* docGView)
331 if (docGView == NULL)
333 if (!occPrs.contains(docGView))
334 occPrs[docGView] = new SOCC_Prs(0);
335 return occPrs[docGView];
338 // -------------------------------------------------------------------------------------------------
339 // MainWindow presentation
340 // -------------------------------------------------------------------------------------------------
341 QDockWidget *_dwPattern; // Hexablock model edition
342 QDockWidget *_dwAssociation; // Hexablock association edition
343 QDockWidget *_dwGroups; // Hexablock groups edition
344 QDockWidget *_dwMesh; // Hexablock meshing edtion
345 QDockWidget *_dwObjectBrowser; // Salome study
346 QDockWidget *_dwInputPanel; // user Input
349 // ** Elements creation and modification Dialogs **
351 // Dialog Box ( to keep persistent values )
352 HEXABLOCK::GUI::VertexDialog* _vertexDiag;
353 HEXABLOCK::GUI::EdgeDialog* _edgeDiag;
354 HEXABLOCK::GUI::QuadDialog* _quadDiag;
355 HEXABLOCK::GUI::HexaDialog* _hexaDiag;
356 HEXABLOCK::GUI::VectorDialog* _vectorDiag;
357 HEXABLOCK::GUI::CylinderDialog* _cylinderDiag;
358 HEXABLOCK::GUI::PipeDialog* _pipeDiag;
359 HEXABLOCK::GUI::MakeGridDialog* _makeGridDiag;
360 HEXABLOCK::GUI::MakeCylinderDialog* _makeCylinderDiag;
361 HEXABLOCK::GUI::MakePipeDialog* _makePipeDiag;
362 HEXABLOCK::GUI::MakeCylindersDialog* _makeCylindersDiag;
363 HEXABLOCK::GUI::MakePipesDialog* _makePipesDiag;
364 HEXABLOCK::GUI::RemoveHexaDialog* _removeHexaDiag;
365 HEXABLOCK::GUI::PrismQuadDialog* _prismQuadDiag;
366 HEXABLOCK::GUI::JoinQuadDialog* _joinQuadDiag;
367 HEXABLOCK::GUI::MergeDialog* _mergeDiag;
368 HEXABLOCK::GUI::DisconnectDialog* _disconnectDiag;
369 HEXABLOCK::GUI::CutEdgeDialog* _cutEdgeDiag;
370 HEXABLOCK::GUI::MakeTransformationDialog* _makeTransformationDiag;
371 HEXABLOCK::GUI::MakeSymmetryDialog* _makeSymmetryDiag;
372 HEXABLOCK::GUI::PerformTransformationDialog* _performTransformationDiag;
373 HEXABLOCK::GUI::PerformSymmetryDialog* _performSymmetryDiag;
374 HEXABLOCK::GUI::VertexAssocDialog* _vertexAssocDiag;
375 HEXABLOCK::GUI::EdgeAssocDialog* _edgeAssocDiag;
376 HEXABLOCK::GUI::QuadAssocDialog* _quadAssocDiag;
377 HEXABLOCK::GUI::GroupDialog* _groupDiag;
378 HEXABLOCK::GUI::LawDialog* _lawDiag;
379 HEXABLOCK::GUI::PropagationDialog* _propagationDiag;
380 HEXABLOCK::GUI::ComputeMeshDialog* _computeMeshDiag;
381 HEXABLOCK::GUI::ReplaceHexaDialog* _replaceHexaDiag;
382 HEXABLOCK::GUI::QuadRevolutionDialog* _quadRevolutionDiag;
383 HEXABLOCK::GUI::MakeHemiSphereDialog* _makeHemiSphereDiag;
384 HEXABLOCK::GUI::ModelInfoDialog* _modelInfoDiag;
385 HEXABLOCK::GUI::AddShapeDialog* _addShapeDiag;
387 // ** Elements information dialogs **
388 HEXABLOCK::GUI::VertexDialog* _vertexInfoDialog;
389 HEXABLOCK::GUI::EdgeDialog* _edgeInfoDialog;
390 HEXABLOCK::GUI::QuadDialog* _quadInfoDialog;
391 HEXABLOCK::GUI::HexaDialog* _hexaInfoDialog;
392 HEXABLOCK::GUI::VectorDialog* _vectorInfoDialog;
393 HEXABLOCK::GUI::GroupDialog* _groupInfoDialog;
394 HEXABLOCK::GUI::LawDialog* _lawInfoDialog;
395 HEXABLOCK::GUI::PropagationDialog* _propagationInfoDialog;
398 std::set<HEXABLOCK::GUI::HexaBaseDialog*> currentModelDialogs;
415 // QAction *_addCylinder;
416 // QAction *_addPipe;
417 QAction *_makeGrid; //Cartesian, Cylindrical, Spherical
418 QAction *_makeCylinder;
420 QAction *_makeCylinders;
423 QAction *_makeHemiSphere; // NEW HEXA3
426 // Pattern Data Edition
427 QAction *_removeHexa;
430 QAction *_merge;// QAction *_mergeVertices; // QAction *_mergeEdges;
431 QAction *_disconnect;
433 QAction *_makeTransformation; // QAction *_makeTranslation;
434 QAction *_makeSymmetry;
435 QAction *_performTransformation;
436 QAction *_performSymmetry;
438 QAction *_replaceHexa; // NEW HEXA3
439 QAction *_quadRevolution; // NEW HEXA3
441 // Pattern Data Association
442 QAction *_assocVertex;
448 QAction *_removeGroup ; //CS_TODO
455 QAction *_setPropagation;
458 QAction *_computeMesh;
459 QAction* _showModelInfoAct;
460 QAction* _addShapeAct;
463 QAction* _sep1; // tmonin
464 QAction* _sep2; // tmonin
465 QAction* _sep3; // tmonin
466 QAction* _sep4; // ...... tparti
468 // -------------------------------------------------------------------------------------------------
469 // Model/View implementation
470 // -------------------------------------------------------------------------------------------------
472 HEXABLOCK::GUI::AssociationsModel *_associationsModel; // sub-part of DocumentModel
474 // VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW
475 QTreeView* _patternDataTreeView; // document's pattern : 1 ( only one view )
476 // QTreeView* _patternBuilderTreeView; // document's pattern : 1 ( only one view )
477 QTreeView* _patternGeomTreeView; // the geometries' tree view
478 QTreeView* _associationTreeView; // document's association : 1 ( only one view )
479 QTreeView* _groupsTreeView; // document's groups
480 QTreeView* _meshTreeView; // document's mesh property: 1 ( only one view )
482 // DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE
483 // HEXABLOCK::GUI::DocumentDelegate *_treeViewDelegate; // specific editor for each item of the tree
485 HEXABLOCK::GUI::GraphicViewsHandler* graphicViewsHandler; //vtk views hanlder (create, close, ...)
487 // SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME
488 QMap<QString, HEXABLOCK::GUI::VtkDocumentGraphicView*> docs; // key = entry
489 QMap<HEXABLOCK::GUI::VtkDocumentGraphicView*, HEXABLOCK::GUI::HexaBaseDialog*> gViewDlgBox; // key = entry
490 QMap<HEXABLOCK::GUI::VtkDocumentGraphicView*, SOCC_Prs*> occPrs;
493 bool moduleActivatedOnce;
496 QDir* loadDocLastPath;
497 QDir* saveDocLastPath;
500 void test_make_cart_grid();
501 void test_make_elmts_transform();
503 QString addDocInStudy (HEXA_NS::Document* doc); // Hexa6
504 HEXA_NS::Hex* hexa_root; // Hexa6