1 // Copyright (C) 2009-2013 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_
23 #include "HEXABLOCKGUI_Export.hxx"
30 #include <QModelIndex>
31 #include <QDockWidget>
34 #include "klinkitemselectionmodel.hxx"
36 #include <OB_Browser.h>
37 #include <SalomeApp_Module.h>
38 #include <SalomeApp_DataObject.h>
40 #include <LightApp_SelectionMgr.h>
41 #include <LightApp_DataModel.h>
43 #include <SALOMEconfig.h>
45 #include "HEXABLOCKGUI_Resource.hxx"
46 #include "HEXABLOCKGUI_OCCSelector.h"
47 #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();
134 static SalomeApp_Study* activeStudy();
136 // static HEXABLOCK_ORB::HEXABLOCK_Gen_ptr InitHEXABLOCKGen( SalomeApp_Application* );
137 static LightApp_SelectionMgr* selectionMgr();
138 static SALOMEDS::Study_var ClientStudyToStudy (_PTR(Study) theStudy);
139 static ViewType getActiveViewType();
140 static HEXABLOCKGUI* getInstance();
142 //add an object in the study
143 void addInStudy(QMap<QString, TopoDS_Shape>& topo_shapes,
144 QMap<QString, QString>& docShapesEntry,
145 QMap<QString, QString>& docShapesName);
147 static HEXABLOCK::GUI::VtkDocumentGraphicView* currentDocGView;
148 static HEXABLOCK::GUI::OccGraphicView* currentOccGView;
149 static bool assocInProgress;
150 static SalomeApp_Application* myApplication;
152 virtual void initialize( CAM_Application* app);
154 virtual bool renameAllowed( const QString& ) const;
155 virtual bool renameObject( const QString& entry, const QString& name);
156 virtual void windows( QMap<int, int>& theMap) const;
157 virtual QString engineIOR() const;
159 virtual void viewManagers(QStringList& list) const;
160 virtual void setResource(SUIT_ResourceMgr* r);
161 virtual void createPreferences();
162 virtual void preferencesChanged( const QString& sect, const QString& name );
163 virtual void studyActivated();
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 updateSelectors();
178 void switchModel(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview);
179 void switchOnGraphicView(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview);
180 void switchOffGraphicView(HEXABLOCK::GUI::VtkDocumentGraphicView* dgview,
181 bool saveCurrentDlg = true);
182 void showDockWidgets(bool isVisible);
184 HEXABLOCK::GUI::VtkDocumentGraphicView* getCurrentVtkGraphicView() const { return currentDocGView; }
185 HEXABLOCK::GUI::VtkDocumentGraphicView* getOrCreateDocument(SalomeApp_DataObject* studyObject);
186 HEXABLOCK::GUI::VtkDocumentGraphicView* getDocGViewByEntry(const QString& entry) const
188 return ( (docs.contains(entry) ? docs[entry] : NULL ) );
190 HEXABLOCK::GUI::DocumentModel* getCurrentModel();
191 HEXABLOCK::GUI::HexaBaseDialog* getDlgBox(HEXABLOCK::GUI::VtkDocumentGraphicView* view);
192 QTreeView* getPatternDataTreeView() const { return _patternDataTreeView; }
193 QTreeView* getPatternGeomTreeView() const { return _patternGeomTreeView; }
196 bool deactivateModule( SUIT_Study* theStudy);
197 bool activateModule( SUIT_Study* theStudy);
198 void onObjectBrowserClick(const QModelIndex& index);
200 void showDocumentMenus(bool show);
201 void showPatternMenus(bool show);
202 void showAssociationMenus(bool show);
203 void showGroupsMenus(bool show);
204 void showMeshMenus(bool show);
207 void onWindowActivated( SUIT_ViewWindow* svw);
208 void onWindowClosed( SUIT_ViewWindow* svw);
210 virtual void onViewManagerAdded( SUIT_ViewManager* );
211 virtual void onViewManagerRemoved( SUIT_ViewManager* );
213 void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
216 void showOnlyActor();
219 bool createSComponent();
220 virtual bool eventFilter(QObject *obj, QEvent *event);
222 void _showDialogBox( HEXABLOCK::GUI::HexaBaseDialog* diag );
223 HEXABLOCK::GUI::HexaBaseDialog* currentDialog;
225 SOCC_Prs* lastOccPrs;
226 HEXABLOCK::GUI::VtkDocumentGraphicView* lastVtkDocGView;
228 HEXABLOCKGUI_Resource* _myresource;
229 static int _oldStudyId;
230 // static HEXABLOCK_ORB::HEXABLOCK_Gen_var _hexaEngine; // Hexa6 TODo
233 void slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
235 void treeContextMenu(const QPoint& aPosition);
237 void test_association();
241 void loadDocument( const QString &path = QString() );
256 void makeCylinders();
259 void makeHemiSphere(); // NEW HEXA3
265 void disconnectElts();
267 void makeTransformation();
269 void performTransformation();
270 void performSymmetry();
272 void replaceHexa(); // NEW HEXA3
273 void quadRevolution(); // NEW HEXA3
281 void removeGroup (); //CS_TODO
284 void setPropagation();
287 //show the current model's information (nb vertex, edge, ... and more)
288 void showModelInfo();
290 //associate a shape to a document
293 //Clears associations of a single element (VERTEX, EDGE, QUAD, ...)
294 void clearAssociations();
296 //Clears associations under a tree (VERTEX_TREE, EDGE_TREE, ...)
297 void clearAllAssociations();
299 void showAssociations();
303 QList<HEXABLOCKGUI_OCCSelector*> myOCCSelectors;
304 QList<LightApp_VTKSelector*> myVTKSelectors;
307 QStringList getQuickDirList();
310 SOCC_Prs* getOccPrs(HEXABLOCK::GUI::VtkDocumentGraphicView* docGView)
312 if (docGView == NULL)
314 if (!occPrs.contains(docGView))
315 occPrs[docGView] = new SOCC_Prs();
316 return occPrs[docGView];
319 // -------------------------------------------------------------------------------------------------
320 // MainWindow presentation
321 // -------------------------------------------------------------------------------------------------
322 QDockWidget *_dwPattern; // Hexablock model edition
323 QDockWidget *_dwAssociation; // Hexablock association edition
324 QDockWidget *_dwGroups; // Hexablock groups edition
325 QDockWidget *_dwMesh; // Hexablock meshing edtion
326 QDockWidget *_dwObjectBrowser; // Salome study
327 QDockWidget *_dwInputPanel; // user Input
330 // Dialog Box ( to keep persistent values )
331 HEXABLOCK::GUI::VertexDialog* _vertexDiag;
332 HEXABLOCK::GUI::EdgeDialog* _edgeDiag;
333 HEXABLOCK::GUI::QuadDialog* _quadDiag;
334 HEXABLOCK::GUI::HexaDialog* _hexaDiag;
335 HEXABLOCK::GUI::VectorDialog* _vectorDiag;
336 HEXABLOCK::GUI::CylinderDialog* _cylinderDiag;
337 HEXABLOCK::GUI::PipeDialog* _pipeDiag;
338 HEXABLOCK::GUI::MakeGridDialog* _makeGridDiag;
339 HEXABLOCK::GUI::MakeCylinderDialog* _makeCylinderDiag;
340 HEXABLOCK::GUI::MakePipeDialog* _makePipeDiag;
341 HEXABLOCK::GUI::MakeCylindersDialog* _makeCylindersDiag;
342 HEXABLOCK::GUI::MakePipesDialog* _makePipesDiag;
343 HEXABLOCK::GUI::RemoveHexaDialog* _removeHexaDiag;
344 HEXABLOCK::GUI::PrismQuadDialog* _prismQuadDiag;
345 HEXABLOCK::GUI::JoinQuadDialog* _joinQuadDiag;
346 HEXABLOCK::GUI::MergeDialog* _mergeDiag;
347 HEXABLOCK::GUI::DisconnectDialog* _disconnectDiag;
348 HEXABLOCK::GUI::CutEdgeDialog* _cutEdgeDiag;
349 HEXABLOCK::GUI::MakeTransformationDialog* _makeTransformationDiag;
350 HEXABLOCK::GUI::MakeSymmetryDialog* _makeSymmetryDiag;
351 HEXABLOCK::GUI::PerformTransformationDialog* _performTransformationDiag;
352 HEXABLOCK::GUI::PerformSymmetryDialog* _performSymmetryDiag;
353 HEXABLOCK::GUI::VertexAssocDialog* _vertexAssocDiag;
354 HEXABLOCK::GUI::EdgeAssocDialog* _edgeAssocDiag;
355 HEXABLOCK::GUI::QuadAssocDialog* _quadAssocDiag;
356 HEXABLOCK::GUI::GroupDialog* _groupDiag;
357 HEXABLOCK::GUI::LawDialog* _lawDiag;
358 HEXABLOCK::GUI::PropagationDialog* _propagationDiag;
359 HEXABLOCK::GUI::ComputeMeshDialog* _computeMeshDiag;
360 HEXABLOCK::GUI::ReplaceHexaDialog* _replaceHexaDiag;
361 HEXABLOCK::GUI::QuadRevolutionDialog* _quadRevolutionDiag;
362 HEXABLOCK::GUI::MakeHemiSphereDialog* _makeHemiSphereDiag;
363 HEXABLOCK::GUI::ModelInfoDialog* _modelInfoDiag;
364 HEXABLOCK::GUI::AddShapeDialog* _addShapeDiag;
367 std::set<HEXABLOCK::GUI::HexaBaseDialog*> currentModelDialogs;
384 QAction *_addCylinder;
386 QAction *_makeGrid; //Cartesian, Cylindrical, Spherical
387 QAction *_makeCylinder;
389 QAction *_makeCylinders;
392 QAction *_makeHemiSphere; // NEW HEXA3
395 // Pattern Data Edition
396 QAction *_removeHexa;
399 QAction *_merge;// QAction *_mergeVertices; // QAction *_mergeEdges;
400 QAction *_disconnect;
402 QAction *_makeTransformation; // QAction *_makeTranslation;
403 QAction *_makeSymmetry;
404 QAction *_performTransformation;
405 QAction *_performSymmetry;
407 QAction *_replaceHexa; // NEW HEXA3
408 QAction *_quadRevolution; // NEW HEXA3
410 // Pattern Data Association
411 QAction *_assocVertex;
417 QAction *_removeGroup ; //CS_TODO
424 QAction *_setPropagation;
427 QAction *_computeMesh;
429 QAction* _showModelInfoAct;
431 QAction* _addShapeAct;
434 QAction* _sep1; // tmonin
435 QAction* _sep2; // tmonin
436 QAction* _sep3; // tmonin
437 QAction* _sep4; // ...... tparti
439 // -------------------------------------------------------------------------------------------------
440 // Model/View implementation
441 // -------------------------------------------------------------------------------------------------
443 HEXABLOCK::GUI::AssociationsModel *_associationsModel; // sub-part of DocumentModel
445 // VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW VIEW
446 QTreeView* _patternDataTreeView; // document's pattern : 1 ( only one view )
447 QTreeView* _patternBuilderTreeView; // document's pattern : 1 ( only one view )
448 QTreeView* _patternGeomTreeView; // the geometries' tree view
449 QTreeView* _associationTreeView; // document's association : 1 ( only one view )
450 QTreeView* _groupsTreeView; // document's groups
451 QTreeView* _meshTreeView; // document's mesh property: 1 ( only one view )
453 // DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE
454 HEXABLOCK::GUI::DocumentDelegate *_treeViewDelegate; // specific editor for each item of the tree
456 HEXABLOCK::GUI::GraphicViewsHandler* graphicViewsHandler; //vtk views hanlder (create, close, ...)
458 // SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME SALOME
459 QMap<QString, HEXABLOCK::GUI::VtkDocumentGraphicView*> docs; // key = entry
460 QMap<HEXABLOCK::GUI::VtkDocumentGraphicView*, HEXABLOCK::GUI::HexaBaseDialog*> gViewDlgBox; // key = entry
461 QMap<HEXABLOCK::GUI::VtkDocumentGraphicView*, SOCC_Prs*> occPrs;
464 bool moduleActivatedOnce;
466 QDir* loadDocLastPath;
467 QDir* saveDocLastPath;
470 void test_make_cart_grid();
471 void test_make_elmts_transform();
473 QString addDocInStudy (HEXA_NS::Document* doc); // Hexa6
474 HEXA_NS::Hex* hexa_root; // Hexa6