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 
28 
31 
32 #include <MemoryX/gui-plugins/SnapshotControl/ui_SnapshotControlWidget.h>
33 #include <MemoryX/interface/components/LongtermMemoryInterface.h>
34 #include <MemoryX/interface/components/WorkingMemoryInterface.h>
35 
36 namespace armarx
37 {
38  /**
39  \page MemoryX-GuiPlugins-SnapshotControl SnapshotGui
40  \brief SnapshotControlWidgetController provides a graphical interface for loading, storing, and removing Memory Snapshots
41 
42  \image html SnapshotControlGui.png
43 
44  A list of all available Snapshots will be fetched after a connection to LongtermMemory and WorkingMemory has been established.
45  These Snapshot names are presented in a drop-down list and the selected entry
46  can either be loaded into WorkingMemory or removed from the memory/database.
47 
48  Additionally, it is possible to save the current content of the WorkingMemory under a new Snapshot name.
49  The new name is provided via the text input field and "Snapshot_" is prepended to the name if it has been omitted.
50 
51  SnapshotControl API Documentation \ref SnapshotControlWidgetController
52  \see SnapshotControlGuiPlugin
53  */
54 
55  /**
56  * \class SnapshotControlWidgetController
57  * \brief SnapshotControlWidgetController provides a graphical interface for loading, storing, and removing Memory Snapshots
58  * \see SnapshotControlGuiPlugin
59  */
61  public ArmarXComponentWidgetControllerTemplate<SnapshotControlWidgetController>
62  {
63  Q_OBJECT
64 
65  public:
66  /**
67  * Controller Constructor
68  */
70 
71  /**
72  * Controller destructor
73  */
75 
76  /**
77  * @see ArmarXWidgetController::loadSettings()
78  */
79  void loadSettings(QSettings* settings) override;
80 
81  /**
82  * @see ArmarXWidgetController::saveSettings()
83  */
84  void saveSettings(QSettings* settings) override;
85 
86  /**
87  * Returns the Widget name displayed in the ArmarXGui to create an
88  * instance of this class.
89  */
90  static QString
92  {
93  return "MemoryX.SnapshotControl";
94  }
95 
96  /**
97  * @see armarx::Component::onInitComponent()
98  *
99  * Initializes waiting for proxies of LongtermMemory and WorkingMemory.
100  */
101  void onInitComponent() override;
102 
103  /**
104  * @see armarx::Component::onConnectComponent()
105  *
106  * Fetches proxies and the list of all available snapshots.
107  * Enables the main widget.
108  */
109  void onConnectComponent() override;
110 
111  /**
112  * @see armarx::Component::onDisconnectComponent()
113  *
114  * Disables the main widget if the connection has been lost.
115  */
116  void onDisconnectComponent() override;
117 
118  public slots:
119  /* QT slot declarations */
120  /**
121  * @brief loadSnapshotNames fetches the list of available Snapshot names from LongtermMemory
122  */
123  void loadSnapshotNames();
124 
125  /**
126  * @brief loadSnapshot loads the Snapshot currently selected in the dropdown list into WorkingMemory
127  */
128  void loadSnapshot();
129  /**
130  * @brief removeSnapshot removes the Snapshot currently selected in the dropdown list from LongtermMemory
131  */
132  void removeSnapshot();
133  /**
134  * @brief saveSnapshot saves the current content of WorkingMemory in LongtermMemory under the name provided in the text input field
135  */
136  void saveSnapshot();
137  private slots:
138  /**
139  * @brief snapshotNameChanged is called when text is typed into the input field (en-/disables the save button)
140  * @param snapshotName
141  */
142  void snapshotNameChanged(const QString& snapshotName);
143  signals:
144  /* QT signal declarations */
145 
146  private:
147  /**
148  * @brief connectSlots does the initial wiring of signals to slots
149  */
150  void connectSlots();
151  /**
152  * Widget Form
153  */
154  Ui::SnapshotControlWidget widget;
155 
156  /**
157  * @brief workingMemoryPrx proxy to WorkingMemory
158  */
159  memoryx::WorkingMemoryInterfacePrx workingMemoryPrx;
160  /**
161  * @brief longtermMemoryPrx proxy to LongtermMemory
162  */
163  memoryx::LongtermMemoryInterfacePrx longtermMemoryPrx;
164 
165  /**
166  * @brief LONGTERM_SNAPSHOT_PREFIX is set to "Snapshot_" and needs to be the prefix of each Snapshot name
167  */
168  const std::string LONGTERM_SNAPSHOT_PREFIX;
169  };
170 } // namespace armarx
armarx::SnapshotControlWidgetController::GetWidgetName
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Definition: SnapshotControlWidgetController.h:91
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
ArmarXGuiPlugin.h
armarx::SnapshotControlWidgetController
SnapshotControlWidgetController provides a graphical interface for loading, storing,...
Definition: SnapshotControlWidgetController.h:60
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:27
ImportExportComponent.h