[TD]Py Cosmetic Vertex, Line, Circle Arc
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
#include "ViewProviderPage.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
|
||||
|
||||
@@ -346,14 +347,14 @@ void execMidpoints(Gui::Command* cmd)
|
||||
}
|
||||
|
||||
//combine 2 loops?
|
||||
const std::vector<TechDrawGeometry::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
const std::vector<TechDraw::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
double scale = objFeat->getScale();
|
||||
for (auto& s: SubNames) {
|
||||
int GeoId(TechDraw::DrawUtil::getIndexFromName(s));
|
||||
TechDrawGeometry::BaseGeom* geom = edges.at(GeoId);
|
||||
Base::Vector2d mid = geom->getMidPoint();
|
||||
Base::Vector3d mid3(mid.x / scale, - mid.y / scale, 0.0);
|
||||
objFeat->addRandomVertex(mid3);
|
||||
TechDraw::BaseGeom* geom = edges.at(GeoId);
|
||||
Base::Vector3d mid = geom->getMidPoint();
|
||||
// Base::Vector3d mid3(mid.x / scale, - mid.y / scale, 0.0);
|
||||
objFeat->addCosmeticVertex(mid / scale);
|
||||
}
|
||||
cmd->updateActive();
|
||||
// Base::Console().Message("execMidpoints - exits\n");
|
||||
@@ -387,18 +388,18 @@ void execQuadrant(Gui::Command* cmd)
|
||||
}
|
||||
|
||||
//combine 2 loops?
|
||||
const std::vector<TechDrawGeometry::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
const std::vector<TechDraw::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
double scale = objFeat->getScale();
|
||||
bool nonCircles = false;
|
||||
for (auto& s: SubNames) {
|
||||
int GeoId(TechDraw::DrawUtil::getIndexFromName(s));
|
||||
TechDrawGeometry::BaseGeom* geom = edges.at(GeoId);
|
||||
TechDraw::BaseGeom* geom = edges.at(GeoId);
|
||||
//TODO: should this be restricted to circles??
|
||||
// if (geom->geomType == TechDrawGeometry::CIRCLE) {
|
||||
std::vector<Base::Vector2d> quads = geom->getQuads();
|
||||
// if (geom->geomType == TechDraw::CIRCLE) {
|
||||
std::vector<Base::Vector3d> quads = geom->getQuads();
|
||||
for (auto& q: quads) {
|
||||
Base::Vector3d q3(q.x / scale, - q.y / scale, 0.0);
|
||||
objFeat->addRandomVertex(q3);
|
||||
// Base::Vector3d q3(q.x / scale, - q.y / scale, 0.0);
|
||||
objFeat->addCosmeticVertex(q / scale);
|
||||
}
|
||||
// } else {
|
||||
// nonCircles = true;
|
||||
@@ -641,7 +642,15 @@ void CmdTechDrawFaceCenterLine::activated(int iMsg)
|
||||
SubNames = (*itSel).getSubNames();
|
||||
}
|
||||
}
|
||||
if (SubNames.empty()) {
|
||||
std::vector<std::string> faceNames;
|
||||
for (auto& s: SubNames) {
|
||||
std::string geomType = DrawUtil::getGeomTypeFromName(s);
|
||||
if (geomType == "Face") {
|
||||
faceNames.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (faceNames.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
QObject::tr("You must select a Face(s) for the center line."));
|
||||
return;
|
||||
@@ -649,7 +658,7 @@ void CmdTechDrawFaceCenterLine::activated(int iMsg)
|
||||
|
||||
Gui::Control().showDialog(new TaskDlgCenterLine(baseFeat,
|
||||
page,
|
||||
SubNames));
|
||||
faceNames));
|
||||
}
|
||||
|
||||
bool CmdTechDrawFaceCenterLine::isActive(void)
|
||||
@@ -728,12 +737,12 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg)
|
||||
if (geomType == "Edge") {
|
||||
TechDraw::CosmeticEdge* ce = objFeat->getCosmeticEdgeByLink(idx);
|
||||
if (ce != nullptr) {
|
||||
objFeat->removeRandomEdge(ce);
|
||||
objFeat->removeCosmeticEdge(ce);
|
||||
}
|
||||
} else if (geomType == "Vertex") {
|
||||
TechDraw::CosmeticVertex* cv = objFeat->getCosmeticVertexByLink(idx);
|
||||
if (cv != nullptr) {
|
||||
objFeat->removeRandomVertex(cv);
|
||||
objFeat->removeCosmeticVertex(cv);
|
||||
}
|
||||
} else {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
|
||||
@@ -1158,18 +1158,18 @@ int _isValidSingleEdge(Gui::Command* cmd) {
|
||||
if (SubNames.size() == 1) { //only 1 subshape selected
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") { //the Name starts with "Edge"
|
||||
int GeoId( TechDraw::DrawUtil::getIndexFromName(SubNames[0]) );
|
||||
TechDrawGeometry::BaseGeom* geom = objFeat->getProjEdgeByIndex(GeoId);
|
||||
TechDraw::BaseGeom* geom = objFeat->getProjEdgeByIndex(GeoId);
|
||||
if (!geom) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d\n",GeoId);
|
||||
return isInvalid;
|
||||
}
|
||||
|
||||
if(geom->geomType == TechDrawGeometry::GENERIC) {
|
||||
TechDrawGeometry::Generic* gen1 = static_cast<TechDrawGeometry::Generic *>(geom);
|
||||
if(geom->geomType == TechDraw::GENERIC) {
|
||||
TechDraw::Generic* gen1 = static_cast<TechDraw::Generic *>(geom);
|
||||
if(gen1->points.size() > 2) { //the edge is a polyline
|
||||
return isInvalid;
|
||||
}
|
||||
Base::Vector2d line = gen1->points.at(1) - gen1->points.at(0);
|
||||
Base::Vector3d line = gen1->points.at(1) - gen1->points.at(0);
|
||||
if(fabs(line.y) < FLT_EPSILON ) {
|
||||
edgeType = isHorizontal;
|
||||
} else if(fabs(line.x) < FLT_EPSILON) {
|
||||
@@ -1177,14 +1177,14 @@ int _isValidSingleEdge(Gui::Command* cmd) {
|
||||
} else {
|
||||
edgeType = isDiagonal;
|
||||
}
|
||||
} else if (geom->geomType == TechDrawGeometry::CIRCLE ||
|
||||
geom->geomType == TechDrawGeometry::ARCOFCIRCLE ) {
|
||||
} else if (geom->geomType == TechDraw::CIRCLE ||
|
||||
geom->geomType == TechDraw::ARCOFCIRCLE ) {
|
||||
edgeType = isCircle;
|
||||
} else if (geom->geomType == TechDrawGeometry::ELLIPSE ||
|
||||
geom->geomType == TechDrawGeometry::ARCOFELLIPSE) {
|
||||
} else if (geom->geomType == TechDraw::ELLIPSE ||
|
||||
geom->geomType == TechDraw::ARCOFELLIPSE) {
|
||||
edgeType = isEllipse;
|
||||
} else if (geom->geomType == TechDrawGeometry::BSPLINE) {
|
||||
TechDrawGeometry::BSpline* spline = static_cast<TechDrawGeometry::BSpline*>(geom);
|
||||
} else if (geom->geomType == TechDraw::BSPLINE) {
|
||||
TechDraw::BSpline* spline = static_cast<TechDraw::BSpline*>(geom);
|
||||
if (spline->isCircle()) {
|
||||
edgeType = isBSplineCircle;
|
||||
} else {
|
||||
@@ -1235,23 +1235,23 @@ int _isValidEdgeToEdge(Gui::Command* cmd) {
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
||||
int GeoId0( TechDraw::DrawUtil::getIndexFromName(SubNames[0]) );
|
||||
int GeoId1( TechDraw::DrawUtil::getIndexFromName(SubNames[1]) );
|
||||
TechDrawGeometry::BaseGeom* geom0 = objFeat0->getProjEdgeByIndex(GeoId0);
|
||||
TechDrawGeometry::BaseGeom* geom1 = objFeat0->getProjEdgeByIndex(GeoId1);
|
||||
TechDraw::BaseGeom* geom0 = objFeat0->getProjEdgeByIndex(GeoId0);
|
||||
TechDraw::BaseGeom* geom1 = objFeat0->getProjEdgeByIndex(GeoId1);
|
||||
if ((!geom0) || (!geom1)) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",GeoId0,GeoId1);
|
||||
return isInvalid;
|
||||
}
|
||||
|
||||
if(geom0->geomType == TechDrawGeometry::GENERIC &&
|
||||
geom1->geomType == TechDrawGeometry::GENERIC) {
|
||||
TechDrawGeometry::Generic *gen0 = static_cast<TechDrawGeometry::Generic *>(geom0);
|
||||
TechDrawGeometry::Generic *gen1 = static_cast<TechDrawGeometry::Generic *>(geom1);
|
||||
if(geom0->geomType == TechDraw::GENERIC &&
|
||||
geom1->geomType == TechDraw::GENERIC) {
|
||||
TechDraw::Generic *gen0 = static_cast<TechDraw::Generic *>(geom0);
|
||||
TechDraw::Generic *gen1 = static_cast<TechDraw::Generic *>(geom1);
|
||||
if(gen0->points.size() > 2 ||
|
||||
gen1->points.size() > 2) { //the edge is a polyline
|
||||
return isInvalid;
|
||||
}
|
||||
Base::Vector2d line0 = gen0->points.at(1) - gen0->points.at(0);
|
||||
Base::Vector2d line1 = gen1->points.at(1) - gen1->points.at(0);
|
||||
Base::Vector3d line0 = gen0->points.at(1) - gen0->points.at(0);
|
||||
Base::Vector3d line1 = gen1->points.at(1) - gen1->points.at(0);
|
||||
double xprod = fabs(line0.x * line1.y - line0.y * line1.x);
|
||||
if(xprod > FLT_EPSILON) { //edges are not parallel
|
||||
return isAngle;
|
||||
@@ -1280,8 +1280,8 @@ bool _isValidVertexToEdge(Gui::Command* cmd) {
|
||||
const std::vector<std::string> SubNames = selection[0].getSubNames();
|
||||
if(SubNames.size() == 2) { //there are 2
|
||||
int eId,vId;
|
||||
TechDrawGeometry::BaseGeom* e;
|
||||
TechDrawGeometry::Vertex* v;
|
||||
TechDraw::BaseGeom* e;
|
||||
TechDraw::Vertex* v;
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" &&
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Vertex") {
|
||||
eId = TechDraw::DrawUtil::getIndexFromName(SubNames[0]);
|
||||
@@ -1299,7 +1299,7 @@ bool _isValidVertexToEdge(Gui::Command* cmd) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",eId,vId);
|
||||
return false;
|
||||
}
|
||||
if (e->geomType != TechDrawGeometry::GENERIC) { //only vertex-line for now.
|
||||
if (e->geomType != TechDraw::GENERIC) { //only vertex-line for now.
|
||||
return false;
|
||||
}
|
||||
result = true;
|
||||
|
||||
@@ -96,9 +96,9 @@ void QGIDrawingTemplate::draw()
|
||||
// Clear the previous geometry stored
|
||||
|
||||
// Get a list of geometry and iterate
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> &geoms = tmplte->getGeometry();
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = tmplte->getGeometry();
|
||||
|
||||
std::vector<TechDrawGeometry::BaseGeom *>::const_iterator it = geoms.begin();
|
||||
std::vector<TechDraw::BaseGeom *>::const_iterator it = geoms.begin();
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
@@ -106,12 +106,12 @@ void QGIDrawingTemplate::draw()
|
||||
// iterate through all the geometries
|
||||
for(; it != geoms.end(); ++it) {
|
||||
switch((*it)->geomType) {
|
||||
case TechDrawGeometry::GENERIC: {
|
||||
case TechDraw::GENERIC: {
|
||||
|
||||
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(*it);
|
||||
TechDraw::Generic *geom = static_cast<TechDraw::Generic *>(*it);
|
||||
|
||||
path.moveTo(geom->points[0].x, geom->points[0].y);
|
||||
std::vector<Base::Vector2d>::const_iterator it = geom->points.begin();
|
||||
std::vector<Base::Vector3d>::const_iterator it = geom->points.begin();
|
||||
|
||||
for(++it; it != geom->points.end(); ++it) {
|
||||
path.lineTo((*it).x, (*it).y);
|
||||
|
||||
@@ -50,8 +50,10 @@ QGIEdge::QGIEdge(int index) :
|
||||
setCosmetic(isCosmetic);
|
||||
}
|
||||
|
||||
//NOTE this refers to Qt cosmetic lines
|
||||
void QGIEdge::setCosmetic(bool state)
|
||||
{
|
||||
// Base::Console().Message("QGIE::setCosmetic(%d)\n", state);
|
||||
isCosmetic = state;
|
||||
if (state) {
|
||||
setWidth(0.0);
|
||||
|
||||
@@ -285,7 +285,7 @@ QGraphicsPathItem* QGIFace::lineFromPoints(Base::Vector3d start, Base::Vector3d
|
||||
return fillItem;
|
||||
}
|
||||
|
||||
QGraphicsPathItem* QGIFace::geomToLine(TechDrawGeometry::BaseGeom* base, LineSet& ls)
|
||||
QGraphicsPathItem* QGIFace::geomToLine(TechDraw::BaseGeom* base, LineSet& ls)
|
||||
{
|
||||
QGraphicsPathItem* fillItem = new QGraphicsPathItem(this);
|
||||
Base::Vector3d start(base->getStartPoint().x,
|
||||
@@ -302,7 +302,7 @@ QGraphicsPathItem* QGIFace::geomToLine(TechDrawGeometry::BaseGeom* base, LineSe
|
||||
|
||||
|
||||
//! make a fragment (length = remain) of a dashed line, with pattern starting at +offset
|
||||
QGraphicsPathItem* QGIFace::geomToStubbyLine(TechDrawGeometry::BaseGeom* base, double remain, LineSet& ls)
|
||||
QGraphicsPathItem* QGIFace::geomToStubbyLine(TechDraw::BaseGeom* base, double remain, LineSet& ls)
|
||||
{
|
||||
QGraphicsPathItem* fillItem = new QGraphicsPathItem(this);
|
||||
Base::Vector3d start(base->getStartPoint().x,
|
||||
|
||||
@@ -110,9 +110,9 @@ public:
|
||||
void clearFillItems(void);
|
||||
|
||||
void lineSetToFillItems(LineSet& ls);
|
||||
QGraphicsPathItem* geomToLine(TechDrawGeometry::BaseGeom* base,LineSet& ls);
|
||||
// QGraphicsPathItem* geomToOffsetLine(TechDrawGeometry::BaseGeom* base, double offset, const LineSet& ls);
|
||||
QGraphicsPathItem* geomToStubbyLine(TechDrawGeometry::BaseGeom* base, double offset, LineSet& ls);
|
||||
QGraphicsPathItem* geomToLine(TechDraw::BaseGeom* base,LineSet& ls);
|
||||
// QGraphicsPathItem* geomToOffsetLine(TechDraw::BaseGeom* base, double offset, const LineSet& ls);
|
||||
QGraphicsPathItem* geomToStubbyLine(TechDraw::BaseGeom* base, double offset, LineSet& ls);
|
||||
QGraphicsPathItem* lineFromPoints(Base::Vector3d start, Base::Vector3d end, DashSpec ds);
|
||||
|
||||
//bitmap texture fill parms method
|
||||
@@ -127,7 +127,7 @@ protected:
|
||||
std::vector<double> offsetDash(const std::vector<double> dv, const double offset);
|
||||
QPainterPath dashedPPath(const std::vector<double> dv, const Base::Vector3d start, const Base::Vector3d end);
|
||||
double dashRemain(const std::vector<double> dv, const double offset);
|
||||
double calcOffset(TechDrawGeometry::BaseGeom* g,LineSet ls);
|
||||
double calcOffset(TechDraw::BaseGeom* g,LineSet ls);
|
||||
int projIndex; //index of face in Projection. -1 for SectionFace.
|
||||
QGCustomRect *m_rect;
|
||||
|
||||
|
||||
@@ -204,17 +204,20 @@ QColor QGIPrimPath::getSelectColor()
|
||||
|
||||
void QGIPrimPath::setWidth(double w)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::setWidth(%.3f)\n", w);
|
||||
m_width = w;
|
||||
m_pen.setWidthF(m_width);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setStyle(Qt::PenStyle s)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::setStyle(QTPS: %d)\n", s);
|
||||
m_styleCurrent = s;
|
||||
}
|
||||
|
||||
void QGIPrimPath::setStyle(int s)
|
||||
{
|
||||
// Base::Console().Message("QGIPP::setStyle(int: %d)\n", s);
|
||||
m_styleCurrent = (Qt::PenStyle) s;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace TechDraw {
|
||||
class DrawViewBalloon;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
namespace TechDraw {
|
||||
class BaseGeom;
|
||||
class AOC;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace TechDraw {
|
||||
class DrawViewDimension;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
namespace TechDraw {
|
||||
class BaseGeom;
|
||||
class AOC;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,6 @@
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDrawGeometry;
|
||||
|
||||
const float lineScaleFactor = Rez::guiX(1.); // temp fiddle for devel
|
||||
|
||||
@@ -132,21 +131,21 @@ void QGIViewPart::setViewPartFeature(TechDraw::DrawViewPart *obj)
|
||||
setViewFeature(static_cast<TechDraw::DrawView *>(obj));
|
||||
}
|
||||
|
||||
QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom) const
|
||||
QPainterPath QGIViewPart::drawPainterPath(TechDraw::BaseGeom *baseGeom) const
|
||||
{
|
||||
double rot = getViewObject()->Rotation.getValue();
|
||||
return geomToPainterPath(baseGeom,rot);
|
||||
}
|
||||
|
||||
|
||||
QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom, double rot)
|
||||
QPainterPath QGIViewPart::geomToPainterPath(TechDraw::BaseGeom *baseGeom, double rot)
|
||||
{
|
||||
Q_UNUSED(rot);
|
||||
QPainterPath path;
|
||||
|
||||
switch(baseGeom->geomType) {
|
||||
case TechDrawGeometry::CIRCLE: {
|
||||
TechDrawGeometry::Circle *geom = static_cast<TechDrawGeometry::Circle *>(baseGeom);
|
||||
case TechDraw::CIRCLE: {
|
||||
TechDraw::Circle *geom = static_cast<TechDraw::Circle *>(baseGeom);
|
||||
|
||||
double x = geom->center.x - geom->radius;
|
||||
double y = geom->center.y - geom->radius;
|
||||
@@ -156,8 +155,8 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
Rez::guiX(geom->radius * 2),
|
||||
Rez::guiX(geom->radius * 2)); //topleft@(x,y) radx,rady
|
||||
} break;
|
||||
case TechDrawGeometry::ARCOFCIRCLE: {
|
||||
TechDrawGeometry::AOC *geom = static_cast<TechDrawGeometry::AOC *>(baseGeom);
|
||||
case TechDraw::ARCOFCIRCLE: {
|
||||
TechDraw::AOC *geom = static_cast<TechDraw::AOC *>(baseGeom);
|
||||
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->radius),
|
||||
@@ -170,8 +169,8 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
} break;
|
||||
case TechDrawGeometry::ELLIPSE: {
|
||||
TechDrawGeometry::Ellipse *geom = static_cast<TechDrawGeometry::Ellipse *>(baseGeom);
|
||||
case TechDraw::ELLIPSE: {
|
||||
TechDraw::Ellipse *geom = static_cast<TechDraw::Ellipse *>(baseGeom);
|
||||
|
||||
// Calculate start and end points as ellipse with theta = 0 and pi
|
||||
double startX = geom->center.x + geom->major * cos(geom->angle),
|
||||
@@ -202,8 +201,8 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
Rez::guiX(endY));
|
||||
|
||||
} break;
|
||||
case TechDrawGeometry::ARCOFELLIPSE: {
|
||||
TechDrawGeometry::AOE *geom = static_cast<TechDrawGeometry::AOE *>(baseGeom);
|
||||
case TechDraw::ARCOFELLIPSE: {
|
||||
TechDraw::AOE *geom = static_cast<TechDraw::AOE *>(baseGeom);
|
||||
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
@@ -217,8 +216,8 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
|
||||
} break;
|
||||
case TechDrawGeometry::BEZIER: {
|
||||
TechDrawGeometry::BezierSegment *geom = static_cast<TechDrawGeometry::BezierSegment *>(baseGeom);
|
||||
case TechDraw::BEZIER: {
|
||||
TechDraw::BezierSegment *geom = static_cast<TechDraw::BezierSegment *>(baseGeom);
|
||||
|
||||
// Move painter to the beginning
|
||||
path.moveTo(Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y));
|
||||
@@ -243,10 +242,10 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case TechDrawGeometry::BSPLINE: {
|
||||
TechDrawGeometry::BSpline *geom = static_cast<TechDrawGeometry::BSpline *>(baseGeom);
|
||||
case TechDraw::BSPLINE: {
|
||||
TechDraw::BSpline *geom = static_cast<TechDraw::BSpline *>(baseGeom);
|
||||
|
||||
std::vector<TechDrawGeometry::BezierSegment>::const_iterator it = geom->segments.begin();
|
||||
std::vector<TechDraw::BezierSegment>::const_iterator it = geom->segments.begin();
|
||||
|
||||
// Move painter to the beginning of our first segment
|
||||
path.moveTo(Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y));
|
||||
@@ -272,11 +271,11 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case TechDrawGeometry::GENERIC: {
|
||||
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(baseGeom);
|
||||
case TechDraw::GENERIC: {
|
||||
TechDraw::Generic *geom = static_cast<TechDraw::Generic *>(baseGeom);
|
||||
|
||||
path.moveTo(Rez::guiX(geom->points[0].x), Rez::guiX(geom->points[0].y));
|
||||
std::vector<Base::Vector2d>::const_iterator it = geom->points.begin();
|
||||
std::vector<Base::Vector3d>::const_iterator it = geom->points.begin();
|
||||
for(++it; it != geom->points.end(); ++it) {
|
||||
path.lineTo(Rez::guiX((*it).x), Rez::guiX((*it).y));
|
||||
}
|
||||
@@ -334,6 +333,7 @@ void QGIViewPart::draw() {
|
||||
|
||||
void QGIViewPart::drawViewPart()
|
||||
{
|
||||
// Base::Console().Message("QGIVP::dvp()\n");
|
||||
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
if ( viewPart == nullptr ) {
|
||||
return;
|
||||
@@ -364,8 +364,8 @@ void QGIViewPart::drawViewPart()
|
||||
// Draw Faces
|
||||
std::vector<TechDraw::DrawHatch*> hatchObjs = viewPart->getHatches();
|
||||
std::vector<TechDraw::DrawGeomHatch*> geomObjs = viewPart->getGeomHatches();
|
||||
const std::vector<TechDrawGeometry::Face *> &faceGeoms = viewPart->getFaceGeometry();
|
||||
std::vector<TechDrawGeometry::Face *>::const_iterator fit = faceGeoms.begin();
|
||||
const std::vector<TechDraw::Face *> &faceGeoms = viewPart->getFaceGeometry();
|
||||
std::vector<TechDraw::Face *>::const_iterator fit = faceGeoms.begin();
|
||||
for(int i = 0 ; fit != faceGeoms.end(); fit++, i++) {
|
||||
QGIFace* newFace = drawFace(*fit,i);
|
||||
newFace->isHatched(false);
|
||||
@@ -417,8 +417,8 @@ void QGIViewPart::drawViewPart()
|
||||
#endif //#if MOD_TECHDRAW_HANDLE_FACES
|
||||
|
||||
// Draw Edges
|
||||
const std::vector<TechDrawGeometry::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
|
||||
std::vector<TechDrawGeometry::BaseGeom *>::const_iterator itEdge = geoms.begin();
|
||||
const std::vector<TechDraw::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
|
||||
std::vector<TechDraw::BaseGeom *>::const_iterator itEdge = geoms.begin();
|
||||
QGIEdge* item;
|
||||
for(int i = 0 ; itEdge != geoms.end(); itEdge++, i++) {
|
||||
bool showEdge = false;
|
||||
@@ -445,15 +445,14 @@ void QGIViewPart::drawViewPart()
|
||||
if ((*itEdge)->cosmetic == true) {
|
||||
TechDraw::CosmeticEdge* ce = viewPart->getCosmeticEdgeByLink(i);
|
||||
if (ce != nullptr) {
|
||||
item->setNormalColor(ce->color.asValue<QColor>());
|
||||
item->setWidth(ce->width * lineScaleFactor);
|
||||
item->setStyle(ce->style);
|
||||
item->setNormalColor(ce->m_format.m_color.asValue<QColor>());
|
||||
item->setWidth(ce->m_format.m_weight * lineScaleFactor);
|
||||
item->setStyle(ce->m_format.m_style);
|
||||
}
|
||||
}
|
||||
addToGroup(item); //item is at scene(0,0), not group(0,0)
|
||||
item->setPos(0.0,0.0); //now at group(0,0)
|
||||
item->setPath(drawPainterPath(*itEdge));
|
||||
// item->setWidth(lineWidth);
|
||||
item->setZValue(ZVALUE::EDGE);
|
||||
if(!(*itEdge)->visible) {
|
||||
item->setWidth(lineWidthHid);
|
||||
@@ -502,8 +501,8 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<TechDrawGeometry::Vertex *> &verts = viewPart->getVertexGeometry();
|
||||
std::vector<TechDrawGeometry::Vertex *>::const_iterator vert = verts.begin();
|
||||
const std::vector<TechDraw::Vertex *> &verts = viewPart->getVertexGeometry();
|
||||
std::vector<TechDraw::Vertex *>::const_iterator vert = verts.begin();
|
||||
double cAdjust = vp->CenterScale.getValue();
|
||||
|
||||
for(int i = 0 ; vert != verts.end(); ++vert, i++) {
|
||||
@@ -529,7 +528,7 @@ void QGIViewPart::drawViewPart()
|
||||
item->setRadius(lineWidth * vertexScaleFactor);
|
||||
}
|
||||
addToGroup(item);
|
||||
item->setPos(Rez::guiX((*vert)->pnt.x), Rez::guiX((*vert)->pnt.y));
|
||||
item->setPos(Rez::guiX((*vert)->point.x), Rez::guiX((*vert)->point.y));
|
||||
item->setPrettyNormal();
|
||||
item->setZValue(ZVALUE::VERTEX);
|
||||
}
|
||||
@@ -543,13 +542,13 @@ void QGIViewPart::drawViewPart()
|
||||
}
|
||||
}
|
||||
|
||||
QGIFace* QGIViewPart::drawFace(TechDrawGeometry::Face* f, int idx)
|
||||
QGIFace* QGIViewPart::drawFace(TechDraw::Face* f, int idx)
|
||||
{
|
||||
std::vector<TechDrawGeometry::Wire *> fWires = f->wires;
|
||||
std::vector<TechDraw::Wire *> fWires = f->wires;
|
||||
QPainterPath facePath;
|
||||
for(std::vector<TechDrawGeometry::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
|
||||
for(std::vector<TechDraw::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
|
||||
QPainterPath wirePath;
|
||||
for(std::vector<TechDrawGeometry::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
|
||||
for(std::vector<TechDraw::BaseGeom *>::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) {
|
||||
//Save the start Position
|
||||
QPainterPath edgePath = drawPainterPath(*edge);
|
||||
// If the current end point matches the shape end point the new edge path needs reversing
|
||||
@@ -993,6 +992,7 @@ void QGIViewPart::toggleCosmeticLines(bool state)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TechDraw::DrawHatch* QGIViewPart::faceIsHatched(int i,std::vector<TechDraw::DrawHatch*> hatchObjs) const
|
||||
{
|
||||
TechDraw::DrawHatch* result = nullptr;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
virtual void rotateView(void) override;
|
||||
|
||||
|
||||
static QPainterPath geomToPainterPath(TechDrawGeometry::BaseGeom *baseGeom, double rotation = 0.0);
|
||||
static QPainterPath geomToPainterPath(TechDraw::BaseGeom *baseGeom, double rotation = 0.0);
|
||||
/// Helper for pathArc()
|
||||
/*!
|
||||
* x_axis_rotation is in radian
|
||||
@@ -91,9 +91,9 @@ public:
|
||||
double curx, double cury);
|
||||
|
||||
protected:
|
||||
QPainterPath drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom) const;
|
||||
QPainterPath drawPainterPath(TechDraw::BaseGeom *baseGeom) const;
|
||||
void drawViewPart();
|
||||
QGIFace* drawFace(TechDrawGeometry::Face* f, int idx);
|
||||
QGIFace* drawFace(TechDraw::Face* f, int idx);
|
||||
|
||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ void QGIViewSection::drawSectionFace()
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<TechDrawGeometry::Face *>::iterator fit = sectionFaces.begin();
|
||||
std::vector<TechDraw::Face *>::iterator fit = sectionFaces.begin();
|
||||
QColor faceColor = (sectionVp->CutSurfaceColor.getValue()).asValue<QColor>();
|
||||
int i = 0;
|
||||
for(; fit != sectionFaces.end(); fit++, i++) {
|
||||
|
||||
@@ -55,12 +55,6 @@ double Rez::guiX(double x)
|
||||
return getRezFactor() * x;
|
||||
}
|
||||
|
||||
Base::Vector2d Rez::guiX(Base::Vector2d v)
|
||||
{
|
||||
Base::Vector2d result(guiX(v.y),guiX(v.y));
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Rez::guiX(Base::Vector3d v)
|
||||
{
|
||||
Base::Vector3d result(guiX(v.x),guiX(v.y),guiX(v.z));
|
||||
@@ -73,12 +67,6 @@ double Rez::appX(double x)
|
||||
return x / getRezFactor();
|
||||
}
|
||||
|
||||
Base::Vector2d Rez::appX(Base::Vector2d v)
|
||||
{
|
||||
Base::Vector2d result(appX(v.y),appX(v.y));
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Rez::appX(Base::Vector3d v)
|
||||
{
|
||||
Base::Vector3d result(appX(v.x),appX(v.y),appX(v.z));
|
||||
|
||||
@@ -41,11 +41,9 @@ public:
|
||||
static void setRezFactor(double f);
|
||||
//turn App side value to Gui side value
|
||||
static double guiX(double x);
|
||||
static Base::Vector2d guiX(Base::Vector2d v);
|
||||
static Base::Vector3d guiX(Base::Vector3d v);
|
||||
//turn Gui side value to App side value
|
||||
static double appX(double x);
|
||||
static Base::Vector2d appX(Base::Vector2d v);
|
||||
static Base::Vector3d appX(Base::Vector3d v);
|
||||
static QPointF appX(QPointF p);
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ void TaskCenterLine::createCenterLine(void)
|
||||
}
|
||||
m_extendBy = ui->qsbExtend->rawValue();
|
||||
TechDraw::CosmeticEdge* ce = calcEndPoints(m_subNames,vertical,m_extendBy);
|
||||
m_partFeat->addRandomEdge(ce);
|
||||
m_partFeat->addCosmeticEdge(ce);
|
||||
m_partFeat->requestPaint();
|
||||
Gui::Command::updateActive();
|
||||
Gui::Command::commitCommand();
|
||||
@@ -302,7 +302,7 @@ TechDraw::CosmeticEdge* TaskCenterLine::calcEndPoints(std::vector<std::string> f
|
||||
continue;
|
||||
}
|
||||
int idx = TechDraw::DrawUtil::getIndexFromName(fn);
|
||||
std::vector<TechDrawGeometry::BaseGeom*> faceEdges =
|
||||
std::vector<TechDraw::BaseGeom*> faceEdges =
|
||||
m_partFeat->getFaceEdgesByIndex(idx);
|
||||
for (auto& fe: faceEdges) {
|
||||
if (!fe->cosmetic) {
|
||||
@@ -339,13 +339,13 @@ TechDraw::CosmeticEdge* TaskCenterLine::calcEndPoints(std::vector<std::string> f
|
||||
p2 = right;
|
||||
}
|
||||
|
||||
result = new TechDraw::CosmeticEdge(p1, p2, scale); //p1 & p2 are as found in GO.
|
||||
result = new TechDraw::CosmeticEdge(p1 / scale, p2 / scale); //p1 & p2 are as found in GO.
|
||||
App::Color ac;
|
||||
ac.setValue<QColor>(ui->cpLineColor->color());
|
||||
result->color = ac;
|
||||
result->width = ui->dsbWeight->value();
|
||||
result->style = ui->cboxStyle->currentIndex();
|
||||
result->visible = true;
|
||||
result->m_format.m_color = ac;
|
||||
result->m_format.m_weight = ui->dsbWeight->value();
|
||||
result->m_format.m_style = ui->cboxStyle->currentIndex();
|
||||
result->m_format.m_visible = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class DrawView;
|
||||
class DrawViewPart;
|
||||
}
|
||||
|
||||
namespace TechDrawGeometry
|
||||
namespace TechDraw
|
||||
{
|
||||
class Face;
|
||||
}
|
||||
|
||||
@@ -154,9 +154,9 @@ void TaskCosVertex::updateUi(void)
|
||||
void TaskCosVertex::addCosVertex(QPointF qPos)
|
||||
{
|
||||
// Base::Console().Message("TCV::addCosVertex(%s)\n", TechDraw::DrawUtil::formatVector(qPos).c_str());
|
||||
Base::Vector3d pos(qPos.x(), -qPos.y());
|
||||
Base::Vector3d pos(qPos.x(), qPos.y());
|
||||
// int idx =
|
||||
(void) m_baseFeat->addRandomVertex(pos);
|
||||
(void) m_baseFeat->addCosmeticVertex(pos);
|
||||
m_baseFeat->requestPaint();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user