From e2065ec5b91b8081384f644b8c336ee939c62cbd Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 23 Apr 2017 00:38:34 +0200 Subject: [PATCH 01/12] Extend task panel for filling function --- src/Mod/Surface/Gui/TaskFilling.cpp | 102 ++++++++++++++++--- src/Mod/Surface/Gui/TaskFilling.h | 6 ++ src/Mod/Surface/Gui/TaskFilling.ui | 146 ++++++++++++++++++++-------- 3 files changed, 203 insertions(+), 51 deletions(-) diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 2436461335..c26bc80eac 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #include #include @@ -171,7 +173,7 @@ public: } private: - bool allowFace(App::DocumentObject* pObj, const char* sSubName) + bool allowFace(App::DocumentObject*, const char* sSubName) { std::string element(sSubName); if (element.substr(0,4) != "Face") @@ -216,9 +218,9 @@ FillingPanel::FillingPanel(ViewProviderFilling* vp, Surface::Filling* obj) // Create context menu QAction* action = new QAction(tr("Remove"), this); action->setShortcut(QString::fromLatin1("Del")); - ui->listWidget->addAction(action); + ui->listBoundary->addAction(action); connect(action, SIGNAL(triggered()), this, SLOT(onDeleteEdge())); - ui->listWidget->setContextMenuPolicy(Qt::ActionsContextMenu); + ui->listBoundary->setContextMenuPolicy(Qt::ActionsContextMenu); } /* @@ -251,8 +253,8 @@ void FillingPanel::setEditedObject(Surface::Filling* obj) App::Document* doc = editedObject->getDocument(); for (; it != objects.end() && jt != element.end(); ++it, ++jt) { - QListWidgetItem* item = new QListWidgetItem(ui->listWidget); - ui->listWidget->addItem(item); + QListWidgetItem* item = new QListWidgetItem(ui->listBoundary); + ui->listBoundary->addItem(item); QString text = QString::fromLatin1("%1.%2") .arg(QString::fromUtf8((*it)->Label.getValue())) @@ -370,6 +372,56 @@ void FillingPanel::on_buttonEdgeRemove_clicked() Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject)); } +void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item) +{ + Gui::Selection().clearSelection(); + Gui::Selection().rmvSelectionGate(); + selectionMode = None; + ui->comboBoxFaces->clear(); + ui->comboBoxCont->clear(); + + if (item) { + modifyBorder(true); + + QList data; + data = item->data(Qt::UserRole).toList(); + + try { + App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray()); + App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr; + if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); + TopoDS_Shape edge = shape.getSubShape(data[2].toByteArray()); + + // build up map edge->face + TopTools_IndexedMapOfShape faces; + TopExp::MapShapes(shape.getShape(), TopAbs_FACE, faces); + TopTools_IndexedDataMapOfShapeListOfShape edge2Face; + TopExp::MapShapesAndAncestors(shape.getShape(), TopAbs_EDGE, TopAbs_FACE, edge2Face); + const TopTools_ListOfShape& adj_faces = edge2Face.FindFromKey(edge); + if (adj_faces.Extent() > 0) { + ui->comboBoxFaces->addItem(tr("None")); + ui->comboBoxCont->addItem(QString::fromLatin1("C0")); + ui->comboBoxCont->addItem(QString::fromLatin1("G1")); + ui->comboBoxCont->addItem(QString::fromLatin1("G2")); + TopTools_ListIteratorOfListOfShape it(adj_faces); + for (; it.More(); it.Next()) { + const TopoDS_Shape& F = it.Value(); + int index = faces.FindIndex(F); + ui->comboBoxFaces->addItem(QString::fromLatin1("Face%1").arg(index)); + } + } + } + + Gui::Selection().addSelection(data[0].toByteArray(), + data[1].toByteArray(), + data[2].toByteArray()); + } + catch (...) { + } + } +} + void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) { if (selectionMode == None) @@ -393,8 +445,8 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) selectionMode = None; } else if (selectionMode == AppendEdge) { - QListWidgetItem* item = new QListWidgetItem(ui->listWidget); - ui->listWidget->addItem(item); + QListWidgetItem* item = new QListWidgetItem(ui->listBoundary); + ui->listBoundary->addItem(item); Gui::SelectionObject sel(msg); QString text = QString::fromLatin1("%1.%2") @@ -421,10 +473,10 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) data << QByteArray(msg.pDocName); data << QByteArray(msg.pObjectName); data << QByteArray(msg.pSubName); - for (int i=0; ilistWidget->count(); i++) { - QListWidgetItem* item = ui->listWidget->item(i); + for (int i=0; ilistBoundary->count(); i++) { + QListWidgetItem* item = ui->listBoundary->item(i); if (item && item->data(Qt::UserRole) == data) { - ui->listWidget->takeItem(i); + ui->listBoundary->takeItem(i); delete item; } } @@ -454,13 +506,13 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) void FillingPanel::onDeleteEdge() { - int row = ui->listWidget->currentRow(); - QListWidgetItem* item = ui->listWidget->item(row); + int row = ui->listBoundary->currentRow(); + QListWidgetItem* item = ui->listBoundary->item(row); if (item) { checkOpenCommand(); QList data; data = item->data(Qt::UserRole).toList(); - ui->listWidget->takeItem(row); + ui->listBoundary->takeItem(row); delete item; App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray()); @@ -483,6 +535,30 @@ void FillingPanel::onDeleteEdge() } } +void FillingPanel::on_buttonAccept_clicked() +{ + modifyBorder(false); +} + +void FillingPanel::on_buttonIgnore_clicked() +{ + modifyBorder(false); +} + +void FillingPanel::modifyBorder(bool on) +{ + ui->buttonInitFace->setDisabled(on); + ui->lineInitFaceName->setDisabled(on); + ui->buttonEdgeAdd->setDisabled(on); + ui->buttonEdgeRemove->setDisabled(on); + ui->listBoundary->setDisabled(on); + + ui->comboBoxFaces->setEnabled(on); + ui->comboBoxCont->setEnabled(on); + ui->buttonAccept->setEnabled(on); + ui->buttonIgnore->setEnabled(on); +} + // ---------------------------------------------------------------------------- TaskFilling::TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj) diff --git a/src/Mod/Surface/Gui/TaskFilling.h b/src/Mod/Surface/Gui/TaskFilling.h index ce56c7b3b8..752904f60a 100644 --- a/src/Mod/Surface/Gui/TaskFilling.h +++ b/src/Mod/Surface/Gui/TaskFilling.h @@ -31,6 +31,8 @@ #include #include +class QListWidgetItem; + namespace SurfaceGui { @@ -81,12 +83,16 @@ protected: virtual void slotUndoDocument(const Gui::Document& Doc); /** Notifies on redo */ virtual void slotRedoDocument(const Gui::Document& Doc); + void modifyBorder(bool); private Q_SLOTS: void on_buttonInitFace_clicked(); void on_buttonEdgeAdd_clicked(); void on_buttonEdgeRemove_clicked(); void on_lineInitFaceName_textChanged(const QString&); + void on_listBoundary_itemDoubleClicked(QListWidgetItem*); + void on_buttonAccept_clicked(); + void on_buttonIgnore_clicked(); void onDeleteEdge(void); void clearSelection(); }; diff --git a/src/Mod/Surface/Gui/TaskFilling.ui b/src/Mod/Surface/Gui/TaskFilling.ui index 733779d10f..bb25d5850b 100644 --- a/src/Mod/Surface/Gui/TaskFilling.ui +++ b/src/Mod/Surface/Gui/TaskFilling.ui @@ -19,7 +19,7 @@ Filling - + @@ -39,43 +39,113 @@ - - - - - true - - - - 0 - 0 - - - - Add Edge - - - false - - - - - - - - 0 - 0 - - - - Remove Edge - - - - - - - + + + Boundary + + + + + + + + + Faces: + + + + + + + false + + + + + + + Continuity: + + + + + + + false + + + + + + + Qt::Horizontal + + + + 74 + 20 + + + + + + + + false + + + Accept + + + + + + + false + + + Ignore + + + + + + + + + true + + + + 0 + 0 + + + + Add Edge + + + false + + + + + + + + 0 + 0 + + + + Remove Edge + + + + + + + From 29673491e9988cc1514c4e2a5740605a75013013 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 23 Apr 2017 12:39:58 +0200 Subject: [PATCH 02/12] Extend task panel for filling function --- src/Mod/Surface/Gui/TaskFilling.cpp | 54 +++++++++++++++++++++++++---- src/Mod/Surface/Gui/TaskFilling.ui | 36 +++++++++++++++---- 2 files changed, 76 insertions(+), 14 deletions(-) diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index c26bc80eac..4dfc123362 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -210,6 +211,8 @@ FillingPanel::FillingPanel(ViewProviderFilling* vp, Surface::Filling* obj) { ui = new Ui_TaskFilling(); ui->setupUi(this); + ui->statusLabel->clear(); + selectionMode = None; this->vp = vp; checkCommand = true; @@ -381,8 +384,6 @@ void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item) ui->comboBoxCont->clear(); if (item) { - modifyBorder(true); - QList data; data = item->data(Qt::UserRole).toList(); @@ -400,16 +401,33 @@ void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item) TopExp::MapShapesAndAncestors(shape.getShape(), TopAbs_EDGE, TopAbs_FACE, edge2Face); const TopTools_ListOfShape& adj_faces = edge2Face.FindFromKey(edge); if (adj_faces.Extent() > 0) { - ui->comboBoxFaces->addItem(tr("None")); - ui->comboBoxCont->addItem(QString::fromLatin1("C0")); - ui->comboBoxCont->addItem(QString::fromLatin1("G1")); - ui->comboBoxCont->addItem(QString::fromLatin1("G2")); + int n = adj_faces.Extent(); + ui->statusLabel->setText(tr("Edge has %n adjacent face(s)", 0, n)); + + // fill up the combo boxes + modifyBorder(true); + ui->comboBoxFaces->addItem(tr("None"), QByteArray("None")); + ui->comboBoxCont->addItem(QString::fromLatin1("C0"), static_cast(GeomAbs_C0)); + ui->comboBoxCont->addItem(QString::fromLatin1("G1"), static_cast(GeomAbs_G1)); + ui->comboBoxCont->addItem(QString::fromLatin1("G2"), static_cast(GeomAbs_G2)); TopTools_ListIteratorOfListOfShape it(adj_faces); for (; it.More(); it.Next()) { const TopoDS_Shape& F = it.Value(); int index = faces.FindIndex(F); - ui->comboBoxFaces->addItem(QString::fromLatin1("Face%1").arg(index)); + QString text = QString::fromLatin1("Face%1").arg(index); + ui->comboBoxFaces->addItem(text, text.toLatin1()); } + + // activste face and continuity + if (data.size() == 5) { + int index = ui->comboBoxFaces->findData(data[3]); + ui->comboBoxFaces->setCurrentIndex(index); + index = ui->comboBoxCont->findData(data[4]); + ui->comboBoxCont->setCurrentIndex(index); + } + } + else { + ui->statusLabel->setText(tr("Edge has no adjacent faces")); } } @@ -537,12 +555,34 @@ void FillingPanel::onDeleteEdge() void FillingPanel::on_buttonAccept_clicked() { + QListWidgetItem* item = ui->listBoundary->currentItem(); + if (item) { + QList data; + data = item->data(Qt::UserRole).toList(); + if (data.size() == 5) { + data[3] = ui->comboBoxFaces->itemData(ui->comboBoxFaces->currentIndex()); + data[4] = ui->comboBoxCont->itemData(ui->comboBoxCont->currentIndex()); + } + else { + data << ui->comboBoxFaces->itemData(ui->comboBoxFaces->currentIndex()); + data << ui->comboBoxCont->itemData(ui->comboBoxCont->currentIndex()); + } + + item->setData(Qt::UserRole, data); + } + modifyBorder(false); + ui->comboBoxFaces->clear(); + ui->comboBoxCont->clear(); + ui->statusLabel->clear(); } void FillingPanel::on_buttonIgnore_clicked() { modifyBorder(false); + ui->comboBoxFaces->clear(); + ui->comboBoxCont->clear(); + ui->statusLabel->clear(); } void FillingPanel::modifyBorder(bool on) diff --git a/src/Mod/Surface/Gui/TaskFilling.ui b/src/Mod/Surface/Gui/TaskFilling.ui index bb25d5850b..42c41f8e1e 100644 --- a/src/Mod/Surface/Gui/TaskFilling.ui +++ b/src/Mod/Surface/Gui/TaskFilling.ui @@ -47,39 +47,54 @@ - + + + + 0 + 0 + + Faces: - + false - + + + + 0 + 0 + + Continuity: - + false - + Qt::Horizontal + + QSizePolicy::Maximum + 74 @@ -88,7 +103,7 @@ - + false @@ -98,7 +113,7 @@ - + false @@ -144,6 +159,13 @@ + + + + Status messages + + + From b0eed05a732bdf4d46dfdc40a0215233b4534a53 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 23 Apr 2017 15:02:48 +0200 Subject: [PATCH 03/12] Extend Py interface of PropertyStringList to accept all sequence types --- src/App/PropertyStandard.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 31920dbafa..a1827a2ff5 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1604,13 +1604,16 @@ PyObject *PropertyStringList::getPyObject(void) void PropertyStringList::setPyObject(PyObject *value) { - if (PyList_Check(value)) { - Py_ssize_t nSize = PyList_Size(value); + if (PyString_Check(value)) { + setValue(PyString_AsString(value)); + } + else if (PySequence_Check(value)) { + Py_ssize_t nSize = PySequence_Size(value); std::vector values; values.resize(nSize); for (Py_ssize_t i=0; iob_type->tp_name; From b47805dcc658989c28185086e3cde8402518dfe6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 23 Apr 2017 16:12:27 +0200 Subject: [PATCH 04/12] Extend task panel for filling function --- src/Mod/Surface/App/FeatureFilling.cpp | 104 +++++++++++++++++-------- src/Mod/Surface/App/FeatureFilling.h | 18 ++--- src/Mod/Surface/Gui/TaskFilling.cpp | 45 ++++++----- src/Mod/Surface/Gui/TaskFilling.h | 2 +- 4 files changed, 104 insertions(+), 65 deletions(-) diff --git a/src/Mod/Surface/App/FeatureFilling.cpp b/src/Mod/Surface/App/FeatureFilling.cpp index 172e01f6f9..b7a7abd1ca 100644 --- a/src/Mod/Surface/App/FeatureFilling.cpp +++ b/src/Mod/Surface/App/FeatureFilling.cpp @@ -46,42 +46,52 @@ PROPERTY_SOURCE(Surface::Filling, Part::Spline) Filling::Filling() { - ADD_PROPERTY_TYPE(Border,(0,""), "Filling", App::Prop_None, "Border Edges (C0 is required for edges without a corresponding face)"); - ADD_PROPERTY_TYPE(BorderFaces,(0,""), "Filling", App::Prop_None, "Border Faces"); - ADD_PROPERTY_TYPE(OrderBorderFaces,(-1), "Filling", App::Prop_None, "Order of constraint on border faces (C0, G1 and G2 are possible)"); + ADD_PROPERTY_TYPE(BoundaryEdges,(0,""), "Filling", App::Prop_None, "Boundary Edges (C0 is required for edges without a corresponding face)"); + ADD_PROPERTY_TYPE(BoundaryFaces,(""), "Filling", App::Prop_None, "Boundary Faces"); + ADD_PROPERTY_TYPE(BoundaryOrder,(-1), "Filling", App::Prop_None, "Order of constraint on boundary faces (C0, G1 and G2 are possible)"); - ADD_PROPERTY_TYPE(Curves,(0,""), "Filling", App::Prop_None, "Other Constraint Curves (C0 is required for edges without a corresponding face)"); - ADD_PROPERTY_TYPE(CurveFaces,(0,""), "Filling", App::Prop_None, "Curve Faces"); - ADD_PROPERTY_TYPE(OrderCurveFaces,(-1), "Filling", App::Prop_None, "Order of constraint on curve faces (C0, G1 and G2 are possible)"); + ADD_PROPERTY_TYPE(UnboundEdges,(0,""), "Filling", App::Prop_None, "Unbound constraint edges (C0 is required for edges without a corresponding face)"); + ADD_PROPERTY_TYPE(UnboundFaces,(""), "Filling", App::Prop_None, "Unbound constraint faces"); + ADD_PROPERTY_TYPE(UnboundOrder,(-1), "Filling", App::Prop_None, "Order of constraint on curve faces (C0, G1 and G2 are possible)"); ADD_PROPERTY_TYPE(FreeFaces,(0,""), "Filling", App::Prop_None, "Free constraint on a face"); - ADD_PROPERTY_TYPE(OrderFreeFaces,(0), "Filling", App::Prop_None, "Order of constraint on free faces"); + ADD_PROPERTY_TYPE(FreeOrder,(0), "Filling", App::Prop_None, "Order of constraint on free faces"); ADD_PROPERTY_TYPE(Points,(0,""), "Filling", App::Prop_None, "Constraint Points (on Surface)"); ADD_PROPERTY_TYPE(InitialFace,(0), "Filling", App::Prop_None, "Initial surface to use"); ADD_PROPERTY_TYPE(Degree,(3), "Filling", App::Prop_None, "Starting degree"); - ADD_PROPERTY_TYPE(PointsOnCurve,(3), "Filling", App::Prop_None, "Number of points on an edge for constraint"); + ADD_PROPERTY_TYPE(PointsOnCurve,(15), "Filling", App::Prop_None, "Number of points on an edge for constraint"); ADD_PROPERTY_TYPE(Iterations,(2), "Filling", App::Prop_None, "Number of iterations"); ADD_PROPERTY_TYPE(Anisotropy,(false), "Filling", App::Prop_None, "Anisotropy"); ADD_PROPERTY_TYPE(Tolerance2d,(0.00001), "Filling", App::Prop_None, "2D Tolerance"); ADD_PROPERTY_TYPE(Tolerance3d,(0.0001), "Filling", App::Prop_None, "3D Tolerance"); - ADD_PROPERTY_TYPE(TolAngular,(0.001), "Filling", App::Prop_None, "G1 tolerance"); - ADD_PROPERTY_TYPE(TolCurvature,(0.01), "Filling", App::Prop_None, "G2 tolerance"); + ADD_PROPERTY_TYPE(TolAngular,(0.01), "Filling", App::Prop_None, "G1 tolerance"); + ADD_PROPERTY_TYPE(TolCurvature,(0.1), "Filling", App::Prop_None, "G2 tolerance"); ADD_PROPERTY_TYPE(MaximumDegree,(8), "Filling", App::Prop_None, "Maximum curve degree"); - ADD_PROPERTY_TYPE(MaximumSegments,(10000), "Filling", App::Prop_None, "Maximum number of segments"); + ADD_PROPERTY_TYPE(MaximumSegments,(9), "Filling", App::Prop_None, "Maximum number of segments"); + + BoundaryEdges.setSize(0); + BoundaryFaces.setSize(0); + BoundaryOrder.setSize(0); + UnboundEdges.setSize(0); + UnboundFaces.setSize(0); + UnboundOrder.setSize(0); + FreeFaces.setSize(0); + FreeOrder.setSize(0); + Points.setSize(0); } short Filling::mustExecute() const { - if (Border.isTouched() || - BorderFaces.isTouched() || - OrderBorderFaces.isTouched() || - Curves.isTouched() || - CurveFaces.isTouched() || - OrderCurveFaces.isTouched() || + if (BoundaryEdges.isTouched() || + BoundaryFaces.isTouched() || + BoundaryOrder.isTouched() || + UnboundEdges.isTouched() || + UnboundFaces.isTouched() || + UnboundOrder.isTouched() || FreeFaces.isTouched() || - OrderFreeFaces.isTouched() || + FreeOrder.isTouched() || Points.isTouched() || InitialFace.isTouched() || Degree.isTouched() || @@ -100,39 +110,61 @@ short Filling::mustExecute() const void Filling::addConstraints(BRepFill_Filling& builder, const App::PropertyLinkSubList& edges, - const App::PropertyLinkSubList& faces, + const App::PropertyStringList& faces, const App::PropertyIntegerList& orders, Standard_Boolean bnd) { auto edge_obj = edges.getValues(); auto edge_sub = edges.getSubValues(); - auto face_obj = faces.getValues(); - auto face_sub = faces.getSubValues(); + auto face_sub = faces.getValues(); auto contvals = orders.getValues(); - // tmp. workaround - if (edge_obj.size() != contvals.size()) { - contvals.resize(edge_obj.size()); + // if the number of continuities doesn't match then fall back to C0 + if (edge_sub.size() != contvals.size()) { + contvals.resize(edge_sub.size()); std::fill(contvals.begin(), contvals.end(), static_cast(GeomAbs_C0)); } - if (edge_obj.size() == edge_sub.size() && - edge_obj.size() == contvals.size()) { + // if the number of faces doesn't match then fall back to empty strings + // an empty face string indicates that there is no face associated to an edge + if (face_sub.size() != edge_sub.size()) { + face_sub.resize(edge_obj.size()); + std::fill(face_sub.begin(), face_sub.end(), std::string()); + } + + if (edge_obj.size() == edge_sub.size()) { for (std::size_t index = 0; index < edge_obj.size(); index++) { + // get the part object App::DocumentObject* obj = edge_obj[index]; const std::string& sub = edge_sub[index]; + if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) { + // get the sub-edge of the part's shape const Part::TopoShape& shape = static_cast(obj)->Shape.getShape(); TopoDS_Shape edge = shape.getSubShape(sub.c_str()); if (!edge.IsNull() && edge.ShapeType() == TopAbs_EDGE) { GeomAbs_Shape cont = static_cast(contvals[index]); - if (cont == GeomAbs_C0) { + + // check for an adjacent face of the edge + std::string subFace = face_sub[index]; + + // edge doesn't have set an adjacent face + if (subFace.empty()) { builder.Add(TopoDS::Edge(edge), cont, bnd); } else { - builder.Add(TopoDS::Edge(edge), cont, bnd); + TopoDS_Shape face = shape.getSubShape(subFace.c_str()); + if (!face.IsNull() && face.ShapeType() == TopAbs_FACE) { + builder.Add(TopoDS::Edge(edge), TopoDS::Face(face), cont, bnd); + } + else { + Standard_Failure::Raise("Sub-shape is not a face"); + } } } + else { + Standard_Failure::Raise("Sub-shape is not an edge"); + } } } } @@ -141,6 +173,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, } } +// Add free support faces with their continuities void Filling::addConstraints(BRepFill_Filling& builder, const App::PropertyLinkSubList& faces, const App::PropertyIntegerList& orders) @@ -161,6 +194,9 @@ void Filling::addConstraints(BRepFill_Filling& builder, GeomAbs_Shape cont = static_cast(contvals[index]); builder.Add(TopoDS::Face(face), cont); } + else { + Standard_Failure::Raise("Sub-shape is not a face"); + } } } } @@ -207,7 +243,7 @@ App::DocumentObjectExecReturn *Filling::execute(void) BRepFill_Filling builder(degree, ptsoncurve, numIter, anisotropy, tol2d, tol3d, tolG1, tolG2, maxdeg, maxseg); - if ((Border.getSize()) < 1) { + if ((BoundaryEdges.getSize()) < 1) { return new App::DocumentObjectExecReturn("Border must have at least one curve defined."); } @@ -226,16 +262,16 @@ App::DocumentObjectExecReturn *Filling::execute(void) } // Add the constraints of border curves/faces (bound) - addConstraints(builder, Border, BorderFaces, OrderBorderFaces, Standard_True); + addConstraints(builder, BoundaryEdges, BoundaryFaces, BoundaryOrder, Standard_True); - // Add additional curves constraints if available (unbound) - if (Curves.getSize() > 0) { - addConstraints(builder, Curves, CurveFaces, OrderCurveFaces, Standard_False); + // Add additional edge constraints if available (unbound) + if (UnboundEdges.getSize() > 0) { + addConstraints(builder, UnboundEdges, UnboundFaces, UnboundOrder, Standard_False); } // Add additional constraint on free faces if (FreeFaces.getSize() > 0) { - addConstraints(builder, FreeFaces, OrderFreeFaces); + addConstraints(builder, FreeFaces, FreeOrder); } // App point constraints diff --git a/src/Mod/Surface/App/FeatureFilling.h b/src/Mod/Surface/App/FeatureFilling.h index bdc1ba535d..9e1f1f6b8c 100644 --- a/src/Mod/Surface/App/FeatureFilling.h +++ b/src/Mod/Surface/App/FeatureFilling.h @@ -41,14 +41,14 @@ public: Filling(); //Properties of Curves - App::PropertyLinkSubList Border; // Border Edges (C0 is required for edges without a corresponding face) - App::PropertyLinkSubList BorderFaces; // Border Faces (C0, G1 and G2 are possible) - App::PropertyIntegerList OrderBorderFaces; // Order of constraint on border faces - App::PropertyLinkSubList Curves; // Other Constraint Curves (C0 is required for edges without a corresponding face) - App::PropertyLinkSubList CurveFaces; // Curve Faces (C0, G1 and G2 are possible) - App::PropertyIntegerList OrderCurveFaces; // Order of constraint on curve faces - App::PropertyLinkSubList FreeFaces; // Free constraint on a face - App::PropertyIntegerList OrderFreeFaces; // Order of constraint on free faces + App::PropertyLinkSubList BoundaryEdges; // Boundary Edges (C0 is required for edges without a corresponding face) + App::PropertyStringList BoundaryFaces; // Boundary Faces (C0, G1 and G2 are possible) + App::PropertyIntegerList BoundaryOrder; // Order of constraint on border faces + App::PropertyLinkSubList UnboundEdges; // Unbound constraint edges (C0 is required for edges without a corresponding face) + App::PropertyStringList UnboundFaces; // Unbound constraint faces (C0, G1 and G2 are possible) + App::PropertyIntegerList UnboundOrder; // Order of constraint on curve faces + App::PropertyLinkSubList FreeFaces; // Free constraint faces + App::PropertyIntegerList FreeOrder; // Order of constraint on free faces App::PropertyLinkSubList Points; // Constraint Points (on Surface) App::PropertyLinkSub InitialFace; // Initial Face to use @@ -75,7 +75,7 @@ public: private: void addConstraints(BRepFill_Filling& builder, const App::PropertyLinkSubList& edges, - const App::PropertyLinkSubList& faces, + const App::PropertyStringList& faces, const App::PropertyIntegerList& orders, Standard_Boolean bnd); void addConstraints(BRepFill_Filling& builder, diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 4dfc123362..bd4c10b0af 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -107,7 +107,7 @@ QIcon ViewProviderFilling::getIcon(void) const void ViewProviderFilling::highlightReferences(bool on) { Surface::Filling* surface = static_cast(getObject()); - auto bounds = surface->Border.getSubListValues(); + auto bounds = surface->BoundaryEdges.getSubListValues(); for (auto it : bounds) { Part::Feature* base = dynamic_cast(it.first); if (base) { @@ -187,7 +187,7 @@ private: if (element.substr(0,4) != "Edge") return false; - auto links = editedObject->Border.getSubListValues(); + auto links = editedObject->BoundaryEdges.getSubListValues(); for (auto it : links) { if (it.first == pObj) { for (auto jt : it.second) { @@ -249,8 +249,8 @@ void FillingPanel::setEditedObject(Surface::Filling* obj) ui->lineInitFaceName->setText(text); } - auto objects = editedObject->Border.getValues(); - auto element = editedObject->Border.getSubValues(); + auto objects = editedObject->BoundaryEdges.getValues(); + auto element = editedObject->BoundaryEdges.getSubValues(); auto it = objects.begin(); auto jt = element.begin(); @@ -405,7 +405,7 @@ void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item) ui->statusLabel->setText(tr("Edge has %n adjacent face(s)", 0, n)); // fill up the combo boxes - modifyBorder(true); + modifyBoundary(true); ui->comboBoxFaces->addItem(tr("None"), QByteArray("None")); ui->comboBoxCont->addItem(QString::fromLatin1("C0"), static_cast(GeomAbs_C0)); ui->comboBoxCont->addItem(QString::fromLatin1("G1"), static_cast(GeomAbs_G1)); @@ -478,11 +478,11 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) data << QByteArray(msg.pSubName); item->setData(Qt::UserRole, data); - auto objects = editedObject->Border.getValues(); + auto objects = editedObject->BoundaryEdges.getValues(); objects.push_back(sel.getObject()); - auto element = editedObject->Border.getSubValues(); + auto element = editedObject->BoundaryEdges.getSubValues(); element.push_back(msg.pSubName); - editedObject->Border.setValues(objects, element); + editedObject->BoundaryEdges.setValues(objects, element); this->vp->highlightReferences(true); } else if (selectionMode == RemoveEdge) { @@ -502,15 +502,15 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) this->vp->highlightReferences(false); App::DocumentObject* obj = sel.getObject(); std::string sub = msg.pSubName; - auto objects = editedObject->Border.getValues(); - auto element = editedObject->Border.getSubValues(); + auto objects = editedObject->BoundaryEdges.getValues(); + auto element = editedObject->BoundaryEdges.getSubValues(); auto it = objects.begin(); auto jt = element.begin(); for (; it != objects.end() && jt != element.end(); ++it, ++jt) { if (*it == obj && *jt == sub) { objects.erase(it); element.erase(jt); - editedObject->Border.setValues(objects, element); + editedObject->BoundaryEdges.setValues(objects, element); break; } } @@ -536,8 +536,8 @@ void FillingPanel::onDeleteEdge() App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray()); App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr; std::string sub = data[2].toByteArray().constData(); - auto objects = editedObject->Border.getValues(); - auto element = editedObject->Border.getSubValues(); + auto objects = editedObject->BoundaryEdges.getValues(); + auto element = editedObject->BoundaryEdges.getSubValues(); auto it = objects.begin(); auto jt = element.begin(); this->vp->highlightReferences(false); @@ -545,7 +545,7 @@ void FillingPanel::onDeleteEdge() if (*it == obj && *jt == sub) { objects.erase(it); element.erase(jt); - editedObject->Border.setValues(objects, element); + editedObject->BoundaryEdges.setValues(objects, element); break; } } @@ -559,19 +559,22 @@ void FillingPanel::on_buttonAccept_clicked() if (item) { QList data; data = item->data(Qt::UserRole).toList(); + + QVariant face = ui->comboBoxFaces->itemData(ui->comboBoxFaces->currentIndex()); + QVariant cont = ui->comboBoxCont->itemData(ui->comboBoxCont->currentIndex()); if (data.size() == 5) { - data[3] = ui->comboBoxFaces->itemData(ui->comboBoxFaces->currentIndex()); - data[4] = ui->comboBoxCont->itemData(ui->comboBoxCont->currentIndex()); + data[3] = face; + data[4] = cont; } else { - data << ui->comboBoxFaces->itemData(ui->comboBoxFaces->currentIndex()); - data << ui->comboBoxCont->itemData(ui->comboBoxCont->currentIndex()); + data << face; + data << cont; } item->setData(Qt::UserRole, data); } - modifyBorder(false); + modifyBoundary(false); ui->comboBoxFaces->clear(); ui->comboBoxCont->clear(); ui->statusLabel->clear(); @@ -579,13 +582,13 @@ void FillingPanel::on_buttonAccept_clicked() void FillingPanel::on_buttonIgnore_clicked() { - modifyBorder(false); + modifyBoundary(false); ui->comboBoxFaces->clear(); ui->comboBoxCont->clear(); ui->statusLabel->clear(); } -void FillingPanel::modifyBorder(bool on) +void FillingPanel::modifyBoundary(bool on) { ui->buttonInitFace->setDisabled(on); ui->lineInitFaceName->setDisabled(on); diff --git a/src/Mod/Surface/Gui/TaskFilling.h b/src/Mod/Surface/Gui/TaskFilling.h index 752904f60a..a19bc497b6 100644 --- a/src/Mod/Surface/Gui/TaskFilling.h +++ b/src/Mod/Surface/Gui/TaskFilling.h @@ -83,7 +83,7 @@ protected: virtual void slotUndoDocument(const Gui::Document& Doc); /** Notifies on redo */ virtual void slotRedoDocument(const Gui::Document& Doc); - void modifyBorder(bool); + void modifyBoundary(bool); private Q_SLOTS: void on_buttonInitFace_clicked(); From e50dff0f02a979f0fe81d0568a7edde9bc7eeaf8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 23 Apr 2017 19:02:01 +0200 Subject: [PATCH 05/12] Extend task panel for filling function --- src/Mod/Surface/Gui/CMakeLists.txt | 4 + src/Mod/Surface/Gui/TaskFilling.cpp | 148 +++++++--- src/Mod/Surface/Gui/TaskFilling.h | 10 +- src/Mod/Surface/Gui/TaskFillingVertex.cpp | 340 ++++++++++++++++++++++ src/Mod/Surface/Gui/TaskFillingVertex.h | 84 ++++++ src/Mod/Surface/Gui/TaskFillingVertex.ui | 75 +++++ 6 files changed, 617 insertions(+), 44 deletions(-) create mode 100644 src/Mod/Surface/Gui/TaskFillingVertex.cpp create mode 100644 src/Mod/Surface/Gui/TaskFillingVertex.h create mode 100644 src/Mod/Surface/Gui/TaskFillingVertex.ui diff --git a/src/Mod/Surface/Gui/CMakeLists.txt b/src/Mod/Surface/Gui/CMakeLists.txt index 9421d69d6b..83ee775700 100644 --- a/src/Mod/Surface/Gui/CMakeLists.txt +++ b/src/Mod/Surface/Gui/CMakeLists.txt @@ -25,6 +25,7 @@ set(SurfaceGui_LIBS set(SurfaceGui_MOC_HDRS TaskFilling.h + TaskFillingVertex.h TaskGeomFillSurface.h ) fc_wrap_cpp(SurfaceGui_MOC_SRCS ${SurfaceGui_MOC_HDRS}) @@ -38,6 +39,7 @@ endif() SET(SurfaceGui_UIC_SRCS TaskFilling.ui + TaskFillingVertex.ui TaskGeomFillSurface.ui ) @@ -52,6 +54,8 @@ SET(SurfaceGui_SRCS ${SurfaceGui_UIC_HDRS} TaskFilling.cpp TaskFilling.h + TaskFillingVertex.cpp + TaskFillingVertex.h TaskGeomFillSurface.cpp TaskGeomFillSurface.h AppSurfaceGui.cpp diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index bd4c10b0af..7abb040efb 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -43,6 +43,7 @@ #include #include "TaskFilling.h" +#include "TaskFillingVertex.h" #include "ui_TaskFilling.h" @@ -104,32 +105,74 @@ QIcon ViewProviderFilling::getIcon(void) const return Gui::BitmapFactory().pixmap("BSplineSurf"); } -void ViewProviderFilling::highlightReferences(bool on) +void ViewProviderFilling::highlightReferences(ShapeType type, const References& refs, bool on) { - Surface::Filling* surface = static_cast(getObject()); - auto bounds = surface->BoundaryEdges.getSubListValues(); - for (auto it : bounds) { + for (auto it : refs) { Part::Feature* base = dynamic_cast(it.first); if (base) { PartGui::ViewProviderPartExt* svp = dynamic_cast( Gui::Application::Instance->getViewProvider(base)); if (svp) { - if (on) { - std::vector colors; - TopTools_IndexedMapOfShape eMap; - TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap); - colors.resize(eMap.Extent(), svp->LineColor.getValue()); + switch (type) { + case ViewProviderFilling::Vertex: +#if 0 //FIXME + if (on) { + std::vector colors; + TopTools_IndexedMapOfShape vMap; + TopExp::MapShapes(base->Shape.getValue(), TopAbs_VERTEX, vMap); + colors.resize(vMap.Extent(), svp->PointColor.getValue()); - for (auto jt : it.second) { - std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); - assert (idx < colors.size()); - colors[idx] = App::Color(1.0,0.0,1.0); // magenta + for (auto jt : it.second) { + std::size_t idx = static_cast(std::stoi(jt.substr(6)) - 1); + assert (idx < colors.size()); + colors[idx] = App::Color(1.0,0.0,1.0); // magenta + } + + svp->setHighlightedPoints(colors); } + else { + svp->unsetHighlightedPoints(); + } +#endif + break; + case ViewProviderFilling::Edge: + if (on) { + std::vector colors; + TopTools_IndexedMapOfShape eMap; + TopExp::MapShapes(base->Shape.getValue(), TopAbs_EDGE, eMap); + colors.resize(eMap.Extent(), svp->LineColor.getValue()); - svp->setHighlightedEdges(colors); - } - else { - svp->unsetHighlightedEdges(); + for (auto jt : it.second) { + std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); + assert (idx < colors.size()); + colors[idx] = App::Color(1.0,0.0,1.0); // magenta + } + + svp->setHighlightedEdges(colors); + } + else { + svp->unsetHighlightedEdges(); + } + break; + case ViewProviderFilling::Face: + if (on) { + std::vector colors; + TopTools_IndexedMapOfShape fMap; + TopExp::MapShapes(base->Shape.getValue(), TopAbs_FACE, fMap); + colors.resize(fMap.Extent(), svp->ShapeColor.getValue()); + + for (auto jt : it.second) { + std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); + assert (idx < colors.size()); + colors[idx] = App::Color(1.0,0.0,1.0); // magenta + } + + svp->setHighlightedFaces(colors); + } + else { + svp->unsetHighlightedFaces(); + } + break; } } } @@ -141,12 +184,16 @@ void ViewProviderFilling::highlightReferences(bool on) class FillingPanel::ShapeSelection : public Gui::SelectionFilterGate { public: - ShapeSelection(FillingPanel::SelectionMode mode, Surface::Filling* editedObject) + ShapeSelection(FillingPanel::SelectionMode& mode, Surface::Filling* editedObject) : Gui::SelectionFilterGate(static_cast(nullptr)) , mode(mode) , editedObject(editedObject) { } + ~ShapeSelection() + { + mode = FillingPanel::None; + } /** * Allow the user to pick only edges. */ @@ -201,7 +248,7 @@ private: } private: - FillingPanel::SelectionMode mode; + FillingPanel::SelectionMode& mode; Surface::Filling* editedObject; }; @@ -286,7 +333,8 @@ void FillingPanel::changeEvent(QEvent *e) void FillingPanel::open() { checkOpenCommand(); - this->vp->highlightReferences(true); + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), true); Gui::Selection().clearSelection(); } @@ -328,7 +376,8 @@ bool FillingPanel::accept() return false; } - this->vp->highlightReferences(false); + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), false); Gui::Command::commitCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); @@ -338,7 +387,8 @@ bool FillingPanel::accept() bool FillingPanel::reject() { - this->vp->highlightReferences(false); + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), false); selectionMode = None; Gui::Selection().rmvSelectionGate(); @@ -359,20 +409,23 @@ void FillingPanel::on_lineInitFaceName_textChanged(const QString& text) void FillingPanel::on_buttonInitFace_clicked() { - selectionMode = InitFace; + // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject)); + selectionMode = InitFace; } void FillingPanel::on_buttonEdgeAdd_clicked() { - selectionMode = AppendEdge; + // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject)); + selectionMode = AppendEdge; } void FillingPanel::on_buttonEdgeRemove_clicked() { - selectionMode = RemoveEdge; + // 'selectionMode' is passed by reference and changed when the filter is deleted Gui::Selection().addSelectionGate(new ShapeSelection(selectionMode, editedObject)); + selectionMode = RemoveEdge; } void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item) @@ -457,7 +510,7 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) std::vector subList; subList.push_back(msg.pSubName); editedObject->InitialFace.setValue(sel.getObject(), subList); - //this->vp->highlightReferences(true); + //this->vp->highlightReferences(..., true); Gui::Selection().rmvSelectionGate(); selectionMode = None; @@ -483,7 +536,8 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) auto element = editedObject->BoundaryEdges.getSubValues(); element.push_back(msg.pSubName); editedObject->BoundaryEdges.setValues(objects, element); - this->vp->highlightReferences(true); + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), true); } else if (selectionMode == RemoveEdge) { Gui::SelectionObject sel(msg); @@ -499,7 +553,8 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) } } - this->vp->highlightReferences(false); + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), false); App::DocumentObject* obj = sel.getObject(); std::string sub = msg.pSubName; auto objects = editedObject->BoundaryEdges.getValues(); @@ -514,7 +569,8 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) break; } } - this->vp->highlightReferences(true); + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), true); } editedObject->recomputeFeature(); @@ -540,7 +596,8 @@ void FillingPanel::onDeleteEdge() auto element = editedObject->BoundaryEdges.getSubValues(); auto it = objects.begin(); auto jt = element.begin(); - this->vp->highlightReferences(false); + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), false); for (; it != objects.end() && jt != element.end(); ++it, ++jt) { if (*it == obj && *jt == sub) { objects.erase(it); @@ -549,7 +606,8 @@ void FillingPanel::onDeleteEdge() break; } } - this->vp->highlightReferences(true); + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), true); } } @@ -606,13 +664,21 @@ void FillingPanel::modifyBoundary(bool on) TaskFilling::TaskFilling(ViewProviderFilling* vp, Surface::Filling* obj) { - widget = new FillingPanel(vp, obj); - widget->setWindowTitle(QObject::tr("Surface")); - taskbox = new Gui::TaskView::TaskBox( + // first task box + widget1 = new FillingPanel(vp, obj); + Gui::TaskView::TaskBox* taskbox1 = new Gui::TaskView::TaskBox( Gui::BitmapFactory().pixmap("BezSurf"), - widget->windowTitle(), true, 0); - taskbox->groupLayout()->addWidget(widget); - Content.push_back(taskbox); + widget1->windowTitle(), true, 0); + taskbox1->groupLayout()->addWidget(widget1); + Content.push_back(taskbox1); + + // second task box + widget2 = new FillingVertexPanel(vp, obj); + Gui::TaskView::TaskBox* taskbox2 = new Gui::TaskView::TaskBox( + QPixmap(), widget2->windowTitle(), true, 0); + taskbox2->groupLayout()->addWidget(widget2); + Content.push_back(taskbox2); + taskbox2->hideGroupBox(); } TaskFilling::~TaskFilling() @@ -622,22 +688,22 @@ TaskFilling::~TaskFilling() void TaskFilling::setEditedObject(Surface::Filling* obj) { - widget->setEditedObject(obj); + widget1->setEditedObject(obj); } void TaskFilling::open() { - widget->open(); + widget1->open(); } bool TaskFilling::accept() { - return widget->accept(); + return widget1->accept(); } bool TaskFilling::reject() { - return widget->reject(); + return widget1->reject(); } } diff --git a/src/Mod/Surface/Gui/TaskFilling.h b/src/Mod/Surface/Gui/TaskFilling.h index a19bc497b6..1122e17bb0 100644 --- a/src/Mod/Surface/Gui/TaskFilling.h +++ b/src/Mod/Surface/Gui/TaskFilling.h @@ -36,17 +36,21 @@ class QListWidgetItem; namespace SurfaceGui { +class FillingVertexPanel; class Ui_TaskFilling; class ViewProviderFilling : public PartGui::ViewProviderSpline { PROPERTY_HEADER(SurfaceGui::ViewProviderFilling); + typedef std::vector References; + public: + enum ShapeType {Vertex, Edge, Face}; virtual void setupContextMenu(QMenu*, QObject*, const char*); virtual bool setEdit(int ModNum); virtual void unsetEdit(int ModNum); QIcon getIcon(void) const; - void highlightReferences(bool on); + void highlightReferences(ShapeType type, const References& refs, bool on); }; class FillingPanel : public QWidget, @@ -115,8 +119,8 @@ public: { return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; } private: - FillingPanel* widget; - Gui::TaskView::TaskBox* taskbox; + FillingPanel* widget1; + FillingVertexPanel* widget2; }; } //namespace SurfaceGui diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp new file mode 100644 index 0000000000..307e2e3689 --- /dev/null +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -0,0 +1,340 @@ +/*************************************************************************** + * Copyright (c) 2015 Balázs Bámer * + * Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#include "PreCompiled.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "TaskFillingVertex.h" +#include "ui_TaskFillingVertex.h" +#include "TaskFilling.h" + + +using namespace SurfaceGui; + +namespace SurfaceGui { + +class FillingVertexPanel::VertexSelection : public Gui::SelectionFilterGate +{ +public: + VertexSelection(FillingVertexPanel::SelectionMode& mode, Surface::Filling* editedObject) + : Gui::SelectionFilterGate(static_cast(nullptr)) + , mode(mode) + , editedObject(editedObject) + { + } + ~VertexSelection() + { + mode = FillingVertexPanel::None; + } + /** + * Allow the user to pick only edges. + */ + bool allow(App::Document*, App::DocumentObject* pObj, const char* sSubName) + { + // don't allow references to itself + if (pObj == editedObject) + return false; + if (!pObj->isDerivedFrom(Part::Feature::getClassTypeId())) + return false; + + if (!sSubName || sSubName[0] == '\0') + return false; + + switch (mode) { + case FillingVertexPanel::AppendVertex: + return allowVertex(true, pObj, sSubName); + case FillingVertexPanel::RemoveVertex: + return allowVertex(false, pObj, sSubName); + default: + return false; + } + } + +private: + bool allowVertex(bool appendVertex, App::DocumentObject* pObj, const char* sSubName) + { + std::string element(sSubName); + if (element.substr(0,6) != "Vertex") + return false; + + auto links = editedObject->Points.getSubListValues(); + for (auto it : links) { + if (it.first == pObj) { + for (auto jt : it.second) { + if (jt == sSubName) + return !appendVertex; + } + } + } + + return appendVertex; + } + +private: + FillingVertexPanel::SelectionMode& mode; + Surface::Filling* editedObject; +}; + +// ---------------------------------------------------------------------------- + +FillingVertexPanel::FillingVertexPanel(ViewProviderFilling* vp, Surface::Filling* obj) +{ + ui = new Ui_TaskFillingVertex(); + ui->setupUi(this); + + selectionMode = None; + this->vp = vp; + checkCommand = true; + setEditedObject(obj); + + // Create context menu + QAction* action = new QAction(tr("Remove"), this); + action->setShortcut(QString::fromLatin1("Del")); + ui->listFreeVertex->addAction(action); + connect(action, SIGNAL(triggered()), this, SLOT(onDeleteVertex())); + ui->listFreeVertex->setContextMenuPolicy(Qt::ActionsContextMenu); +} + +/* + * Destroys the object and frees any allocated resources + */ +FillingVertexPanel::~FillingVertexPanel() +{ + // no need to delete child widgets, Qt does it all for us + delete ui; + Gui::Selection().rmvSelectionGate(); +} + +// stores object pointer, its old fill type and adjusts radio buttons according to it. +void FillingVertexPanel::setEditedObject(Surface::Filling* obj) +{ + editedObject = obj; + + auto objects = editedObject->Points.getValues(); + auto element = editedObject->Points.getSubValues(); + auto it = objects.begin(); + auto jt = element.begin(); + + App::Document* doc = editedObject->getDocument(); + for (; it != objects.end() && jt != element.end(); ++it, ++jt) { + QListWidgetItem* item = new QListWidgetItem(ui->listFreeVertex); + ui->listFreeVertex->addItem(item); + + QString text = QString::fromLatin1("%1.%2") + .arg(QString::fromUtf8((*it)->Label.getValue())) + .arg(QString::fromStdString(*jt)); + item->setText(text); + + QList data; + data << QByteArray(doc->getName()); + data << QByteArray((*it)->getNameInDocument()); + data << QByteArray(jt->c_str()); + item->setData(Qt::UserRole, data); + } + attachDocument(Gui::Application::Instance->getDocument(doc)); +} + +void FillingVertexPanel::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } + else { + QWidget::changeEvent(e); + } +} + +void FillingVertexPanel::open() +{ + checkOpenCommand(); + this->vp->highlightReferences(ViewProviderFilling::Vertex, + editedObject->Points.getSubListValues(), true); + Gui::Selection().clearSelection(); +} + +void FillingVertexPanel::clearSelection() +{ + Gui::Selection().clearSelection(); +} + +void FillingVertexPanel::checkOpenCommand() +{ + if (checkCommand && !Gui::Command::hasPendingCommand()) { + std::string Msg("Edit "); + Msg += editedObject->Label.getValue(); + Gui::Command::openCommand(Msg.c_str()); + checkCommand = false; + } +} + +void FillingVertexPanel::slotUndoDocument(const Gui::Document&) +{ + checkCommand = true; +} + +void FillingVertexPanel::slotRedoDocument(const Gui::Document&) +{ + checkCommand = true; +} + +void FillingVertexPanel::on_buttonVertexAdd_clicked() +{ + // 'selectionMode' is passed by reference and changed when the filter is deleted + Gui::Selection().addSelectionGate(new VertexSelection(selectionMode, editedObject)); + selectionMode = AppendVertex; +} + +void FillingVertexPanel::on_buttonVertexRemove_clicked() +{ + // 'selectionMode' is passed by reference and changed when the filter is deleted + Gui::Selection().addSelectionGate(new VertexSelection(selectionMode, editedObject)); + selectionMode = RemoveVertex; +} + +void FillingVertexPanel::onSelectionChanged(const Gui::SelectionChanges& msg) +{ + if (selectionMode == None) + return; + + if (msg.Type == Gui::SelectionChanges::AddSelection) { + checkOpenCommand(); + if (selectionMode == AppendVertex) { + QListWidgetItem* item = new QListWidgetItem(ui->listFreeVertex); + ui->listFreeVertex->addItem(item); + + Gui::SelectionObject sel(msg); + QString text = QString::fromLatin1("%1.%2") + .arg(QString::fromUtf8(sel.getObject()->Label.getValue())) + .arg(QString::fromLatin1(msg.pSubName)); + item->setText(text); + + QList data; + data << QByteArray(msg.pDocName); + data << QByteArray(msg.pObjectName); + data << QByteArray(msg.pSubName); + item->setData(Qt::UserRole, data); + + auto objects = editedObject->Points.getValues(); + objects.push_back(sel.getObject()); + auto element = editedObject->Points.getSubValues(); + element.push_back(msg.pSubName); + editedObject->Points.setValues(objects, element); + this->vp->highlightReferences(ViewProviderFilling::Vertex, + editedObject->Points.getSubListValues(), true); + } + else if (selectionMode == RemoveVertex) { + Gui::SelectionObject sel(msg); + QList data; + data << QByteArray(msg.pDocName); + data << QByteArray(msg.pObjectName); + data << QByteArray(msg.pSubName); + for (int i=0; ilistFreeVertex->count(); i++) { + QListWidgetItem* item = ui->listFreeVertex->item(i); + if (item && item->data(Qt::UserRole) == data) { + ui->listFreeVertex->takeItem(i); + delete item; + } + } + + this->vp->highlightReferences(ViewProviderFilling::Vertex, + editedObject->Points.getSubListValues(), false); + App::DocumentObject* obj = sel.getObject(); + std::string sub = msg.pSubName; + auto objects = editedObject->Points.getValues(); + auto element = editedObject->Points.getSubValues(); + auto it = objects.begin(); + auto jt = element.begin(); + for (; it != objects.end() && jt != element.end(); ++it, ++jt) { + if (*it == obj && *jt == sub) { + objects.erase(it); + element.erase(jt); + editedObject->Points.setValues(objects, element); + break; + } + } + this->vp->highlightReferences(ViewProviderFilling::Vertex, + editedObject->Points.getSubListValues(), false); + } + + editedObject->recomputeFeature(); + QTimer::singleShot(50, this, SLOT(clearSelection())); + } +} + +void FillingVertexPanel::onDeleteVertex() +{ + int row = ui->listFreeVertex->currentRow(); + QListWidgetItem* item = ui->listFreeVertex->item(row); + if (item) { + checkOpenCommand(); + QList data; + data = item->data(Qt::UserRole).toList(); + ui->listFreeVertex->takeItem(row); + delete item; + + App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray()); + App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr; + std::string sub = data[2].toByteArray().constData(); + auto objects = editedObject->Points.getValues(); + auto element = editedObject->Points.getSubValues(); + auto it = objects.begin(); + auto jt = element.begin(); + this->vp->highlightReferences(ViewProviderFilling::Vertex, + editedObject->Points.getSubListValues(), false); + + for (; it != objects.end() && jt != element.end(); ++it, ++jt) { + if (*it == obj && *jt == sub) { + objects.erase(it); + element.erase(jt); + editedObject->Points.setValues(objects, element); + editedObject->recomputeFeature(); + break; + } + } + + this->vp->highlightReferences(ViewProviderFilling::Vertex, + editedObject->Points.getSubListValues(), true); + } +} + +} + +#include "moc_TaskFillingVertex.cpp" diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.h b/src/Mod/Surface/Gui/TaskFillingVertex.h new file mode 100644 index 0000000000..5776b58319 --- /dev/null +++ b/src/Mod/Surface/Gui/TaskFillingVertex.h @@ -0,0 +1,84 @@ +/*************************************************************************** + * Copyright (c) 2015 Balázs Bámer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#ifndef SURFACEGUI_TASKFILLINGVERTEX_H +#define SURFACEGUI_TASKFILLINGVERTEX_H + +#include +#include +#include +#include +#include +#include +#include + +class QListWidgetItem; + +namespace SurfaceGui +{ + +class ViewProviderFilling; +class Ui_TaskFillingVertex; + +class FillingVertexPanel : public QWidget, + public Gui::SelectionObserver, + public Gui::DocumentObserver +{ + Q_OBJECT + +protected: + class VertexSelection; + enum SelectionMode { None, AppendVertex, RemoveVertex }; + SelectionMode selectionMode; + Surface::Filling* editedObject; + bool checkCommand; + +private: + Ui_TaskFillingVertex* ui; + ViewProviderFilling* vp; + +public: + FillingVertexPanel(ViewProviderFilling* vp, Surface::Filling* obj); + ~FillingVertexPanel(); + + void open(); + void checkOpenCommand(); + void setEditedObject(Surface::Filling* obj); + +protected: + void changeEvent(QEvent *e); + virtual void onSelectionChanged(const Gui::SelectionChanges& msg); + /** Notifies on undo */ + virtual void slotUndoDocument(const Gui::Document& Doc); + /** Notifies on redo */ + virtual void slotRedoDocument(const Gui::Document& Doc); + +private Q_SLOTS: + void on_buttonVertexAdd_clicked(); + void on_buttonVertexRemove_clicked(); + void onDeleteVertex(void); + void clearSelection(); +}; + +} //namespace SurfaceGui + +#endif // SURFACEGUI_TASKFILLINGVERTEX_H diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.ui b/src/Mod/Surface/Gui/TaskFillingVertex.ui new file mode 100644 index 0000000000..e82452c75b --- /dev/null +++ b/src/Mod/Surface/Gui/TaskFillingVertex.ui @@ -0,0 +1,75 @@ + + + SurfaceGui::TaskFillingVertex + + + + 0 + 0 + 273 + 329 + + + + Vertexes + + + + + + Unbound vertexes + + + + + + + + true + + + + 0 + 0 + + + + Add Vertex + + + true + + + false + + + + + + + + 0 + 0 + + + + Remove Vertex + + + true + + + + + + + + + + + + + + + + From d73fd1e8ab18091f6173c5775975bafd00be2826 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Apr 2017 00:23:11 +0200 Subject: [PATCH 06/12] Extend task panel for filling function --- src/Mod/Surface/Gui/TaskFilling.cpp | 123 +++++++++++++++++++--- src/Mod/Surface/Gui/TaskFilling.h | 2 +- src/Mod/Surface/Gui/TaskFillingVertex.cpp | 3 +- src/Mod/Surface/Gui/TaskFillingVertex.h | 2 +- 4 files changed, 114 insertions(+), 16 deletions(-) diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 7abb040efb..ff5a90d901 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -1,6 +1,5 @@ /*************************************************************************** - * Copyright (c) 2015 Balázs Bámer * - * Werner Mayer * + * Copyright (c) 2017 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * @@ -287,6 +286,7 @@ void FillingPanel::setEditedObject(Surface::Filling* obj) { editedObject = obj; + // get the link to the initial surface if set App::DocumentObject* initFace = editedObject->InitialFace.getValue(); const std::vector& subList = editedObject->InitialFace.getSubValues(); if (initFace && subList.size() == 1) { @@ -296,27 +296,56 @@ void FillingPanel::setEditedObject(Surface::Filling* obj) ui->lineInitFaceName->setText(text); } + // get the boundary edges, if set their adjacent faces and continuities auto objects = editedObject->BoundaryEdges.getValues(); - auto element = editedObject->BoundaryEdges.getSubValues(); - auto it = objects.begin(); - auto jt = element.begin(); + auto edges = editedObject->BoundaryEdges.getSubValues(); + auto count = objects.size(); + + // fill up faces if wrong size + auto faces = editedObject->BoundaryFaces.getValues(); + if (faces.size() != edges.size()) { + faces.resize(edges.size()); + std::fill(faces.begin(), faces.end(), std::string()); + } + + // fill up continuities if wrong size + auto conts = editedObject->BoundaryOrder.getValues(); + if (edges.size() != conts.size()) { + conts.resize(edges.size()); + std::fill(conts.begin(), conts.end(), static_cast(GeomAbs_C0)); + } App::Document* doc = editedObject->getDocument(); - for (; it != objects.end() && jt != element.end(); ++it, ++jt) { + for (std::size_t i=0; ilistBoundary); ui->listBoundary->addItem(item); QString text = QString::fromLatin1("%1.%2") - .arg(QString::fromUtf8((*it)->Label.getValue())) - .arg(QString::fromStdString(*jt)); + .arg(QString::fromUtf8(obj->Label.getValue())) + .arg(QString::fromStdString(edge)); item->setText(text); + // The user data field of a list widget item + // is a list of five elementa: + // 1. document name + // 2. object name + // 3. sub-element name of the edge + // 4. sub-element of an adjacent face or empty string + // 5. the continuity as int QList data; data << QByteArray(doc->getName()); - data << QByteArray((*it)->getNameInDocument()); - data << QByteArray(jt->c_str()); + data << QByteArray(obj->getNameInDocument()); + data << QByteArray(edge.c_str()); + data << QByteArray(face.c_str()); + data << static_cast(conts[i]); item->setData(Qt::UserRole, data); } + + // attach this document observer attachDocument(Gui::Application::Instance->getDocument(doc)); } @@ -433,6 +462,7 @@ void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item) Gui::Selection().clearSelection(); Gui::Selection().rmvSelectionGate(); selectionMode = None; + ui->comboBoxFaces->clear(); ui->comboBoxCont->clear(); @@ -459,7 +489,7 @@ void FillingPanel::on_listBoundary_itemDoubleClicked(QListWidgetItem* item) // fill up the combo boxes modifyBoundary(true); - ui->comboBoxFaces->addItem(tr("None"), QByteArray("None")); + ui->comboBoxFaces->addItem(tr("None"), QByteArray("")); ui->comboBoxCont->addItem(QString::fromLatin1("C0"), static_cast(GeomAbs_C0)); ui->comboBoxCont->addItem(QString::fromLatin1("G1"), static_cast(GeomAbs_G1)); ui->comboBoxCont->addItem(QString::fromLatin1("G2"), static_cast(GeomAbs_G2)); @@ -529,13 +559,29 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) data << QByteArray(msg.pDocName); data << QByteArray(msg.pObjectName); data << QByteArray(msg.pSubName); + data << QByteArray(""); + data << static_cast(GeomAbs_C0); item->setData(Qt::UserRole, data); auto objects = editedObject->BoundaryEdges.getValues(); + std::size_t count = objects.size(); objects.push_back(sel.getObject()); auto element = editedObject->BoundaryEdges.getSubValues(); element.push_back(msg.pSubName); editedObject->BoundaryEdges.setValues(objects, element); + + // extend faces and continuities lists if needed + auto faces = editedObject->BoundaryFaces.getValues(); + if (count == faces.size()) { + faces.push_back(std::string()); + editedObject->BoundaryFaces.setValues(faces); + } + auto conts = editedObject->BoundaryOrder.getValues(); + if (count == conts.size()) { + conts.push_back(static_cast(GeomAbs_C0)); + editedObject->BoundaryOrder.setValues(conts); + } + this->vp->highlightReferences(ViewProviderFilling::Edge, editedObject->BoundaryEdges.getSubListValues(), true); } @@ -545,11 +591,15 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) data << QByteArray(msg.pDocName); data << QByteArray(msg.pObjectName); data << QByteArray(msg.pSubName); + + // only the three first elements must match for (int i=0; ilistBoundary->count(); i++) { QListWidgetItem* item = ui->listBoundary->item(i); - if (item && item->data(Qt::UserRole) == data) { + QList userdata = item->data(Qt::UserRole).toList(); + if (userdata.mid(0,3) == data) { ui->listBoundary->takeItem(i); delete item; + break; } } @@ -561,11 +611,28 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) auto element = editedObject->BoundaryEdges.getSubValues(); auto it = objects.begin(); auto jt = element.begin(); + for (; it != objects.end() && jt != element.end(); ++it, ++jt) { if (*it == obj && *jt == sub) { + std::size_t index = std::distance(objects.begin(), it); + objects.erase(it); element.erase(jt); editedObject->BoundaryEdges.setValues(objects, element); + + // try to remove the item also from the faces + auto faces = editedObject->BoundaryFaces.getValues(); + if (index < faces.size()) { + faces.erase(faces.begin() + index); + editedObject->BoundaryFaces.setValues(faces); + } + + // try to remove the item also from the orders + auto order = editedObject->BoundaryOrder.getValues(); + if (index < order.size()) { + order.erase(order.begin() + index); + editedObject->BoundaryOrder.setValues(order); + } break; } } @@ -600,9 +667,25 @@ void FillingPanel::onDeleteEdge() editedObject->BoundaryEdges.getSubListValues(), false); for (; it != objects.end() && jt != element.end(); ++it, ++jt) { if (*it == obj && *jt == sub) { + std::size_t index = std::distance(objects.begin(), it); + objects.erase(it); element.erase(jt); editedObject->BoundaryEdges.setValues(objects, element); + + // try to remove the item also from the faces + auto faces = editedObject->BoundaryFaces.getValues(); + if (index < faces.size()) { + faces.erase(faces.begin() + index); + editedObject->BoundaryFaces.setValues(faces); + } + + // try to remove the item also from the orders + auto order = editedObject->BoundaryOrder.getValues(); + if (index < order.size()) { + order.erase(order.begin() + index); + editedObject->BoundaryOrder.setValues(order); + } break; } } @@ -630,6 +713,22 @@ void FillingPanel::on_buttonAccept_clicked() } item->setData(Qt::UserRole, data); + + std::size_t index = ui->listBoundary->row(item); + + // try to set the item of the faces + auto faces = editedObject->BoundaryFaces.getValues(); + if (index < faces.size()) { + faces[index] = face.toByteArray().data(); + editedObject->BoundaryFaces.setValues(faces); + } + + // try to set the item of the orders + auto order = editedObject->BoundaryOrder.getValues(); + if (index < order.size()) { + order[index] = cont.toInt(); + editedObject->BoundaryOrder.setValues(order); + } } modifyBoundary(false); diff --git a/src/Mod/Surface/Gui/TaskFilling.h b/src/Mod/Surface/Gui/TaskFilling.h index 1122e17bb0..a1e448334c 100644 --- a/src/Mod/Surface/Gui/TaskFilling.h +++ b/src/Mod/Surface/Gui/TaskFilling.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2015 Balázs Bámer * + * Copyright (c) 2017 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp index 307e2e3689..dbe3b38b6d 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.cpp +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -1,6 +1,5 @@ /*************************************************************************** - * Copyright (c) 2015 Balázs Bámer * - * Werner Mayer * + * Copyright (c) 2017 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.h b/src/Mod/Surface/Gui/TaskFillingVertex.h index 5776b58319..157ca40daa 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.h +++ b/src/Mod/Surface/Gui/TaskFillingVertex.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2015 Balázs Bámer * + * Copyright (c) 2017 Werner Mayer * * * * This file is part of the FreeCAD CAx development system. * * * From aad1777443baf609e958f8847d99d125dd55f6b2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Apr 2017 11:11:17 +0200 Subject: [PATCH 07/12] fix include dir on cmake --- src/Mod/Surface/Gui/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Surface/Gui/CMakeLists.txt b/src/Mod/Surface/Gui/CMakeLists.txt index 83ee775700..36bb016d40 100644 --- a/src/Mod/Surface/Gui/CMakeLists.txt +++ b/src/Mod/Surface/Gui/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories( ${CMAKE_BINARY_DIR}/src ${CMAKE_CURRENT_BINARY_DIR} ${Boost_INCLUDE_DIRS} - ${COIN3D_INCLUDE_DIR} + ${COIN3D_INCLUDE_DIRS} ${OCC_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${XercesC_INCLUDE_DIRS} From 6a4171c24309d4159e5c2c414725b237e6342887 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Apr 2017 14:43:30 +0200 Subject: [PATCH 08/12] implement highlighting of surface in filling task panel --- src/Mod/Part/Gui/ViewProviderExt.cpp | 2 +- src/Mod/Surface/Gui/TaskFilling.cpp | 37 +++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 8c832cf969..fbe17a5bb7 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -701,7 +701,7 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector& void ViewProviderPartExt::unsetHighlightedFaces() { - ShapeMaterial.touch(); + DiffuseColor.touch(); Transparency.touch(); } diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index ff5a90d901..a97b8d14aa 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -114,7 +114,6 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References& if (svp) { switch (type) { case ViewProviderFilling::Vertex: -#if 0 //FIXME if (on) { std::vector colors; TopTools_IndexedMapOfShape vMap; @@ -132,7 +131,6 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References& else { svp->unsetHighlightedPoints(); } -#endif break; case ViewProviderFilling::Edge: if (on) { @@ -362,8 +360,17 @@ void FillingPanel::changeEvent(QEvent *e) void FillingPanel::open() { checkOpenCommand(); + + // highlight the boundary edges this->vp->highlightReferences(ViewProviderFilling::Edge, editedObject->BoundaryEdges.getSubListValues(), true); + + // highlight the referenced face + std::vector links; + links.push_back(std::make_pair(editedObject->InitialFace.getValue(), + editedObject->InitialFace.getSubValues())); + this->vp->highlightReferences(ViewProviderFilling::Face, links, true); + Gui::Selection().clearSelection(); } @@ -408,6 +415,12 @@ bool FillingPanel::accept() this->vp->highlightReferences(ViewProviderFilling::Edge, editedObject->BoundaryEdges.getSubListValues(), false); + // unhighlight the referenced face + std::vector links; + links.push_back(std::make_pair(editedObject->InitialFace.getValue(), + editedObject->InitialFace.getSubValues())); + this->vp->highlightReferences(ViewProviderFilling::Face, links, false); + Gui::Command::commitCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); Gui::Command::updateActive(); @@ -418,6 +431,13 @@ bool FillingPanel::reject() { this->vp->highlightReferences(ViewProviderFilling::Edge, editedObject->BoundaryEdges.getSubListValues(), false); + + // unhighlight the referenced face + std::vector links; + links.push_back(std::make_pair(editedObject->InitialFace.getValue(), + editedObject->InitialFace.getSubValues())); + this->vp->highlightReferences(ViewProviderFilling::Face, links, false); + selectionMode = None; Gui::Selection().rmvSelectionGate(); @@ -431,6 +451,13 @@ void FillingPanel::on_lineInitFaceName_textChanged(const QString& text) { if (text.isEmpty()) { checkOpenCommand(); + + // unhighlight the referenced face + std::vector links; + links.push_back(std::make_pair(editedObject->InitialFace.getValue(), + editedObject->InitialFace.getSubValues())); + this->vp->highlightReferences(ViewProviderFilling::Face, links, false); + editedObject->InitialFace.setValue(nullptr); editedObject->recomputeFeature(); } @@ -540,7 +567,11 @@ void FillingPanel::onSelectionChanged(const Gui::SelectionChanges& msg) std::vector subList; subList.push_back(msg.pSubName); editedObject->InitialFace.setValue(sel.getObject(), subList); - //this->vp->highlightReferences(..., true); + + // highlight the referenced face + std::vector links; + links.push_back(std::make_pair(sel.getObject(), subList)); + this->vp->highlightReferences(ViewProviderFilling::Face, links, true); Gui::Selection().rmvSelectionGate(); selectionMode = None; From 7e977a8eccfb92f530dbb9dff06269abaa78efb6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Apr 2017 14:53:05 +0200 Subject: [PATCH 09/12] rename material binding class member for faces to make clear its purpose --- src/Mod/Part/Gui/ViewProviderExt.cpp | 26 +++++++++++++------------- src/Mod/Part/Gui/ViewProviderExt.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index fbe17a5bb7..98f5bb7ec2 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -273,8 +273,8 @@ ViewProviderPartExt::ViewProviderPartExt() nodeset = new SoBrepPointSet(); nodeset->ref(); - pcShapeBind = new SoMaterialBinding(); - pcShapeBind->ref(); + pcFaceBind = new SoMaterialBinding(); + pcFaceBind->ref(); pcLineBind = new SoMaterialBinding(); pcLineBind->ref(); @@ -308,7 +308,7 @@ ViewProviderPartExt::ViewProviderPartExt() ViewProviderPartExt::~ViewProviderPartExt() { - pcShapeBind->unref(); + pcFaceBind->unref(); pcLineBind->unref(); pcLineMaterial->unref(); pcPointMaterial->unref(); @@ -391,7 +391,7 @@ void ViewProviderPartExt::onChanged(const App::Property* prop) setHighlightedFaces(DiffuseColor.getValues()); } else if (prop == &ShapeMaterial || prop == &ShapeColor) { - pcShapeBind->value = SoMaterialBinding::OVERALL; + pcFaceBind->value = SoMaterialBinding::OVERALL; ViewProviderGeometryObject::onChanged(prop); DiffuseColor.setValue(ShapeColor.getValue()); } @@ -400,7 +400,7 @@ void ViewProviderPartExt::onChanged(const App::Property* prop) long value = (long)(100*Mat.transparency); if (value != Transparency.getValue()) { float trans = Transparency.getValue()/100.0f; - if (pcShapeBind->value.getValue() == SoMaterialBinding::PER_PART) { + if (pcFaceBind->value.getValue() == SoMaterialBinding::PER_PART) { int cnt = pcShapeMaterial->diffuseColor.getNum(); pcShapeMaterial->transparency.setNum(cnt); float *t = pcShapeMaterial->transparency.startEditing(); @@ -480,7 +480,7 @@ void ViewProviderPartExt::attach(App::DocumentObject *pcFeat) // just faces with no edges or points pcFlatRoot->addChild(pShapeHints); - pcFlatRoot->addChild(pcShapeBind); + pcFlatRoot->addChild(pcFaceBind); pcFlatRoot->addChild(pcShapeMaterial); SoDrawStyle* pcFaceStyle = new SoDrawStyle(); pcFaceStyle->style = SoDrawStyle::FILLED; @@ -643,7 +643,7 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector& col { int size = static_cast(colors.size()); if (size > 1 && size == this->faceset->partIndex.getNum()) { - pcShapeBind->value = SoMaterialBinding::PER_PART; + pcFaceBind->value = SoMaterialBinding::PER_PART; pcShapeMaterial->diffuseColor.setNum(size); pcShapeMaterial->transparency.setNum(size); SbColor* ca = pcShapeMaterial->diffuseColor.startEditing(); @@ -656,7 +656,7 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector& col pcShapeMaterial->transparency.finishEditing(); } else if (colors.size() == 1) { - pcShapeBind->value = SoMaterialBinding::OVERALL; + pcFaceBind->value = SoMaterialBinding::OVERALL; pcShapeMaterial->diffuseColor.setValue(colors[0].r, colors[0].g, colors[0].b); //pcShapeMaterial->transparency = colors[0].a; do not get transparency from DiffuseColor in this case } @@ -666,7 +666,7 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector& { int size = static_cast(colors.size()); if (size > 1 && size == this->faceset->partIndex.getNum()) { - pcShapeBind->value = SoMaterialBinding::PER_PART; + pcFaceBind->value = SoMaterialBinding::PER_PART; pcShapeMaterial->diffuseColor.setNum(size); pcShapeMaterial->ambientColor.setNum(size); @@ -691,7 +691,7 @@ void ViewProviderPartExt::setHighlightedFaces(const std::vector& pcShapeMaterial->emissiveColor.finishEditing(); } else if (colors.size() == 1) { - pcShapeBind->value = SoMaterialBinding::OVERALL; + pcFaceBind->value = SoMaterialBinding::OVERALL; pcShapeMaterial->diffuseColor.setValue(colors[0].diffuseColor.r, colors[0].diffuseColor.g, colors[0].diffuseColor.b); pcShapeMaterial->ambientColor.setValue(colors[0].ambientColor.r, colors[0].ambientColor.g, colors[0].ambientColor.b); pcShapeMaterial->specularColor.setValue(colors[0].specularColor.r, colors[0].specularColor.g, colors[0].specularColor.b); @@ -745,7 +745,7 @@ void ViewProviderPartExt::setHighlightedPoints(const std::vector& co int size = static_cast(colors.size()); if (size > 1) { // FIXME: Check for size mismatch between number of points and number of colors - pcShapeBind->value = SoMaterialBinding::PER_VERTEX; + pcFaceBind->value = SoMaterialBinding::PER_VERTEX; pcPointMaterial->diffuseColor.setNum(size); SbColor* ca = pcPointMaterial->diffuseColor.startEditing(); for (int i = 0; i < size; ++i) @@ -753,7 +753,7 @@ void ViewProviderPartExt::setHighlightedPoints(const std::vector& co pcPointMaterial->diffuseColor.finishEditing(); } else if (size == 1) { - pcShapeBind->value = SoMaterialBinding::OVERALL; + pcFaceBind->value = SoMaterialBinding::OVERALL; pcPointMaterial->diffuseColor.setValue(colors[0].r, colors[0].g, colors[0].b); } } @@ -818,7 +818,7 @@ void ViewProviderPartExt::updateData(const App::Property* prop) if (!VisualTouched) { if (this->faceset->partIndex.getNum() > this->pcShapeMaterial->diffuseColor.getNum()) { - this->pcShapeBind->value = SoMaterialBinding::OVERALL; + this->pcFaceBind->value = SoMaterialBinding::OVERALL; } } } diff --git a/src/Mod/Part/Gui/ViewProviderExt.h b/src/Mod/Part/Gui/ViewProviderExt.h index 36f2130dfa..2af7c0b6ac 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.h +++ b/src/Mod/Part/Gui/ViewProviderExt.h @@ -145,7 +145,7 @@ protected: TColgp_Array1OfDir& theNormals); // nodes for the data representation - SoMaterialBinding * pcShapeBind; + SoMaterialBinding * pcFaceBind; SoMaterialBinding * pcLineBind; SoMaterial * pcLineMaterial; SoMaterial * pcPointMaterial; From 35544db84a74fdd14dfd17cb4942bec3274fc790 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Apr 2017 17:19:21 +0200 Subject: [PATCH 10/12] fix vertex highlighting --- src/Mod/Part/Gui/ViewProviderExt.cpp | 20 ++++++++++++++++---- src/Mod/Part/Gui/ViewProviderExt.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 98f5bb7ec2..1d82e3690b 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -73,6 +73,7 @@ # include # include # include +# include # include # include # include @@ -244,6 +245,7 @@ ViewProviderPartExt::ViewProviderPartExt() ADD_PROPERTY(PointMaterial,(mat)); ADD_PROPERTY(LineColor,(mat.diffuseColor)); ADD_PROPERTY(PointColor,(mat.diffuseColor)); + ADD_PROPERTY(PointColorArray, (PointColor.getValue())); ADD_PROPERTY(DiffuseColor,(ShapeColor.getValue())); ADD_PROPERTY(LineColorArray,(LineColor.getValue())); ADD_PROPERTY(LineWidth,(lwidth)); @@ -282,6 +284,8 @@ ViewProviderPartExt::ViewProviderPartExt() pcLineMaterial->ref(); LineMaterial.touch(); + pcPointBind = new SoMaterialBinding(); + pcPointBind->ref(); pcPointMaterial = new SoMaterial; pcPointMaterial->ref(); PointMaterial.touch(); @@ -310,6 +314,7 @@ ViewProviderPartExt::~ViewProviderPartExt() { pcFaceBind->unref(); pcLineBind->unref(); + pcPointBind->unref(); pcLineMaterial->unref(); pcPointMaterial->unref(); pcLineStyle->unref(); @@ -494,6 +499,7 @@ void ViewProviderPartExt::attach(App::DocumentObject *pcFeat) pcWireframeRoot->addChild(pcPointsRoot); // normal viewing with edges and points + pcPointsRoot->addChild(pcPointBind); pcPointsRoot->addChild(pcPointMaterial); pcPointsRoot->addChild(pcPointStyle); pcPointsRoot->addChild(nodeset); @@ -744,8 +750,14 @@ void ViewProviderPartExt::setHighlightedPoints(const std::vector& co { int size = static_cast(colors.size()); if (size > 1) { - // FIXME: Check for size mismatch between number of points and number of colors - pcFaceBind->value = SoMaterialBinding::PER_VERTEX; +#ifdef FC_DEBUG + int numPoints = coords->point.getNum() - nodeset->startIndex.getValue(); + if (numPoints != size) { + SoDebugError::postWarning("ViewProviderPartExt::setHighlightedPoints", + "The number of points (%d) doesn't match with the number of colors (%d).", numPoints, size); + } +#endif + pcPointBind->value = SoMaterialBinding::PER_VERTEX; pcPointMaterial->diffuseColor.setNum(size); SbColor* ca = pcPointMaterial->diffuseColor.startEditing(); for (int i = 0; i < size; ++i) @@ -753,14 +765,14 @@ void ViewProviderPartExt::setHighlightedPoints(const std::vector& co pcPointMaterial->diffuseColor.finishEditing(); } else if (size == 1) { - pcFaceBind->value = SoMaterialBinding::OVERALL; + pcPointBind->value = SoMaterialBinding::OVERALL; pcPointMaterial->diffuseColor.setValue(colors[0].r, colors[0].g, colors[0].b); } } void ViewProviderPartExt::unsetHighlightedPoints() { - PointMaterial.touch(); + PointColorArray.touch(); } bool ViewProviderPartExt::loadParameter() diff --git a/src/Mod/Part/Gui/ViewProviderExt.h b/src/Mod/Part/Gui/ViewProviderExt.h index 2af7c0b6ac..33accd97a0 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.h +++ b/src/Mod/Part/Gui/ViewProviderExt.h @@ -147,6 +147,7 @@ protected: // nodes for the data representation SoMaterialBinding * pcFaceBind; SoMaterialBinding * pcLineBind; + SoMaterialBinding * pcPointBind; SoMaterial * pcLineMaterial; SoMaterial * pcPointMaterial; SoDrawStyle * pcLineStyle; From 2cfb029fe501e57ee84b000dacc9118f2c68c9d0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Apr 2017 17:20:41 +0200 Subject: [PATCH 11/12] highlighting of point constraints --- src/Mod/Surface/Gui/TaskFilling.cpp | 26 ++++++++++++++++------- src/Mod/Surface/Gui/TaskFillingVertex.cpp | 8 ++++++- src/Mod/Surface/Gui/TaskFillingVertex.h | 1 + src/Mod/Surface/Gui/TaskFillingVertex.ui | 6 ------ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index a97b8d14aa..48c2f4be93 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -421,9 +421,6 @@ bool FillingPanel::accept() editedObject->InitialFace.getSubValues())); this->vp->highlightReferences(ViewProviderFilling::Face, links, false); - Gui::Command::commitCommand(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); - Gui::Command::updateActive(); return true; } @@ -441,9 +438,6 @@ bool FillingPanel::reject() selectionMode = None; Gui::Selection().rmvSelectionGate(); - Gui::Command::abortCommand(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); - Gui::Command::updateActive(); return true; } @@ -828,12 +822,28 @@ void TaskFilling::open() bool TaskFilling::accept() { - return widget1->accept(); + bool ok = widget1->accept(); + if (ok) { + widget2->reject(); + Gui::Command::commitCommand(); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::updateActive(); + } + + return ok; } bool TaskFilling::reject() { - return widget1->reject(); + bool ok = widget1->reject(); + if (ok) { + widget2->reject(); + Gui::Command::abortCommand(); + Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::updateActive(); + } + + return ok; } } diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp index dbe3b38b6d..b9246d673c 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.cpp +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -189,6 +189,12 @@ void FillingVertexPanel::open() Gui::Selection().clearSelection(); } +void FillingVertexPanel::reject() +{ + this->vp->highlightReferences(ViewProviderFilling::Vertex, + editedObject->Points.getSubListValues(), false); +} + void FillingVertexPanel::clearSelection() { Gui::Selection().clearSelection(); @@ -290,7 +296,7 @@ void FillingVertexPanel::onSelectionChanged(const Gui::SelectionChanges& msg) } } this->vp->highlightReferences(ViewProviderFilling::Vertex, - editedObject->Points.getSubListValues(), false); + editedObject->Points.getSubListValues(), true); } editedObject->recomputeFeature(); diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.h b/src/Mod/Surface/Gui/TaskFillingVertex.h index 157ca40daa..a1a704fb07 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.h +++ b/src/Mod/Surface/Gui/TaskFillingVertex.h @@ -61,6 +61,7 @@ public: ~FillingVertexPanel(); void open(); + void reject(); void checkOpenCommand(); void setEditedObject(Surface::Filling* obj); diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.ui b/src/Mod/Surface/Gui/TaskFillingVertex.ui index e82452c75b..7e939ad7e8 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.ui +++ b/src/Mod/Surface/Gui/TaskFillingVertex.ui @@ -36,9 +36,6 @@ Add Vertex - - true - false @@ -55,9 +52,6 @@ Remove Vertex - - true - From fa50729aeb34e1f5a44ce74b2bf70552de95ef99 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 24 Apr 2017 19:18:58 +0200 Subject: [PATCH 12/12] reset highlighting of references if object is being deleted, fix crash with invalid sub-element names --- src/Mod/Surface/Gui/TaskFilling.cpp | 39 +++++++++++++++++---- src/Mod/Surface/Gui/TaskFilling.h | 2 ++ src/Mod/Surface/Gui/TaskFillingVertex.cpp | 10 ++++++ src/Mod/Surface/Gui/TaskFillingVertex.h | 2 ++ src/Mod/Surface/Gui/TaskGeomFillSurface.cpp | 12 ++++++- src/Mod/Surface/Gui/TaskGeomFillSurface.h | 2 ++ 6 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 48c2f4be93..7f7b82b26c 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -121,9 +121,11 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References& colors.resize(vMap.Extent(), svp->PointColor.getValue()); for (auto jt : it.second) { + // check again that the index is in range because it's possible that the + // sub-names are invalid std::size_t idx = static_cast(std::stoi(jt.substr(6)) - 1); - assert (idx < colors.size()); - colors[idx] = App::Color(1.0,0.0,1.0); // magenta + if (idx < colors.size()) + colors[idx] = App::Color(1.0,0.0,1.0); // magenta } svp->setHighlightedPoints(colors); @@ -141,8 +143,10 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References& for (auto jt : it.second) { std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); - assert (idx < colors.size()); - colors[idx] = App::Color(1.0,0.0,1.0); // magenta + // check again that the index is in range because it's possible that the + // sub-names are invalid + if (idx < colors.size()) + colors[idx] = App::Color(1.0,0.0,1.0); // magenta } svp->setHighlightedEdges(colors); @@ -160,8 +164,10 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References& for (auto jt : it.second) { std::size_t idx = static_cast(std::stoi(jt.substr(4)) - 1); - assert (idx < colors.size()); - colors[idx] = App::Color(1.0,0.0,1.0); // magenta + // check again that the index is in range because it's possible that the + // sub-names are invalid + if (idx < colors.size()) + colors[idx] = App::Color(1.0,0.0,1.0); // magenta } svp->setHighlightedFaces(colors); @@ -399,6 +405,22 @@ void FillingPanel::slotRedoDocument(const Gui::Document&) checkCommand = true; } +void FillingPanel::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) +{ + // If this view provider is being deleted then reset the colors of + // referenced part objects. The dialog will be deleted later. + if (this->vp == &Obj) { + this->vp->highlightReferences(ViewProviderFilling::Edge, + editedObject->BoundaryEdges.getSubListValues(), false); + + // unhighlight the referenced face + std::vector links; + links.push_back(std::make_pair(editedObject->InitialFace.getValue(), + editedObject->InitialFace.getSubValues())); + this->vp->highlightReferences(ViewProviderFilling::Face, links, false); + } +} + bool FillingPanel::accept() { selectionMode = None; @@ -716,6 +738,8 @@ void FillingPanel::onDeleteEdge() } this->vp->highlightReferences(ViewProviderFilling::Edge, editedObject->BoundaryEdges.getSubListValues(), true); + + editedObject->recomputeFeature(); } } @@ -760,6 +784,8 @@ void FillingPanel::on_buttonAccept_clicked() ui->comboBoxFaces->clear(); ui->comboBoxCont->clear(); ui->statusLabel->clear(); + + editedObject->recomputeFeature(); } void FillingPanel::on_buttonIgnore_clicked() @@ -818,6 +844,7 @@ void TaskFilling::setEditedObject(Surface::Filling* obj) void TaskFilling::open() { widget1->open(); + widget2->open(); } bool TaskFilling::accept() diff --git a/src/Mod/Surface/Gui/TaskFilling.h b/src/Mod/Surface/Gui/TaskFilling.h index a1e448334c..157c2172c5 100644 --- a/src/Mod/Surface/Gui/TaskFilling.h +++ b/src/Mod/Surface/Gui/TaskFilling.h @@ -87,6 +87,8 @@ protected: virtual void slotUndoDocument(const Gui::Document& Doc); /** Notifies on redo */ virtual void slotRedoDocument(const Gui::Document& Doc); + /** Notifies when the object is about to be removed. */ + virtual void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj); void modifyBoundary(bool); private Q_SLOTS: diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp index b9246d673c..b39d0fd334 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.cpp +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -220,6 +220,16 @@ void FillingVertexPanel::slotRedoDocument(const Gui::Document&) checkCommand = true; } +void FillingVertexPanel::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) +{ + // If this view provider is being deleted then reset the colors of + // referenced part objects. The dialog will be deleted later. + if (this->vp == &Obj) { + this->vp->highlightReferences(ViewProviderFilling::Vertex, + editedObject->Points.getSubListValues(), false); + } +} + void FillingVertexPanel::on_buttonVertexAdd_clicked() { // 'selectionMode' is passed by reference and changed when the filter is deleted diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.h b/src/Mod/Surface/Gui/TaskFillingVertex.h index a1a704fb07..7b67493425 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.h +++ b/src/Mod/Surface/Gui/TaskFillingVertex.h @@ -72,6 +72,8 @@ protected: virtual void slotUndoDocument(const Gui::Document& Doc); /** Notifies on redo */ virtual void slotRedoDocument(const Gui::Document& Doc); + /** Notifies when the object is about to be removed. */ + virtual void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj); private Q_SLOTS: void on_buttonVertexAdd_clicked(); diff --git a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp index 19ddc7037c..ae9ec5eb36 100644 --- a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp +++ b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp @@ -297,9 +297,17 @@ void GeomFillSurface::slotRedoDocument(const Gui::Document&) checkCommand = true; } +void GeomFillSurface::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) +{ + // If this view provider is being deleted then reset the colors of + // referenced part objects. The dialog will be deleted later. + if (this->vp == &Obj) { + this->vp->highlightReferences(false); + } +} + bool GeomFillSurface::accept() { - this->vp->highlightReferences(false); selectionMode = None; Gui::Selection().rmvSelectionGate(); @@ -325,6 +333,8 @@ bool GeomFillSurface::accept() return false; } + this->vp->highlightReferences(false); + Gui::Command::commitCommand(); Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); Gui::Command::updateActive(); diff --git a/src/Mod/Surface/Gui/TaskGeomFillSurface.h b/src/Mod/Surface/Gui/TaskGeomFillSurface.h index 8ba76034ec..1ed15fa287 100644 --- a/src/Mod/Surface/Gui/TaskGeomFillSurface.h +++ b/src/Mod/Surface/Gui/TaskGeomFillSurface.h @@ -82,6 +82,8 @@ protected: virtual void slotUndoDocument(const Gui::Document& Doc); /** Notifies on redo */ virtual void slotRedoDocument(const Gui::Document& Doc); + /** Notifies when the object is about to be removed. */ + virtual void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj); void changeFillType(GeomFill_FillingStyle); private Q_SLOTS: