Some little change.
--HG-- branch : develop
This commit is contained in:
parent
12424ddad0
commit
e98d855764
|
@ -609,8 +609,7 @@ void VContainer::AddLengthSpline(const QString &name, const qreal &value)
|
||||||
void VContainer::AddLengthArc(const qint64 &id)
|
void VContainer::AddLengthArc(const qint64 &id)
|
||||||
{
|
{
|
||||||
const VArc * arc = GeometricObject<const VArc *>(id);
|
const VArc * arc = GeometricObject<const VArc *>(id);
|
||||||
QString name = QString("%1_%2").arg(arc->name()).arg(id);
|
lengthArcs[arc->name()] = toMM(arc->GetLength());
|
||||||
lengthArcs[name] = toMM(arc->GetLength());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VContainer::AddLineAngle(const QString &name, const qreal &value)
|
void VContainer::AddLineAngle(const QString &name, const qreal &value)
|
||||||
|
|
|
@ -66,6 +66,11 @@ VArc &VArc::operator =(const VArc &arc)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal VArc::GetLength() const
|
||||||
|
{
|
||||||
|
return (M_PI * radius)/180 * AngleArc();
|
||||||
|
}
|
||||||
|
|
||||||
QPointF VArc::GetP1() const
|
QPointF VArc::GetP1() const
|
||||||
{
|
{
|
||||||
QPointF p1 ( GetCenter().x () + radius, GetCenter().y () );
|
QPointF p1 ( GetCenter().x () + radius, GetCenter().y () );
|
||||||
|
@ -84,13 +89,22 @@ QPointF VArc::GetP2 () const
|
||||||
|
|
||||||
QPainterPath VArc::GetPath() const
|
QPainterPath VArc::GetPath() const
|
||||||
{
|
{
|
||||||
QPainterPath Path;
|
QPainterPath path;
|
||||||
QPointF center = GetCenter().toQPointF();
|
|
||||||
QRectF rect(center.x()-radius, center.y()-radius, radius*2, radius*2);
|
QVector<QPointF> points = GetPoints();
|
||||||
Path.moveTo(GetP1());
|
if (points.count() >= 2)
|
||||||
qreal angle = QLineF(center, GetP1()).angleTo(QLineF(center, GetP2()));
|
{
|
||||||
Path.arcTo(rect, GetF1(), angle);
|
for (qint32 i = 0; i < points.count()-1; ++i)
|
||||||
return Path;
|
{
|
||||||
|
path.moveTo(points[i]);
|
||||||
|
path.lineTo(points[i+1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning()<<"points.count() < 2"<<Q_FUNC_INFO;
|
||||||
|
}
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal VArc::AngleArc() const
|
qreal VArc::AngleArc() const
|
||||||
|
@ -102,92 +116,25 @@ qreal VArc::AngleArc() const
|
||||||
return l1.angleTo(l2);
|
return l1.angleTo(l2);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32 VArc::NumberSplOfArc() const
|
|
||||||
{
|
|
||||||
qint32 angArc = static_cast<qint32> (AngleArc ());
|
|
||||||
switch ( angArc )
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
QString error = QString(tr("Angle of arc can't be 0 degree."));
|
|
||||||
throw VException(error);
|
|
||||||
}
|
|
||||||
case 90:
|
|
||||||
return 1;
|
|
||||||
case 180:
|
|
||||||
return 2;
|
|
||||||
case 270:
|
|
||||||
return 3;
|
|
||||||
case 360:
|
|
||||||
return 4;
|
|
||||||
default:
|
|
||||||
return static_cast<qint32> (AngleArc ( ) / 90 + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QVector<QPointF> VArc::GetPoints() const
|
QVector<QPointF> VArc::GetPoints() const
|
||||||
{
|
{
|
||||||
QVector<QPointF> points;
|
QVector<QPointF> points;
|
||||||
qint32 numberSpl = NumberSplOfArc();
|
qreal i = 0;
|
||||||
for (qint32 i = 1; i <= numberSpl; ++i)
|
qreal angle = qRound(AngleArc());
|
||||||
|
do
|
||||||
{
|
{
|
||||||
points<<SplOfArc ( i );
|
QLineF line(center.toQPointF(), GetP1());
|
||||||
|
line.setAngle(line.angle()+i);
|
||||||
|
points.append(line.p2());
|
||||||
|
i = i + 0.1;
|
||||||
}
|
}
|
||||||
|
while(i <= angle);
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<QPointF> VArc::SplOfArc(qint32 number) const
|
QString VArc::name() const
|
||||||
{
|
{
|
||||||
qint32 n = NumberSplOfArc ();
|
return _name;
|
||||||
if ( number > n )
|
|
||||||
{
|
|
||||||
QString error = QString(tr("Arc has not this number of parts."));
|
|
||||||
throw VException(error);
|
|
||||||
}
|
|
||||||
qreal f1 = GetF1 ();
|
|
||||||
qreal f2 = GetF2 ();
|
|
||||||
qint32 i;
|
|
||||||
for ( i = 0; i < n; ++i )
|
|
||||||
{
|
|
||||||
if ( i == n - 1 )
|
|
||||||
{
|
|
||||||
f2 = GetF2 ();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( f1 + 90 > 360 )
|
|
||||||
{
|
|
||||||
f2 = f1 + 90 - 360;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
f2 = f1 + 90;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
qreal anglF1, anglF2;
|
|
||||||
if ( f1 + 90 > 360 )
|
|
||||||
{
|
|
||||||
anglF1 = f1 + 90 - 360;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
anglF1 = f1 + 90;
|
|
||||||
}
|
|
||||||
if ( f2 - 90 < 0 )
|
|
||||||
{
|
|
||||||
anglF2 = 360 + f2 - 90;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
anglF2 = f2 - 90;
|
|
||||||
}
|
|
||||||
if ( i + 1 == number )
|
|
||||||
{
|
|
||||||
f1 = f2;
|
|
||||||
return VSpline::SplinePoints(GetP1 (), GetP2 (), anglF1, anglF2, 1., 1., 1.);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QVector<QPointF>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
|
QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
|
||||||
|
@ -205,19 +152,22 @@ QPointF VArc::CutArc(const qreal &length, VArc &arc1, VArc &arc2) const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
len = length;
|
len = length;
|
||||||
qDebug()<<len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal n = (len*180)/(M_PI*radius);
|
qreal n = (len*180)/(M_PI*radius);
|
||||||
qDebug()<<n;
|
|
||||||
QLineF line(GetCenter().toQPointF(), GetP1());
|
QLineF line(GetCenter().toQPointF(), GetP1());
|
||||||
line.setAngle(line.angle()+n);
|
line.setAngle(line.angle()+n);
|
||||||
QPointF point = line.p2();
|
|
||||||
|
|
||||||
arc1 = VArc (center, radius, formulaRadius, f1, formulaF1, line.angle(), QString().setNum(line.angle()),
|
arc1 = VArc (center, radius, formulaRadius, f1, formulaF1, line.angle(), QString().setNum(line.angle()),
|
||||||
idObject, mode);
|
idObject, mode);
|
||||||
|
|
||||||
arc2 = VArc (center, radius, formulaRadius, line.angle(), QString().setNum(line.angle()), f2, formulaF2,
|
arc2 = VArc (center, radius, formulaRadius, line.angle(), QString().setNum(line.angle()), f2, formulaF2,
|
||||||
idObject, mode);
|
idObject, mode);
|
||||||
return point;
|
return line.p2();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VArc::setId(const qint64 &id)
|
||||||
|
{
|
||||||
|
_id = id;
|
||||||
|
_name = QString ("Arc_%1_%2").arg(center.name()).arg(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
* @brief GetLength повертає довжину дуги.
|
* @brief GetLength повертає довжину дуги.
|
||||||
* @return повертає довжину дуги.
|
* @return повертає довжину дуги.
|
||||||
*/
|
*/
|
||||||
inline qreal GetLength () const {return M_PI * radius/180 * (f2-f1);}
|
qreal GetLength () const;
|
||||||
/**
|
/**
|
||||||
* @brief GetRadius повертає радіус дуги.
|
* @brief GetRadius повертає радіус дуги.
|
||||||
* @return повертає радіус дуги.
|
* @return повертає радіус дуги.
|
||||||
|
@ -128,24 +128,14 @@ public:
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
qreal AngleArc() const;
|
qreal AngleArc() const;
|
||||||
/**
|
|
||||||
* @brief NumberSplOfArc
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
qint32 NumberSplOfArc () const;
|
|
||||||
/**
|
/**
|
||||||
* @brief GetPoints
|
* @brief GetPoints
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
QVector<QPointF> GetPoints () const;
|
QVector<QPointF> GetPoints () const;
|
||||||
/**
|
virtual QString name() const;
|
||||||
* @brief SplOfArc
|
|
||||||
* @param number
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
QVector<QPointF> SplOfArc( qint32 number ) const;
|
|
||||||
virtual QString name() const{return _name;}
|
|
||||||
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
|
QPointF CutArc (const qreal &length, VArc &arc1, VArc &arc2) const;
|
||||||
|
virtual void setId(const qint64 &id);
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief f1 початковий кут в градусах
|
* @brief f1 початковий кут в градусах
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
void setMode(const Draw::Draws &value);
|
void setMode(const Draw::Draws &value);
|
||||||
GObject::Type getType() const;
|
GObject::Type getType() const;
|
||||||
qint64 id() const;
|
qint64 id() const;
|
||||||
void setId(const qint64 &id);
|
virtual void setId(const qint64 &id);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief _id id in container. Ned for arcs, spline and spline paths.
|
* @brief _id id in container. Ned for arcs, spline and spline paths.
|
||||||
|
|
|
@ -706,8 +706,11 @@ void MainWindow::currentDrawChanged( int index )
|
||||||
doc->setCurrentData();
|
doc->setCurrentData();
|
||||||
doc->ChangeActivDraw(comboBoxDraws->itemText(index));
|
doc->ChangeActivDraw(comboBoxDraws->itemText(index));
|
||||||
qint64 id = doc->SPointActiveDraw();
|
qint64 id = doc->SPointActiveDraw();
|
||||||
const VPointF *p = pattern->GeometricObject<const VPointF *>(id);
|
if (id != 0)
|
||||||
view->centerOn(p->toQPointF());
|
{
|
||||||
|
const VPointF *p = pattern->GeometricObject<const VPointF *>(id);
|
||||||
|
view->centerOn(p->toQPointF());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,11 @@ void VToolCutArc::ChangedActivDraw(const QString &newName)
|
||||||
VToolPoint::ChangedActivDraw(newName);
|
VToolPoint::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VToolCutArc::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
ContextMenu(dialogCutArc, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
void VToolCutArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
ContextMenu(dialogCutArc, this, event);
|
ContextMenu(dialogCutArc, this, event);
|
||||||
|
|
|
@ -74,6 +74,7 @@ public slots:
|
||||||
* @param newName
|
* @param newName
|
||||||
*/
|
*/
|
||||||
virtual void ChangedActivDraw(const QString &newName);
|
virtual void ChangedActivDraw(const QString &newName);
|
||||||
|
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief contextMenuEvent
|
* @brief contextMenuEvent
|
||||||
|
|
|
@ -209,6 +209,11 @@ void VToolCutSpline::ChangedActivDraw(const QString &newName)
|
||||||
VToolPoint::ChangedActivDraw(newName);
|
VToolPoint::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VToolCutSpline::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
ContextMenu(dialogCutSpline, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
void VToolCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
ContextMenu(dialogCutSpline, this, event);
|
ContextMenu(dialogCutSpline, this, event);
|
||||||
|
|
|
@ -109,6 +109,7 @@ public slots:
|
||||||
* @param newName
|
* @param newName
|
||||||
*/
|
*/
|
||||||
virtual void ChangedActivDraw(const QString &newName);
|
virtual void ChangedActivDraw(const QString &newName);
|
||||||
|
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief contextMenuEvent
|
* @brief contextMenuEvent
|
||||||
|
|
|
@ -286,6 +286,11 @@ void VToolCutSplinePath::ChangedActivDraw(const QString &newName)
|
||||||
VToolPoint::ChangedActivDraw(newName);
|
VToolPoint::ChangedActivDraw(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VToolCutSplinePath::ShowContextMenu(QGraphicsSceneContextMenuEvent *event)
|
||||||
|
{
|
||||||
|
ContextMenu(dialogCutSplinePath, this, event);
|
||||||
|
}
|
||||||
|
|
||||||
void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
void VToolCutSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
ContextMenu(dialogCutSplinePath, this, event);
|
ContextMenu(dialogCutSplinePath, this, event);
|
||||||
|
|
|
@ -99,6 +99,7 @@ public slots:
|
||||||
* @param newName
|
* @param newName
|
||||||
*/
|
*/
|
||||||
virtual void ChangedActivDraw(const QString &newName);
|
virtual void ChangedActivDraw(const QString &newName);
|
||||||
|
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief contextMenuEvent
|
* @brief contextMenuEvent
|
||||||
|
|
Loading…
Reference in New Issue
Block a user