StateParameterEditor.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 <QStyledItemDelegate>
27 #include <QTableWidget>
28 
32 
33 class QComboBox;
34 
35 namespace armarx
36 {
37 
38  class StateParameterEditor : public QTableWidget
39  {
40  Q_OBJECT
41  public:
42  enum ColumnIds
43  {
50  };
51 
52  explicit StateParameterEditor(QWidget* parent = 0,
53  const StateParameterMap& params = StateParameterMap());
54 
55  void
57  {
58  this->communicator = communicator;
59  }
60 
61  void
63  {
64  this->variantInfo = variantInfo;
65  }
66 
67  void
69  {
70  this->currentProfile = currentProfile;
71  }
72 
73  void setKeyBlackList(const QSet<QString>& keyBlackList);
74  QSet<QString> getKeys() const;
76  StringVariantContainerBaseMap getStringValueMap() const;
78 
79  QString getValueAsString(int row) const;
80  VariantContainerBasePtr getVariantContainer(int row) const;
81  QString getJson(QString key) const;
82  QString getKey(int row) const;
83  QString getType(int row) const;
84  QString getType(QString key) const;
85  int getRow(const QString& key) const;
86  bool getIsOptional(int row) const;
87 
88  void
89  addParameterRow(QString key, QString variantIdStr, QString value, bool optional = false);
90  void createValueButton(int row, const QString& jsonValue);
91  void setHeaders();
92  Qt::CheckState getDefaultValueState() const;
93  void setDefaultValueState(const Qt::CheckState& value);
94 
95  StateParameterIceBasePtr getStateParameter(int row) const;
96  signals:
97  void buildRequested(const StateParameterMap& map,
98  const std::map<QString, std::pair<QString, QString>>& jsonStringMap);
99  void rowAdded(int rowId);
100  void rowFilled(int rowId, const QString& key);
101  public slots:
102  void buildFromMap(const StateParameterMap& map,
103  const std::map<QString, std::pair<QString, QString>>& jsonStringMap =
104  std::map<QString, std::pair<QString, QString>>());
105  int addParameterRow();
106  void typeCbChanged(const QString& text);
107  void deleteRow();
108  void checkAndUpdateRowCount(int row, int column);
109  void refreshVariantTypes();
111  private slots:
112  void __buildFromMap(const StateParameterMap& map,
113  const std::map<QString, std::pair<QString, QString>>& jsonStringMap =
114  std::map<QString, std::pair<QString, QString>>());
115 
116  private:
117  void connectUserEditSlots();
118  void addVariantTypesToComboBox(QComboBox* combo);
119  QString getHumanNameFromBaseName(QString variantBaseTypeName) const;
120  QString getBaseNameFromHumanName(QString humanName) const;
121  static bool compareVariantNames(const QString& a, const QString& b);
122 
123  class LineEditDelegate : public QStyledItemDelegate
124  {
125  QWidget* createEditor(QWidget* parent,
126  const QStyleOptionViewItem& option,
127  const QModelIndex& index) const override;
128  };
129 
130  LineEditDelegate delegate;
131  Ice::CommunicatorPtr communicator;
132  VariantInfoPtr variantInfo;
133  Qt::CheckState defaultValueState;
134  QSet<QString> keyBlackList;
135  StatechartProfilePtr currentProfile;
136  };
137 
138 } // namespace armarx
armarx::StateParameterEditor::eOptional
@ eOptional
Definition: StateParameterEditor.h:46
armarx::StateParameterEditor
Definition: StateParameterEditor.h:38
armarx::StateParameterEditor::eType
@ eType
Definition: StateParameterEditor.h:45
armarx::StateParameterEditor::getKeys
QSet< QString > getKeys() const
Definition: StateParameterEditor.cpp:88
armarx::StateParameterEditor::eKey
@ eKey
Definition: StateParameterEditor.h:44
armarx::StateParameterEditor::getDefaultValueState
Qt::CheckState getDefaultValueState() const
Definition: StateParameterEditor.cpp:986
armarx::StateParameterEditor::buildFromMap
void buildFromMap(const StateParameterMap &map, const std::map< QString, std::pair< QString, QString >> &jsonStringMap=std::map< QString, std::pair< QString, QString >>())
Definition: StateParameterEditor.cpp:1010
armarx::StateParameterEditor::getStringValueMap
StringVariantContainerBaseMap getStringValueMap() const
Definition: StateParameterEditor.cpp:148
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::StateParameterEditor::setDefaultValueState
void setDefaultValueState(const Qt::CheckState &value)
Definition: StateParameterEditor.cpp:992
armarx::StateParameterEditor::buildRequested
void buildRequested(const StateParameterMap &map, const std::map< QString, std::pair< QString, QString >> &jsonStringMap)
armarx::StateParameterEditor::setCurrentProfile
void setCurrentProfile(StatechartProfilePtr currentProfile)
Definition: StateParameterEditor.h:68
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:51
armarx::StateParameterEditor::getStateParameters
StateParameterMap getStateParameters() const
Definition: StateParameterEditor.cpp:119
armarx::StateParameterEditor::addParameterRow
int addParameterRow()
Definition: StateParameterEditor.cpp:438
armarx::StateParameterEditor::createValueButton
void createValueButton(int row, const QString &jsonValue)
Definition: StateParameterEditor.cpp:551
armarx::StateParameterEditor::setCommunicator
void setCommunicator(Ice::CommunicatorPtr communicator)
Definition: StateParameterEditor.h:56
armarx::StateParameterEditor::getType
QString getType(int row) const
Definition: StateParameterEditor.cpp:378
armarx::StateParameterEditor::editDefaultButtonClicked
void editDefaultButtonClicked()
Definition: StateParameterEditor.cpp:807
Statechart.h
armarx::StateParameterEditor::ColumnIds
ColumnIds
Definition: StateParameterEditor.h:42
IceInternal::Handle<::Ice::Communicator >
armarx::StateParameterEditor::getStateParameter
StateParameterIceBasePtr getStateParameter(int row) const
Definition: StateParameterEditor.cpp:104
armarx::StateParameterEditor::getValueAsString
QString getValueAsString(int row) const
Definition: StateParameterEditor.cpp:168
armarx::StateParameterEditor::getKey
QString getKey(int row) const
Definition: StateParameterEditor.cpp:362
armarx::StateParameterEditor::eDeleteButton
@ eDeleteButton
Definition: StateParameterEditor.h:49
armarx::StateParameterEditor::setKeyBlackList
void setKeyBlackList(const QSet< QString > &keyBlackList)
Definition: StateParameterEditor.cpp:82
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:855
armarx::StateParameterEditor::getVariantContainer
VariantContainerBasePtr getVariantContainer(int row) const
Definition: StateParameterEditor.cpp:272
armarx::statechartmodel::StateParameterMap
QMap< QString, StateParameterPtr > StateParameterMap
Definition: StateParameter.h:46
armarx::StateParameterEditor::setVariantInfo
void setVariantInfo(VariantInfoPtr variantInfo)
Definition: StateParameterEditor.h:62
armarx::StateParameterEditor::getJson
QString getJson(QString key) const
Definition: StateParameterEditor.cpp:186
armarx::StateParameterEditor::refreshVariantTypes
void refreshVariantTypes()
Definition: StateParameterEditor.cpp:796
armarx::StateParameterEditor::getIsOptional
bool getIsOptional(int row) const
Definition: StateParameterEditor.cpp:426
armarx::StateParameterEditor::getRow
int getRow(const QString &key) const
Definition: StateParameterEditor.cpp:404
StatechartProfiles.h
armarx::StateParameterEditor::setHeaders
void setHeaders()
Definition: StateParameterEditor.cpp:998
armarx::StateParameterEditor::eProvideDefaultValue
@ eProvideDefaultValue
Definition: StateParameterEditor.h:47
armarx::StateParameterEditor::rowFilled
void rowFilled(int rowId, const QString &key)
option
#define option(type, fn)
armarx::StateParameterEditor::getStateParametersWithoutValue
StateParameterMap getStateParametersWithoutValue() const
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::StateParameterEditor::checkAndUpdateRowCount
void checkAndUpdateRowCount(int row, int column)
Definition: StateParameterEditor.cpp:745
armarx::StateParameterEditor::StateParameterEditor
StateParameterEditor(QWidget *parent=0, const StateParameterMap &params=StateParameterMap())
Definition: StateParameterEditor.cpp:50
armarx::StateParameterEditor::deleteRow
void deleteRow()
Definition: StateParameterEditor.cpp:726
armarx::StateParameterEditor::eValue
@ eValue
Definition: StateParameterEditor.h:48
armarx::StateParameterEditor::rowAdded
void rowAdded(int rowId)
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::StateParameterEditor::typeCbChanged
void typeCbChanged(const QString &text)
Definition: StateParameterEditor.cpp:657
VariantInfo.h