Fix issue 53 Drawing templates
@@ -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)
|
||||
|
||||
@@ -130,13 +130,9 @@ void DrawSVGTemplate::onChanged(const App::Property* prop)
|
||||
execute();
|
||||
|
||||
// Update the parent page if exists
|
||||
std::vector<App::DocumentObject*> parent = getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = parent.begin(); it != parent.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) {
|
||||
TechDraw::DrawPage *page = static_cast<TechDraw::DrawPage *>(*it);
|
||||
page->touch();
|
||||
}
|
||||
}
|
||||
TechDraw::DrawPage *page = getParentPage();
|
||||
if (page)
|
||||
page->touch();
|
||||
}
|
||||
|
||||
TechDraw::DrawTemplate::onChanged(prop);
|
||||
|
||||
@@ -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<App::DocumentObject*> parent = getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = parent.begin(); it != parent.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(DrawPage::getClassTypeId())) {
|
||||
page = static_cast<TechDraw::DrawPage *>(*it);
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
// Python Template feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
|
||||
@@ -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 */
|
||||
//@{
|
||||
|
||||
@@ -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<Base::Vector3d> 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 ---------------------------------------------------------
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -19,7 +19,6 @@ INSTALL(
|
||||
Templates
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_DATADIR}/Mod/TechDraw
|
||||
FILES_MATCHING
|
||||
FILES_MATCHING
|
||||
PATTERN "*.svg*"
|
||||
PATTERN "*.dxf*"
|
||||
)
|
||||
|
||||
@@ -149,8 +149,8 @@ void CmdTechDrawNewPageDef::activated(int iMsg)
|
||||
Base::Reference<ParameterGrp> 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);
|
||||
|
||||
@@ -30,6 +30,7 @@ using namespace TechDrawGui;
|
||||
DlgTemplateField::DlgTemplateField( QWidget* parent )
|
||||
{
|
||||
setupUi(this);
|
||||
leInput->setFocus();
|
||||
}
|
||||
|
||||
DlgTemplateField::~DlgTemplateField()
|
||||
|
||||
@@ -80,7 +80,7 @@ std::vector<std::string> 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
|
||||
|
||||
95
src/Mod/TechDraw/Templates/A0_Landscape_ISO7200TD.svg
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
95
src/Mod/TechDraw/Templates/A1_Landscape_ISO7200TD.svg
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
95
src/Mod/TechDraw/Templates/A2_Landscape_ISO7200TD.svg
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
95
src/Mod/TechDraw/Templates/A3_Landscape_ISO7200TD.svg
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
1679
src/Mod/TechDraw/Templates/A4_LandscapeTD.svg
Normal file
|
After Width: | Height: | Size: 75 KiB |
90
src/Mod/TechDraw/Templates/A4_Landscape_ISO7200TD.svg
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
94
src/Mod/TechDraw/Templates/A4_Portrait_ISO7200TD.svg
Normal file
|
After Width: | Height: | Size: 4.6 KiB |