Salome HOME
Merge branch 'V9_9_BR'
[modules/med.git] / src / MEDCalc / gui / DatasourceController.hxx
1 // Copyright (C) 2007-2022  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
29 #include <SalomeApp_Module.h>
30 #include <SALOME_AppStudyEditor.hxx>
31 #include <MEDPresentation.hxx>
32
33 #include "XmedDataModel.hxx"
34 #include "MEDCALCGUI.hxx"
35 //
36 // The DatasourceController defines data structures and classes to
37 // manage the usage of objects in the data space. The data space is
38 // technically the study, whose graphical representation is the
39 // objects browser.
40 //
41
42 // A datasource event is used by the DatasourceController to notify a
43 // job to the Workspace controller (Qt signal/slot pattern connected
44 // by the main controller MEDModule). The setting of attributes and
45 // usage of these attributes in the WorkspaceController depends on the
46 // event type. For example, in the case of a IMPORT event, we just
47 // have to transmit the object, while in the USE event we have to
48 // transmit an object AND an alias.
49 typedef struct {
50   enum EventType {
51     //
52     EVENT_IMPORT_OBJECT, // Simply import the object in the workspace
53     EVENT_USE_OBJECT,    // Import in the workspace AND define a proxy
54                          // variable in the tui console to use it
55     // presentations
56     EVENT_VIEW_OBJECT_CONTOUR,
57     EVENT_VIEW_OBJECT_DEFLECTION_SHAPE,
58     EVENT_VIEW_OBJECT_POINT_SPRITE,
59     EVENT_VIEW_OBJECT_SCALAR_MAP,
60     EVENT_VIEW_OBJECT_SLICES,
61     EVENT_VIEW_OBJECT_VECTOR_FIELD,
62     // these ones forward actions to workspace (and then to python console)
63     EVENT_ADD_DATASOURCE,
64     EVENT_ADD_IMAGE_AS_DATASOURCE,
65     EVENT_ADD_PRESENTATION
66   };
67   int eventtype;
68   XmedDataObject* objectdata;
69   QString objectalias;
70 } DatasourceEvent;
71
72 class MEDModule;
73
74 //
75 // ==============================================================
76 // Datasource controller
77 // ==============================================================
78 //
79 class MEDCALCGUI_EXPORT DatasourceController: public QObject {
80   Q_OBJECT
81
82 public:
83   DatasourceController(MEDModule* salomeModule);
84   ~DatasourceController();
85
86   void createActions();
87
88 public slots:
89   void processWorkspaceEvent(const MEDCALC::MedEvent* event);
90
91 signals:
92   void datasourceSignal(const DatasourceEvent* event);
93
94 protected slots:
95   void OnAddDatasource();
96   void OnAddImagesource();
97   void OnExpandField();
98   void OnUseInWorkspace();
99
100 private:
101   void addDatasource(const char* filename);
102   void updateTreeViewWithNewDatasource(const MEDCALC::DatasourceHandler*);
103
104 private:
105   MEDModule* _salomeModule;
106   SALOME_AppStudyEditor* _studyEditor; // borrowed to MEDModule
107 };
108
109 #endif