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 #include <ArmarXGui/gui-plugins/StatechartEventSenderPlugin/ui_EventSenderConfig.h>
25 
26 #include <IceUtil/IceUtil.h>
27 
28 #include <QSpacerItem>
29 
30 using namespace armarx;
31 
32 
33 EventSenderComponent::EventSenderComponent(QString eventSenderName, QWidget* parent) :
34  dialog(0)
35 {
36 
37  config.eventSenderName = eventSenderName;
38  setupUi();
39 }
40 
42 {
43  // ARMARX_INFO << "~EventSenderComponent" << flush;
44  delete dialog;
45 }
46 
47 
48 
49 
50 
51 //QWidget *EventSenderComponent::getMainWidget()
52 //{
53 // return this;
54 //}
55 
57 {
58  if (dialog)
59  {
60  return;
61  }
62 
63  // gbEventSender = new QGroupBox(this);
64  this->setObjectName(QString::fromUtf8("this"));
65  this->setMinimumSize(QSize(0, 40));
66  horizontalLayout = new QHBoxLayout(this);
67  horizontalLayout->setSpacing(2);
68  horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
69  horizontalLayout->setContentsMargins(2, 3, 2, -1);
70  tbSend = new QToolButton(this);
71  tbSend->setObjectName(QString::fromUtf8("tbSend"));
72  tbSend->setMinimumSize(QSize(60, 20));
73  QIcon icon;
74  icon.addFile(QString::fromUtf8(":/icons/media-playback-start.ico"), QSize(), QIcon::Normal, QIcon::Off);
75  tbSend->setIcon(icon);
76  tbSend->setIconSize(QSize(16, 16));
77  tbSend->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
78  horizontalLayout->addWidget(tbSend);
79 
80  tbConfig = new QToolButton(this);
81  tbConfig->setObjectName(QString::fromUtf8("tbConfig"));
82  tbConfig->setMinimumSize(QSize(20, 20));
83 
84  QIcon icon2;
85  icon2.addFile(QString::fromUtf8(":/icons/configure-3.png"), QSize(), QIcon::Normal, QIcon::Off);
86  tbConfig->setIcon(icon2);
87  tbConfig->setIconSize(QSize(16, 16));
88  horizontalLayout->addWidget(tbConfig);
89 
90  tbDelete = new QToolButton(this);
91  tbDelete->setObjectName(QString::fromUtf8("tbDelete"));
92  tbDelete->setMinimumSize(QSize(20, 20));
93 
94  QIcon iconClose;
95  iconClose.addFile(QString::fromUtf8(":/icons/dialog-close.ico"), QSize(), QIcon::Normal, QIcon::Off);
96  tbDelete->setIcon(iconClose);
97  tbDelete->setIconSize(QSize(16, 16));
98  tbDelete->setToolButtonStyle(Qt::ToolButtonIconOnly);
99  horizontalLayout->addWidget(tbDelete);
100 
101  QSpacerItem* spacer = new QSpacerItem(1, 20, QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
102  horizontalLayout->addItem(spacer);
103 
104  this->setTitle(QApplication::translate("EventSenderOverview", config.eventSenderName.toStdString().c_str(), 0));
105 #ifndef QT_NO_TOOLTIP
106  tbSend->setToolTip(QApplication::translate("EventSenderOverview", "Send Event", 0));
107  tbDelete->setToolTip(QApplication::translate("EventSenderOverview", "Delete this EventSender", 0));
108  tbConfig->setToolTip(QApplication::translate("EventSenderOverview", "Configure this EventSender", 0));
109 #endif // QT_NO_TOOLTIP
110  tbSend->setText(QApplication::translate("EventSenderOverview", "Send", 0));
111  tbConfig->setText(QApplication::translate("EventSenderOverview", "...", 0));
112 
113 
114  dialog = new EventSenderConfigDialog(this);
115 
116 
117 
118  // slots and signals
119  connect(tbSend, SIGNAL(clicked()), this, SLOT(sendClicked()));
120  connect(tbConfig, SIGNAL(clicked()), this, SLOT(openConfig()));
121  connect(tbDelete, SIGNAL(clicked()), this, SLOT(deleteClicked()));
122 
123  connect(dialog, SIGNAL(accepted()), this, SLOT(configDone()));
124 }
125 
127 {
128  this->config = EventSenderConfig(conf);
129 
130  if (conf.event)
131  {
132  this->config.event = EventPtr::dynamicCast(conf.event->clone());
133  }
134 
135  this->setTitle(conf.eventSenderName);
136 
137 }
138 
140 {
141  if (dialog)
142  {
143  dialog->setIceManager(iceMan);
144  }
145 
146  this->iceManager = iceMan;
147 
148 }
149 
150 
151 
152 
154 {
155  emit sendEvent(config);
156 }
157 
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 
173 {
174  throw exceptions::user::NotImplementedYetException("EventSenderDeletion");
175 }
176 
178 {
180  config.globalStateIdentifier = dialog->getSelectedState().toStdString();
181  config.event = dialog->getSelectedEvent();
182  config.description = dialog->ui->edtDescription->text();
183  config.eventSenderName = dialog->ui->edtEventSenderName->text();
184  this->setTitle(config.eventSenderName);
185  setToolTip(config.description);
186 }
armarx::EventSenderComponent::config
EventSenderConfig config
Definition: EventSenderComponent.h:44
armarx::EventSenderConfigDialog::ui
Ui::EventSenderConfigDialog * ui
Definition: EventSenderConfig.h:96
armarx::EventSenderComponent::configDone
void configDone()
Definition: EventSenderComponent.cpp:177
armarx::EventSenderConfig::componentName
QString componentName
Definition: EventSenderConfig.h:56
armarx::EventSenderComponent::setConfig
void setConfig(const EventSenderConfig &conf)
Definition: EventSenderComponent.cpp:126
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:139
armarx::EventSenderConfig
Definition: EventSenderConfig.h:52
armarx::EventSenderConfigDialog::setIceManager
void setIceManager(IceManagerPtr iceManager)
Definition: EventSenderConfig.cpp:368
armarx::EventSenderComponent::sendClicked
void sendClicked()
Definition: EventSenderComponent.cpp:153
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:41
armarx::EventSenderConfigDialog::getSelectedState
QString getSelectedState()
Definition: EventSenderConfig.cpp:674
armarx::EventSenderConfig::event
EventPtr event
Definition: EventSenderConfig.h:57
armarx::EventSenderConfigDialog
Definition: EventSenderConfig.h:86
GfxTL::Off
OnOff< false > Off
Definition: OnOff.h:11
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:56
armarx::EventSenderConfigDialog::setConfig
void setConfig(const EventSenderConfig &config)
Definition: EventSenderConfig.cpp:275
armarx::EventSenderConfigDialog::getSelectedEvent
EventPtr getSelectedEvent()
Definition: EventSenderConfig.cpp:216
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::EventSenderConfigDialog::getSelectedComponentName
QString getSelectedComponentName()
Definition: EventSenderConfig.cpp:668