StatechartEditorController.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-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
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
25
26#include <QCoreApplication>
27#include <QInputDialog>
28#include <QLabel>
29#include <QMessageBox>
30#include <QTimer>
31
32// Qt headers must come before <filesystem>
33// https://stackoverflow.com/questions/69407237/qt-moc-errorusr-include-c-10-bits-fs-fwd-39-parse-error-at-std
34#include <filesystem>
35
36#include <IceUtil/UUID.h>
37
38#include <SimoxUtility/algorithm/string/string_tools.h>
39
42#include <ArmarXCore/interface/statechart/RemoteStateOffererIce.h>
43
46
49#include "io/GroupXmlReader.h"
50#include "io/GroupXmlWriter.h"
55
56namespace armarx
57{
58
60 // editor(NULL)
61 watcher(NULL)
62 {
63 // For jsonobject double/float serilization on german/spanish pcs....
64 setlocale(LC_ALL, "C");
65
66 QSettings s("KIT", "ArmarXStatechartEditor");
67 config.lockRemoteStates = s.value("lockRemoteStates", true).toBool();
68 config.searchPaths = s.value("searchPaths").toStringList();
69 }
70
75
76 void
78 {
79 ARMARX_INFO << "Updating auto-storage config";
80 QSettings s("KIT", "ArmarXStatechartEditor");
81 s.setValue("lockRemoteStates", config.lockRemoteStates);
82 s.setValue("searchPaths", config.searchPaths);
83 }
84
85 QStringList
87 {
88 QStringList result;
89 if (basePath.isEmpty())
90 {
91 return result;
92 }
93 try
94 {
95 int i = 0;
96
97 for (std::filesystem::recursive_directory_iterator end, dir(basePath.toUtf8().data());
98 dir != end && getState() < eManagedIceObjectExiting;
99 ++dir, i++)
100 {
101 std::string path(dir->path().c_str());
102 // search for all statechart group xml files
103 if (dir->path().extension() == ".scgxml")
104 {
105 // skip groups in deprecated folders
106 if (path.find("deprecated") != std::string::npos)
107 {
108 ARMARX_INFO << "Skipping deprecated Statechart Group " << path;
109 }
110 else
111 {
112 result << dir->path().c_str();
113 }
114 }
115
116 if (i % 100 == 0)
117 {
118 QCoreApplication::processEvents();
119 }
120 }
121 }
122 catch (std::exception& e)
123 {
124 ARMARX_WARNING << "Invalid filepath: " << e.what();
125 }
126
127 return result;
128 }
129
130 void
135
136 void
138 {
139 QTimer::singleShot(0, this, SLOT(initWidget()));
140 stateWatcher = new StateWatcher();
141 getArmarXManager()->addObject(
142 stateWatcher, "StateWatcher" + IceUtil::generateUUID(), false);
143 }
144
145 void
149
150 void
152 {
153 if (executionStatusTask)
154 {
155 executionStatusTask->stop();
156 }
157 }
158
159 void
161 {
162 // searchPaths = settings->value("paths").toStringList();
163 // int size = settings->beginReadArray("groups");
164 // for(int row = 0; row < size; row++)
165 // {
166 // settings->setArrayIndex(row);
167 // config.groupsToLoad.push_back(settings->value("path").toString());
168 // }
169 // settings->endArray();
170 if (!profiles)
171 {
173 Application::getInstance()->getArmarXPackageNames());
174 }
175
176 if (settings->contains("selectedProfile"))
177 {
178 config.selectedProfile = profiles->getProfileByName(
179 settings->value("selectedProfile").toString().toStdString());
180 }
181 else if (getConfigDialog(getWidget())->exec() == QDialog::Accepted)
182 {
183 configured();
184 }
185 else
186 {
187 config.selectedProfile = profiles->getProfileByName(profiles->GetRootName());
188 }
189
190 config.openAllStatesWasSelected = settings->value("openAllStatesSelected", false).toBool();
191 }
192
193 void
195 {
196 // settings->setValue("paths", searchPaths);
197 // if(treeController)
198 // {
199 // settings->beginWriteArray("groups");
200 // for(int row = 0; row < treeController->rowCount(); row++)
201 // {
202 // QModelIndex index = treeController->index(row, 0);
203 // auto node = treeController->getNode(index);
204 //
205 // settings->setArrayIndex(row);
206 // settings->setValue("path", node->getGroup()->getDefinitionFilePath());
207 // }
208 // settings->endArray();
209 // }
210
211 if (config.selectedProfile)
212 {
213 settings->setValue("selectedProfile",
214 QString::fromStdString(config.selectedProfile->getName()));
215 }
216
217 settings->setValue("openAllStatesSelected", config.openAllStatesWasSelected);
218 }
219
220 void
222 {
223 StateTreeNodePtr node = treeController->getNode(index);
224
225 if (node && node->getState())
226 {
227 int index = editor->getStateTabWidget()->getStateTab(node->getState());
228 getTipDialog()->showMessage(
229 "You can move states by holding the SHIFT + left click button. You can move the "
230 "scene by holding ALT + move mouse.",
231 "State Interaction");
232
233 if (index < 0)
234 {
235 editor->getStateTabWidget()->addStateTab(node->getState());
236 }
237 else
238 {
239 editor->getStateTabWidget()->setCurrentIndex(index);
240 }
241 }
242 }
243
244 void
246 {
247 treeController->saveAll();
248 }
249
250 void
252 {
253 StatechartView* view = editor->getUI()->stateTabWidget->stateview(index);
254
255 if (view && view->getStateInstance() && view->getStateInstance()->getStateClass())
256 {
257 treeController->selectNodeByState(view->getStateInstance()->getStateClass());
259 view->showSubSubstates(editor->ui->actionShow_Subsubstates->isChecked());
260 }
261 }
262
263 void
265 {
266 QList<QString> selectedProxies;
267 // enable statechart context generation for new groups by default
269 "",
270 packageTool,
271 variantInfo,
272 selectedProxies,
273 true,
274 profiles);
275
276 if (d.exec() == QDialog::Accepted)
277 {
278 StatechartGroupPtr g = treeController->addNewGroup(d.getGroupName(),
279 d.getGroupPath(),
281 d.getPackageName(),
282 d.getProxies(),
285 }
286 }
287
288 void
290 {
292 d.setPaths(config.searchPaths);
293 d.setRemoteStatesLocked(config.lockRemoteStates);
294 if (d.exec() == QDialog::Accepted)
295 {
296 config.searchPaths = d.getPaths();
297 config.searchPaths.removeDuplicates();
298 searchAndOpenPaths(config.searchPaths);
299 // d.setPaths(config.searchPaths);
300 // d.setRemoteStatesLocked(config.lockRemoteStates);
301 // if(d.exec() == QDialog::Accepted)
302 // {
303 // config.searchPaths = d.getPaths();
304 // searchAndAddPaths(config.searchPaths);
305 config.lockRemoteStates = d.getRemoteStatesLocked();
306 stateEditorController->setLockRemoteStatesByDefault(config.lockRemoteStates);
308 }
309 }
310
311 void
313 {
314 editor->getUI()->treeViewProgressBar->show();
315 editor->getUI()->treeViewProgressBar->setMaximum(groups.size());
316 int i = 1;
317 foreach (QString groupPath, groups)
318 {
319 treeController->onOpenGroup(groupPath);
320 editor->getUI()->treeViewProgressBar->setValue(i);
321 i++;
322 qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
323 }
324 editor->getUI()->treeViewProgressBar->hide();
325 }
326
327 void
329 {
330 paths.removeDuplicates();
331 QStringList groups;
332 foreach (QString path, paths)
333 {
334 groups.append(findAllStatechartGroupDefinitions(path.trimmed()));
335 }
336 openStatechartGroups(groups);
337 }
338
339 void
341 {
342 StatechartView* view = editor->getUI()->stateTabWidget->currentStateview();
343
344 if (view)
345 {
346 connect(view,
347 SIGNAL(selectedStateChanged(statechartmodel::StateInstancePtr)),
348 this,
350 }
351 }
352
353 void
355 {
356 if (stateInstance && stateInstance->getStateClass())
357 {
358 StateTreeNodePtr node = treeController->getNodeByState(stateInstance->getStateClass());
359
360 if (node)
361 {
362 std::string filePath = node->getBoostCppFilePath().c_str();
363 showCodeFileContent(QString::fromStdString(filePath));
364 }
365 }
366 }
367
368 void
370 {
371 watcher->removePath(path);
372 std::string fileContent;
373
374 if (std::filesystem::exists(path.toUtf8().data()))
375 {
376 watcher->addPath(path);
377 fileContent = RapidXmlReader::ReadFileContents(path.toUtf8().data());
378 }
379 else
380 {
381 fileContent = "<cpp missing>";
382 }
383
384 int line = editor->getUI()->textEditCppCode->textCursor().blockNumber();
385 QTextCursor cursor = editor->getUI()->textEditCppCode->textCursor();
386 cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, line);
387 editor->getUI()->textEditCppCode->setText(QString::fromUtf8(fileContent.c_str()));
388 editor->getUI()->textEditCppCode->setTextCursor(cursor);
389 }
390
391 void
393 {
394 editor->getUI()->textEditCppCode->find("::CreateInstance(");
395 editor->getUI()->textEditCppCode->find("::onEnter()", QTextDocument::FindBackward);
396 }
397
398 void
400 {
401 editor->getUI()->textEditCppCode->find("::CreateInstance(");
402 editor->getUI()->textEditCppCode->find("::run()", QTextDocument::FindBackward);
403 }
404
405 void
407 {
408 editor->getUI()->textEditCppCode->find("::CreateInstance(");
409 editor->getUI()->textEditCppCode->find("::onBreak()", QTextDocument::FindBackward);
410 }
411
412 void
414 {
415 editor->getUI()->textEditCppCode->find("::CreateInstance(");
416 editor->getUI()->textEditCppCode->find("::onExit()", QTextDocument::FindBackward);
417 }
418
419 void
421 {
423
424 if (editor->getUI()->stateTabWidget->currentStateview())
425 {
426
427 auto selection =
428 editor->getUI()->stateTabWidget->currentStateview()->getScene()->selectedItems();
429
430 for (QGraphicsItem* item : selection)
431 {
432 StateItem* stateItem = dynamic_cast<StateItem*>(item);
433
434 if (stateItem)
435 {
436 if (stateItem->getStateInstance())
437 {
438 state = stateItem->getStateInstance()->getStateClass();
439
440 if (state)
441 {
442 break;
443 }
444 }
445 }
446 }
447 }
448
449 if (state)
450 {
451 auto node = treeController->getNodeByState(state);
452
453 if (node && node->isState())
454 {
455 treeController->openStateCPP(node);
456 }
457 }
458 else
459 {
460 showMessageBox("No state with a StateClass is selected");
461 }
462 }
463
464 void
466 {
467 editor->getStateTabWidget()->clear();
468 }
469
470 void
472 {
473 StatechartView* view = editor->getUI()->stateTabWidget->currentStateview();
474 if (!executedOpenedGroup)
475 {
476 if (view)
477 {
478 auto node =
479 treeController->getNodeByState(view->getStateInstance()->getStateClass());
480 if (node)
481 {
482 if (node->isPublic())
483 {
484 treeController->executeGroupWithDependencies(
485 node->getGroup(),
486 view->getStateInstance()->getStateClass()->getStateName());
487 executedOpenedGroup = node->getGroup();
488 editor->getUI()->toolButtonRunState->setIcon(QIcon(":/icons/delete.ico"));
489 editor->getUI()->toolButtonRunState->setToolTip(
490 "Stop the Statechart Group");
491 editor->getUI()->toolButtonWatchStateExecution->setEnabled(false);
492 editor->getUI()->labelExecutionState->setVisible(true);
493 alreadyWatchingState = false;
494 executionStatusTask->start();
495 }
496 else
497 {
498 QMessageBox::warning(
499 editor,
500 "Execution not possible",
501 "You can only execute public state. Right-click on the state in the "
502 "tree view on the left and select 'Public State'.");
503 }
504 }
505 }
506 else
507 {
508 QMessageBox::warning(
509 editor,
510 "Execution not possible",
511 "You need to open a state before executing it with this button.");
512 }
513 }
514 else
515 {
516 if (executedOpenedGroup)
517 {
518 treeController->stopGroupExecutionWithDependencies(executedOpenedGroup);
519 executedOpenedGroup.reset();
520 executionStatusTask->stop();
521 editor->getUI()->labelExecutionState->setVisible(false);
522 }
523 editor->getUI()->toolButtonRunState->setToolTip("Start the Statechart Group");
524 editor->getUI()->toolButtonRunState->setIcon(QIcon(":/icons/run.svg"));
525 editor->getUI()->toolButtonWatchStateExecution->setEnabled(true);
526 if (view)
527 {
529 }
530 std::function<void(StateItem * state)> unsubscriptionLamba;
531 unsubscriptionLamba = [&](StateItem* state)
532 {
533 stateWatcher->unsubscribeState(state);
534 for (auto stateInstance : state->getSubstateItems())
535 {
536 if (stateInstance)
537 {
538 unsubscriptionLamba(stateInstance);
539 }
540 }
541 };
542 unsubscriptionLamba(view->getScene()->getTopLevelStateItem());
543 }
544 }
545
546 void
547 StatechartEditorController::updateExecutionButtonStatus()
548 {
549 bool changeToWaiting = false;
550 QString labelText = "";
551 if (executedOpenedGroup)
552 {
553 std::string proxyName =
554 executedOpenedGroup->getName().toStdString() + "StateComponentAppManager";
555 std::string objName = config.selectedProfile->getName() +
556 executedOpenedGroup->getName().toStdString() +
557 "RemoteStateOfferer";
558 ArmarXManagerInterfacePrx stateComponentProxy =
559 getProxy<ArmarXManagerInterfacePrx>(proxyName, false, "", false);
560 try
561 {
562 if (getArmarXManager()->getIceManager()->isObjectReachable(objName))
563 {
564 // Dont need to do anything, the RemoteStateOfferer is already running.
565 }
566 else if (stateComponentProxy)
567 {
568 auto state = stateComponentProxy->getObjectState(objName);
569 if (state != eManagedIceObjectStarted)
570 {
571 Ice::StringSeq deps;
572 for (auto elem :
573 stateComponentProxy->getObjectConnectivity(objName).dependencies)
574 {
575 ManagedIceObjectDependencyBasePtr dep = elem.second;
576 if (!dep->getResolved())
577 {
578 if (deps.size() >= 2)
579 {
580 deps.push_back("...");
581 break;
582 }
583 else
584 {
585 deps.push_back(dep->getName());
586 }
587 }
588 }
589 labelText = "Waiting for dependencies: " +
590 QString::fromStdString(simox::alg::join(deps, ", "));
591 changeToWaiting = true;
592 }
593 }
594 else
595 {
596 labelText = "Waiting for statechart group to start";
597 changeToWaiting = true;
598 }
599 }
600 catch (const Ice::Exception& e)
601 {
602 labelText = "Waiting for statechart group to start (ice-exception catched)";
603 changeToWaiting = true;
604 }
605
606 catch (...)
607 {
608 labelText = "Waiting for statechart group to start (exception catched)";
609 changeToWaiting = true;
610 }
611
612 if (!changeToWaiting)
613 {
614 labelText = "Statechart group is running";
615 if (editor->getUI()->toolButtonWatchStateExecution->isChecked() &&
616 !alreadyWatchingState)
617 {
618 watchState(objName);
619 }
620 }
621 }
622 QMetaObject::invokeMethod(editor->getUI()->labelExecutionState,
623 "setText",
624 Qt::QueuedConnection,
625 Q_ARG(QString, labelText));
626 // editor->getUI()->labelExecutionState->setText(labelText);
627 }
628
629 void
630 StatechartEditorController::watchState(const std::string& objName)
631 {
632 RemoteStateOffererInterfacePrx statechartHandler =
633 getProxy<RemoteStateOffererInterfacePrx>(objName, false, "", false);
634 // ARMARX_INFO << deactivateSpam(4) << "getting proxy for " << objName;
635 StatechartView* view = editor->getUI()->stateTabWidget->currentStateview();
636 if (view)
637 {
638 std::string globalStateName =
639 "TopLevel->" +
640 view->getStateInstance()->getStateClass()->getStateName().toStdString();
641 QMap<QString, StateInstanceData> instanceData =
642 view->getScene()->getStateInstanceData();
643 auto toplevelPathString = view->getScene()->getTopLevelStateItem()->getFullStatePath();
644 auto asyncResult =
645 statechartHandler->begin_getStatechartInstanceByGlobalIdStr(globalStateName);
646 while (!asyncResult->isCompleted())
647 {
648 if (getState() >= eManagedIceObjectExiting)
649 {
650 return;
651 }
652 usleep(10000);
653 // qApp->processEvents();
654 }
655 armarx::StateIceBasePtr stateptr =
656 statechartHandler->end_getStatechartInstanceByGlobalIdStr(asyncResult);
657 if (!stateptr)
658 {
659 // ARMARX_WARNING_S << deactivateSpam(4) << "Could not find state with name " << globalStateName;
660 }
661 else
662 {
663
664
665 std::function<void(StateIceBasePtr iceState, StateItem * state)> subscriptionLamba;
666 subscriptionLamba = [&](StateIceBasePtr iceState, StateItem* state)
667 {
668 stateWatcher->subscribeToState(iceState, state);
669 size_t i = 0;
670 for (auto stateInstance : state->getSubstateItems())
671 {
672 if (stateInstance->getStateInstance()->getStateClass() &&
673 iceState->subStateList.size() > i)
674 {
675 subscriptionLamba(
676 StateIceBasePtr::dynamicCast(iceState->subStateList.at(i)),
677 stateInstance);
678 }
679 i++;
680 }
681 };
682 subscriptionLamba(stateptr, view->getScene()->getTopLevelStateItem());
683
684 alreadyWatchingState = true;
685 }
686 }
687 }
688
689 QPointer<QWidget>
691 {
692 if (!editor)
693 {
694 // QWidget* w = qobject_cast<QWidget*>(new StatechartEditorMainWindow());
695 editor = new StatechartEditorMainWindow();
696 }
697
698 return qobject_cast<QWidget*>(editor);
699 }
700
701 void
702 StatechartEditorController::initWidget()
703 {
704 getWidget()->setFocusPolicy(Qt::WheelFocus);
705
706
707 ARMARX_INFO << "selectedProfile: " << config.selectedProfile->getFullName();
708 ARMARX_INFO << "profile packages: " << config.selectedProfile->getAllPackages();
709 variantInfo = VariantInfo::ReadInfoFiles(
710 {"ArmarXCore"},
711 true,
712 false); // read core variantinfo file in case the root profile is selected
713 for (const auto& eventuallyNamespacedPackage : config.selectedProfile->getAllPackages())
714 {
716 eventuallyNamespacedPackage, "", true, variantInfo);
717 }
718 editor->setCommunicator(getIceManager()->getCommunicator());
719 editor->setVariantInfo(variantInfo);
720 editor->setCurrentProfile(config.selectedProfile);
721 editor->getUI()->toolBarViewControl->addWidget(new QLabel(
722 QString::fromStdString("Selected Profile: " + config.selectedProfile->getFullName())));
723 editor->getUI()->toolBarViewControl->insertWidget(
724 editor->getUI()->actionEdit_State_Properties, new QLabel("Active State:"));
725
726 QList<QVariant> header;
727 header.push_back(QString("TEST"));
728 treeController.reset(new StateTreeController(getIceManager()->getCommunicator(),
729 variantInfo,
730 header,
731 editor->getUI()->treeViewGroups,
732 editor->getUI()->lineEditStateSearch,
733 packageTool,
734 profiles,
735 config.selectedProfile,
736 this));
737
738
739 QStringList searchPaths;
740 if (config.openAllStatesWasSelected)
741 {
742 for (std::string eventuallyNamespacedPackage : config.selectedProfile->getAllPackages())
743 {
744 // check for namespaced package
745 const auto elements = simox::alg::split(eventuallyNamespacedPackage, "::");
746 ARMARX_IMPORTANT << VAROUT(elements);
747
748 const std::string cmakePackageName =
749 simox::alg::replace_all(eventuallyNamespacedPackage, "::", "_");
750
751 for (const auto& includePath :
752 CMakePackageFinder(cmakePackageName).getIncludePathList())
753 {
754 ARMARX_IMPORTANT << VAROUT(includePath);
755
756 if (elements.size() == 1) // standard packages
757 {
758 std::filesystem::path packageStatechartPath(includePath.c_str());
759 packageStatechartPath /= cmakePackageName;
760 packageStatechartPath /= "statecharts";
761
762 if (std::filesystem::exists(packageStatechartPath) &&
763 !std::filesystem::exists(
764 packageStatechartPath /
765 "cmake_install.cmake")) // do not add the build dir
766 {
767 ARMARX_VERBOSE << "Adding statechart search path: "
768 << packageStatechartPath.string();
769 searchPaths.push_back(packageStatechartPath.c_str());
770 }
771 }
772
773 if (elements.size() == 2) // special handling of namespaced packages
774 {
775 std::filesystem::path packageStatechartPathArmarXPackage(
776 includePath.c_str());
777
778 packageStatechartPathArmarXPackage /= elements.at(0);
779 packageStatechartPathArmarXPackage /= elements.at(1);
780 packageStatechartPathArmarXPackage /= "statecharts";
781
782 ARMARX_IMPORTANT << VAROUT(packageStatechartPathArmarXPackage);
783
784 if (std::filesystem::exists(packageStatechartPathArmarXPackage) &&
785 !std::filesystem::exists(
786 packageStatechartPathArmarXPackage /
787 "cmake_install.cmake")) // do not add the build dir
788 {
789 ARMARX_IMPORTANT << "Adding statechart search path: "
790 << packageStatechartPathArmarXPackage.string();
791 searchPaths.push_back(packageStatechartPathArmarXPackage.c_str());
792 }
793 }
794 }
795 }
796 }
797 config.searchPaths.removeDuplicates();
798
799
800 connect(editor->getUI()->actionNew_State_Definition,
801 SIGNAL(triggered()),
802 treeController.get(),
803 SLOT(onNewStateDefinition()));
804 connect(editor->getUI()->actionDelete_State_Definition,
805 SIGNAL(triggered()),
806 treeController.get(),
807 SLOT(onDeleteNode()));
808 connect(editor->getUI()->treeViewGroups,
809 SIGNAL(doubleClicked(QModelIndex)),
810 SLOT(treeviewGroupsDoubleClicked(QModelIndex)));
811 connect(editor->getUI()->actionSave_State, SIGNAL(triggered()), SLOT(requestSave()));
812 connect(editor->getUI()->stateTabWidget,
813 SIGNAL(currentChanged(int)),
814 SLOT(onStateTabChanged(int)));
815 connect(editor->getUI()->actionNew_Statechart_Group,
816 SIGNAL(triggered()),
817 this,
819 connect(editor->getUI()->actionOpenStatechartGroup,
820 SIGNAL(triggered()),
821 treeController.get(),
822 SLOT(onOpenGroup()));
823 connect(editor->getUI()->actionSettings,
824 SIGNAL(triggered()),
825 this,
827 connect(editor->getUI()->toolButtonRunState,
828 SIGNAL(clicked(bool)),
829 this,
830 SLOT(executeOpenedState(bool)));
831
832 connect(treeController.get(), SIGNAL(closeAllTabsRequested()), this, SLOT(closeAllTabs()));
833
834 // setup plugin specific shortcuts
835 editor->getUI()->actionOpenStatechartGroup->setShortcutContext(
836 Qt::WidgetWithChildrenShortcut);
837 editor->getUI()->actionOpenStatechartGroup->setShortcut(tr("Ctrl+O"));
838 getWidget()->addAction(editor->getUI()->actionOpenStatechartGroup);
839
840
841 stateEditorController.reset(new StateEditorController(editor,
842 treeController,
844 variantInfo,
845 config.selectedProfile,
846 getTipDialog()));
847 stateEditorController->setLockRemoteStatesByDefault(config.lockRemoteStates);
848 connect(editor->getUI()->stateTabWidget,
849 SIGNAL(currentChanged(int)),
850 this,
851 SLOT(connectToView(int)),
852 Qt::UniqueConnection);
853 connect(editor->getUI()->radioOnEnter,
854 SIGNAL(clicked()),
855 this,
856 SLOT(showOnEnterFunction()),
857 Qt::UniqueConnection);
858 connect(editor->getUI()->radioOnBreak,
859 SIGNAL(clicked()),
860 this,
861 SLOT(showOnBreakFunction()),
862 Qt::UniqueConnection);
863 connect(editor->getUI()->radioRun,
864 SIGNAL(clicked()),
865 this,
866 SLOT(showRunFunction()),
867 Qt::UniqueConnection);
868 connect(editor->getUI()->radioOnExit,
869 SIGNAL(clicked()),
870 this,
871 SLOT(showOnExitFunction()),
872 Qt::UniqueConnection);
873
874
875 connect(
876 editor->getUI()->btnOpenCppCode, SIGNAL(clicked()), this, SLOT(openSelectedState()));
877
878 watcher = new QFileSystemWatcher(editor);
879 connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(showCodeFileContent(QString)));
880
881 searchAndOpenPaths(config.searchPaths + searchPaths);
882 // OpenStatechartGroups(config.groupsToLoad);
883 // config.groupsToLoad.clear();
884 treeController->collapseAll();
885 executionStatusTask = new PeriodicTask<StatechartEditorController>(
886 this, &StatechartEditorController::updateExecutionButtonStatus, 300);
887 }
888
889 bool
891 {
892 // QSettings s("KIT", "ArmarXStatechartEditor");
893 // saveSettings(&s);
895 }
896
897 void
899 {
901 qobject_cast<StatechartEditorConfigDialog*>(getConfigDialog(getWidget()));
902 config.selectedProfile = dialog->getSelectedProfile();
903 config.openAllStatesWasSelected = dialog->openAllStatesIsSelected();
904 }
905
906} // namespace armarx
907
908QPointer<QDialog>
910{
911 if (!dialog)
912 {
914 Application::getInstance()->getArmarXPackageNames());
915 dialog = new StatechartEditorConfigDialog(profiles, parent);
916 }
917
918 return qobject_cast<StatechartEditorConfigDialog*>(dialog);
919}
uint8_t index
#define VAROUT(x)
static ApplicationPtr getInstance()
Retrieve shared pointer to the application object.
bool onClose() override
If you overwrite this method, make sure to call this implementation at the end of your implementation...
The ArmarXPackageToolInterface class.
QPointer< TipDialog > getTipDialog() const
Returns the default instance for the TipDialog used by all widgets (if not set otherwise).
static int showMessageBox(const QString &msg)
QMap< QString, QString > getConfigurations() const
IceManagerPtr getIceManager() const
Returns the IceManager.
Ice::ObjectPrx getProxy(long timeoutMs=0, bool waitForScheduler=true) const
Returns the proxy of this object (optionally it waits for the proxy)
Ice::CommunicatorPtr getCommunicator() const
int getState() const
Retrieve current state of the ManagedIceObject.
ArmarXManagerPtr getArmarXManager() const
Returns the ArmarX manager used to add and remove components.
static std::string ReadFileContents(const std::string &path)
QVector< StateItem * > getSubstateItems() const
statechartmodel::StateInstancePtr getStateInstance() const
Definition StateItem.h:66
StateItem * getTopLevelStateItem() const
void clearActiveSubstates()
void onInitComponent() override
Pure virtual hook for the subclass.
bool onClose() override
If you overwrite this method, make sure to call this implementation at the end of your implementation...
void onDisconnectComponent() override
Hook for subclass.
void loadSettings(QSettings *settings) override
Implement to load the settings that are part of the GUI configuration.
void saveSettings(QSettings *settings) override
Implement to save the settings as part of the GUI configuration.
void showStateCode(statechartmodel::StateInstancePtr stateInstance)
QStringList findAllStatechartGroupDefinitions(const QString &basePath)
QPointer< QWidget > getWidget() override
getWidget returns a pointer to the a widget of this controller.
void onConnectComponent() override
Pure virtual hook for the subclass.
void configured() override
This function must be implemented by the user, if he supplies a config dialog.
void onExitComponent() override
Hook for subclass.
QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
struct armarx::StatechartEditorController::Config config
static StatechartProfilesPtr ReadProfileFiles(const std::vector< std::string > &packages)
void showSubSubstates(bool show=true)
statechartmodel::StateInstancePtr getStateInstance() const
StateScene * getScene() const
static VariantInfoPtr ReadInfoFilesRecursive(const std::string &rootPackageName, const std::string &rootPackagePath, bool showErrors, VariantInfoPtr variantInfo=VariantInfoPtr())
static VariantInfoPtr ReadInfoFiles(const std::vector< std::string > &packages, bool showErrors=true, bool throwOnError=true)
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
std::shared_ptr< State > StatePtr
Definition State.h:48
std::shared_ptr< StateInstance > StateInstancePtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< StatechartGroup > StatechartGroupPtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr