stdr_gui_loader.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  STDR Simulator - Simple Two DImensional Robot Simulator
3  Copyright (C) 2013 STDR Simulator
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 3 of the License, or
7  (at your option) any later version.
8  This program 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
11  GNU General Public License for more details.
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software Foundation,
14  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 
16  Authors :
17  * Manos Tsardoulias, etsardou@gmail.com
18  * Aris Thallas, aris.thallas@gmail.com
19  * Chris Zalidis, zalidis@gmail.com
20 ******************************************************************************/
21 
23 
24 namespace stdr_gui
25 {
32  CGuiLoader::CGuiLoader(int argc,char **argv):
33  argc_(argc),
34  argv_(argv)
35  {
36  setupUi(this);
37 
39  close_signal_ = false;
40  }
41 
47  {
48 
49  QIcon applicationIcon;
50  applicationIcon.addFile(QString::fromUtf8((
52  std::string("/resources/images/favicon.ico")).c_str()),
53  QSize(),
54  QIcon::Normal,
55  QIcon::Off);
56  setWindowIcon (applicationIcon);
57 
58  actionLoadMap = new QAction(this);
59  actionLoadMap->setObjectName(QString::fromUtf8("actionLoadMap"));
60  actionLoadMap->setCheckable(false);
61  actionLoadMap->setIconText(QString("Load map"));
62  QIcon iconLoadMap;
63 
64 
65  iconLoadMap.addFile(QString::fromUtf8((
67  std::string("/resources/images/load_map.png")).c_str()),
68  QSize(),
69  QIcon::Normal,
70  QIcon::Off);
71  actionLoadMap->setIcon(iconLoadMap);
72  toolBar->addAction(actionLoadMap);
73 
74  toolBar->addSeparator();
75 
76  actionAddRobot = new QAction(this);
77  actionAddRobot->setObjectName(QString::fromUtf8("actionNewRobot"));
78  actionAddRobot->setCheckable(false);
79  actionAddRobot->setIconText(QString("Load robot"));
80  QIcon iconAddRobot;
81  iconAddRobot.addFile(QString::fromUtf8((
83  std::string("/resources/images/add_robot.png")).c_str()),
84  QSize(),
85  QIcon::Normal,
86  QIcon::Off);
87  actionAddRobot->setIcon(iconAddRobot);
88  toolBar->addAction(actionAddRobot);
89 
90  actionNewRobot = new QAction(this);
91  actionNewRobot->setObjectName(QString::fromUtf8("actionNewRobot"));
92  actionNewRobot->setCheckable(false);
93  actionNewRobot->setIconText(QString("Create robot"));
94  QIcon iconNewRobot;
95  iconNewRobot.addFile(QString::fromUtf8((
97  std::string("/resources/images/new_robot.png")).c_str()),
98  QSize(),
99  QIcon::Normal,
100  QIcon::Off);
101  actionNewRobot->setIcon(iconNewRobot);
102  toolBar->addAction(actionNewRobot);
103 
104  toolBar->addSeparator();
105 
106  actionNewRfid = new QAction(this);
107  actionNewRfid->setObjectName(QString::fromUtf8("actionNewRfid"));
108  actionNewRfid->setCheckable(false);
109  actionNewRfid->setIconText(QString("Add RFID tag"));
110  QIcon iconNewRfid;
111  iconNewRfid.addFile(QString::fromUtf8((
112  stdr_gui_tools::getRosPackagePath("stdr_gui") +
113  std::string("/resources/images/rfid.png")).c_str()),
114  QSize(),
115  QIcon::Normal,
116  QIcon::Off);
117  actionNewRfid->setIcon(iconNewRfid);
118  toolBar->addAction(actionNewRfid);
119 
120  actionNewThermal = new QAction(this);
121  actionNewThermal->setObjectName(QString::fromUtf8("actionNewThermal"));
122  actionNewThermal->setCheckable(false);
123  actionNewThermal->setIconText(QString("Add heat source"));
124  QIcon iconNewThermal;
125  iconNewThermal.addFile(QString::fromUtf8((
126  stdr_gui_tools::getRosPackagePath("stdr_gui") +
127  std::string("/resources/images/thermal.png")).c_str()),
128  QSize(),
129  QIcon::Normal,
130  QIcon::Off);
131 
132  actionNewThermal->setIcon(iconNewThermal);
133  toolBar->addAction(actionNewThermal);
134 
135  actionNewCo2 = new QAction(this);
136  actionNewCo2->setObjectName(QString::fromUtf8("actionNewCo2"));
137  actionNewCo2->setCheckable(false);
138  actionNewCo2->setIconText(QString("Add CO2 source"));
139  QIcon iconNewCo2;
140  iconNewCo2.addFile(QString::fromUtf8((
141  stdr_gui_tools::getRosPackagePath("stdr_gui") +
142  std::string("/resources/images/co2.png")).c_str()),
143  QSize(),
144  QIcon::Normal,
145  QIcon::Off);
146  actionNewCo2->setIcon(iconNewCo2);
147  toolBar->addAction(actionNewCo2);
148 
149  actionNewSound = new QAction(this);
150  actionNewSound->setObjectName(QString::fromUtf8("actionNewSound"));
151  actionNewSound->setCheckable(false);
152  actionNewSound->setIconText(QString("Add sound source"));
153  QIcon iconNewSound;
154  iconNewSound.addFile(QString::fromUtf8((
155  stdr_gui_tools::getRosPackagePath("stdr_gui") +
156  std::string("/resources/images/sound.png")).c_str()),
157  QSize(),
158  QIcon::Normal,
159  QIcon::Off);
160  actionNewSound->setIcon(iconNewSound);
161  toolBar->addAction(actionNewSound);
162 
163  toolBar->addSeparator();
164 
165  actionProperties = new QAction(this);
166  actionProperties->setObjectName(QString::fromUtf8("actionProperties"));
167  actionProperties->setCheckable(false);
168  actionProperties->setIconText(QString("Properties"));
169  QIcon iconProperties;
170  iconProperties.addFile(QString::fromUtf8((
171  stdr_gui_tools::getRosPackagePath("stdr_gui") +
172  std::string("/resources/images/properties.png")).c_str()),
173  QSize(),
174  QIcon::Normal,
175  QIcon::Off);
176  actionProperties->setIcon(iconProperties);
177  toolBar->addAction(actionProperties);
178 
179  toolBar->addSeparator();
180 
181  actionGrid = new QAction(this);
182  actionGrid->setObjectName(QString::fromUtf8("actionGrid"));
183  actionGrid->setCheckable(true);
184  actionGrid->setChecked(false);
185  actionGrid->setIconText(QString("Enable grid"));
186  QIcon iconGrid;
187  iconGrid.addFile(QString::fromUtf8((
188  stdr_gui_tools::getRosPackagePath("stdr_gui") +
189  std::string("/resources/images/grid.png")).c_str()),
190  QSize(),
191  QIcon::Normal,
192  QIcon::Off);
193  actionGrid->setIcon(iconGrid);
194  toolBar->addAction(actionGrid);
195 
196  actionZoomIn = new QAction(this);
197  actionZoomIn->setObjectName(QString::fromUtf8("actionZoomIn"));
198  actionZoomIn->setCheckable(true);
199  actionZoomIn->setIconText(QString("Zoom in"));
200  QIcon iconZoomIn;
201  iconZoomIn.addFile(QString::fromUtf8((
202  stdr_gui_tools::getRosPackagePath("stdr_gui") +
203  std::string("/resources/images/zoom_in_b.png")).c_str()),
204  QSize(),
205  QIcon::Normal,
206  QIcon::Off);
207  actionZoomIn->setIcon(iconZoomIn);
208  toolBar->addAction(actionZoomIn);
209 
210  actionZoomOut = new QAction(this);
211  actionZoomOut->setObjectName(QString::fromUtf8("actionZoomOut"));
212  actionZoomOut->setCheckable(true);
213  actionZoomOut->setIconText(QString("Zoom out"));
214  QIcon iconZoomOut;
215  iconZoomOut.addFile(QString::fromUtf8((
216  stdr_gui_tools::getRosPackagePath("stdr_gui") +
217  std::string("/resources/images/zoom_out_b.png")).c_str()),
218  QSize(),
219  QIcon::Normal,
220  QIcon::Off);
221  actionZoomOut->setIcon(iconZoomOut);
222  toolBar->addAction(actionZoomOut);
223 
224  actionAdjusted = new QAction(this);
225  actionAdjusted->setObjectName(QString::fromUtf8("actionAdjusted"));
226  actionAdjusted->setCheckable(false);
227  actionAdjusted->setChecked(true);
228  actionAdjusted->setIconText(QString("Adjust size"));
229  QIcon iconAdjust;
230  iconAdjust.addFile(QString::fromUtf8((
231  stdr_gui_tools::getRosPackagePath("stdr_gui") +
232  std::string("/resources/images/adjusted.png")).c_str()),
233  QSize(),
234  QIcon::Normal,
235  QIcon::Off);
236  actionAdjusted->setIcon(iconAdjust);
237  toolBar->addAction(actionAdjusted);
238 
239  toolBar->setIconSize(QSize(30,30));
240  }
241 
247  void CGuiLoader::closeEvent(QCloseEvent *event)
248  {
249  //~ ROS_ERROR("Shutdown signal!");
250  if(close_signal_)
251  {
252  event->accept();
253  //~ ROS_ERROR("Shutting down ros...");
254  ros::shutdown();
255  exit(0);
256  return;
257  }
258  close_signal_ = true;
259  event->ignore();
260  event_ = event;
261  }
262 
268  {
269  return event_;
270  }
271 
277  {
278  return close_signal_;
279  }
280 
286  {
287  this->close();
288  }
289 }
QAction * actionZoomOut
The action of map adjusted button.
std::string getRosPackagePath(std::string package)
Returns the global path of the ROS package provided.
Definition: stdr_tools.cpp:31
QAction * actionNewRobot
The action of adding a new robot button.
QEvent * getCloseEvent(void)
Returns the exit event.
void shutdown(void)
Shuts down the main window.
QAction * actionAddRobot
The action of new RFID tag button.
QAction * actionZoomIn
The action of zooming out button.
QAction * actionGrid
The action of creating new robot button.
CGuiLoader(int argc, char **argv)
Default contructor.
void closeEvent(QCloseEvent *event)
Overloading of closeEvent function from QMainWindow.
QAction * actionNewSound
The action of loading a map button.
QAction * actionLoadMap
The action of zooming in button.
The main namespace for STDR GUI.
QAction * actionProperties
< The action of properties button
QAction * actionNewRfid
The action of new thermal source button.
QAction * actionNewThermal
The action of new CO2 source button.
ROSCPP_DECL void shutdown()
QCloseEvent * event_
void addToolbarIcons(void)
Adds the tool buttons in the main window toolbar.
QAction * actionNewCo2
The action of new sound source button.
bool closeTriggered(void)
Returns true if a close event was triggered.
bool close_signal_
The exit event (when occurs)


stdr_gui
Author(s): Manos Tsardoulias
autogenerated on Mon Jun 10 2019 15:15:16