23 #include "../Interpolation/InterpolationType.h"
31 ARMARX_INFO <<
"RobotTrajectoryDesigner: TransitionController on init";
34 initInterpolationComboBox();
37 this->guiTransitionTab->getTransitionTab()->transitionList->
38 setSelectionMode(QAbstractItemView::SingleSelection);
39 this->guiTransitionTab->getTransitionTab()->transitionList->clear();
42 QDoubleValidator* validator =
new QDoubleValidator(
46 guiTransitionTab.get());
47 validator->setNotation(QDoubleValidator::StandardNotation);
48 this->guiTransitionTab->getTransitionTab()->durationLineEdit->setValidator(validator);
53 ARMARX_INFO <<
"RobotTrajectoryDesigner: TransitionController on connect";
56 QObject::connect(guiTransitionTab->getTransitionTab()->transitionList,
57 SIGNAL(itemClicked(QListWidgetItem*)),
this,
61 QObject::connect(guiTransitionTab->getTransitionTab()->durationLineEdit,
62 SIGNAL(editingFinished()),
63 this, SLOT(setDurationValue()));
66 QObject::connect(guiTransitionTab->getTransitionTab()->interpolationComboBox,
67 SIGNAL(activated(
int)),
68 this, SLOT(setInterpolation(
int)));
73 ARMARX_INFO <<
"RobotTrajectoryDesigner: TransitionController on disconnect";
78 ARMARX_INFO <<
"RobotTrajectoryDesigner: TransitionController on exit";
82 guiTransitionTab(guiTransitionTab)
90 return this->guiTransitionTab;
95 if (guiTransitionTab != NULL)
97 this->guiTransitionTab = guiTransitionTab;
110 transition.
start = start;
111 transition.
it = interpolation;
117 data.setValue(transition);
120 QListWidgetItem* item =
new QListWidgetItem(QString((
"Transition: " +
std::to_string(
index)).c_str()));
121 item->setData(Qt::UserRole,
data);
122 QListWidget* transitions = guiTransitionTab->getTransitionTab()->transitionList;
124 transitions->insertItem(
index, item);
127 changeTextListWidgetItems();
132 QListWidget* transitions = guiTransitionTab->getTransitionTab()->transitionList;
135 if (transitions->count() >
index)
137 delete transitions->takeItem(
index);
139 changeTextListWidgetItems();
147 guiTransitionTab->getTransitionTab()->durationLineEdit->
148 setText(QString::number(transition.
duration));
150 guiTransitionTab->getTransitionTab()->startValueLabel->
151 setText(QString::number(transition.
start));
153 guiTransitionTab->getTransitionTab()->EndValueLabel->
154 setText(QString::number(transition.
start + transition.
duration));
156 guiTransitionTab->getTransitionTab()->interpolationComboBox->
157 setCurrentIndex(transition.
it);
160 QListWidget* transitions = guiTransitionTab->getTransitionTab()->transitionList;
167 GuiTransition transition = guiTransitionTab->getTransitionTab()->transitionList->
171 guiTransitionTab->getTransitionTab()->durationLineEdit->
172 setText(QString::number(transition.
duration));
174 guiTransitionTab->getTransitionTab()->startValueLabel->
175 setText(QString::number(transition.
start));
177 guiTransitionTab->getTransitionTab()->EndValueLabel->
178 setText(QString::number(transition.
start + transition.
duration));
180 guiTransitionTab->getTransitionTab()->interpolationComboBox->
181 setCurrentIndex(transition.
it);
184 void TransitionController::setDurationValue()
186 if (this->guiTransitionTab->getTransitionTab()->durationLineEdit->hasAcceptableInput())
188 QListWidget* transitions = guiTransitionTab->getTransitionTab()->transitionList;
189 QListWidgetItem* item = transitions->currentItem();
195 double dur = this->guiTransitionTab->getTransitionTab()->
196 durationLineEdit->text().toDouble();
199 if ((dur >= 0) && (dur != transition.
duration))
208 void TransitionController::setInterpolation(
int index)
210 QListWidget* transitions = guiTransitionTab->getTransitionTab()->transitionList;
211 QListWidgetItem* item = transitions->currentItem();
225 void TransitionController::enableAll(
bool enable)
227 this->guiTransitionTab->getTransitionTab()->durationLineEdit->setEnabled(enable);
228 this->guiTransitionTab->getTransitionTab()->interpolationComboBox->setEnabled(enable);
229 this->guiTransitionTab->getTransitionTab()->transitionList->setEnabled(enable);
241 transition.
start = start;
248 data.setValue(transition);
250 QListWidget* transitions = guiTransitionTab->getTransitionTab()->transitionList;
251 QListWidgetItem* item = transitions->item(
index);
254 item->setData(Qt::UserRole,
data);
256 if (transitions->currentRow() ==
index)
265 throw (
"not yet implemented");
271 this->guiTransitionTab->getTransitionTab()->transitionList->clear();
273 this->guiTransitionTab->getTransitionTab()->durationLineEdit->clear();
275 this->guiTransitionTab->getTransitionTab()->startValueLabel->clear();
276 this->guiTransitionTab->getTransitionTab()->EndValueLabel->clear();
278 this->guiTransitionTab->getTransitionTab()->interpolationComboBox->setCurrentIndex(0);
283 for (
int i = 0; i <
list->count(); i++)
293 void TransitionController::initInterpolationComboBox()
295 QComboBox* interpolation = guiTransitionTab->getTransitionTab()->
296 interpolationComboBox;
299 interpolation->setFocusPolicy(Qt::StrongFocus);
300 interpolation->installEventFilter(
new WheelEventFilter(
this));
303 interpolation->clear();
304 interpolation->addItem(QString::fromStdString(
"Linear Interpolation"));
305 interpolation->addItem(QString::fromStdString(
"Spline interpolation"));
306 interpolation->setEnabled(
true);
307 interpolation->setCurrentIndex(0);
310 void TransitionController::changeTextListWidgetItems()
312 QListWidget* transitions = this->guiTransitionTab->getTransitionTab()->transitionList;
313 for (
int i = 0; i < transitions->count(); i++)
315 transitions->item(i)->setText(QString::fromStdString((
"Transition: " +
std::to_string(i))));