StateTreeNode.h
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 #pragma once
25 
26 #include "StatechartGroupDefs.h"
27 #include "StatechartGroup.h"
28 
29 #include "../../StatechartViewerPlugin/model/State.h"
30 
31 #include <QVariant>
32 
33 #include <memory>
34 #include <filesystem>
35 
36 namespace armarx
37 {
38 
39  class StateTreeModel;
41  : public std::enable_shared_from_this<StateTreeNode>
42  {
43  friend class StateTreeModel;
44  public:
45  enum NodeType { Group, Folder, State };
46  enum class Path
47  {
49  };
50 
51  StateTreeNode(QString display, QString basename, NodeType nodeType, StateTreeNodePtr parentNode, StatechartGroupPtr parentGroup, bool stateIsPublic);
53 
55  void sortChildren();
57 
59  int childCount() const;
60  int columnCount() const;
61  QString getDisplay() const;
62  int row() const;
65  QList<StateTreeNodePtr> getChildren() const;
66  bool isPublic();
67  void setPublic(bool isPublic);
68 
70 
71  QString getBasename() const;
72  std::filesystem::path getBoostPath(std::filesystem::path parentPath) const;
73  std::filesystem::path getBoostPathRelativeToGroup() const;
74  std::filesystem::path getAbsoluteBoostPath() const;
75  std::filesystem::path getBoostXmlFilePath(Path pathType = Path::Absolute) const;
76  std::filesystem::path getBoostCppFilePath(Path pathType = Path::Absolute) const;
77  std::filesystem::path getBoostHFilePath(Path pathType = Path::Absolute) const;
78  std::filesystem::path getBoostGeneratedHFilePath(Path pathType = Path::Absolute) const;
79  bool getCppExists() const;
80  bool checkCppExists();
81 
83  //void setState(const armarx::statechartmodel::StatePtr &value);
84 
85  bool isState() const;
86  bool isFolderOrGroup() const;
87  bool isGroup() const;
88  bool isFolder() const;
90 
92  QVector<StateTreeNodePtr> getAllSubNodesRecursively() const;
93  QVector<statechartmodel::StatePtr> getAllStatesRecursively(bool localOnly) const;
94 
96 
97  static bool CheckNodeName(QString name);
98 
99  private:
100  static int NodeTypeToSortIndex(NodeType nodeType);
101  static bool CompareChildren(const StateTreeNodePtr& a, const StateTreeNodePtr& b);
102  void GetAllSubstatesRecursively(const statechartmodel::StatePtr& state, QVector<statechartmodel::StatePtr>& result, bool localOnly) const;
103 
104  QList<StateTreeNodePtr> children;
105  QList<QVariant> itemData;
106  std::weak_ptr<StateTreeNode> parentNode;
107  std::weak_ptr<StatechartGroup> parentGroup;
108  NodeType nodeType;
109  QString basename;
110  QString display;
112  bool stateIsPublic;
113  bool cppExists;
114  };
115 
116 }
117 
armarx::StateTreeNode::getAllStatesRecursively
QVector< statechartmodel::StatePtr > getAllStatesRecursively(bool localOnly) const
Definition: StateTreeNode.cpp:322
armarx::StateTreeNode::isFolderOrGroup
bool isFolderOrGroup() const
Definition: StateTreeNode.cpp:257
armarx::StateTreeNode
Definition: StateTreeNode.h:40
StatechartGroupDefs.h
armarx::StateTreeNode::row
int row() const
Definition: StateTreeNode.cpp:113
armarx::StateTreeNode::isState
bool isState() const
Definition: StateTreeNode.cpp:252
armarx::StateTreeNodePtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr
Definition: StatechartGroupDefs.h:31
armarx::StateTreeNode::getBoostXmlFilePath
std::filesystem::path getBoostXmlFilePath(Path pathType=Path::Absolute) const
Definition: StateTreeNode.cpp:161
armarx::StateTreeNode::columnCount
int columnCount() const
Definition: StateTreeNode.cpp:103
armarx::StateTreeNode::isPublic
bool isPublic()
Definition: StateTreeNode.cpp:384
armarx::StateTreeNode::findNodeByStateName
StateTreeNodePtr findNodeByStateName(QString name)
Definition: StateTreeNode.cpp:285
armarx::StateTreeNode::getGroup
StatechartGroupPtr getGroup()
Definition: StateTreeNode.cpp:142
armarx::StateTreeNode::Group
@ Group
Definition: StateTreeNode.h:45
armarx::StateTreeNode::getBasename
QString getBasename() const
Definition: StateTreeNode.cpp:151
armarx::StateTreeNode::getBoostPathRelativeToGroup
std::filesystem::path getBoostPathRelativeToGroup() const
Definition: StateTreeNode.cpp:233
armarx::StateTreeNode::checkCppExists
bool checkCppExists()
Definition: StateTreeNode.cpp:217
armarx::StateTreeNode::appendChild
void appendChild(StateTreeNodePtr child)
Definition: StateTreeNode.cpp:47
armarx::StateTreeNode::getBoostPath
std::filesystem::path getBoostPath(std::filesystem::path parentPath) const
Definition: StateTreeNode.cpp:228
armarx::StateTreeNode::sortChildren
void sortChildren()
Definition: StateTreeNode.cpp:83
armarx::StateTreeNode::getAbsoluteBoostPath
std::filesystem::path getAbsoluteBoostPath() const
Definition: StateTreeNode.cpp:156
armarx::StateTreeNode::Path::RelativeToGroup
@ RelativeToGroup
armarx::StateTreeNode::getState
armarx::statechartmodel::StatePtr getState() const
Definition: StateTreeNode.cpp:246
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
StatechartGroup.h
armarx::StateTreeNode::~StateTreeNode
~StateTreeNode()
Definition: StateTreeNode.cpp:42
armarx::StateTreeModel
Definition: StateTreeModel.h:46
armarx::StateTreeNode::getBoostHFilePath
std::filesystem::path getBoostHFilePath(Path pathType=Path::Absolute) const
Definition: StateTreeNode.cpp:183
armarx::StateTreeNode::getClosestParentFolderOrGroupNode
StateTreeNodePtr getClosestParentFolderOrGroupNode()
Definition: StateTreeNode.cpp:272
armarx::StateTreeNode::getBoostGeneratedHFilePath
std::filesystem::path getBoostGeneratedHFilePath(Path pathType=Path::Absolute) const
Definition: StateTreeNode.cpp:195
armarx::StateTreeNode::setPublic
void setPublic(bool isPublic)
Definition: StateTreeNode.cpp:389
armarx::StateTreeNode::child
StateTreeNodePtr child(int row)
Definition: StateTreeNode.cpp:93
armarx::State
Definition: State.h:54
armarx::StateTreeNode::CheckNodeName
static bool CheckNodeName(QString name)
Definition: StateTreeNode.cpp:369
armarx::StateTreeNode::getCppExists
bool getCppExists() const
Definition: StateTreeNode.cpp:207
armarx::StateTreeNode::removeChild
void removeChild(StateTreeNodePtr child)
Definition: StateTreeNode.cpp:88
armarx::StateTreeNode::isGroup
bool isGroup() const
Definition: StateTreeNode.cpp:262
armarx::StatechartGroupPtr
std::shared_ptr< StatechartGroup > StatechartGroupPtr
Definition: StatechartGroupDefs.h:34
armarx::StateTreeNode::StateTreeNode
StateTreeNode(QString display, QString basename, NodeType nodeType, StateTreeNodePtr parentNode, StatechartGroupPtr parentGroup, bool stateIsPublic)
Definition: StateTreeNode.cpp:30
armarx::StateTreeNode::getAllSubNodesRecursively
QVector< StateTreeNodePtr > getAllSubNodesRecursively() const
Definition: StateTreeNode.cpp:305
armarx::StateTreeNode::getChildren
QList< StateTreeNodePtr > getChildren() const
Definition: StateTreeNode.cpp:379
armarx::StateTreeNode::getDisplay
QString getDisplay() const
Definition: StateTreeNode.cpp:108
armarx::StateTreeNode::NodeType
NodeType
Definition: StateTreeNode.h:45
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::StateTreeNode::childCount
int childCount() const
Definition: StateTreeNode.cpp:98
armarx::StateTreeNode::Path
Path
Definition: StateTreeNode.h:46
armarx::StateTreeNode::getNodeType
NodeType getNodeType()
Definition: StateTreeNode.cpp:147
armarx::StateTreeNode::getNestingLevelRelativeToGroup
int getNestingLevelRelativeToGroup()
Definition: StateTreeNode.cpp:359
armarx::StateTreeNode::Path::Absolute
@ Absolute
armarx::StateTreeNode::getBoostCppFilePath
std::filesystem::path getBoostCppFilePath(Path pathType=Path::Absolute) const
Definition: StateTreeNode.cpp:171
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::StateTreeNode::isFolder
bool isFolder() const
Definition: StateTreeNode.cpp:267