From 4ba488d0c0fbc0e4cd14aec2eb74c114986fcb6d Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 2 Jan 2015 19:02:07 +0200 Subject: [PATCH] VAbstractDetail parent class for VDetail. --HG-- branch : feature --- src/app/app.pro | 9 ++ src/app/geometry/vdetail.cpp | 183 +++++++++++++++++-------- src/app/geometry/vdetail.h | 206 ++++------------------------- src/app/geometry/vdetail_p.h | 45 ++----- src/libs/vlayout/vabstractdetail.h | 2 +- 5 files changed, 174 insertions(+), 271 deletions(-) diff --git a/src/app/app.pro b/src/app/app.pro index 2f2885803..fcc923638 100644 --- a/src/app/app.pro +++ b/src/app/app.pro @@ -393,6 +393,15 @@ DEPENDPATH += $$PWD/../libs/vobj win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vobj/$${DESTDIR}/vobj.lib else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vobj/$${DESTDIR}/libvobj.a +# VLayout static library +unix|win32: LIBS += -L$$OUT_PWD/../libs/vlayout/$${DESTDIR}/ -lvlayout + +INCLUDEPATH += $$PWD/../libs/vlayout +DEPENDPATH += $$PWD/../libs/vlayout + +win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vlayout/$${DESTDIR}/vlayout.lib +else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vlayout/$${DESTDIR}/libvlayout.a + # Strip after you link all libaries. CONFIG(release, debug|release){ diff --git a/src/app/geometry/vdetail.cpp b/src/app/geometry/vdetail.cpp index d0322f4d3..e9a0eb17e 100644 --- a/src/app/geometry/vdetail.cpp +++ b/src/app/geometry/vdetail.cpp @@ -32,27 +32,45 @@ #include //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VDetail default contructor. Create empty detail. + */ VDetail::VDetail() - :d(new VDetailData) + :VAbstractDetail(), d(new VDetailData) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VDetail constructor. + * @param name detail name. + * @param nodes list of nodes. + */ VDetail::VDetail(const QString &name, const QVector &nodes) - :d(new VDetailData(name, nodes)) + :VAbstractDetail(name), d(new VDetailData(nodes)) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief VDetail copy constructor. + * @param detail detail. + */ VDetail::VDetail(const VDetail &detail) - :d (detail.d) + :VAbstractDetail(detail), d (detail.d) {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief operator = assignment operator. + * @param detail detail. + * @return new detail. + */ VDetail &VDetail::operator =(const VDetail &detail) { if ( &detail == this ) { return *this; } + VAbstractDetail::operator=(detail); d = detail.d; return *this; } @@ -62,24 +80,31 @@ VDetail::~VDetail() {} //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Clear detail full clear. + */ void VDetail::Clear() { d->nodes.clear(); - d->name.clear(); d->mx = 0; d->my = 0; - d->seamAllowance = true; - d->closed = true; - d->width = 0; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief ClearNodes clear list of nodes. + */ void VDetail::ClearNodes() { d->nodes.clear(); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Containes check if detail containe this id. + * @param id object id. + * @return true if containe. + */ bool VDetail::Containes(const quint32 &id) const { for (int i = 0; i < d->nodes.size(); ++i) @@ -94,36 +119,66 @@ bool VDetail::Containes(const quint32 &id) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief operator [] find node by index in list. + * @param indx index node in list. + * @return node + */ VNodeDetail &VDetail::operator [](int indx) { return d->nodes[indx]; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief at find node by index in list. + * @param indx index node in list. + * @return const node. + */ const VNodeDetail &VDetail::at(int indx) const { return d->nodes.at(indx); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief indexOfNode return index in list node using id object. + * @param id object (arc, point, spline, splinePath) id. + * @return index in list or -1 id can't find. + */ int VDetail::indexOfNode(const quint32 &id) const { return indexOfNode(d->nodes, id); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief id return id detail in list data. + * @return id. + */ quint32 VDetail::id() const { return d->_id; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setId set id detail in list data. + * @param id detail id. + */ void VDetail::setId(const quint32 &id) { d->_id = id; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief OnEdge checks if two poins located on the edge. Edge is line between two points. If between two points + * located arcs or splines ignore this. + * @param p1 id first point. + * @param p2 id second point. + * @return true - on edge, false - no. + */ bool VDetail::OnEdge(const quint32 &p1, const quint32 &p2) const { QVector list = listNodePoint(); @@ -162,6 +217,13 @@ bool VDetail::OnEdge(const quint32 &p1, const quint32 &p2) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Edge return edge index in detail. Edge is line between two points. If between two points + * located arcs or splines ignore this. + * @param p1 id first point. + * @param p2 id second point. + * @return edge index or -1 if points don't located on edge + */ int VDetail::Edge(const quint32 &p1, const quint32 &p2) const { if (OnEdge(p1, p2) == false) @@ -187,6 +249,12 @@ int VDetail::Edge(const quint32 &p1, const quint32 &p2) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief NodeOnEdge return nodes located on edge with index. + * @param index index of edge. + * @param p1 first node. + * @param p2 second node. + */ void VDetail::NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2) const { QVector list = listNodePoint(); @@ -207,6 +275,11 @@ void VDetail::NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief RemoveEdge return detail without edge with index. + * @param index idex of edge. + * @return detail without edge with index. + */ VDetail VDetail::RemoveEdge(const quint32 &index) const { VDetail det(*this); @@ -250,6 +323,12 @@ VDetail VDetail::RemoveEdge(const quint32 &index) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief Missing find missing ids in detail. When we deleted object in detail and return this detail need + * understand, what nodes need make invisible. + * @param det changed detail. + * @return list with missing detail. + */ QList VDetail::Missing(const VDetail &det) const { if (d->nodes.size() == det.CountNode()) @@ -275,6 +354,10 @@ QList VDetail::Missing(const VDetail &det) const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief listNodePoint return list nodes only with points. + * @return list points node. + */ QVector VDetail::listNodePoint() const { QVector list; @@ -289,6 +372,12 @@ QVector VDetail::listNodePoint() const } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief indexOfNode return index in list node using id object. + * @param list list nodes detail. + * @param id object (arc, point, spline, splinePath) id. + * @return index in list or -1 id can't find. + */ int VDetail::indexOfNode(const QVector &list, const quint32 &id) { for (int i = 0; i < list.size(); ++i) @@ -303,96 +392,80 @@ int VDetail::indexOfNode(const QVector &list, const quint32 &id) } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief append append in the end of list node. + * @param node new node. + */ void VDetail::append(const VNodeDetail &node) { d->nodes.append(node); } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief CountNode return count nodes. + * @return count. + */ qint32 VDetail::CountNode() const { return d->nodes.size(); } //--------------------------------------------------------------------------------------------------------------------- -QString VDetail::getName() const -{ - return d->name; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VDetail::setName(const QString &value) -{ - d->name = value; -} - -//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getMx return bias for X axis. + * @return x bias. + */ qreal VDetail::getMx() const { return d->mx; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setMx set bias for X axis. + * @param value new x bias. + */ void VDetail::setMx(const qreal &value) { d->mx = value; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getMy get bias for y axis. + * @return y axis. + */ qreal VDetail::getMy() const { return d->my; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setMy set bias for y axis. + * @param value new y bias. + */ void VDetail::setMy(const qreal &value) { d->my = value; } //--------------------------------------------------------------------------------------------------------------------- -bool VDetail::getSeamAllowance() const -{ - return d->seamAllowance; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VDetail::setSeamAllowance(bool value) -{ - d->seamAllowance = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -bool VDetail::getClosed() const -{ - return d->closed; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VDetail::setClosed(bool value) -{ - d->closed = value; -} - -//--------------------------------------------------------------------------------------------------------------------- -qreal VDetail::getWidth() const -{ - return d->width; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VDetail::setWidth(const qreal &value) -{ - d->width = value; -} - -//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getNodes return list of nodes. + * @return list of nodes. + */ QVector VDetail::getNodes() const { return d->nodes; } //--------------------------------------------------------------------------------------------------------------------- +/** + * @brief setNodes set list of nodes + * @param value list of nodes + */ void VDetail::setNodes(const QVector &value) { d->nodes = value; diff --git a/src/app/geometry/vdetail.h b/src/app/geometry/vdetail.h index 50a3ac12c..2e9bef2f4 100644 --- a/src/app/geometry/vdetail.h +++ b/src/app/geometry/vdetail.h @@ -30,212 +30,56 @@ #define VDETAIL_H #include "vnodedetail.h" -#include #include -class QString; +#include "../libs/vlayout/vabstractdetail.h" + class VDetailData; /** * @brief The VDetail class for path of object (points, arcs, splines). */ -class VDetail +class VDetail :public VAbstractDetail { public: - /** - * @brief VDetail default contructor. Create empty detail. - */ VDetail(); - /** - * @brief VDetail constructor. - * @param name detail name. - * @param nodes list of nodes. - */ VDetail(const QString &name, const QVector &nodes); - /** - * @brief VDetail copy constructor. - * @param detail detail. - */ VDetail(const VDetail &detail); - /** - * @brief operator = assignment operator. - * @param detail detail. - * @return new detail. - */ VDetail &operator=(const VDetail &detail); - ~VDetail(); - /** - * @brief append append in the end of list node. - * @param node new node. - */ + virtual ~VDetail(); + void append(const VNodeDetail &node); - /** - * @brief Clear detail full clear. - */ void Clear(); - /** - * @brief ClearNodes clear list of nodes. - */ void ClearNodes(); - /** - * @brief CountNode return count nodes. - * @return count. - */ qint32 CountNode() const; - /** - * @brief Containes check if detail containe this id. - * @param id object id. - * @return true if containe. - */ bool Containes(const quint32 &id)const; - /** - * @brief operator [] find node by index in list. - * @param indx index node in list. - * @return node - */ VNodeDetail & operator[](int indx); - /** - * @brief at find node by index in list. - * @param indx index node in list. - * @return const node. - */ const VNodeDetail & at ( int indx ) const; - /** - * @brief getName return detail name. - * @return name. - */ - QString getName() const; - /** - * @brief setName set detail name. - * @param value new name. - */ - void setName(const QString &value); - /** - * @brief getMx return bias for X axis. - * @return x bias. - */ - qreal getMx() const; - /** - * @brief setMx set bias for X axis. - * @param value new x bias. - */ - void setMx(const qreal &value); - /** - * @brief getMy get bias for y axis. - * @return y axis. - */ - qreal getMy() const; - /** - * @brief setMy set bias for y axis. - * @param value new y bias. - */ - void setMy(const qreal &value); - /** - * @brief getSeamAllowance keep status for seam allowance detail. - * @return true - need seam allowance, false - no need seam allowance. - */ - bool getSeamAllowance() const; - /** - * @brief setSeamAllowance set status for seam allowance detail. - * @param value true - need seam allowance, false - no need seam allowance. - */ - void setSeamAllowance(bool value); - /** - * @brief getClosed keep close status for detail equdistant. - * @return true - close equdistant, false - don't close equdistant. - */ - bool getClosed() const; - /** - * @brief setClosed set close status for detail equdistant. - * @param value true - close equdistant, false - don't close equdistant. - */ - void setClosed(bool value); - /** - * @brief getWidth return value detail seam allowance. - * @return value in mm. - */ - qreal getWidth() const; - /** - * @brief setWidth set value detail seam allowance. - * @param value width in mm. - */ - void setWidth(const qreal &value); - /** - * @brief getNodes return list of nodes. - * @return list of nodes. - */ + + qreal getMx() const; + void setMx(const qreal &value); + + qreal getMy() const; + void setMy(const qreal &value); + + quint32 id() const; + void setId(const quint32 &id); + QVector getNodes() const; - /** - * @brief setNodes set list of nodes - * @param value list of nodes - */ - void setNodes(const QVector &value); - /** - * @brief indexOfNode return index in list node using id object. - * @param id object (arc, point, spline, splinePath) id. - * @return index in list or -1 id can't find. - */ - int indexOfNode(const quint32 &id) const; - /** - * @brief id return id detail in list data. - * @return id. - */ - quint32 id() const; - /** - * @brief setId set id detail in list data. - * @param id detail id. - */ - void setId(const quint32 &id); - /** - * @brief OnEdge checks if two poins located on the edge. Edge is line between two points. If between two points - * located arcs or splines ignore this. - * @param p1 id first point. - * @param p2 id second point. - * @return true - on edge, false - no. - */ - bool OnEdge(const quint32 &p1, const quint32 &p2)const; - /** - * @brief Edge return edge index in detail. Edge is line between two points. If between two points - * located arcs or splines ignore this. - * @param p1 id first point. - * @param p2 id second point. - * @return edge index or -1 if points don't located on edge - */ - int Edge(const quint32 &p1, const quint32 &p2)const; - /** - * @brief NodeOnEdge return nodes located on edge with index. - * @param index index of edge. - * @param p1 first node. - * @param p2 second node. - */ - void NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2)const; - /** - * @brief RemoveEdge return detail without edge with index. - * @param index idex of edge. - * @return detail without edge with index. - */ - VDetail RemoveEdge(const quint32 &index) const; - /** - * @brief Missing find missing ids in detail. When we deleted object in detail and return this detail need - * understand, what nodes need make invisible. - * @param det changed detail. - * @return list with missing detail. - */ + void setNodes(const QVector &value); + + int indexOfNode(const quint32 &id) const; + bool OnEdge(const quint32 &p1, const quint32 &p2)const; + int Edge(const quint32 &p1, const quint32 &p2)const; + void NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2)const; + VDetail RemoveEdge(const quint32 &index) const; + QList Missing(const VDetail &det) const; private: QSharedDataPointer d; - /** - * @brief listNodePoint return list nodes only with points. - * @return list points node. - */ + QVector listNodePoint()const; - /** - * @brief indexOfNode return index in list node using id object. - * @param list list nodes detail. - * @param id object (arc, point, spline, splinePath) id. - * @return index in list or -1 id can't find. - */ - static int indexOfNode(const QVector &list, const quint32 &id); + static int indexOfNode(const QVector &list, const quint32 &id); }; #endif // VDETAIL_H diff --git a/src/app/geometry/vdetail_p.h b/src/app/geometry/vdetail_p.h index cfb880992..097d5b835 100644 --- a/src/app/geometry/vdetail_p.h +++ b/src/app/geometry/vdetail_p.h @@ -42,53 +42,30 @@ class VDetailData : public QSharedData { public: VDetailData() - :_id(NULL_ID), nodes(QVector()), name(QString()), mx(0), my(0), seamAllowance(true), closed(true), - width(0) + :_id(NULL_ID), nodes(QVector()), mx(0), my(0) {} - VDetailData(const QString &name, const QVector &nodes) - :_id(NULL_ID), nodes(nodes), name(name), mx(0), my(0), seamAllowance(true), closed(true), width(0) + VDetailData(const QVector &nodes) + :_id(NULL_ID), nodes(nodes), mx(0), my(0) {} VDetailData(const VDetailData &detail) - :QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), name(detail.name), mx(detail.mx), my(detail.my), - seamAllowance(detail.seamAllowance), closed(detail.closed), width(detail.width) + :QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), mx(detail.mx), my(detail.my) {} ~VDetailData() {} - /** - * @brief _id id detail. - */ + /** @brief _id id detail. */ quint32 _id; - /** - * @brief nodes list detail nodes. - */ + + /** @brief nodes list detail nodes. */ QVector nodes; - /** - * @brief name detail name. - */ - QString name; - /** - * @brief mx bias x axis. - */ + + /** @brief mx bias x axis. */ qreal mx; - /** - * @brief my bias y axis. - */ + + /** @brief my bias y axis. */ qreal my; - /** - * @brief seamAllowance status seamAllowance detail. - */ - bool seamAllowance; - /** - * @brief closed status equdistant detail. - */ - bool closed; - /** - * @brief width value seamAllowance in mm. - */ - qreal width; }; #ifdef Q_CC_GNU diff --git a/src/libs/vlayout/vabstractdetail.h b/src/libs/vlayout/vabstractdetail.h index 046793bce..d22f0f4e7 100644 --- a/src/libs/vlayout/vabstractdetail.h +++ b/src/libs/vlayout/vabstractdetail.h @@ -44,7 +44,7 @@ public: VAbstractDetail(const QString &name); VAbstractDetail(const VAbstractDetail &detail); VAbstractDetail &operator=(const VAbstractDetail &detail); - ~VAbstractDetail(); + virtual ~VAbstractDetail(); void Clear();