Salome HOME
Add presentation in datasource tree
[modules/med.git] / src / MEDCalc / gui / DatasourceController.hxx
1 // Copyright (C) 2007-2015  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, or (at your option) any later version.
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 // Author : Guillaume Boulant (EDF)
21
22 #ifndef DATASOURCE_CONTROLLER_H
23 #define DATASOURCE_CONTROLLER_H
24
25 #include "MEDEventListener_i.hxx"
26 #include <SALOMEconfig.h>
27 #include CORBA_CLIENT_HEADER(MEDDataManager)
28 #include <StandardApp_Module.hxx>
29 #include <SALOME_AppStudyEditor.hxx>
30 #include <MEDPresentation.hxx>
31
32 #include <map>
33
34 #include "XmedDataModel.hxx"
35 #include "DlgChangeUnderlyingMesh.hxx"
36 #include "DlgInterpolateField.hxx"
37 #include "MEDCALCGUI.hxx"
38 //
39 // The DatasourceController defines data structures and classes to
40 // manage the usage of objects in the data space. The data space is
41 // technically the study, whose graphical representation is the
42 // objects browser.
43 //
44
45 // A datasource event is used by the DatasourceController to notify a
46 // job to the Workspace controller (Qt signal/slot pattern connected
47 // by the main controller MEDModule). The setting of attributes and
48 // usage of these attributes in the WorkspaceController depends on the
49 // event type. For example, in the case of a IMPORT event, we just
50 // have to transmit the object, while in the USE event we have to
51 // transmit an object AND an alias.
52 typedef struct {
53   enum EventType {
54     //
55     EVENT_IMPORT_OBJECT, // Simply import the object in the workspace
56     EVENT_USE_OBJECT,    // Import in the workspace AND define a proxy
57                          // variable in the tui console to use it
58     EVENT_VIEW_OBJECT_SCALAR_MAP,
59     // these ones forward actions to workspace (and then to python console)
60     EVENT_ADD_DATASOURCE,
61     EVENT_ADD_IMAGE_AS_DATASOURCE,
62     EVENT_ADD_PRESENTATION
63   };
64   int eventtype;
65   XmedDataObject * objectdata;
66   QString objectalias;
67 } DatasourceEvent;
68
69 //
70 // ==============================================================
71 // Datasource controller
72 // ==============================================================
73 //
74 class MEDCALCGUI_EXPORT DatasourceController: public QObject {
75   Q_OBJECT
76
77 public:
78   DatasourceController(StandardApp_Module * salomeModule);
79   ~DatasourceController();
80
81   void createActions();
82
83 public slots:
84   // Callback connected to dialog box validation signals
85   void OnChangeUnderlyingMeshInputValidated();
86   void OnInterpolateFieldInputValidated();
87   void processWorkspaceEvent(const MEDCALC::MedEvent * event);
88
89 signals:
90   void datasourceSignal(const DatasourceEvent * event);
91
92 protected slots:
93   void OnAddDatasource();
94   void OnAddImagesource();
95   void OnExpandField();
96   void OnVisualizeScalarMap();
97   void OnUseInWorkspace();
98   void OnChangeUnderlyingMesh();
99   void OnInterpolateField();
100
101 private:
102   void visualize(DatasourceEvent::EventType);
103   void addDatasource(const char* filename);
104   void updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler*);
105   void updateTreeViewWithNewPresentation(long fieldId, long presentationId);
106
107 private:
108   StandardApp_Module * _salomeModule;
109   SALOME_AppStudyEditor * _studyEditor;
110   std::map<long, std::string> _fieldSeriesEntries;
111
112   DlgChangeUnderlyingMesh * _dlgChangeUnderlyingMesh;
113   DlgInterpolateField * _dlgInterpolateField;
114
115 };
116
117 #endif