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 
30 
32 
34 
35 class QComboBox;
36 
37 namespace armarx
38 {
39 
40  class StateParameterEditor : public QTableWidget
41  {
42  Q_OBJECT
43  public:
44 
45  enum ColumnIds
46  {
53  };
54  explicit StateParameterEditor(QWidget* parent = 0, const StateParameterMap& params = StateParameterMap());
55 
57  {
58  this->communicator = communicator;
59  }
60  void setVariantInfo(VariantInfoPtr variantInfo)
61  {
62  this->variantInfo = variantInfo;
63  }
65  {
66  this->currentProfile = currentProfile;
67  }
68  void setKeyBlackList(const QSet<QString>& keyBlackList);
69  QSet<QString> getKeys() const;
71  StringVariantContainerBaseMap getStringValueMap() const;
73 
74  QString getValueAsString(int row) const;
75  VariantContainerBasePtr getVariantContainer(int row) const;
76  QString getJson(QString key) const;
77  QString getKey(int row) const;
78  QString getType(int row) const;
79  QString getType(QString key) const;
80  int getRow(const QString& key) const;
81  bool getIsOptional(int row) const;
82 
83  void addParameterRow(QString key, QString variantIdStr, QString value, bool optional = false);
84  void createValueButton(int row, const QString& jsonValue);
85  void setHeaders();
86  Qt::CheckState getDefaultValueState() const;
87  void setDefaultValueState(const Qt::CheckState& value);
88 
89  StateParameterIceBasePtr getStateParameter(int row) const;
90  signals:
91  void buildRequested(const StateParameterMap& map, const std::map<QString, std::pair<QString, QString> >& jsonStringMap);
92  void rowAdded(int rowId);
93  void rowFilled(int rowId, const QString& key);
94  public slots:
95  void buildFromMap(const StateParameterMap& map, const std::map<QString, std::pair<QString, QString> >& jsonStringMap = std::map<QString, std::pair<QString, QString>>());
96  int addParameterRow();
97  void typeCbChanged(const QString& text);
98  void deleteRow();
99  void checkAndUpdateRowCount(int row, int column);
100  void refreshVariantTypes();
102  private slots:
103  void __buildFromMap(const StateParameterMap& map, const std::map<QString, std::pair<QString, QString> >& jsonStringMap = std::map<QString, std::pair<QString, QString>>());
104 
105  private:
106  void connectUserEditSlots();
107  void addVariantTypesToComboBox(QComboBox* combo);
108  QString getHumanNameFromBaseName(QString variantBaseTypeName) const;
109  QString getBaseNameFromHumanName(QString humanName) const;
110  static bool compareVariantNames(const QString& a, const QString& b);
111 
112  class LineEditDelegate : public QStyledItemDelegate
113  {
114  QWidget* createEditor(QWidget* parent,
115  const QStyleOptionViewItem& option,
116  const QModelIndex& index) const override;
117  };
118  LineEditDelegate delegate;
119  Ice::CommunicatorPtr communicator;
120  VariantInfoPtr variantInfo;
121  Qt::CheckState defaultValueState;
122  QSet<QString> keyBlackList;
123  StatechartProfilePtr currentProfile;
124 
125  };
126 
127 }
128 
armarx::StateParameterEditor::eOptional
@ eOptional
Definition: StateParameterEditor.h:49
armarx::StateParameterEditor
Definition: StateParameterEditor.h:40
armarx::StateParameterEditor::eType
@ eType
Definition: StateParameterEditor.h:48
armarx::StateParameterEditor::getKeys
QSet< QString > getKeys() const
Definition: StateParameterEditor.cpp:84
armarx::StateParameterEditor::eKey
@ eKey
Definition: StateParameterEditor.h:47
armarx::StateParameterEditor::getDefaultValueState
Qt::CheckState getDefaultValueState() const
Definition: StateParameterEditor.cpp:932
armarx::StateParameterEditor::getStringValueMap
StringVariantContainerBaseMap getStringValueMap() const
Definition: StateParameterEditor.cpp:141
index
uint8_t index
Definition: EtherCATFrame.h:59
armarx::StateParameterEditor::setDefaultValueState
void setDefaultValueState(const Qt::CheckState &value)
Definition: StateParameterEditor.cpp:937
armarx::StateParameterEditor::setCurrentProfile
void setCurrentProfile(StatechartProfilePtr currentProfile)
Definition: StateParameterEditor.h:64
armarx::StatechartProfilePtr
std::shared_ptr< class StatechartProfile > StatechartProfilePtr
Definition: StatechartContext.h:52
armarx::StateParameterEditor::getStateParameters
StateParameterMap getStateParameters() const
Definition: StateParameterEditor.cpp:113
armarx::StateParameterEditor::addParameterRow
int addParameterRow()
Definition: StateParameterEditor.cpp:424
armarx::StateParameterEditor::createValueButton
void createValueButton(int row, const QString &jsonValue)
Definition: StateParameterEditor.cpp:531
armarx::StateParameterEditor::setCommunicator
void setCommunicator(Ice::CommunicatorPtr communicator)
Definition: StateParameterEditor.h:56
armarx::StateParameterEditor::getType
QString getType(int row) const
Definition: StateParameterEditor.cpp:366
armarx::StateParameterEditor::editDefaultButtonClicked
void editDefaultButtonClicked()
Definition: StateParameterEditor.cpp:774
Statechart.h
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:956
armarx::StateParameterEditor::ColumnIds
ColumnIds
Definition: StateParameterEditor.h:45
IceInternal::Handle< ::Ice::Communicator >
armarx::StateParameterEditor::getStateParameter
StateParameterIceBasePtr getStateParameter(int row) const
Definition: StateParameterEditor.cpp:99
armarx::StateParameterEditor::getValueAsString
QString getValueAsString(int row) const
Definition: StateParameterEditor.cpp:160
armarx::StateParameterEditor::getKey
QString getKey(int row) const
Definition: StateParameterEditor.cpp:351
armarx::StateParameterEditor::eDeleteButton
@ eDeleteButton
Definition: StateParameterEditor.h:52
armarx::StateParameterEditor::setKeyBlackList
void setKeyBlackList(const QSet< QString > &keyBlackList)
Definition: StateParameterEditor.cpp:79
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:926
armarx::StateParameterEditor::getVariantContainer
VariantContainerBasePtr getVariantContainer(int row) const
Definition: StateParameterEditor.cpp:263
armarx::statechartmodel::StateParameterMap
QMap< QString, StateParameterPtr > StateParameterMap
Definition: StateParameter.h:46
armarx::StateParameterEditor::setVariantInfo
void setVariantInfo(VariantInfoPtr variantInfo)
Definition: StateParameterEditor.h:60
armarx::StateParameterEditor::getJson
QString getJson(QString key) const
Definition: StateParameterEditor.cpp:177
armarx::StateParameterEditor::refreshVariantTypes
void refreshVariantTypes()
Definition: StateParameterEditor.cpp:763
armarx::StateParameterEditor::getIsOptional
bool getIsOptional(int row) const
Definition: StateParameterEditor.cpp:412
armarx::StateParameterEditor::getRow
int getRow(const QString &key) const
Definition: StateParameterEditor.cpp:391
StatechartProfiles.h
armarx::StateParameterEditor::setHeaders
void setHeaders()
Definition: StateParameterEditor.cpp:945
armarx::StateParameterEditor::eProvideDefaultValue
@ eProvideDefaultValue
Definition: StateParameterEditor.h:50
armarx::StateParameterEditor::rowFilled
void rowFilled(int rowId, const QString &key)
option
#define option(type, fn)
armarx::StateParameterEditor::buildRequested
void buildRequested(const StateParameterMap &map, const std::map< QString, std::pair< QString, QString > > &jsonStringMap)
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:716
armarx::StateParameterEditor::StateParameterEditor
StateParameterEditor(QWidget *parent=0, const StateParameterMap &params=StateParameterMap())
Definition: StateParameterEditor.cpp:50
armarx::StateParameterEditor::deleteRow
void deleteRow()
Definition: StateParameterEditor.cpp:698
armarx::StateParameterEditor::eValue
@ eValue
Definition: StateParameterEditor.h:51
armarx::StateParameterEditor::rowAdded
void rowAdded(int rowId)
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::StateParameterEditor::typeCbChanged
void typeCbChanged(const QString &text)
Definition: StateParameterEditor.cpp:633
VariantInfo.h