Skip to content
Snippets Groups Projects

Merge of all branches of Fabian PK (related to skills)

Merged Fabian Tërnava requested to merge test/merge-branch-skills-to-master into master
18 files
+ 322
123
Compare changes
  • Side-by-side
  • Inline
Files
18
  • c28d544e
    Way better parse error reporting · c28d544e
    Tobias Bodmer authored
    noticing broken items, even when they are not touched. Also coloring
    their parents in an orange color, so that the error is noticable even
    when not expanded.
    
    For better generality (and was useful for error reporting): All widgets
    introduced inherit from a common base class: CustomWidget. It holds a
    signal definition that can be used to directly forward signals to its
    QTreeWidgetItem underneath.
@@ -45,9 +45,44 @@ namespace armarx
bool
AronTreeWidgetConverterVisitor::isConversionSuccessful()
{
return !errorOccured;
return !isDirectError && !hasTransitiveError;
}
bool
AronTreeWidgetConverterVisitor::onlyChildFailedConversion()
{
return hasTransitiveError;
}
bool
AronTreeWidgetConverterVisitor::hasDirectError() const
{
return isDirectError;
}
void
AronTreeWidgetConverterVisitor::handleErrors(AronTreeWidgetConverterVisitor childV,
bool ownFault)
{
// TODO debug this. Make target back to debugabble
isDirectError |= ownFault;
hasTransitiveError |= childV.isDirectError || childV.hasTransitiveError;
auto* aronItem = AronTreeWidgetItem::DynamicCast(parentItem->child(index));
ARMARX_CHECK(aronItem);
aronItem->setValueErrorState(isDirectError, hasTransitiveError);
}
void
AronTreeWidgetConverterVisitor::handleErrors(bool ownFault)
{
isDirectError = ownFault;
auto* aronItem = AronTreeWidgetItem::DynamicCast(parentItem->child(index));
ARMARX_CHECK(aronItem);
aronItem->setValueErrorState(isDirectError, false);
}
void
AronTreeWidgetConverterVisitor::visitAronVariant(const aron::type::ObjectPtr& i)
{
@@ -61,11 +96,8 @@ namespace armarx
AronTreeWidgetConverterVisitor v(el, x++);
aron::type::visit(v, value);
if (v.errorOccured || !v.createdAron.get())
{
errorOccured = true;
}
else
handleErrors(v);
if (v.isConversionSuccessful())
{
createdAronDict->addElement(key, v.createdAron);
}
@@ -84,23 +116,12 @@ namespace armarx
auto it = el->child(x);
AronTreeWidgetConverterVisitor v(el, x);
aron::type::visit(v, i->getAcceptedType());
if (v.createdAron && !v.errorOccured)
auto key = it->text(0).toStdString();
// TODO: handle key errors more elegantly / separately
handleErrors(v, createdAronDict->hasElement(key));
if (v.createdAron && v.isConversionSuccessful() && !createdAronDict->hasElement(key))
{
// TODO find more elegant solution that does not crash aron code
auto key = it->text(0).toStdString();
if (createdAronDict->hasElement(key))
{
errorOccured = true;
}
else
{
createdAronDict->addElement(key, v.createdAron);
}
}
else
{
errorOccured = true;
createdAronDict->addElement(key, v.createdAron);
}
}
}
@@ -117,14 +138,12 @@ namespace armarx
{
AronTreeWidgetConverterVisitor convVisitor(elem, j);
aron::type::visit(convVisitor, childrenTypes[0]);
if (convVisitor.createdAron && !convVisitor.errorOccured)
handleErrors(convVisitor);
if (convVisitor.createdAron && convVisitor.isConversionSuccessful())
{
createdAronList->addElement(convVisitor.createdAron);
}
else
{
errorOccured = true;
}
}
}
@@ -139,14 +158,11 @@ namespace armarx
for (int j = 0; j < 2; ++j)
{
AronTreeWidgetConverterVisitor convVisitor(elem, j);
if (convVisitor.createdAron && !convVisitor.errorOccured)
handleErrors(convVisitor);
if (convVisitor.createdAron && convVisitor.isConversionSuccessful())
{
createdAronPair->addElement(convVisitor.createdAron);
}
else
{
errorOccured = true;
}
}
}
@@ -162,15 +178,12 @@ namespace armarx
{
AronTreeWidgetConverterVisitor convVisitor(currElem, j);
aron::type::visit(convVisitor, i);
handleErrors(convVisitor);
if (convVisitor.createdAron && !convVisitor.errorOccured)
if (convVisitor.createdAron && convVisitor.isConversionSuccessful())
{
createdAronTuple->addElement(convVisitor.createdAron);
}
else
{
errorOccured = true;
}
}
}
@@ -209,11 +222,13 @@ namespace armarx
ARMARX_CHECK(rootWidget);
auto* widget = rootWidget->itemWidget(currElem, 1);
auto* matrixWidget = EditMatrixWidget::DynamicCastAndCheck(widget);
handleErrors(matrixWidget->hasParseErrors());
if (matrixWidget->hasParseErrors())
{
errorOccured = true;
return;
}
// write to aron data
std::vector<unsigned char> elems;
elems.reserve(totalByteSize);
// CAUTION: Raw data has column based storage
@@ -241,11 +256,15 @@ namespace armarx
auto* currTreeElem = parentItem->child(index);
auto* itemWidget = currTreeElem->treeWidget()->itemWidget(currTreeElem, 1);
auto* quatWidget = QuaternionWidget::DynamicCastAndCheck(itemWidget);
// error handling
handleErrors(quatWidget->hasParseErrors());
if (quatWidget->hasParseErrors())
{
errorOccured = true;
return;
}
// write to aron data
auto serialized = quatWidget->parseAllToNDArray();
if ((int)serialized.size() != dataSize * 4)
{
@@ -280,7 +299,8 @@ namespace armarx
}
bool success;
std::tie(success, createdAron) = intEnumWidget->parseToAron();
errorOccured &= success;
handleErrors(!success);
}
void
@@ -303,12 +323,12 @@ namespace armarx
}
catch (const simox::error::SimoxError& err)
{
errorOccured = true;
handleErrors();
ARMARX_VERBOSE << "Conversion from String to Int failed. Error:\"" << err.what()
<< "\"";
return;
}
handleErrors(false);
}
void
@@ -321,6 +341,7 @@ namespace armarx
std::string str = el->text(1).toStdString();
if (str.empty())
{
//TODO: similar behaviour for rest?
str = el->text(3).toStdString();
}
try
@@ -329,10 +350,12 @@ namespace armarx
}
catch (const simox::error::SimoxError& err)
{
errorOccured = true;
handleErrors();
ARMARX_VERBOSE << "Conversion from String to Long failed. Error:\"" << err.what()
<< "\"";
return;
}
handleErrors(false);
}
void
@@ -353,10 +376,12 @@ namespace armarx
}
catch (const simox::error::SimoxError& err)
{
errorOccured = true;
handleErrors();
ARMARX_VERBOSE << "Conversion from String to Float failed. Error:\"" << err.what()
<< "\"";
return;
}
handleErrors(false);
}
void
@@ -377,10 +402,12 @@ namespace armarx
}
catch (const simox::error::SimoxError& err)
{
errorOccured = true;
handleErrors();
ARMARX_VERBOSE << "Conversion from String to Double failed. Error:\"" << err.what()
<< "\"";
return;
}
handleErrors(false);
}
void
@@ -401,10 +428,12 @@ namespace armarx
}
catch (const simox::error::SimoxError& err)
{
errorOccured = true;
handleErrors();
ARMARX_VERBOSE << "Conversion from String to Bool failed. Error:\"" << err.what()
<< "\"";
return;
}
handleErrors(false);
}
void
Loading