SnapshotControlWidgetController.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package MemoryX::gui-plugins::SnapshotControlWidgetController
19  * @author Manfred Kroehnert ( Manfred dot Kroehnert at kit dot edu )
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #pragma once
26 
27 #include <MemoryX/gui-plugins/SnapshotControl/ui_SnapshotControlWidget.h>
28 
30 
33 
34 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
35 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
36 
37 namespace armarx
38 {
39  /**
40  \page MemoryX-GuiPlugins-SnapshotControl SnapshotGui
41  \brief SnapshotControlWidgetController provides a graphical interface for loading, storing, and removing Memory Snapshots
42 
43  \image html SnapshotControlGui.png
44 
45  A list of all available Snapshots will be fetched after a connection to LongtermMemory and WorkingMemory has been established.
46  These Snapshot names are presented in a drop-down list and the selected entry
47  can either be loaded into WorkingMemory or removed from the memory/database.
48 
49  Additionally, it is possible to save the current content of the WorkingMemory under a new Snapshot name.
50  The new name is provided via the text input field and "Snapshot_" is prepended to the name if it has been omitted.
51 
52  SnapshotControl API Documentation \ref SnapshotControlWidgetController
53  \see SnapshotControlGuiPlugin
54  */
55 
56  /**
57  * \class SnapshotControlWidgetController
58  * \brief SnapshotControlWidgetController provides a graphical interface for loading, storing, and removing Memory Snapshots
59  * \see SnapshotControlGuiPlugin
60  */
63  public ArmarXComponentWidgetControllerTemplate<SnapshotControlWidgetController>
64  {
65  Q_OBJECT
66 
67  public:
68  /**
69  * Controller Constructor
70  */
72 
73  /**
74  * Controller destructor
75  */
77 
78  /**
79  * @see ArmarXWidgetController::loadSettings()
80  */
81  void loadSettings(QSettings* settings) override;
82 
83  /**
84  * @see ArmarXWidgetController::saveSettings()
85  */
86  void saveSettings(QSettings* settings) override;
87 
88  /**
89  * Returns the Widget name displayed in the ArmarXGui to create an
90  * instance of this class.
91  */
92  static QString GetWidgetName()
93  {
94  return "MemoryX.SnapshotControl";
95  }
96 
97  /**
98  * @see armarx::Component::onInitComponent()
99  *
100  * Initializes waiting for proxies of LongtermMemory and WorkingMemory.
101  */
102  void onInitComponent() override;
103 
104  /**
105  * @see armarx::Component::onConnectComponent()
106  *
107  * Fetches proxies and the list of all available snapshots.
108  * Enables the main widget.
109  */
110  void onConnectComponent() override;
111 
112  /**
113  * @see armarx::Component::onDisconnectComponent()
114  *
115  * Disables the main widget if the connection has been lost.
116  */
117  void onDisconnectComponent() override;
118 
119  public slots:
120  /* QT slot declarations */
121  /**
122  * @brief loadSnapshotNames fetches the list of available Snapshot names from LongtermMemory
123  */
124  void loadSnapshotNames();
125 
126  /**
127  * @brief loadSnapshot loads the Snapshot currently selected in the dropdown list into WorkingMemory
128  */
129  void loadSnapshot();
130  /**
131  * @brief removeSnapshot removes the Snapshot currently selected in the dropdown list from LongtermMemory
132  */
133  void removeSnapshot();
134  /**
135  * @brief saveSnapshot saves the current content of WorkingMemory in LongtermMemory under the name provided in the text input field
136  */
137  void saveSnapshot();
138  private slots:
139  /**
140  * @brief snapshotNameChanged is called when text is typed into the input field (en-/disables the save button)
141  * @param snapshotName
142  */
143  void snapshotNameChanged(const QString& snapshotName);
144  signals:
145  /* QT signal declarations */
146 
147  private:
148  /**
149  * @brief connectSlots does the initial wiring of signals to slots
150  */
151  void connectSlots();
152  /**
153  * Widget Form
154  */
155  Ui::SnapshotControlWidget widget;
156 
157  /**
158  * @brief workingMemoryPrx proxy to WorkingMemory
159  */
160  memoryx::WorkingMemoryInterfacePrx workingMemoryPrx;
161  /**
162  * @brief longtermMemoryPrx proxy to LongtermMemory
163  */
164  memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx;
165 
166  /**
167  * @brief LONGTERM_SNAPSHOT_PREFIX is set to "Snapshot_" and needs to be the prefix of each Snapshot name
168  */
169  const std::string LONGTERM_SNAPSHOT_PREFIX;
170  };
171 }
172 
armarx::SnapshotControlWidgetController::GetWidgetName
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Definition: SnapshotControlWidgetController.h:92
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
ArmarXGuiPlugin.h
armarx::SnapshotControlWidgetController
SnapshotControlWidgetController provides a graphical interface for loading, storing,...
Definition: SnapshotControlWidgetController.h:61
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
ImportExportComponent.h