EventSenderComponent.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * 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 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package ArmarX::Gui
17 * @author Mirko Waechter ( mirko.waechter at kit dot edu)
18 * @date 2012
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22 
23 #include "EventSenderComponent.h"
24 
25 #include <QSpacerItem>
26 
27 #include <IceUtil/IceUtil.h>
28 
29 #include <ArmarXGui/gui-plugins/StatechartEventSenderPlugin/ui_EventSenderConfig.h>
30 
31 using namespace armarx;
32 
33 EventSenderComponent::EventSenderComponent(QString eventSenderName, QWidget* parent) : dialog(0)
34 {
35 
36  config.eventSenderName = eventSenderName;
37  setupUi();
38 }
39 
41 {
42  // ARMARX_INFO << "~EventSenderComponent" << flush;
43  delete dialog;
44 }
45 
46 //QWidget *EventSenderComponent::getMainWidget()
47 //{
48 // return this;
49 //}
50 
51 void
53 {
54  if (dialog)
55  {
56  return;
57  }
58 
59  // gbEventSender = new QGroupBox(this);
60  this->setObjectName(QString::fromUtf8("this"));
61  this->setMinimumSize(QSize(0, 40));
62  horizontalLayout = new QHBoxLayout(this);
63  horizontalLayout->setSpacing(2);
64  horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
65  horizontalLayout->setContentsMargins(2, 3, 2, -1);
66  tbSend = new QToolButton(this);
67  tbSend->setObjectName(QString::fromUtf8("tbSend"));
68  tbSend->setMinimumSize(QSize(60, 20));
69  QIcon icon;
70  icon.addFile(
71  QString::fromUtf8(":/icons/media-playback-start.ico"), QSize(), QIcon::Normal, QIcon::Off);
72  tbSend->setIcon(icon);
73  tbSend->setIconSize(QSize(16, 16));
74  tbSend->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
75  horizontalLayout->addWidget(tbSend);
76 
77  tbConfig = new QToolButton(this);
78  tbConfig->setObjectName(QString::fromUtf8("tbConfig"));
79  tbConfig->setMinimumSize(QSize(20, 20));
80 
81  QIcon icon2;
82  icon2.addFile(QString::fromUtf8(":/icons/configure-3.png"), QSize(), QIcon::Normal, QIcon::Off);
83  tbConfig->setIcon(icon2);
84  tbConfig->setIconSize(QSize(16, 16));
85  horizontalLayout->addWidget(tbConfig);
86 
87  tbDelete = new QToolButton(this);
88  tbDelete->setObjectName(QString::fromUtf8("tbDelete"));
89  tbDelete->setMinimumSize(QSize(20, 20));
90 
91  QIcon iconClose;
92  iconClose.addFile(
93  QString::fromUtf8(":/icons/dialog-close.ico"), QSize(), QIcon::Normal, QIcon::Off);
94  tbDelete->setIcon(iconClose);
95  tbDelete->setIconSize(QSize(16, 16));
96  tbDelete->setToolButtonStyle(Qt::ToolButtonIconOnly);
97  horizontalLayout->addWidget(tbDelete);
98 
99  QSpacerItem* spacer =
100  new QSpacerItem(1, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
101  horizontalLayout->addItem(spacer);
102 
103  this->setTitle(QApplication::translate(
104  "EventSenderOverview", config.eventSenderName.toStdString().c_str(), 0));
105 #ifndef QT_NO_TOOLTIP
106  tbSend->setToolTip(QApplication::translate("EventSenderOverview", "Send Event", 0));
107  tbDelete->setToolTip(
108  QApplication::translate("EventSenderOverview", "Delete this EventSender", 0));
109  tbConfig->setToolTip(
110  QApplication::translate("EventSenderOverview", "Configure this EventSender", 0));
111 #endif // QT_NO_TOOLTIP
112  tbSend->setText(QApplication::translate("EventSenderOverview", "Send", 0));
113  tbConfig->setText(QApplication::translate("EventSenderOverview", "...", 0));
114 
115 
116  dialog = new EventSenderConfigDialog(this);
117 
118 
119  // slots and signals
120  connect(tbSend, SIGNAL(clicked()), this, SLOT(sendClicked()));
121  connect(tbConfig, SIGNAL(clicked()), this, SLOT(openConfig()));
122  connect(tbDelete, SIGNAL(clicked()), this, SLOT(deleteClicked()));
123 
124  connect(dialog, SIGNAL(accepted()), this, SLOT(configDone()));
125 }
126 
127 void
129 {
130  this->config = EventSenderConfig(conf);
131 
132  if (conf.event)
133  {
134  this->config.event = EventPtr::dynamicCast(conf.event->clone());
135  }
136 
137  this->setTitle(conf.eventSenderName);
138 }
139 
140 void
142 {
143  if (dialog)
144  {
145  dialog->setIceManager(iceMan);
146  }
147 
148  this->iceManager = iceMan;
149 }
150 
151 void
153 {
154  emit sendEvent(config);
155 }
156 
157 void
159 {
160  dialog->setConfig(config);
161  dialog->setModal(true);
162  dialog->show();
163  dialog->raise();
164  dialog->activateWindow();
165  dialog->setParent(0);
166 
167 
168  //ARMARX_INFO_S << config.componentName.toStdString() << ", " << config.globalStateIdentifier << ", " << config.event->eventName << flush;
169 }
170 
171 void
173 {
174  throw exceptions::user::NotImplementedYetException("EventSenderDeletion");
175 }
176 
177 void
179 {
181  config.globalStateIdentifier = dialog->getSelectedState().toStdString();
182  config.event = dialog->getSelectedEvent();
183  config.description = dialog->ui->edtDescription->text();
184  config.eventSenderName = dialog->ui->edtEventSenderName->text();
185  this->setTitle(config.eventSenderName);
186  setToolTip(config.description);
187 }
armarx::EventSenderComponent::config
EventSenderConfig config
Definition: EventSenderComponent.h:42
armarx::EventSenderConfigDialog::ui
Ui::EventSenderConfigDialog * ui
Definition: EventSenderConfig.h:94
armarx::EventSenderComponent::configDone
void configDone()
Definition: EventSenderComponent.cpp:178
armarx::EventSenderConfig::componentName
QString componentName
Definition: EventSenderConfig.h:56
armarx::EventSenderComponent::setConfig
void setConfig(const EventSenderConfig &conf)
Definition: EventSenderComponent.cpp:128
armarx::EventSenderComponent::deleteClicked
void deleteClicked()
Definition: EventSenderComponent.cpp:172
armarx::EventSenderConfig::eventSenderName
QString eventSenderName
Definition: EventSenderConfig.h:54
armarx::EventSenderComponent::setIceManager
void setIceManager(IceManagerPtr iceMan)
Definition: EventSenderComponent.cpp:141
GfxTL::Off
OnOff< false > Off
Definition: OnOff.h:13
armarx::EventSenderConfig
Definition: EventSenderConfig.h:52
armarx::EventSenderConfigDialog::setIceManager
void setIceManager(IceManagerPtr iceManager)
Definition: EventSenderConfig.cpp:376
armarx::EventSenderComponent::sendClicked
void sendClicked()
Definition: EventSenderComponent.cpp:152
armarx::EventSenderComponent::sendEvent
void sendEvent(const EventSenderConfig &config)
EventSenderComponent.h
armarx::EventSenderConfig::globalStateIdentifier
std::string globalStateIdentifier
Definition: EventSenderConfig.h:58
armarx::EventSenderComponent::openConfig
void openConfig()
Definition: EventSenderComponent.cpp:158
armarx::EventSenderComponent::~EventSenderComponent
~EventSenderComponent() override
Definition: EventSenderComponent.cpp:40
armarx::EventSenderConfigDialog::getSelectedState
QString getSelectedState()
Definition: EventSenderConfig.cpp:694
armarx::EventSenderConfig::event
EventPtr event
Definition: EventSenderConfig.h:57
armarx::EventSenderConfigDialog
Definition: EventSenderConfig.h:87
armarx::EventSenderConfig::description
QString description
Definition: EventSenderConfig.h:55
IceUtil::Handle< IceManager >
armarx::EventSenderComponent::EventSenderComponent
EventSenderComponent(QString eventSenderName, QWidget *parent=0)
Definition: EventSenderComponent.cpp:33
armarx::exceptions::user::NotImplementedYetException
Throw this exception to indicate missing functionality.
Definition: NotImplementedYetException.h:39
armarx::EventSenderComponent::setupUi
void setupUi()
Definition: EventSenderComponent.cpp:52
armarx::EventSenderConfigDialog::setConfig
void setConfig(const EventSenderConfig &config)
Definition: EventSenderConfig.cpp:273
armarx::EventSenderConfigDialog::getSelectedEvent
EventPtr getSelectedEvent()
Definition: EventSenderConfig.cpp:213
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::EventSenderConfigDialog::getSelectedComponentName
QString getSelectedComponentName()
Definition: EventSenderConfig.cpp:687