Salome HOME
bos #28928: Merge branch 'rnv/28928'
[modules/med.git] / doc / dev / sphinx / fields_arch_gui.rst
1 .. _fields_arch_gui_page:
2
3 *****************
4 FIELDS module GUI 
5 *****************
6
7 FIELDS module uses the following components to manage and display presentations:
8
9 * Standard SALOME *Object browser* represents structure of MED file within FIELDS module. When MED file is loaded, the following steps are performed:
10
11   #. Reading structure of MED file. For these purpose, ``MEDCALC::MedDataManager`` CORBA service (which uses *MEDCoupling* library) is used.
12   #. Creating structure of MED file (full path to MED file, name of a mesh, name and type (``ON_NODES`` or ``ON_CELLS``) of each field in MED file, and all timesteps for each field).
13      ``MED_ORB::MED`` CORBA component is used for that, and each item of the data tree structure is represented via standard SALOME data object ``SObject``.
14
15 * *Presentation Parameters* panel allows managing parameters of presentations. This panel is implemented in the following way:
16
17   #. Interface of *Presentation Parameters* panel is described via `Qt Designer tool <https://doc.qt.io/qt-5/qtdesigner-manual.html>`__;
18      for details see ``WidgetPresentationParameters.ui`` (UI form) and ``WidgetPresentationParameters.cxx`` (C++ wrapping of UI) files.
19      The UI file contains all needed GUI controls which are used to manage parameters of all FIELDS presentations, i.e. single UI file is used for all types of presentations.
20      All these parameters are hidden by default; and parameters, required for specific presentation are shown at first usage, for example:
21      
22       .. code-block:: cpp
23
24         void WidgetPresentationParameters::setSliceOrientation(MEDCALC::SliceOrientationType orient) {
25            ...
26            // Show the widgets:
27            _ui.labelSliceOrient->show();
28            _ui.comboBoxSliceOrient->show();
29            ...
30            ...
31            ...    
32         }
33
34      Widget which contains all these parameters is displayed inside the dockable window which is created during the initialization of FIELDS module.
35
36   #. Interaction between GUI controls and ``medcalc`` Python package is implemented via several helper classes. The hierarchy of these classes is presented on the following diagram:
37
38       .. image:: images/image_helpers_hierarchy.png
39          :align: center
40     
41     * ``MEDWidgetHelper`` - base abstract class to manage common parameters of all FIELDS presentations.
42     * ``MEDWidgetHelperComponent`` - base abstract class to manage parameters of all presentations having only one component to change.
43
44       These base classes contain one pure virtual method 
45
46        .. code-block:: cpp
47         
48           virtual std::string getPythonTag() const = 0;
49
50       This method must be implemented in all descendant classes; it should return the type of a presentation ("ScalarMap", "Slices" and etc.)
51
52     * All other classes (such as ``MEDWidgetHelperScalarMap``, ``MEDWidgetHelperSlices`` etc.) are descendants of classes ``MEDWidgetHelper`` or ``MEDWidgetHelperComponent``.
53
54     Helper classes send ``PresentationEvent`` event via emitting ``presentationUpdateSignal`` signal on any user action made in *Presentation Parameters* panel.
55
56   #. ``PresentationController`` class is aimed for 
57      
58     * Converting ``PresentationEvent`` events to calls of ``medcalc`` Python package API, and executing related commands in the embedded Python console, for example:
59
60       .. code-block:: cpp
61        
62           QStringList commands;
63           ...
64           if ( event->eventtype == PresentationEvent::EVENT_CHANGE_COMPONENT ) {
65            
66             // Get presentation type by calling getPythonTag() method
67             std::string typ = getPresTypeFromWidgetHelper(event->presentationId); 
68
69             // Convert 'PresentationEvent' to set of python commands
70             commands += QString("params = medcalc.Get%1Parameters(%2)").arg(QString::fromStdString(typ)).arg(event->presentationId);
71             commands += QString("params.displayedComponent = '%1'").arg(QString::fromStdString(event->aString));
72             commands += QString("medcalc.Update%1(%2, params)").arg(QString::fromStdString(typ)).arg(event->presentationId);
73           }
74           ...
75           _consoleDriver->exec(commands); 
76
77     * Updating content of *Presentation Parameters* panel according to the presentation, selected in the *Object browser*.
78
79 * Standard SALOME *Displayer* mechanism is used to manage visiblity of FIELDS presentations in the ParaView viewer.