New way find arc points.
--HG-- branch : develop
This commit is contained in:
parent
e98d855764
commit
e5247cf323
|
@ -223,6 +223,7 @@ QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &po
|
||||||
qWarning()<<"Only three points.";
|
qWarning()<<"Only three points.";
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
//Clear equivalent points
|
||||||
for(qint32 i = 0; i <points.size(); ++i)
|
for(qint32 i = 0; i <points.size(); ++i)
|
||||||
{
|
{
|
||||||
if(i == points.size()-1)
|
if(i == points.size()-1)
|
||||||
|
@ -240,6 +241,22 @@ QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &po
|
||||||
correctPoints.append(points.at(i));
|
correctPoints.append(points.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(correctPoints.size()<3)
|
||||||
|
{
|
||||||
|
return correctPoints;
|
||||||
|
}
|
||||||
|
//Remove point on line
|
||||||
|
QPointF point;
|
||||||
|
for(qint32 i = 1; i <correctPoints.size()-1; ++i)
|
||||||
|
{
|
||||||
|
QLineF l1(correctPoints[i-1], correctPoints[i]);
|
||||||
|
QLineF l2(correctPoints[i], correctPoints[i+1]);
|
||||||
|
QLineF::IntersectType intersect = l1.intersect(l2, &point);
|
||||||
|
if (intersect == QLineF::NoIntersection)
|
||||||
|
{
|
||||||
|
correctPoints.remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
return correctPoints;
|
return correctPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,13 +120,21 @@ QVector<QPointF> VArc::GetPoints() const
|
||||||
{
|
{
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
qreal i = 0;
|
qreal i = 0;
|
||||||
qreal angle = qRound(AngleArc());
|
qreal angle = AngleArc();
|
||||||
|
qint32 k = static_cast<qint32>(angle);
|
||||||
|
qreal s = angle/(k/4);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
QLineF line(center.toQPointF(), GetP1());
|
QLineF line(center.toQPointF(), GetP1());
|
||||||
line.setAngle(line.angle()+i);
|
line.setAngle(line.angle()+i);
|
||||||
points.append(line.p2());
|
points.append(line.p2());
|
||||||
i = i + 0.1;
|
i = i + s;
|
||||||
|
if(i > angle)
|
||||||
|
{
|
||||||
|
QLineF line(center.toQPointF(), GetP1());
|
||||||
|
line.setAngle(line.angle()+angle);
|
||||||
|
points.append(line.p2());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while(i <= angle);
|
while(i <= angle);
|
||||||
return points;
|
return points;
|
||||||
|
|
|
@ -247,8 +247,7 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const
|
||||||
{
|
{
|
||||||
domElement.setAttribute(AttrMx, QString().setNum(toMM(newPos.x())));
|
domElement.setAttribute(AttrMx, QString().setNum(toMM(newPos.x())));
|
||||||
domElement.setAttribute(AttrMy, QString().setNum(toMM(newPos.y())));
|
domElement.setAttribute(AttrMy, QString().setNum(toMM(newPos.y())));
|
||||||
//I don't now why but signal does not work.
|
doc->haveLiteChange();
|
||||||
doc->FullUpdateTree();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VDomDocument *doc, VContai
|
||||||
|
|
||||||
QLineF l1(center->toQPointF(), p1.toQPointF());
|
QLineF l1(center->toQPointF(), p1.toQPointF());
|
||||||
QLineF l2(center->toQPointF(), p2.toQPointF());
|
QLineF l2(center->toQPointF(), p2.toQPointF());
|
||||||
|
center->setMode(Draw::Modeling);
|
||||||
qint64 idCenter = data->AddGObject(center);
|
qint64 idCenter = data->AddGObject(center);
|
||||||
Q_UNUSED(idCenter);
|
Q_UNUSED(idCenter);
|
||||||
VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(),
|
VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(),
|
||||||
|
@ -112,12 +113,12 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VDomDocument *doc, VContai
|
||||||
QString().setNum(l2.angle()));
|
QString().setNum(l2.angle()));
|
||||||
Q_ASSERT(arc1 != 0);
|
Q_ASSERT(arc1 != 0);
|
||||||
arc1->setMode(Draw::Modeling);
|
arc1->setMode(Draw::Modeling);
|
||||||
id = data->AddGObject(arc1);
|
idObject = data->AddGObject(arc1);
|
||||||
|
|
||||||
VArc *arc2 = new VArc(*arc1);
|
VArc *arc2 = new VArc(*arc1);
|
||||||
Q_ASSERT(arc2 != 0);
|
Q_ASSERT(arc2 != 0);
|
||||||
arc2->setMode(Draw::Modeling);
|
arc2->setMode(Draw::Modeling);
|
||||||
idObject = data->AddGObject(arc2);
|
id = data->AddGObject(arc2);
|
||||||
|
|
||||||
VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Tool::FromGui, idTool, tool);
|
VNodeArc::Create(doc, data, id, idObject, Document::FullParse, Tool::FromGui, idTool, tool);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +243,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
||||||
{
|
{
|
||||||
case (Tool::NodePoint):
|
case (Tool::NodePoint):
|
||||||
{
|
{
|
||||||
if (qFuzzyCompare(dx+1, 1) == false && qFuzzyCompare(dy+1, 1) == false && pRotate != 0)
|
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
|
||||||
{
|
{
|
||||||
VPointF *point = new VPointF(*data->GeometricObject<const VPointF *>(det.at(i).getId()));
|
VPointF *point = new VPointF(*data->GeometricObject<const VPointF *>(det.at(i).getId()));
|
||||||
Q_ASSERT(point != 0);
|
Q_ASSERT(point != 0);
|
||||||
|
@ -257,7 +258,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeArc):
|
case (Tool::NodeArc):
|
||||||
{
|
{
|
||||||
if (qFuzzyCompare(dx+1, 1) == false && qFuzzyCompare(dy+1, 1) == false && pRotate != 0)
|
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
|
||||||
{
|
{
|
||||||
const VArc *arc = data->GeometricObject<const VArc *>(det.at(i).getId());
|
const VArc *arc = data->GeometricObject<const VArc *>(det.at(i).getId());
|
||||||
VPointF p1 = VPointF(arc->GetP1());
|
VPointF p1 = VPointF(arc->GetP1());
|
||||||
|
@ -272,6 +273,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
||||||
QLineF l1(center->toQPointF(), p1.toQPointF());
|
QLineF l1(center->toQPointF(), p1.toQPointF());
|
||||||
QLineF l2(center->toQPointF(), p2.toQPointF());
|
QLineF l2(center->toQPointF(), p2.toQPointF());
|
||||||
++idCount;
|
++idCount;
|
||||||
|
center->setMode(Draw::Modeling);
|
||||||
data->UpdateGObject(idDetail+idCount, center);
|
data->UpdateGObject(idDetail+idCount, center);
|
||||||
VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(),
|
VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(),
|
||||||
QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle()));
|
QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle()));
|
||||||
|
@ -286,7 +288,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeSpline):
|
case (Tool::NodeSpline):
|
||||||
{
|
{
|
||||||
if (qFuzzyCompare(dx+1, 1) == false && qFuzzyCompare(dy+1, 1) == false && pRotate != 0)
|
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
|
||||||
{
|
{
|
||||||
const VSpline *spline = data->GeometricObject<const VSpline *>(det.at(i).getId());
|
const VSpline *spline = data->GeometricObject<const VSpline *>(det.at(i).getId());
|
||||||
|
|
||||||
|
@ -320,7 +322,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
||||||
break;
|
break;
|
||||||
case (Tool::NodeSplinePath):
|
case (Tool::NodeSplinePath):
|
||||||
{
|
{
|
||||||
if (qFuzzyCompare(dx+1, 1) == false && qFuzzyCompare(dy+1, 1) == false && pRotate != 0)
|
if (qFuzzyCompare(dx+1, 1) == false || qFuzzyCompare(dy+1, 1) == false || pRotate != 0)
|
||||||
{
|
{
|
||||||
VSplinePath *path = new VSplinePath();
|
VSplinePath *path = new VSplinePath();
|
||||||
Q_ASSERT(path != 0);
|
Q_ASSERT(path != 0);
|
||||||
|
|
|
@ -1314,7 +1314,6 @@ void VDomDocument::FullUpdateTree()
|
||||||
Q_ASSERT(scene != 0);
|
Q_ASSERT(scene != 0);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
data->ClearGObjects();
|
|
||||||
Parse(Document::LiteParse, scene, scene);
|
Parse(Document::LiteParse, scene, scene);
|
||||||
}
|
}
|
||||||
catch (const std::bad_alloc &)
|
catch (const std::bad_alloc &)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user