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