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

Method dropObject

src/Mod/TechDraw/Gui/ViewProviderPageExtension.cpp:124–196  ·  view source on GitHub ↗

this code used to live in ViewProviderPage

Source from the content-addressed store, hash-verified

122
123//this code used to live in ViewProviderPage
124void ViewProviderPageExtension::dropObject(App::DocumentObject* obj)
125{
126 auto dvp = freecad_cast<TechDraw::DrawViewPart*>(obj);
127 if (dvp && DrawView::isProjGroupItem(dvp)) {
128 //DPGI can not be dropped onto the Page if it belongs to DPG
129 auto* dpgi = static_cast<TechDraw::DrawProjGroupItem*>(obj);
130 if (dpgi->getPGroup()) {
131 return;
132 }
133 }
134 if (obj->isDerivedFrom<App::Link>()) {
135 auto* link = static_cast<App::Link*>(obj);
136 obj = link->getLinkedObject();
137 if (!obj->isDerivedFrom<TechDraw::DrawView>()) {
138 return;
139 }
140
141 std::vector<App::DocumentObject*> deps;
142 for (auto& inObj : obj->getInList()) {
143 if (inObj && inObj->isDerivedFrom<TechDraw::DrawView>()) {
144 deps.push_back(inObj);
145 }
146 }
147
148 TechDraw::DrawPage* page = nullptr;
149 for (auto& inObj : link->getInList()) {
150 if (inObj->isDerivedFrom<TechDraw::DrawPage>()) {
151 page = static_cast<TechDraw::DrawPage*>(inObj);
152 }
153 }
154 if (page) {
155 for (auto* dep : deps) {
156 page->removeView(dep);
157 }
158 page->removeView(link);
159 }
160
161 getViewProviderPage()->getDrawPage()->addView(link, false);
162 for (auto* dep : deps) {
163 getViewProviderPage()->getDrawPage()->addView(dep, false);
164 }
165
166 return;
167 }
168
169 if (obj->isDerivedFrom<TechDraw::DrawView>()) {
170 auto dv = static_cast<TechDraw::DrawView*>(obj);
171
172 std::vector<App::DocumentObject*> deps;
173 for (auto* dep : dv->getInList()) {
174 if (dep && dep->isDerivedFrom<TechDraw::DrawView>()) {
175 deps.push_back(dep);
176 }
177 }
178
179 auto* parentPage = dv->findParentPage();
180 if (parentPage) {
181 for (auto* dep : deps) {

Callers

nothing calls this directly

Calls 9

getViewProviderPageFunction · 0.85
getPGroupMethod · 0.80
getLinkedObjectMethod · 0.45
getInListMethod · 0.45
push_backMethod · 0.45
removeViewMethod · 0.45
addViewMethod · 0.45
getDrawPageMethod · 0.45
findParentPageMethod · 0.45

Tested by

no test coverage detected