[TD]Add Properties for Cosmetic persistence

This commit is contained in:
wandererfan
2019-07-07 09:35:56 -04:00
committed by WandererFan
parent e881dcd860
commit 9828655f48
32 changed files with 3265 additions and 731 deletions

View File

@@ -42,6 +42,11 @@
#include "DrawViewBalloon.h"
#include "DrawLeaderLine.h"
#include "DrawRichAnno.h"
#include "Cosmetic.h"
#include "PropertyGeomFormatList.h"
#include "PropertyCenterLineList.h"
#include "PropertyCosmeticEdgeList.h"
#include "PropertyCosmeticVertexList.h"
namespace TechDraw {
extern PyObject* initModule();
@@ -83,7 +88,7 @@ PyMOD_INIT_FUNC(TechDraw)
TechDraw::DrawViewDetail ::init();
TechDraw::DrawViewBalloon ::init();
TechDraw::DrawLeaderLine ::init();
TechDraw::DrawRichAnno ::init();
TechDraw::DrawRichAnno ::init();
TechDraw::DrawTemplate ::init();
TechDraw::DrawParametricTemplate::init();
@@ -91,19 +96,28 @@ PyMOD_INIT_FUNC(TechDraw)
TechDraw::DrawViewClip ::init();
TechDraw::DrawHatch ::init();
TechDraw::DrawGeomHatch ::init();
TechDraw::DrawGeomHatch ::init();
TechDraw::DrawViewDraft ::init();
TechDraw::DrawViewArch ::init();
TechDraw::DrawViewImage ::init();
TechDraw::PropertyGeomFormatList::init();
TechDraw::GeomFormat ::init();
TechDraw::PropertyCenterLineList::init();
TechDraw::CenterLine ::init();
TechDraw::PropertyCosmeticEdgeList::init();
TechDraw::CosmeticEdge ::init();
TechDraw::PropertyCosmeticVertexList::init();
TechDraw::CosmeticVertex ::init();
// Python Types
TechDraw::DrawPagePython ::init();
TechDraw::DrawViewPython ::init();
TechDraw::DrawViewPartPython ::init();
TechDraw::DrawViewMultiPython ::init();
TechDraw::DrawViewMultiPython ::init();
TechDraw::DrawTemplatePython ::init();
TechDraw::DrawViewSymbolPython::init();
TechDraw::DrawLeaderLinePython::init();
TechDraw::DrawRichAnnoPython::init();
TechDraw::DrawRichAnnoPython ::init();
PyMOD_Return(mod);
}

View File

