StatechartEditorParameterEditor.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 
25 #pragma once
28 #include <QComboBox>
29 #include <QStyledItemDelegate>
30 #include <QTableWidget>
31 #include <QToolButton>
33 
34 
35 namespace armarx
36 {
37  class AnimatedToolButton : public QToolButton
38  {
39 
40  Q_OBJECT
41  Q_PROPERTY(QColor color READ color WRITE setColor)
42 
43  public:
44  AnimatedToolButton(QWidget* parent = 0) : QToolButton(parent)
45  {
46  }
47  void setColor(QColor color);
48  QColor color()
49  {
50  return Qt::black; // getter is not really needed for now
51  }
52  };
53 
55  public QTableWidget
56  {
57  Q_OBJECT
58  public:
59 
62  // void buildFromMap(const statechartmodel::StateParameterMap& map);
63  protected slots:
64  void addCustomColumn(int row);
65  void fillCustomColumn(int row, const QString& key);
66  void showHelpDialog();
67  void addInputToParent();
68  void init(const statechartmodel::StateParameterMap& params);
69  protected:
72 
73 
74  // ###### StateParameterEditor: ######
75  public:
76  enum ColumnIds
77  {
84  };
85  //explicit StateParameterEditor(QWidget *parent = 0, const StateParameterMap& params = StateParameterMap());
86 
88  {
89  this->communicator = communicator;
90  }
91  void setVariantInfo(VariantInfoPtr variantInfo)
92  {
93  this->variantInfo = variantInfo;
94  }
96  {
97  this->currentProfile = currentProfile;
98  setColumnCount(eEditableValue + getRelevantProfiles().size());
99  }
100  void setKeyBlackList(const QSet<QString>& keyBlackList);
101  QSet<QString> getKeys() const;
102  QSet<QString> getTypes() const;
105 
106  QMap<QString, QString> getValuesAsString(int row) const;
107  QMap<QString, VariantContainerBasePtr> getProfileVariantContainerMap(int row) const;
108  QMap<QString, QString> getProfileJsonMap(QString key) const;
109  QString getKey(int row) const;
110  QString getType(int row) const;
111  QString getType(QString key) const;
112  int getRow(const QString& key) const;
113  bool getIsOptional(int row) const;
114 
115  void addParameterRow(QString key, QString variantIdStr, QVector<QString> values, bool optional = false);
116  void setHeaders();
117  Qt::CheckState getDefaultValueState() const;
118  void setDefaultValueState(const Qt::CheckState& value);
119  void hideValueColumns();
120 
122  signals:
124  void rowAdded(int rowId);
125  void rowFilled(int rowId, const QString& key);
126  void typeChanged(int row, const QString& newType);
127  public slots:
129  int addParameterRow();
130  void typeCbChanged(const QString&);
131  void deleteRow();
132  void checkAndUpdateRowCount(int row, int column);
133  void refreshVariantTypes();
134  private slots:
135  void __buildFromMap(const statechartmodel::StateParameterMap& map);
136 
137  private:
138  QVector<QString> getRelevantProfiles() const;
139  void connectUserEditSlots();
140  QStringList addVariantTypesToComboBox(QComboBox* combo);
141  QString getHumanNameFromBaseName(QString variantBaseTypeName) const;
142  QString getBaseNameFromHumanName(QString humanName) const;
143  static bool compareVariantNames(const QString& a, const QString& b);
144 
145  class LineEditDelegate : public QStyledItemDelegate
146  {
147  QWidget* createEditor(QWidget* parent,
148  const QStyleOptionViewItem& option,
149  const QModelIndex& index) const override;
150  };
151  LineEditDelegate delegate;
152  Ice::CommunicatorPtr communicator;
153  VariantInfoPtr variantInfo;
154  Qt::CheckState defaultValueState;
155  QSet<QString> keyBlackList;
156  StatechartProfilePtr currentProfile;
157  };
158 
159 } // namespace armarx
160 
armarx::StatechartEditorParameterEditor::getIsOptional
bool getIsOptional(int row) const
Definition: StatechartEditorParameterEditor.cpp:487
armarx::StatechartEditorParameterEditor::getKey
QString getKey(int row) const
Definition: StatechartEditorParameterEditor.cpp:426
armarx::StatechartEditorParameterEditor::setCurrentProfile
void setCurrentProfile(StatechartProfilePtr currentProfile)
Definition: StatechartEditorParameterEditor.h:95
armarx::StatechartEditorParameterEditor::state
statechartmodel::StateInstancePtr state
Definition: StatechartEditorParameterEditor.h:70
armarx::StatechartEditorParameterEditor::getProfileVariantContainerMap
QMap< QString, VariantContainerBasePtr > getProfileVariantContainerMap(int row) const
Definition: StatechartEditorParameterEditor.cpp:406
armarx::StatechartEditorParameterEditor::fillCustomColumn
void fillCustomColumn(int row, const QString &key)
Definition: StatechartEditorParameterEditor.cpp:144
armarx::AnimatedToolButton::setColor
void setColor(QColor color)
Definition: StatechartEditorParameterEditor.cpp:936
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::StatechartEditorParameterEditor::originalParamMap
statechartmodel::StateParameterMap originalParamMap
Definition: StatechartEditorParameterEditor.h:71
armarx::StatechartEditorParameterEditor::getProfileJsonMap
QMap< QString, QString > getProfileJsonMap(QString key) const
Definition: StatechartEditorParameterEditor.cpp:370
armarx::StatechartEditorParameterEditor::eEditableValue
@ eEditableValue
Definition: StatechartEditorParameterEditor.h:83
armarx::StatechartEditorParameterEditor::setDefaultValueState
void setDefaultValueState(const Qt::CheckState &value)
Definition: StatechartEditorParameterEditor.cpp:826
armarx::StatechartEditorParameterEditor::getDefaultValueState
Qt::CheckState getDefaultValueState() const
Definition: StatechartEditorParameterEditor.cpp:821
ProsthesisInterface.values
values
Definition: ProsthesisInterface.py:190
armarx::AnimatedToolButton::AnimatedToolButton
AnimatedToolButton(QWidget *parent=0)
Definition: StatechartEditorParameterEditor.h:44
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:52
armarx::StatechartEditorParameterEditor::buildRequested
void buildRequested(const statechartmodel::StateParameterMap &map)
armarx::StatechartEditorParameterEditor::rowAdded
void rowAdded(int rowId)
armarx::StatechartEditorParameterEditor::setStateInstance
void setStateInstance(statechartmodel::StateInstancePtr state)
Definition: StatechartEditorParameterEditor.cpp:66
armarx::AnimatedToolButton::color
QColor color
Definition: StatechartEditorParameterEditor.h:41
armarx::StatechartEditorParameterEditor::getKeys
QSet< QString > getKeys() const
Definition: StatechartEditorParameterEditor.cpp:268
armarx::StatechartEditorParameterEditor::eKey
@ eKey
Definition: StatechartEditorParameterEditor.h:78
armarx::statechartmodel::StateInstancePtr
std::shared_ptr< StateInstance > StateInstancePtr
Definition: StateInstance.h:138
armarx::StatechartEditorParameterEditor::setCommunicator
void setCommunicator(Ice::CommunicatorPtr communicator)
Definition: StatechartEditorParameterEditor.h:87
armarx::StatechartEditorParameterEditor::checkAndUpdateRowCount
void checkAndUpdateRowCount(int row, int column)
Definition: StatechartEditorParameterEditor.cpp:623
armarx::StatechartEditorParameterEditor::addCustomColumn
void addCustomColumn(int row)
Definition: StatechartEditorParameterEditor.cpp:110
IceInternal::Handle< ::Ice::Communicator >
armarx::StatechartEditorParameterEditor::setKeyBlackList
void setKeyBlackList(const QSet< QString > &keyBlackList)
Definition: StatechartEditorParameterEditor.cpp:263
armarx::StatechartEditorParameterEditor::getStateParametersWithoutValue
statechartmodel::StateParameterMap getStateParametersWithoutValue() const
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
armarx::StatechartEditorParameterEditor::hideValueColumns
void hideValueColumns()
Definition: StatechartEditorParameterEditor.cpp:831
cxxopts::value
std::shared_ptr< Value > value()
Definition: cxxopts.hpp:926
armarx::StatechartEditorParameterEditor::typeChanged
void typeChanged(int row, const QString &newType)
armarx::StatechartEditorParameterEditor::getStateParameters
statechartmodel::StateParameterMap getStateParameters() const
Definition: StatechartEditorParameterEditor.cpp:320
armarx::statechartmodel::StateParameterMap
QMap< QString, StateParameterPtr > StateParameterMap
Definition: StateParameter.h:46
armarx::StatechartEditorParameterEditor::deleteRow
void deleteRow()
Definition: StatechartEditorParameterEditor.cpp:605
StatechartProfiles.h
armarx::StatechartEditorParameterEditor::showHelpDialog
void showHelpDialog()
Definition: StatechartEditorParameterEditor.cpp:186
armarx::StatechartEditorParameterEditor::eDeleteButton
@ eDeleteButton
Definition: StatechartEditorParameterEditor.h:81
armarx::statechartmodel::StateParameterPtr
std::shared_ptr< StateParameter > StateParameterPtr
Definition: StateParameter.h:45
armarx::StatechartEditorParameterEditor::eAdditionalButtons
@ eAdditionalButtons
Definition: StatechartEditorParameterEditor.h:82
armarx::StatechartEditorParameterEditor::getRow
int getRow(const QString &key) const
Definition: StatechartEditorParameterEditor.cpp:466
armarx::StatechartEditorParameterEditor::addInputToParent
void addInputToParent()
Definition: StatechartEditorParameterEditor.cpp:213
armarx::StatechartEditorParameterEditor::buildFromMap
void buildFromMap(const statechartmodel::StateParameterMap &map)
Definition: StatechartEditorParameterEditor.cpp:862
armarx::StatechartEditorParameterEditor::getStateParameter
statechartmodel::StateParameterPtr getStateParameter(int row) const
Definition: StatechartEditorParameterEditor.cpp:293
option
#define option(type, fn)
armarx::StatechartEditorParameterEditor
Definition: StatechartEditorParameterEditor.h:54
armarx::StatechartEditorParameterEditor::eOptional
@ eOptional
Definition: StatechartEditorParameterEditor.h:80
armarx::StatechartEditorParameterEditor::addParameterRow
int addParameterRow()
Definition: StatechartEditorParameterEditor.cpp:499
armarx::StatechartEditorParameterEditor::getValuesAsString
QMap< QString, QString > getValuesAsString(int row) const
Definition: StatechartEditorParameterEditor.cpp:346
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::StatechartEditorParameterEditor::getType
QString getType(int row) const
Definition: StatechartEditorParameterEditor.cpp:441
armarx::StatechartEditorParameterEditor::getTypes
QSet< QString > getTypes() const
Definition: StatechartEditorParameterEditor.cpp:283
armarx::StatechartEditorParameterEditor::eType
@ eType
Definition: StatechartEditorParameterEditor.h:79
armarx::StatechartEditorParameterEditor::rowFilled
void rowFilled(int rowId, const QString &key)
armarx::StatechartEditorParameterEditor::StatechartEditorParameterEditor
StatechartEditorParameterEditor(QWidget *parent=0, statechartmodel::StateInstancePtr state=statechartmodel::StateInstancePtr(), const statechartmodel::StateParameterMap &params=statechartmodel::StateParameterMap())
Definition: StatechartEditorParameterEditor.cpp:71
State.h
armarx::StatechartEditorParameterEditor::setVariantInfo
void setVariantInfo(VariantInfoPtr variantInfo)
Definition: StatechartEditorParameterEditor.h:91
armarx::StatechartEditorParameterEditor::refreshVariantTypes
void refreshVariantTypes()
Definition: StatechartEditorParameterEditor.cpp:666
armarx::StatechartEditorParameterEditor::setHeaders
void setHeaders()
Definition: StatechartEditorParameterEditor.cpp:841
armarx::StatechartEditorParameterEditor::init
void init(const statechartmodel::StateParameterMap &params)
Definition: StatechartEditorParameterEditor.cpp:237
armarx::StatechartEditorParameterEditor::ColumnIds
ColumnIds
Definition: StatechartEditorParameterEditor.h:76
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::AnimatedToolButton
Definition: StatechartEditorParameterEditor.h:37
armarx::AnimatedToolButton::color
QColor color()
Definition: StatechartEditorParameterEditor.h:48
armarx::StatechartEditorParameterEditor::typeCbChanged
void typeCbChanged(const QString &)
Definition: StatechartEditorParameterEditor.cpp:575
VariantInfo.h