diff --git a/src/Mod/TechDraw/App/CMakeLists.txt b/src/Mod/TechDraw/App/CMakeLists.txt index 603632330..366cd9f72 100644 --- a/src/Mod/TechDraw/App/CMakeLists.txt +++ b/src/Mod/TechDraw/App/CMakeLists.txt @@ -127,6 +127,15 @@ SOURCE_GROUP("Features" FILES ${Draw_SRCS}) SOURCE_GROUP("Geometry" FILES ${Geometry_SRCS}) SOURCE_GROUP("Python" FILES ${Python_SRCS}) +SET(TechDraw_Templates + Templates/A0_Landscape_ISO7200TD.svg + Templates/A1_Landscape_ISO7200TD.svg + Templates/A2_Landscape_ISO7200TD.svg + Templates/A3_Landscape_ISO7200TD.svg + Templates/A4_LandscapeTD.svg + Templates/A4_Landscape_ISO7200TD.svg + Templates/A4_Portrait_ISO7200TD.svg +) if(MSVC) #add_definitions(-D_PreComp_) @@ -150,7 +159,7 @@ fc_target_copy_resource(TechDraw fc_target_copy_resource(TechDraw ${CMAKE_SOURCE_DIR}/src/Mod/TechDraw ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw - ${TechDrawTemplates}) + ${TechDraw_Templates}) SET_BIN_DIR(TechDraw TechDraw /Mod/TechDraw) SET_PYTHON_PREFIX_SUFFIX(TechDraw) diff --git a/src/Mod/TechDraw/App/DrawSVGTemplate.cpp b/src/Mod/TechDraw/App/DrawSVGTemplate.cpp index 8d986b518..2984697b0 100644 --- a/src/Mod/TechDraw/App/DrawSVGTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawSVGTemplate.cpp @@ -130,13 +130,9 @@ void DrawSVGTemplate::onChanged(const App::Property* prop) execute(); // Update the parent page if exists - std::vector parent = getInList(); - for (std::vector::iterator it = parent.begin(); it != parent.end(); ++it) { - if ((*it)->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) { - TechDraw::DrawPage *page = static_cast(*it); - page->touch(); - } - } + TechDraw::DrawPage *page = getParentPage(); + if (page) + page->touch(); } TechDraw::DrawTemplate::onChanged(prop); diff --git a/src/Mod/TechDraw/App/DrawTemplate.cpp b/src/Mod/TechDraw/App/DrawTemplate.cpp index 13f19353c..745369072 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawTemplate.cpp @@ -131,6 +131,18 @@ void DrawTemplate::getBlockDimensions(double &x, double &y, double &width, doubl throw Base::Exception("implement in virtual function"); } +DrawPage* DrawTemplate::getParentPage() const +{ + TechDraw::DrawPage* page = nullptr; + std::vector parent = getInList(); + for (std::vector::iterator it = parent.begin(); it != parent.end(); ++it) { + if ((*it)->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) { + page = static_cast(*it); + } + } + return page; +} + // Python Template feature --------------------------------------------------------- namespace App { diff --git a/src/Mod/TechDraw/App/DrawTemplate.h b/src/Mod/TechDraw/App/DrawTemplate.h index 1ee6b944c..98effc287 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.h +++ b/src/Mod/TechDraw/App/DrawTemplate.h @@ -38,6 +38,8 @@ namespace TechDrawGeometry namespace TechDraw { +class DrawPage; + class TechDrawExport DrawTemplate : public App::DocumentObject { PROPERTY_HEADER(TechDraw::DrawTemplate); @@ -62,6 +64,7 @@ public: virtual double getHeight() const; virtual void getBlockDimensions(double &x, double &y, double &width, double &height) const; + virtual DrawPage* getParentPage() const; /** @name methods overide Feature */ //@{ diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 2e101d615..073a6f81f 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -149,12 +149,15 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) Base::Vector3d plnPnt(tmp1.x, tmp1.y, tmp1.z); Base::Vector3d plnNorm(tmp2.x, tmp2.y, tmp2.z); - if(!bb.IsCutPlane(plnPnt, plnNorm)) { - return new App::DocumentObjectExecReturn("Section Plane doesn't intersect part"); +// if(!bb.IsCutPlane(plnPnt, plnNorm)) { //this test doesn't work if plane is coincident with bb! + if(!isReallyInBox(plnPnt, bb)) { + Base::Console().Warning("DVS: Section Plane doesn't intersect part in %s\n",getNameInDocument()); + Base::Console().Warning("DVS: Using center of bounding box.\n"); + plnPnt = bb.GetCenter(); + SectionOrigin.setValue(plnPnt); + //return new App::DocumentObjectExecReturn("Section Plane doesn't intersect part"); } - //bb.Enlarge(1.0); // Enlarge the bounding box to prevent any clipping - // Gather the points std::vector pnts; @@ -244,8 +247,8 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) } catch (Standard_Failure) { Handle_Standard_Failure e1 = Standard_Failure::Caught(); - Base::Console().Log("DrawViewSection::execute - building Section shape failed: %s\n",e1->GetMessageString()); - return new App::DocumentObjectExecReturn(e1->GetMessageString()); + return new App::DocumentObjectExecReturn(std::string("DVS building Section shape failed: ") + + std::string(e1->GetMessageString())); } touch(); @@ -384,6 +387,18 @@ TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face, return projectedFace; } +//this should really be in BoundBox.h +bool DrawViewSection::isReallyInBox (const Base::Vector3d v, const Base::BoundBox3d bb) const +{ + if (v.x <= bb.MinX || v.x >= bb.MaxX) + return false; + if (v.y <= bb.MinY || v.y >= bb.MaxY) + return false; + if (v.z <= bb.MinZ || v.z >= bb.MaxZ) + return false; + return true; +} + // Python Drawing feature --------------------------------------------------------- diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 4bd8967fa..a872db47f 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -56,7 +56,7 @@ public: App::PropertyBool ShowCutSurface; short mustExecute() const; - + bool isReallyInBox (const Base::Vector3d v, const Base::BoundBox3d bb) const; /** @name methods overide Feature */ //@{ /// recalculate the Feature diff --git a/src/Mod/TechDraw/CMakeLists.txt b/src/Mod/TechDraw/CMakeLists.txt index a588a4ccf..ebe8e7f47 100644 --- a/src/Mod/TechDraw/CMakeLists.txt +++ b/src/Mod/TechDraw/CMakeLists.txt @@ -19,7 +19,6 @@ INSTALL( Templates DESTINATION ${CMAKE_INSTALL_DATADIR}/Mod/TechDraw - FILES_MATCHING + FILES_MATCHING PATTERN "*.svg*" - PATTERN "*.dxf*" ) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 5c1433d09..2eefda2b5 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -149,8 +149,8 @@ void CmdTechDrawNewPageDef::activated(int iMsg) Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw"); - std::string defaultDir = App::Application::getResourceDir() + "Mod/Drawing/Templates"; - std::string defaultFileName = defaultDir + "A4_Landscape.svg"; + std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Templates/"; + std::string defaultFileName = defaultDir + "A4_LandscapeTD.svg"; QString templateFileName = QString::fromStdString(hGrp->GetASCII("TemplateFile",defaultFileName.c_str())); if (templateFileName.isEmpty()) { templateFileName = QString::fromStdString(defaultFileName); diff --git a/src/Mod/TechDraw/Gui/DlgTemplateField.cpp b/src/Mod/TechDraw/Gui/DlgTemplateField.cpp index e8c37e470..4e046d0b1 100644 --- a/src/Mod/TechDraw/Gui/DlgTemplateField.cpp +++ b/src/Mod/TechDraw/Gui/DlgTemplateField.cpp @@ -30,6 +30,7 @@ using namespace TechDrawGui; DlgTemplateField::DlgTemplateField( QWidget* parent ) { setupUi(this); + leInput->setFocus(); } DlgTemplateField::~DlgTemplateField() diff --git a/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp b/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp index 424b5cf42..473991ea1 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp @@ -80,7 +80,7 @@ std::vector ViewProviderTemplate::getDisplayModes(void) const void ViewProviderTemplate::updateData(const App::Property* prop) { - Base::Console().Log("ViewProviderTemplate::updateData(%s)",prop->getName()); + //Base::Console().Log("ViewProviderTemplate::updateData(%s)/n",prop->getName()); } TechDraw::DrawTemplate* ViewProviderTemplate::getTemplate() const diff --git a/src/Mod/TechDraw/Templates/A0_Landscape_ISO7200TD.svg b/src/Mod/TechDraw/Templates/A0_Landscape_ISO7200TD.svg new file mode 100644 index 000000000..209570305 --- /dev/null +++ b/src/Mod/TechDraw/Templates/A0_Landscape_ISO7200TD.svg @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + Created by: + Title: + Supplementary information: + Size: + Sheet: + Scale: + Part number: + Drawing number: + Date: + Revision: + + + + + + + AUTHOR NAME + DRAWING TITLE + + + FreeCAD DRAWING + + + + A0 + X / Y + SCALE + PN + DN + DD/MM/YYYY + REV A + + + + diff --git a/src/Mod/TechDraw/Templates/A1_Landscape_ISO7200TD.svg b/src/Mod/TechDraw/Templates/A1_Landscape_ISO7200TD.svg new file mode 100644 index 000000000..1b89b935a --- /dev/null +++ b/src/Mod/TechDraw/Templates/A1_Landscape_ISO7200TD.svg @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + Created by: + Title: + Supplementary information: + Size: + Sheet: + Scale: + Part number: + Drawing number: + Date: + Revision: + + + + + + + AUTHOR NAME + DRAWING TITLE + + + FreeCAD DRAWING + + + + A1 + X / Y + SCALE + PN + DN + DD/MM/YYYY + REV A + + + + diff --git a/src/Mod/TechDraw/Templates/A2_Landscape_ISO7200TD.svg b/src/Mod/TechDraw/Templates/A2_Landscape_ISO7200TD.svg new file mode 100644 index 000000000..051f21b89 --- /dev/null +++ b/src/Mod/TechDraw/Templates/A2_Landscape_ISO7200TD.svg @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + Created by: + Title: + Supplementary information: + Size: + Sheet: + Scale: + Part number: + Drawing number: + Date: + Revision: + + + + + + transform="translate(384,123)"> + + AUTHOR NAME + DRAWING TITLE + + + FreeCAD DRAWING + + + + A2 + X / Y + SCALE + PN + DN + DD/MM/YYYY + REV A + + + diff --git a/src/Mod/TechDraw/Templates/A3_Landscape_ISO7200TD.svg b/src/Mod/TechDraw/Templates/A3_Landscape_ISO7200TD.svg new file mode 100644 index 000000000..ffa63a91f --- /dev/null +++ b/src/Mod/TechDraw/Templates/A3_Landscape_ISO7200TD.svg @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + Created by: + Title: + Supplementary information: + Size: + Sheet: + Scale: + Part number: + Drawing number: + Date: + Revision: + + + + + + + + AUTHOR NAME + DRAWING TITLE + + + FreeCAD DRAWING + + + + A3 + X / Y + SCALE + PN + DN + DD/MM/YYYY + REV A + + + diff --git a/src/Mod/TechDraw/Templates/A4_LandscapeTD.svg b/src/Mod/TechDraw/Templates/A4_LandscapeTD.svg new file mode 100644 index 000000000..33eaff6ef --- /dev/null +++ b/src/Mod/TechDraw/Templates/A4_LandscapeTD.svg @@ -0,0 +1,1679 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This drawing is our property; it can't be reproduced or communicated without our written consent. + A4 + + + + + + + + + Designed by Name + Date + Scale + Weight + Title + Subtitle + Drawing number + Sheet + + diff --git a/src/Mod/TechDraw/Templates/A4_Landscape_ISO7200TD.svg b/src/Mod/TechDraw/Templates/A4_Landscape_ISO7200TD.svg new file mode 100644 index 000000000..d599f2613 --- /dev/null +++ b/src/Mod/TechDraw/Templates/A4_Landscape_ISO7200TD.svg @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + Created by: + Title: + Supplementary information: + Size: + Sheet: + Scale: + Part number: + Drawing no.: + Date: + Revision: + + + + + + + AUTHOR NAME + DRAWING TITLE + + FreeCAD DRAWING + + A4 + X / Y + SCALE + PN + DN + DD/MM/YYYY + REV A + + + diff --git a/src/Mod/TechDraw/Templates/A4_Portrait_ISO7200TD.svg b/src/Mod/TechDraw/Templates/A4_Portrait_ISO7200TD.svg new file mode 100644 index 000000000..e7669d6bf --- /dev/null +++ b/src/Mod/TechDraw/Templates/A4_Portrait_ISO7200TD.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + Created by: + Title: + Supplementary information: + Size: + Sheet: + Scale: + Part number: + Drawing number: + Date: + Revision: + + + AUTHOR NAME + DRAWING TITLE + + + FreeCAD DRAWING + + + + A4 + X / Y + SCALE + PN + DN + DD/MM/YYYY + REV A + + + + + + +