Skip to content

Commit

Permalink
[TD]remove Hatches from Display when deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Mar 11, 2020
1 parent b7146a5 commit 0ab6ba7
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/Mod/TechDraw/App/DrawGeomHatch.cpp
Expand Up @@ -596,6 +596,7 @@ void DrawGeomHatch::setupPatIncluded(void)
}
}

//TODO: replace with FileInfo copy
//copy whole text file from inSpec to outSpec
void DrawGeomHatch::copyFile(std::string inSpec, std::string outSpec)
{
Expand All @@ -609,6 +610,18 @@ void DrawGeomHatch::copyFile(std::string inSpec, std::string outSpec)
}
}

void DrawGeomHatch::unsetupObject(void)
{
// Base::Console().Message("DGH::unsetupObject() - status: %lu removing: %d \n", getStatus(), isRemoving());
App::DocumentObject* source = Source.getValue();
DrawView* dv = dynamic_cast<DrawView*>(source);
if (dv != nullptr) {
dv->requestPaint();
}
App::DocumentObject::unsetupObject();
}



// Python Drawing feature ---------------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions src/Mod/TechDraw/App/DrawGeomHatch.h
Expand Up @@ -65,6 +65,8 @@ class TechDrawExport DrawGeomHatch : public App::DocumentObject
return "TechDrawGui::ViewProviderGeomHatch";
}
virtual PyObject *getPyObject(void) override;
virtual void unsetupObject(void) override;


DrawViewPart* getSourceView(void) const;

Expand Down
11 changes: 11 additions & 0 deletions src/Mod/TechDraw/App/DrawHatch.cpp
Expand Up @@ -280,6 +280,17 @@ void DrawHatch::copyFile(std::string inSpec, std::string outSpec)
}
}

void DrawHatch::unsetupObject(void)
{
// Base::Console().Message("DH::unsetupObject() - status: %lu removing: %d \n", getStatus(), isRemoving());
App::DocumentObject* source = Source.getValue();
DrawView* dv = dynamic_cast<DrawView*>(source);
if (dv != nullptr) {
dv->requestPaint();
}
App::DocumentObject::unsetupObject();
}


// Python Drawing feature ---------------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions src/Mod/TechDraw/App/DrawHatch.h
Expand Up @@ -50,6 +50,8 @@ class TechDrawExport DrawHatch : public App::DocumentObject
virtual const char* getViewProviderName(void) const override {
return "TechDrawGui::ViewProviderHatch";
}
virtual void unsetupObject(void) override;

//return PyObject as DrawHatchPy
virtual PyObject *getPyObject(void) override;

Expand Down
6 changes: 4 additions & 2 deletions src/Mod/TechDraw/App/DrawViewPart.cpp
Expand Up @@ -620,7 +620,8 @@ std::vector<TechDraw::DrawHatch*> DrawViewPart::getHatches() const
std::vector<TechDraw::DrawHatch*> result;
std::vector<App::DocumentObject*> children = getInList();
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != children.end(); ++it) {
if ((*it)->getTypeId().isDerivedFrom(DrawHatch::getClassTypeId())) {
if ( ((*it)->getTypeId().isDerivedFrom(DrawHatch::getClassTypeId())) &&
(!(*it)->isRemoving()) ) {
TechDraw::DrawHatch* hatch = dynamic_cast<TechDraw::DrawHatch*>(*it);
result.push_back(hatch);
}
Expand All @@ -633,7 +634,8 @@ std::vector<TechDraw::DrawGeomHatch*> DrawViewPart::getGeomHatches() const
std::vector<TechDraw::DrawGeomHatch*> result;
std::vector<App::DocumentObject*> children = getInList();
for (std::vector<App::DocumentObject*>::iterator it = children.begin(); it != children.end(); ++it) {
if ((*it)->getTypeId().isDerivedFrom(DrawGeomHatch::getClassTypeId())) {
if ( ((*it)->getTypeId().isDerivedFrom(DrawGeomHatch::getClassTypeId())) &&
(!(*it)->isRemoving()) ) {
TechDraw::DrawGeomHatch* geom = dynamic_cast<TechDraw::DrawGeomHatch*>(*it);
result.push_back(geom);
}
Expand Down

0 comments on commit 0ab6ba7

Please sign in to comment.