[TD]Welding Symbol creation
This commit is contained in:
@@ -42,6 +42,9 @@
|
||||
#include "DrawViewBalloon.h"
|
||||
#include "DrawLeaderLine.h"
|
||||
#include "DrawRichAnno.h"
|
||||
#include "DrawTile.h"
|
||||
#include "DrawTileWeld.h"
|
||||
#include "DrawWeldSymbol.h"
|
||||
#include "Cosmetic.h"
|
||||
#include "PropertyGeomFormatList.h"
|
||||
#include "PropertyCenterLineList.h"
|
||||
@@ -100,6 +103,9 @@ PyMOD_INIT_FUNC(TechDraw)
|
||||
TechDraw::DrawViewDraft ::init();
|
||||
TechDraw::DrawViewArch ::init();
|
||||
TechDraw::DrawViewImage ::init();
|
||||
TechDraw::DrawTile ::init();
|
||||
TechDraw::DrawTileWeld ::init();
|
||||
TechDraw::DrawWeldSymbol ::init();
|
||||
|
||||
TechDraw::PropertyGeomFormatList::init();
|
||||
TechDraw::GeomFormat ::init();
|
||||
@@ -119,5 +125,8 @@ PyMOD_INIT_FUNC(TechDraw)
|
||||
TechDraw::DrawViewSymbolPython::init();
|
||||
TechDraw::DrawLeaderLinePython::init();
|
||||
TechDraw::DrawRichAnnoPython ::init();
|
||||
TechDraw::DrawTilePython ::init();
|
||||
TechDraw::DrawTileWeldPython ::init();
|
||||
TechDraw::DrawWeldSymbolPython::init();
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ generate_from_xml(GeomFormatPy)
|
||||
generate_from_xml(CenterLinePy)
|
||||
generate_from_xml(CosmeticEdgePy)
|
||||
generate_from_xml(CosmeticVertexPy)
|
||||
generate_from_xml(DrawTilePy)
|
||||
generate_from_xml(DrawTileWeldPy)
|
||||
generate_from_xml(DrawWeldSymbolPy)
|
||||
|
||||
SET(Draw_SRCS
|
||||
DrawPage.cpp
|
||||
@@ -117,6 +120,12 @@ SET(Draw_SRCS
|
||||
DrawRichAnno.h
|
||||
QDomNodeModel.cpp
|
||||
QDomNodeModel.h
|
||||
DrawTile.cpp
|
||||
DrawTile.h
|
||||
DrawTileWeld.cpp
|
||||
DrawTileWeld.h
|
||||
DrawWeldSymbol.cpp
|
||||
DrawWeldSymbol.h
|
||||
)
|
||||
|
||||
SET(TechDraw_SRCS
|
||||
@@ -196,6 +205,12 @@ SET(Python_SRCS
|
||||
CosmeticEdgePyImp.cpp
|
||||
CosmeticVertexPy.xml
|
||||
CosmeticVertexPyImp.cpp
|
||||
DrawTilePy.xml
|
||||
DrawTilePyImp.cpp
|
||||
DrawTileWeldPy.xml
|
||||
DrawTileWeldPyImp.cpp
|
||||
DrawWeldSymbolPy.xml
|
||||
DrawWeldSymbolPyImp.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP("Mod" FILES ${TechDraw_SRCS})
|
||||
@@ -225,6 +240,13 @@ ADD_CUSTOM_COMMAND(TARGET TechDraw
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/src/Mod/TechDraw/Templates
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw/Templates
|
||||
)
|
||||
|
||||
ADD_CUSTOM_COMMAND(TARGET TechDraw
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory
|
||||
${CMAKE_SOURCE_DIR}/src/Mod/TechDraw/Symbols
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw/Symbols
|
||||
)
|
||||
|
||||
SET_BIN_DIR(TechDraw TechDraw /Mod/TechDraw)
|
||||
|
||||
@@ -187,6 +187,52 @@ void DrawLeaderLine::adjustLastSegment(void)
|
||||
WayPoints.setValues(wp);
|
||||
}
|
||||
|
||||
//middle of last line segment
|
||||
Base::Vector3d DrawLeaderLine::getTileOrigin(void) const
|
||||
{
|
||||
Base::Vector3d result;
|
||||
std::vector<Base::Vector3d> wp = WayPoints.getValues();
|
||||
if (wp.size() > 1) {
|
||||
Base::Vector3d last = wp.rbegin()[0];
|
||||
Base::Vector3d second = wp.rbegin()[1];
|
||||
result = (last + second) / 2.0;
|
||||
} else {
|
||||
Base::Console().Warning("DLL::getTileOrigin - no waypoints\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//start of last line segment
|
||||
Base::Vector3d DrawLeaderLine::getKinkPoint(void) const
|
||||
{
|
||||
Base::Vector3d result;
|
||||
std::vector<Base::Vector3d> wp = WayPoints.getValues();
|
||||
if (wp.size() > 1) {
|
||||
Base::Vector3d second = wp.rbegin()[1];
|
||||
result = second;
|
||||
} else {
|
||||
Base::Console().Warning("DLL::getKinkPoint - no waypoints\n");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//end of last line segment
|
||||
Base::Vector3d DrawLeaderLine::getTailPoint(void) const
|
||||
{
|
||||
Base::Vector3d result;
|
||||
std::vector<Base::Vector3d> wp = WayPoints.getValues();
|
||||
if (!wp.empty()) {
|
||||
Base::Vector3d last = wp.rbegin()[0];
|
||||
result = last;
|
||||
} else {
|
||||
Base::Console().Warning("DLL::getTailPoint - no waypoints\n");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
bool DrawLeaderLine::getDefAuto(void) const
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
|
||||
@@ -66,6 +66,10 @@ public:
|
||||
void adjustLastSegment(void);
|
||||
bool getDefAuto(void) const;
|
||||
|
||||
Base::Vector3d getTileOrigin(void) const;
|
||||
Base::Vector3d getKinkPoint(void) const;
|
||||
Base::Vector3d getTailPoint(void) const;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop) override;
|
||||
|
||||
118
src/Mod/TechDraw/App/DrawTile.cpp
Normal file
118
src/Mod/TechDraw/App/DrawTile.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Wanderer Fan <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_
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
|
||||
#include <Mod/TechDraw/App/DrawTilePy.h> // generated from DrawTilePy.xml
|
||||
#include "DrawTile.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
//===========================================================================
|
||||
// DrawTile - attachable tile
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(TechDraw::DrawTile, App::DocumentObject)
|
||||
|
||||
DrawTile::DrawTile(void)
|
||||
{
|
||||
static const char *group = "Tile";
|
||||
|
||||
Base::Vector3d defOrg(0.0, 0.0, 0.0);
|
||||
ADD_PROPERTY_TYPE(TileParent,(0),group,(App::PropertyType)(App::Prop_None),
|
||||
"Object to which this tile is attached");
|
||||
ADD_PROPERTY_TYPE(TileRow, (0), group, App::Prop_None, "Row in parent");
|
||||
ADD_PROPERTY_TYPE(TileColumn, (0), group, App::Prop_None, "Column in parent");
|
||||
ADD_PROPERTY_TYPE(TileOrigin, (defOrg), group, App::Prop_None, "Width limit before auto wrap");
|
||||
}
|
||||
|
||||
DrawTile::~DrawTile()
|
||||
{
|
||||
}
|
||||
|
||||
void DrawTile::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
//nothing in particular
|
||||
}
|
||||
DocumentObject::onChanged(prop);
|
||||
|
||||
}
|
||||
|
||||
short DrawTile::mustExecute() const
|
||||
{
|
||||
return DocumentObject::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawTile::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DT::execute()\n");
|
||||
return DocumentObject::execute();
|
||||
}
|
||||
|
||||
DrawView* DrawTile::getParent(void) const
|
||||
{
|
||||
Base::Console().Message("DT::getParent() - %s\n", getNameInDocument());
|
||||
DrawView* result = nullptr;
|
||||
App::DocumentObject* baseObj = TileParent.getValue();
|
||||
if (baseObj != nullptr) {
|
||||
DrawView* cast = dynamic_cast<DrawView*>(baseObj);
|
||||
if (cast != nullptr) {
|
||||
result = cast;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject *DrawTile::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawTilePy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawTilePython, TechDraw::DrawTile)
|
||||
template<> const char* TechDraw::DrawTilePython::getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderTile";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class TechDrawExport FeaturePythonT<TechDraw::DrawTile>;
|
||||
}
|
||||
|
||||
65
src/Mod/TechDraw/App/DrawTile.h
Normal file
65
src/Mod/TechDraw/App/DrawTile.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Wanderer Fan <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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _TechDraw_DrawTile_h_
|
||||
#define _TechDraw_DrawTile_h_
|
||||
|
||||
# include <App/DocumentObject.h>
|
||||
# include <App/FeaturePython.h>
|
||||
|
||||
#include "DrawView.h"
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
class TechDrawExport DrawTile : public App::DocumentObject
|
||||
{
|
||||
PROPERTY_HEADER(TechDraw::DrawTile);
|
||||
|
||||
public:
|
||||
DrawTile();
|
||||
virtual ~DrawTile();
|
||||
|
||||
App::PropertyLink TileParent; //eg DrawWeldSymbol
|
||||
App::PropertyInteger TileRow;
|
||||
App::PropertyInteger TileColumn;
|
||||
App::PropertyVector TileOrigin; //sb call to TileParent - WeldingSymbol
|
||||
|
||||
virtual short mustExecute() const;
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderTile";
|
||||
}
|
||||
virtual PyObject *getPyObject(void);
|
||||
virtual DrawView* getParent(void) const;
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<DrawTile> DrawTilePython;
|
||||
|
||||
} //namespace TechDraw
|
||||
#endif
|
||||
18
src/Mod/TechDraw/App/DrawTilePy.xml
Normal file
18
src/Mod/TechDraw/App/DrawTilePy.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DocumentObjectPy"
|
||||
Name="DrawTilePy"
|
||||
Twin="DrawTile"
|
||||
TwinPointer="DrawTile"
|
||||
Include="Mod/TechDraw/App/DrawTile.h"
|
||||
Namespace="TechDraw"
|
||||
FatherInclude="App/DocumentObjectPy.h"
|
||||
FatherNamespace="App">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for adding tiles to leader lines</UserDocu>
|
||||
</Documentation>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
54
src/Mod/TechDraw/App/DrawTilePyImp.cpp
Normal file
54
src/Mod/TechDraw/App/DrawTilePyImp.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 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_
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
#include "DrawTile.h"
|
||||
|
||||
// inclusion of the generated files (generated out of DrawTilePy.xml)
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Mod/TechDraw/App/DrawTilePy.h>
|
||||
#include <Mod/TechDraw/App/DrawTilePy.cpp>
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string DrawTilePy::representation(void) const
|
||||
{
|
||||
return std::string("<DrawTile object>");
|
||||
}
|
||||
|
||||
PyObject *DrawTilePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawTilePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
103
src/Mod/TechDraw/App/DrawTileWeld.cpp
Normal file
103
src/Mod/TechDraw/App/DrawTileWeld.cpp
Normal file
@@ -0,0 +1,103 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Wanderer Fan <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_
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
|
||||
#include <Mod/TechDraw/App/DrawTileWeldPy.h> // generated from DrawTileWeldPy.xml
|
||||
#include "DrawTileWeld.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
//===========================================================================
|
||||
// DrawTileWeld - attachable tile
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(TechDraw::DrawTileWeld, TechDraw::DrawTile)
|
||||
|
||||
DrawTileWeld::DrawTileWeld(void)
|
||||
{
|
||||
static const char *group = "TileWeld";
|
||||
|
||||
ADD_PROPERTY_TYPE(LeftText,(""),group,(App::PropertyType)(App::Prop_None),
|
||||
"Text LHS");
|
||||
ADD_PROPERTY_TYPE(RightText, (0), group, App::Prop_None, "Text RHS");
|
||||
ADD_PROPERTY_TYPE(CenterText, (0), group, App::Prop_None, "Text above Symbol");
|
||||
ADD_PROPERTY_TYPE(SymbolFile, (""), group, App::Prop_None, "Svg Symbol File");
|
||||
}
|
||||
|
||||
DrawTileWeld::~DrawTileWeld()
|
||||
{
|
||||
}
|
||||
|
||||
void DrawTileWeld::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
//nothing in particular
|
||||
}
|
||||
DrawTile::onChanged(prop);
|
||||
|
||||
}
|
||||
|
||||
short DrawTileWeld::mustExecute() const
|
||||
{
|
||||
return DrawTile::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawTileWeld::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DT::execute()\n");
|
||||
return DrawTile::execute();
|
||||
}
|
||||
|
||||
PyObject *DrawTileWeld::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawTileWeldPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawTileWeldPython, TechDraw::DrawTileWeld)
|
||||
template<> const char* TechDraw::DrawTileWeldPython::getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderTile";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class TechDrawExport FeaturePythonT<TechDraw::DrawTileWeld>;
|
||||
}
|
||||
|
||||
68
src/Mod/TechDraw/App/DrawTileWeld.h
Normal file
68
src/Mod/TechDraw/App/DrawTileWeld.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Wanderer Fan <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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _TechDraw_DrawTileWeld_h_
|
||||
#define _TechDraw_DrawTileWeld_h_
|
||||
|
||||
#include <App/DocumentObject.h>
|
||||
#include <App/FeaturePython.h>
|
||||
#include <App/PropertyFile.h>
|
||||
#include <App/PropertyStandard.h>
|
||||
|
||||
#include "DrawTile.h"
|
||||
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
|
||||
class TechDrawExport DrawTileWeld : public TechDraw::DrawTile
|
||||
{
|
||||
PROPERTY_HEADER(TechDraw::DrawTileWeld);
|
||||
|
||||
public:
|
||||
DrawTileWeld();
|
||||
virtual ~DrawTileWeld();
|
||||
|
||||
App::PropertyString LeftText;
|
||||
App::PropertyString RightText;
|
||||
App::PropertyString CenterText;
|
||||
App::PropertyFileIncluded SymbolFile;
|
||||
|
||||
virtual short mustExecute() const;
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderTile";
|
||||
}
|
||||
virtual PyObject *getPyObject(void);
|
||||
virtual QRectF getRect() const { return QRectF(0,0,1,1);}
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<DrawTileWeld> DrawTileWeldPython;
|
||||
|
||||
} //namespace TechDraw
|
||||
#endif
|
||||
18
src/Mod/TechDraw/App/DrawTileWeldPy.xml
Normal file
18
src/Mod/TechDraw/App/DrawTileWeldPy.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DrawTilePy"
|
||||
Name="DrawTileWeldPy"
|
||||
Twin="DrawTileWeld"
|
||||
TwinPointer="DrawTileWeld"
|
||||
Include="Mod/TechDraw/App/DrawTileWeld.h"
|
||||
Namespace="TechDraw"
|
||||
FatherInclude="Mod/TechDraw/App/DrawTilePy.h"
|
||||
FatherNamespace="TechDraw">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for adding welding tiles to leader lines</UserDocu>
|
||||
</Documentation>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
54
src/Mod/TechDraw/App/DrawTileWeldPyImp.cpp
Normal file
54
src/Mod/TechDraw/App/DrawTileWeldPyImp.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 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_
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
#include "DrawTileWeld.h"
|
||||
|
||||
// inclusion of the generated files (generated out of DrawTileWeldPy.xml)
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Mod/TechDraw/App/DrawTileWeldPy.h>
|
||||
#include <Mod/TechDraw/App/DrawTileWeldPy.cpp>
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string DrawTileWeldPy::representation(void) const
|
||||
{
|
||||
return std::string("<DrawTileWeld object>");
|
||||
}
|
||||
|
||||
PyObject *DrawTileWeldPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawTileWeldPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
136
src/Mod/TechDraw/App/DrawWeldSymbol.cpp
Normal file
136
src/Mod/TechDraw/App/DrawWeldSymbol.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Wanderer Fan <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_
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
|
||||
#include <Mod/TechDraw/App/DrawWeldSymbolPy.h> // generated from DrawWeldSymbolPy.xml
|
||||
|
||||
#include "DrawTile.h"
|
||||
#include "DrawTileWeld.h"
|
||||
#include "DrawWeldSymbol.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
//===========================================================================
|
||||
// DrawWeldSymbol - welding symbol
|
||||
//===========================================================================
|
||||
|
||||
PROPERTY_SOURCE(TechDraw::DrawWeldSymbol, TechDraw::DrawView)
|
||||
|
||||
DrawWeldSymbol::DrawWeldSymbol(void)
|
||||
{
|
||||
static const char *group = "Weld Symbol";
|
||||
|
||||
ADD_PROPERTY_TYPE(Leader,(0),group,(App::PropertyType)(App::Prop_None), "Parent Leader");
|
||||
ADD_PROPERTY_TYPE(AllAround, (false), group, App::Prop_None, "All Around Symbol on/off");
|
||||
ADD_PROPERTY_TYPE(FieldWeld, (false), group, App::Prop_None, "Field Weld Symbol on/off");
|
||||
ADD_PROPERTY_TYPE(TailText, (""), group, App::Prop_None, "Text at tail of symbol");
|
||||
|
||||
Caption.setStatus(App::Property::Hidden,true);
|
||||
Scale.setStatus(App::Property::Hidden,true);
|
||||
ScaleType.setStatus(App::Property::Hidden,true);
|
||||
|
||||
}
|
||||
|
||||
DrawWeldSymbol::~DrawWeldSymbol()
|
||||
{
|
||||
}
|
||||
|
||||
void DrawWeldSymbol::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
//nothing in particular
|
||||
}
|
||||
DrawView::onChanged(prop);
|
||||
}
|
||||
|
||||
short DrawWeldSymbol::mustExecute() const
|
||||
{
|
||||
return DrawView::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawWeldSymbol::execute(void)
|
||||
{
|
||||
// Base::Console().Message("DWS::execute()\n");
|
||||
if (!keepUpdated()) {
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
std::vector<DrawTileWeld*> DrawWeldSymbol::getTiles(void) const
|
||||
{
|
||||
// Base::Console().Message("DWS::getTiles()\n");
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
std::vector<DrawTileWeld*> result;
|
||||
|
||||
std::vector<App::DocumentObject*> tiles = getInList();
|
||||
if (!tiles.empty()) {
|
||||
for(std::vector<App::DocumentObject *>::iterator it = tiles.begin(); it != tiles.end(); it++) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawTileWeld::getClassTypeId())) {
|
||||
App::DocumentObject* doTemp = (*it);
|
||||
DrawTileWeld* temp = static_cast<DrawTileWeld*>(doTemp);
|
||||
result.push_back(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Base::Console().Message("DWS::getTiles - returns: %d tiles\n",result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject *DrawWeldSymbol::getPyObject(void)
|
||||
{
|
||||
if (PythonObject.is(Py::_None())) {
|
||||
// ref counter is set to 1
|
||||
PythonObject = Py::Object(new DrawWeldSymbolPy(this),true);
|
||||
}
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
namespace App {
|
||||
/// @cond DOXERR
|
||||
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawWeldSymbolPython, TechDraw::DrawWeldSymbol)
|
||||
template<> const char* TechDraw::DrawWeldSymbolPython::getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderWeld";
|
||||
}
|
||||
/// @endcond
|
||||
|
||||
// explicit template instantiation
|
||||
template class TechDrawExport FeaturePythonT<TechDraw::DrawWeldSymbol>;
|
||||
}
|
||||
|
||||
72
src/Mod/TechDraw/App/DrawWeldSymbol.h
Normal file
72
src/Mod/TechDraw/App/DrawWeldSymbol.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 Wanderer Fan <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 *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _TechDraw_DrawWeldSymbol_h_
|
||||
#define _TechDraw_DrawWeldSymbol_h_
|
||||
|
||||
# include <App/DocumentObject.h>
|
||||
# include <App/FeaturePython.h>
|
||||
|
||||
#include "DrawView.h"
|
||||
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
class DrawTile;
|
||||
class DrawTileWeld;
|
||||
|
||||
class TechDrawExport DrawWeldSymbol : public TechDraw::DrawView
|
||||
{
|
||||
PROPERTY_HEADER(TechDraw::DrawWeldSymbol);
|
||||
|
||||
public:
|
||||
DrawWeldSymbol();
|
||||
virtual ~DrawWeldSymbol();
|
||||
|
||||
App::PropertyLink Leader;
|
||||
// App::PropertyLinkList Tiles;
|
||||
App::PropertyBool AllAround;
|
||||
App::PropertyBool FieldWeld;
|
||||
App::PropertyString TailText;
|
||||
|
||||
virtual short mustExecute() const;
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
|
||||
virtual const char* getViewProviderName(void) const {
|
||||
return "TechDrawGui::ViewProviderWeld";
|
||||
}
|
||||
virtual PyObject *getPyObject(void);
|
||||
virtual QRectF getRect() const { return QRectF(0,0,1,1);}
|
||||
|
||||
std::vector<DrawTileWeld*> getTiles(void) const;
|
||||
// void addTile(App::DocumentObject* d);
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
typedef App::FeaturePythonT<DrawWeldSymbol> DrawWeldSymbolPython;
|
||||
|
||||
} //namespace TechDraw
|
||||
#endif
|
||||
18
src/Mod/TechDraw/App/DrawWeldSymbolPy.xml
Normal file
18
src/Mod/TechDraw/App/DrawWeldSymbolPy.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
|
||||
<PythonExport
|
||||
Father="DrawViewPy"
|
||||
Name="DrawWeldSymbolPy"
|
||||
Twin="DrawWeldSymbol"
|
||||
TwinPointer="DrawWeldSymbol"
|
||||
Include="Mod/TechDraw/App/DrawWeldSymbol.h"
|
||||
Namespace="TechDraw"
|
||||
FatherInclude="Mod/TechDraw/App/DrawViewPy.h"
|
||||
FatherNamespace="TechDraw">
|
||||
<Documentation>
|
||||
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
|
||||
<UserDocu>Feature for adding welding tiles to leader lines</UserDocu>
|
||||
</Documentation>
|
||||
<CustomAttributes />
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
67
src/Mod/TechDraw/App/DrawWeldSymbolPyImp.cpp
Normal file
67
src/Mod/TechDraw/App/DrawWeldSymbolPyImp.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2019 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_
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
#include "DrawWeldSymbol.h"
|
||||
|
||||
// inclusion of the generated files (generated out of DrawWeldSymbolPy.xml)
|
||||
#include <Base/VectorPy.h>
|
||||
#include <Mod/TechDraw/App/DrawWeldSymbolPy.h>
|
||||
#include <Mod/TechDraw/App/DrawWeldSymbolPy.cpp>
|
||||
|
||||
using namespace TechDraw;
|
||||
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string DrawWeldSymbolPy::representation(void) const
|
||||
{
|
||||
return std::string("<DrawWeldSymbol object>");
|
||||
}
|
||||
|
||||
//PyObject* DrawWeldSymbolPy::getTiles(PyObject *args)
|
||||
//{
|
||||
// const char* fileSpec;
|
||||
// PyObject* pTile
|
||||
// if (!PyArg_ParseTuple(args, "O", &pTile)) {
|
||||
// throw Py::TypeError("getTiles expected DrawTile");
|
||||
// }
|
||||
// auto dws = getDrawWeldSymbolPtr();
|
||||
//// auto dt = pTile->getDrawTilePtr();
|
||||
////TODO: finish this!
|
||||
// Py_Return;
|
||||
//}
|
||||
|
||||
PyObject *DrawWeldSymbolPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DrawWeldSymbolPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user