From 79111a5d05e8912aae718f4de297e82bbf04fa20 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 3 Dec 2019 11:39:05 +0100 Subject: [PATCH 1/4] only change draw mode of current mesh --- OpenMesh/OMPropertyVisualizer.hh | 2 ++ OpenMesh/OMPropertyVisualizerBooleanT_impl.hh | 8 ++++---- OpenMesh/OMPropertyVisualizerDoubleT_impl.hh | 8 ++++---- OpenMesh/OMPropertyVisualizerIntegerT_impl.hh | 8 ++++---- OpenMesh/OMPropertyVisualizerSkinWeightsT_impl.hh | 2 +- OpenMesh/OMPropertyVisualizerT_impl.hh | 10 ++++++++++ OpenMesh/OMPropertyVisualizerVector2T_impl.hh | 10 +++++----- .../OMPropertyVisualizerVectorFieldDifferenceT_impl.hh | 8 ++++---- OpenMesh/OMPropertyVisualizerVectorT_impl.hh | 10 +++++----- 9 files changed, 39 insertions(+), 27 deletions(-) diff --git a/OpenMesh/OMPropertyVisualizer.hh b/OpenMesh/OMPropertyVisualizer.hh index 8d7dd9b..40d6596 100644 --- a/OpenMesh/OMPropertyVisualizer.hh +++ b/OpenMesh/OMPropertyVisualizer.hh @@ -90,6 +90,8 @@ public: virtual QString getPropertyText(unsigned int index); + void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode& _mode); + protected: MeshT* mesh; int mObjectID; diff --git a/OpenMesh/OMPropertyVisualizerBooleanT_impl.hh b/OpenMesh/OMPropertyVisualizerBooleanT_impl.hh index 1b5d16b..299e254 100644 --- a/OpenMesh/OMPropertyVisualizerBooleanT_impl.hh +++ b/OpenMesh/OMPropertyVisualizerBooleanT_impl.hh @@ -87,7 +87,7 @@ void OMPropertyVisualizerBoolean::visualizeFaceProp(bool _setDrawMode) mesh->set_color(*f_it, colorFalse); if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); } @@ -116,7 +116,7 @@ void OMPropertyVisualizerBoolean::visualizeEdgeProp(bool _setDrawMode) mesh->set_color(*e_it, colorFalse); if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); } template @@ -144,7 +144,7 @@ void OMPropertyVisualizerBoolean::visualizeHalfedgeProp(bool _setDrawMode mesh->set_color(*he_it, colorFalse); if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); } @@ -173,7 +173,7 @@ void OMPropertyVisualizerBoolean::visualizeVertexProp(bool _setDrawMode) mesh->set_color(*v_it, colorFalse); if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); } diff --git a/OpenMesh/OMPropertyVisualizerDoubleT_impl.hh b/OpenMesh/OMPropertyVisualizerDoubleT_impl.hh index e5a6120..b4d01d0 100644 --- a/OpenMesh/OMPropertyVisualizerDoubleT_impl.hh +++ b/OpenMesh/OMPropertyVisualizerDoubleT_impl.hh @@ -132,7 +132,7 @@ void OMPropertyVisualizerDouble::visualizeFaceProp(bool _setDrawMode) } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); } template @@ -211,7 +211,7 @@ void OMPropertyVisualizerDouble::visualizeEdgeProp(bool _setDrawMode) } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); } @@ -288,7 +288,7 @@ void OMPropertyVisualizerDouble::visualizeHalfedgeProp(bool _setDrawMode) } } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); } template @@ -365,7 +365,7 @@ void OMPropertyVisualizerDouble::visualizeVertexProp(bool _setDrawMode) } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); } template diff --git a/OpenMesh/OMPropertyVisualizerIntegerT_impl.hh b/OpenMesh/OMPropertyVisualizerIntegerT_impl.hh index 8852cd2..4822634 100644 --- a/OpenMesh/OMPropertyVisualizerIntegerT_impl.hh +++ b/OpenMesh/OMPropertyVisualizerIntegerT_impl.hh @@ -142,7 +142,7 @@ void OMPropertyVisualizerInteger::visualizeFaceProp(bool _setDrawMode) } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); } template @@ -218,7 +218,7 @@ void OMPropertyVisualizerInteger::visualizeEdgeProp(bool _setDrawMode) } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); } @@ -295,7 +295,7 @@ void OMPropertyVisualizerInteger::visualizeHalfedgeProp(bool _setDrawM } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); } template @@ -371,7 +371,7 @@ void OMPropertyVisualizerInteger::visualizeVertexProp(bool _setDrawMod } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); } diff --git a/OpenMesh/OMPropertyVisualizerSkinWeightsT_impl.hh b/OpenMesh/OMPropertyVisualizerSkinWeightsT_impl.hh index d95d2e5..79e697e 100644 --- a/OpenMesh/OMPropertyVisualizerSkinWeightsT_impl.hh +++ b/OpenMesh/OMPropertyVisualizerSkinWeightsT_impl.hh @@ -113,7 +113,7 @@ void OMPropertyVisualizerSkinWeights::visualizeVertexProp(bool _setDrawMo } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); } template diff --git a/OpenMesh/OMPropertyVisualizerT_impl.hh b/OpenMesh/OMPropertyVisualizerT_impl.hh index 1dc3b85..d96b6e2 100644 --- a/OpenMesh/OMPropertyVisualizerT_impl.hh +++ b/OpenMesh/OMPropertyVisualizerT_impl.hh @@ -145,6 +145,16 @@ QString OMPropertyVisualizer::getPropertyText(unsigned int index) } +template +void OMPropertyVisualizer::setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode& _mode) +{ + BaseObjectData* object; + PluginFunctions::getObject(mObjectID, object); + object->setObjectDrawMode(_mode); +} + + + template void OMPropertyVisualizer::setPropertyFromText(unsigned int index, QString text) { diff --git a/OpenMesh/OMPropertyVisualizerVector2T_impl.hh b/OpenMesh/OMPropertyVisualizerVector2T_impl.hh index c581f58..1342664 100644 --- a/OpenMesh/OMPropertyVisualizerVector2T_impl.hh +++ b/OpenMesh/OMPropertyVisualizerVector2T_impl.hh @@ -158,7 +158,7 @@ void OMPropertyVisualizerVector2::visualizeFaceProp(bool _set PropertyVisualizer::propertyInfo); } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); } else visualizeFacePropAsStrokes(); } @@ -190,7 +190,7 @@ void OMPropertyVisualizerVector2::visualizeEdgeProp(bool _set PropertyVisualizer::propertyInfo); } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); } else visualizeEdgePropAsStrokes(); } @@ -224,7 +224,7 @@ void OMPropertyVisualizerVector2::visualizeHalfedgeProp(bool } if (_setDrawMode) - PluginFunctions::setDrawMode( + this->setDrawMode( ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); } else visualizeHalfedgePropAsStrokes(); @@ -255,7 +255,7 @@ void OMPropertyVisualizerVector2::visualizeVertexProp(bool _s PropertyVisualizer::propertyInfo); } if (_setDrawMode) - PluginFunctions::setDrawMode( + this->setDrawMode( ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); } else visualizeVertexPropAsStrokes(); @@ -303,7 +303,7 @@ void OMPropertyVisualizerVector2::visualizeFacePropOnEdges() } _mesh->set_color(*e_it, color); } - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED | ACG::SceneGraph::DrawModes::EDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED | ACG::SceneGraph::DrawModes::EDGES_COLORED); } template diff --git a/OpenMesh/OMPropertyVisualizerVectorFieldDifferenceT_impl.hh b/OpenMesh/OMPropertyVisualizerVectorFieldDifferenceT_impl.hh index e73efbe..50cfc14 100644 --- a/OpenMesh/OMPropertyVisualizerVectorFieldDifferenceT_impl.hh +++ b/OpenMesh/OMPropertyVisualizerVectorFieldDifferenceT_impl.hh @@ -140,7 +140,7 @@ void OMPropertyVisualizerVectorFieldDifference::visualizeFaceProp(bool _s OMPVVFD::colorElements, OMPVVFD::scalarFn_norm_of_diff >(mesh, p1, p2, mesh->faces_begin(), mesh->faces_end()); if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); } template @@ -161,7 +161,7 @@ void OMPropertyVisualizerVectorFieldDifference::visualizeEdgeProp(bool _s OMPVVFD::colorElements, OMPVVFD::scalarFn_norm_of_diff >(mesh, p1, p2, mesh->edges_begin(), mesh->edges_end()); if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); } template @@ -182,7 +182,7 @@ void OMPropertyVisualizerVectorFieldDifference::visualizeHalfedgeProp(boo OMPVVFD::colorElements, OMPVVFD::scalarFn_norm_of_diff >(mesh, p1, p2, mesh->halfedges_begin(), mesh->halfedges_end()); if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); } template @@ -203,5 +203,5 @@ void OMPropertyVisualizerVectorFieldDifference::visualizeVertexProp(bool OMPVVFD::colorElements, OMPVVFD::scalarFn_norm_of_diff >(mesh, p1, p2, mesh->vertices_begin(), mesh->vertices_end()); if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); } diff --git a/OpenMesh/OMPropertyVisualizerVectorT_impl.hh b/OpenMesh/OMPropertyVisualizerVectorT_impl.hh index d744d22..9d03da2 100644 --- a/OpenMesh/OMPropertyVisualizerVectorT_impl.hh +++ b/OpenMesh/OMPropertyVisualizerVectorT_impl.hh @@ -154,7 +154,7 @@ void OMPropertyVisualizerVector::visualizeFaceProp(bool _setDrawMode) PropertyVisualizer::propertyInfo); } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED); } else visualizeFacePropAsStrokes(); } @@ -187,7 +187,7 @@ void OMPropertyVisualizerVector::visualizeEdgeProp(bool _setDrawMode) PropertyVisualizer::propertyInfo); } if (_setDrawMode) - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED); } else visualizeEdgePropAsStrokes(); } @@ -222,7 +222,7 @@ void OMPropertyVisualizerVector::visualizeHalfedgeProp(bool _setDrawMode) } if (_setDrawMode) - PluginFunctions::setDrawMode( + this->setDrawMode( ACG::SceneGraph::DrawModes::HALFEDGES_COLORED); } else visualizeHalfedgePropAsStrokes(); @@ -254,7 +254,7 @@ void OMPropertyVisualizerVector::visualizeVertexProp(bool _setDrawMode) PropertyVisualizer::propertyInfo); } if (_setDrawMode) - PluginFunctions::setDrawMode( + this->setDrawMode( ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED); } else visualizeVertexPropAsStrokes(); @@ -303,7 +303,7 @@ void OMPropertyVisualizerVector::visualizeFacePropOnEdges() { } _mesh->set_color(*e_it, color); } - PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED | ACG::SceneGraph::DrawModes::EDGES_COLORED); + this->setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED | ACG::SceneGraph::DrawModes::EDGES_COLORED); } template -- GitLab From 83f680d1a5b7e9785935fa7b5bca906364be4a92 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 3 Dec 2019 11:39:23 +0100 Subject: [PATCH 2/4] fix some warnings --- OpenMesh/OMPropertyModelT_impl.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenMesh/OMPropertyModelT_impl.hh b/OpenMesh/OMPropertyModelT_impl.hh index 0347cd5..da829d9 100644 --- a/OpenMesh/OMPropertyModelT_impl.hh +++ b/OpenMesh/OMPropertyModelT_impl.hh @@ -70,8 +70,8 @@ OMPropertyModel::OMPropertyModel(MeshT* mesh, int objectID, QObject *pare : OMPropertyModelSubclass(parent), mesh_(mesh), objectID_(objectID), - mCombineProperty1(0), - mCombineProperty2(0), + mCombineProperty1(nullptr), + mCombineProperty2(nullptr), pickModeActive(false) { gatherProperties(); @@ -263,7 +263,7 @@ bool OMPropertyModel::parseHeader(QString header, PropertyVisualizer*& pr TypeInfoWrapper typeInfo = getSupportedTypeInfoWrapper(friendlyName); - QString propName = QInputDialog::getText(0, "Property Name", "Please enter name.",QLineEdit::Normal,headerParts[4]); + QString propName = QInputDialog::getText(nullptr, "Property Name", "Please enter name.",QLineEdit::Normal,headerParts[4]); if (propName == "") return false; bool replace = false; -- GitLab From 02f2ecc6210f2079e8d80a7808ea7a10bbfb1f0e Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 3 Dec 2019 11:40:23 +0100 Subject: [PATCH 3/4] fix crash when failed to getPickedObject --- OpenMesh/OMPropertyModelT_impl.hh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/OpenMesh/OMPropertyModelT_impl.hh b/OpenMesh/OMPropertyModelT_impl.hh index da829d9..9512fe5 100644 --- a/OpenMesh/OMPropertyModelT_impl.hh +++ b/OpenMesh/OMPropertyModelT_impl.hh @@ -383,15 +383,17 @@ void OMPropertyModel::mouseEvent(QMouseEvent* _event) ACG::Vec3d hit_point; if (PluginFunctions::scenegraphPick(ACG::SceneGraph::PICK_FACE, _event->pos(),node_idx, face_idx, &hit_point)) { - BaseObjectData* object; - PluginFunctions::getPickedObject(node_idx, object); + BaseObjectData* object = nullptr; - if (object->id() == objectID_ && !currentlySelectedIndices.empty()) + if (PluginFunctions::getPickedObject(node_idx, object)) { - OMPropertyVisualizer* viz = dynamic_cast*>(propertyVisualizers[currentlySelectedIndices.first().row()] ); - unsigned int primitiveId = viz->getClosestPrimitiveId(face_idx, hit_point); - mPickWidget.pickedHandle->setText(tr("%1").arg(primitiveId)); - mPickWidget.pickedValue->setText(viz->getPropertyText(primitiveId)); + if (object->id() == objectID_ && !currentlySelectedIndices.empty()) + { + OMPropertyVisualizer* viz = dynamic_cast*>(propertyVisualizers[currentlySelectedIndices.first().row()] ); + unsigned int primitiveId = viz->getClosestPrimitiveId(face_idx, hit_point); + mPickWidget.pickedHandle->setText(tr("%1").arg(primitiveId)); + mPickWidget.pickedValue->setText(viz->getPropertyText(primitiveId)); + } } } } -- GitLab From 4ed43069c307dd9998e1a904cae36ae4233a18a4 Mon Sep 17 00:00:00 2001 From: Max Lyon Date: Tue, 3 Dec 2019 11:44:03 +0100 Subject: [PATCH 4/4] only set draw mode if getting object was successful --- OpenMesh/OMPropertyVisualizerT_impl.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenMesh/OMPropertyVisualizerT_impl.hh b/OpenMesh/OMPropertyVisualizerT_impl.hh index d96b6e2..870616b 100644 --- a/OpenMesh/OMPropertyVisualizerT_impl.hh +++ b/OpenMesh/OMPropertyVisualizerT_impl.hh @@ -149,8 +149,8 @@ template void OMPropertyVisualizer::setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode& _mode) { BaseObjectData* object; - PluginFunctions::getObject(mObjectID, object); - object->setObjectDrawMode(_mode); + if (PluginFunctions::getObject(mObjectID, object)) + object->setObjectDrawMode(_mode); } -- GitLab