@@ -59,7 +59,10 @@ generate_from_xml(DrawProjGroupItemPy)
generate_from_xml(DrawViewAnnotationPy)
generate_from_xml(DrawLeaderLinePy)
generate_from_xml(DrawRichAnnoPy)
generate_from_xml(GeomFormatPy)
generate_from_xml(CenterLinePy)
generate_from_xml(CosmeticEdgePy)
generate_from_xml(CosmeticVertexPy)
SET(Draw_SRCS
DrawPage.cpp
@@ -140,6 +143,14 @@ SET(Geometry_SRCS
GeometryObject.h
Cosmetic.cpp
Cosmetic.h
PropertyGeomFormatList.cpp
PropertyGeomFormatList.h
PropertyCenterLineList.cpp
PropertyCenterLineList.h
PropertyCosmeticEdgeList.cpp
PropertyCosmeticEdgeList.h
PropertyCosmeticVertexList.cpp
PropertyCosmeticVertexList.h
)
SET(Python_SRCS
@@ -177,6 +188,14 @@ SET(Python_SRCS
DrawLeaderLinePyImp.cpp
DrawRichAnnoPy.xml
DrawRichAnnoPyImp.cpp
GeomFormatPy.xml
GeomFormatPyImp.cpp
CenterLinePy.xml
CenterLinePyImp.cpp
CosmeticEdgePy.xml
CosmeticEdgePyImp.cpp
CosmeticVertexPy.xml
CosmeticVertexPyImp.cpp
)
SOURCE_GROUP("Mod" FILES ${TechDraw_SRCS})

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PyObjectBase"
Name="CenterLinePy"
Twin="CenterLine"
TwinPointer="CenterLine"
Include="Mod/TechDraw/App/Cosmetic.h"
Namespace="TechDraw"
FatherInclude="Base/PyObjectBase.h"
FatherNamespace="Base"
Constructor="true"
Delete="true">
<Documentation>
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>CenterLine specifies appearance parameters for TechDraw Geometry objects</UserDocu>
</Documentation>
<Methode Name="clone" Const="true">
<Documentation>
<UserDocu>Create a clone of this centerline</UserDocu>
</Documentation>
</Methode>
<Methode Name="copy" Const="true">
<Documentation>
<UserDocu>Create a copy of this centerline</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,118 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
//# include <boost/uuid/uuid_io.hpp>
#endif
#include "Cosmetic.h"
#include "CenterLinePy.h"
#include "CenterLinePy.cpp"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string CenterLinePy::representation(void) const
{
return "<CenterLine object>";
}
PyObject *CenterLinePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// never create such objects with the constructor
PyErr_SetString(PyExc_RuntimeError,
"You cannot create an instance of the abstract class 'CenterLine'.");
return 0;
}
// constructor method
int CenterLinePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
{
return 0;
}
PyObject* CenterLinePy::clone(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
TechDraw::CenterLine* geom = this->getCenterLinePtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, 0);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create clone of CenterLine");
return 0;
}
TechDraw::CenterLinePy* geompy = static_cast<TechDraw::CenterLinePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CenterLine' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CenterLine* clone = static_cast<TechDraw::CenterLine*>(geompy->_pcTwinPointer);
delete clone;
}
geompy->_pcTwinPointer = geom->clone();
return cpy;
}
PyObject* CenterLinePy::copy(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
TechDraw::CenterLine* geom = this->getCenterLinePtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, 0);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create copy of CenterLine");
return 0;
}
TechDraw::CenterLinePy* geompy = static_cast<TechDraw::CenterLinePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CenterLine' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CenterLine* copy = static_cast<TechDraw::CenterLine*>(geompy->_pcTwinPointer);
delete copy;
}
geompy->_pcTwinPointer = geom->copy();
return cpy;
}
PyObject *CenterLinePy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int CenterLinePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -39,11 +39,19 @@
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <Base/Reader.h>
#include <Base/Tools.h>
#include <Base/Vector3D.h>
#include <Base/Writer.h>
#include <App/Application.h>
#include <App/Material.h>
#include <Mod/TechDraw/App/GeomFormatPy.h>
#include <Mod/TechDraw/App/CenterLinePy.h>
#include <Mod/TechDraw/App/CosmeticEdgePy.h>
#include <Mod/TechDraw/App/CosmeticVertexPy.h>
#include "DrawUtil.h"
#include "GeometryObject.h"
#include "Geometry.h"
@@ -75,10 +83,10 @@ LineFormat::LineFormat(int style,
void LineFormat::dump(char* title)
{
Base::Console().Message("LF::dump - %s \n",title);
Base::Console().Message("LF::dump - %s \n",toCSV().c_str());
Base::Console().Message("LF::dump - %s \n",toString().c_str());
}
std::string LineFormat::toCSV(void) const
std::string LineFormat::toString(void) const
{
std::stringstream ss;
ss << m_style << "," <<
@@ -88,24 +96,24 @@ std::string LineFormat::toCSV(void) const
return ss.str();
}
bool LineFormat::fromCSV(std::string& lineSpec)
{
unsigned int maxCells = 4;
if (lineSpec.length() == 0) {
Base::Console().Message( "LineFormat::fromCSV - lineSpec empty\n");
return false;
}
std::vector<std::string> values = DrawUtil::split(lineSpec);
if (values.size() < maxCells) {
Base::Console().Message( "LineFormat::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
return false;
}
m_style = atoi(values[0].c_str());
m_weight= atof(values[1].c_str());
m_color.fromHexString(values[2]);
m_visible = atoi(values[3].c_str());
return true;
}
//bool LineFormat::fromCSV(std::string& lineSpec)
//{
// unsigned int maxCells = 4;
// if (lineSpec.length() == 0) {
// Base::Console().Message( "LineFormat::fromCSV - lineSpec empty\n");
// return false;
// }
// std::vector<std::string> values = DrawUtil::split(lineSpec);
// if (values.size() < maxCells) {
// Base::Console().Message( "LineFormat::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
// return false;
// }
// m_style = atoi(values[0].c_str());
// m_weight= atof(values[1].c_str());
// m_color.fromHexString(values[2]);
// m_visible = atoi(values[3].c_str());
// return true;
//}
//static preference getters.
double LineFormat::getDefEdgeWidth()
@@ -139,6 +147,8 @@ int LineFormat::getDefEdgeStyle()
//****************************************************************************************
TYPESYSTEM_SOURCE(TechDraw::CosmeticVertex, Base::Persistence)
CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
{
point(Base::Vector3d(0.0, 0.0, 0.0));
@@ -154,6 +164,15 @@ CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
visible = true;
}
CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::Vertex(cv)
{
linkGeom = cv->linkGeom;
color = cv->color;
size = cv->size;
style = cv->style;
visible = cv->visible;
}
CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
@@ -169,7 +188,7 @@ CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
visible = true;
}
std::string CosmeticVertex::toCSV(void) const
std::string CosmeticVertex::toString(void) const
{
std::stringstream ss;
ss << point().x << "," <<
@@ -184,74 +203,144 @@ std::string CosmeticVertex::toCSV(void) const
return ss.str();
}
bool CosmeticVertex::fromCSV(std::string& lineSpec)
//bool CosmeticVertex::fromCSV(std::string& lineSpec)
//{
// unsigned int maxCells = 8;
// if (lineSpec.length() == 0) {
// Base::Console().Message( "CosmeticVertex::fromCSV - lineSpec empty\n");
// return false;
// }
// std::vector<std::string> values = DrawUtil::split(lineSpec);
// if (values.size() < maxCells) {
// Base::Console().Message( "CosmeticVertex::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
// return false;
// }
// double x = atof(values[0].c_str());
// double y = atof(values[1].c_str());
// double z = atof(values[2].c_str());
// point(Base::Vector3d (x,y,z));
// linkGeom = atoi(values[3].c_str());
// color.fromHexString(values[4]);
// size = atof(values[5].c_str());
// style = atoi(values[6].c_str());
// visible = atoi(values[7].c_str());
// return true;
//}
// Persistence implementers
unsigned int CosmeticVertex::getMemSize (void) const
{
unsigned int maxCells = 8;
if (lineSpec.length() == 0) {
Base::Console().Message( "CosmeticVertex::fromCSV - lineSpec empty\n");
return false;
}
std::vector<std::string> values = DrawUtil::split(lineSpec);
if (values.size() < maxCells) {
Base::Console().Message( "CosmeticVertex::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
return false;
}
double x = atof(values[0].c_str());
double y = atof(values[1].c_str());
double z = atof(values[2].c_str());
point(Base::Vector3d (x,y,z));
linkGeom = atoi(values[3].c_str());
color.fromHexString(values[4]);
size = atof(values[5].c_str());
style = atoi(values[6].c_str());
visible = atoi(values[7].c_str());
return true;
return 1;
}
void CosmeticVertex::Save(Base::Writer &writer) const
{
TechDraw::Vertex::Save(writer);
writer.Stream() << writer.ind() << "<LinkGeom value=\"" << linkGeom << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Color value=\"" << color.asHexString() << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Size value=\"" << size << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Style value=\"" << style << "\"/>" << endl;
const char v = visible?'1':'0';
writer.Stream() << writer.ind() << "<Visible value=\"" << v << "\"/>" << endl;
}
void CosmeticVertex::Restore(Base::XMLReader &reader)
{
TechDraw::Vertex::Restore(reader);
reader.readElement("LinkGeom");
linkGeom = reader.getAttributeAsInteger("value");
reader.readElement("Color");
std::string temp = reader.getAttribute("value");
color.fromHexString(temp);
reader.readElement("Size");
size = reader.getAttributeAsFloat("value");
reader.readElement("Style");
style = reader.getAttributeAsInteger("value");
reader.readElement("Visible");
visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
}
CosmeticVertex* CosmeticVertex::copy(void) const
{
// Base::Console().Message("CV::copy()\n");
CosmeticVertex* newCV = new CosmeticVertex(this);
return newCV;
}
CosmeticVertex* CosmeticVertex::clone(void) const
{
// Base::Console().Message("CV::clone()\n");
CosmeticVertex* cpy = this->copy();
return cpy;
}
PyObject* CosmeticVertex::getPyObject(void)
{
return new CosmeticVertexPy(new CosmeticVertex(this->copy()));
}
void CosmeticVertex::dump(char* title)
{
Base::Console().Message("CV::dump - %s \n",title);
Base::Console().Message("CV::dump - %s \n",toCSV().c_str());
Base::Console().Message("CV::dump - %s \n",toString().c_str());
}
//******************************************
TYPESYSTEM_SOURCE(TechDraw::CosmeticEdge,Base::Persistence)
//note this ctor has no occEdge or first/last point for geometry!
CosmeticEdge::CosmeticEdge()
{
// Base::Console().Message("CE::CE()\n");
m_geometry = new TechDraw::BaseGeom();
init();
initialize();
}
CosmeticEdge::CosmeticEdge(CosmeticEdge* ce)
{
// Base::Console().Message("CE::CE(ce)\n");
//if ce gets deleted later, this CE will have an invalid pointer to geometry!
//need to make our own copy of the geometry
TechDraw::BaseGeom* newGeom = ce->m_geometry->copy();
m_geometry = newGeom;
m_format = ce->m_format;
}
CosmeticEdge::CosmeticEdge(Base::Vector3d pt1, Base::Vector3d pt2)
{
// Base::Console().Message("CE::CE(p1,p2)\n");
Base::Vector3d p1 = DrawUtil::invertY(pt1);
Base::Vector3d p2 = DrawUtil::invertY(pt2);
gp_Pnt gp1(p1.x,p1.y,p1.z);
gp_Pnt gp2(p2.x,p2.y,p2.z);
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
m_geometry = TechDraw::BaseGeom::baseFactory(e);
init();
initialize();
}
CosmeticEdge::CosmeticEdge(TopoDS_Edge e)
{
// Base::Console().Message("CE::CE(TopoDS_Edge)\n");
m_geometry = TechDraw::BaseGeom::baseFactory(e);
init();
initialize();
}
CosmeticEdge::CosmeticEdge(TechDraw::BaseGeom* g)
{
// Base::Console().Message("CE::CE(bg)\n");
m_geometry = g;
init();
initialize();
}
CosmeticEdge::~CosmeticEdge(void)
{
delete m_geometry;
if (m_geometry != nullptr) {
delete m_geometry;
}
}
void CosmeticEdge::init(void)
void CosmeticEdge::initialize(void)
{
m_geometry->classOfEdge = ecHARD;
m_geometry->visible = true;
@@ -271,97 +360,180 @@ TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
return newGeom;
}
std::string CosmeticEdge::toCSV(void) const
std::string CosmeticEdge::toString(void) const
{
std::stringstream ss;
if (m_geometry != nullptr) {
ss << m_geometry->geomType <<
",$$$," <<
m_geometry->toCSV() <<
m_geometry->toString() <<
",$$$," <<
m_format.toCSV();
m_format.toString();
}
return ss.str();
}
bool CosmeticEdge::fromCSV(std::string& lineSpec)
{
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
if (tokens.empty()) {
Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - no tokens\n");
return false;
}
//bool CosmeticEdge::fromCSV(std::string& lineSpec)
//{
// std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
// if (tokens.empty()) {
// Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - no tokens\n");
// return false;
// }
if (tokens[0].length() == 0) {
Base::Console().Message( "CosmeticEdge::fromCSV - token0 empty\n");
return false;
}
std::vector<std::string> values = DrawUtil::split(tokens[0]);
unsigned int maxCells = 1;
if (values.size() < maxCells) {
Base::Console().Message( "CosmeticEdge::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
return false;
}
int geomType = atoi(values[0].c_str());
// if (tokens[0].length() == 0) {
// Base::Console().Message( "CosmeticEdge::fromCSV - token0 empty\n");
// return false;
// }
//
// std::vector<std::string> values = DrawUtil::split(tokens[0]);
// unsigned int maxCells = 1;
// if (values.size() < maxCells) {
// Base::Console().Message( "CosmeticEdge::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
// return false;
// }
// int geomType = atoi(values[0].c_str());
int lastToken = 0;
if (geomType == TechDraw::GeomType::GENERIC) {
if (tokens.size() != 4) {
Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
return false;
}
TechDraw::Generic* tempGeom = new TechDraw::Generic();
tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2]);
lastToken = 3;
m_geometry = tempGeom;
m_geometry->occEdge = GeometryUtils::edgeFromGeneric(tempGeom);
} else if (geomType == TechDraw::GeomType::CIRCLE) {
if (tokens.size() != 4) {
Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
return false;
}
TechDraw::Circle* tempGeom = new TechDraw::Circle();
tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2]);
lastToken = 3;
m_geometry = tempGeom;
m_geometry->occEdge = GeometryUtils::edgeFromCircle(tempGeom);
} else if (geomType == TechDraw::GeomType::ARCOFCIRCLE) {
if (tokens.size() != 5) {
Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
return false;
}
TechDraw::AOC* tempGeom = new TechDraw::AOC();
tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2] + ",$$$," + tokens[3]);
lastToken = 4;
m_geometry = tempGeom;
m_geometry->occEdge = GeometryUtils::edgeFromCircleArc(tempGeom);
} else {
Base::Console().Message("Cosmetic::fromCSV - unimplemented geomType: %d\n", geomType);
return false;
}
// int lastToken = 0;
// if (geomType == TechDraw::GeomType::GENERIC) {
// if (tokens.size() != 4) {
// Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
// return false;
// }
// TechDraw::Generic* tempGeom = new TechDraw::Generic();
// tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2]);
// lastToken = 3;
// m_geometry = tempGeom;
// m_geometry->occEdge = GeometryUtils::edgeFromGeneric(tempGeom);
// } else if (geomType == TechDraw::GeomType::CIRCLE) {
// if (tokens.size() != 4) {
// Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
// return false;
// }
// TechDraw::Circle* tempGeom = new TechDraw::Circle();
// tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2]);
// lastToken = 3;
// m_geometry = tempGeom;
// m_geometry->occEdge = GeometryUtils::edgeFromCircle(tempGeom);
// } else if (geomType == TechDraw::GeomType::ARCOFCIRCLE) {
// if (tokens.size() != 5) {
// Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
// return false;
// }
// TechDraw::AOC* tempGeom = new TechDraw::AOC();
// tempGeom->fromCSV(tokens[1] + ",$$$," + tokens[2] + ",$$$," + tokens[3]);
// lastToken = 4;
// m_geometry = tempGeom;
// m_geometry->occEdge = GeometryUtils::edgeFromCircleArc(tempGeom);
// } else {
// Base::Console().Message("Cosmetic::fromCSV - unimplemented geomType: %d\n", geomType);
// return false;
// }
m_format.fromCSV(tokens[lastToken]);
// m_format.fromCSV(tokens[lastToken]);
m_geometry->classOfEdge = ecHARD;
m_geometry->visible = true;
m_geometry->cosmetic = true;
return true;
}
void CosmeticEdge::replaceGeometry(TechDraw::BaseGeom* g)
{
delete m_geometry;
m_geometry = g;
}
// m_geometry->classOfEdge = ecHARD;
// m_geometry->visible = true;
// m_geometry->cosmetic = true;
// return true;
//}
void CosmeticEdge::dump(char* title)
{
Base::Console().Message("CE::dump - %s \n",title);
Base::Console().Message("CE::dump - %s \n",toCSV().c_str());
Base::Console().Message("CE::dump - %s \n",toString().c_str());
}
// Persistence implementers
unsigned int CosmeticEdge::getMemSize (void) const
{
return 1;
}
void CosmeticEdge::Save(Base::Writer &writer) const
{
writer.Stream() << writer.ind() << "<Style value=\"" << m_format.m_style << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Weight value=\"" << m_format.m_weight << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Color value=\"" << m_format.m_color.asHexString() << "\"/>" << endl;
const char v = m_format.m_visible?'1':'0';
writer.Stream() << writer.ind() << "<Visible value=\"" << v << "\"/>" << endl;
writer.Stream() << writer.ind() << "<GeometryType value=\"" << m_geometry->geomType <<"\"/>" << endl;
if (m_geometry->geomType == TechDraw::GeomType::GENERIC) {
Generic* gen = static_cast<Generic*>(m_geometry);
gen->Save(writer);
} else if (m_geometry->geomType == TechDraw::GeomType::CIRCLE) {
TechDraw::Circle* circ = static_cast<TechDraw::Circle*>(m_geometry);
circ->Save(writer);
} else if (m_geometry->geomType == TechDraw::GeomType::ARCOFCIRCLE) {
TechDraw::AOC* aoc = static_cast<TechDraw::AOC*>(m_geometry);
aoc->Save(writer);
} else {
Base::Console().Message("CE::Save - unimplemented geomType: %d\n", m_geometry->geomType);
}
}
void CosmeticEdge::Restore(Base::XMLReader &reader)
{
reader.readElement("Style");
m_format.m_style = reader.getAttributeAsInteger("value");
reader.readElement("Weight");
m_format.m_weight = reader.getAttributeAsFloat("value");
reader.readElement("Color");
std::string temp = reader.getAttribute("value");
m_format.m_color.fromHexString(temp);
reader.readElement("Visible");
m_format.m_visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("GeometryType");
TechDraw::GeomType gType = (TechDraw::GeomType)reader.getAttributeAsInteger("value");
if (gType == TechDraw::GeomType::GENERIC) {
TechDraw::Generic* gen = new TechDraw::Generic();
gen->Restore(reader);
gen->occEdge = GeometryUtils::edgeFromGeneric(gen);
m_geometry = (TechDraw::BaseGeom*) gen;
} else if (gType == TechDraw::GeomType::CIRCLE) {
TechDraw::Circle* circ = new TechDraw::Circle();
circ->Restore(reader);
circ->occEdge = GeometryUtils::edgeFromCircle(circ);
m_geometry = (TechDraw::BaseGeom*) circ;
} else if (gType == TechDraw::GeomType::ARCOFCIRCLE) {
TechDraw::AOC* aoc = new TechDraw::AOC();
aoc->Restore(reader);
aoc->occEdge = GeometryUtils::edgeFromCircleArc(aoc);
m_geometry = (TechDraw::BaseGeom*) aoc;
} else {
Base::Console().Message("CE::Restore - unimplemented geomType: %d\n", gType);
}
}
CosmeticEdge* CosmeticEdge::copy(void) const
{
// Base::Console().Message("CE::copy()\n");
CosmeticEdge* newCE = new CosmeticEdge();
TechDraw::BaseGeom* newGeom = m_geometry->copy();
newCE->m_geometry = newGeom;
newCE->m_format = m_format;
return newCE;
}
CosmeticEdge* CosmeticEdge::clone(void) const
{
// Base::Console().Message("CE::clone()\n");
CosmeticEdge* cpy = this->copy();
return cpy;
}
PyObject* CosmeticEdge::getPyObject(void)
{
return new CosmeticEdgePy(new CosmeticEdge(this->copy()));
}
//*********************************************************
TYPESYSTEM_SOURCE(TechDraw::CenterLine,Base::Persistence)
CenterLine::CenterLine(void)
{
m_start = Base::Vector3d(0.0, 0.0, 0.0);
@@ -373,6 +545,19 @@ CenterLine::CenterLine(void)
m_extendBy = 0.0;
}
CenterLine::CenterLine(CenterLine* cl)
{
m_start = cl->m_start;
m_end = cl->m_end;
m_mode = cl->m_mode;
m_hShift = cl->m_hShift;
m_vShift = cl->m_vShift;
m_rotate = cl->m_rotate;
m_extendBy = cl->m_extendBy;
m_faces = cl->m_faces;
m_format = cl->m_format;
}
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2)
{
m_start = p1;
@@ -398,6 +583,7 @@ CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2,
m_vShift = v;
m_rotate = r;
m_extendBy = x;
//m_faces = ??
}
CenterLine::~CenterLine()
@@ -432,21 +618,21 @@ TechDraw::BaseGeom* CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFeat)
return newGeom;
}
std::string CenterLine::toCSV(void) const
std::string CenterLine::toString(void) const
{
std::stringstream ss;
ss << m_start.x << "," << //0
m_start.y << "," << //1
m_start.z << "," << //2
m_end.x << "," << //3
m_end.y << "," << //4
m_end.z << "," << //5
m_mode << "," << //6
m_hShift << "," << //7
m_vShift << "," << //8
m_rotate << "," << //9
m_extendBy << "," << //10
m_faces.size(); //11
ss << m_start.x << "," <<
m_start.y << "," <<
m_start.z << "," <<
m_end.x << "," <<
m_end.y << "," <<
m_end.z << "," <<
m_mode << "," <<
m_hShift << "," <<
m_vShift << "," <<
m_rotate << "," <<
m_extendBy << "," <<
m_faces.size();
if (!m_faces.empty()) {
for (auto& f: m_faces) {
if (!f.empty()) {
@@ -456,56 +642,56 @@ std::string CenterLine::toCSV(void) const
}
std::string clCSV = ss.str();
std::string fmtCSV = m_format.toCSV();
std::string fmtCSV = m_format.toString();
return clCSV + ",$$$," + fmtCSV;
}
bool CenterLine::fromCSV(std::string& lineSpec)
{
if (lineSpec.length() == 0) {
Base::Console().Message( "CenterLine::fromCSV - lineSpec empty\n");
return false;
}
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
if (tokens.size() != 2) {
Base::Console().Message("CenterLine::fromCSV - tokenize failed - size: %d\n",tokens.size());
}
//bool CenterLine::fromCSV(std::string& lineSpec)
//{
// if (lineSpec.length() == 0) {
// Base::Console().Message( "CenterLine::fromCSV - lineSpec empty\n");
// return false;
// }
//
// std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
// if (tokens.size() != 2) {
// Base::Console().Message("CenterLine::fromCSV - tokenize failed - size: %d\n",tokens.size());
// }
if (tokens[0].length() == 0) {
Base::Console().Message( "CenterLine::fromCSV - token0 empty\n");
return false;
}
// if (tokens[0].length() == 0) {
// Base::Console().Message( "CenterLine::fromCSV - token0 empty\n");
// return false;
// }
std::vector<std::string> values = DrawUtil::split(tokens[0]);
// std::vector<std::string> values = DrawUtil::split(tokens[0]);
// variable length record, can't determine maxCells in advance.
double x = atof(values[0].c_str());
double y = atof(values[1].c_str());
double z = atof(values[2].c_str());
m_start = Base::Vector3d (x,y,z);
x = atof(values[3].c_str());
y = atof(values[4].c_str());
z = atof(values[5].c_str());
m_end = Base::Vector3d (x,y,z);
m_mode = atoi(values[6].c_str());
m_hShift = atof(values[7].c_str());
m_vShift = atof(values[8].c_str());
m_rotate = atof(values[9].c_str());
m_extendBy = atof(values[10].c_str());
int m_faceCount = atoi(values[11].c_str());
int i = 0;
for ( ; i < m_faceCount; i++ ) {
m_faces.push_back(values[12 + i]);
}
m_format.fromCSV(tokens[1]);
return true;
}
//// variable length record, can't determine maxCells in advance.
// double x = atof(values[0].c_str());
// double y = atof(values[1].c_str());
// double z = atof(values[2].c_str());
// m_start = Base::Vector3d (x,y,z);
// x = atof(values[3].c_str());
// y = atof(values[4].c_str());
// z = atof(values[5].c_str());
// m_end = Base::Vector3d (x,y,z);
// m_mode = atoi(values[6].c_str());
// m_hShift = atof(values[7].c_str());
// m_vShift = atof(values[8].c_str());
// m_rotate = atof(values[9].c_str());
// m_extendBy = atof(values[10].c_str());
// int m_faceCount = atoi(values[11].c_str());
// int i = 0;
// for ( ; i < m_faceCount; i++ ) {
// m_faces.push_back(values[12 + i]);
// }
// m_format.fromCSV(tokens[1]);
// return true;
//}
void CenterLine::dump(char* title)
{
Base::Console().Message("CL::dump - %s \n",title);
Base::Console().Message("CL::dump - %s \n",toCSV().c_str());
Base::Console().Message("CL::dump - %s \n",toString().c_str());
}
std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart* partFeat,
@@ -545,14 +731,10 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart
faceBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
double Xspan = fabs(Xmax - Xmin);
// Xspan = (Xspan / 2.0) + (ext * scale); //this should be right? edges in GO are scaled!
// Xspan = (Xspan / 2.0) + ext;
Xspan = (Xspan / 2.0);
double Xmid = Xmin + fabs(Xmax - Xmin) / 2.0;
double Yspan = fabs(Ymax - Ymin);
// Yspan = (Yspan / 2.0) + (ext * scale);
// Yspan = (Yspan / 2.0) + ext;
Yspan = (Yspan / 2.0);
double Ymid = Ymin + fabs(Ymax - Ymin) / 2.0;
@@ -595,6 +777,135 @@ std::pair<Base::Vector3d, Base::Vector3d> CenterLine::calcEndPoints(DrawViewPart
return result;
}
// Persistence implementers
unsigned int CenterLine::getMemSize (void) const
{
return 1;
}
void CenterLine::Save(Base::Writer &writer) const
{
writer.Stream() << writer.ind() << "<Start "
<< "X=\"" << m_start.x <<
"\" Y=\"" << m_start.y <<
"\" Z=\"" << m_start.z <<
"\"/>" << endl;
writer.Stream() << writer.ind() << "<End "
<< "X=\"" << m_end.x <<
"\" Y=\"" << m_end.y <<
"\" Z=\"" << m_end.z <<
"\"/>" << endl;
writer.Stream() << writer.ind() << "<Mode value=\"" << m_mode <<"\"/>" << endl;
writer.Stream() << writer.ind() << "<HShift value=\"" << m_hShift <<"\"/>" << endl;
writer.Stream() << writer.ind() << "<VShift value=\"" << m_vShift <<"\"/>" << endl;
writer.Stream() << writer.ind() << "<Rotate value=\"" << m_rotate <<"\"/>" << endl;
writer.Stream() << writer.ind() << "<Extend value=\"" << m_extendBy <<"\"/>" << endl;
writer.Stream()
<< writer.ind()
<< "<Faces "
<< "FaceCount=\"" << m_faces.size() <<
"\">" << endl;
writer.incInd();
for (auto& f: m_faces) {
writer.Stream()
<< writer.ind()
<< "<Face value=\"" << f <<"\"/>" << endl;
}
writer.decInd();
writer.Stream() << writer.ind() << "</Faces>" << endl ;
writer.Stream() << writer.ind() << "<Style value=\"" << m_format.m_style << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Weight value=\"" << m_format.m_weight << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Color value=\"" << m_format.m_color.asHexString() << "\"/>" << endl;
const char v = m_format.m_visible?'1':'0';
writer.Stream() << writer.ind() << "<Visible value=\"" << v << "\"/>" << endl;
}
void CenterLine::Restore(Base::XMLReader &reader)
{
// read my Element
reader.readElement("Start");
// get the value of my Attribute
m_start.x = reader.getAttributeAsFloat("X");
m_start.y = reader.getAttributeAsFloat("Y");
m_start.z = reader.getAttributeAsFloat("Z");
reader.readElement("End");
m_end.x = reader.getAttributeAsFloat("X");
m_end.y = reader.getAttributeAsFloat("Y");
m_end.z = reader.getAttributeAsFloat("Z");
reader.readElement("Mode");
m_mode = reader.getAttributeAsInteger("value");
reader.readElement("HShift");
m_hShift = reader.getAttributeAsFloat("value");
reader.readElement("VShift");
m_vShift = reader.getAttributeAsFloat("value");
reader.readElement("Rotate");
m_rotate = reader.getAttributeAsFloat("value");
reader.readElement("Extend");
m_extendBy = reader.getAttributeAsFloat("value");
reader.readElement("Faces");
int count = reader.getAttributeAsInteger("FaceCount");
int i = 0;
for ( ; i < count; i++) {
reader.readElement("Face");
std::string f = reader.getAttribute("value");
m_faces.push_back(f);
}
reader.readEndElement("Faces");
reader.readElement("Style");
m_format.m_style = reader.getAttributeAsInteger("value");
reader.readElement("Weight");
m_format.m_weight = reader.getAttributeAsFloat("value");
reader.readElement("Color");
std::string temp = reader.getAttribute("value");
m_format.m_color.fromHexString(temp);
reader.readElement("Visible");
m_format.m_visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
}
CenterLine* CenterLine::copy(void) const
{
CenterLine* newCL = new CenterLine();
newCL->m_start = m_start;
newCL->m_end = m_end;
newCL->m_mode = m_mode;
newCL->m_hShift = m_hShift;
newCL->m_vShift = m_vShift;
newCL->m_rotate = m_rotate;
newCL->m_extendBy = m_extendBy;
newCL->m_faces = m_faces;
newCL->m_format.m_style = m_format.m_style;
newCL->m_format.m_weight = m_format.m_weight;
newCL->m_format.m_color = m_format.m_color;
newCL->m_format.m_visible = m_format.m_visible;
return newCL;
}
CenterLine* CenterLine::clone(void) const
{
CenterLine* cpy = this->copy();
return cpy;
}
PyObject* CenterLine::getPyObject(void)
{
return new CenterLinePy(new CenterLine(this->copy()));
}
//------------------------------------------------------------------------------
TYPESYSTEM_SOURCE(TechDraw::GeomFormat,Base::Persistence)
GeomFormat::GeomFormat() :
m_geomIndex(-1)
{
@@ -604,6 +915,15 @@ GeomFormat::GeomFormat() :
m_format.m_visible = true;
}
GeomFormat::GeomFormat(GeomFormat* gf)
{
m_geomIndex = gf->m_geomIndex;
m_format.m_style = gf->m_format.m_style;
m_format.m_weight = gf->m_format.m_weight;
m_format.m_color = gf->m_format.m_color;
m_format.m_visible = gf->m_format.m_visible;
}
GeomFormat::GeomFormat(int idx,
TechDraw::LineFormat fmt) :
m_geomIndex(idx)
@@ -612,54 +932,111 @@ GeomFormat::GeomFormat(int idx,
m_format.m_weight = fmt.m_weight;
m_format.m_color = fmt.m_color;
m_format.m_visible = fmt.m_visible;
//m_format = fmt; //???
}
GeomFormat::~GeomFormat()
{
}
void GeomFormat::dump(char* title)
void GeomFormat::dump(char* title) const
{
Base::Console().Message("GF::dump - %s \n",title);
Base::Console().Message("GF::dump - %s \n",toCSV().c_str());
Base::Console().Message("GF::dump - %s \n",toString().c_str());
}
std::string GeomFormat::toCSV(void) const
std::string GeomFormat::toString(void) const
{
std::stringstream ss;
ss << m_geomIndex << ",$$$," <<
m_format.toCSV();
m_format.toString();
return ss.str();
}
bool GeomFormat::fromCSV(std::string& lineSpec)
//bool GeomFormat::fromCSV(std::string& lineSpec)
//{
// std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
// if (tokens.empty()) {
// Base::Console().Message("GeomFormat::fromCSV - tokenize failed - no tokens\n");
// return false;
// }
// if (tokens[0].length() == 0) {
// Base::Console().Message( "GeomFormat::fromCSV - token0 empty\n");
// return false;
// }
// std::vector<std::string> values = DrawUtil::split(tokens[0]);
// unsigned int maxCells = 1;
// if (values.size() < maxCells) {
// Base::Console().Message( "GeomFormat::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
// return false;
// }
// m_geomIndex = atoi(values[0].c_str());
// int lastToken = 1;
// if (tokens.size() != 2) {
// Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
// return false;
// }
// m_format.fromCSV(tokens[lastToken]);
// return true;
//}
// Persistence implementer
unsigned int GeomFormat::getMemSize (void) const
{
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
if (tokens.empty()) {
Base::Console().Message("GeomFormat::fromCSV - tokenize failed - no tokens\n");
return false;
}
if (tokens[0].length() == 0) {
Base::Console().Message( "GeomFormat::fromCSV - token0 empty\n");
return false;
}
std::vector<std::string> values = DrawUtil::split(tokens[0]);
unsigned int maxCells = 1;
if (values.size() < maxCells) {
Base::Console().Message( "GeomFormat::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
return false;
}
m_geomIndex = atoi(values[0].c_str());
int lastToken = 1;
if (tokens.size() != 2) {
Base::Console().Message("CE::fromCSV - wrong number of tokens\n");
return false;
}
m_format.fromCSV(tokens[lastToken]);
return true;
return 1;
}
void GeomFormat::Save(Base::Writer &writer) const
{
const char v = m_format.m_visible?'1':'0';
writer.Stream() << writer.ind() << "<GeomIndex value=\"" << m_geomIndex << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Style value=\"" << m_format.m_style << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Weight value=\"" << m_format.m_weight << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Color value=\"" << m_format.m_color.asHexString() << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Visible value=\"" << v << "\"/>" << endl;
}
void GeomFormat::Restore(Base::XMLReader &reader)
{
// read my Element
reader.readElement("GeomIndex");
// get the value of my Attribute
m_geomIndex = reader.getAttributeAsInteger("value");
reader.readElement("Style");
m_format.m_style = reader.getAttributeAsInteger("value");
reader.readElement("Weight");
m_format.m_weight = reader.getAttributeAsFloat("value");
reader.readElement("Color");
std::string temp = reader.getAttribute("value");
m_format.m_color.fromHexString(temp);
reader.readElement("Visible");
m_format.m_visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
}
GeomFormat* GeomFormat::copy(void) const
{
GeomFormat* newFmt = new GeomFormat();
newFmt->m_geomIndex = m_geomIndex;
newFmt->m_format.m_style = m_format.m_style;
newFmt->m_format.m_weight = m_format.m_weight;
newFmt->m_format.m_color = m_format.m_color;
newFmt->m_format.m_visible = m_format.m_visible;
return newFmt;
}
GeomFormat* GeomFormat::clone(void) const
{
GeomFormat* cpy = this->copy();
return cpy;
}
PyObject* GeomFormat::getPyObject(void)
{
return new GeomFormatPy(new GeomFormat(this->copy()));
}

View File

@@ -23,6 +23,9 @@
#ifndef TECHDRAW_COSMETIC_H
#define TECHDRAW_COSMETIC_H
#include <App/FeaturePython.h>
#include <Base/Persistence.h>
#include <Base/Vector3D.h>
#include <App/Material.h>
@@ -53,21 +56,33 @@ public:
static int getDefEdgeStyle();
void dump(char* title);
std::string toCSV() const;
bool fromCSV(std::string& lineSpec);
std::string toString() const;
/* bool fromCSV(std::string& lineSpec);*/
};
class TechDrawExport CosmeticVertex: public TechDraw::Vertex
class TechDrawExport CosmeticVertex: public Base::Persistence, public TechDraw::Vertex
{
TYPESYSTEM_HEADER();
public:
CosmeticVertex();
CosmeticVertex(const CosmeticVertex* cv);
CosmeticVertex(Base::Vector3d loc);
virtual ~CosmeticVertex() = default;
std::string toCSV(void) const;
bool fromCSV(std::string& lineSpec);
std::string toString(void) const;
/* bool fromCSV(std::string& lineSpec);*/
void dump(char* title);
// Persistence implementer ---------------------
virtual unsigned int getMemSize(void) const;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
virtual PyObject *getPyObject(void);
CosmeticVertex* copy(void) const;
CosmeticVertex* clone(void) const;
int linkGeom; //connection to corresponding "real" Vertex
App::Color color;
double size;
@@ -78,23 +93,33 @@ protected:
};
class TechDrawExport CosmeticEdge
class TechDrawExport CosmeticEdge : public Base::Persistence
{
TYPESYSTEM_HEADER();
public:
CosmeticEdge();
CosmeticEdge(CosmeticEdge* ce);
CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2);
CosmeticEdge(TopoDS_Edge e);
CosmeticEdge(TechDraw::BaseGeom* g);
virtual ~CosmeticEdge();
void init(void);
void initialize(void);
TechDraw::BaseGeom* scaledGeometry(double scale);
virtual std::string toCSV(void) const;
virtual bool fromCSV(std::string& lineSpec);
void replaceGeometry(TechDraw::BaseGeom* newGeom);
virtual std::string toString(void) const;
/* virtual bool fromCSV(std::string& lineSpec);*/
void dump(char* title);
// Persistence implementer ---------------------
virtual unsigned int getMemSize(void) const;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
virtual PyObject *getPyObject(void);
CosmeticEdge* copy(void) const;
CosmeticEdge* clone(void) const;
TechDraw::BaseGeom* m_geometry;
LineFormat m_format;
@@ -102,10 +127,14 @@ protected:
};
class TechDrawExport CenterLine
class TechDrawExport CenterLine: public Base::Persistence
{
TYPESYSTEM_HEADER();
public:
CenterLine();
CenterLine(CenterLine* cl);
//set m_faces after using next 2 ctors
CenterLine(Base::Vector3d p1, Base::Vector3d p2);
CenterLine(Base::Vector3d p1, Base::Vector3d p2,
int m,
@@ -113,11 +142,20 @@ public:
double v,
double r,
double x);
~CenterLine();
virtual ~CenterLine();
std::string toCSV(void) const;
bool fromCSV(std::string& lineSpec);
CosmeticEdge* toCosmeticEdge(TechDraw::DrawViewPart* partFeat); //??
// Persistence implementer ---------------------
virtual unsigned int getMemSize(void) const;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
virtual PyObject *getPyObject(void);
CenterLine* copy(void) const;
CenterLine* clone(void) const;
std::string toString(void) const;
/* bool fromCSV(std::string& lineSpec);*/
/* CosmeticEdge* toCosmeticEdge(TechDraw::DrawViewPart* partFeat); //??*/
TechDraw::BaseGeom* scaledGeometry(TechDraw::DrawViewPart* partFeat);
static std::pair<Base::Vector3d, Base::Vector3d> calcEndPoints(
TechDraw::DrawViewPart* partFeat,
@@ -136,26 +174,42 @@ public:
double m_rotate;
double m_extendBy;
LineFormat m_format;
protected:
};
class TechDrawExport GeomFormat
class TechDrawExport GeomFormat: public Base::Persistence
{
TYPESYSTEM_HEADER();
public:
GeomFormat();
GeomFormat(TechDraw::GeomFormat* gf);
GeomFormat(int idx,
LineFormat fmt);
~GeomFormat();
std::string toCSV(void) const;
bool fromCSV(std::string& lineSpec);
void dump(char* title);
// Persistence implementer ---------------------
virtual unsigned int getMemSize(void) const;
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
virtual PyObject *getPyObject(void);
GeomFormat* copy(void) const;
GeomFormat* clone(void) const;
std::string toString(void) const;
/* bool fromCSV(std::string& lineSpec);*/
void dump(char* title) const;
int m_geomIndex;
LineFormat m_format;
protected:
};
} //end namespace TechDraw
#endif //TECHDRAW_COSMETIC_H

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PyObjectBase"
Name="CosmeticEdgePy"
Twin="CosmeticEdge"
TwinPointer="CosmeticEdge"
Include="Mod/TechDraw/App/Cosmetic.h"
Namespace="TechDraw"
FatherInclude="Base/PyObjectBase.h"
FatherNamespace="Base"
Constructor="true"
Delete="true">
<Documentation>
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>CosmeticEdge specifies an extra (cosmetic) edge in Views</UserDocu>
</Documentation>
<Methode Name="clone" Const="true">
<Documentation>
<UserDocu>Create a clone of this CosmeticEdge</UserDocu>
</Documentation>
</Methode>
<Methode Name="copy" Const="true">
<Documentation>
<UserDocu>Create a copy of this CosmeticEdge</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,119 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 "Cosmetic.h"
#include "CosmeticEdgePy.h"
#include "CosmeticEdgePy.cpp"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string CosmeticEdgePy::representation(void) const
{
return "<CosmeticEdge object>";
}
PyObject *CosmeticEdgePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// never create such objects with the constructor
PyErr_SetString(PyExc_RuntimeError,
"You cannot create an instance of the abstract class 'CosmeticEdge'.");
return 0;
}
// constructor method
int CosmeticEdgePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
{
return 0;
}
PyObject* CosmeticEdgePy::clone(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
TechDraw::CosmeticEdge* geom = this->getCosmeticEdgePtr();
geom->dump("CEPYI::clone");
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, 0);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create clone of CosmeticEdge");
return 0;
}
TechDraw::CosmeticEdgePy* geompy = static_cast<TechDraw::CosmeticEdgePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CosmeticEdge' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CosmeticEdge* clone = static_cast<TechDraw::CosmeticEdge*>(geompy->_pcTwinPointer);
delete clone;
}
geompy->_pcTwinPointer = geom->clone();
return cpy;
}
PyObject* CosmeticEdgePy::copy(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
TechDraw::CosmeticEdge* geom = this->getCosmeticEdgePtr();
geom->dump("CEPYI::copy");
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, 0);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create copy of CosmeticEdge");
return 0;
}
TechDraw::CosmeticEdgePy* geompy = static_cast<TechDraw::CosmeticEdgePy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CosmeticEdge' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CosmeticEdge* copy = static_cast<TechDraw::CosmeticEdge*>(geompy->_pcTwinPointer);
delete copy;
}
geompy->_pcTwinPointer = geom->copy();
return cpy;
}
PyObject *CosmeticEdgePy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int CosmeticEdgePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PyObjectBase"
Name="CosmeticVertexPy"
Twin="CosmeticVertex"
TwinPointer="CosmeticVertex"
Include="Mod/TechDraw/App/Cosmetic.h"
Namespace="TechDraw"
FatherInclude="Base/PyObjectBase.h"
FatherNamespace="Base"
Constructor="true"
Delete="true">
<Documentation>
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>CosmeticVertex specifies an extra (cosmetic) vertex in Views</UserDocu>
</Documentation>
<Methode Name="clone" Const="true">
<Documentation>
<UserDocu>Create a clone of this CosmeticVertex</UserDocu>
</Documentation>
</Methode>
<Methode Name="copy" Const="true">
<Documentation>
<UserDocu>Create a copy of this CosmeticVertex</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,119 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* 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 "Cosmetic.h"
#include "CosmeticVertexPy.h"
#include "CosmeticVertexPy.cpp"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string CosmeticVertexPy::representation(void) const
{
return "<CosmeticVertex object>";
}
PyObject *CosmeticVertexPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// never create such objects with the constructor
PyErr_SetString(PyExc_RuntimeError,
"You cannot create an instance of the abstract class 'CosmeticVertex'.");
return 0;
}
// constructor method
int CosmeticVertexPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
{
return 0;
}
PyObject* CosmeticVertexPy::clone(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
TechDraw::CosmeticVertex* geom = this->getCosmeticVertexPtr();
geom->dump("CEPYI::clone");
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, 0);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create clone of CosmeticVertex");
return 0;
}
TechDraw::CosmeticVertexPy* geompy = static_cast<TechDraw::CosmeticVertexPy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CosmeticVertex' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CosmeticVertex* clone = static_cast<TechDraw::CosmeticVertex*>(geompy->_pcTwinPointer);
delete clone;
}
geompy->_pcTwinPointer = geom->clone();
return cpy;
}
PyObject* CosmeticVertexPy::copy(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
TechDraw::CosmeticVertex* geom = this->getCosmeticVertexPtr();
geom->dump("CEPYI::copy");
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, 0);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create copy of CosmeticVertex");
return 0;
}
TechDraw::CosmeticVertexPy* geompy = static_cast<TechDraw::CosmeticVertexPy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'CosmeticVertex' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::CosmeticVertex* copy = static_cast<TechDraw::CosmeticVertex*>(geompy->_pcTwinPointer);
delete copy;
}
geompy->_pcTwinPointer = geom->copy();
return cpy;
}
PyObject *CosmeticVertexPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int CosmeticVertexPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -347,11 +347,8 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute(void)
return new App::DocumentObjectExecReturn(e1.GetMessageString());
}
//add back the cosmetic vertices
for (auto& v: CVertexTable) {
int idx = geometryObject->addCosmeticVertex(v->point() * getScale());
v->linkGeom = idx;
}
//add the cosmetic vertices to the geometry vertices list
addCosmeticVertexesToGeom();
//add the cosmetic Edges to geometry Edges list
addCosmeticEdgesToGeom();
//add centerlines to geometry edges list

