25#include <SimoxUtility/math/convert/quat_to_rpy.h>
26#include <SimoxUtility/math/convert/rpy_to_quat.h>
38#define INPUT_GUARD(i) \
40 ARMARX_CHECK_NOT_NULL(i); \
52 if (dict->getPath().hasElement())
55 group_hierarchy_.emplace_back(std::make_shared<RemoteGui::detail::GroupBoxBuilder>(
60 group_hierarchy_.push_back(builder_);
68 auto builder = *group_hierarchy_.back();
69 group_hierarchy_.pop_back();
70 if (!group_hierarchy_.empty())
72 group_hierarchy_.back()->addChild(builder);
86 .value(value->getValue())
90 group_hierarchy_.back()->addChild(group);
103 .value(value->getValue())
107 group_hierarchy_.back()->addChild(group);
120 .value(value->getValue())
124 group_hierarchy_.back()->addChild(group);
138 group_hierarchy_.back()->addChild(group);
152 group_hierarchy_.back()->addChild(group);
172 if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(),
type) !=
173 implementedListDescriptors.end())
178 for (
const auto& el :
data->getElements())
186 .toolTip(
"Remove List Element"),
189 group_hierarchy_.back()->addChild(
191 .label(o->getPath().getLastElement())
196 .toolTip(
"Add new list entry.")));
201 group_hierarchy_.emplace_back(std::make_shared<RemoteGui::detail::GroupBoxBuilder>(
213 if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(),
type) !=
214 implementedListDescriptors.end())
219 auto builder = *group_hierarchy_.back();
220 group_hierarchy_.pop_back();
221 if (not group_hierarchy_.empty())
223 group_hierarchy_.back()->addChild(builder);
239 .options(
type->getAcceptedValueNames())
240 .value(
type->getValueName(
data->getValue()))
242 group_hierarchy_.back()->addChild(group);
247 const std::shared_ptr<type::Variant>& t)
250 auto type = type::Matrix::DynamicCast(t);
251 const auto& cols =
type->getCols();
252 const auto& rows =
type->getRows();
258 if (cols == 4 and rows == 4)
264 else if ((cols == 3 and rows == 1) or (rows == 3 and cols == 1))
270 group_hierarchy_.back()->addChild(group);
275 const std::shared_ptr<type::Variant>& t)
280 const auto& quat = simox::math::quat_to_rpy(
293 group_hierarchy_.back()->addChild(group);
298 const std::shared_ptr<type::Variant>& t)
304 if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(),
type) ==
305 implementedListDescriptors.end())
309 for (
const auto& el :
data->getElements())
320 .toolTip(
"Remove List Element"),
323 group_hierarchy_.back()->addChild(
325 .label(o->getPath().getLastElement())
330 .toolTip(
"Add new dict entry.")));
335 const std::shared_ptr<type::Variant>&)
351 auto gui_value = proxy_->getValue<
int>(name);
352 if (value->getValue() != gui_value.get())
354 if (proxy_->hasValueChanged(name))
356 value->setValue(gui_value.get());
361 proxy_->setValue(value->getValue(), name);
372 auto gui_value = proxy_->getValue<
float>(name);
373 if (value->getValue() != gui_value.get())
375 if (proxy_->hasValueChanged(name))
377 value->setValue(gui_value.get());
382 proxy_->setValue(value->getValue(), name);
394 auto gui_value = proxy_->getValue<
float>(name);
395 if (value->getValue() != gui_value.get())
397 if (proxy_->hasValueChanged(name))
399 value->setValue(gui_value.get());
404 proxy_->setValue(
static_cast<float>(value->getValue()), name);
415 auto gui_value = proxy_->getValue<
bool>(name);
416 if (value->getValue() != gui_value.get())
418 if (proxy_->hasValueChanged(name))
420 value->setValue(gui_value.get());
425 proxy_->setValue(value->getValue(), name);
436 auto gui_value = proxy_->getValue<std::string>(name);
437 if (value->getValue() != gui_value.get())
439 if (proxy_->hasValueChanged(name))
441 value->setValue(gui_value.get());
446 proxy_->setValue(value->getValue(), name);
498 if (proxy_->hasValueChanged(name))
505 proxy_->setValue(
type->getValueName(
data->getValue()), name);
517 if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(),
type) !=
518 implementedListDescriptors.end())
522 const auto& elements =
data->getElements();
525 if (proxy_->getButtonClicked(
pathToName(el) +
"_button"))
527 data->removeElement(idx);
528 tab_rebuild_required_ =
true;
530 auto gui_value = proxy_->getValue<std::string>(
pathToName(el)).get();
533 if (proxy_->getButtonClicked(
pathToName(o) +
"_add"))
536 "", o->getPath().withIndex(
data->childrenSize())));
537 tab_rebuild_required_ =
true;
554 if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(),
type) !=
555 implementedListDescriptors.end())
568 return tab_rebuild_required_;
573 const std::shared_ptr<type::Variant>& t)
577 auto type = type::Matrix::DynamicCastAndCheck(t);
579 const auto& cols =
type->getCols();
580 const auto& rows =
type->getRows();
582 if (cols == 4 && rows == 4)
584 auto gui_value = proxy_->getValue<Eigen::Matrix4f>(name);
587 if (config_value != gui_value.get())
589 if (proxy_->hasValueChanged(name))
593 value->setData(gui_value.get().size() *
sizeof(
float), variant->getData());
597 proxy_->setValue(config_value, name);
601 else if ((cols == 3 and rows == 1) or (cols == 1 and rows == 3))
603 auto gui_value = proxy_->getValue<Eigen::Vector3f>(name);
606 if (config_value != gui_value.get())
608 if (proxy_->hasValueChanged(name))
612 value->setData(gui_value.get().size() *
sizeof(
float), variant->getData());
616 proxy_->setValue(config_value, name);
624 const std::shared_ptr<type::Variant>& t)
630 auto gui_value = proxy_->getValue<Eigen::Vector3f>(name);
631 const auto& quat = simox::math::quat_to_rpy(
633 if (quat != gui_value.get())
635 if (proxy_->hasValueChanged(name))
638 simox::math::rpy_to_quat(gui_value.get()));
639 value->setData(4 *
sizeof(
float), variant->getData());
643 proxy_->setValue(quat, name);
650 const std::shared_ptr<type::Variant>& t)
655 if (std::find(implementedListDescriptors.begin(), implementedListDescriptors.end(),
type) ==
656 implementedListDescriptors.end())
660 const auto& elements =
data->getElements();
661 std::map<std::string, std::string> changed_labels;
662 for (
const auto& [idx, el] : elements)
665 if (proxy_->getButtonClicked(name +
"_button"))
667 data->removeElement(idx);
668 tab_rebuild_required_ =
true;
670 auto gui_value = proxy_->getValue<std::string>(name).get();
671 auto gui_key = proxy_->getValue<std::string>(name +
"_lbl").get();
673 if (gui_value != config_value)
675 if (proxy_->hasValueChanged(name))
681 proxy_->setValue(config_value, name);
686 if (proxy_->hasValueChanged(name +
"_lbl"))
688 changed_labels.emplace(idx, gui_key);
692 proxy_->setValue(idx, name +
"_lbl");
697 for (
const auto& [old_label, new_label] : changed_labels)
699 auto element =
data->getElement(old_label);
700 data->removeElement(old_label);
702 data->addElement(new_label,
703 variantHelper->from_string(
704 variantHelper->to_string(element),
705 o->getPath().withDetachedLastElement().withElement(new_label)));
706 tab_rebuild_required_ =
true;
709 if (proxy_->getButtonClicked(
pathToName(o) +
"_add"))
711 data->addElement(
"defaultKey",
713 "", o->getPath().withElement(
"defaultKey")));
714 tab_rebuild_required_ =
true;
720 const std::shared_ptr<type::Variant>&)
static auto make(const type::Descriptor &s, Args &&... args)
MapElements getObjectElements(DataInput &, TypeInput &) override
void visitString(DataInput &, TypeInput &) override
bool tabRebuildRequired() const
GetValueFromMapVisitor(armarx::RemoteGui::TabProxy *proxy)
PairElements getPairElements(DataInput &, TypeInput &) override
void visitDictOnExit(DataInput &, TypeInput &) override
TupleElements getTupleElements(DataInput &, TypeInput &) override
type::Descriptor getDescriptor(DataInput &, TypeInput &) override
void visitFloat(DataInput &, TypeInput &) override
void visitIntEnum(DataInput &, TypeInput &) override
void visitQuaternion(DataInput &elementData, TypeInput &elementType) override
void visitListOnExit(DataInput &, TypeInput &) override
void visitDictOnEnter(DataInput &, TypeInput &) override
void visitMatrix(DataInput &elementData, TypeInput &elementType) override
void visitInt(DataInput &, TypeInput &) override
ListElements getListElements(DataInput &, TypeInput &) override
void visitDouble(DataInput &, TypeInput &) override
void visitListOnEnter(DataInput &, TypeInput &) override
MapElements getDictElements(DataInput &, TypeInput &) override
void visitBool(DataInput &, TypeInput &) override
void visitString(DataInput &, TypeInput &) override
RemoteGui::detail::GroupBoxBuilder getGroupBoxBuilder() const
void visitMatrix(DataInput &input, TypeInput &typeInput) override
void visitObjectOnEnter(DataInput &, TypeInput &) override
void visitDictOnExit(DataInput &, TypeInput &) override
MakeConfigGuiVisitor(const std::string &name)
void visitQuaternion(DataInput &input, TypeInput &typeInput) override
void visitFloat(DataInput &, TypeInput &) override
void visitIntEnum(DataInput &, TypeInput &) override
void visitListOnExit(DataInput &, TypeInput &) override
void visitDictOnEnter(DataInput &, TypeInput &) override
void visitInt(DataInput &, TypeInput &) override
void visitDouble(DataInput &, TypeInput &) override
void visitListOnEnter(DataInput &, TypeInput &) override
void visitObjectOnExit(DataInput &, TypeInput &) override
void visitBool(DataInput &, TypeInput &) override
static Eigen::Matrix4f ConvertToMatrix4f(const data::NDArrayPtr &)
static Eigen::Vector3f ConvertToVector3f(const data::NDArrayPtr &)
static data::NDArrayPtr ConvertFromQuaternion(const Eigen::Quaternion< T > &quat)
static data::NDArrayPtr ConvertFromMatrix(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &mat)
static Eigen::Quaternion< float > ConvertToQuaternionf(const data::NDArrayPtr &)
static PointerType DynamicCastAndCheck(const VariantPtr &n)
VariantPtr getAcceptedType() const
VariantPtr getAcceptedType() const
static List & DynamicCast(Variant &n)
static std::shared_ptr< DerivedT > DynamicCastAndCheck(const VariantPtr &n)
detail::IntSpinBoxBuilder makeIntSpinBox(std::string const &name)
detail::CheckBoxBuilder makeCheckBox(std::string const &name)
detail::ComboBoxBuilder makeComboBox(std::string const &name)
detail::FloatSpinBoxBuilder makeFloatSpinBox(std::string const &name)
detail::PosRPYSpinBoxesBuilder makePosRPYSpinBoxes(std::string const &name, float limpos=1000, float limrpy=M_PI)
detail::HBoxLayoutBuilder makeHBoxLayout(std::string const &name="")
detail::Vector3fSpinBoxesBuilder makeVector3fSpinBoxes(std::string const &name, float limpos=1000)
detail::SimpleGridLayoutBuilder makeSimpleGridLayout(std::string const &name="")
detail::ButtonBuilder makeButton(std::string const &name)
detail::LabelBuilder makeLabel(std::string const &name)
detail::GroupBoxBuilder makeGroupBox(std::string const &name="")
detail::LineEditBuilder makeLineEdit(std::string const &name)
std::pair< std::pair< typename std::remove_const< DataInputT >::type, typename std::remove_const< TypeInputT >::type >, std::pair< typename std::remove_const< DataInputT >::type, typename std::remove_const< TypeInputT >::type > > getPairElements(DataInputT &o, TypeInputT &t)
std::string pathToName(const std::shared_ptr< data::Variant > &v)
std::map< std::string, std::pair< typename std::remove_const< DataInputT >::type, typename std::remove_const< TypeInputT >::type > > getObjectElements(DataInputT &o, TypeInputT &t)
std::vector< std::pair< typename std::remove_const< DataInputT >::type, typename std::remove_const< TypeInputT >::type > > getListElements(DataInputT &o, TypeInputT &t)
std::map< std::string, std::pair< typename std::remove_const< DataInputT >::type, typename std::remove_const< TypeInputT >::type > > getDictElements(DataInputT &o, TypeInputT &t)
std::vector< std::pair< typename std::remove_const< DataInputT >::type, typename std::remove_const< TypeInputT >::type > > getTupleElements(DataInputT &o, TypeInputT &t)
A convenience header to include all aron files (full include, not forward declared)
A convenience header to include all aron files (full include, not forward declared)
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
auto MakeIndexedContainer(Container &c, Containers &... cs)
const std::string & to_string(const std::string &s)
std::vector< T > min(const std::vector< T > &v1, const std::vector< T > &v2)
SimpleGridLayoutBuilder & cols(int n)
static type::Descriptor GetDescriptor(DataInput &i, TypeInput &j)
typename TypedVisitorBase< const data::VariantPtr, const type::VariantPtr >::TypeInput TypeInput
std::vector< std::pair< DataInputNonConst, TypeInputNonConst > > ListElements
typename TypedVisitorBase< const data::VariantPtr, const type::VariantPtr >::DataInput DataInput
std::pair< std::pair< DataInputNonConst, TypeInputNonConst >, std::pair< DataInputNonConst, TypeInputNonConst > > PairElements
std::vector< std::pair< DataInputNonConst, TypeInputNonConst > > TupleElements
std::map< std::string, std::pair< DataInputNonConst, TypeInputNonConst > > MapElements