diff --git a/src/Mod/TechDraw/App/CMakeLists.txt b/src/Mod/TechDraw/App/CMakeLists.txt index ef4f49a0c9..8a9d059160 100644 --- a/src/Mod/TechDraw/App/CMakeLists.txt +++ b/src/Mod/TechDraw/App/CMakeLists.txt @@ -42,6 +42,7 @@ generate_from_xml(DrawGeomHatchPy) generate_from_xml(DrawViewCollectionPy) generate_from_xml(DrawProjGroupPy) generate_from_xml(DrawProjGroupItemPy) +generate_from_xml(DrawViewAnnotationPy) SET(Draw_SRCS DrawPage.cpp @@ -143,7 +144,9 @@ SET(Python_SRCS DrawProjGroupPy.xml DrawProjGroupPyImp.cpp DrawProjGroupItemPy.xml - DrawProjGroupItemPyImp.cpp) + DrawProjGroupItemPyImp.cpp + DrawViewAnnotationPy.xml + DrawViewAnnotationPyImp.cpp) SOURCE_GROUP("Mod" FILES ${TechDraw_SRCS}) SOURCE_GROUP("Features" FILES ${Draw_SRCS}) diff --git a/src/Mod/TechDraw/App/DrawPage.cpp b/src/Mod/TechDraw/App/DrawPage.cpp index 861b8f54a1..df01a1ab79 100644 --- a/src/Mod/TechDraw/App/DrawPage.cpp +++ b/src/Mod/TechDraw/App/DrawPage.cpp @@ -318,28 +318,44 @@ void DrawPage::onDocumentRestored() bool autoUpdate = hGrp->GetBool("KeepPagesUpToDate", 1l); KeepUpdated.setValue(autoUpdate); - std::vector featViews = Views.getValues(); + std::vector featViews = getAllViews(); std::vector::const_iterator it = featViews.begin(); //first, make sure all the Parts have been executed so GeometryObjects exist for(; it != featViews.end(); ++it) { TechDraw::DrawViewPart *part = dynamic_cast(*it); if (part != nullptr && !part->hasGeometry()) { - part->touch(); + part->recomputeFeature(); } } //second, make sure all the Dimensions have been executed so Measurements have References for(it = featViews.begin(); it != featViews.end(); ++it) { TechDraw::DrawViewDimension *dim = dynamic_cast(*it); - if (dim != nullptr && - !dim->has2DReferences()) { - dim->touch(); + if (dim != nullptr) { + dim->recomputeFeature(); } } - recompute(); App::DocumentObject::onDocumentRestored(); } +std::vector DrawPage::getAllViews(void) +{ + auto views = Views.getValues(); //list of docObjects + std::vector allViews; + for (auto& v: views) { + if (v->isDerivedFrom(TechDraw::DrawProjGroup::getClassTypeId())) { + TechDraw::DrawProjGroup* dpg = static_cast(v); + if (dpg != nullptr) { //can't really happen! + std::vector pgViews = dpg->Views.getValues(); + allViews.insert(allViews.end(),pgViews.begin(),pgViews.end()); + } + } else { + allViews.push_back(v); + } + } + return allViews; +} + void DrawPage::unsetupObject() { nowUnsetting = true; diff --git a/src/Mod/TechDraw/App/DrawPage.h b/src/Mod/TechDraw/App/DrawPage.h index 60df838b83..ff695915ee 100644 --- a/src/Mod/TechDraw/App/DrawPage.h +++ b/src/Mod/TechDraw/App/DrawPage.h @@ -88,6 +88,7 @@ public: const char* getPageOrientation() const; bool isUnsetting(void) { return nowUnsetting; } void requestPaint(void); + std::vector getAllViews(void) ; protected: diff --git a/src/Mod/TechDraw/App/DrawPagePy.xml b/src/Mod/TechDraw/App/DrawPagePy.xml index 5357768f2f..8fda91c872 100644 --- a/src/Mod/TechDraw/App/DrawPagePy.xml +++ b/src/Mod/TechDraw/App/DrawPagePy.xml @@ -23,6 +23,11 @@ removeView(DrawView) - Remove a View to this Page + + + getAllViews() - returns a list of all the views on page including Views inside Collections + + Return the width of this page diff --git a/src/Mod/TechDraw/App/DrawPagePyImp.cpp b/src/Mod/TechDraw/App/DrawPagePyImp.cpp index 7a445e7778..bff965a33d 100644 --- a/src/Mod/TechDraw/App/DrawPagePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawPagePyImp.cpp @@ -6,9 +6,15 @@ #include "DrawPage.h" #include "DrawView.h" +#include "DrawViewPart.h" +#include "DrawProjGroup.h" +#include "DrawProjGroupItem.h" // inclusion of the generated files #include +#include +#include +#include #include #include @@ -70,6 +76,30 @@ PyObject* DrawPagePy::removeView(PyObject* args) #endif } +PyObject* DrawPagePy::getAllViews(PyObject* args) +{ + (void) args; + DrawPage* page = getDrawPagePtr(); + std::vector allViews = page->getAllViews(); + + PyObject* ret = PyList_New(0); + for (auto&v: allViews) { + if (v->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { + TechDraw::DrawProjGroupItem* dpgi = static_cast(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(v); + PyList_Append(ret,new TechDraw::DrawViewPartPy(dvp)); + } else if (v->isDerivedFrom(TechDraw::DrawViewAnnotation::getClassTypeId())) { + TechDraw::DrawViewAnnotation* dva = static_cast(v); + PyList_Append(ret,new TechDraw::DrawViewAnnotationPy(dva)); + } else { + TechDraw::DrawView* dv = static_cast(v); + PyList_Append(ret,new TechDraw::DrawViewPy(dv)); + } + } + return ret; +} // double getPageWidth() const; PyObject* DrawPagePy::getPageWidth(PyObject *) diff --git a/src/Mod/TechDraw/App/DrawViewAnnotationPy.xml b/src/Mod/TechDraw/App/DrawViewAnnotationPy.xml new file mode 100644 index 0000000000..82a92ea422 --- /dev/null +++ b/src/Mod/TechDraw/App/DrawViewAnnotationPy.xml @@ -0,0 +1,18 @@ + + + + + + Feature for creating and manipulating Technical Drawing Annotation Views + + + + diff --git a/src/Mod/TechDraw/App/DrawViewAnnotationPyImp.cpp b/src/Mod/TechDraw/App/DrawViewAnnotationPyImp.cpp new file mode 100644 index 0000000000..a559b6ee05 --- /dev/null +++ b/src/Mod/TechDraw/App/DrawViewAnnotationPyImp.cpp @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (c) 2018 WandererFan (wandererfan@gmail.com) * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" + +#ifndef _PreComp_ +# include +#endif + +#include +#include + +#include "DrawPage.h" +#include "DrawView.h" +#include "DrawViewAnnotation.h" + +// inclusion of the generated files +#include +#include +#include + +using namespace TechDraw; + +// returns a string which represents the object e.g. when printed in python +std::string DrawViewAnnotationPy::representation(void) const +{ + return std::string(""); +} + +PyObject *DrawViewAnnotationPy::getCustomAttributes(const char* ) const +{ + return 0; +} + +int DrawViewAnnotationPy::setCustomAttributes(const char* , PyObject *) +{ + return 0; +}