View File

@@ -1135,6 +1135,28 @@ std::string DrawViewDimension::getDefaultFormatSpec() const
return Base::Tools::toStdString(formatSpec);
}
//! is refName a target of this Dim (2D references)
bool DrawViewDimension::references(std::string refName) const
{
Base::Console().Message("DVD::references(%s) - %s\n",refName.c_str(),getNameInDocument());
bool result = false;
const std::vector<App::DocumentObject*> &objects = References2D.getValues();
if (!objects.empty()) {
const std::vector<std::string> &subElements = References2D.getSubValues();
if (!subElements.empty()) {
for (auto& s: subElements) {
if (!s.empty()) {
if (s == refName) {
result = true;
break;
}
}
}
}
}
return result;
}
PyObject *DrawViewDimension::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {

View File

@@ -137,6 +137,7 @@ public:
arcPoints getArcPoints(void) {return m_arcPoints; }
anglePoints getAnglePoints(void) {return m_anglePoints; }
bool leaderIntersectsArc(Base::Vector3d s, Base::Vector3d pointOnCircle);
bool references(std::string geomName) const;
protected:
void onChanged(const App::Property* prop);

View File

@@ -149,16 +149,10 @@ 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(CosmeticVertexList ,(""),sgroup,App::Prop_None,"CosmeticVertex Save/Restore");
ADD_PROPERTY_TYPE(CosmeticEdgeList ,(""),sgroup,App::Prop_None,"CosmeticEdge Save/Restore");
ADD_PROPERTY_TYPE(CenterLineList ,(""),sgroup,App::Prop_None,"CenterLine Save/Restore");
ADD_PROPERTY_TYPE(GeomFormatList ,(""),sgroup,App::Prop_None,"Geometry format Save/Restore");
std::vector<std::string> emptyList;
CosmeticVertexList.setValues(emptyList);
CosmeticEdgeList.setValues(emptyList);
CenterLineList.setValues(emptyList);
GeomFormatList.setValues(emptyList);
ADD_PROPERTY_TYPE(CosmeticVertexes ,(0),sgroup,App::Prop_None,"CosmeticVertex Save/Restore");
ADD_PROPERTY_TYPE(CosmeticEdges ,(0),sgroup,App::Prop_None,"CosmeticEdge Save/Restore");
ADD_PROPERTY_TYPE(CenterLines ,(0),sgroup,App::Prop_None,"Geometry format Save/Restore");
ADD_PROPERTY_TYPE(GeomFormats ,(0),sgroup,App::Prop_None,"Geometry format Save/Restore");
geometryObject = nullptr;
getRunControl();
@@ -346,15 +340,13 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
}
}
//add back the cosmetic vertices
for (auto& v: CVertexTable) {
int idx = geometryObject->addCosmeticVertex(v->point() * getScale());
v->linkGeom = idx;
}
//add the cosmetic vertices to the geometry vertices list
addCosmeticVertexesToGeom();
//add the cosmetic Edges to geometry Edges list
addCosmeticEdgesToGeom();
//add centerlines to geometry edges list
addCenterLinesToGeom();
auto end = chrono::high_resolution_clock::now();
auto diff = end - start;
double diffOut = chrono::duration <double, milli> (diff).count();
@@ -956,134 +948,95 @@ bool DrawViewPart::isIso(void) const
//********
//* Cosmetics
//********
//build CVertexTable from CosmeticVertexList
void DrawViewPart::readCVertexProp(void)
void DrawViewPart::clearCosmeticVertexes(void)
{
CVertexTable.clear();
std::vector<std::string> restoreVerts = CosmeticVertexList.getValues();
if (restoreVerts.empty()) {
return;
}
for (auto& rv: restoreVerts) {
if (!rv.empty()) {
CosmeticVertex* cv = new CosmeticVertex();
bool rc = cv->fromCSV(rv);
if (rc) {
CVertexTable.push_back(cv);
} else {
delete cv;
}
}
}
std::vector<CosmeticVertex*> noVerts;
CosmeticVertexes.setValues(noVerts);
}
//build CEdgeTable from CosmeticEdgeList
void DrawViewPart::readCEdgeProp(void)
{
CEdgeTable.clear();
std::vector<std::string> restoreEdges = CosmeticEdgeList.getValues();
if (restoreEdges.empty()) {
return;
}
for (auto& re: restoreEdges) {
if (!re.empty()) {
CosmeticEdge* ce = new CosmeticEdge();
bool rc = ce->fromCSV(re);
if (rc) {
CEdgeTable.push_back(ce);
} else {
delete ce;
}
}
}
}
//build CLineTable from CenterLineList
void DrawViewPart::readCLineProp(void)
{
CLineTable.clear();
std::vector<std::string> restoreLines = CenterLineList.getValues();
if (restoreLines.empty()) {
return;
}
for (auto& rl: restoreLines) {
if (!rl.empty()) {
CenterLine* cl = new CenterLine();
bool rc = cl->fromCSV(rl);
if (rc) {
CLineTable.push_back(cl);
} else {
delete cl;
}
}
}
}
// adds a cosmetic vertex to CVertexTable and CosmeticVertexList
int DrawViewPart::addCosmeticVertex(Base::Vector3d pos)
{
TechDraw::CosmeticVertex* cv = new TechDraw::CosmeticVertex(pos);
int newIdx = (int) (CVertexTable.size());
CVertexTable.push_back(cv);
std::string csv = cv->toCSV();
std::vector<std::string> vertexList = CosmeticVertexList.getValues();
vertexList.push_back(csv);
CosmeticVertexList.setValues(vertexList);
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;
}
void DrawViewPart::writeCVertProp(void)
int DrawViewPart::addCosmeticVertex(CosmeticVertex* cv)
{
std::vector<std::string> saveVerts;
const std::vector<TechDraw::CosmeticVertex*> cosVerts = getCosmeticVertex();
for (auto& cv: cosVerts) {
std::string csv = cv->toCSV();
saveVerts.push_back(csv);
}
CosmeticVertexList.setValues(saveVerts);
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(cv)\n");
bool found = false;
std::vector<TechDraw::CosmeticVertex*> newCosmoVertex;
for (auto& v: CVertexTable) {
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;
continue;
} else {
newCosmoVertex.push_back(v);
break;
}
}
if ( (cv != nullptr) &&
(found) ) {
delete cv;
removeCosmeticVertex(i);
}
CVertexTable = newCosmoVertex;
writeCVertProp();
recomputeFeature();
}
void DrawViewPart::removeCosmeticVertex(int idx)
{
if (idx < (int) CVertexTable.size()) {
TechDraw::CosmeticVertex* cvSave = CVertexTable.at(idx);
CVertexTable.erase(CVertexTable.begin() + idx);
delete cvSave;
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
if (idx < (int) verts.size()) {
verts.erase(verts.begin() + idx);
CosmeticVertexes.setValues(verts);
recomputeFeature();
}
}
void DrawViewPart::replaceCosmeticVertex(int idx, TechDraw::CosmeticVertex* cv)
{
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
if (idx < (int) verts.size()) {
verts.at(idx) = cv;
recomputeFeature();
}
}
void DrawViewPart::replaceCosmeticVertexByGeom(int geomIndex, TechDraw::CosmeticVertex* cl)
{
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
int stop = (int) verts.size();
int i = 0;
bool found = false;
if (geomIndex > -1) {
for ( ; i < stop; i++ ) {
if (verts.at(i)->linkGeom == geomIndex) {
found = true;
break;
}
}
if (found) {
replaceCosmeticVertex(i, cl);
}
}
writeCVertProp();
recomputeFeature();
}
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByIndex(int idx) const
{
CosmeticVertex* result = nullptr;
const std::vector<TechDraw::CosmeticVertex*> verts = getCosmeticVertex();
if ((unsigned) idx < verts.size()) {
const std::vector<TechDraw::CosmeticVertex*> verts = CosmeticVertexes.getValues();
if (idx < (int) verts.size()) {
result = verts.at(idx);
}
return result;
@@ -1093,123 +1046,115 @@ TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByIndex(int idx) const
TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByGeom(int idx) const
{
CosmeticVertex* result = nullptr;
const std::vector<TechDraw::CosmeticVertex*> verts = getCosmeticVertex();
for (auto& cv: verts) {
if (cv->linkGeom == idx) {
result = cv;
break;
std::vector<CosmeticVertex*> verts = CosmeticVertexes.getValues();
int stop = (int) verts.size();
int i = 0;
bool found = false;
if (idx > -1) {
for ( ; i < stop; i++ ) {
if (verts.at(i)->linkGeom == idx) {
found = true;
break;
}
}
if (found) {
result = verts.at(i);
}
}
return result;
}
void DrawViewPart::clearCosmeticVertices(void)
//add the cosmetic verts to geometry vertex list
void DrawViewPart::addCosmeticVertexesToGeom(void)
{
CVertexTable.clear();
std::vector<std::string> noVerts;
CosmeticVertexList.setValues(noVerts);
int i = 0;
const std::vector<TechDraw::CosmeticVertex*> verts = CosmeticVertexes.getValues();
int stop = (int) verts.size();
for ( ; i < stop; i++) {
int idx = geometryObject->addCosmeticVertex((verts.at(i)->point()) * getScale(), i);
verts.at(i)->linkGeom = idx;
}
}
//CosmeticEdges -------------------------------------------------------------------
void DrawViewPart::clearCosmeticEdges(void)
{
CEdgeTable.clear();
std::vector<std::string> noEdges;
CosmeticEdgeList.setValues(noEdges);
std::vector<CosmeticEdge*> noEdges;
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
CosmeticEdges.setValues(noEdges);
for (auto& e: edges) {
delete e;
}
}
// adds a cosmetic edge to CEdgeTable and CosmeticEdgeList
int DrawViewPart::addCosmeticEdge(Base::Vector3d p1, Base::Vector3d p2)
{
// Base::Console().Message("DVP::addCosmeticEdge(p1,p2)\n");
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(p1, p2);
int newIdx = (int) (CEdgeTable.size());
CEdgeTable.push_back(ce);
std::string csv = ce->toCSV();
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
edgeList.push_back(csv);
CosmeticEdgeList.setValues(edgeList);
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
int newIdx = (int) (edges.size());
edges.push_back(ce);
CosmeticEdges.setValues(edges);
return newIdx;
}
int DrawViewPart::addCosmeticEdge(TopoDS_Edge e)
{
// Base::Console().Message("DVP::addCosmeticEdge(p1,p2)\n");
TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(e);
int newIdx = (int) (CEdgeTable.size());
CEdgeTable.push_back(ce);
std::string csv = ce->toCSV();
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
edgeList.push_back(csv);
CosmeticEdgeList.setValues(edgeList);
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
int newIdx = (int) (edges.size());
edges.push_back(ce);
CosmeticEdges.setValues(edges);
return newIdx;
}
int DrawViewPart::addCosmeticEdge(CosmeticEdge* ce)
{
int newIdx = (int) (CEdgeTable.size());
CEdgeTable.push_back(ce);
std::string csv = ce->toCSV();
std::vector<std::string> edgeList = CosmeticEdgeList.getValues();
edgeList.push_back(csv);
CosmeticEdgeList.setValues(edgeList);
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
int newIdx = (int) (edges.size());
edges.push_back(ce);
CosmeticEdges.setValues(edges);
return newIdx;
}
void DrawViewPart::writeCEdgeProp(void)
{
std::vector<std::string> saveEdges;
const std::vector<TechDraw::CosmeticEdge*> cosEdges = getCosmeticEdges();
for (auto& ce: cosEdges) {
std::string csv = ce->toCSV();
saveEdges.push_back(csv);
}
CosmeticEdgeList.setValues(saveEdges);
}
void DrawViewPart::removeCosmeticEdge(TechDraw::CosmeticEdge* ce)
{
bool found = false;
std::vector<TechDraw::CosmeticEdge*> newCosmoEdge;
for (auto& e: CEdgeTable) {
int i = 0;
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
int stop = edges.size();
for ( ; i < stop; i++) {
TechDraw::CosmeticEdge* e = edges.at(i);
if (ce == e) {
found = true;
continue;
} else {
newCosmoEdge.push_back(e);
break;
}
}
if ( (ce != nullptr) &&
(found) ) {
delete ce;
removeCosmeticEdge(i);
}
CEdgeTable = newCosmoEdge;
writeCEdgeProp();
recomputeFeature();
}
void DrawViewPart::removeCosmeticEdge(int idx)
{
if (idx < (int) CEdgeTable.size()) {
TechDraw::CosmeticEdge* ceSave = CEdgeTable.at(idx);
CEdgeTable.erase(CEdgeTable.begin() + idx);
delete ceSave;
writeCEdgeProp();
recomputeFeature();
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
if (idx < (int) edges.size()) {
edges.erase(edges.begin() + idx);
CosmeticEdges.setValues(edges);
recomputeFeature(); //execute needs to run to replace Geoms
}
}
void DrawViewPart::replaceCosmeticEdge(int idx, TechDraw::CosmeticEdge* ce)
{
std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdges();
std::vector<CosmeticEdge*> edges = CosmeticEdges.getValues();
if (idx < (int) edges.size()) {
edges.at(idx) = ce;
//TODO: GC old ce
writeCEdgeProp();
CosmeticEdges.setValues(edges);
recomputeFeature();
}
}
@@ -1217,14 +1162,16 @@ void DrawViewPart::replaceCosmeticEdge(int idx, TechDraw::CosmeticEdge* ce)
void DrawViewPart::replaceCosmeticEdgeByGeom(int geomIndex, TechDraw::CosmeticEdge* ce)
{
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
//TODO: check that geom has m_source == cosmetic
int sourceIndex = geoms.at(geomIndex)->sourceIndex();
replaceCosmeticEdge(sourceIndex, ce);
}
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByIndex(int idx) const
{
// Base::Console().Message("DVP::getCosmeticEdgeByIndex(%d)\n",idx);
CosmeticEdge* result = nullptr;
const std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdges();
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
if (idx < (int) edges.size()) {
result = edges.at(idx);
}
@@ -1234,10 +1181,11 @@ TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByIndex(int idx) const
//find the cosmetic edge corresponding to geometry edge idx
TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByGeom(int idx) const
{
CosmeticEdge* result = nullptr;
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
int sourceIndex = geoms.at(idx)->sourceIndex();
result = CEdgeTable.at(sourceIndex);
CosmeticEdge* result = nullptr;
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
result = edges.at(sourceIndex);
return result;
}
@@ -1245,7 +1193,7 @@ TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByGeom(int idx) const
int DrawViewPart::getCosmeticEdgeIndex(TechDraw::CosmeticEdge* ce) const
{
int result = -1;
const std::vector<TechDraw::CosmeticEdge*> edges = getCosmeticEdges();
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
int i = 0;
int stop = (int) edges.size();
for (; i < stop; i++) {
@@ -1257,43 +1205,51 @@ int DrawViewPart::getCosmeticEdgeIndex(TechDraw::CosmeticEdge* ce) const
return result;
}
//add the cosmetic edges to geometry Edges list
void DrawViewPart::addCosmeticEdgesToGeom(void)
{
int i = 0;
const std::vector<TechDraw::CosmeticEdge*> edges = CosmeticEdges.getValues();
int stop = (int) edges.size();
for ( ; i < stop; i++) {
TechDraw::BaseGeom* scaledGeom = edges.at(i)->scaledGeometry(getScale());
if (scaledGeom == nullptr) {
Base::Console().Message("DVP::addCosmeticEdgesToGeom - scaledGeometry is null\n");
continue;
}
// int idx =
(void) geometryObject->addCosmeticEdge(scaledGeom, 1, i);
}
}
// CenterLines -----------------------------------------------------------------
void DrawViewPart::clearCenterLines(void)
{
CLineTable.clear();
std::vector<std::string> noLines;
CenterLineList.setValues(noLines);
std::vector<CenterLine*> noLines;
std::vector<CenterLine*> lines = CenterLines.getValues();
CenterLines.setValues(noLines);
for (auto& l: lines) {
delete l;
}
}
// adds a centerLine edge to CLineTable and CenterLineList
int DrawViewPart::addCenterLine(CenterLine* cl)
{
int newIdx = (int) (CLineTable.size());
CLineTable.push_back(cl);
std::string csv = cl->toCSV();
std::vector<std::string> lineList = CenterLineList.getValues();
lineList.push_back(csv);
CenterLineList.setValues(lineList);
std::vector<CenterLine*> lines = CenterLines.getValues();
int newIdx = (int) lines.size();
lines.push_back(cl);
CenterLines.setValues(lines);
return newIdx;
}
void DrawViewPart::writeCLineProp(void)
{
std::vector<std::string> saveLines;
const std::vector<TechDraw::CenterLine*> cLines = getCenterLines();
for (auto& cl: cLines) {
std::string csv = cl->toCSV();
saveLines.push_back(csv);
}
CenterLineList.setValues(saveLines);
}
void DrawViewPart::removeCenterLine(TechDraw::CenterLine* cl)
{
bool found = false;
int i = 0;
int stop = CLineTable.size();
std::vector<CenterLine*> lines = CenterLines.getValues();
int stop = lines.size();
for ( ; i < stop; i++) {
TechDraw::CenterLine* l = CLineTable.at(i);
TechDraw::CenterLine* l = lines.at(i);
if (cl == l) {
found = true;
break;
@@ -1307,19 +1263,19 @@ void DrawViewPart::removeCenterLine(TechDraw::CenterLine* cl)
void DrawViewPart::removeCenterLine(int idx)
{
if (idx < (int) CLineTable.size()) {
CLineTable.erase(CLineTable.begin() + idx);
writeCLineProp();
std::vector<CenterLine*> lines = CenterLines.getValues();
if (idx < (int) lines.size()) {
lines.erase(lines.begin() + idx);
CenterLines.setValues(lines);
recomputeFeature();
}
}
void DrawViewPart::replaceCenterLine(int idx, TechDraw::CenterLine* cl)
{
std::vector<TechDraw::CenterLine*> lines = getCenterLines();
std::vector<CenterLine*> lines = CenterLines.getValues();
if (idx < (int) lines.size()) {
lines.at(idx) = cl;
writeCLineProp();
recomputeFeature();
}
}
@@ -1334,7 +1290,7 @@ void DrawViewPart::replaceCenterLineByGeom(int geomIndex, TechDraw::CenterLine*
TechDraw::CenterLine* DrawViewPart::getCenterLineByIndex(int idx) const
{
CenterLine* result = nullptr;
const std::vector<TechDraw::CenterLine*> lines = getCenterLines();
const std::vector<TechDraw::CenterLine*> lines = CenterLines.getValues();
if (idx < (int) lines.size()) {
result = lines.at(idx);
}
@@ -1347,32 +1303,19 @@ TechDraw::CenterLine* DrawViewPart::getCenterLineByGeom(int idx) const
const std::vector<TechDraw::BaseGeom*> &geoms = getEdgeGeometry();
int sourceIndex = geoms.at(idx)->sourceIndex();
CenterLine* result = nullptr;
const std::vector<TechDraw::CenterLine*> lines = getCenterLines();
const std::vector<TechDraw::CenterLine*> lines = CenterLines.getValues();
result = lines.at(sourceIndex);
return result;
}
//add the cosmetic Edges to geometry Edges list
void DrawViewPart::addCosmeticEdgesToGeom(void)
{
int i = 0;
for ( ; i < (int) CEdgeTable.size(); i++) {
TechDraw::BaseGeom* scaledGeom = CEdgeTable.at(i)->scaledGeometry(getScale());
if (scaledGeom == nullptr) {
Base::Console().Message("DVP::addCosmeticEdgesToGeom - scaledGeometry is null\n");
continue;
}
// int idx =
(void) geometryObject->addCosmeticEdge(scaledGeom, 1, i);
}
}
//add the center lines to geometry Edges list
void DrawViewPart::addCenterLinesToGeom(void)
{
int i = 0;
for ( ; i < (int) CLineTable.size(); i++) {
TechDraw::BaseGeom* scaledGeom = CLineTable.at(i)->scaledGeometry(this);
const std::vector<TechDraw::CenterLine*> lines = CenterLines.getValues();
int stop = (int) lines.size();
for ( ; i < stop; i++) {
TechDraw::BaseGeom* scaledGeom = lines.at(i)->scaledGeometry(this);
if (scaledGeom == nullptr) {
Base::Console().Message("DVP::addCenterLinesToGeom - scaledGeometry is null\n");
continue;
@@ -1382,62 +1325,35 @@ void DrawViewPart::addCenterLinesToGeom(void)
}
}
//build GFormatTable from GeomFormatList
void DrawViewPart::readGFormatProp(void)
{
GFormatTable.clear();
std::vector<std::string> restoreFormats = GeomFormatList.getValues();
if (restoreFormats.empty()) {
return;
}
for (auto& rf: restoreFormats) {
if (!rf.empty()) {
GeomFormat* gf = new GeomFormat();
bool rc = gf->fromCSV(rf);
if (rc) {
GFormatTable.push_back(gf);
} else {
delete gf;
}
}
}
}
void DrawViewPart::writeGFormatProp(void)
{
std::vector<std::string> saveFormats;
const std::vector<TechDraw::GeomFormat*> gForms = getGeomFormats();
for (auto& gf: gForms) {
std::string csv = gf->toCSV();
saveFormats.push_back(csv);
}
GeomFormatList.setValues(saveFormats);
}
// GeomFormats -----------------------------------------------------------------
void DrawViewPart::clearGeomFormats(void)
{
GFormatTable.clear();
std::vector<std::string> noFormats;
GeomFormatList.setValues(noFormats);
std::vector<GeomFormat*> noFormats;
std::vector<GeomFormat*> fmts = GeomFormats.getValues();
GeomFormats.setValues(noFormats);
for (auto& f: fmts) {
delete f;
}
}
// adds a GeomFormat to GFormatTable and GeomFormatList
int DrawViewPart::addGeomFormat(GeomFormat* gf)
{
int newIdx = (int) (GFormatTable.size());
GFormatTable.push_back(gf);
std::string csv = gf->toCSV();
std::vector<std::string> formatList = GeomFormatList.getValues();
formatList.push_back(csv);
GeomFormatList.setValues(formatList);
std::vector<GeomFormat*> fmts = GeomFormats.getValues();
int newIdx = (int) fmts.size();
fmts.push_back(gf);
GeomFormats.setValues(fmts);
return newIdx;
}
void DrawViewPart::removeGeomFormat(int idx)
{
if (idx < (int) GFormatTable.size()) {
GFormatTable.erase(GFormatTable.begin() + idx);
writeGFormatProp();
std::vector<GeomFormat*> fmts = GeomFormats.getValues();
if (idx < (int) fmts.size()) {
GeomFormat* toRemove = fmts[idx];
fmts.erase(fmts.begin() + idx);
GeomFormats.setValues(fmts);
delete toRemove;
requestPaint();
}
}
@@ -1445,7 +1361,7 @@ void DrawViewPart::removeGeomFormat(int idx)
TechDraw::GeomFormat* DrawViewPart::getGeomFormatByIndex(int idx) const
{
GeomFormat* result = nullptr;
const std::vector<TechDraw::GeomFormat*> fmts = getGeomFormats();
const std::vector<TechDraw::GeomFormat*> fmts = GeomFormats.getValues();
if (idx < (int) fmts.size()) {
result = fmts.at(idx);
}
@@ -1456,7 +1372,7 @@ TechDraw::GeomFormat* DrawViewPart::getGeomFormatByIndex(int idx) const
TechDraw::GeomFormat* DrawViewPart::getGeomFormatByGeom(int idx) const
{
GeomFormat* result = nullptr;
const std::vector<TechDraw::GeomFormat*> fmts = getGeomFormats();
const std::vector<TechDraw::GeomFormat*> fmts = GeomFormats.getValues();
for (auto& f: fmts) {
if (f->m_geomIndex == idx) {
result = f;
@@ -1468,13 +1384,9 @@ TechDraw::GeomFormat* DrawViewPart::getGeomFormatByGeom(int idx) const
void DrawViewPart::onDocumentRestored()
{
readCVertexProp();
readCEdgeProp();
readCLineProp();
readGFormatProp();
// requestPaint();
//if execute has not run yet, there will be no GO, and paint will not do anything.
execute();
recomputeFeature();
DrawView::onDocumentRestored();
}
@@ -1487,7 +1399,6 @@ PyObject *DrawViewPart::getPyObject(void)
return Py::new_reference_to(PythonObject);
}
// Python Drawing feature ---------------------------------------------------------
namespace App {

View File

@@ -37,6 +37,10 @@
#include <Base/BoundBox.h>
#include "PropertyGeomFormatList.h"
#include "PropertyCenterLineList.h"
#include "PropertyCosmeticEdgeList.h"
#include "PropertyCosmeticVertexList.h"
#include "DrawView.h"
class gp_Pnt;
@@ -105,10 +109,10 @@ public:
App::PropertyBool IsoHidden;
App::PropertyInteger IsoCount;
App::PropertyStringList CosmeticVertexList;
App::PropertyStringList CosmeticEdgeList;
App::PropertyStringList CenterLineList;
App::PropertyStringList GeomFormatList;
TechDraw::PropertyCosmeticVertexList CosmeticVertexes;
TechDraw::PropertyCosmeticEdgeList CosmeticEdges;
TechDraw::PropertyCenterLineList CenterLines;
TechDraw::PropertyGeomFormatList GeomFormats;
virtual short mustExecute() const;
virtual void onDocumentRestored() override;
@@ -123,8 +127,6 @@ public:
std::vector<TechDraw::DrawViewDimension*> getDimensions() const;
std::vector<TechDraw::DrawViewBalloon*> getBalloons() const;
//TODO: are there use-cases for Python access to TechDraw???
const std::vector<TechDraw::Vertex *> & getVertexGeometry() const;
const std::vector<TechDraw::BaseGeom *> & getEdgeGeometry() const;
const std::vector<TechDraw::BaseGeom *> getVisibleFaceEdges() const;
@@ -165,46 +167,41 @@ public:
bool isIso(void) const;
virtual int addCosmeticVertex(Base::Vector3d pos);
virtual void writeCVertProp(void);
virtual int addCosmeticVertex(CosmeticVertex* cv);
virtual void removeCosmeticVertex(TechDraw::CosmeticVertex* cv);
virtual void removeCosmeticVertex(int idx);
const std::vector<TechDraw::CosmeticVertex*> & getCosmeticVertex(void) const { return CVertexTable; }
void replaceCosmeticVertex(int idx, TechDraw::CosmeticVertex* cv);
void replaceCosmeticVertexByGeom(int geomIndex, TechDraw::CosmeticVertex* cl);
TechDraw::CosmeticVertex* getCosmeticVertexByIndex(int idx) const;
TechDraw::CosmeticVertex* getCosmeticVertexByGeom(int idx) const;
void clearCosmeticVertices(void);
void clearCosmeticVertexes(void);
void addCosmeticVertexesToGeom(void);
virtual int addCosmeticEdge(Base::Vector3d start, Base::Vector3d end);
virtual int addCosmeticEdge(TopoDS_Edge e);
virtual int addCosmeticEdge(TechDraw::CosmeticEdge*);
virtual void writeCEdgeProp(void);
virtual void removeCosmeticEdge(TechDraw::CosmeticEdge* ce);
virtual void removeCosmeticEdge(int idx);
const std::vector<TechDraw::CosmeticEdge*> & getCosmeticEdges(void) const { return CEdgeTable; }
TechDraw::CosmeticEdge* getCosmeticEdgeByIndex(int idx) const;
TechDraw::CosmeticEdge* getCosmeticEdgeByGeom(int idx) const;
int getCosmeticEdgeIndex(TechDraw::CosmeticEdge* ce) const;
void replaceCosmeticEdge(int idx, TechDraw::CosmeticEdge* ce);
void replaceCosmeticEdgeByGeom(int geomIndex, TechDraw::CosmeticEdge* ce);
void clearCosmeticEdges(void);
void addCosmeticEdgesToGeom(void);
virtual int addCenterLine(TechDraw::CenterLine*);
virtual void writeCLineProp(void);
virtual void removeCenterLine(TechDraw::CenterLine* cl);
virtual void removeCenterLine(int idx);
const std::vector<TechDraw::CenterLine*> & getCenterLines(void) const { return CLineTable; }
TechDraw::CenterLine* getCenterLineByIndex(int idx) const;
TechDraw::CenterLine* getCenterLineByGeom(int idx) const;
void replaceCenterLine(int idx, TechDraw::CenterLine* cl);
void replaceCenterLineByGeom(int geomIndex, TechDraw::CenterLine* cl);
void clearCenterLines(void);
void addCosmeticEdgesToGeom(void);
void addCenterLinesToGeom(void);
int addGeomFormat(TechDraw::GeomFormat* gf);
virtual void writeGFormatProp(void);
virtual void removeGeomFormat(int idx);
const std::vector<TechDraw::GeomFormat*> & getGeomFormats(void) const { return GFormatTable; }
TechDraw::GeomFormat* getGeomFormatByIndex(int idx) const;
TechDraw::GeomFormat* getGeomFormatByGeom(int idx) const;
void clearGeomFormats(void);
@@ -230,22 +227,8 @@ protected:
bool m_sectionEdges;
bool m_handleFaces;
//Cosmetics
std::vector<TechDraw::CosmeticVertex*> CVertexTable;
void readCVertexProp(void);
std::vector<TechDraw::CosmeticEdge*> CEdgeTable;
void readCEdgeProp(void);
std::vector<TechDraw::CenterLine*> CLineTable;
void readCLineProp(void);
std::vector<TechDraw::GeomFormat*> GFormatTable;
void readGFormatProp(void);
private:
bool nowUnsetting;
/* bool m_restoreComplete;*/
};

View File

@@ -66,7 +66,7 @@ PyObject* DrawViewPartPy::clearCosmeticVertices(PyObject *args)
{
(void) args;
DrawViewPart* item = getDrawViewPartPtr();
item->clearCosmeticVertices();
item->clearCosmeticVertexes();
Py_INCREF(Py_None);
return Py_None;
}
@@ -107,7 +107,8 @@ PyObject* DrawViewPartPy::makeCosmeticVertex(PyObject *args)
}
DrawViewPart* item = getDrawViewPartPtr();
Base::Vector3d pnt1 = DrawUtil::invertY(static_cast<Base::VectorPy*>(pPnt1)->value());
// Base::Vector3d pnt1 = DrawUtil::invertY(static_cast<Base::VectorPy*>(pPnt1)->value());
Base::Vector3d pnt1 = static_cast<Base::VectorPy*>(pPnt1)->value();
int idx = item->addCosmeticVertex(pnt1);
return PyLong_FromLong(idx);
}
@@ -134,14 +135,18 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args)
Base::Vector3d pnt2 = static_cast<Base::VectorPy*>(pPnt2)->value();
int idx = dvp->addCosmeticEdge(pnt1, pnt2);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
ce->m_format.m_color = defCol;
if (ce != nullptr) {
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
ce->m_format.m_color = defCol;
} else {
ce->m_format.m_color = pyTupleToColor(pColor);
}
} else {
ce->m_format.m_color = pyTupleToColor(pColor);
//TODO: throw something
idx = -1;
}
dvp->writeCEdgeProp();
return PyLong_FromLong(idx);
}
@@ -177,14 +182,18 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args)
TopoDS_Edge edge = aMakeEdge.Edge();
int idx = dvp->addCosmeticEdge(edge);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
ce->m_format.m_color = defCol;
if (ce != nullptr) {
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
ce->m_format.m_color = defCol;
} else {
ce->m_format.m_color = pyTupleToColor(pColor);
}
} else {
ce->m_format.m_color = pyTupleToColor(pColor);
//TODO: throw something
idx = -1;
}
dvp->writeCEdgeProp();
return PyLong_FromLong(idx);
}
@@ -223,14 +232,18 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args)
TopoDS_Edge edge = aMakeEdge.Edge();
int idx = dvp->addCosmeticEdge(edge);
TechDraw::CosmeticEdge* ce = dvp->getCosmeticEdgeByIndex(idx);
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
ce->m_format.m_color = defCol;
if (ce != nullptr) {
ce->m_format.m_style = style;
ce->m_format.m_weight = weight;
if (pColor == nullptr) {
ce->m_format.m_color = defCol;
} else {
ce->m_format.m_color = pyTupleToColor(pColor);
}
} else {
ce->m_format.m_color = pyTupleToColor(pColor);
//TODO: throw something
idx = -1;
}
dvp->writeCEdgeProp();
return PyLong_FromLong(idx);
}
@@ -244,9 +257,7 @@ PyObject* DrawViewPartPy::getCosmeticVertexByIndex(PyObject *args)
DrawViewPart* dvp = getDrawViewPartPtr();
TechDraw::CosmeticVertex* cv = dvp->getCosmeticVertexByIndex(idx);
if (cv != nullptr) {
Base::Console().Message("DVPPI::getCosVertbyIdx - CosmeticVertexPy not implemented yet\n");
//make a py object
result = new CosmeticVertexPy(new CosmeticVertex(cv));
}
return result;
}

View File

@@ -326,11 +326,8 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
return new App::DocumentObjectExecReturn(e2.GetMessageString());
}
//add back the cosmetic vertices
for (auto& v: CVertexTable) {
int idx = geometryObject->addCosmeticVertex(v->point() * getScale());
v->linkGeom = idx;
}
//add the cosmetic vertices to the geometry vertices list
addCosmeticVertexesToGeom();
//add the cosmetic Edges to geometry Edges list
addCosmeticEdgesToGeom();
//add centerlines to geometry edges list

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="PyObjectBase"
Name="GeomFormatPy"
Twin="GeomFormat"
TwinPointer="GeomFormat"
Include="Mod/TechDraw/App/Cosmetic.h"
Namespace="TechDraw"
FatherInclude="Base/PyObjectBase.h"
FatherNamespace="Base"
Constructor="true"
Delete="true">
<Documentation>
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>GeomFormat specifies appearance parameters for TechDraw Geometry objects</UserDocu>
</Documentation>
<Methode Name="clone" Const="true">
<Documentation>
<UserDocu>Create a clone of this geomformat</UserDocu>
</Documentation>
</Methode>
<Methode Name="copy" Const="true">
<Documentation>
<UserDocu>Create a copy of this geomformat</UserDocu>
</Documentation>
</Methode>
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,141 @@
/***************************************************************************
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
//# include <gp_Ax1.hxx>
//# include <gp_Dir.hxx>
//# include <gp_Pnt.hxx>
//# include <gp_Vec.hxx>
//# include <gp_Trsf.hxx>
//# include <Geom_GeometryFormat.hxx>
//# include <Geom_Curve.hxx>
//# include <Geom_Surface.hxx>
//# include <Precision.hxx>
//# include <Standard_Failure.hxx>
# include <boost/uuid/uuid_io.hpp>
#endif
//#include <Base/GeomFormatPyCXX.h>
//#include <Base/Matrix.h>
//#include <Base/MatrixPy.h>
//#include <Base/Vector3D.h>
//#include <Base/VectorPy.h>
//#include <Base/Rotation.h>
//#include <Base/Placement.h>
//#include <Base/PlacementPy.h>
//#include "OCCError.h"
#include "Cosmetic.h"
#include "GeomFormatPy.h"
#include "GeomFormatPy.cpp"
//#include "TopoShape.h"
//#include "TopoShapePy.h"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string GeomFormatPy::representation(void) const
{
return "<GeomFormat object>";
}
PyObject *GeomFormatPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
{
// never create such objects with the constructor
PyErr_SetString(PyExc_RuntimeError,
"You cannot create an instance of the abstract class 'GeomFormat'.");
return 0;
}
// constructor method
int GeomFormatPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
{
return 0;
}
PyObject* GeomFormatPy::clone(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
TechDraw::GeomFormat* geom = this->getGeomFormatPtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, 0);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create clone of GeomFormat");
return 0;
}
TechDraw::GeomFormatPy* geompy = static_cast<TechDraw::GeomFormatPy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'GeomFormat' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::GeomFormat* clone = static_cast<TechDraw::GeomFormat*>(geompy->_pcTwinPointer);
delete clone;
}
geompy->_pcTwinPointer = geom->clone();
return cpy;
}
PyObject* GeomFormatPy::copy(PyObject *args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
TechDraw::GeomFormat* geom = this->getGeomFormatPtr();
PyTypeObject* type = this->GetType();
PyObject* cpy = 0;
// let the type object decide
if (type->tp_new)
cpy = type->tp_new(type, this, 0);
if (!cpy) {
PyErr_SetString(PyExc_TypeError, "failed to create copy of GeomFormat");
return 0;
}
TechDraw::GeomFormatPy* geompy = static_cast<TechDraw::GeomFormatPy*>(cpy);
// the PyMake function must have created the corresponding instance of the 'GeomFormat' subclass
// so delete it now to avoid a memory leak
if (geompy->_pcTwinPointer) {
TechDraw::GeomFormat* copy = static_cast<TechDraw::GeomFormat*>(geompy->_pcTwinPointer);
delete copy;
}
geompy->_pcTwinPointer = geom->copy();
return cpy;
}
PyObject *GeomFormatPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int GeomFormatPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -69,6 +69,8 @@
#include <Base/Exception.h>
#include <Base/Tools2D.h>
#include <Base/Parameter.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <App/Application.h>
#include <App/Material.h>
@@ -119,11 +121,30 @@ BaseGeom::BaseGeom() :
cosmetic(false),
m_source(0),
m_sourceIndex(-1)
{
}
std::string BaseGeom::toCSV(void) const
BaseGeom* BaseGeom::copy()
{
BaseGeom* result = nullptr;
if (!occEdge.IsNull()) {
result = baseFactory(occEdge);
if (result != nullptr) {
result->extractType = extractType;
result->classOfEdge = classOfEdge;
result->visible = visible;
result->reversed = reversed;
result->ref3D = ref3D;
result->cosmetic = cosmetic;
result->source(m_source);
result->sourceIndex(m_sourceIndex);
}
}
return result;
}
std::string BaseGeom::toString(void) const
{
std::stringstream ss;
ss << geomType << "," <<
@@ -138,29 +159,67 @@ std::string BaseGeom::toCSV(void) const
return ss.str();
}
bool BaseGeom::fromCSV(std::string lineSpec)
{
unsigned int maxCells = 9;
if (lineSpec.length() == 0) {
Base::Console().Message( "BG::fromCSV - lineSpec empty\n");
return false;
}
std::vector<std::string> values = DrawUtil::split(lineSpec);
if (values.size() < maxCells) {
Base::Console().Message( "BG::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
return false;
}
//bool BaseGeom::fromCSV(std::string lineSpec)
//{
// unsigned int maxCells = 9;
// if (lineSpec.length() == 0) {
// Base::Console().Message( "BG::fromCSV - lineSpec empty\n");
// return false;
// }
// std::vector<std::string> values = DrawUtil::split(lineSpec);
// if (values.size() < maxCells) {
// Base::Console().Message( "BG::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
// return false;
// }
geomType = (TechDraw::GeomType) atoi(values[0].c_str());
extractType = (TechDraw::ExtractionType) atoi(values[1].c_str());
classOfEdge = (TechDraw::edgeClass) atoi(values[2].c_str());
visible = (bool) atoi(values[3].c_str());
reversed = (bool) atoi(values[4].c_str());
ref3D = atoi(values[5].c_str());
cosmetic = (bool) atoi(values[6].c_str());
m_source = atoi(values[7].c_str());
m_sourceIndex = atoi(values[8].c_str());
return true;
// geomType = (TechDraw::GeomType) atoi(values[0].c_str());
// extractType = (TechDraw::ExtractionType) atoi(values[1].c_str());
// classOfEdge = (TechDraw::edgeClass) atoi(values[2].c_str());
// visible = (bool) atoi(values[3].c_str());
// reversed = (bool) atoi(values[4].c_str());
// ref3D = atoi(values[5].c_str());
// cosmetic = (bool) atoi(values[6].c_str());
// m_source = atoi(values[7].c_str());
// m_sourceIndex = atoi(values[8].c_str());
// return true;
//}
void BaseGeom::Save(Base::Writer &writer) const
{
writer.Stream() << writer.ind() << "<GeomType value=\"" << geomType << "\"/>" << endl;
writer.Stream() << writer.ind() << "<ExtractType value=\"" << extractType << "\"/>" << endl;
writer.Stream() << writer.ind() << "<EdgeClass value=\"" << classOfEdge << "\"/>" << endl;
const char v = visible?'1':'0';
writer.Stream() << writer.ind() << "<Visible value=\"" << v << "\"/>" << endl;
const char r = reversed?'1':'0';
writer.Stream() << writer.ind() << "<Reversed value=\"" << r << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Ref3D value=\"" << ref3D << "\"/>" << endl;
const char c = cosmetic?'1':'0';
writer.Stream() << writer.ind() << "<Cosmetic value=\"" << c << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Source value=\"" << m_source << "\"/>" << endl;
writer.Stream() << writer.ind() << "<SourceIndex value=\"" << m_sourceIndex << "\"/>" << endl;
}
void BaseGeom::Restore(Base::XMLReader &reader)
{
reader.readElement("GeomType");
geomType = (TechDraw::GeomType) reader.getAttributeAsInteger("value");
reader.readElement("ExtractType");
extractType = (TechDraw::ExtractionType) reader.getAttributeAsInteger("value");
reader.readElement("EdgeClass");
classOfEdge = (TechDraw::edgeClass) reader.getAttributeAsInteger("value");
reader.readElement("Visible");
visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("Reversed");
reversed = (int)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("Ref3D");
ref3D = reader.getAttributeAsInteger("value");
reader.readElement("Cosmetic");
cosmetic = (int)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("Source");
m_source = reader.getAttributeAsInteger("value");
reader.readElement("SourceIndex");
m_sourceIndex = reader.getAttributeAsInteger("value");
}
std::vector<Base::Vector3d> BaseGeom::findEndPoints()
@@ -454,9 +513,9 @@ Circle::Circle(const TopoDS_Edge &e)
radius = circ.Radius();
center = Base::Vector3d(p.X(), p.Y(), p.Z());
}
std::string Circle::toCSV(void) const
std::string Circle::toString(void) const
{
std::string baseCSV = BaseGeom::toCSV();
std::string baseCSV = BaseGeom::toString();
std::stringstream ss;
ss << center.x << "," <<
center.y << "," <<
@@ -465,34 +524,59 @@ std::string Circle::toCSV(void) const
return baseCSV + ",$$$," + ss.str();
}
bool Circle::fromCSV(std::string lineSpec)
//bool Circle::fromCSV(std::string lineSpec)
//{
// if (lineSpec.length() == 0) {
// Base::Console().Message( "Circle::fromCSV - lineSpec empty\n");
// return false;
// }
// std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
// //"baseCSV,$$$,circleCSV"
// if (tokens.size() != 2) {
// Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - size: %d\n",tokens.size());
// }
// BaseGeom::fromCSV(tokens[0]);
// unsigned int maxCells = 4;
// std::vector<std::string> values = DrawUtil::split(tokens[1]);
// if (values.size() < maxCells) {
// Base::Console().Message( "Circle::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
// return false;
// }
// double x = atof(values[0].c_str());
// double y = atof(values[1].c_str());
// double z = atof(values[2].c_str());
// center = Base::Vector3d(x,y,z);
// radius = atof(values[3].c_str());
// return true;
//}
void Circle::Save(Base::Writer &writer) const
{
if (lineSpec.length() == 0) {
Base::Console().Message( "Circle::fromCSV - lineSpec empty\n");
return false;
}
BaseGeom::Save(writer);
writer.Stream() << writer.ind() << "<Center "
<< "X=\"" << center.x <<
"\" Y=\"" << center.y <<
"\" Z=\"" << center.z <<
"\"/>" << endl;
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
//"baseCSV,$$$,circleCSV"
if (tokens.size() != 2) {
Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - size: %d\n",tokens.size());
}
BaseGeom::fromCSV(tokens[0]);
unsigned int maxCells = 4;
std::vector<std::string> values = DrawUtil::split(tokens[1]);
if (values.size() < maxCells) {
Base::Console().Message( "Circle::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
return false;
}
double x = atof(values[0].c_str());
double y = atof(values[1].c_str());
double z = atof(values[2].c_str());
center = Base::Vector3d(x,y,z);
radius = atof(values[3].c_str());
return true;
writer.Stream() << writer.ind() << "<Radius value=\"" << radius << "\"/>" << endl;
}
void Circle::Restore(Base::XMLReader &reader)
{
BaseGeom::Restore(reader);
// read my Element
reader.readElement("Center");
// get the value of my Attribute
center.x = reader.getAttributeAsFloat("X");
center.y = reader.getAttributeAsFloat("Y");
center.z = reader.getAttributeAsFloat("Z");
reader.readElement("Radius");
radius = reader.getAttributeAsFloat("value");
}
AOC::AOC(const TopoDS_Edge &e) : Circle(e)
{
@@ -583,9 +667,9 @@ bool AOC::intersectsArc(Base::Vector3d p1, Base::Vector3d p2)
return result;
}
std::string AOC::toCSV(void) const
std::string AOC::toString(void) const
{
std::string circleCSV = Circle::toCSV();
std::string circleCSV = Circle::toString();
std::stringstream ss;
ss << startPnt.x << "," <<
@@ -606,44 +690,96 @@ std::string AOC::toCSV(void) const
return result;
}
bool AOC::fromCSV(std::string lineSpec)
{
// Base::Console().Message( "AOC::fromCSV(%s)\n", lineSpec.c_str());
if (lineSpec.length() == 0) {
Base::Console().Message( "AOC::fromCSV - lineSpec empty\n");
return false;
}
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
//"(baseCSV,$$$,circleCSV),$$$,AOCCSV"
// [0] [1] [2]
if (tokens.size() != 3) {
Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - size: %d\n",tokens.size());
}
//bool AOC::fromCSV(std::string lineSpec)
//{
//// Base::Console().Message( "AOC::fromCSV(%s)\n", lineSpec.c_str());
// if (lineSpec.length() == 0) {
// Base::Console().Message( "AOC::fromCSV - lineSpec empty\n");
// return false;
// }
// std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
// //"(baseCSV,$$$,circleCSV),$$$,AOCCSV"
// // [0] [1] [2]
// if (tokens.size() != 3) {
// Base::Console().Message("CosmeticEdge::fromCSV - tokenize failed - size: %d\n",tokens.size());
// }
Circle::fromCSV(tokens[0] + ",$$$," + tokens[1]); //extra work here.
unsigned int maxCells = 13;
std::vector<std::string> values = DrawUtil::split(tokens[2]); // we are only interested in last token
if (values.size() < maxCells) {
Base::Console().Message( "AOC::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
return false;
}
double x = atof(values[0].c_str());
double y = atof(values[1].c_str());
double z = atof(values[2].c_str());
startPnt = Base::Vector3d(x,y,z);
x = atof(values[3].c_str());
y = atof(values[4].c_str());
z = atof(values[5].c_str());
endPnt = Base::Vector3d(x,y,z);
x = atof(values[6].c_str());
y = atof(values[7].c_str());
z = atof(values[8].c_str());
midPnt = Base::Vector3d(x,y,z);
startAngle = atof(values[9].c_str());
endAngle = atof(values[10].c_str());
cw = atoi(values[11].c_str());
largeArc = atoi(values[12].c_str());
return true;
// Circle::fromCSV(tokens[0] + ",$$$," + tokens[1]); //extra work here.
// unsigned int maxCells = 13;
// std::vector<std::string> values = DrawUtil::split(tokens[2]); // we are only interested in last token
// if (values.size() < maxCells) {
// Base::Console().Message( "AOC::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
// return false;
// }
// double x = atof(values[0].c_str());
// double y = atof(values[1].c_str());
// double z = atof(values[2].c_str());
// startPnt = Base::Vector3d(x,y,z);
// x = atof(values[3].c_str());
// y = atof(values[4].c_str());
// z = atof(values[5].c_str());
// endPnt = Base::Vector3d(x,y,z);
// x = atof(values[6].c_str());
// y = atof(values[7].c_str());
// z = atof(values[8].c_str());
// midPnt = Base::Vector3d(x,y,z);
// startAngle = atof(values[9].c_str());
// endAngle = atof(values[10].c_str());
// cw = atoi(values[11].c_str());
// largeArc = atoi(values[12].c_str());
// return true;
//}
void AOC::Save(Base::Writer &writer) const
{
Circle::Save(writer);
writer.Stream() << writer.ind() << "<Start "
<< "X=\"" << startPnt.x <<
"\" Y=\"" << startPnt.y <<
"\" Z=\"" << startPnt.z <<
"\"/>" << endl;
writer.Stream() << writer.ind() << "<End "
<< "X=\"" << endPnt.x <<
"\" Y=\"" << endPnt.y <<
"\" Z=\"" << endPnt.z <<
"\"/>" << endl;
writer.Stream() << writer.ind() << "<Middle "
<< "X=\"" << midPnt.x <<
"\" Y=\"" << midPnt.y <<
"\" Z=\"" << midPnt.z <<
"\"/>" << endl;
writer.Stream() << writer.ind() << "<StartAngle value=\"" << startAngle << "\"/>" << endl;
writer.Stream() << writer.ind() << "<EndAngle value=\"" << endAngle << "\"/>" << endl;
const char c = cw?'1':'0';
writer.Stream() << writer.ind() << "<Clockwise value=\"" << c << "\"/>" << endl;
const char la = largeArc?'1':'0';
writer.Stream() << writer.ind() << "<Large value=\"" << la << "\"/>" << endl;
}
void AOC::Restore(Base::XMLReader &reader)
{
Circle::Restore(reader);
reader.readElement("Start");
startPnt.x = reader.getAttributeAsFloat("X");
startPnt.y = reader.getAttributeAsFloat("Y");
startPnt.z = reader.getAttributeAsFloat("Z");
reader.readElement("End");
endPnt.x = reader.getAttributeAsFloat("X");
endPnt.y = reader.getAttributeAsFloat("Y");
endPnt.z = reader.getAttributeAsFloat("Z");
reader.readElement("Middle");
midPnt.x = reader.getAttributeAsFloat("X");
midPnt.y = reader.getAttributeAsFloat("Y");
midPnt.z = reader.getAttributeAsFloat("Z");
reader.readElement("StartAngle");
startAngle = reader.getAttributeAsFloat("value");
reader.readElement("EndAngle");
endAngle = reader.getAttributeAsFloat("value");
reader.readElement("Clockwise");
cw = (int)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("Large");
largeArc = (int)reader.getAttributeAsInteger("value")==0?false:true;
}
//! Generic is a multiline
@@ -676,9 +812,9 @@ Generic::Generic()
geomType = GENERIC;
}
std::string Generic::toCSV(void) const
std::string Generic::toString(void) const
{
std::string baseCSV = BaseGeom::toCSV();
std::string baseCSV = BaseGeom::toString();
std::stringstream ss;
ss << points.size() << ",";
for (auto& p: points) {
@@ -691,34 +827,69 @@ std::string Generic::toCSV(void) const
return baseCSV + ",$$$," + genericCSV;
}
bool Generic::fromCSV(std::string lineSpec)
//bool Generic::fromCSV(std::string lineSpec)
//{
// std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
// //"baseCSV,$$$,genericCSV"
// if (tokens.size() != 2) {
// Base::Console().Message("Generic::fromCSV - tokenize failed - size: %d\n",tokens.size());
// }
// BaseGeom::fromCSV(tokens[0]);
// if (lineSpec.length() == 0) {
// Base::Console().Message( "Generic::fromCSV - lineSpec empty\n");
// return false;
// }
// std::vector<std::string> values = DrawUtil::split(tokens[1]);
// if (!values.empty()) {
// double count = atoi(values[0].c_str());
// points.clear();
// int i = 0;
// for ( ; i < count; i++) {
// int idx = i * 3;
// double x = atof(values[idx+1].c_str());
// double y = atof(values[idx+2].c_str());
// double z = atof(values[idx+3].c_str());
// points.push_back(Base::Vector3d(x, y, z));
// }
// }
// return true;
//}
void Generic::Save(Base::Writer &writer) const
{
BaseGeom::Save(writer);
writer.Stream() << writer.ind()
<< "<Points PointsCount =\"" << points.size() << "\">" << endl;
writer.incInd();
for (auto& p: points) {
writer.Stream() << writer.ind() << "<Point "
<< "X=\"" << p.x <<
"\" Y=\"" << p.y <<
"\" Z=\"" << p.z <<
"\"/>" << endl;
}
writer.decInd();
writer.Stream() << writer.ind() << "</Points>" << endl ;
std::vector<std::string> tokens = DrawUtil::tokenize(lineSpec);
//"baseCSV,$$$,genericCSV"
if (tokens.size() != 2) {
Base::Console().Message("Generic::fromCSV - tokenize failed - size: %d\n",tokens.size());
}
}
BaseGeom::fromCSV(tokens[0]);
if (lineSpec.length() == 0) {
Base::Console().Message( "Generic::fromCSV - lineSpec empty\n");
return false;
void Generic::Restore(Base::XMLReader &reader)
{
BaseGeom::Restore(reader);
reader.readElement("Points");
int stop = reader.getAttributeAsInteger("PointsCount");
int i = 0;
for ( ; i < stop; i++) {
reader.readElement("Point");
Base::Vector3d p;
p.x = reader.getAttributeAsFloat("X");
p.y = reader.getAttributeAsFloat("Y");
p.z = reader.getAttributeAsFloat("Z");
points.push_back(p);
}
std::vector<std::string> values = DrawUtil::split(tokens[1]);
if (!values.empty()) {
double count = atoi(values[0].c_str());
points.clear();
int i = 0;
for ( ; i < count; i++) {
int idx = i * 3;
double x = atof(values[idx+1].c_str());
double y = atof(values[idx+2].c_str());
double z = atof(values[idx+3].c_str());
points.push_back(Base::Vector3d(x, y, z));
}
}
return true;
reader.readEndElement("Points");
}
Base::Vector3d Generic::asVector(void)
@@ -1117,6 +1288,20 @@ Vertex::Vertex()
isCenter = false;
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(0.0, 0.0, 0.0));
occVertex = mkVert.Vertex();
cosmetic = false;
cosmeticLink = -1;
}
Vertex::Vertex(const Vertex* v)
{
pnt = v->pnt;
extractType = v->extractType; //obs?
visible = v->visible;
ref3D = v->ref3D; //obs. never used.
isCenter = v->isCenter;
occVertex = v->occVertex;
cosmetic = v->cosmetic;
cosmeticLink = v->cosmeticLink;
}
Vertex::Vertex(double x, double y)
@@ -1128,6 +1313,8 @@ Vertex::Vertex(double x, double y)
isCenter = false;
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(x,y,0.0));
occVertex = mkVert.Vertex();
cosmetic = false;
cosmeticLink = -1;
}
bool Vertex::isEqual(Vertex* v, double tol)
@@ -1140,6 +1327,49 @@ bool Vertex::isEqual(Vertex* v, double tol)
return result;
}
void Vertex::Save(Base::Writer &writer) const
{
writer.Stream() << writer.ind() << "<Point "
<< "X=\"" << pnt.x <<
"\" Y=\"" << pnt.y <<
"\" Z=\"" << pnt.z <<
"\"/>" << endl;
writer.Stream() << writer.ind() << "<Extract value=\"" << extractType << "\"/>" << endl;
const char v = visible?'1':'0';
writer.Stream() << writer.ind() << "<Visible value=\"" << v << "\"/>" << endl;
writer.Stream() << writer.ind() << "<Ref3D value=\"" << ref3D << "\"/>" << endl;
const char c = isCenter?'1':'0';
writer.Stream() << writer.ind() << "<IsCenter value=\"" << c << "\"/>" << endl;
const char c2 = cosmetic?'1':'0';
writer.Stream() << writer.ind() << "<Cosmetic value=\"" << c2 << "\"/>" << endl;
writer.Stream() << writer.ind() << "<CosmeticLink value=\"" << cosmeticLink << "\"/>" << endl;
}
void Vertex::Restore(Base::XMLReader &reader)
{
reader.readElement("Point");
pnt.x = reader.getAttributeAsFloat("X");
pnt.y = reader.getAttributeAsFloat("Y");
pnt.z = reader.getAttributeAsFloat("Z");
reader.readElement("Extract");
extractType = (ExtractionType) reader.getAttributeAsInteger("value");
reader.readElement("Visible");
visible = (bool)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("Ref3D");
ref3D = reader.getAttributeAsInteger("value");
reader.readElement("IsCenter");
visible = (bool)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("Cosmetic");
cosmetic = (bool)reader.getAttributeAsInteger("value")==0?false:true;
reader.readElement("CosmeticLink");
cosmeticLink = reader.getAttributeAsInteger("value");
BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(pnt.x, pnt.y, pnt.z));
occVertex = mkVert.Vertex();
}
/*static*/
BaseGeomPtrVector GeometryUtils::chainGeoms(BaseGeomPtrVector geoms)

View File

@@ -25,6 +25,8 @@
#include <Base/Tools2D.h>
#include <Base/Vector3D.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
@@ -85,8 +87,10 @@ class TechDrawExport BaseGeom
int sourceIndex(void) { return m_sourceIndex; }
void sourceIndex(int si) { m_sourceIndex = si; }
virtual std::string toCSV(void) const;
virtual bool fromCSV(std::string s);
virtual std::string toString(void) const;
/* virtual bool fromCSV(std::string s);*/
virtual void Save(Base::Writer& w) const;
virtual void Restore(Base::XMLReader& r);
std::vector<Base::Vector3d> findEndPoints();
Base::Vector3d getStartPoint();
Base::Vector3d getEndPoint();
@@ -97,6 +101,7 @@ class TechDrawExport BaseGeom
Base::Vector3d nearPoint(const BaseGeom* p);
static BaseGeom* baseFactory(TopoDS_Edge edge);
bool closed(void);
BaseGeom* copy();
std::string dump();
protected:
@@ -115,8 +120,10 @@ class TechDrawExport Circle: public BaseGeom
~Circle() = default;
public:
virtual std::string toCSV(void) const override;
virtual bool fromCSV(std::string s) override;
virtual std::string toString(void) const override;
/* virtual bool fromCSV(std::string s) override;*/
virtual void Save(Base::Writer& w) const override;
virtual void Restore(Base::XMLReader& r) override;
Base::Vector3d center;
double radius;
@@ -167,8 +174,10 @@ class TechDrawExport AOC: public Circle
~AOC() = default;
public:
virtual std::string toCSV(void) const override;
virtual bool fromCSV(std::string s) override;
virtual std::string toString(void) const override;
/* virtual bool fromCSV(std::string s) override;*/
virtual void Save(Base::Writer& w) const override;
virtual void Restore(Base::XMLReader& r) override;
Base::Vector3d startPnt;
Base::Vector3d endPnt;
@@ -234,8 +243,10 @@ class TechDrawExport Generic: public BaseGeom
Generic();
~Generic() = default;
virtual std::string toCSV(void) const override;
virtual bool fromCSV(std::string s) override;
virtual std::string toString(void) const override;
/* virtual bool fromCSV(std::string s) override;*/
virtual void Save(Base::Writer& w) const override;
virtual void Restore(Base::XMLReader& r) override;
Base::Vector3d asVector(void);
double slope(void);
Base::Vector3d apparentInter(Generic* g);
@@ -264,14 +275,17 @@ class TechDrawExport Face
std::vector<Wire *> wires;
};
//! 2D Vertex
class TechDrawExport Vertex
{
public:
Vertex();
Vertex(const Vertex* v);
Vertex(double x, double y);
Vertex(Base::Vector3d v) : Vertex(v.x,v.y) {}
~Vertex() = default;
virtual ~Vertex() {}
virtual void Save(Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
Base::Vector3d pnt;
ExtractionType extractType; //obs?
@@ -282,6 +296,8 @@ class TechDrawExport Vertex
bool isEqual(Vertex* v, double tol);
Base::Vector3d point(void) const { return Base::Vector3d(pnt.x,pnt.y,0.0); }
void point(Base::Vector3d v){ pnt = Base::Vector3d(v.x, v.y); }
bool cosmetic;
int cosmeticLink;
double x() {return pnt.x;}
double y() {return pnt.y;}

View File

@@ -473,11 +473,13 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
} //end TopExp
}
int GeometryObject::addCosmeticVertex(Base::Vector3d pos)
int GeometryObject::addCosmeticVertex(Base::Vector3d pos, int link)
{
TechDraw::Vertex* v = new TechDraw::Vertex(pos.x, pos.y);
v->cosmetic = true;
v->cosmeticLink = link;
int idx = vertexGeom.size();
vertexGeom.push_back(v);
int idx = vertexGeom.size() - 1;
return idx;
}

View File

@@ -134,7 +134,7 @@ public:
TopoDS_Shape getHidIso(void) { return hidIso; }
//Are removeXXXXX functions really needed for GO?
int addCosmeticVertex(Base::Vector3d pos);
int addCosmeticVertex(Base::Vector3d pos, int link = -1);
/* void removeCosmeticVertex(TechDraw::CosmeticVertex* cv);*/
/* void removeCosmeticVertex(int idx);*/
int addCosmeticEdge(TechDraw::BaseGeom* bg, int s = 0, int si = -1);

View File

@@ -0,0 +1,226 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2010 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <assert.h>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Exception.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Base/Console.h>
#include "Cosmetic.h"
#include "CenterLinePy.h"
#include "PropertyCenterLineList.h"
using namespace App;
using namespace Base;
using namespace std;
using namespace TechDraw;
//**************************************************************************
// PropertyCenterLineList
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(TechDraw::PropertyCenterLineList, App::PropertyLists);
//**************************************************************************
// Construction/Destruction
PropertyCenterLineList::PropertyCenterLineList()
{
}
PropertyCenterLineList::~PropertyCenterLineList()
{
for (std::vector<CenterLine*>::iterator it = _lValueList.begin(); it != _lValueList.end(); ++it)
if (*it) delete *it;
}
void PropertyCenterLineList::setSize(int newSize)
{
for (unsigned int i = newSize; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(newSize);
}
int PropertyCenterLineList::getSize(void) const
{
return static_cast<int>(_lValueList.size());
}
void PropertyCenterLineList::setValue(const CenterLine* lValue)
{
if (lValue) {
aboutToSetValue();
CenterLine* newVal = lValue->clone();
for (unsigned int i = 0; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(1);
_lValueList[0] = newVal;
hasSetValue();
}
}
void PropertyCenterLineList::setValues(const std::vector<CenterLine*>& lValue)
{
aboutToSetValue();
std::vector<CenterLine*> oldVals(_lValueList);
_lValueList.resize(lValue.size());
// copy all objects
for (unsigned int i = 0; i < lValue.size(); i++)
_lValueList[i] = lValue[i]->clone();
for (unsigned int i = 0; i < oldVals.size(); i++)
delete oldVals[i];
hasSetValue();
}
PyObject *PropertyCenterLineList::getPyObject(void)
{
PyObject* list = PyList_New(getSize());
for (int i = 0; i < getSize(); i++)
PyList_SetItem( list, i, _lValueList[i]->getPyObject());
return list;
}
void PropertyCenterLineList::setPyObject(PyObject *value)
{
// check container of this property to notify about changes
// Part2DObject* part2d = dynamic_cast<Part2DObject*>(this->getContainer());
if (PySequence_Check(value)) {
Py_ssize_t nSize = PySequence_Size(value);
std::vector<CenterLine*> values;
values.resize(nSize);
for (Py_ssize_t i=0; i < nSize; ++i) {
PyObject* item = PySequence_GetItem(value, i);
if (!PyObject_TypeCheck(item, &(CenterLinePy::Type))) {
std::string error = std::string("types in list must be 'CenterLine', not ");
error += item->ob_type->tp_name;
throw Base::TypeError(error);
}
values[i] = static_cast<CenterLinePy*>(item)->getCenterLinePtr();
}
setValues(values);
// if (part2d)
// part2d->acceptCenterLine();
}
else if (PyObject_TypeCheck(value, &(CenterLinePy::Type))) {
CenterLinePy *pcObject = static_cast<CenterLinePy*>(value);
setValue(pcObject->getCenterLinePtr());
}
else {
std::string error = std::string("type must be 'CenterLine' or list of 'CenterLine', not ");
error += value->ob_type->tp_name;
throw Base::TypeError(error);
}
}
void PropertyCenterLineList::Save(Writer &writer) const
{
writer.Stream() << writer.ind() << "<CenterLineList count=\"" << getSize() <<"\">" << endl;
writer.incInd();
for (int i = 0; i < getSize(); i++) {
writer.Stream() << writer.ind() << "<CenterLine type=\""
<< _lValueList[i]->getTypeId().getName() << "\">" << endl;
writer.incInd();
_lValueList[i]->Save(writer);
writer.decInd();
writer.Stream() << writer.ind() << "</CenterLine>" << endl;
}
writer.decInd();
writer.Stream() << writer.ind() << "</CenterLineList>" << endl ;
}
void PropertyCenterLineList::Restore(Base::XMLReader &reader)
{
// read my element
reader.clearPartialRestoreObject();
reader.readElement("CenterLineList");
// get the value of my attribute
int count = reader.getAttributeAsInteger("count");
std::vector<CenterLine*> values;
values.reserve(count);
for (int i = 0; i < count; i++) {
reader.readElement("CenterLine");
const char* TypeName = reader.getAttribute("type");
CenterLine *newG = (CenterLine *)Base::Type::fromName(TypeName).createInstance();
newG->Restore(reader);
if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) {
Base::Console().Error("CenterLine \"%s\" within a PropertyCenterLineList was subject to a partial restore.\n",reader.localName());
if(isOrderRelevant()) {
// Pushes the best try by the CenterLine class
values.push_back(newG);
}
else {
delete newG;
}
reader.clearPartialRestoreObject();
}
else {
values.push_back(newG);
}
reader.readEndElement("CenterLine");
}
reader.readEndElement("CenterLineList");
// assignment
setValues(values);
}
App::Property *PropertyCenterLineList::Copy(void) const
{
PropertyCenterLineList *p = new PropertyCenterLineList();
p->setValues(_lValueList);
return p;
}
void PropertyCenterLineList::Paste(const Property &from)
{
const PropertyCenterLineList& FromList = dynamic_cast<const PropertyCenterLineList&>(from);
setValues(FromList._lValueList);
}
unsigned int PropertyCenterLineList::getMemSize(void) const
{
int size = sizeof(PropertyCenterLineList);
for (int i = 0; i < getSize(); i++)
size += _lValueList[i]->getMemSize();
return size;
}

View File

@@ -0,0 +1,97 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2010 *
* *
* 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_PropertyCenterLineList_H
#define TECHDRAW_PropertyCenterLineList_H
// Std. configurations
#include <vector>
#include <string>
#include <App/Property.h>
#include <Mod/TechDraw/App/CenterLinePy.h>
#include "Cosmetic.h"
namespace Base {
class Writer;
}
namespace TechDraw
{
class CenterLine;
class TechDrawExport PropertyCenterLineList: public App::PropertyLists
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyCenterLineList();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyCenterLineList();
virtual void setSize(int newSize);
virtual int getSize(void) const;
/** Sets the property
*/
void setValue(const CenterLine*);
void setValues(const std::vector<CenterLine*>&);
/// index operator
const CenterLine *operator[] (const int idx) const {
return _lValueList[idx];
}
const std::vector<CenterLine*> &getValues(void) const {
return _lValueList;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
virtual void Save(Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual App::Property *Copy(void) const;
virtual void Paste(const App::Property &from);
virtual unsigned int getMemSize(void) const;
private:
std::vector<CenterLine*> _lValueList;
};
} // namespace TechDraw
#endif // TECHDRAW_PropertyCenterLineList_H

View File

@@ -0,0 +1,226 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2010 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <assert.h>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Exception.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Base/Console.h>
#include "Cosmetic.h"
#include "CosmeticEdgePy.h"
#include "PropertyCosmeticEdgeList.h"
using namespace App;
using namespace Base;
using namespace std;
using namespace TechDraw;
//**************************************************************************
// PropertyCosmeticEdgeList
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(TechDraw::PropertyCosmeticEdgeList, App::PropertyLists);
//**************************************************************************
// Construction/Destruction
PropertyCosmeticEdgeList::PropertyCosmeticEdgeList()
{
}
PropertyCosmeticEdgeList::~PropertyCosmeticEdgeList()
{
for (std::vector<CosmeticEdge*>::iterator it = _lValueList.begin(); it != _lValueList.end(); ++it)
if (*it) delete *it;
}
void PropertyCosmeticEdgeList::setSize(int newSize)
{
for (unsigned int i = newSize; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(newSize);
}
int PropertyCosmeticEdgeList::getSize(void) const
{
return static_cast<int>(_lValueList.size());
}
void PropertyCosmeticEdgeList::setValue(const CosmeticEdge* lValue)
{
if (lValue) {
aboutToSetValue();
CosmeticEdge* newVal = lValue->clone();
for (unsigned int i = 0; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(1);
_lValueList[0] = newVal;
hasSetValue();
}
}
void PropertyCosmeticEdgeList::setValues(const std::vector<CosmeticEdge*>& lValue)
{
aboutToSetValue();
std::vector<CosmeticEdge*> oldVals(_lValueList);
_lValueList.resize(lValue.size());
// copy all objects
for (unsigned int i = 0; i < lValue.size(); i++)
_lValueList[i] = lValue[i]->clone();
for (unsigned int i = 0; i < oldVals.size(); i++)
delete oldVals[i];
hasSetValue();
}
PyObject *PropertyCosmeticEdgeList::getPyObject(void)
{
PyObject* list = PyList_New(getSize());
for (int i = 0; i < getSize(); i++)
PyList_SetItem( list, i, _lValueList[i]->getPyObject());
return list;
}
void PropertyCosmeticEdgeList::setPyObject(PyObject *value)
{
// check container of this property to notify about changes
// Part2DObject* part2d = dynamic_cast<Part2DObject*>(this->getContainer());
if (PySequence_Check(value)) {
Py_ssize_t nSize = PySequence_Size(value);
std::vector<CosmeticEdge*> values;
values.resize(nSize);
for (Py_ssize_t i=0; i < nSize; ++i) {
PyObject* item = PySequence_GetItem(value, i);
if (!PyObject_TypeCheck(item, &(CosmeticEdgePy::Type))) {
std::string error = std::string("types in list must be 'CosmeticEdge', not ");
error += item->ob_type->tp_name;
throw Base::TypeError(error);
}
values[i] = static_cast<CosmeticEdgePy*>(item)->getCosmeticEdgePtr();
}
setValues(values);
// if (part2d)
// part2d->acceptCosmeticEdge();
}
else if (PyObject_TypeCheck(value, &(CosmeticEdgePy::Type))) {
CosmeticEdgePy *pcObject = static_cast<CosmeticEdgePy*>(value);
setValue(pcObject->getCosmeticEdgePtr());
}
else {
std::string error = std::string("type must be 'CosmeticEdge' or list of 'CosmeticEdge', not ");
error += value->ob_type->tp_name;
throw Base::TypeError(error);
}
}
void PropertyCosmeticEdgeList::Save(Writer &writer) const
{
writer.Stream() << writer.ind() << "<CosmeticEdgeList count=\"" << getSize() <<"\">" << endl;
writer.incInd();
for (int i = 0; i < getSize(); i++) {
writer.Stream() << writer.ind() << "<CosmeticEdge type=\""
<< _lValueList[i]->getTypeId().getName() << "\">" << endl;
writer.incInd();
_lValueList[i]->Save(writer);
writer.decInd();
writer.Stream() << writer.ind() << "</CosmeticEdge>" << endl;
}
writer.decInd();
writer.Stream() << writer.ind() << "</CosmeticEdgeList>" << endl ;
}
void PropertyCosmeticEdgeList::Restore(Base::XMLReader &reader)
{
// read my element
reader.clearPartialRestoreObject();
reader.readElement("CosmeticEdgeList");
// get the value of my attribute
int count = reader.getAttributeAsInteger("count");
std::vector<CosmeticEdge*> values;
values.reserve(count);
for (int i = 0; i < count; i++) {
reader.readElement("CosmeticEdge");
const char* TypeName = reader.getAttribute("type");
CosmeticEdge *newG = (CosmeticEdge *)Base::Type::fromName(TypeName).createInstance();
newG->Restore(reader);
if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) {
Base::Console().Error("CosmeticEdge \"%s\" within a PropertyCosmeticEdgeList was subject to a partial restore.\n",reader.localName());
if(isOrderRelevant()) {
// Pushes the best try by the CosmeticEdge class
values.push_back(newG);
}
else {
delete newG;
}
reader.clearPartialRestoreObject();
}
else {
values.push_back(newG);
}
reader.readEndElement("CosmeticEdge");
}
reader.readEndElement("CosmeticEdgeList");
// assignment
setValues(values);
}
App::Property *PropertyCosmeticEdgeList::Copy(void) const
{
PropertyCosmeticEdgeList *p = new PropertyCosmeticEdgeList();
p->setValues(_lValueList);
return p;
}
void PropertyCosmeticEdgeList::Paste(const Property &from)
{
const PropertyCosmeticEdgeList& FromList = dynamic_cast<const PropertyCosmeticEdgeList&>(from);
setValues(FromList._lValueList);
}
unsigned int PropertyCosmeticEdgeList::getMemSize(void) const
{
int size = sizeof(PropertyCosmeticEdgeList);
for (int i = 0; i < getSize(); i++)
size += _lValueList[i]->getMemSize();
return size;
}

View File

@@ -0,0 +1,97 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2010 *
* *
* 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_PropertyCosmeticEdgeList_H
#define TECHDRAW_PropertyCosmeticEdgeList_H
// Std. configurations
#include <vector>
#include <string>
#include <App/Property.h>
#include <Mod/TechDraw/App/CosmeticEdgePy.h>
#include "Cosmetic.h"
namespace Base {
class Writer;
}
namespace TechDraw
{
class CosmeticEdge;
class TechDrawExport PropertyCosmeticEdgeList: public App::PropertyLists
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyCosmeticEdgeList();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyCosmeticEdgeList();
virtual void setSize(int newSize);
virtual int getSize(void) const;
/** Sets the property
*/
void setValue(const CosmeticEdge*);
void setValues(const std::vector<CosmeticEdge*>&);
/// index operator
const CosmeticEdge *operator[] (const int idx) const {
return _lValueList[idx];
}
const std::vector<CosmeticEdge*> &getValues(void) const {
return _lValueList;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
virtual void Save(Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual App::Property *Copy(void) const;
virtual void Paste(const App::Property &from);
virtual unsigned int getMemSize(void) const;
private:
std::vector<CosmeticEdge*> _lValueList;
};
} // namespace TechDraw
#endif // TECHDRAW_PropertyCosmeticEdgeList_H

View File

@@ -0,0 +1,225 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2010 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <assert.h>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Exception.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Base/Console.h>
#include "Cosmetic.h"
#include "CosmeticVertexPy.h"
#include "PropertyCosmeticVertexList.h"
using namespace App;
using namespace Base;
using namespace std;
using namespace TechDraw;
//**************************************************************************
// PropertyCosmeticVertexList
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(TechDraw::PropertyCosmeticVertexList, App::PropertyLists);
//**************************************************************************
// Construction/Destruction
PropertyCosmeticVertexList::PropertyCosmeticVertexList()
{
}
PropertyCosmeticVertexList::~PropertyCosmeticVertexList()
{
for (std::vector<CosmeticVertex*>::iterator it = _lValueList.begin(); it != _lValueList.end(); ++it)
if (*it) delete *it;
}
void PropertyCosmeticVertexList::setSize(int newSize)
{
for (unsigned int i = newSize; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(newSize);
}
int PropertyCosmeticVertexList::getSize(void) const
{
return static_cast<int>(_lValueList.size());
}
void PropertyCosmeticVertexList::setValue(const CosmeticVertex* lValue)
{
if (lValue) {
aboutToSetValue();
CosmeticVertex* newVal = lValue->clone();
for (unsigned int i = 0; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(1);
_lValueList[0] = newVal;
hasSetValue();
}
}
void PropertyCosmeticVertexList::setValues(const std::vector<CosmeticVertex*>& lValue)
{
aboutToSetValue();
std::vector<CosmeticVertex*> oldVals(_lValueList);
_lValueList.resize(lValue.size());
// copy all objects
for (unsigned int i = 0; i < lValue.size(); i++)
_lValueList[i] = lValue[i]->clone();
for (unsigned int i = 0; i < oldVals.size(); i++)
delete oldVals[i];
hasSetValue();
}
PyObject *PropertyCosmeticVertexList::getPyObject(void)
{
PyObject* list = PyList_New(getSize());
for (int i = 0; i < getSize(); i++)
PyList_SetItem( list, i, _lValueList[i]->getPyObject());
return list;
}
void PropertyCosmeticVertexList::setPyObject(PyObject *value)
{
// check container of this property to notify about changes
if (PySequence_Check(value)) {
Py_ssize_t nSize = PySequence_Size(value);
std::vector<CosmeticVertex*> values;
values.resize(nSize);
for (Py_ssize_t i=0; i < nSize; ++i) {
PyObject* item = PySequence_GetItem(value, i);
if (!PyObject_TypeCheck(item, &(CosmeticVertexPy::Type))) {
std::string error = std::string("types in list must be 'CosmeticVertex', not ");
error += item->ob_type->tp_name;
throw Base::TypeError(error);
}
values[i] = static_cast<CosmeticVertexPy*>(item)->getCosmeticVertexPtr();
}
setValues(values);
// if (part2d)
// part2d->acceptCosmeticVertex();
}
else if (PyObject_TypeCheck(value, &(CosmeticVertexPy::Type))) {
CosmeticVertexPy *pcObject = static_cast<CosmeticVertexPy*>(value);
setValue(pcObject->getCosmeticVertexPtr());
}
else {
std::string error = std::string("type must be 'CosmeticVertex' or list of 'CosmeticVertex', not ");
error += value->ob_type->tp_name;
throw Base::TypeError(error);
}
}
void PropertyCosmeticVertexList::Save(Writer &writer) const
{
writer.Stream() << writer.ind() << "<CosmeticVertexList count=\"" << getSize() <<"\">" << endl;
writer.incInd();
for (int i = 0; i < getSize(); i++) {
writer.Stream() << writer.ind() << "<CosmeticVertex type=\""
<< _lValueList[i]->getTypeId().getName() << "\">" << endl;
writer.incInd();
_lValueList[i]->Save(writer);
writer.decInd();
writer.Stream() << writer.ind() << "</CosmeticVertex>" << endl;
}
writer.decInd();
writer.Stream() << writer.ind() << "</CosmeticVertexList>" << endl ;
}
void PropertyCosmeticVertexList::Restore(Base::XMLReader &reader)
{
// read my element
reader.clearPartialRestoreObject();
reader.readElement("CosmeticVertexList");
// get the value of my attribute
int count = reader.getAttributeAsInteger("count");
std::vector<CosmeticVertex*> values;
values.reserve(count);
for (int i = 0; i < count; i++) {
reader.readElement("CosmeticVertex");
const char* TypeName = reader.getAttribute("type");
CosmeticVertex *newG = (CosmeticVertex *)Base::Type::fromName(TypeName).createInstance();
newG->Restore(reader);
if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) {
Base::Console().Error("CosmeticVertex \"%s\" within a PropertyCosmeticVertexList was subject to a partial restore.\n",reader.localName());
if(isOrderRelevant()) {
// Pushes the best try by the CosmeticVertex class
values.push_back(newG);
}
else {
delete newG;
}
reader.clearPartialRestoreObject();
}
else {
values.push_back(newG);
}
reader.readEndElement("CosmeticVertex");
}
reader.readEndElement("CosmeticVertexList");
// assignment
setValues(values);
}
App::Property *PropertyCosmeticVertexList::Copy(void) const
{
PropertyCosmeticVertexList *p = new PropertyCosmeticVertexList();
p->setValues(_lValueList);
return p;
}
void PropertyCosmeticVertexList::Paste(const Property &from)
{
const PropertyCosmeticVertexList& FromList = dynamic_cast<const PropertyCosmeticVertexList&>(from);
setValues(FromList._lValueList);
}
unsigned int PropertyCosmeticVertexList::getMemSize(void) const
{
int size = sizeof(PropertyCosmeticVertexList);
for (int i = 0; i < getSize(); i++)
size += _lValueList[i]->getMemSize();
return size;
}

View File

@@ -0,0 +1,97 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2010 *
* *
* 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_PropertyCosmeticVertexList_H
#define TECHDRAW_PropertyCosmeticVertexList_H
// Std. configurations
#include <vector>
#include <string>
#include <App/Property.h>
#include <Mod/TechDraw/App/CosmeticVertexPy.h>
#include "Cosmetic.h"
namespace Base {
class Writer;
}
namespace TechDraw
{
class CosmeticVertex;
class TechDrawExport PropertyCosmeticVertexList: public App::PropertyLists
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyCosmeticVertexList();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyCosmeticVertexList();
virtual void setSize(int newSize);
virtual int getSize(void) const;
/** Sets the property
*/
void setValue(const CosmeticVertex*);
void setValues(const std::vector<CosmeticVertex*>&);
/// index operator
const CosmeticVertex *operator[] (const int idx) const {
return _lValueList[idx];
}
const std::vector<CosmeticVertex*> &getValues(void) const {
return _lValueList;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
virtual void Save(Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual App::Property *Copy(void) const;
virtual void Paste(const App::Property &from);
virtual unsigned int getMemSize(void) const;
private:
std::vector<CosmeticVertex*> _lValueList;
};
} // namespace TechDraw
#endif // TECHDRAW_PropertyCosmeticVertexList_H

View File

@@ -0,0 +1,226 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2010 *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
# include <assert.h>
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Exception.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Base/Console.h>
#include "Cosmetic.h"
#include "GeomFormatPy.h"
#include "PropertyGeomFormatList.h"
using namespace App;
using namespace Base;
using namespace std;
using namespace TechDraw;
//**************************************************************************
// PropertyGeomFormatList
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TYPESYSTEM_SOURCE(TechDraw::PropertyGeomFormatList, App::PropertyLists);
//**************************************************************************
// Construction/Destruction
PropertyGeomFormatList::PropertyGeomFormatList()
{
}
PropertyGeomFormatList::~PropertyGeomFormatList()
{
for (std::vector<GeomFormat*>::iterator it = _lValueList.begin(); it != _lValueList.end(); ++it)
if (*it) delete *it;
}
void PropertyGeomFormatList::setSize(int newSize)
{
for (unsigned int i = newSize; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(newSize);
}
int PropertyGeomFormatList::getSize(void) const
{
return static_cast<int>(_lValueList.size());
}
void PropertyGeomFormatList::setValue(const GeomFormat* lValue)
{
if (lValue) {
aboutToSetValue();
GeomFormat* newVal = lValue->clone();
for (unsigned int i = 0; i < _lValueList.size(); i++)
delete _lValueList[i];
_lValueList.resize(1);
_lValueList[0] = newVal;
hasSetValue();
}
}
void PropertyGeomFormatList::setValues(const std::vector<GeomFormat*>& lValue)
{
aboutToSetValue();
std::vector<GeomFormat*> oldVals(_lValueList);
_lValueList.resize(lValue.size());
// copy all objects
for (unsigned int i = 0; i < lValue.size(); i++)
_lValueList[i] = lValue[i]->clone();
for (unsigned int i = 0; i < oldVals.size(); i++)
delete oldVals[i];
hasSetValue();
}
PyObject *PropertyGeomFormatList::getPyObject(void)
{
PyObject* list = PyList_New(getSize());
for (int i = 0; i < getSize(); i++)
PyList_SetItem( list, i, _lValueList[i]->getPyObject());
return list;
}
void PropertyGeomFormatList::setPyObject(PyObject *value)
{
// check container of this property to notify about changes
// Part2DObject* part2d = dynamic_cast<Part2DObject*>(this->getContainer());
if (PySequence_Check(value)) {
Py_ssize_t nSize = PySequence_Size(value);
std::vector<GeomFormat*> values;
values.resize(nSize);
for (Py_ssize_t i=0; i < nSize; ++i) {
PyObject* item = PySequence_GetItem(value, i);
if (!PyObject_TypeCheck(item, &(GeomFormatPy::Type))) {
std::string error = std::string("types in list must be 'GeomFormat', not ");
error += item->ob_type->tp_name;
throw Base::TypeError(error);
}
values[i] = static_cast<GeomFormatPy*>(item)->getGeomFormatPtr();
}
setValues(values);
// if (part2d)
// part2d->acceptGeomFormat();
}
else if (PyObject_TypeCheck(value, &(GeomFormatPy::Type))) {
GeomFormatPy *pcObject = static_cast<GeomFormatPy*>(value);
setValue(pcObject->getGeomFormatPtr());
}
else {
std::string error = std::string("type must be 'GeomFormat' or list of 'GeomFormat', not ");
error += value->ob_type->tp_name;
throw Base::TypeError(error);
}
}
void PropertyGeomFormatList::Save(Writer &writer) const
{
writer.Stream() << writer.ind() << "<GeomFormatList count=\"" << getSize() <<"\">" << endl;
writer.incInd();
for (int i = 0; i < getSize(); i++) {
writer.Stream() << writer.ind() << "<GeomFormat type=\""
<< _lValueList[i]->getTypeId().getName() << "\">" << endl;
writer.incInd();
_lValueList[i]->Save(writer);
writer.decInd();
writer.Stream() << writer.ind() << "</GeomFormat>" << endl;
}
writer.decInd();
writer.Stream() << writer.ind() << "</GeomFormatList>" << endl ;
}
void PropertyGeomFormatList::Restore(Base::XMLReader &reader)
{
// read my element
reader.clearPartialRestoreObject();
reader.readElement("GeomFormatList");
// get the value of my attribute
int count = reader.getAttributeAsInteger("count");
std::vector<GeomFormat*> values;
values.reserve(count);
for (int i = 0; i < count; i++) {
reader.readElement("GeomFormat");
const char* TypeName = reader.getAttribute("type");
GeomFormat *newG = (GeomFormat *)Base::Type::fromName(TypeName).createInstance();
newG->Restore(reader);
if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) {
Base::Console().Error("GeomFormat \"%s\" within a PropertyGeomFormatList was subject to a partial restore.\n",reader.localName());
if(isOrderRelevant()) {
// Pushes the best try by the GeomFormat class
values.push_back(newG);
}
else {
delete newG;
}
reader.clearPartialRestoreObject();
}
else {
values.push_back(newG);
}
reader.readEndElement("GeomFormat");
}
reader.readEndElement("GeomFormatList");
// assignment
setValues(values);
}
App::Property *PropertyGeomFormatList::Copy(void) const
{
PropertyGeomFormatList *p = new PropertyGeomFormatList();
p->setValues(_lValueList);
return p;
}
void PropertyGeomFormatList::Paste(const Property &from)
{
const PropertyGeomFormatList& FromList = dynamic_cast<const PropertyGeomFormatList&>(from);
setValues(FromList._lValueList);
}
unsigned int PropertyGeomFormatList::getMemSize(void) const
{
int size = sizeof(PropertyGeomFormatList);
for (int i = 0; i < getSize(); i++)
size += _lValueList[i]->getMemSize();
return size;
}

View File

@@ -0,0 +1,97 @@
/***************************************************************************
* Copyright (c) Jürgen Riegel (juergen.riegel@web.de) 2010 *
* *
* 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_PropertyGeomFormatList_H
#define TECHDRAW_PropertyGeomFormatList_H
// Std. configurations
#include <vector>
#include <string>
#include <App/Property.h>
#include <Mod/TechDraw/App/GeomFormatPy.h>
#include "Cosmetic.h"
namespace Base {
class Writer;
}
namespace TechDraw
{
class GeomFormat;
class TechDrawExport PropertyGeomFormatList: public App::PropertyLists
{
TYPESYSTEM_HEADER();
public:
/**
* A constructor.
* A more elaborate description of the constructor.
*/
PropertyGeomFormatList();
/**
* A destructor.
* A more elaborate description of the destructor.
*/
virtual ~PropertyGeomFormatList();
virtual void setSize(int newSize);
virtual int getSize(void) const;
/** Sets the property
*/
void setValue(const GeomFormat*);
void setValues(const std::vector<GeomFormat*>&);
/// index operator
const GeomFormat *operator[] (const int idx) const {
return _lValueList[idx];
}
const std::vector<GeomFormat*> &getValues(void) const {
return _lValueList;
}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
virtual void Save(Base::Writer &writer) const;
virtual void Restore(Base::XMLReader &reader);
virtual App::Property *Copy(void) const;
virtual void Paste(const App::Property &from);
virtual unsigned int getMemSize(void) const;
private:
std::vector<GeomFormat*> _lValueList;
};
} // namespace TechDraw
#endif // TECHDRAW_PropertyGeomFormatList_H

View File

@@ -166,7 +166,7 @@ void TaskLineDecor::onVisibleChanged(void)
void TaskLineDecor::applyDecorations(void)
{
Base::Console().Message("TLD::applyDecorations()\n");
// Base::Console().Message("TLD::applyDecorations()\n");
for (auto& e: m_edges) {
int num = DrawUtil::getIndexFromName(e);
BaseGeom* bg = m_partFeat->getGeomByIndex(num);
@@ -178,7 +178,6 @@ void TaskLineDecor::applyDecorations(void)
ce->m_format.m_color = m_color;
ce->m_format.m_weight = m_weight;
ce->m_format.m_visible = m_visible;
Base::Console().Message("TLD::applyDecorations()\n");
} else if (bg->source() == 2) {
TechDraw::CenterLine* cl = m_partFeat->getCenterLineByIndex(bg->sourceIndex());
cl->m_format.m_style = m_style;
@@ -211,14 +210,11 @@ void TaskLineDecor::applyDecorations(void)
bool TaskLineDecor::accept()
{
Base::Console().Message("TLD::accept()\n");
// Base::Console().Message("TLD::accept()\n");
Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument());
if (!doc) return false;
applyDecorations();
m_partFeat->writeGFormatProp();
m_partFeat->writeCEdgeProp();
m_partFeat->writeCLineProp();
m_partFeat->requestPaint();
@@ -230,7 +226,7 @@ bool TaskLineDecor::accept()
bool TaskLineDecor::reject()
{
Base::Console().Message("TLD::reject()\n");
// Base::Console().Message("TLD::reject()\n");
Gui::Document* doc = Gui::Application::Instance->getDocument(m_partFeat->getDocument());
if (!doc) return false;
@@ -274,7 +270,7 @@ void TaskRestoreLines::initUi()
void TaskRestoreLines::onAllPressed(void)
{
Base::Console().Message("TRL::onAllPressed()\n");
// Base::Console().Message("TRL::onAllPressed()\n");
onGeometryPressed();
onCosmeticPressed();
onCenterPressed();
@@ -282,29 +278,26 @@ void TaskRestoreLines::onAllPressed(void)
void TaskRestoreLines::onGeometryPressed(void)
{
Base::Console().Message("TRL::onGeometryPressed()\n");
// Base::Console().Message("TRL::onGeometryPressed()\n");
restoreInvisibleGeoms();
ui->l_Geometry->setText(QString::number(0));
ui->l_All->setText(QString::number(countInvisibleLines()));
m_partFeat->writeGFormatProp();
}
void TaskRestoreLines::onCosmeticPressed(void)
{
Base::Console().Message("TRL::onCosmeticPressed()\n");
// Base::Console().Message("TRL::onCosmeticPressed()\n");
restoreInvisibleCosmetics();
ui->l_Cosmetic->setText(QString::number(0));
ui->l_All->setText(QString::number(countInvisibleLines()));
m_partFeat->writeCEdgeProp();
}
void TaskRestoreLines::onCenterPressed(void)
{
Base::Console().Message("TRL::onCenterPressed()\n");
// Base::Console().Message("TRL::onCenterPressed()\n");
restoreInvisibleCenters();
ui->l_Center->setText(QString::number(0));
ui->l_All->setText(QString::number(countInvisibleLines()));
m_partFeat->writeCLineProp();
}
int TaskRestoreLines::countInvisibleLines(void)
@@ -319,7 +312,7 @@ int TaskRestoreLines::countInvisibleLines(void)
int TaskRestoreLines::countInvisibleGeoms(void)
{
int iGeoms = 0;
const std::vector<TechDraw::GeomFormat*> geoms = m_partFeat->getGeomFormats();
const std::vector<TechDraw::GeomFormat*> geoms = m_partFeat->GeomFormats.getValues();
for (auto& g : geoms) {
if (!g->m_format.m_visible) {
iGeoms++;
@@ -331,7 +324,7 @@ int TaskRestoreLines::countInvisibleGeoms(void)
int TaskRestoreLines::countInvisibleCosmetics(void)
{
int iCosmos = 0;
const std::vector<TechDraw::CosmeticEdge*> cosmos = m_partFeat->getCosmeticEdges();
const std::vector<TechDraw::CosmeticEdge*> cosmos = m_partFeat->CosmeticEdges.getValues();
for (auto& c : cosmos) {
if (!c->m_format.m_visible) {
iCosmos++;
@@ -343,7 +336,7 @@ int TaskRestoreLines::countInvisibleCosmetics(void)
int TaskRestoreLines::countInvisibleCenters(void)
{
int iCenter = 0;
const std::vector<TechDraw::CenterLine*> centers = m_partFeat->getCenterLines();
const std::vector<TechDraw::CenterLine*> centers = m_partFeat->CenterLines.getValues();
for (auto& c : centers) {
if (!c->m_format.m_visible) {
iCenter++;
@@ -361,44 +354,47 @@ void TaskRestoreLines::restoreInvisibleLines(void)
void TaskRestoreLines::restoreInvisibleGeoms(void)
{
const std::vector<TechDraw::GeomFormat*> geoms = m_partFeat->getGeomFormats();
const std::vector<TechDraw::GeomFormat*> geoms = m_partFeat->GeomFormats.getValues();
for (auto& g : geoms) {
if (!g->m_format.m_visible) {
g->m_format.m_visible = true;
}
}
m_partFeat->GeomFormats.setValues(geoms);
}
void TaskRestoreLines::restoreInvisibleCosmetics(void)
{
const std::vector<TechDraw::CosmeticEdge*> cosmos = m_partFeat->getCosmeticEdges();
const std::vector<TechDraw::CosmeticEdge*> cosmos = m_partFeat->CosmeticEdges.getValues();
for (auto& c : cosmos) {
if (!c->m_format.m_visible) {
c->m_format.m_visible = true;
}
}
m_partFeat->CosmeticEdges.setValues(cosmos);
}
void TaskRestoreLines::restoreInvisibleCenters(void)
{
const std::vector<TechDraw::CenterLine*> centers = m_partFeat->getCenterLines();
const std::vector<TechDraw::CenterLine*> centers = m_partFeat->CenterLines.getValues();
for (auto& c : centers) {
if (!c->m_format.m_visible) {
c->m_format.m_visible = true;
}
}
m_partFeat->CenterLines.setValues(centers);
}
bool TaskRestoreLines::accept()
{
Base::Console().Message("TRL::accept()\n");
// Base::Console().Message("TRL::accept()\n");
return true;
}
bool TaskRestoreLines::reject()
{
Base::Console().Message("TRL::reject()\n");
// Base::Console().Message("TRL::reject()\n");
return false;
}
@@ -447,14 +443,14 @@ void TaskDlgLineDecor::clicked(int i)
bool TaskDlgLineDecor::accept()
{
Base::Console().Message("TDLD::accept()\n");
// Base::Console().Message("TDLD::accept()\n");
widget->accept();
return true;
}
bool TaskDlgLineDecor::reject()
{
Base::Console().Message("TDLD::reject()\n");
// Base::Console().Message("TDLD::reject()\n");
widget->reject();
return true;
}