[TD]Python routines & extension for CosmeticVertex

This commit is contained in:
wandererfan
2019-12-01 09:18:24 -05:00
committed by WandererFan
parent 0458d31dbb
commit f63cd9255a
22 changed files with 800 additions and 249 deletions

View File

@@ -52,6 +52,8 @@
#include "PropertyCosmeticEdgeList.h"
#include "PropertyCosmeticVertexList.h"
#include "CosmeticExtension.h"
namespace TechDraw {
extern PyObject* initModule();
}
@@ -71,11 +73,6 @@ PyMOD_INIT_FUNC(TechDraw)
PyObject* mod = TechDraw::initModule();
Base::Console().Log("Loading TechDraw module... done\n");
// NOTE: To finish the initialization of our own type objects we must
// call PyType_Ready, otherwise we run into a segmentation fault, later on.
// This function is responsible for adding inherited slots from a type's base class.
TechDraw::DrawPage ::init();
TechDraw::DrawView ::init();
TechDraw::DrawViewCollection ::init();
@@ -118,6 +115,10 @@ PyMOD_INIT_FUNC(TechDraw)
TechDraw::PropertyCosmeticVertexList::init();
TechDraw::CosmeticVertex ::init();
TechDraw::CosmeticExtension ::init();
TechDraw::CosmeticExtensionPython::init();
// are these python init calls required? some modules don't have them
// Python Types
TechDraw::DrawPagePython ::init();
TechDraw::DrawViewPython ::init();
@@ -130,5 +131,6 @@ PyMOD_INIT_FUNC(TechDraw)
TechDraw::DrawTilePython ::init();
TechDraw::DrawTileWeldPython ::init();
TechDraw::DrawWeldSymbolPython::init();
PyMOD_Return(mod);
}

View File

