MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / unsetupObject

Method unsetupObject

src/Mod/TechDraw/App/DrawViewPart.cpp:1238–1294  ·  view source on GitHub ↗

remove features that are useless without this DVP hatches, geomhatches, dimensions, ...

Source from the content-addressed store, hash-verified

1236//! remove features that are useless without this DVP
1237//! hatches, geomhatches, dimensions, ...
1238void DrawViewPart::unsetupObject()
1239{
1240// Base::Console().message("DVP::unsetupObject()\n");
1241 nowUnsetting = true;
1242 App::Document* doc = getDocument();
1243 std::string docName = doc->getName();
1244
1245 // Remove the View's Hatches from document
1246 std::vector<TechDraw::DrawHatch*> hatches = getHatches();
1247 std::vector<TechDraw::DrawHatch*>::iterator it = hatches.begin();
1248 for (; it != hatches.end(); it++) {
1249 std::string viewName = (*it)->getNameInDocument();
1250 Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
1251 docName.c_str(), viewName.c_str());
1252 }
1253
1254 // Remove the View's GeomHatches from document
1255 std::vector<TechDraw::DrawGeomHatch*> gHatches = getGeomHatches();
1256 std::vector<TechDraw::DrawGeomHatch*>::iterator it2 = gHatches.begin();
1257 for (; it2 != gHatches.end(); it2++) {
1258 std::string viewName = (*it2)->getNameInDocument();
1259 Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
1260 docName.c_str(), viewName.c_str());
1261 }
1262
1263 // Remove Dimensions which reference this DVP
1264 // must use page->removeObject first
1265 TechDraw::DrawPage* page = findParentPage();
1266 if (page) {
1267 std::vector<TechDraw::DrawViewDimension*> dims = getDimensions();
1268 std::vector<TechDraw::DrawViewDimension*>::iterator it3 = dims.begin();
1269 for (; it3 != dims.end(); it3++) {
1270 page->removeView(*it3);
1271 const char* name = (*it3)->getNameInDocument();
1272 if (name) {
1273 Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
1274 docName.c_str(), name);
1275 }
1276 }
1277 }
1278
1279 // Remove Balloons which reference this DVP
1280 // must use page->removeObject first
1281 page = findParentPage();
1282 if (page) {
1283 std::vector<TechDraw::DrawViewBalloon*> balloons = getBalloons();
1284 std::vector<TechDraw::DrawViewBalloon*>::iterator it3 = balloons.begin();
1285 for (; it3 != balloons.end(); it3++) {
1286 page->removeView(*it3);
1287 const char* name = (*it3)->getNameInDocument();
1288 if (name) {
1289 Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
1290 docName.c_str(), name);
1291 }
1292 }
1293 }
1294}
1295

Callers

nothing calls this directly

Calls 8

runStringArgMethod · 0.80
getDocumentFunction · 0.70
getNameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
getNameInDocumentMethod · 0.45
c_strMethod · 0.45
removeViewMethod · 0.45

Tested by

no test coverage detected