From 3441aed519a1d90ed71158dfcb963ab294b883e0 Mon Sep 17 00:00:00 2001 From: Fabian Peller <fabian.peller-konrad@kit.edu> Date: Mon, 13 Mar 2023 17:27:47 +0000 Subject: [PATCH] fix runtime error in add_element context menu --- .../ArMemExample/config/ExampleMemory.cfg | 109 +----------------- .../AronTreeWidgetController.cpp | 26 +++-- .../visitors/AronTreeWidgetConverter.cpp | 21 +++- .../visitors/AronTreeWidgetModalCreator.cpp | 81 ++----------- .../visitors/AronTreeWidgetModalCreator.h | 28 ++--- .../widgets/EditMatrixWidget.cpp | 34 +++--- .../aronTreeWidget/widgets/EditMatrixWidget.h | 23 ++-- 7 files changed, 86 insertions(+), 236 deletions(-) diff --git a/scenarios/ArMemExample/config/ExampleMemory.cfg b/scenarios/ArMemExample/config/ExampleMemory.cfg index 7989108bc..251382f2a 100644 --- a/scenarios/ArMemExample/config/ExampleMemory.cfg +++ b/scenarios/ArMemExample/config/ExampleMemory.cfg @@ -143,21 +143,12 @@ ArmarX.ArMemExampleMemory.tpc.pub.MemoryListener = MemoryUpdates # ArmarX.ExampleMemory.mem.MemoryName = Example -# ArmarX.ExampleMemory.mem.ltm..buffer.storeFreq: Frequency to store the buffer to the LTM in Hz. +# ArmarX.ExampleMemory.mem.ltm.configuration: # Attributes: -# - Default: 10 +# - Default: {} # - Case sensitivity: yes # - Required: no -# ArmarX.ExampleMemory.mem.ltm..buffer.storeFreq = 10 - - -# ArmarX.ExampleMemory.mem.ltm.depthImageExtractor.Enabled: -# Attributes: -# - Default: true -# - Case sensitivity: yes -# - Required: no -# - Possible values: {0, 1, false, no, true, yes} -# ArmarX.ExampleMemory.mem.ltm.depthImageExtractor.Enabled = true +# ArmarX.ExampleMemory.mem.ltm.configuration = {} # ArmarX.ExampleMemory.mem.ltm.enabled: @@ -169,100 +160,6 @@ ArmarX.ArMemExampleMemory.tpc.pub.MemoryListener = MemoryUpdates # ArmarX.ExampleMemory.mem.ltm.enabled = false -# ArmarX.ExampleMemory.mem.ltm.exrConverter.Enabled: -# Attributes: -# - Default: true -# - Case sensitivity: yes -# - Required: no -# - Possible values: {0, 1, false, no, true, yes} -# ArmarX.ExampleMemory.mem.ltm.exrConverter.Enabled = true - - -# ArmarX.ExampleMemory.mem.ltm.imageExtractor.Enabled: -# Attributes: -# - Default: true -# - Case sensitivity: yes -# - Required: no -# - Possible values: {0, 1, false, no, true, yes} -# ArmarX.ExampleMemory.mem.ltm.imageExtractor.Enabled = true - - -# ArmarX.ExampleMemory.mem.ltm.memFreqFilter.Enabled: -# Attributes: -# - Default: false -# - Case sensitivity: yes -# - Required: no -# - Possible values: {0, 1, false, no, true, yes} -# ArmarX.ExampleMemory.mem.ltm.memFreqFilter.Enabled = false - - -# ArmarX.ExampleMemory.mem.ltm.memFreqFilter.WaitingTime: Waiting time in MS after each LTM update. -# Attributes: -# - Default: -1 -# - Case sensitivity: yes -# - Required: no -# ArmarX.ExampleMemory.mem.ltm.memFreqFilter.WaitingTime = -1 - - -# ArmarX.ExampleMemory.mem.ltm.pngConverter.Enabled: -# Attributes: -# - Default: true -# - Case sensitivity: yes -# - Required: no -# - Possible values: {0, 1, false, no, true, yes} -# ArmarX.ExampleMemory.mem.ltm.pngConverter.Enabled = true - - -# ArmarX.ExampleMemory.mem.ltm.sizeToCompressDataInMegaBytes: The size in MB to compress away the current export. Exports are numbered (lower number means newer). -# Attributes: -# - Default: 1024 -# - Case sensitivity: yes -# - Required: no -# ArmarX.ExampleMemory.mem.ltm.sizeToCompressDataInMegaBytes = 1024 - - -# ArmarX.ExampleMemory.mem.ltm.snapEqFilter.Enabled: -# Attributes: -# - Default: false -# - Case sensitivity: yes -# - Required: no -# - Possible values: {0, 1, false, no, true, yes} -# ArmarX.ExampleMemory.mem.ltm.snapEqFilter.Enabled = false - - -# ArmarX.ExampleMemory.mem.ltm.snapEqFilter.MaxWaitingTime: Max Waiting time in MS after each Entity update. -# Attributes: -# - Default: -1 -# - Case sensitivity: yes -# - Required: no -# ArmarX.ExampleMemory.mem.ltm.snapEqFilter.MaxWaitingTime = -1 - - -# ArmarX.ExampleMemory.mem.ltm.snapFreqFilter.Enabled: -# Attributes: -# - Default: false -# - Case sensitivity: yes -# - Required: no -# - Possible values: {0, 1, false, no, true, yes} -# ArmarX.ExampleMemory.mem.ltm.snapFreqFilter.Enabled = false - - -# ArmarX.ExampleMemory.mem.ltm.snapFreqFilter.WaitingTime: Waiting time in MS after each Entity update. -# Attributes: -# - Default: -1 -# - Case sensitivity: yes -# - Required: no -# ArmarX.ExampleMemory.mem.ltm.snapFreqFilter.WaitingTime = -1 - - -# ArmarX.ExampleMemory.mem.ltm.storagepath: The path to the memory storage (the memory will be stored in a seperate subfolder). -# Attributes: -# - Default: Default value not mapped. -# - Case sensitivity: yes -# - Required: no -# ArmarX.ExampleMemory.mem.ltm.storagepath = Default value not mapped. - - # ArmarX.ExampleMemory.mns.MemoryNameSystemEnabled: Whether to use (and depend on) the Memory Name System (MNS). # Set to false to use this memory as a stand-alone. # Attributes: diff --git a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/AronTreeWidgetController.cpp b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/AronTreeWidgetController.cpp index e1bc78574..52110b494 100644 --- a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/AronTreeWidgetController.cpp +++ b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/AronTreeWidgetController.cpp @@ -79,6 +79,8 @@ namespace armarx void AronTreeWidgetController::ShowContextMenu(const QPoint& pos) { + tree->blockSignals(true); + auto idx = tree->indexAt(pos); AronTreeWidgetItem* clickedItem = AronTreeWidgetItem::DynamicCast(tree->itemAt(pos)); if (clickedItem) @@ -88,6 +90,8 @@ namespace armarx aron::type::visit(visitor, clickedItem->aronType); visitor.showMenuAndExecute(); } + + tree->blockSignals(false); } void AronTreeWidgetController::onTreeWidgetItemDoubleClicked(QTreeWidgetItem* item, int column) @@ -96,6 +100,8 @@ namespace armarx { return; } + tree->blockSignals(true); + auto* aronItem = AronTreeWidgetItem::DynamicCast(item); if (column == 1 && aronItem) { @@ -122,6 +128,8 @@ namespace armarx { item->treeWidget()->editItem(item, column); } + + tree->blockSignals(false); } void @@ -135,15 +143,19 @@ namespace armarx aronElem->onUserChange(column); } // start conversion for entire tree -- this also sets the highlighting - ARMARX_CHECK(parent->childCount() == 1); - auto* aronTreeRoot = AronTreeWidgetItem::DynamicCast(parent->child(0)); - aronTreeRoot->resetError(); - if (aronTreeRoot) + if (parent->childCount() == 1) { - AronTreeWidgetConverterVisitor v(parent, 0); - aron::type::visit(v, type); - aronTreeRoot->setValueErrorState(v.hasDirectError(), v.onlyChildFailedConversion()); + auto* aronTreeRoot = AronTreeWidgetItem::DynamicCast(parent->child(0)); + aronTreeRoot->resetError(); + if (aronTreeRoot) + { + AronTreeWidgetConverterVisitor v(parent, 0); + aron::type::visit(v, type); + aronTreeRoot->setValueErrorState(v.hasDirectError(), v.onlyChildFailedConversion()); + } } + // else perhaps the GUI was stopped or died. + tree->blockSignals(false); } diff --git a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetConverter.cpp b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetConverter.cpp index 3eeee694b..c0a8088db 100644 --- a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetConverter.cpp +++ b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetConverter.cpp @@ -64,6 +64,7 @@ namespace armarx AronTreeWidgetConverterVisitor::handleErrors(AronTreeWidgetConverterVisitor childV, bool ownFault) { + ARMARX_TRACE; isDirectError |= ownFault; hasTransitiveError |= childV.isDirectError || childV.hasTransitiveError; @@ -75,6 +76,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::handleErrors(bool ownFault) { + ARMARX_TRACE; isDirectError = ownFault; auto* aronItem = AronTreeWidgetItem::DynamicCast(parentItem->child(index)); ARMARX_CHECK(aronItem); @@ -85,6 +87,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::ObjectPtr& i) { + ARMARX_TRACE; auto createdAronDict = std::make_shared<aron::data::Dict>(i->getPath()); createdAron = createdAronDict; QTreeWidgetItem* el = parentItem->child(index); @@ -92,6 +95,7 @@ namespace armarx unsigned int x = 0; for (const auto& [key, value] : i->getMemberTypes()) { + ARMARX_TRACE; AronTreeWidgetConverterVisitor v(el, x++); aron::type::visit(v, value); @@ -106,6 +110,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::DictPtr& i) { + ARMARX_TRACE; auto createdAronDict = std::make_shared<aron::data::Dict>(i->getPath()); createdAron = createdAronDict; QTreeWidgetItem* el = parentItem->child(index); @@ -128,6 +133,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::ListPtr& i) { + ARMARX_TRACE; auto createdAronList = std::make_shared<aron::data::List>(i->getPath()); createdAron = createdAronList; auto* elem = parentItem->child(index); @@ -150,6 +156,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::PairPtr& i) { + ARMARX_TRACE; auto createdAronPair = std::make_shared<aron::data::List>(i->getPath()); createdAron = createdAronPair; auto* elem = parentItem->child(index); @@ -168,7 +175,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::TuplePtr& i) { - + ARMARX_TRACE; auto createdAronList = std::make_shared<aron::data::List>(i->getPath()); createdAron = createdAronList; QTreeWidgetItem* el = parentItem->child(index); @@ -190,12 +197,14 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::NDArrayPtr& i) { + ARMARX_TRACE; ARMARX_ERROR << "Currently do not support supplying raw NDArrays!"; } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::MatrixPtr& i) { + ARMARX_TRACE; auto createdMatrix = std::make_shared<aron::data::NDArray>(i->getPath()); int dataSize = 0; switch (i->getElementType()) @@ -248,6 +257,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::QuaternionPtr& i) { + ARMARX_TRACE; auto createdQuat = std::make_shared<aron::data::NDArray>(i->getPath()); createdAron = createdQuat; int dataSize = i->getElementType() == aron::type::quaternion::ElementType::FLOAT32 ? 4 : 8; @@ -277,18 +287,21 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::ImagePtr& i) { + ARMARX_TRACE; // TODO } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::PointCloudPtr& i) { + ARMARX_TRACE; // TODO } void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::IntEnumPtr& i) { + ARMARX_TRACE; QTreeWidgetItem* el = parentItem->child(index); auto* genericWidget = el->treeWidget()->itemWidget(el, 1); auto* intEnumWidget = IntEnumWidget::DynamicCastAndCheck(genericWidget); @@ -306,6 +319,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::IntPtr& i) { + ARMARX_TRACE; auto createdAronInt = std::make_shared<aron::data::Int>(i->getPath()); createdAron = createdAronInt; QTreeWidgetItem* el = parentItem->child(index); @@ -334,6 +348,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::LongPtr& i) { + ARMARX_TRACE; auto createdAronLong = std::make_shared<aron::data::Long>(i->getPath()); createdAron = createdAronLong; QTreeWidgetItem* el = parentItem->child(index); @@ -361,6 +376,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::FloatPtr& i) { + ARMARX_TRACE; auto createdAronFloat = std::make_shared<aron::data::Float>(i->getPath()); createdAron = createdAronFloat; QTreeWidgetItem* el = parentItem->child(index); @@ -387,6 +403,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::DoublePtr& i) { + ARMARX_TRACE; auto createdAronDouble = std::make_shared<aron::data::Double>(i->getPath()); createdAron = createdAronDouble; QTreeWidgetItem* el = parentItem->child(index); @@ -413,6 +430,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::BoolPtr& i) { + ARMARX_TRACE; auto createdAronBool = std::make_shared<aron::data::Bool>(i->getPath()); createdAron = createdAronBool; QTreeWidgetItem* el = parentItem->child(index); @@ -439,6 +457,7 @@ namespace armarx void AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::StringPtr& i) { + ARMARX_TRACE; auto createdAronString = std::make_shared<aron::data::String>(i->getPath()); createdAron = createdAronString; QTreeWidgetItem* el = parentItem->child(index); diff --git a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetModalCreator.cpp b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetModalCreator.cpp index edb553e2d..bb76232a8 100644 --- a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetModalCreator.cpp +++ b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetModalCreator.cpp @@ -20,14 +20,15 @@ * GNU General Public License */ -#include "AronTreeWidgetModalCreator.h" - #include <string> +#include "AronTreeWidgetModalCreator.h" + #include <SimoxUtility/algorithm/string.h> // modals #include "../modal/text/AronTreeWidgetTextInputModalController.h" +#include "../modal/dict/AronTreeWidgetDictInputModalController.h" // qt #include <QTreeWidget> @@ -36,81 +37,15 @@ namespace armarx { - void AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::ObjectPtr& i) - { - } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::DictPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::PairPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::TuplePtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::ListPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::NDArrayPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::MatrixPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::QuaternionPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::ImagePtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::PointCloudPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::IntEnumPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::IntPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::LongPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::FloatPtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::DoublePtr& i) - { } - - void - AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::BoolPtr& i) - { } - void AronTreeWidgetModalCreatorVisitor::visitAronVariant(const aron::type::StringPtr& i) { - createdModal = - std::make_shared<AronTreeWidgetTextInputModalController>(label, item, parent); + createdModal = std::make_shared<AronTreeWidgetTextInputModalController>(label, item, parent); } - void - AronTreeWidgetModalCreatorVisitor::visitUnknown(Input&) + void AronTreeWidgetModalCreatorVisitor::visitUnknown(Input&) { - ARMARX_WARNING_S << "Received an unknown type when trying to create a tree view widget " - "modal for a skill argument type."; + ARMARX_WARNING_S << "Received an unknown type when trying to create a tree view widget modal for a skill argument type."; } -} // namespace armarx +} + diff --git a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetModalCreator.h b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetModalCreator.h index e22930a10..f4c8f0223 100644 --- a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetModalCreator.h +++ b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/visitors/AronTreeWidgetModalCreator.h @@ -29,15 +29,17 @@ namespace armarx { - // Convert aron type to tree widget + // Convert aron type to tree widget. + // (Widgets are only created for string types to enter longer texts. + // However, the visitor implementation allows modals for differnt types. Might be useful in the future..) class AronTreeWidgetModalCreatorVisitor : public armarx::aron::type::ConstVariantVisitor { public: - std::string label; - AronTreeWidgetItem* item; - QTreeWidget* parent; - AronTreeWidgetModalControllerPtr createdModal; + std::string label = ""; + AronTreeWidgetItem* item = nullptr; + QTreeWidget* parent = nullptr; + AronTreeWidgetModalControllerPtr createdModal = nullptr; AronTreeWidgetModalCreatorVisitor() = delete; AronTreeWidgetModalCreatorVisitor(const std::string& label, AronTreeWidgetItem* item, QTreeWidget* parent) : @@ -46,22 +48,6 @@ namespace armarx parent(parent) {} - void visitAronVariant(const aron::type::ObjectPtr&) final; - void visitAronVariant(const aron::type::DictPtr& i) final; - void visitAronVariant(const aron::type::PairPtr& i) final; - void visitAronVariant(const aron::type::TuplePtr& i) final; - void visitAronVariant(const aron::type::ListPtr& i) final; - void visitAronVariant(const aron::type::NDArrayPtr& i) final; - void visitAronVariant(const aron::type::MatrixPtr& i) final; - void visitAronVariant(const aron::type::QuaternionPtr& i) final; - void visitAronVariant(const aron::type::ImagePtr& i) final; - void visitAronVariant(const aron::type::PointCloudPtr& i) final; - void visitAronVariant(const aron::type::IntEnumPtr& i) final; - void visitAronVariant(const aron::type::IntPtr& i) final; - void visitAronVariant(const aron::type::LongPtr& i) final; - void visitAronVariant(const aron::type::FloatPtr& i) final; - void visitAronVariant(const aron::type::DoublePtr& i) final; - void visitAronVariant(const aron::type::BoolPtr& i) final; void visitAronVariant(const aron::type::StringPtr& i) final; void visitUnknown(Input&) final; }; diff --git a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/widgets/EditMatrixWidget.cpp b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/widgets/EditMatrixWidget.cpp index a3d6f0ffd..8e01710f0 100644 --- a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/widgets/EditMatrixWidget.cpp +++ b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/widgets/EditMatrixWidget.cpp @@ -12,8 +12,8 @@ namespace armarx { - EditMatrixWidget::EditMatrixWidget(size_t numRows, - size_t numCols, + EditMatrixWidget::EditMatrixWidget(long numRows, + long numCols, aron::type::matrix::ElementType elemType, QTreeWidgetItem* currentItem) : CustomWidget(currentItem) @@ -28,10 +28,10 @@ namespace armarx QGridLayout* innerGrid = new QGridLayout(); - const size_t createRows = std::min(numRows, MAX_ROWS_DISPLAY); - const size_t createCols = std::min(numCols, MAX_COLS_DISPLAY); + const long createRows = std::min(numRows, MAX_ROWS_DISPLAY); + const long createCols = std::min(numCols, MAX_COLS_DISPLAY); - for (size_t i = 0; i < createRows * createCols; ++i) + for (long i = 0; i < createRows * createCols; ++i) { auto* edit = new QLineEdit(); dispElements.push_back(edit); @@ -68,7 +68,7 @@ namespace armarx hiddenElems.push_back(std::vector<std::string>(hiddenCols * createRows, "")); // add all rows that are hidden - for (size_t i = 0; i < numRows - createRows; ++i) + for (long i = 0; i < numRows - createRows; ++i) { // add full cols; everything is hidden here hiddenElems.push_back(std::vector<std::string>(numCols, "")); @@ -101,7 +101,7 @@ namespace armarx } void - EditMatrixWidget::setText(size_t row, size_t col, const std::string& str) + EditMatrixWidget::setText(long row, long col, const std::string& str) { ARMARX_CHECK(row < realRows); ARMARX_CHECK(col < realCols); @@ -114,7 +114,7 @@ namespace armarx } else if (row < dispRows) { - size_t idx = row * (realCols - dispCols) + col - dispCols; + long idx = row * (realCols - dispCols) + col - dispCols; hiddenElems.at(0).at(idx) = str; } else @@ -124,7 +124,7 @@ namespace armarx } std::string - EditMatrixWidget::getText(size_t row, size_t col) + EditMatrixWidget::getText(long row, long col) { ARMARX_CHECK(row < realRows); ARMARX_CHECK(col < realCols); @@ -138,7 +138,7 @@ namespace armarx else if (row < getDisplayedRows()) { // the stuff besides the displayed rows - size_t idx = row * (realCols - dispCols) + col - dispCols; + long idx = row * (realCols - dispCols) + col - dispCols; return hiddenElems.at(0).at(idx); } else @@ -153,9 +153,9 @@ namespace armarx { auto dispRows = getDisplayedRows(); auto dispCols = getDisplayedCols(); - for (size_t row = 0; row < dispRows; ++row) + for (long row = 0; row < dispRows; ++row) { - for (size_t col = 0; col < dispCols; ++col) + for (long col = 0; col < dispCols; ++col) { auto parsed = parseElement(row, col); if (parsed.empty()) @@ -176,9 +176,9 @@ namespace armarx EditMatrixWidget::hasParseErrors() { // also parse the hidden stuff! - for (size_t row = 0; row < realRows; ++row) + for (long row = 0; row < realRows; ++row) { - for (size_t col = 0; col < realCols; ++col) + for (long col = 0; col < realCols; ++col) { auto parsed = parseElement(row, col); if (parsed.empty()) @@ -199,7 +199,7 @@ namespace armarx } std::vector<unsigned char> - EditMatrixWidget::parseElement(size_t row, size_t col) + EditMatrixWidget::parseElement(long row, long col) { std::string str = getText(row, col); try @@ -229,12 +229,12 @@ namespace armarx return {}; } - size_t + long EditMatrixWidget::getDisplayedRows() const { return std::min(realRows, MAX_ROWS_DISPLAY); } - size_t + long EditMatrixWidget::getDisplayedCols() const { return std::min(realCols, MAX_COLS_DISPLAY); diff --git a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/widgets/EditMatrixWidget.h b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/widgets/EditMatrixWidget.h index b086fb2ca..2aa0542fb 100644 --- a/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/widgets/EditMatrixWidget.h +++ b/source/RobotAPI/gui-plugins/SkillManagerPlugin/aronTreeWidget/widgets/EditMatrixWidget.h @@ -20,8 +20,9 @@ namespace armarx { Q_OBJECT public: - EditMatrixWidget(size_t numRows, - size_t numCols, + EditMatrixWidget() = delete; + EditMatrixWidget(long numRows, + long numCols, aron::type::matrix::ElementType elemType, QTreeWidgetItem* currentWidget); @@ -29,24 +30,24 @@ namespace armarx static EditMatrixWidget* DynamicCastAndCheck(QWidget*); // Sets the text on all visible rows and cols. - void setText(size_t row, size_t col, const std::string& str); - std::string getText(size_t row, size_t col); + void setText(long row, long col, const std::string& str); + std::string getText(long row, long col); void highlightUnparsableEntries(); bool hasParseErrors(); // returns an empty vector if parsing failed. Else, contains the individual bytes. - std::vector<unsigned char> parseElement(size_t row, size_t col); + std::vector<unsigned char> parseElement(long row, long col); private: // Dimensions of the underlying Type to represent - size_t realRows; - size_t realCols; + long realRows = 1; + long realCols = 1; // maximum of rows / cols to display - static constexpr size_t MAX_ROWS_DISPLAY = 5; - static constexpr size_t MAX_COLS_DISPLAY = 5; - size_t getDisplayedRows() const; - size_t getDisplayedCols() const; + static constexpr long MAX_ROWS_DISPLAY = 5; + static constexpr long MAX_COLS_DISPLAY = 5; + long getDisplayedRows() const; + long getDisplayedCols() const; // Want to add dots to show the user that not all is displayed. This needs some wrapping layouts QVBoxLayout* outerVerticalLayout; -- GitLab