@@ -67,6 +67,7 @@ generate_from_xml(CosmeticVertexPy)
generate_from_xml(DrawTilePy)
generate_from_xml(DrawTileWeldPy)
generate_from_xml(DrawWeldSymbolPy)
generate_from_xml(CosmeticExtensionPy)
SET(Draw_SRCS
DrawPage.cpp
@@ -167,6 +168,8 @@ SET(Geometry_SRCS
PropertyCosmeticEdgeList.h
PropertyCosmeticVertexList.cpp
PropertyCosmeticVertexList.h
CosmeticExtension.cpp
CosmeticExtension.h
)
SET(Python_SRCS
@@ -220,6 +223,8 @@ SET(Python_SRCS
DrawTileWeldPyImp.cpp
DrawWeldSymbolPy.xml
DrawWeldSymbolPyImp.cpp
CosmeticExtensionPy.xml
CosmeticExtensionPyImp.cpp
)
SOURCE_GROUP("Mod" FILES ${TechDraw_SRCS})

View File

@@ -323,7 +323,9 @@ CosmeticVertex* CosmeticVertex::clone(void) const
PyObject* CosmeticVertex::getPyObject(void)
{
return new CosmeticVertexPy(new CosmeticVertex(this->copy()));
// return new CosmeticVertexPy(new CosmeticVertex(this->copy())); //shouldn't this be clone?
PyObject* result = new CosmeticVertexPy(this->clone()); //shouldn't this be clone?
return result;
}
void CosmeticVertex::dump(const char* title)

View File

@@ -91,6 +91,7 @@ public:
Base::Vector3d permaPoint; //permanent, unscaled value
int linkGeom; //connection to corresponding "geom" Vertex (fragile - index based!)
//better to do reverse search for CosmeticTag in vertex geometry
App::Color color;
double size;
int style;

View File

@@ -0,0 +1,192 @@
/***************************************************************************
* 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 // #ifndef _PreComp_
#include "CosmeticExtension.h"
#include <Base/Console.h>
#include <App/Application.h>
#include <App/FeaturePythonPyImp.h>
#include "CosmeticExtensionPy.h"
#include "Cosmetic.h"
#include "DrawUtil.h"
#include "DrawViewPart.h"
using namespace TechDraw;
using namespace std;
EXTENSION_PROPERTY_SOURCE(TechDraw::CosmeticExtension, App::DocumentObjectExtension)
CosmeticExtension::CosmeticExtension()
{
static const char *cgroup = "Cosmetics";
EXTENSION_ADD_PROPERTY_TYPE(CosmeticVertexes ,(0),cgroup,App::Prop_Output,"CosmeticVertex Save/Restore");
initExtensionType(CosmeticExtension::getExtensionClassTypeId());
}
CosmeticExtension::~CosmeticExtension()
{
}
//void CosmeticExtension::extHandleChangedPropertyName(Base::XMLReader &reader,
// const char* TypeName,
// const char* PropName)
//{
//}
//==============================================================================
//CosmeticVertex x,y are stored as unscaled, but mirrored (inverted Y) values.
//if you are creating a CV based on calculations of scaled geometry, you need to
//unscale x,y before creation.
//if you are creating a CV based on calculations of mirrored geometry, you need to
//mirror again before creation.
//returns unique CV id
//only adds cv to cvlist property. does not add to display geometry until dvp executes.
std::string CosmeticExtension::addCosmeticVertex(Base::Vector3d pos)
{
// Base::Console().Message("CEx::addCosmeticVertex(%s)\n",
// DrawUtil::formatVector(pos).c_str());
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
Base::Vector3d tempPos = DrawUtil::invertY(pos);
TechDraw::CosmeticVertex* cv = new TechDraw::CosmeticVertex(tempPos);
verts.push_back(cv);
CosmeticVertexes.setValues(verts);
std::string result = cv->getTagAsString();
return result;
}
//get CV by unique id
TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertex(std::string tagString) const
{
// Base::Console().Message("CEx::getCosmeticVertex(%s)\n", tagString.c_str());
CosmeticVertex* result = nullptr;
const std::vector<TechDraw::CosmeticVertex*> verts = CosmeticVertexes.getValues();
for (auto& cv: verts) {
std::string cvTag = cv->getTagAsString();
if (cvTag == tagString) {
result = cv;
break;
}
}
return result;
}
// find the cosmetic vertex corresponding to selection name (Vertex5)
// used when selecting
TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::string name) const
{
// Base::Console().Message("CEx::getCVBySelection(%s)\n",name.c_str());
CosmeticVertex* result = nullptr;
App::DocumentObject* extObj = const_cast<App::DocumentObject*> (getExtendedObject());
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(extObj);
if (dvp == nullptr) {
return result;
}
int idx = DrawUtil::getIndexFromName(name);
TechDraw::Vertex* v = dvp->getProjVertexByIndex(idx);
if (v == nullptr) {
return result;
}
if (!v->cosmeticTag.empty()) {
result = getCosmeticVertex(v->cosmeticTag);
}
return result;
}
//overload for index only
TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(int i) const
{
// Base::Console().Message("CEx::getCVBySelection(%d)\n", i);
std::stringstream ss;
ss << "Vertex" << i;
std::string vName = ss.str();
return getCosmeticVertexBySelection(vName);
}
void CosmeticExtension::removeCosmeticVertex(std::string delTag)
{
// Base::Console().Message("DVP::removeCV(%s)\n", delTag.c_str());
std::vector<CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
std::vector<CosmeticVertex*> newVerts;
for (auto& cv: cVerts) {
if (cv->getTagAsString() != delTag) {
newVerts.push_back(cv);
}
}
CosmeticVertexes.setValues(newVerts);
}
void CosmeticExtension::removeCosmeticVertex(std::vector<std::string> delTags)
{
for (auto& t: delTags) {
removeCosmeticVertex(t);
}
}
bool CosmeticExtension::replaceCosmeticVertex(CosmeticVertex* newCV)
{
// Base::Console().Message("DVP::replaceCV(%s)\n", newCV->getTagAsString().c_str());
bool result = false;
std::vector<CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
std::vector<CosmeticVertex*> newVerts;
std::string tag = newCV->getTagAsString();
for (auto& cv: cVerts) {
if (cv->getTagAsString() == tag) {
newVerts.push_back(newCV);
result = true;
} else {
newVerts.push_back(cv);
}
}
CosmeticVertexes.setValues(newVerts);
return result;
}
//================================================================================
PyObject* CosmeticExtension::getExtensionPyObject(void) {
if (ExtensionPythonObject.is(Py::_None())){
// ref counter is set to 1
ExtensionPythonObject = Py::Object(new CosmeticExtensionPy(this),true);
}
return Py::new_reference_to(ExtensionPythonObject);
}
namespace App {
/// @cond DOXERR
EXTENSION_PROPERTY_SOURCE_TEMPLATE(TechDraw::CosmeticExtensionPython, TechDraw::CosmeticExtension)
/// @endcond
// explicit template instantiation
template class TechDrawExport ExtensionPythonT<TechDraw::CosmeticExtension>;
}

View File

@@ -0,0 +1,73 @@
/***************************************************************************
* 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 *
* *
***************************************************************************/
#ifndef TECHDRAW_COSMETICEXTENSION_H
#define TECHDRAW_COSMETICEXTENSION_H
#include <App/DocumentObject.h>
#include <App/DocumentObjectExtension.h>
#include <App/PropertyStandard.h>
#include <App/Material.h>
#include <Base/Vector3D.h>
#include <Base/Exception.h>
#include "PropertyCosmeticVertexList.h"
namespace TechDraw {
class DrawViewPart;
class GeometryObject;
class TechDrawExport CosmeticExtension : public App::DocumentObjectExtension {
EXTENSION_PROPERTY_HEADER(TechDraw::CosmeticObject);
public:
CosmeticExtension();
virtual ~CosmeticExtension();
TechDraw::PropertyCosmeticVertexList CosmeticVertexes;
virtual std::string addCosmeticVertex(Base::Vector3d pos);
virtual CosmeticVertex* getCosmeticVertexBySelection(std::string name) const;
virtual CosmeticVertex* getCosmeticVertexBySelection(int i) const;
virtual CosmeticVertex* getCosmeticVertex(std::string id) const;
virtual bool replaceCosmeticVertex(CosmeticVertex* newVertex);
virtual void removeCosmeticVertex(std::string tag);
virtual void removeCosmeticVertex(std::vector<std::string> delTags);
PyObject* getExtensionPyObject(void);
protected:
/* virtual void extHandleChangedPropertyName(Base::XMLReader &reader, */
/* const char* TypeName, */
/* const char* PropName);*/
private:
};
typedef App::ExtensionPythonT<CosmeticExtension> CosmeticExtensionPython;
} //end namespace TechDraw
#endif //TECHDRAW_COSMETICEXTENSION_H

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DocumentObjectExtensionPy"
Name="CosmeticExtensionPy"
Twin="CosmeticExtension"
TwinPointer="CosmeticExtension"
Include="Mod/TechDraw/App/CosmeticExtension.h"
Namespace="TechDraw"
FatherInclude="App/DocumentObjectExtensionPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>This object represents cosmetic features for a DrawViewPart.</UserDocu>
</Documentation>
</PythonExport>
</GenerateModel>

View 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"
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Vector3D.h>
#include <Base/VectorPy.h>
#include "Mod/TechDraw/App/CosmeticExtension.h"
// inclusion of the generated files (generated out of CosmeticExtensionPy.xml)
#include "CosmeticExtensionPy.h"
#include "CosmeticExtensionPy.cpp"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string CosmeticExtensionPy::representation(void) const
{
return std::string("<TechDraw::CosmeticObject>");
}
PyObject *CosmeticExtensionPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int CosmeticExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -31,5 +31,18 @@
</Documentation>
<Parameter Name="Tag" Type="String"/>
</Attribute>
<Attribute Name="Point">
<Documentation>
<UserDocu>Gives the position of this CosmeticVertex as vector.</UserDocu>
</Documentation>
<Parameter Name="Point" Type="Object"/>
</Attribute>
<Attribute Name="Show">
<Documentation>
<UserDocu>Show/hide the vertex.</UserDocu>
</Documentation>
<Parameter Name="Show" Type="Boolean"/>
</Attribute>
</PythonExport>
</GenerateModel>

View File

@@ -27,10 +27,18 @@
# include <boost/uuid/uuid_io.hpp>
#endif
#include <Base/Console.h>
#include <Base/Vector3D.h>
#include <Base/VectorPy.h>
#include <Base/GeometryPyCXX.h>
#include "Cosmetic.h"
#include "CosmeticVertexPy.h"
#include "CosmeticVertexPy.cpp"
#include "DrawUtil.h"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
@@ -59,7 +67,7 @@ PyObject* CosmeticVertexPy::clone(PyObject *args)
return NULL;
TechDraw::CosmeticVertex* geom = this->getCosmeticVertexPtr();
geom->dump("CEPYI::clone");
// geom->dump("CEPYI::clone");
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
@@ -87,7 +95,7 @@ PyObject* CosmeticVertexPy::copy(PyObject *args)
return NULL;
TechDraw::CosmeticVertex* geom = this->getCosmeticVertexPtr();
geom->dump("CEPYI::copy");
// geom->dump("CEPYI::copy");
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
@@ -115,6 +123,57 @@ Py::String CosmeticVertexPy::getTag(void) const
return Py::String(tmp);
}
Py::Object CosmeticVertexPy::getPoint(void) const
{
Base::Vector3d point = getCosmeticVertexPtr()->permaPoint;
point = DrawUtil::invertY(point);
return Py::asObject(new Base::VectorPy(point));
}
void CosmeticVertexPy::setPoint(Py::Object arg)
{
PyObject* p = arg.ptr();
if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) {
Base::Vector3d point = static_cast<Base::VectorPy*>(p)->value();
getCosmeticVertexPtr()->permaPoint =
DrawUtil::invertY(point);
}
else if (PyObject_TypeCheck(p, &PyTuple_Type)) {
Base::Vector3d point = Base::getVectorFromTuple<double>(p);
getCosmeticVertexPtr()->permaPoint =
DrawUtil::invertY(point);
}
else {
std::string error = std::string("type must be 'Vector', not ");
error += p->ob_type->tp_name;
throw Py::TypeError(error);
}
}
Py::Boolean CosmeticVertexPy::getShow(void) const
{
bool show = getCosmeticVertexPtr()->visible;
if (show) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;
}
// return Py::asObject();
}
void CosmeticVertexPy::setShow(Py::Boolean arg)
{
PyObject* p = arg.ptr();
if (PyBool_Check(p)) {
if (p == Py_True) {
getCosmeticVertexPtr()->visible = true;
} else {
getCosmeticVertexPtr()->visible = false;
}
}
}
PyObject *CosmeticVertexPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;

