Skip to content

Commit

Permalink
reset highlighting of references if object is being deleted, fix cras…
Browse files Browse the repository at this point in the history
…h with invalid sub-element names
  • Loading branch information
wwmayer committed Apr 24, 2017
1 parent 2cfb029 commit fa50729
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 7 deletions.
39 changes: 33 additions & 6 deletions src/Mod/Surface/Gui/TaskFilling.cpp
Expand Up @@ -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::size_t>(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);
Expand All @@ -141,8 +143,10 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References&

for (auto jt : it.second) {
std::size_t idx = static_cast<std::size_t>(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);
Expand All @@ -160,8 +164,10 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References&

for (auto jt : it.second) {
std::size_t idx = static_cast<std::size_t>(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);
Expand Down Expand Up @@ -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<App::PropertyLinkSubList::SubSet> 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;
Expand Down Expand Up @@ -716,6 +738,8 @@ void FillingPanel::onDeleteEdge()
}
this->vp->highlightReferences(ViewProviderFilling::Edge,
editedObject->BoundaryEdges.getSubListValues(), true);

editedObject->recomputeFeature();
}
}

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -818,6 +844,7 @@ void TaskFilling::setEditedObject(Surface::Filling* obj)
void TaskFilling::open()
{
widget1->open();
widget2->open();
}

bool TaskFilling::accept()
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Surface/Gui/TaskFilling.h
Expand Up @@ -87,6 +87,8 @@ class FillingPanel : public QWidget,
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:
Expand Down
10 changes: 10 additions & 0 deletions src/Mod/Surface/Gui/TaskFillingVertex.cpp
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Surface/Gui/TaskFillingVertex.h
Expand Up @@ -72,6 +72,8 @@ class FillingVertexPanel : public QWidget,
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();
Expand Down
12 changes: 11 additions & 1 deletion src/Mod/Surface/Gui/TaskGeomFillSurface.cpp
Expand Up @@ -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();

Expand All @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Surface/Gui/TaskGeomFillSurface.h
Expand Up @@ -82,6 +82,8 @@ class GeomFillSurface : public QWidget,
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:
Expand Down

0 comments on commit fa50729

Please sign in to comment.