StateTreeController.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  */
24 #include "StateTreeController.h"
25 
28 
29 
30 #include "io/GroupXmlWriter.h"
31 #include "io/XmlWriter.h"
32 
37 #include "io/GroupXmlReader.h"
38 #include "io/GroupXmlWriter.h"
39 #include "../StatechartViewerPlugin/model/DynamicRemoteStateClass.h"
45 #include <QIcon>
46 #include <QInputDialog>
47 #include <QMessageBox>
48 #include <QtGui>
49 #include <QProgressDialog>
50 #include <QMenu>
51 #include <QFileDialog>
52 #include <QLabel>
53 #include <QDialogButtonBox>
54 #include <QCheckBox>
55 #include <QBoxLayout>
56 
57 #include <filesystem>
58 
59 using namespace armarx;
60 using namespace statechartio;
61 using namespace statechartmodel;
62 
63 StateTreeController::StateTreeController(Ice::CommunicatorPtr ic, VariantInfoPtr variantInfo, QList<QVariant> headerInfo, QTreeView* treeView, QLineEdit* filterLineEdit, const ArmarXPackageToolInterfacePtr& packageTool, const StatechartProfilesPtr& statechartProfiles, StatechartProfilePtr currentProfile, QObject* parent)
64  : QAbstractItemModel(parent)
65 {
66  qRegisterMetaType<StateTreeNodePtr>("StateTreeNodePtr");
67  CMakePackageFinder finder("ArmarXCore");
68  this->appForDrag.reset(
70  "XMLRemoteStateOffererRun",
71  finder.getBinaryDir(),
72  "ArmarXCore"
73  ));
74  this->variantInfo = variantInfo;
75  this->profiles = statechartProfiles;
76  this->currentProfile = currentProfile;
77  this->packageTool = packageTool;
78  this->headerInfo = headerInfo;
79  this->treeView = treeView;
80  this->stateTreeModel.reset(new StateTreeModel(ic, variantInfo));
81  this->rootNode = this->stateTreeModel->getRootNode();
82  this->groupCloner = std::make_shared<GroupCloner>(stateTreeModel, packageTool);
83  this->groupRenamer = std::make_shared<GroupRenamer>(groupCloner);
84  this->communicator = ic;
85 
86 
87  proxyModel = new InfixFilterModel(this);
88  proxyModel->setSourceModel(this);
89  proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
90  treeView->setModel(proxyModel);
91 
92 
93  contextMenuGroup = new QMenu(treeView);
94  contextMenuFolder = new QMenu(treeView);
95  contextMenuState = new QMenu(treeView);
96  treeView->setContextMenuPolicy(Qt::CustomContextMenu);
97 
98  actionDeleteNode = new QAction(QIcon(":/icons/delete.ico"), "Delete", treeView);
99  actionMakeStatePublic = new QAction("Public State", treeView);
100  actionMakeStatePublic->setCheckable(true);
101  actionNewFolder = new QAction(QIcon(":/icons/folder-new.svg"), "Add new Folder", treeView);
102  actionNewStateDefinition = new QAction(QIcon(":/icons/images/add-state.png"), "Add new State Definition", treeView);
103  actionNewDynamicRemoteStateDefinition = new QAction("Add new Dynamic Remote State Definition", treeView);
104  actionFindStateUsages = new QAction(QIcon(":/icons/search.svg"), "Find State Usages", treeView);
105  actionRenameState = new QAction(QIcon(":/icons/rename.svg"), "Rename State", treeView);
106  actionOpenCMakeProject = new QAction(QIcon(":/icons/qt-small.png"), "Open CMake Project", treeView);
107  actionShowFullPath = new QAction(QIcon(":/icons/search.svg"), "Show Full Path", treeView);
108  actionOpenStateCPP = new QAction(QIcon(":/icons/cpp.svg"), "Open C++ Code", treeView);
109  actionExecuteGroup = new QAction(QIcon(":/icons/run.svg"), "Execute Statechart Group", treeView);
110  //actionGenerateStateBaseClass = new QAction(QIcon(":/icons/document-properties.svg"), "Generate Base Class", treeView);
111  //actionGenerateRsoBaseClass = new QAction(QIcon(":/icons/document-properties.svg"), "Generate RSO Base Class", treeView);
112  actionGenerateStateCPP = new QAction(QIcon(":/icons/document-properties.svg"), "Generate State C++ Files", treeView);
113  actionRenameGroup = new QAction(QIcon(":/icons/rename.svg"), "Rename Group", treeView);
114  actionCloneGroup = new QAction(QIcon(":/icons/clone.svg"), "Clone Group", treeView);
115  actionGroupProperties = new QAction(QIcon(":/icons/document-properties.svg"), "Group Properties", treeView);
116 
117  QList<QAction*> groupActions, folderActions, stateActions;
118 
119  groupActions.append(actionNewStateDefinition);
120  groupActions.append(actionNewDynamicRemoteStateDefinition);
121  groupActions.append(actionNewFolder);
122  groupActions.append(actionDeleteNode);
123  groupActions.append(actionOpenCMakeProject);
124  groupActions.append(actionShowFullPath);
125  groupActions.append(actionExecuteGroup);
126  //groupActions.append(actionGenerateRsoBaseClass);
127  groupActions.append(actionRenameGroup);
128  groupActions.append(actionCloneGroup);
129  groupActions.append(actionGroupProperties);
130 
131  folderActions.append(actionNewStateDefinition);
132  folderActions.append(actionNewDynamicRemoteStateDefinition);
133  folderActions.append(actionNewFolder);
134  folderActions.append(actionDeleteNode);
135 
136  stateActions.append(actionMakeStatePublic);
137  stateActions.append(actionFindStateUsages);
138  stateActions.append(actionRenameState);
139  stateActions.append(actionDeleteNode);
140  stateActions.append(actionOpenStateCPP);
141  //stateActions.append(actionGenerateStateBaseClass);
142  stateActions.append(actionGenerateStateCPP);
143 
144  for (QAction* a : groupActions)
145  {
146  a->setIconVisibleInMenu(true);
147  }
148 
149  for (QAction* a : folderActions)
150  {
151  a->setIconVisibleInMenu(true);
152  }
153 
154  for (QAction* a : stateActions)
155  {
156  a->setIconVisibleInMenu(true);
157  }
158 
159  contextMenuGroup->addActions(groupActions);
160  contextMenuFolder->addActions(folderActions);
161  contextMenuState->addActions(stateActions);
162 
163 
164  connect(stateTreeModel.get(), SIGNAL(stateAddedOrRemoved()), SLOT(stateAddedOrRemoved()));
165  connect(treeView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(onContextMenu(QPoint)));
166 
167  connect(actionNewStateDefinition, SIGNAL(triggered()), SLOT(onNewStateDefinition()));
168  connect(actionNewDynamicRemoteStateDefinition, SIGNAL(triggered()), SLOT(onNewDynamicRemoteStateDefinition()));
169  connect(actionDeleteNode, SIGNAL(triggered()), SLOT(onDeleteNode()));
170  connect(actionMakeStatePublic, SIGNAL(triggered(bool)), SLOT(onMakeStatePublic(bool)));
171  connect(actionNewFolder, SIGNAL(triggered()), SLOT(onNewFolder()));
172  connect(actionFindStateUsages, SIGNAL(triggered()), SLOT(onFindStateUsages()));
173  connect(actionRenameState, SIGNAL(triggered()), SLOT(onRenameState()));
174  connect(actionOpenCMakeProject, SIGNAL(triggered()), this, SLOT(onOpenCMakeProject()));
175  connect(actionShowFullPath, SIGNAL(triggered()), this, SLOT(onShowFullPath()));
176  connect(actionOpenStateCPP, SIGNAL(triggered()), this, SLOT(onOpenStateCPP()));
177  connect(actionExecuteGroup, SIGNAL(triggered()), this, SLOT(onExecuteGroup()));
178  //connect(actionGenerateStateBaseClass, SIGNAL(triggered()), this, SLOT(onGenerateStateBaseClass()));
179  connect(actionGenerateStateCPP, SIGNAL(triggered()), this, SLOT(onGenerateStateCppFiles()));
180  //connect(actionGenerateRsoBaseClass, SIGNAL(triggered()), this, SLOT(onGenerateRsoBaseClass()));
181  connect(actionRenameGroup, SIGNAL(triggered()), this, SLOT(onRenameGroup()));
182  connect(actionCloneGroup, SIGNAL(triggered()), this, SLOT(onCloneGroup()));
183  connect(actionGroupProperties, SIGNAL(triggered()), this, SLOT(onGroupProperties()));
184 
185  connect(filterLineEdit, SIGNAL(textChanged(QString)), proxyModel, SLOT(setFilterFixedString(QString)));
186  connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(expandFilterResults(QString)));
187 }
188 
190 {
191  //delete rootNode;
192  ARMARX_INFO << "Killing " << processes.size() << " statechart processes";
193  for (auto& process : processes)
194  {
195  ARMARX_INFO << "stopping " << process->pid();
196  process-> terminate();
197  }
198  for (auto& process : processes)
199  {
200  ARMARX_INFO << "Waiting for process " << process->pid();
201  process->waitForFinished(2000);
202  }
203  for (auto& process : processes)
204  {
205  if (process->pid() > 0)
206  {
207  ARMARX_INFO << "killing " << process->pid();
208  process->kill();
209  }
210  }
211 
212 }
213 
214 QVariant StateTreeController::data(const QModelIndex& index, int role) const
215 {
216  if (!index.isValid())
217  {
218  return QVariant();
219  }
220 
221  StateTreeNodePtr node = getNode(index); //static_cast<StateTreeNode*>(index.internalPointer());
222 
223  switch (role)
224  {
225  case Qt::DisplayRole:
226  if (node->getNodeType() == StateTreeNode::State)
227  {
228  return node->getDisplay()
229  + (node->getState() ? "" : " [no .xml]")
230  + (node->getCppExists() ? "" : " [no .cpp]")
231  + (node->isPublic() ? " (public)" : "")
232  + (node->getGroup()->getWriteAccess() == StatechartGroup::eReadOnly ? " (read-only)" : "");
233  }
234  else
235  {
236  return node->getDisplay();
237  }
238 
239  case Qt::DecorationRole:
240  if (node->getNodeType() == StateTreeNode::Folder || node->getNodeType() == StateTreeNode::Group)
241  {
242  if (node->getGroup()->getWriteAccess() == StatechartGroup::eReadOnly)
243  {
244  return getIcon(":/icons/folder-locked.svg");
245  }
246  if (treeView->isExpanded(index))
247  {
248  return getIcon(":/icons/folder-open.svg");
249  }
250  else
251  {
252  return getIcon(":/icons/folder.svg");
253  }
254  }
255  else if (node->getNodeType() == StateTreeNode::State)
256  {
257  if (node->getState())
258  {
259  if (node->getState()->getSubstates().count() > 0)
260  {
261  return getIcon(node->isPublic() ? ":/statechart-editor/states-public.svg" : ":/statechart-editor/states.svg");
262  }
263  else
264  {
265  return getIcon(node->isPublic() ? ":/statechart-editor/state-public.svg" : ":/statechart-editor/state.svg");
266  }
267  }
268  else
269  {
270  return getIcon(":/statechart-editor/state-broken.svg");
271  }
272  }
273 
274  return QVariant();
275 
276  case Qt::ToolTipRole:
277 
278  return QString::fromStdString(node->getAbsoluteBoostPath().string());
279 
280  default:
281  return QVariant();
282  }
283 
284 }
285 
286 Qt::ItemFlags StateTreeController::flags(const QModelIndex& index) const
287 {
288  if (!index.isValid())
289  {
290  return 0;
291  }
292 
293  Qt::ItemFlags flags;
295  flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
296 
297  if (node)
298  {
299  if (node->getState() || node->isGroup())
300  {
301  flags |= Qt::ItemIsDragEnabled;
302  }
303  }
304 
305  return flags;
306 }
307 
308 QVariant StateTreeController::headerData(int section, Qt::Orientation orientation, int role) const
309 {
310  if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
311  {
312  return headerInfo.value(section);
313  }
314 
315  return QVariant();
316 }
317 
318 QModelIndex StateTreeController::index(int row, int column, const QModelIndex& parentIndex) const
319 {
320  if (!hasIndex(row, column, parentIndex))
321  {
322  return QModelIndex();
323  }
324 
325  StateTreeNode* parentNode;
326 
327  if (!parentIndex.isValid())
328  {
329  parentNode = this->rootNode.get();
330  }
331  else
332  {
333  parentNode = static_cast<StateTreeNode*>(parentIndex.internalPointer());
334  }
335 
336  StateTreeNode* childNode = parentNode->child(row).get();
337 
338  if (childNode)
339  {
340  return createIndex(row, column, childNode);
341  }
342  else
343  {
344  return QModelIndex();
345  }
346 }
347 
348 QModelIndex StateTreeController::parent(const QModelIndex& index) const
349 {
350  if (!index.isValid())
351  {
352  return QModelIndex();
353  }
354 
355  StateTreeNode* childNode = static_cast<StateTreeNode*>(index.internalPointer());
356  StateTreeNodePtr parentNode = childNode->getParent();
357 
358  if (parentNode == rootNode)
359  {
360  return QModelIndex();
361  }
362 
363  return createIndex(parentNode->row(), 0, parentNode.get());
364 }
365 
366 int StateTreeController::rowCount(const QModelIndex& parent) const
367 {
368  //StatechartGroupTreeNode *parentNode;
369  if (parent.column() > 0)
370  {
371  return 0;
372  }
373 
374  if (!parent.isValid())
375  {
376  return rootNode->childCount();
377  }
378  else
379  {
380  ARMARX_CHECK_EXPRESSION(parent.internalPointer()) << "The internal pointer of a tree node is zero";
381  return static_cast<StateTreeNode*>(parent.internalPointer())->childCount();
382  }
383 
384  //return parentNode->childCount();
385 }
386 
387 int StateTreeController::columnCount(const QModelIndex& parent) const
388 {
389  if (parent.isValid())
390  {
391  return static_cast<StateTreeNode*>(parent.internalPointer())->columnCount();
392  }
393  else
394  {
395  return rootNode->columnCount();
396  }
397 }
398 
400 {
401  bool load = !groupDefinitionFile.isEmpty();
402  if (!load)
403  {
404  QFileDialog selectGroupFile(treeView, "Open Statechart Group");
405  // selectFolder.setOption(QFileDialog::ShowDirsOnly, true);
406  selectGroupFile.setOption(QFileDialog::ReadOnly, true);
407  selectGroupFile.setOption(QFileDialog::HideNameFilterDetails, false);
408  selectGroupFile.setFileMode(QFileDialog::ExistingFile);
409  QList<QUrl> urls;
410  urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation))
411  << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation));
412 
414  {
415  urls << QUrl::fromLocalFile(QString::fromStdString(ArmarXDataPath::getHomePath()));
416  }
417 
418  selectGroupFile.setSidebarUrls(urls);
419  QStringList filters;
420  filters << "Statechart Group (*.scgxml)";
421  filters << "All Files(*.*)";
422  selectGroupFile.setNameFilters(filters);
423  load = selectGroupFile.exec() == QDialog::Accepted;
424  if (load && groupDefinitionFile.isEmpty())
425  {
426  groupDefinitionFile = selectGroupFile.selectedFiles().first();
427  }
428  }
429 
430  StatechartGroupPtr group;
431  if (load)
432  {
433  try
434  {
435  group = loadGroup(groupDefinitionFile);
436 
437  if (!group)
438  {
439  return group;
440  }
441 
442  try
443  {
444  stateTreeModel->loadGroupStates(group);
445  }
446  catch (std::exception& e)
447  {
448  QString reason(QString::fromStdString(e.what()));
449  reason.truncate(200);
450  ARMARX_WARNING_S << "Exception caught: " << e.what();
451  QMessageBox::warning(0, "Error while loading States", QString("An error while loading states - Reason:\n" + reason));
452  }
453  }
454  catch (std::exception& e)
455  {
456  QString reason = QString::fromStdString(e.what());
457  reason.truncate(200);
458  QMessageBox::warning(0, "Error while loading Statechart Group", QString("An error while loading the statechart group file '") + groupDefinitionFile + "' - Reason:\n" + reason);
459  }
460  }
461 
462  return group;
463 }
464 
466 {
467  //StatechartGroupTreeNodePtr root = treeController->getRoot();
468  //beginInsertRows(getIndex(rootNode), rowCount(), rowCount());
469 
470  this->layoutAboutToBeChanged();
471  StatechartGroupPtr group = stateTreeModel->loadGroup(groupDefinitionFile, rootNode);
472 
473  if (!group)
474  {
475  return group;
476  }
477 
478  rootNode->appendChild(group->getRootNode());
479  rootNode->sortChildren();
480  //endInsertRows();
481  this->layoutChanged();
482 
483  StateTreeNodePtr groupNode = group->getRootNode();
484  treeView->expand(getIndex(groupNode));
485  treeView->setCurrentIndex(getIndex(groupNode));
486 
487  return group;
488 }
489 
490 StatechartGroupPtr StateTreeController::addNewGroup(const QString& groupName, const QString& groupPath, const QString& description, const QString& packageName, const QList<QString> proxies, bool generateContext, const QMap<QString, QString>& statechartGroupConfigurations)
491 {
492  beginInsertRows(getIndex(rootNode), rowCount(), rowCount());
493  std::filesystem::path defPath = groupPath.toUtf8().data();
494  defPath /= (groupName + ".scgxml").toUtf8().data();
495  StatechartGroupPtr group(new StatechartGroup(QString::fromUtf8(defPath.c_str()), groupPath, groupName, description, packageName, proxies, generateContext, statechartGroupConfigurations, StatechartGroup::eWritable));
496  StateTreeNodePtr groupRootNode(new StateTreeNode(group->getName(), "", StateTreeNode::Group, rootNode, group, false));
497  group->setRootNode(groupRootNode);
498 
499  stateTreeModel->addGroup(group);
500  rootNode->appendChild(group->getRootNode());
501  endInsertRows();
502  rootNode->sortChildren();
503 
504  // emit dataChanged(getIndex(group->getRootNode()),getIndex(group->getRootNode()));
505 
506  QMetaObject::invokeMethod(this, "selectNode", Qt::QueuedConnection, Q_ARG(StateTreeNodePtr, group->getRootNode()));
507 
508  return group;
509 }
510 
512 {
513  stateTreeModel->loadAllStates();
514 }
515 
517 {
518  return stateTreeModel->getNodeByState(state);
519 }
520 
522 {
523  QModelIndex selected = treeView->currentIndex();
524 
525  if (!selected.isValid())
526  {
527  return StateTreeNodePtr();
528  }
529 
530  return getNode(selected);
531 }
532 
534 {
535  return node ? node->getClosestParentFolderOrGroupNode() : StateTreeNodePtr();
536 }
537 
539 {
540  return node ? node->getNodeType() == StateTreeNode::State : false;
541 }
542 
544 {
545  return node ? node->getNodeType() == StateTreeNode::Folder : false;
546 }
547 
549 {
550  return node ? node->getNodeType() == StateTreeNode::Group : false;
551 }
552 
554 {
555  return node ? node->getNodeType() == StateTreeNode::Folder || node->getNodeType() == StateTreeNode::Group : false;
556 }
557 
559 {
560  return nodeIsState(getSelectedNode());
561 }
562 
564 {
565  return nodeIsFolder(getSelectedNode());
566 }
567 
569 {
570  return nodeIsGroup(getSelectedNode());
571 }
572 
574 {
576 }
577 
579 {
581 
582  if (!nodeIsFolderOrGroup(node))
583  {
584  return StateTreeNodePtr();
585  }
586 
587  return createNewState(name, node);
588 }
589 
591 {
593 
594  if (!nodeIsState(node))
595  {
596  return;
597  }
598 
599  QList<StateInstancePtr> instances = stateTreeModel->findStateUsages(node);
600 
601  if (instances.count() > 0)
602  {
603  QString message = QString("Cannot delete state, it is still being used by %1 state(s):\n%2")
604  .arg(instances.count()).arg(buildStateUsageString(instances));
605  QMessageBox::warning(NULL, "Cannot delete State", message);
606  return;
607  }
608 
609  if (node->getState())
610  {
611  QString question = QString("You are about to delete the State Definition '%1'.\nDo you also want to permanently remove the underlying file %2?")
612  .arg(node->getDisplay(), node->getBasename());
613  QMessageBox::StandardButton reply = QMessageBox::question(NULL, "Delete State Definition File?", question, QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
614 
615  if (reply == QMessageBox::Cancel)
616  {
617  return;
618  }
619  else if (reply == QMessageBox::Yes)
620  {
621  std::filesystem::remove(node->getAbsoluteBoostPath());
622  if (node->getCppExists())
623  {
624  std::filesystem::remove(node->getBoostCppFilePath());
625  std::filesystem::remove(node->getBoostHFilePath());
626  std::filesystem::remove(node->getBoostGeneratedHFilePath());
627  }
628  }
629  }
630  else
631  {
632  QString question = QString("Remove State Definition '%1'?").arg(node->getDisplay());
633  QMessageBox::StandardButton reply = QMessageBox::question(NULL, "Delete State Definition?", question, QMessageBox::Ok | QMessageBox::Cancel);
634 
635  if (reply == QMessageBox::Cancel)
636  {
637  return;
638  }
639  }
640 
641  removeState(node);
642  GroupXmlWriter::WriteXml(node->getGroup(), QString::fromUtf8((node->getGroup()->getBoostDefinitionFilePath()).c_str()));
643 }
644 
645 StateTreeNodePtr StateTreeController::createNewState(QString name, StateTreeNodePtr parent, bool createDynamicRemoteState)
646 {
647  this->layoutAboutToBeChanged();
648 
650 
651  if (!createDynamicRemoteState)
652  {
653  state.reset(new statechartmodel::State());
654  state->addEndSubstate("Success", "Success");
655  state->addEndSubstate("Failure", "Failure");
657  evt->name = "Failure";
658  evt->description = "Event for statechart-internal failures or optionally user-code failures";
659  state->setOutgoingEvents(EventList {evt});
660  }
661  else
662  {
663  state.reset(new statechartmodel::DynamicRemoteStateClass());
664  }
665 
666 
667  state->setStateName(name);
668  state->setEditable(parent->getGroup()->getWriteAccess() == StatechartGroup::eWritable);
669  StateTreeNodePtr node(new StateTreeNode(name, name + ".xml", StateTreeNode::State, parent, parent->getGroup(), false));
670  stateTreeModel->setNodeState(node, state);
671  parent->appendChild(node);
672  parent->sortChildren();
673  stateTreeModel->notifyNewStateTreeNode(node);
674  this->layoutChanged();
675  treeView->sortByColumn(0, Qt::AscendingOrder);
676 
677  QMetaObject::invokeMethod(this, "selectNode", Qt::QueuedConnection, Q_ARG(StateTreeNodePtr, node));
678 
679  return node;
680 }
681 
683 {
684  this->layoutAboutToBeChanged();
685  StateTreeNodePtr node(new StateTreeNode(name, name, StateTreeNode::Folder, parent, parent->getGroup(), false));
686  parent->appendChild(node);
687  parent->sortChildren();
688 
689  this->layoutChanged();
690 
691  treeView->expand(getIndex(parent));
692  treeView->setCurrentIndex(getIndex(node));
693 
694  return node;
695 }
696 
698 {
699  if (!index.isValid())
700  {
701  return rootNode;
702  }
703  else
704  {
705  if (index.model() == proxyModel)
706  {
707  index = proxyModel->mapToSource(index);
708  }
709  return static_cast<StateTreeNode*>(index.internalPointer())->shared_from_this();
710  }
711 }
712 
714 {
715  StateTreeNodePtr node = stateTreeModel->getNodeByState(state);
716 
717  if (node)
718  {
719  treeView->setCurrentIndex(proxyModel->mapFromSource(getIndex(node)));
720  }
721 }
722 
723 void StateTreeController::onContextMenu(const QPoint& point)
724 {
725  QModelIndex index = treeView->indexAt(point);
726  // index = this->index(index.row(), index.column(), index.parent());
727  // if(!index.isValid())
728  // {
729  // return;
730  // }
731  // StateTreeNodePtr node = static_cast<StateTreeNode*>(index.internalPointer())->shared_from_this();
733 
734  // reset to initial state
735  actionMakeStatePublic->setEnabled(true);
736  actionRenameState->setEnabled(true);
737  actionRenameGroup->setEnabled(true);
738  actionGenerateStateCPP->setEnabled(true);
739  actionNewFolder->setEnabled(true);
740  actionNewStateDefinition->setEnabled(true);
741  actionNewDynamicRemoteStateDefinition->setEnabled(true);
742  actionOpenCMakeProject->setEnabled(true);
743  actionOpenStateCPP->setEnabled(true);
744  actionGroupProperties->setEnabled(true);
745  actionDeleteNode->setEnabled(true);
746 
747  auto applyReadOnlyStatusToMenu = [&, this]()
748  {
749 
750  bool writable = node->getGroup() && node->getGroup()->getWriteAccess() == StatechartGroup::eWritable;
751 
752  if (!writable)
753  {
754  actionMakeStatePublic->setEnabled(writable);
755  actionRenameState->setEnabled(writable);
756  actionRenameGroup->setEnabled(writable);
757  actionGenerateStateCPP->setEnabled(writable);
758  actionNewFolder->setEnabled(writable);
759  actionNewStateDefinition->setEnabled(writable);
760  actionNewDynamicRemoteStateDefinition->setEnabled(writable);
761  actionOpenCMakeProject->setEnabled(writable);
762  actionOpenStateCPP->setEnabled(writable);
763  actionGroupProperties->setEnabled(writable);
764  actionDeleteNode->setEnabled(writable);
765  }
766  };
767 
768 
769  if (node->isState())
770  {
771  actionMakeStatePublic->setEnabled(node->getState() != NULL);
772  actionMakeStatePublic->setChecked(node->isPublic());
773  actionFindStateUsages->setEnabled(node->getState() != NULL);
774  actionRenameState->setEnabled(node->isState());
775  actionGenerateStateCPP->setEnabled(!node->getCppExists() && node->getState()->getType() == eNormalState);
776  actionOpenStateCPP->setEnabled(node->getCppExists());
777  applyReadOnlyStatusToMenu();
778  contextMenuState->exec(treeView->mapToGlobal(point));
779  }
780  else if (node->isGroup())
781  {
782  // @@@ Buggy implementation: if process is stopped while context menu is open a new process is started. Better: use 2 different context menu entries and 2 differend handler functions.
783  QMap<QString, QProcess*>::const_iterator it;
784 
785  if (node->getGroup() // @@@ check not needed, every node has a group
786  && (it = processes.find(node->getGroup()->getGroupPath())) != processes.end()
787  && it.value()->state() != QProcess::NotRunning)
788  {
789  actionExecuteGroup->setText("Stop and Execute Statechart Group");
790  }
791  else
792  {
793  actionExecuteGroup->setText("Execute Statechart Group");
794  }
795  applyReadOnlyStatusToMenu();
796  contextMenuGroup->exec(treeView->mapToGlobal(point));
797  }
798  else if (node->isFolder() && node != rootNode)
799  {
800  applyReadOnlyStatusToMenu();
801  contextMenuFolder->exec(treeView->mapToGlobal(point));
802  }
803 
804 
805 }
806 
807 struct StateCreationDialog : public QDialog
808 {
809  QCheckBox* checkbox;
810  QLabel* label;
811  QLineEdit* editField;
812  QDialogButtonBox* buttonBox;
813  StateCreationDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0) : QDialog(parent, flags)
814  {
815  label = new QLabel("Enter the state name", this);
816  editField = new QLineEdit(this);
817  QRegExp rx("^([a-zA-Z_]{1})([a-zA-Z_0-9]+)$");
818  QValidator* validator = new QRegExpValidator(rx, this);
819  editField->setValidator(validator);
820  setWindowTitle("New State Definition");
821  resize(250, 120);
822  checkbox = new QCheckBox("Create C++ Files", this);
823  QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
824  buttonBox = new QDialogButtonBox(this);
825  buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
826  buttonBox->setOrientation(Qt::Horizontal);
827  buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
828  layout->addWidget(label);
829  layout->addWidget(editField);
830  layout->addWidget(checkbox);
831  layout->addWidget(buttonBox);
832  QObject::connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
833  QObject::connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
834 
835  }
836 };
837 
838 bool StateTreeController::retrieveNewStateName(QString& newStateName, StateTreeNodePtr& node, bool& createCPPFiles, bool askForCPPFiles)
839 {
840  node = getSelectedNode();
841 
842  if (!node)
843  {
844  QMessageBox::warning(NULL, "Nothing selected", "Error: No state, group or folder selected.");
845  return false;
846  }
847 
848  node = node->getClosestParentFolderOrGroupNode();
849 
850  StateCreationDialog dialog;
851  dialog.checkbox->setEnabled(askForCPPFiles);
852 
853  if (dialog.exec() == QDialog::Rejected)
854  {
855  return false;
856  }
857 
858  newStateName = dialog.editField->text();
859  createCPPFiles = dialog.checkbox->isChecked();
860 
861  if (!StateTreeNode::CheckNodeName(newStateName))
862  {
863  QMessageBox::warning(NULL, "Invalid name", QString("Error: Provided name '%1' does not meet requirements: Has to start with a letter, followed by letters and digits. Sorry.").arg(newStateName));
864  return false;
865  }
866 
867  if (node->getGroup()->findNodeByStateName(newStateName))
868  {
869  QMessageBox::warning(NULL, "Duplicate State Name", QString("Error: State with name '%1' exists already. Sorry.").arg(newStateName));
870  return false;
871  }
872 
873  if (node->getGroup()->getName() == newStateName)
874  {
875  QMessageBox::warning(NULL, "Name Conflict", QString("Error: State cannot have same name as Group. Sorry."));
876  return false;
877  }
878 
879  return true;
880 }
881 
882 QIcon StateTreeController::getIcon(const QString& path) const
883 {
884  if (!icons.contains(path))
885  {
886  icons[path] = QIcon(path);
887  }
888  return icons[path];
889 }
890 
892 {
893  bool createCPPFiles;
894  StateTreeNodePtr node;
895  QString newStateName;
896 
897  if (!retrieveNewStateName(newStateName, node, createCPPFiles, true))
898  {
899  return;
900  }
901 
902 
903  StateTreeNodePtr newState = createNewState(newStateName, node);
904 
905  ARMARX_CHECK_EXPRESSION(packageTool);
906 
907  if (createCPPFiles)
908  {
909  if (!packageTool->addFullXmlStatechart(newState->getGroup()->getName().toUtf8().data(),
910  newState->getBoostPathRelativeToGroup().replace_extension().string(),
911  newState->getGroup()->getPackagePath().toUtf8().data()))
912  {
913  ARMARX_WARNING_S << "Creating source files for state " << newStateName << " failed";
914  }
915  }
916  else
917  {
918  if (!packageTool->addXmlOnlyXmlStatechart(newState->getGroup()->getName().toUtf8().data(),
919  newState->getBoostPathRelativeToGroup().replace_extension().string(),
920  newState->getGroup()->getPackagePath().toUtf8().data()))
921  {
922  ARMARX_WARNING_S << "Creating source files for state " << newStateName << " failed";
923  }
924  }
925 
926  newState->checkCppExists();
927  saveAll();
928 
929 }
930 
932 {
933  bool createCPPFiles;
934  StateTreeNodePtr node;
935  QString newStateName;
936 
937  if (!retrieveNewStateName(newStateName, node, createCPPFiles, false))
938  {
939  return;
940  }
941 
942 
943  createNewState(newStateName, node, true);
944  saveAll();
945 }
946 
948 {
950 
951  if (!node)
952  {
953  QMessageBox::warning(NULL, "Nothing selected", "Error: No state, group or folder selected.");
954  return;
955  }
956 
957  if (!nodeIsFolderOrGroup(node))
958  {
959  QMessageBox::warning(NULL, "Internal error", "Internal error.");
960  return;
961  }
962 
963  bool ok;
964  QString name = QInputDialog::getText(NULL, QString("New Folder"), QString("Enter name"), QLineEdit::Normal, QString(), &ok);
965 
966  if (!ok)
967  {
968  return;
969  }
970 
971  StateTreeNodePtr newFolderNode = createNewFolder(name, node);
972  std::filesystem::create_directory(newFolderNode->getAbsoluteBoostPath());
973 
974 }
975 
977 {
978  if (selectedNodeIsState())
979  {
980  tryDeleteState();
981  return;
982  }
983 
984  if (selectedNodeIsFolder())
985  {
986  tryDeleteFolder();
987  return;
988  }
989 
990  if (selectedNodeIsGroup())
991  {
992  tryDeleteGroup();
993  return;
994  }
995 
996  QMessageBox msgBox;
997  msgBox.setText("Error: No state selected.");
998  msgBox.exec();
999  return;
1000 }
1001 
1003 {
1004  getSelectedNode()->setPublic(enable);
1005  treeView->repaint();
1006 }
1007 
1008 
1009 
1011 {
1012  QList<StateInstancePtr> instances = stateTreeModel->findStateUsages(getSelectedNode());
1013  QMessageBox msgBox;
1014  QString message("Usage count: ");
1015  message += QString::number(instances.count());
1016  message += "\n" + buildStateUsageString(instances);
1017 
1018  msgBox.setText(message);
1019  msgBox.exec();
1020 }
1021 
1023 {
1024  auto node = getSelectedNode();
1025 
1026  if (node && node->isState())
1027  {
1028  statechartmodel::StatePtr state = node->getState();
1029  StatechartGroupPtr group = stateTreeModel->getNodeByState(state)->getGroup();
1030 
1031  RenameStateDialog d(stateTreeModel, group, state);
1032 
1033  if (d.exec() == QDialog::Accepted)
1034  {
1035  if (d.isSaveAllRequested())
1036  {
1037  ARMARX_VERBOSE_S << "Saving all changes first...";
1038  saveAll();
1039  }
1040 
1041  ARMARX_VERBOSE_S << "closing tabs";
1042  emit closeAllTabsRequested();
1043 
1044  ARMARX_VERBOSE_S << "removing groups from tree view";
1045  auto groups = stateTreeModel->getGroups();
1046  stateTreeModel->clear();
1047 
1048  for (const auto& c : rootNode->getChildren())
1049  {
1050  if (c->isGroup())
1051  {
1053  }
1054  }
1055 
1057  {
1058  for (const StatechartGroupPtr& g : groups)
1059  {
1060  ARMARX_VERBOSE_S << "reloading " << g->getName();
1061  auto loadedGroup = loadAndAddGroup(g->getDefinitionFilePath());
1062 
1063  if (loadedGroup->getDefinitionFilePath() == group->getDefinitionFilePath())
1064  {
1065  stateTreeModel->generateBaseClasses(loadedGroup);
1066  }
1067  }
1068  }
1069  else
1070  {
1071  ARMARX_WARNING_S << "Renaming state '" << state->getStateName() << "' to '" << d.getNewStateName() << "' failed";
1072  }
1073  }
1074  }
1075 }
1076 
1078 {
1080 
1081  if (!node)
1082  {
1083  return;
1084  }
1085 
1086  ARMARX_INFO_S << node->getBoostPathRelativeToGroup().string() << " group path: " << node->getGroup()->getGroupPath().toStdString();
1087  EditorFileOpener opener;
1088  opener.openFile("qtcreatorProject", node->getGroup()->getPackagePath().toStdString() + "/CMakeLists.txt");
1089 }
1090 
1092 {
1094 
1095  if (!node)
1096  {
1097  return;
1098  }
1099 
1100  QMessageBox::information(treeView, "Path for Group " + node->getGroup()->getName(), node->getGroup()->getGroupPath());
1101 }
1102 
1104 {
1106 }
1107 
1108 void StateTreeController::onOpenGroup(QString groupFile)
1109 {
1110  loadAndAddGroup(groupFile);
1111 }
1112 
1113 
1114 
1116 {
1117  if (processes.find(group->getGroupPath()) != processes.end())
1118  {
1119  processes[group->getGroupPath()]->terminate();
1120  processes[group->getGroupPath()]->waitForFinished(1000);
1121  processes[group->getGroupPath()]->kill();
1122  processes.remove(group->getGroupPath());
1123  }
1124 }
1125 
1127 {
1128  stopGroupExecution(group);
1129 
1130  if (processes.find(group->getGroupPath()) == processes.end())
1131  {
1132  processes[group->getGroupPath()] = new QProcess(this);
1133  }
1134 
1135 
1136  QProcess* p = processes[group->getGroupPath()];
1137  connect(p, SIGNAL(finished(int)), this, SLOT(onStatechartFinished(int)));
1138  CMakePackageFinder core("ArmarXCore");
1139  QStringList args;
1140  if (!startState.isEmpty())
1141  {
1142  args << "--ArmarX.XMLStateComponent.StatesToEnter=" + startState;
1143  }
1144  args << "--ArmarX.XMLStateComponent.XMLStatechartGroupDefinitionFile=" + group->getDefinitionFilePath();
1145  args << "--ArmarX.XMLStateComponent.XMLStatechartProfile=" + QString::fromStdString(currentProfile->getName());
1146  args << "--ArmarX.XMLStateComponent.ObjectName=" + group->getName() + "StateComponent";
1147  args << "--ArmarX.ApplicationName=" + group->getName() + "StateComponentApp";
1148  QString path = QString::fromStdString(core.getBinaryDir()) + "/XMLRemoteStateOffererRun";
1149  ARMARX_INFO_S << path << " " << args.join(" ").toStdString();
1150 
1151  std::string username;
1152  if (getenv("USER"))
1153  {
1154  username = getenv("USER");
1155  }
1156  std::string tempLogDir = (std::filesystem::temp_directory_path() / ("armarx-" + username) / group->getName().toStdString()).string();
1157  if (!std::filesystem::exists(tempLogDir) && !std::filesystem::create_directories(tempLogDir))
1158  {
1159  ARMARX_WARNING_S << "Could not create log dirs for executing group - aborting";
1160  return;
1161  }
1162  p->setStandardOutputFile(QString::fromStdString(tempLogDir) + "/out.log");
1163  p->setStandardErrorFile(QString::fromStdString(tempLogDir) + "/err.log");
1164  p->setProcessChannelMode(QProcess::MergedChannels);
1165  p->start(path, args);
1166  connect(p, SIGNAL(readyReadStandardOutput()), this, SLOT(processOutputReady()));
1167  connect(p, SIGNAL(readyReadStandardError()), this, SLOT(processErrorsReady()));
1168 }
1169 
1171 {
1172  auto deps = GroupCloner(stateTreeModel, packageTool).getGroupDependencies(group, false);
1173  executeGroup(group, startState);
1174  for (StatechartGroupPtr dep : deps)
1175  {
1176  executeGroup(dep);
1177  }
1178 }
1179 
1181 {
1182  auto deps = GroupCloner(stateTreeModel, packageTool).getGroupDependencies(group, false);
1183  deps.push_back(group);
1184 
1185  for (StatechartGroupPtr dep : deps)
1186  {
1187  if (processes.find(dep->getGroupPath()) != processes.end())
1188  {
1189  processes[dep->getGroupPath()]->terminate();
1190  }
1191  }
1192  auto startTime = IceUtil::Time::now();
1193  for (StatechartGroupPtr dep : deps)
1194  {
1195  if (processes.find(dep->getGroupPath()) != processes.end())
1196  {
1197  auto timeLeftToWait = std::max<int>(0, 1000 - (IceUtil::Time::now() - startTime).toMilliSeconds());
1198  processes[dep->getGroupPath()]->waitForFinished(timeLeftToWait);
1199  processes[dep->getGroupPath()]->kill();
1200  processes.remove(dep->getGroupPath());
1201  }
1202  }
1203 }
1204 
1206 {
1208 
1209  if (!node)
1210  {
1211  return;
1212  }
1213 
1214  QStringList states;
1215  QString noneState("---");
1216  states << noneState ;
1217  for (StateTreeNodePtr curnode : node->getGroup()->getAllNodes())
1218  {
1219  if (curnode->isPublic() && curnode->isState())
1220  {
1221  states << curnode->getState()->getStateName();
1222  }
1223  }
1224  bool ok;
1225  QString startState = QInputDialog::getItem(0, "State", "Select the state to start or none", states, 0, false, &ok);
1226  if (!ok)
1227  {
1228  return;
1229  }
1230  if (startState == noneState)
1231  {
1232  startState = "";
1233  }
1234  StatechartGroupPtr group = node->getGroup();
1235  executeGroupWithDependencies(group, startState);
1236 
1237 
1238  // p->start(QString::fromStdString(core.getBinaryDir()) + "/startApplication.sh", args);
1239  // sleep(2);
1240  // QString p_stdout = p->readAllStandardOutput();
1241  // QString p_stderr = p->readAllStandardError();
1242  // ARMARX_IMPORTANT_S << "Errors:" << p_stderr;
1243  // ARMARX_IMPORTANT_S << "Output: " << p_stdout;
1244 
1245 }
1246 
1248 {
1249  auto process = qobject_cast<QProcess*>(sender());
1250  if (process)
1251  {
1252  ARMARX_INFO_S << process->pid() << " exited with code " << exitCode;
1253  }
1254  else
1255  {
1256  ARMARX_INFO_S << "Exited with code " << exitCode;
1257  }
1258 }
1259 /*
1260 void StateTreeController::onGenerateStateBaseClass()
1261 {
1262  StateTreeNodePtr node = getSelectedNode();
1263 
1264  XmlWriter writer;
1265  writer.serialize(node->getState());
1266  std::string xml = writer.getXmlString(false).toUtf8().data();
1267  std::vector<std::string> namespaces;
1268  namespaces.push_back("armarx");
1269  namespaces.push_back(node->getGroup()->getName().toUtf8().data());
1270 
1271  std::vector<std::string> proxies;
1272  for(QString p : node->getGroup()->getProxies())
1273  {
1274  proxies.push_back(p.toUtf8().data());
1275  }
1276 
1277  std::string cpp = XmlStateBaseClassGenerator::GenerateCpp(namespaces, RapidXmlReader::FromXmlString(xml), proxies, node->getGroup()->contextGenerationEnabled(), node->getGroup()->getName().toUtf8().data(), variantInfo);
1278  //QMessageBox::information(NULL, "test", QString::fromUtf8(cpp.c_str()));
1279 
1280  std::string targetPath(node->getBoostCppFilePath().replace_extension().string() + ".generated.h");
1281  bool identical = false;
1282  if(std::filesystem::exists(std::filesystem::path(targetPath)))
1283  {
1284  std::string currentContents = RapidXmlReader::ReadFileContents(targetPath);
1285  identical = cpp == currentContents;
1286  }
1287  if(!identical)
1288  {
1289  QString qtargetPath = QString::fromUtf8(targetPath.data());
1290  //QMessageBox::information(NULL, "test", qtargetPath);
1291  ARMARX_LOG_S << "Generated file " << targetPath;
1292  GroupXmlWriter::WriteFileContents(qtargetPath, QString::fromUtf8(cpp.data()));
1293  }
1294  else
1295  {
1296  ARMARX_LOG_S << "Skipping identical file " << targetPath;
1297  QMessageBox::information(NULL, "test", "current file and generated output are identical.");
1298  }
1299 
1300 }
1301 
1302 void StateTreeController::onGenerateRsoBaseClass()
1303 {
1304 
1305 }*/
1306 
1308 {
1310 
1311  if (!node || !node->isState())
1312  {
1313  QMessageBox::warning(NULL, "No State selected", "Error: No state selected.");
1314  return;
1315  }
1316 
1317  if (!packageTool->addCppOnlyXmlStatechart(node->getGroup()->getName().toUtf8().data(),
1318  node->getBoostPathRelativeToGroup().replace_extension().string(),
1319  node->getGroup()->getPackagePath().toUtf8().data()))
1320  {
1321  ARMARX_WARNING_S << "Creating source files for state " << node->getBasename() << " failed:\n" << packageTool->getLastOutput();
1322  }
1323 
1324  node->checkCppExists();
1325 }
1326 
1328 {
1330 
1331  if (node && node->isGroup())
1332  {
1333  StatechartGroupPtr group = node->getGroup();
1334 
1335  CloneGroupDialog d(packageTool, group, groupCloner);
1336 
1337  if (d.exec() == QDialog::Accepted)
1338  {
1339  for (const auto& g : d.getGroupsToClone())
1340  {
1341  if (!g.first->existsCMakeLists())
1342  {
1343  QMessageBox::warning(0, "Cloning failed",
1344  g.first->getName() + " at " + g.first->getGroupPath() + " contains no CMakeLists.txt - is it an installed package? Installed packages cannot be cloned.");
1345  return;
1346  }
1347  }
1348 
1349  if (auto newMapping = groupCloner->cloneGroupsTo(d.getGroupsToClone(), d.getPackagePath(), d.getStatechartGroupMapping()))
1350  {
1351  ARMARX_INFO_S << "Cloning successful, creating/overwriting mapping file in package: " << d.getPackagePath();
1352  newMapping.value().writeToFile(d.getPackagePath());
1353 
1354  const QString packageName = QFileInfo(d.getPackagePath()).fileName();
1355 
1356  for (const QPair<StatechartGroupPtr, QString>& g : d.getGroupsToClone())
1357  {
1358  QDir groupDir(d.getPackagePath());
1359  groupDir.cd("source");
1360  groupDir.cd(packageName);
1361  groupDir.cd("statecharts");
1362  groupDir.cd(g.second);
1363  QString newDefFile = groupDir.path() + QDir::separator() + g.second + ".scgxml";
1364  stateTreeModel->generateBaseClasses(loadAndAddGroup(newDefFile));
1365  }
1366  }
1367  }
1368  }
1369 }
1370 
1372 {
1374 
1375  if (node && node->isGroup())
1376  {
1377  StatechartGroupPtr group = node->getGroup();
1378  RenameGroupDialog d(rootNode, stateTreeModel, group, groupRenamer);
1379 
1380  if (d.exec() == QDialog::Accepted)
1381  {
1382  if (d.isSaveAllRequested())
1383  {
1384  ARMARX_VERBOSE_S << "Saving all changes first...";
1385  saveAll();
1386  }
1387 
1388  if (auto newGroupDirPath = groupRenamer->renameGroup(group, d.getNewName(), d.getDependantGroups()))
1389  {
1390  QString newGroupDefinitionPath = *newGroupDirPath + QDir::separator() + d.getNewName() + ".scgxml";
1391 
1392  ARMARX_VERBOSE_S << "closing tabs";
1393  emit closeAllTabsRequested();
1394 
1395  ARMARX_VERBOSE_S << "removing groups from tree view";
1396  stateTreeModel->clear();
1397 
1398  for (const auto& c : rootNode->getChildren())
1399  {
1400  if (c->isGroup())
1401  {
1403  }
1404  }
1405 
1406  for (const StatechartGroupPtr& g : d.getAllGroups())
1407  {
1408  if (g->getGroupPath() == group->getGroupPath())
1409  {
1410  continue;
1411  }
1412 
1413  ARMARX_VERBOSE_S << "reloading " << g->getName();
1414  onOpenGroup(g->getDefinitionFilePath());
1415  }
1416 
1417  onOpenGroup(newGroupDefinitionPath);
1418  }
1419  }
1420  }
1421 }
1422 
1424 {
1426 
1427  if (node && node->isGroup())
1428  {
1429  StatechartGroupPtr group = node->getGroup();
1430  EditStatechartGroupDialog d(EditStatechartGroupDialog::EditGroup, group->getName(), packageTool, variantInfo,
1431  group->getProxies(), group->contextGenerationEnabled(), profiles, group->getConfigurations(), group->getDescription(), group);
1432 
1433  if (d.exec() == QDialog::Accepted)
1434  {
1435  group->setDescription(d.getGroupDescription());
1436  group->setProxies(d.getProxies());
1437  group->setContextGeneration(d.contextGenerationEnabled());
1438  group->setConfigurations(d.getConfigurations());
1439  }
1440  }
1441 }
1442 
1444 {
1445  treeView->collapseAll();
1446 }
1447 
1449 {
1450 
1451  treeView->expand(proxyModel->mapFromSource(getIndex(node->getParent())));
1452  treeView->setCurrentIndex(proxyModel->mapFromSource(getIndex(node)));
1453 }
1454 
1456 {
1457  if (!node->getCppExists())
1458  {
1459  QMessageBox::warning(NULL, "File missing", QString("File '") + node->getBoostCppFilePath().c_str() + "' not found.");
1460  }
1461  else
1462  {
1463  opener.openFileWithDefaultEditor(node->getBoostCppFilePath().c_str());
1464  }
1465 }
1466 
1467 void StateTreeController::processOutputReady()
1468 {
1469  QProcess* p = qobject_cast<QProcess*>(sender());
1470 
1471  if (p)
1472  {
1473  std::cout << QString(p->readAllStandardOutput());
1474  }
1475  else
1476  {
1477  ARMARX_WARNING_S << "cast failed";
1478  }
1479 }
1480 
1481 void StateTreeController::processErrorsReady()
1482 {
1483  QProcess* p = qobject_cast<QProcess*>(sender());
1484 
1485  if (p)
1486  {
1487  std::cerr << QString(p->readAllStandardError());
1488  }
1489  else
1490  {
1491  ARMARX_WARNING_S << "cast failed";
1492  }
1493 
1494 }
1495 
1496 void StateTreeController::stateAddedOrRemoved()
1497 {
1498  std::cout << "StateTreeController::stateAddedOrRemoved()" << std::endl;
1499  treeView->repaint();
1500 }
1501 
1502 void StateTreeController::expandFilterResults(const QString& filterString)
1503 {
1504  if (filterString.length() == 0)
1505  {
1506  return;
1507  }
1508 
1510 
1511 }
1512 
1513 QModelIndex StateTreeController::getIndex(StateTreeNodePtr node)
1514 {
1515  if (!node || node == rootNode || !node->getParent())
1516  {
1517  return QModelIndex();
1518  }
1519 
1520  return createIndex(node->row(), 0, node.get());
1521 }
1522 
1523 QString StateTreeController::buildStateUsageString(QList<StateInstancePtr> instances)
1524 {
1525  QString message;
1526  QListIterator<StateInstancePtr> i(instances);
1527 
1528  while (i.hasNext())
1529  {
1530  StateInstancePtr stateInstance = i.next();
1531  message += stateTreeModel->getNodeByState(stateInstance->getParent())->getGroup()->getName() + "/" + stateInstance->getParent()->getStateName() + ": '" + stateInstance->getInstanceName() + "'\n";
1532  }
1533 
1534  return message.trimmed();
1535 }
1536 
1538 {
1539  removeNodeFromTree(stateNode);
1540  stateTreeModel->notifyDeleteStateTreeNode(stateNode);
1541 }
1542 
1544 {
1546 
1547  if (!nodeIsFolder(node))
1548  {
1549  return;
1550  }
1551 
1552  if (node->getChildren().count() > 0)
1553  {
1554  QMessageBox::warning(NULL, "Folder cannot be deleted.", "Folder cannot be deleted. It is not empty.");
1555  return;
1556  }
1557 
1558  try
1559  {
1560  std::filesystem::remove(node->getAbsoluteBoostPath());
1561  removeFolder(node);
1562  GroupXmlWriter::WriteXml(node->getGroup(), QString::fromUtf8((node->getGroup()->getBoostDefinitionFilePath()).c_str()));
1563  }
1564  catch (std::exception&)
1565  {
1566  QMessageBox::warning(NULL, "Folder cannot be deleted.", "Folder cannot be deleted. It is not empty. ");
1567  }
1568 
1569 }
1570 
1572 {
1573  removeNodeFromTree(folderNode);
1574 }
1575 
1576 
1578 {
1580 
1581  if (!nodeIsGroup(node))
1582  {
1583  return;
1584  }
1585 
1586  auto statechartsCmakeListPath = QString::fromUtf8((node->getAbsoluteBoostPath().remove_filename().parent_path() / "CMakeLists.txt").c_str());
1587  auto filecontents = GuiStatechartGroupXmlReader::ReadFileContents(statechartsCmakeListPath);
1588  filecontents = filecontents.remove("add_subdirectory(" + node->getBasename() + ")");
1589  GroupXmlWriter::WriteFileContents(statechartsCmakeListPath, filecontents);
1590 
1591  std::filesystem::remove_all(node->getAbsoluteBoostPath().remove_filename());
1592 
1593  removeNodeFromTree(node);
1594 }
1595 
1597 {
1598  int row = node->row();
1599  // this->layoutAboutToBeChanged();
1600  this->beginRemoveRows(getIndex(node->getParent()), row, row);
1601 
1602  node->getParent()->removeChild(node);
1603 
1604  this->endRemoveRows();
1605  // this->layoutChanged();
1606 }
1607 
1609 {
1610  {
1611  QProgressDialog d;
1612  // d.show();
1613  d.setMinimumDuration(1000);
1614  stateTreeModel->saveAll(&d);
1615  }
1616  QProgressDialog d;
1617  // d.show();
1618  stateTreeModel->generateAllBaseClasses(&d);
1619 }
1620 
1621 /*
1622 StatechartGroupTreeNodePtr StateTreeController::getRoot()
1623 {
1624  return rootNode;
1625 }
1626 */
1627 
1628 
1630 {
1631  QStringList result;
1632  result << "application/x-State";
1633  result << "application/pointer";
1634  return result;
1635 }
1636 
1637 QMimeData* StateTreeController::mimeData(const QModelIndexList& indexes) const
1638 {
1639  if (indexes.size() == 0)
1640  {
1641  return new QMimeData();
1642  }
1643 
1644  StateTreeNodePtr node = getNode(indexes.first());
1645 
1646  if (node->isGroup()) // a group can be dragged into the scenario manager
1647  {
1648  QMimeData* mimeData = new QMimeData();
1649  QByteArray encodedData;
1650 
1651  QDataStream stream(&encodedData, QIODevice::WriteOnly);
1652 
1653 
1654  foreach (const QModelIndex& index, indexes)
1655  {
1656  if (index.isValid())
1657  {
1658 
1659  CMakePackageFinder package(node->getGroup()->getPackageName().toStdString());
1660  ARMARX_CHECK_EXPRESSION(package.packageFound()) << node->getGroup()->getPackageName().toStdString();
1661  ARMARX_CHECK_GREATER_EQUAL(package.getIncludePathList().size(), 1);
1662  auto prop = appForDrag->getProperties();
1663  auto relativeGroupFilePath = ArmarXDataPath::relativeTo(package.getIncludePathList()[0], node->getGroup()->getBoostDefinitionFilePath().string());
1664  prop->getProperties()->setProperty("ArmarX.XMLStateComponent.XMLStatechartGroupDefinitionFile",
1665  relativeGroupFilePath);
1666  prop->getProperties()->setProperty("ArmarX.XMLStateComponent.XMLStatechartProfile",
1667  currentProfile->getName());
1668  prop->getProperties()->setProperty("ArmarX.XMLStateComponent.ObjectName",
1669  node->getGroup()->getName().toStdString() + "XMLStateComponent");
1670  prop->getProperties()->setProperty("ArmarX.ApplicationName",
1671  node->getGroup()->getName().toStdString() + "App");
1672  appForDrag->setProperties(prop);
1673 
1674 
1675  stream << reinterpret_cast<quint64>(appForDrag.get()) << node->getGroup()->getName() /*instanceName*/;
1676  }
1677  }
1678 
1679 
1680  mimeData->setData("application/pointer", encodedData);
1681  return mimeData;
1682  }
1683 
1684  if (!node || !node->getState())
1685  {
1686  return new QMimeData();
1687  }
1688 
1689 
1690  StateMimeData* data = new StateMimeData(node->getState(), stateTreeModel);
1691  data->setProxyName(node->getGroup()->getName() + STATEOFFERERSUFFIX);
1692  return data;
1693 }
1694 
1695 
1696 StateTreeController::StateMimeData::StateMimeData(statechartmodel::StatePtr state, StateTreeModelPtr stateTreeModel) :
1697  AbstractStateMimeData(state),
1698  stateTreeModel(stateTreeModel)
1699 {
1700 }
1701 
1702 bool StateTreeController::StateMimeData::isInSameGroup(statechartmodel::StatePtr state) const
1703 {
1704  return stateTreeModel->getNodeByState(this->state)->getGroup() == stateTreeModel->getNodeByState(state)->getGroup();
1705 }
1706 
1707 bool StateTreeController::StateMimeData::isPublic() const
1708 {
1709  return stateTreeModel->getNodeByState(this->state)->isPublic();
1710 }
1711 
armarx::StateTreeController::getNodeByState
StateTreeNodePtr getNodeByState(statechartmodel::StatePtr state)
Definition: StateTreeController.cpp:516
armarx::ArmarXDataPath::relativeTo
static std::string relativeTo(const std::string &from, const std::string &to)
Transform an absolute filepath into a relative path of the other absolute filepath.
Definition: ArmarXDataPath.cpp:410
armarx::AbstractStateMimeData
The AbstractStateMimeData class is used to transport state data from the treeview to the stateview an...
Definition: StateMimeData.h:36
armarx::StateTreeController::getSelectedNode
StateTreeNodePtr getSelectedNode()
Definition: StateTreeController.cpp:521
armarx::StateTreeModelPtr
std::shared_ptr< StateTreeModel > StateTreeModelPtr
Definition: StateTreeModel.h:44
armarx::StateTreeNode
Definition: StateTreeNode.h:40
armarx::StateTreeController::createNewState
StateTreeNodePtr createNewState(QString name, StateTreeNodePtr parent, bool createDynamicRemoteState=false)
Definition: StateTreeController.cpp:645
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
armarx::EditStatechartGroupDialog::EditGroup
@ EditGroup
Definition: EditStatechartGroupDialog.h:49
armarx::EditStatechartGroupDialog::getProxies
QList< QString > getProxies() const
Definition: EditStatechartGroupDialog.cpp:252
armarx::StateTreeController::onRenameState
void onRenameState()
Definition: StateTreeController.cpp:1022
armarx::RenameStateDialog::getNewStateName
QString getNewStateName() const
Definition: RenameStateDialog.cpp:172
armarx::GuiStatechartGroupXmlReader::ReadFileContents
static QString ReadFileContents(QString path)
Definition: GroupXmlReader.cpp:109
armarx::StateTreeController::saveAll
void saveAll()
Definition: StateTreeController.cpp:1608
armarx::CMakePackageFinder::packageFound
bool packageFound() const
Returns whether or not this package was found with cmake.
Definition: CMakePackageFinder.cpp:485
XmlStateBaseClassGenerator.h
armarx::StateTreeController::onCloneGroup
void onCloneGroup()
Definition: StateTreeController.cpp:1327
GfxTL::Orientation
ScalarT Orientation(const VectorXD< 2, ScalarT > &p1, const VectorXD< 2, ScalarT > &p2, const VectorXD< 2, ScalarT > &c)
Definition: Orientation.h:9
armarx::ArmarXPackageToolInterfacePtr
std::shared_ptr< ArmarXPackageToolInterface > ArmarXPackageToolInterfacePtr
Definition: ArmarXPackageToolInterface.h:55
armarx::StateTreeController::onStatechartFinished
void onStatechartFinished(int exitCode)
Definition: StateTreeController.cpp:1247
armarx::StateTreeNodePtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr
Definition: StatechartGroupDefs.h:31
armarx::GroupXmlWriter::WriteXml
static void WriteXml(StatechartGroupPtr group, QString path, bool indent=true)
Definition: GroupXmlWriter.cpp:41
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::CloneGroupDialog::getStatechartGroupMapping
StatechartGroupMapping getStatechartGroupMapping() const
Definition: CloneGroupDialog.cpp:117
armarx::StateTreeController::tryDeleteState
void tryDeleteState()
Definition: StateTreeController.cpp:590
armarx::StateTreeNode::Group
@ Group
Definition: StateTreeNode.h:45
armarx::ArmarXDataPath::getHomePath
static std::string getHomePath()
Definition: ArmarXDataPath.cpp:583
armarx::StateTreeController::selectNodeByState
void selectNodeByState(statechartmodel::StatePtr state)
Definition: StateTreeController.cpp:713
armarx::StatechartGroup::eWritable
@ eWritable
Definition: StatechartGroup.h:40
armarx::StateTreeController::flags
Qt::ItemFlags flags(const QModelIndex &index) const override
Definition: StateTreeController.cpp:286
armarx::StateTreeController::selectedNodeIsFolder
bool selectedNodeIsFolder()
Definition: StateTreeController.cpp:563
XmlWriter.h
armarx::StateTreeController::selectedNodeIsFolderOrGroup
bool selectedNodeIsFolderOrGroup()
Definition: StateTreeController.cpp:573
armarx::StateTreeController::removeFolder
void removeFolder(StateTreeNodePtr folderNode)
Definition: StateTreeController.cpp:1571
StateCreationDialog::buttonBox
QDialogButtonBox * buttonBox
Definition: StateTreeController.cpp:812
armarx::statechartmodel::EventList
QList< EventPtr > EventList
Definition: XmlWriter.h:47
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:53
armarx::StateTreeController::stopGroupExecutionWithDependencies
void stopGroupExecutionWithDependencies(StatechartGroupPtr group)
Definition: StateTreeController.cpp:1180
armarx::RenameStateDialog::isSaveAllRequested
bool isSaveAllRequested() const
Definition: RenameStateDialog.cpp:167
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:52
armarx::StateTreeController::onRenameGroup
void onRenameGroup()
Definition: StateTreeController.cpp:1371
c
constexpr T c
Definition: UnscentedKalmanFilterTest.cpp:43
armarx::EditorFileOpener
The EditorFileOpener class.
Definition: editorfileopener.h:40
armarx::StateTreeController::selectedNodeIsState
bool selectedNodeIsState()
Definition: StateTreeController.cpp:558
armarx::StateTreeController::removeNodeFromTree
void removeNodeFromTree(StateTreeNodePtr node)
Definition: StateTreeController.cpp:1596
armarx::CloneGroupDialog
Definition: CloneGroupDialog.h:41
message
message(STATUS "Boost-Library-Dir: " "${Boost_LIBRARY_DIRS}") message(STATUS "Boost-LIBRARIES
Definition: CMakeLists.txt:8
RenameStateDialog.h
armarx::StatechartGroup
Definition: StatechartGroup.h:37
armarx::EditorFileOpener::openFile
void openFile(const std::string &editorName, const std::string &filepath, int lineNumber=0)
Definition: editorfileopener.cpp:84
StateRenamer.h
armarx::StateTreeController::index
QModelIndex index(int row, int column, const QModelIndex &parentIndex=QModelIndex()) const override
Definition: StateTreeController.cpp:318
armarx::StateTreeController::collapseAll
void collapseAll()
Definition: StateTreeController.cpp:1443
armarx::StateTreeController::onMakeStatePublic
void onMakeStatePublic(bool enable)
Definition: StateTreeController.cpp:1002
armarx::GroupCloner
Definition: GroupCloner.h:48
armarx::RenameStateDialog
Definition: RenameStateDialog.h:41
armarx::StateTreeController::~StateTreeController
~StateTreeController() override
Definition: StateTreeController.cpp:189
armarx::StatechartGroup::eReadOnly
@ eReadOnly
Definition: StatechartGroup.h:40
EditStatechartGroupDialog.h
armarx::StateTreeController::onDeleteNode
void onDeleteNode()
Definition: StateTreeController.cpp:976
armarx::StateTreeController::loadAllStates
void loadAllStates()
Definition: StateTreeController.cpp:511
visionx::imrecman::ok
@ ok
Definition: ImageRecordingManagerInterface.ice:46
armarx::StateTreeController::addNewGroup
StatechartGroupPtr addNewGroup(const QString &groupName, const QString &groupPath, const QString &description, const QString &packageName, const QList< QString > proxies, bool generateContext, const QMap< QString, QString > &statechartGroupConfigurations)
Definition: StateTreeController.cpp:490
armarx::statechartmodel::StateInstancePtr
std::shared_ptr< StateInstance > StateInstancePtr
Definition: StateInstance.h:138
armarx::StateTreeController::openStateCPP
void openStateCPP(StateTreeNodePtr node)
Definition: StateTreeController.cpp:1455
armarx::RemoteGui::toUtf8
std::string toUtf8(QString const &qstring)
Definition: WidgetHandler.cpp:7
cxxopts::empty
bool empty(const std::string &s)
Definition: cxxopts.hpp:255
ScenarioManager::Data_Structure::Application
Class containing data about an application Provides methods to get and set the date contained in the ...
Definition: Application.h:45
IceInternal::Handle< ::Ice::Communicator >
armarx::StateTreeController::onOpenStateCPP
void onOpenStateCPP()
Definition: StateTreeController.cpp:1103
armarx::RenameGroupDialog::getDependantGroups
QVector< StatechartGroupPtr > getDependantGroups() const
Definition: RenameGroupDialog.cpp:128
armarx::StateTreeController::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Definition: StateTreeController.cpp:387
armarx::StatechartProfilesPtr
std::shared_ptr< StatechartProfiles > StatechartProfilesPtr
Definition: StatechartProfiles.h:35
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
armarx::CMakePackageFinder::getIncludePathList
std::vector< std::string > getIncludePathList() const
Return the include paths in a vector.
Definition: CMakePackageFinder.cpp:601
armarx::GroupXmlWriter::WriteFileContents
static void WriteFileContents(QString path, QString contents)
Definition: GroupXmlWriter.cpp:90
armarx::CloneGroupDialog::getGroupsToClone
QVector< QPair< StatechartGroupPtr, QString > > getGroupsToClone() const
Definition: CloneGroupDialog.cpp:122
armarx::StateTreeController::onNewStateDefinition
void onNewStateDefinition()
Definition: StateTreeController.cpp:891
armarx::StateTreeController::closeAllTabsRequested
void closeAllTabsRequested()
StateTreeController.h
armarx::EditStatechartGroupDialog
Definition: EditStatechartGroupDialog.h:44
armarx::RenameGroupDialog
Definition: RenameGroupDialog.h:40
armarx::GroupCloner::getGroupDependencies
QVector< StatechartGroupPtr > getGroupDependencies(const StatechartGroupPtr &group, bool includeSelf=false)
Definition: GroupCloner.cpp:44
armarx::StateTreeController::nodeIsState
bool nodeIsState(StateTreeNodePtr node)
Definition: StateTreeController.cpp:538
armarx::StateTreeController::onNewFolder
void onNewFolder()
Definition: StateTreeController.cpp:947
armarx::StateTreeController::loadGroup
StatechartGroupPtr loadGroup(QString groupDefinitionFile)
Definition: StateTreeController.cpp:465
STATEOFFERERSUFFIX
#define STATEOFFERERSUFFIX
Definition: XMLStateComponent.h:33
armarx::CMakePackageFinder::getBinaryDir
std::string getBinaryDir() const
Definition: CMakePackageFinder.h:159
armarx::InfixFilterModel::ExpandFilterResults
static void ExpandFilterResults(QTreeView *treeView)
Expands the treeview that all items that match the filterstring are expanded and directly visible.
Definition: InfixFilterModel.cpp:63
armarx::StateTreeModel
Definition: StateTreeModel.h:46
armarx::StateTreeNode::State
@ State
Definition: StateTreeNode.h:45
boost::process::posix::terminate
void terminate(const Process &p)
Definition: terminate.hpp:20
armarx::StateTreeController::stopGroupExecution
void stopGroupExecution(StatechartGroupPtr group)
Definition: StateTreeController.cpp:1115
armarx::StateTreeController::selectedNodeIsGroup
bool selectedNodeIsGroup()
Definition: StateTreeController.cpp:568
armarx::statechartmodel::State
Definition: State.h:52
editorfileopener.h
armarx::StateTreeController::tryCreateNewState
StateTreeNodePtr tryCreateNewState(QString name)
Definition: StateTreeController.cpp:578
armarx::StateTreeController::onNewDynamicRemoteStateDefinition
void onNewDynamicRemoteStateDefinition()
Definition: StateTreeController.cpp:931
armarx::StateTreeController::loadAndAddGroup
StatechartGroupPtr loadAndAddGroup(QString groupDefinitionFile)
Definition: StateTreeController.cpp:399
StateCreationDialog
Definition: StateTreeController.cpp:807
armarx::StateTreeController::tryDeleteGroup
void tryDeleteGroup()
Definition: StateTreeController.cpp:1577
ARMARX_CHECK_GREATER_EQUAL
#define ARMARX_CHECK_GREATER_EQUAL(lhs, rhs)
This macro evaluates whether lhs is greater or equal (>=) rhs and if it turns out to be false it will...
Definition: ExpressionException.h:123
armarx::StateTreeNode::child
StateTreeNodePtr child(int row)
Definition: StateTreeNode.cpp:93
armarx::StateTreeNode::CheckNodeName
static bool CheckNodeName(QString name)
Definition: StateTreeNode.cpp:369
ARMARX_WARNING_S
#define ARMARX_WARNING_S
Definition: Logging.h:206
armarx::StateTreeController::onShowFullPath
void onShowFullPath()
Definition: StateTreeController.cpp:1091
GroupXmlWriter.h
armarx::StateTreeController::removeState
void removeState(StateTreeNodePtr stateNode)
Definition: StateTreeController.cpp:1537
StateCreationDialog::StateCreationDialog
StateCreationDialog(QWidget *parent=0, Qt::WindowFlags flags=0)
Definition: StateTreeController.cpp:813
armarx::StateTreeController::executeGroup
void executeGroup(StatechartGroupPtr group, QString startState="")
Definition: StateTreeController.cpp:1126
XMLStateComponent.h
armarx::EditStatechartGroupDialog::getConfigurations
QMap< QString, QString > getConfigurations() const
Definition: EditStatechartGroupDialog.cpp:274
RenameGroupDialog.h
armarx::CloneGroupDialog::getPackagePath
QString getPackagePath() const
Definition: CloneGroupDialog.cpp:85
armarx::EditStatechartGroupDialog::getGroupDescription
QString getGroupDescription() const
Definition: EditStatechartGroupDialog.cpp:203
armarx::StatechartGroupPtr
std::shared_ptr< StatechartGroup > StatechartGroupPtr
Definition: StatechartGroupDefs.h:34
armarx::StateTreeController::onExecuteGroup
void onExecuteGroup()
Definition: StateTreeController.cpp:1205
ExpressionException.h
armarx::EditStatechartGroupDialog::contextGenerationEnabled
bool contextGenerationEnabled() const
Definition: EditStatechartGroupDialog.cpp:269
StateCreationDialog::editField
QLineEdit * editField
Definition: StateTreeController.cpp:811
armarx::StateTreeController::onContextMenu
void onContextMenu(const QPoint &point)
Definition: StateTreeController.cpp:723
No
Introduction Thank you for taking interest in our work and downloading this software This library implements the algorithm described in the paper R R R Klein Efficient RANSAC for Point Cloud Shape in Computer Graphics No
Definition: ReadMe.txt:21
armarx::StateTreeController::mimeData
QMimeData * mimeData(const QModelIndexList &indexes) const override
Definition: StateTreeController.cpp:1637
armarx::statechartmodel::DynamicRemoteStateClass
Definition: DynamicRemoteStateClass.h:29
armarx::StateTreeController::onGroupProperties
void onGroupProperties()
Definition: StateTreeController.cpp:1423
armarx::StateTreeController::getNode
StateTreeNodePtr getNode(QModelIndex index) const
Definition: StateTreeController.cpp:697
ARMARX_CHECK_EXPRESSION
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Definition: ExpressionException.h:73
armarx::StateTreeController::createNewFolder
StateTreeNodePtr createNewFolder(QString name, StateTreeNodePtr parent)
Definition: StateTreeController.cpp:682
armarx::StateTreeController::onOpenCMakeProject
void onOpenCMakeProject()
Definition: StateTreeController.cpp:1077
ArmarXWidgetController.h
StateCreationDialog::checkbox
QCheckBox * checkbox
Definition: StateTreeController.cpp:809
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx::StateTreeController::tryDeleteFolder
void tryDeleteFolder()
Definition: StateTreeController.cpp:1543
armarx::StateTreeController::nodeIsGroup
bool nodeIsGroup(StateTreeNodePtr node)
Definition: StateTreeController.cpp:548
armarx::RenameStateDialog::getInstanceRenameInfos
QVector< StateRenamer::InstanceRenameInfo > getInstanceRenameInfos() const
Definition: RenameStateDialog.cpp:162
armarx::EditorFileOpener::openFileWithDefaultEditor
void openFileWithDefaultEditor(const std::string &filepath, int lineNumber=0)
The default editor can be specified by the environment variable $ARMARX_EDITOR.
Definition: editorfileopener.cpp:124
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::StateTreeController::onGenerateStateCppFiles
void onGenerateStateCppFiles()
Definition: StateTreeController.cpp:1307
armarx::StateTreeController::parent
QModelIndex parent(const QModelIndex &index) const override
Definition: StateTreeController.cpp:348
GroupXmlReader.h
armarx::StateTreeController::mimeTypes
QStringList mimeTypes() const override
Definition: StateTreeController.cpp:1629
armarx::AbstractStateMimeData::isPublic
virtual bool isPublic() const =0
armarx::RenameGroupDialog::getNewName
QString getNewName() const
Definition: RenameGroupDialog.cpp:138
armarx::StateTreeController::data
QVariant data(const QModelIndex &index, int role) const override
Definition: StateTreeController.cpp:214
StateCreationDialog::label
QLabel * label
Definition: StateTreeController.cpp:810
armarx::StateTreeNode::getParent
StateTreeNodePtr getParent() const
Definition: StateTreeNode.cpp:137
armarx::statechartmodel::StatePtr
std::shared_ptr< State > StatePtr
Definition: State.h:46
armarx::StateTreeNode::Folder
@ Folder
Definition: StateTreeNode.h:45
ARMARX_VERBOSE_S
#define ARMARX_VERBOSE_S
Definition: Logging.h:200
armarx::StateRenamer::RenameState
static bool RenameState(const QVector< InstanceRenameInfo > &instanceRenameInfos, const StateTreeNodePtr &state, const QString &newStateName, const StatechartGroupPtr &group)
Definition: StateRenamer.cpp:41
armarx::InfixFilterModel
This proxy model reimplements the filterAcceptsRow function with a new behavior: All elements that fi...
Definition: InfixFilterModel.h:41
armarx::statechartmodel::EventPtr
std::shared_ptr< Event > EventPtr
Definition: XmlWriter.h:46
ARMARX_INFO_S
#define ARMARX_INFO_S
Definition: Logging.h:195
armarx::RenameGroupDialog::isSaveAllRequested
bool isSaveAllRequested() const
Definition: RenameGroupDialog.cpp:123
armarx::StateTreeController::onFindStateUsages
void onFindStateUsages()
Definition: StateTreeController.cpp:1010
armarx::statechartmodel::Event
Definition: Event.h:30
armarx::StateTreeController::selectNode
void selectNode(StateTreeNodePtr node)
Definition: StateTreeController.cpp:1448
CloneGroupDialog.h
armarx::StateTreeController::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Definition: StateTreeController.cpp:308
armarx::StateTreeController::onOpenGroup
void onOpenGroup(QString groupFile="")
Definition: StateTreeController.cpp:1108
armarx::RenameGroupDialog::getAllGroups
QVector< StatechartGroupPtr > getAllGroups() const
Definition: RenameGroupDialog.cpp:133
ArmarXDataPath.h
armarx::StateTreeController::executeGroupWithDependencies
void executeGroupWithDependencies(StatechartGroupPtr group, QString startState)
Definition: StateTreeController.cpp:1170
armarx::armem::server::ltm::mongodb::util::load
void load(const mongocxx::database &db, armem::wm::Memory &m)
Definition: operations.cpp:40
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::StateTreeController::getClosestParentFolderOrGroupNode
StateTreeNodePtr getClosestParentFolderOrGroupNode(StateTreeNodePtr node)
Definition: StateTreeController.cpp:533
armarx::StateTreeController::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition: StateTreeController.cpp:366
armarx::StateTreeController::nodeIsFolderOrGroup
bool nodeIsFolderOrGroup(StateTreeNodePtr node)
Definition: StateTreeController.cpp:553
GfxTL::Yes
OnOff< true > Yes
Definition: OnOff.h:12
armarx::StateTreeController::nodeIsFolder
bool nodeIsFolder(StateTreeNodePtr node)
Definition: StateTreeController.cpp:543
armarx::StateTreeController::StateTreeController
StateTreeController(Ice::CommunicatorPtr ic, VariantInfoPtr variantInfo, QList< QVariant > headerInfo, QTreeView *treeView, QLineEdit *filterLineEdit, const ArmarXPackageToolInterfacePtr &packageTool, const StatechartProfilesPtr &statechartProfiles, StatechartProfilePtr currentProfile, QObject *parent=0)
Definition: StateTreeController.cpp:63