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.";
|
||||
return points;
|
||||
}
|
||||
//Clear equivalent points
|
||||
for(qint32 i = 0; i <points.size(); ++i)
|
||||
{
|
||||
if(i == points.size()-1)
|
||||
|
@ -240,6 +241,22 @@ QVector<QPointF> VContainer::CorrectEquidistantPoints(const QVector<QPointF> &po
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,13 +120,21 @@ QVector<QPointF> VArc::GetPoints() const
|
|||
{
|
||||
QVector<QPointF> points;
|
||||
qreal i = 0;
|
||||
qreal angle = qRound(AngleArc());
|
||||
qreal angle = AngleArc();
|
||||
qint32 k = static_cast<qint32>(angle);
|
||||
qreal s = angle/(k/4);
|
||||
do
|
||||
{
|
||||
QLineF line(center.toQPointF(), GetP1());
|
||||
line.setAngle(line.angle()+i);
|
||||
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);
|
||||
return points;
|
||||
|
|
|
@ -247,8 +247,7 @@ QVariant VToolDetail::itemChange(QGraphicsItem::GraphicsItemChange change, const
|
|||
{
|
||||
domElement.setAttribute(AttrMx, QString().setNum(toMM(newPos.x())));
|
||||
domElement.setAttribute(AttrMy, QString().setNum(toMM(newPos.y())));
|
||||
//I don't now why but signal does not work.
|
||||
doc->FullUpdateTree();
|
||||
doc->haveLiteChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VDomDocument *doc, VContai
|
|||
|
||||
QLineF l1(center->toQPointF(), p1.toQPointF());
|
||||
QLineF l2(center->toQPointF(), p2.toQPointF());
|
||||
center->setMode(Draw::Modeling);
|
||||
qint64 idCenter = data->AddGObject(center);
|
||||
Q_UNUSED(idCenter);
|
||||
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()));
|
||||
Q_ASSERT(arc1 != 0);
|
||||
arc1->setMode(Draw::Modeling);
|
||||
id = data->AddGObject(arc1);
|
||||
idObject = data->AddGObject(arc1);
|
||||
|
||||
VArc *arc2 = new VArc(*arc1);
|
||||
Q_ASSERT(arc2 != 0);
|
||||
arc2->setMode(Draw::Modeling);
|
||||
idObject = data->AddGObject(arc2);
|
||||
id = data->AddGObject(arc2);
|
||||
|
||||
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):
|
||||
{
|
||||
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()));
|
||||
Q_ASSERT(point != 0);
|
||||
|
@ -257,7 +258,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
|||
break;
|
||||
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());
|
||||
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 l2(center->toQPointF(), p2.toQPointF());
|
||||
++idCount;
|
||||
center->setMode(Draw::Modeling);
|
||||
data->UpdateGObject(idDetail+idCount, center);
|
||||
VArc *arc1 = new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.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;
|
||||
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());
|
||||
|
||||
|
@ -320,7 +322,7 @@ void VToolUnionDetails::UpdatePoints(const qint64 &idDetail, VContainer *data, c
|
|||
break;
|
||||
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();
|
||||
Q_ASSERT(path != 0);
|
||||
|
|
|
@ -1314,7 +1314,6 @@ void VDomDocument::FullUpdateTree()
|
|||
Q_ASSERT(scene != 0);
|
||||
try
|
||||
{
|
||||
data->ClearGObjects();
|
||||
Parse(Document::LiteParse, scene, scene);
|
||||
}
|
||||
catch (const std::bad_alloc &)
|
||||
|
|
Loading…
Reference in New Issue
Block a user