View File

@@ -350,10 +350,10 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp,
//regular dims will have trouble with geom indexes!
Base::Vector3d cleanMin = DrawUtil::invertY(inMin) / scale;
std::string tag1 = dvp->addCosmeticVertexSS(cleanMin);
std::string tag1 = dvp->addCosmeticVertex(cleanMin);
int iGV1 = dvp->add1CVToGV(tag1);
Base::Vector3d cleanMax = DrawUtil::invertY(inMax) / scale;
std::string tag2 = dvp->addCosmeticVertexSS(cleanMax);
std::string tag2 = dvp->addCosmeticVertex(cleanMax);
int iGV2 = dvp->add1CVToGV(tag2);
std::vector<App::DocumentObject *> objs;

View File

@@ -118,7 +118,9 @@ using namespace std;
//===========================================================================
PROPERTY_SOURCE(TechDraw::DrawViewPart, TechDraw::DrawView)
//PROPERTY_SOURCE(TechDraw::DrawViewPart, TechDraw::DrawView)
PROPERTY_SOURCE_WITH_EXTENSIONS(TechDraw::DrawViewPart,
TechDraw::DrawView)
DrawViewPart::DrawViewPart(void) :
geometryObject(0)
@@ -127,8 +129,11 @@ DrawViewPart::DrawViewPart(void) :
static const char *sgroup = "HLR Parameters";
nowUnsetting = false;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
CosmeticExtension::initExtension(this);
Base::Reference<ParameterGrp> hGrp = App::GetApplication().
GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/General");
double defDist = hGrp->GetFloat("FocusDistance",100.0);
//properties that affect Geometry
@@ -155,7 +160,7 @@ DrawViewPart::DrawViewPart(void) :
ADD_PROPERTY_TYPE(IsoHidden ,(false),sgroup,App::Prop_None,"Hidden Iso u,v lines on/off");
ADD_PROPERTY_TYPE(IsoCount ,(0),sgroup,App::Prop_None,"Number of isoparameters");
ADD_PROPERTY_TYPE(CosmeticVertexes ,(0),sgroup,App::Prop_Output,"CosmeticVertex Save/Restore");
// ADD_PROPERTY_TYPE(CosmeticVertexes ,(0),sgroup,App::Prop_Output,"CosmeticVertex Save/Restore");
ADD_PROPERTY_TYPE(CosmeticEdges ,(0),sgroup,App::Prop_Output,"CosmeticEdge Save/Restore");
ADD_PROPERTY_TYPE(CenterLines ,(0),sgroup,App::Prop_Output,"Geometry format Save/Restore");
ADD_PROPERTY_TYPE(GeomFormats ,(0),sgroup,App::Prop_Output,"Geometry format Save/Restore");
@@ -276,6 +281,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
getNameInDocument(),diffOut);
#endif //#if MOD_TECHDRAW_HANDLE_FACES
// Base::Console().Message("DVP::execute - exits\n");
return DrawView::execute();
}
@@ -308,6 +314,7 @@ short DrawViewPart::mustExecute() const
void DrawViewPart::onChanged(const App::Property* prop)
{
DrawView::onChanged(prop);
//TODO: when scale changes, any Dimensions for this View sb recalculated. DVD should pick this up subject to topological naming issues.
}
@@ -988,179 +995,12 @@ void DrawViewPart::clearCosmeticVertexes(void)
CosmeticVertexes.setValues(noVerts);
}
//CosmeticVertex x,y are stored as unscaled, but mirrored values.
//if you are creating a CV based on calculations of scaled geometry, you need to
//unscale x,y before creation.
//if you are creating a CV based on calculations of mirrored geometry, you need to
//mirror again before creation.
//returns CosmeticVertex index! not geomVertexNumber!
int DrawViewPart::addCosmeticVertex(Base::Vector3d pos)
{
// Base::Console().Message("DVP::addCosmeticVertex(%s)\n",
// DrawUtil::formatVector(pos).c_str());
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
Base::Vector3d tempPos = DrawUtil::invertY(pos);
TechDraw::CosmeticVertex* cv = new TechDraw::CosmeticVertex(tempPos);
int newIdx = (int) (verts.size());
verts.push_back(cv);
CosmeticVertexes.setValues(verts);
return newIdx;
}
std::string DrawViewPart::addCosmeticVertexSS(Base::Vector3d pos)
{
// Base::Console().Message("DVP::addCosmeticVertexSS(%s)\n",
// DrawUtil::formatVector(pos).c_str());
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
Base::Vector3d tempPos = DrawUtil::invertY(pos);
TechDraw::CosmeticVertex* cv = new TechDraw::CosmeticVertex(tempPos);
verts.push_back(cv);
CosmeticVertexes.setValues(verts);
std::string result = cv->getTagAsString();
return result;
}
int DrawViewPart::addCosmeticVertex(CosmeticVertex* cv)
{
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
int newIdx = (int) verts.size();
verts.push_back(cv);
CosmeticVertexes.setValues(verts);
return newIdx;
}
void DrawViewPart::removeCosmeticVertex(TechDraw::CosmeticVertex* cv)
{
// Base::Console().Message("DVP::removeCosmeticVertex(%X)\n", cv);
bool found = false;
int i = 0;
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
int stop = verts.size();
for ( ; i < stop; i++) {
TechDraw::CosmeticVertex* v = verts.at(i);
if (cv == v) {
found = true;
break;
}
}
if ( (cv != nullptr) &&
(found) ) {
removeCosmeticVertex(i);
}
}
//this is by CV index, not the index returned by selection
void DrawViewPart::removeCosmeticVertex(int idx)
{
// Base::Console().Message("DVP::removeCV(%d)\n", idx);
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
if (idx < (int) verts.size()) {
verts.erase(verts.begin() + idx);
CosmeticVertexes.setValues(verts);
recomputeFeature();
}
}
void DrawViewPart::removeCosmeticVertex(std::string delTag)
{
// Base::Console().Message("DVP::removeCV(%s)\n", delTag.c_str());
std::vector<CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
std::vector<CosmeticVertex*> newVerts;
for (auto& cv: cVerts) {
if (cv->getTagAsString() != delTag) {
newVerts.push_back(cv);
}
}
CosmeticVertexes.setValues(newVerts);
// recomputeFeature();
}
void DrawViewPart::removeCosmeticVertex(std::vector<std::string> delTags)
{
std::vector<CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
// Base::Console().Message("DVP::removeCosmeticVertex(list) - cVerts: %d\n", cVerts.size());
std::vector<CosmeticVertex*> newVerts;
for (auto& cv: cVerts) {
bool found = false;
for (auto& dt: delTags) {
if (cv->getTagAsString() == dt) {
found = true; //this cv is in delete list
break;
}
}
if (!found) {
newVerts.push_back(cv);
}
}
CosmeticVertexes.setValues(newVerts);
}
//transition code. temporary. not used??
int DrawViewPart::getCosmeticVertexIndex(std::string tagString)
{
Base::Console().Message("DVP::getCosmeticVertexIndex(%s) - deprec?\n", tagString.c_str());
int result = -1;
int iCV = 0;
const std::vector<TechDraw::CosmeticVertex*> verts = CosmeticVertexes.getValues();
for (auto& cv: verts) {
std::string cvTag = cv->getTagAsString();
if (cvTag == tagString) {
result = iCV;
break;
}
iCV++;
}
return result;
}
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertex(std::string tagString) const
{
CosmeticVertex* result = nullptr;
const std::vector<TechDraw::CosmeticVertex*> verts = CosmeticVertexes.getValues();
for (auto& cv: verts) {
std::string cvTag = cv->getTagAsString();
if (cvTag == tagString) {
result = cv;
break;
}
}
return result;
}
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByIndex(int idx) const
{
CosmeticVertex* result = nullptr;
const std::vector<TechDraw::CosmeticVertex*> verts = CosmeticVertexes.getValues();
if (idx < (int) verts.size()) {
result = verts.at(idx);
}
return result;
}
// find the cosmetic vertex corresponding to geometry vertex idx
// used when selecting
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByGeom(int idx) const
{
CosmeticVertex* result = nullptr;
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
TechDraw::Vertex* v = getProjVertexByIndex(idx);
if (v == nullptr) {
return result;
}
if (!v->cosmeticTag.empty()) {
result = getCosmeticVertex(v->cosmeticTag);
}
return result;
}
//add the cosmetic verts to geometry vertex list
void DrawViewPart::addCosmeticVertexesToGeom(void)
{
// Base::Console().Message("DVP::addCosmeticVertexesToGeom()\n");
int iCV = 0;
const std::vector<TechDraw::CosmeticVertex*> cVerts = CosmeticVertexes.getValues();
const std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
int stop = (int) cVerts.size();
for ( ; iCV < stop; iCV++) {
int iGV = geometryObject->addCosmeticVertex(cVerts.at(iCV)->scaled(getScale()),
@@ -1170,17 +1010,6 @@ void DrawViewPart::addCosmeticVertexesToGeom(void)
}
}
int DrawViewPart::add1CVToGV(int iCV)
{
Base::Console().Message("DVP::add1CVToGV(%d) 1 - deprec?\n", iCV);
TechDraw::CosmeticVertex* cv = getCosmeticVertexByIndex(iCV);
int iGV = geometryObject->addCosmeticVertex(cv->scaled(getScale()),
cv->getTagAsString(),
iCV);
cv->linkGeom = iGV;
return iGV;
}
int DrawViewPart::add1CVToGV(std::string tag)
{
// Base::Console().Message("DVP::add1CVToGV(%s) 2\n", tag.c_str());
@@ -1188,7 +1017,6 @@ int DrawViewPart::add1CVToGV(std::string tag)
if (cv == nullptr) {
Base::Console().Message("DVP::add1CVToGV 2 - cv %s not found\n", tag.c_str());
}
// int iCV = getCosmeticVertexIndex(tag); //transition
int iCV = -1;
int iGV = geometryObject->addCosmeticVertex(cv->scaled(getScale()),
cv->getTagAsString(),
@@ -1197,6 +1025,23 @@ int DrawViewPart::add1CVToGV(std::string tag)
return iGV;
}
//update Vertex geometry with current CV's
void DrawViewPart::refreshCVGeoms(void)
{
// Base::Console().Message("DVP::refreshCVGeoms()\n");
std::vector<TechDraw::Vertex *> gVerts = getVertexGeometry();
std::vector<TechDraw::Vertex *> newGVerts;
for (auto& gv :gVerts) {
if (gv->cosmeticTag.empty()) { //keep only non-cv vertices
newGVerts.push_back(gv);
}
}
getGeometryObject()->setVertexGeometry(newGVerts);
addCosmeticVertexesToGeom();
}
//CosmeticEdges -------------------------------------------------------------------
//for completeness. not actually used anywhere?
@@ -1605,6 +1450,15 @@ PyObject *DrawViewPart::getPyObject(void)
return Py::new_reference_to(PythonObject);
}
void DrawViewPart::handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName)
{
// extHandleChangedPropertyName(reader, TypeName, PropName); // CosmeticExtension
DrawView::handleChangedPropertyName(reader, TypeName, PropName);
}
// Python Drawing feature ---------------------------------------------------------
namespace App {

View File

@@ -41,6 +41,7 @@
#include "PropertyCenterLineList.h"
#include "PropertyCosmeticEdgeList.h"
#include "PropertyCosmeticVertexList.h"
#include "CosmeticExtension.h"
#include "DrawView.h"
class gp_Pnt;
@@ -83,9 +84,9 @@ namespace TechDraw
class DrawViewSection;
class TechDrawExport DrawViewPart : public DrawView
class TechDrawExport DrawViewPart : public DrawView, public CosmeticExtension
{
PROPERTY_HEADER_WITH_OVERRIDE(TechDraw::DrawViewPart);
PROPERTY_HEADER_WITH_EXTENSIONS(TechDraw::DrawViewPart);
public:
DrawViewPart(void);
@@ -110,7 +111,7 @@ public:
App::PropertyBool IsoHidden;
App::PropertyInteger IsoCount;
TechDraw::PropertyCosmeticVertexList CosmeticVertexes;
/* TechDraw::PropertyCosmeticVertexList CosmeticVertexes;*/
TechDraw::PropertyCosmeticEdgeList CosmeticEdges;
TechDraw::PropertyCenterLineList CenterLines;
TechDraw::PropertyGeomFormatList GeomFormats;
@@ -173,22 +174,10 @@ public:
bool isIso(void) const;
virtual int addCosmeticVertex(Base::Vector3d pos);
virtual int addCosmeticVertex(CosmeticVertex* cv);
std::string addCosmeticVertexSS(Base::Vector3d pos);
virtual void removeCosmeticVertex(TechDraw::CosmeticVertex* cv);
virtual void removeCosmeticVertex(int idx);
virtual void removeCosmeticVertex(std::string tagString);
virtual void removeCosmeticVertex(std::vector<std::string> delTags);
int getCosmeticVertexIndex(std::string tagString);
TechDraw::CosmeticVertex* getCosmeticVertex(std::string tagString) const;
TechDraw::CosmeticVertex* getCosmeticVertexByIndex(int idx) const;
TechDraw::CosmeticVertex* getCosmeticVertexByGeom(int idx) const;
void clearCosmeticVertexes(void);
void refreshCVGeoms(void);
void addCosmeticVertexesToGeom(void);
void add1CosmeticVertexToGeom(int iCV);
int add1CVToGV(int iCV);
int add1CVToGV(std::string tag);
virtual int addCosmeticEdge(Base::Vector3d start, Base::Vector3d end);
@@ -249,6 +238,9 @@ protected:
TopoDS_Shape m_saveShape; //TODO: make this a Property. Part::TopoShapeProperty??
Base::Vector3d m_saveCentroid; //centroid before centering shape in origin
void handleChangedPropertyName(Base::XMLReader &reader, const char* TypeName, const char* PropName) override;
private:
bool nowUnsetting;

View File

@@ -25,17 +25,32 @@
</Methode>
<Methode Name="makeCosmeticVertex">
<Documentation>
<UserDocu>makeCosmeticVertex(p1) - add a CosmeticVertex at p1 (View coordinates). Returns index of created vertex.</UserDocu>
<UserDocu>id = makeCosmeticVertex(p1) - add a CosmeticVertex at p1 (View coordinates). Returns unique id vertex.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getCosmeticVertexByIndex">
<Methode Name="makeCosmeticVertex3d">
<Documentation>
<UserDocu>getCosmeticVertexByIndex(idx) - returns CosmeticVertx[idx].</UserDocu>
<UserDocu>id = makeCosmeticVertex3d(p1) - add a CosmeticVertex at p1 (3d model coordinates). Returns unique id vertex.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getCosmeticVertex">
<Documentation>
<UserDocu>getCosmeticVertex(id) - returns CosmeticVertex with unique id.</UserDocu>
</Documentation>
</Methode>
<Methode Name="getCosmeticVertexBySelection">
<Documentation>
<UserDocu>getCosmeticVertexBySelection(name) - returns CosmeticVertex with name (Vertex6). Used in selections.</UserDocu>
</Documentation>
</Methode>
<Methode Name="replaceCosmeticVertex">
<Documentation>
<UserDocu>replaceCosmeticVertex(cv) - replaces CosmeticVertex in View. Returns True/False.</UserDocu>
</Documentation>
</Methode>
<Methode Name="removeCosmeticVertex">
<Documentation>
<UserDocu>removeCosmeticVertex(idx) - remove CosmeticVertex[idx] from View. Returns None.</UserDocu>
<UserDocu>removeCosmeticVertex(cv) - remove CosmeticVertex from View. Returns None.</UserDocu>
</Documentation>
</Methode>
<Methode Name="clearCosmeticVertices">

View File

@@ -49,8 +49,8 @@
#include "DrawViewPart.h"
#include "GeometryObject.h"
#include "Cosmetic.h"
#include "CosmeticExtension.h"
#include "DrawUtil.h"
#include "GeometryObject.h"
// inclusion of the generated files (generated out of DrawViewPartPy.xml)
#include <Mod/TechDraw/App/CosmeticVertexPy.h>
@@ -59,6 +59,7 @@
#include <Mod/TechDraw/App/DrawViewPartPy.h>
#include <Mod/TechDraw/App/DrawViewPartPy.cpp>
using namespace TechDraw;
//TODO: errors to PyErrors
@@ -102,6 +103,8 @@ PyObject* DrawViewPartPy::getHiddenEdges(PyObject *args)
return pEdgeList;
}
// remove all cosmetics
PyObject* DrawViewPartPy::clearCosmeticVertices(PyObject *args)
{
(void) args;
@@ -138,7 +141,7 @@ PyObject* DrawViewPartPy::clearGeomFormats(PyObject *args)
return Py_None;
}
//********* Cosmetic Vertex Routines *******************************************
PyObject* DrawViewPartPy::makeCosmeticVertex(PyObject *args)
{
PyObject* pPnt1 = nullptr;
@@ -146,13 +149,144 @@ PyObject* DrawViewPartPy::makeCosmeticVertex(PyObject *args)
throw Py::TypeError("expected (vector)");
}
DrawViewPart* item = getDrawViewPartPtr();
// Base::Vector3d pnt1 = DrawUtil::invertY(static_cast<Base::VectorPy*>(pPnt1)->value());
DrawViewPart* dvp = getDrawViewPartPtr();
std::string dvpName = dvp->getNameInDocument();
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
int idx = item->addCosmeticVertex(pnt1);
return PyLong_FromLong(idx);
std::string id = dvp->addCosmeticVertex(pnt1);
//int link =
dvp->add1CVToGV(id);
dvp->requestPaint();
return PyUnicode_FromString(id.c_str()); //return tag for new CV
}
PyObject* DrawViewPartPy::makeCosmeticVertex3d(PyObject *args)
{
PyObject* pPnt1 = nullptr;
if (!PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &pPnt1)) {
throw Py::TypeError("expected (vector)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
Base::Vector3d centroid = dvp->getOriginalCentroid();
pnt1 = pnt1 - centroid;
Base::Vector3d projected = DrawUtil::invertY(dvp->projectPoint(pnt1));
std::string id = dvp->addCosmeticVertex(projected);
//int link =
dvp->add1CVToGV(id);
dvp->refreshCVGeoms();
dvp->requestPaint();
return PyUnicode_FromString(id.c_str()); //return tag for new CV
}
//get by unique tag
PyObject* DrawViewPartPy::getCosmeticVertex(PyObject *args)
{
// Base::Console().Message("DVPP::getCosmeticVertex()\n");
PyObject* result = nullptr;
char* id; //unique tag
if (!PyArg_ParseTuple(args, "s", &id)) {
throw Py::TypeError("expected (string)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertex(id);
if (cv != nullptr) {
result = cv->getPyObject();
} else {
result = Py_None;
}
return result;
}
//get by selection name
PyObject* DrawViewPartPy::getCosmeticVertexBySelection(PyObject *args)
{
// Base::Console().Message("DVPP::getCosmeticVertexBySelection()\n");
PyObject* result = nullptr;
char* selName; //Selection routine name - "Vertex0"
if (!PyArg_ParseTuple(args, "s", &selName)) {
throw Py::TypeError("expected (string)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertexBySelection(selName);
if (cv != nullptr) {
result = cv->getPyObject();
} else {
result = Py_None;
}
return result;
}
PyObject* DrawViewPartPy::removeCosmeticVertex(PyObject *args)
{
// Base::Console().Message("DVPP::removeCosmeticVertex()\n");
DrawViewPart* dvp = getDrawViewPartPtr();
if (dvp == nullptr) {
return Py_None;
}
char* tag;
if (PyArg_ParseTuple(args, "s", &tag)) {
dvp->removeCosmeticVertex(tag);
dvp->refreshCVGeoms();
dvp->requestPaint();
return Py_None;
}
PyObject* pCVToDelete = nullptr;
if (PyArg_ParseTuple(args, "O!", &(TechDraw::CosmeticVertexPy::Type), &pCVToDelete)) {
TechDraw::CosmeticVertexPy* cvPy = static_cast<TechDraw::CosmeticVertexPy*>(pCVToDelete);
TechDraw::CosmeticVertex* cv = cvPy->getCosmeticVertexPtr();
dvp->removeCosmeticVertex(cv->getTagAsString());
dvp->refreshCVGeoms();
dvp->requestPaint();
return Py_None;
}
PyObject* pDelList = nullptr;
if (PyArg_ParseTuple(args, "O", &pDelList)) {
if (PySequence_Check(pDelList)) {
Py_ssize_t nSize = PySequence_Size(pDelList);
for (Py_ssize_t i=0; i < nSize; i++) {
PyObject* item = PySequence_GetItem(pDelList, i);
if (!PyObject_TypeCheck(item, &(TechDraw::CosmeticVertexPy::Type))) {
std::string error = std::string("types in list must be 'CosmeticVertex', not ");
error += item->ob_type->tp_name;
throw Base::TypeError(error);
}
TechDraw::CosmeticVertexPy* cvPy = static_cast<TechDraw::CosmeticVertexPy*>(item);
TechDraw::CosmeticVertex* cv = cvPy->getCosmeticVertexPtr();
dvp->removeCosmeticVertex(cv->getTagAsString());
}
dvp->refreshCVGeoms();
dvp->requestPaint();
}
} else {
throw Py::TypeError("expected (CosmeticVertex or [CosmeticVertex])");
}
return Py_None;
}
PyObject* DrawViewPartPy::replaceCosmeticVertex(PyObject *args)
{
PyObject* pNewCV = nullptr;
if (!PyArg_ParseTuple(args, "O!", &(TechDraw::CosmeticVertexPy::Type), &pNewCV)) {
throw Py::TypeError("expected (CosmeticVertex)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticVertexPy* cvPy = static_cast<TechDraw::CosmeticVertexPy*>(pNewCV);
TechDraw::CosmeticVertex* cv = cvPy->getCosmeticVertexPtr();
bool result = dvp->replaceCosmeticVertex(cv);
dvp->refreshCVGeoms();
dvp->requestPaint();
return PyBool_FromLong((long) result);
}
//********* Cosmetic Line Routines *********************************************
PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
{
PyObject* pPnt1 = nullptr;
@@ -290,34 +424,23 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
return PyLong_FromLong(idx);
}
PyObject* DrawViewPartPy::getCosmeticVertexByIndex(PyObject *args)
{
PyObject* result = nullptr;
int idx = -1;
if (!PyArg_ParseTuple(args, "i", &idx)) {
throw Py::TypeError("expected (index)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertexByIndex(idx);
if (cv != nullptr) {
result = new CosmeticVertexPy(new CosmeticVertex(cv));
} else {
result = Py_None;
}
return result;
}
//PyObject* DrawViewPartPy::getCosmeticVertexByIndex(PyObject *args)
//{
// PyObject* result = nullptr;
// int idx = -1;
// if (!PyArg_ParseTuple(args, "i", &idx)) {
// throw Py::TypeError("expected (index)");
// }
// DrawViewPart* dvp = getDrawViewPartPtr();
// TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertexByIndex(idx);
// if (cv != nullptr) {
// result = new CosmeticVertexPy(new CosmeticVertex(cv));
// } else {
// result = Py_None;
// }
// return result;
//}
PyObject* DrawViewPartPy::removeCosmeticVertex(PyObject *args)
{
int idx = 0;
if (!PyArg_ParseTuple(args, "i", &idx)) {
throw Py::TypeError("expected (index)");
}
DrawViewPart* dvp = getDrawViewPartPtr();
dvp->removeCosmeticVertex(idx);
Py_INCREF(Py_None);
return Py_None;
}
PyObject* DrawViewPartPy::getCosmeticEdgeByIndex(PyObject *args)
{

View File

@@ -572,6 +572,24 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
} //end TopExp
}
//adds a new GeomVert surrogate for CV
//returns GeomVert selection index ("Vertex3")
// insertGeomForCV(cv)
int GeometryObject::addCosmeticVertex(CosmeticVertex* cv)
{
// Base::Console().Message("GO::addCosmeticVertex(%X)\n", cv);
double scale = m_parent->getScale();
Base::Vector3d pos = cv->scaled(scale);
TechDraw::Vertex* v = new TechDraw::Vertex(pos.x, pos.y);
v->cosmetic = true;
v->cosmeticLink = -1; //obs??
v->cosmeticTag = cv->getTagAsString();
v->hlrVisible = true;
int idx = vertexGeom.size();
vertexGeom.push_back(v);
return idx;
}
//adds a new GeomVert to list for cv[link]
int GeometryObject::addCosmeticVertex(Base::Vector3d pos, int link)
{
@@ -599,6 +617,8 @@ int GeometryObject::addCosmeticVertex(Base::Vector3d pos, std::string tagString,
return idx;
}
//================================================================================
//do not need source index anymore. base has CosmeticTag
int GeometryObject::addCosmeticEdge(TechDraw::BaseGeom* base,
int s)

View File

@@ -108,6 +108,8 @@ public:
const std::vector<BaseGeom *> & getEdgeGeometry() const { return edgeGeom; }
const std::vector<BaseGeom *> getVisibleFaceEdges(bool smooth, bool seam) const;
const std::vector<Face *> & getFaceGeometry() const { return faceGeom; }
void setVertexGeometry(std::vector<Vertex*> newVerts) {vertexGeom = newVerts; }
void projectShape(const TopoDS_Shape &input,
const gp_Ax2 viewAxis);
@@ -142,8 +144,9 @@ public:
TopoDS_Shape getHidIso(void) { return hidIso; }
//Are removeXXXXX functions really needed for GO?
int addCosmeticVertex(Base::Vector3d pos, int link = -1);
int addCosmeticVertex(Base::Vector3d pos, std::string tagString, int link = -1);
int addCosmeticVertex(CosmeticVertex* cv);
int addCosmeticVertex(Base::Vector3d pos, int link = -1); //obs?
int addCosmeticVertex(Base::Vector3d pos, std::string tagString, int link = -1); //obs??
int addCosmeticEdge(TechDraw::BaseGeom* bg, int s = 0);
int addCenterLine(TechDraw::BaseGeom* bg, int s = 0, int si = -1);

View File

@@ -62,6 +62,8 @@
#include "ViewProviderTile.h"
#include "ViewProviderWeld.h"
#include "ViewProviderCosmeticExtension.h"
// use a different name to CreateCommand()
void CreateTechDrawCommands(void);
@@ -141,6 +143,8 @@ PyMOD_INIT_FUNC(TechDrawGui)
TechDrawGui::ViewProviderTile::init();
TechDrawGui::ViewProviderWeld::init();
TechDrawGui::ViewProviderCosmeticExtension::init();
// register preferences pages
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawImp> ("TechDraw");
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDraw2Imp> ("TechDraw");

View File

@@ -328,6 +328,8 @@ SET(TechDrawGuiViewProvider_SRCS
ViewProviderTile.h
ViewProviderWeld.cpp
ViewProviderWeld.h
ViewProviderCosmeticExtension.cpp
ViewProviderCosmeticExtension.h
)
SOURCE_GROUP("MRTE" FILES ${MRTE_SRCS})

View File

@@ -662,7 +662,8 @@ void QGIViewPart::drawViewPart()
} else { //regular Vertex
if (showVertices) {
QGIVertex *item = new QGIVertex(i);
TechDraw::CosmeticVertex* cv = viewPart->getCosmeticVertexByGeom(i);
TechDraw::CosmeticVertex* cv = viewPart->getCosmeticVertexBySelection(i);
// TechDraw::CosmeticVertex* cv = viewPart->getCosmeticVertexByGeom(i);
if (cv != nullptr) {
item->setNormalColor(cv->color.asValue<QColor>());
item->setRadius(cv->size);

View 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_
# ifdef _MSC_VER
# define _USE_MATH_DEFINES
# include <cmath>
# endif //_MSC_VER
#endif
#include <Base/Console.h>
#include "ViewProviderCosmeticExtension.h"
#include <Mod/TechDraw/App/CosmeticExtension.h>
#include <Gui/BitmapFactory.h>
using namespace TechDrawGui;
EXTENSION_PROPERTY_SOURCE(TechDrawGui::ViewProviderCosmeticExtension, Gui::ViewProviderExtension)
ViewProviderCosmeticExtension::ViewProviderCosmeticExtension()
{
initExtensionType(ViewProviderCosmeticExtension::getExtensionClassTypeId());
}
QIcon ViewProviderCosmeticExtension::extensionMergeOverlayIcons(const QIcon & orig) const
{
QIcon mergedicon = orig;
return mergedicon;
}
void ViewProviderCosmeticExtension::extensionUpdateData(const App::Property* prop)
{
Gui::ViewProviderExtension::extensionUpdateData(prop);
}
namespace Gui {
EXTENSION_PROPERTY_SOURCE_TEMPLATE(TechDrawGui::ViewProviderCosmeticExtensionPython, TechDrawGui::ViewProviderCosmeticExtension)
// explicit template instantiation
template class TechDrawGuiExport ViewProviderExtensionPythonT<TechDrawGui::ViewProviderCosmeticExtension>;
}

View File

@@ -0,0 +1,52 @@
/***************************************************************************
* 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 *
* *
***************************************************************************/
#ifndef GUI_VIEWPROVIDERCOSMETICEXTENSION_H
#define GUI_VIEWPROVIDERCOSMETICEXTENSION_H
#include <App/Extension.h>
#include <Gui/ViewProviderExtension.h>
namespace TechDrawGui
{
class TechDrawGuiExport ViewProviderCosmeticExtension : public Gui::ViewProviderExtension
{
EXTENSION_PROPERTY_HEADER_WITH_OVERRIDE(TechDrawGui::ViewProviderCosmeticExtension);
public:
/// Constructor
ViewProviderCosmeticExtension(void);
virtual ~ViewProviderCosmeticExtension() = default;
virtual QIcon extensionMergeOverlayIcons(const QIcon & orig) const override;
virtual void extensionUpdateData(const App::Property*) override;
};
typedef Gui::ViewProviderExtensionPythonT<TechDrawGui::ViewProviderCosmeticExtension> ViewProviderCosmeticExtensionPython;
} //namespace TechDrawGui
#endif // GUI_VIEWPROVIDERCOSMETICEXTENSION_H