//this is time consuming. should only be used when there is a problem. //should have been called MDIViewPage::fixWidowAndOrphans() //void MDIViewPage::updateDrawing(bool forceUpdate) void MDIViewPage::updateDrawing(void) { // get all the DrawViews for this page, including the second level ones // if we ever have collections of collections, we'll need to revisit this DrawPage* thisPage = m_vpPage->getDrawPage(); std::vector<App::DocumentObject*> pChildren = thisPage->getAllViews(); // if dv doesn't have a graphic, make one for (auto& dv: pChildren) { if (dv->isRemoving()) { continue; } QGIView* qv = m_view->findQViewForDocObj(dv); if (qv == nullptr) { attachView(dv); } } // if qView doesn't have a Feature on this Page, delete it std::vector<QGIView*> qvs = m_view->getViews(); App::Document* doc = getAppDocument(); for (auto& qv: qvs) { App::DocumentObject* obj = doc->getObject(qv->getViewName()); if (obj == nullptr) { m_view->removeQView(qv); } else { DrawPage* pp = qv->getViewObject()->findParentPage(); if (thisPage != pp) { m_view->removeQView(qv); } } } // Update all the QGIVxxxx // WF: why do we do this? views should be keeping themselves up to date. // const std::vector<QGIView *> &upviews = m_view->getViews(); // for(std::vector<QGIView *>::const_iterator it = upviews.begin(); it != upviews.end(); ++it) { // Base::Console().Message("TRACE - MDIVP::updateDrawing - updating a QGIVxxxx\n"); // if((*it)->getViewObject()->isTouched() || // forceUpdate) { // (*it)->updateView(forceUpdate); // } // } }
PyObject* DrawPagePy::removeView(PyObject* args) { //this implements iRC = pyPage.removeView(pyView) -or- //doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); PyObject *pcDocObj; if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) { PyErr_SetString(PyExc_TypeError, "DrawPagePy::removeView - Bad Arg - not DocumentObject"); return nullptr; } DrawPage* page = getDrawPagePtr(); //get DrawPage for pyPage //how to validate that obj is DrawView before use?? DrawViewPy* pyView = static_cast<TechDraw::DrawViewPy*>(pcDocObj); DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView int rc = page->removeView(view); return PyInt_FromLong((long) rc); }
PyObject* DrawPagePy::getAllViews(PyObject* args) { (void) args; DrawPage* page = getDrawPagePtr(); std::vector<App::DocumentObject*> allViews = page->getAllViews(); PyObject* ret = PyList_New(0); for (auto&v: allViews) { if (v->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { TechDraw::DrawProjGroupItem* dpgi = static_cast<TechDraw::DrawProjGroupItem*>(v); PyList_Append(ret,new TechDraw::DrawProjGroupItemPy(dpgi)); //is this legit? or need to make new copy of dv? } else if (v->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(v); PyList_Append(ret,new TechDraw::DrawViewPartPy(dvp)); } else if (v->isDerivedFrom(TechDraw::DrawViewAnnotation::getClassTypeId())) { TechDraw::DrawViewAnnotation* dva = static_cast<TechDraw::DrawViewAnnotation*>(v); PyList_Append(ret,new TechDraw::DrawViewAnnotationPy(dva)); } else { TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v); PyList_Append(ret,new TechDraw::DrawViewPy(dv)); } } return ret; }
PyObject* DrawPagePy::addView(PyObject* args) { //this implements iRC = pyPage.addView(pyView) -or- //doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); PyObject *pcDocObj; if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) { Base::Console().Error("Error: DrawPagePy::addView - Bad Arg - not DocumentObject\n"); return NULL; //TODO: sb PyErr?? //PyErr_SetString(PyExc_TypeError,"addView expects a DrawView"); //return -1; } DrawPage* page = getDrawPagePtr(); //get DrawPage for pyPage //TODO: argument 1 arrives as "DocumentObjectPy", not "DrawViewPy" //how to validate that obj is DrawView before use?? DrawViewPy* pyView = static_cast<TechDraw::DrawViewPy*>(pcDocObj); DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView int rc = page->addView(view); return PyInt_FromLong((long) rc); }