AronTreeWidgetCreator.h
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotAPI::gui-plugins::SkillManagerMonitorWidgetController
17  * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18  * @date 2020
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 #pragma once
23 
24 #include <QTreeWidgetItem>
25 
29 
30 namespace armarx
31 {
32  class AronTreeWidgetItem;
33 
34  // Convert aron type to tree widgets
36  {
37  public:
39 
41 
42  // Takes the parent tree element and attaches the newly crated object during visit() to it.
43  // This allows us to also use information of the parent object during creation (like if this child is a dict entry or part of a list)
44  // IMPORTANT: For the root element, manually set the topLevelWidget after this constructor
45  AronTreeWidgetCreatorVisitor(QTreeWidgetItem* parentInstance);
46 
47  void insertNewTreeViewWidget(Input& i, const std::string&);
48 
49 
50  void visitAronVariant(const aron::type::ObjectPtr&) final;
51  void visitAronVariant(const aron::type::DictPtr& i) final;
52  void visitAronVariant(const aron::type::PairPtr& i) final;
53  void visitAronVariant(const aron::type::TuplePtr& i) final;
54  void visitAronVariant(const aron::type::ListPtr& i) final;
55  void visitAronVariant(const aron::type::NDArrayPtr& i) final;
56  void visitAronVariant(const aron::type::MatrixPtr& i) final;
57  void visitAronVariant(const aron::type::QuaternionPtr& i) final;
58  void visitAronVariant(const aron::type::ImagePtr& i) final;
59  void visitAronVariant(const aron::type::PointCloudPtr& i) final;
60  void visitAronVariant(const aron::type::IntEnumPtr& i) final;
61  void visitAronVariant(const aron::type::IntPtr& i) final;
62  void visitAronVariant(const aron::type::LongPtr& i) final;
63  void visitAronVariant(const aron::type::FloatPtr& i) final;
64  void visitAronVariant(const aron::type::DoublePtr& i) final;
65  void visitAronVariant(const aron::type::BoolPtr& i) final;
66  void visitAronVariant(const aron::type::StringPtr& i) final;
67  void visitUnknown(Input&) final;
68 
69  // setter for the widget attachment point. Only needs to be manually set for the root element.
70  void setTopLevelWidget(QTreeWidget* widget);
71 
72  private:
73  void handleEditable();
74  std::string generateUniqueKeyFromSet(std::set<std::string>&& usedKeys);
75  QTreeWidgetItem* parentOfCreatedObj = nullptr;
76  QTreeWidget* toplevelWidget = nullptr;
77  const std::string defaultMapKeyName = "key_";
78  // controls, if values (column 1) can be edited directly
79  bool editableValue = false;
80  };
81 } // namespace armarx
armarx::aron::type::VisitorBase< const type::VariantPtr >::Input
const type::VariantPtr Input
Definition: Visitor.h:94
armarx::aron::type::MatrixPtr
std::shared_ptr< class Matrix > MatrixPtr
Definition: forward_declarations.h:20
VariantVisitor.h
armarx::AronTreeWidgetCreatorVisitor::createdQWidgetItem
AronTreeWidgetItem * createdQWidgetItem
Definition: AronTreeWidgetCreator.h:38
armarx::aron::type::ImagePtr
std::shared_ptr< class Image > ImagePtr
Definition: forward_declarations.h:22
armarx::aron::type::NDArrayPtr
std::shared_ptr< class NDArray > NDArrayPtr
Definition: forward_declarations.h:19
armarx::AronTreeWidgetItem
Definition: AronTreeWidgetItem.h:19
armarx::AronTreeWidgetCreatorVisitor::visitAronVariant
void visitAronVariant(const aron::type::ObjectPtr &) final
Definition: AronTreeWidgetCreator.cpp:125
All.h
armarx::AronTreeWidgetCreatorVisitor::visitUnknown
void visitUnknown(Input &) final
Definition: AronTreeWidgetCreator.cpp:355
armarx::aron::type::TuplePtr
std::shared_ptr< class Tuple > TuplePtr
Definition: forward_declarations.h:17
armarx::aron::type::PointCloudPtr
std::shared_ptr< class PointCloud > PointCloudPtr
Definition: forward_declarations.h:23
armarx::aron::type::FloatPtr
std::shared_ptr< class Float > FloatPtr
Definition: forward_declarations.h:29
armarx::aron::type::ListPtr
std::shared_ptr< class List > ListPtr
Definition: forward_declarations.h:14
armarx::aron::type::LongPtr
std::shared_ptr< class Long > LongPtr
Definition: forward_declarations.h:28
armarx::aron::type::StringPtr
std::shared_ptr< class String > StringPtr
Definition: forward_declarations.h:31
armarx::AronTreeWidgetCreatorVisitor::AronTreeWidgetCreatorVisitor
AronTreeWidgetCreatorVisitor()=delete
armarx::AronTreeWidgetCreatorVisitor
Definition: AronTreeWidgetCreator.h:35
All.h
armarx::aron::type::PairPtr
std::shared_ptr< class Pair > PairPtr
Definition: forward_declarations.h:16
armarx::aron::type::DictPtr
std::shared_ptr< class Dict > DictPtr
Definition: forward_declarations.h:13
armarx::aron::type::BoolPtr
std::shared_ptr< class Bool > BoolPtr
Definition: forward_declarations.h:32
armarx::AronTreeWidgetCreatorVisitor::insertNewTreeViewWidget
void insertNewTreeViewWidget(Input &i, const std::string &)
Definition: AronTreeWidgetCreator.cpp:73
armarx::aron::type::IntEnumPtr
std::shared_ptr< IntEnum > IntEnumPtr
Definition: IntEnum.h:36
armarx::aron::type::ObjectPtr
std::shared_ptr< Object > ObjectPtr
Definition: Object.h:36
armarx::aron::type::ConstVariantVisitor
The VariantVisitor struct.
Definition: VariantVisitor.h:38
armarx::AronTreeWidgetCreatorVisitor::setTopLevelWidget
void setTopLevelWidget(QTreeWidget *widget)
Definition: AronTreeWidgetCreator.cpp:362
armarx::aron::type::QuaternionPtr
std::shared_ptr< class Quaternion > QuaternionPtr
Definition: forward_declarations.h:21
armarx::aron::type::IntPtr
std::shared_ptr< class Int > IntPtr
Definition: forward_declarations.h:27
armarx::aron::type::DoublePtr
std::shared_ptr< class Double > DoublePtr
Definition: forward_declarations.h:30
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28