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_
28 #include <QModelIndex>
29 #include <QDockWidget>
32 #include "klinkitemselectionmodel.hxx"
34 #include <OB_Browser.h>
35 #include <SalomeApp_Module.h>
36 #include <SalomeApp_DataObject.h>
37 // #include <LightApp_Module.h>
39 #include <LightApp_SelectionMgr.h>
40 #include <LightApp_DataModel.h>
42 #include <SALOMEconfig.h>
45 // #include "MyBasicGUI_PointDlg.hxx"
46 // #include "Resource.hxx"
47 #include "HEXABLOCKGUI_Resource.hxx"
49 #include "GEOMGUI_OCCSelector.h"
51 #include "hexa_base.hxx"
56 #include CORBA_CLIENT_HEADER(HEXABLOCK_Gen)
57 // #include CORBA_CLIENT_HEADER(GEOM_Gen)
58 // #include CORBA_CLIENT_HEADER(SMESH_Gen)
65 class VtkDocumentGraphicView;
67 class GraphicViewsHandler;
68 class DocumentDelegate;
70 class PatternDataModel;
71 class PatternBuilderModel;
72 class AssociationsModel;
75 class PatternDataSelectionModel;
76 class PatternBuilderSelectionModel;
77 class GroupsSelectionModel;
78 class MeshSelectionModel;
89 class MakeCylinderDialog;
91 class MakeCylindersDialog;
92 class MakePipesDialog;
93 class RemoveHexaDialog;
94 class PrismQuadDialog;
97 class DisconnectDialog;
99 class MakeTransformationDialog;
100 class MakeSymmetryDialog;
101 class PerformTransformationDialog;
102 class PerformSymmetryDialog;
103 typedef class MyBasicGUI_PointDlg VertexAssocDialog;
104 class EdgeAssocDialog;
105 class QuadAssocDialog;
108 class PropagationDialog;
109 class ComputeMeshDialog;
110 class ReplaceHexaDialog;
111 class QuadRevolutionDialog;
112 class MakeHemiSphereDialog;
113 class ModelInfoDialog;
114 class AddShapeDialog;
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;
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>
135 class HEXABLOCKGUI : public SalomeApp_Module
139 friend class HEXABLOCKGUI_Resource;
143 virtual ~HEXABLOCKGUI();
151 static SalomeApp_Study* activeStudy();
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" );
157 static LightApp_SelectionMgr* selectionMgr();
159 //add an object in the study
160 static QString addInStudy(QString& fileName);
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;
171 //HEXABLOCK::GUI::DocumentModel*
173 virtual void initialize( CAM_Application* app);
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;
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();
187 ///Returns a new HEXA_NS::Document and it's entry in the study
188 std::pair <QString, HEXA_NS::Document*> newHexaDocument();
190 //------------------------------------
191 void createAndFillDockWidget();
192 void createActions();
198 void updateSelectors();
200 // void showBaseMenus(bool show);
201 // void showEditionMenus(bool show);
202 // void showExecMenus(bool show);
203 // void showCommonMenus(bool show);
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);
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();
218 bool deactivateModule( SUIT_Study* theStudy);
219 bool activateModule( SUIT_Study* theStudy);
220 void onObjectBrowserClick(const QModelIndex& index);
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);
229 void onWindowActivated( SUIT_ViewWindow* svw);
230 void onWindowClosed( SUIT_ViewWindow* svw);
231 // void OnMouseMove( SUIT_ViewWindow*, QMouseEvent* );
233 virtual void onViewManagerAdded( SUIT_ViewManager* );
234 virtual void onViewManagerRemoved( SUIT_ViewManager* );
235 // void onTryClose(bool &isClosed, QxScene_ViewWindow* window);
237 void onSelectionChanged( const QItemSelection & selected, const QItemSelection & deselected );
240 void showOnlyActor();
243 // virtual CAM_DataModel* createDataModel();
244 bool createSComponent();
245 // virtual bool isSelectionCompatible();
246 virtual bool eventFilter(QObject *obj, QEvent *event);
248 void _showDialogBox( HEXABLOCK::GUI::HexaBaseDialog* diag );
249 HEXABLOCK::GUI::HexaBaseDialog* currentDialog;
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;
260 void slot_modelChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
262 void treeContextMenu(const QPoint& aPosition);
264 void test_association();
268 void loadDocument( const QString &path = QString() );
280 // void makeCartesian();
281 // void makeCylindrical();
285 void makeCylinders();
288 // void makeRind(); // NEW HEXA3
289 void makeHemiSphere(); // NEW HEXA3
294 // void mergeVertices();
295 // void mergeEdges();
297 void disconnectElts();
299 // void makeTranslation();
300 void makeTransformation();
302 void performTransformation();
303 void performSymmetry();
305 void replaceHexa(); // NEW HEXA3
306 void quadRevolution(); // NEW HEXA3
314 void removeGroup (); //CS_TODO
317 void setPropagation();
320 //show the current model's information (nb vertex, edge, ... and more)
321 void showModelInfo();
323 //associate a shape to a document
326 //Clears associations of a single element (VERTEX, EDGE, QUAD, ...)
327 void clearAssociations();
329 //Clears associations under a tree (VERTEX_TREE, EDGE_TREE, ...)
330 void clearAllAssociations();
332 void showAssociations();
336 QList<GEOMGUI_OCCSelector*> myOCCSelectors;
337 QList<LightApp_VTKSelector*> myVTKSelectors;
340 QStringList getQuickDirList();
341 // HEXABLOCK::GUI::DocumentGraphicView* newGraphicView();
342 void restoreGraphicViews();
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
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;
394 std::set<HEXABLOCK::GUI::HexaBaseDialog*> currentModelDialogs;
411 QAction *_addCylinder;
413 QAction *_makeGrid; //Cartesian, Cylindrical, Spherical
414 QAction *_makeCylinder;
416 QAction *_makeCylinders;
419 // QAction *_makeRind; // NEW HEXA3
420 QAction *_makeHemiSphere; // NEW HEXA3
423 // Pattern Data Edition
424 QAction *_removeHexa;
427 QAction *_merge;// QAction *_mergeVertices; // QAction *_mergeEdges;
428 QAction *_disconnect;
430 QAction *_makeTransformation; // QAction *_makeTranslation;
431 QAction *_makeSymmetry;
432 QAction *_performTransformation;
433 QAction *_performSymmetry;
435 QAction *_replaceHexa; // NEW HEXA3
436 QAction *_quadRevolution; // NEW HEXA3
438 // Pattern Data Association
439 QAction *_assocVertex;
445 QAction *_removeGroup ; //CS_TODO
452 QAction *_setPropagation;
455 QAction *_computeMesh;
457 QAction* _showModelInfoAct;
459 QAction* _addShapeAct;
461 // QAction *_showAct;
462 // QAction *_showOnlyAct;
463 // QAction *_hideAct;
465 // -------------------------------------------------------------------------------------------------
466 // Model/View implementation
467 // -------------------------------------------------------------------------------------------------
469 HEXABLOCK::GUI::AssociationsModel *_associationsModel; // sub-part of DocumentModel
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 )
480 // DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE DELEGATE
481 HEXABLOCK::GUI::DocumentDelegate *_treeViewDelegate; // specific editor for each item of the tree
483 HEXABLOCK::GUI::GraphicViewsHandler* graphicViewsHandler; //vtk views hanlder (create, close, ...)
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
491 bool moduleActivatedOnce;
493 QDir* loadDocLastPath;
494 QDir* saveDocLastPath;
498 void test_make_cart_grid();
499 void test_make_elmts_transform();