VAbstractDetail parent class for VDetail.

--HG--
branch : feature
This commit is contained in:
dismine 2015-01-02 19:02:07 +02:00
parent 112dbd7f4e
commit 4ba488d0c0
5 changed files with 174 additions and 271 deletions

View File

@ -393,6 +393,15 @@ DEPENDPATH += $$PWD/../libs/vobj
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../libs/vobj/$${DESTDIR}/vobj.lib 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 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. # Strip after you link all libaries.
CONFIG(release, debug|release){ CONFIG(release, debug|release){

View File

@ -32,27 +32,45 @@
#include <QString> #include <QString>
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief VDetail default contructor. Create empty detail.
*/
VDetail::VDetail() 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<VNodeDetail> &nodes) VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes)
:d(new VDetailData(name, nodes)) :VAbstractDetail(name), d(new VDetailData(nodes))
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief VDetail copy constructor.
* @param detail detail.
*/
VDetail::VDetail(const VDetail &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) VDetail &VDetail::operator =(const VDetail &detail)
{ {
if ( &detail == this ) if ( &detail == this )
{ {
return *this; return *this;
} }
VAbstractDetail::operator=(detail);
d = detail.d; d = detail.d;
return *this; return *this;
} }
@ -62,24 +80,31 @@ VDetail::~VDetail()
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief Clear detail full clear.
*/
void VDetail::Clear() void VDetail::Clear()
{ {
d->nodes.clear(); d->nodes.clear();
d->name.clear();
d->mx = 0; d->mx = 0;
d->my = 0; d->my = 0;
d->seamAllowance = true;
d->closed = true;
d->width = 0;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief ClearNodes clear list of nodes.
*/
void VDetail::ClearNodes() void VDetail::ClearNodes()
{ {
d->nodes.clear(); 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 bool VDetail::Containes(const quint32 &id) const
{ {
for (int i = 0; i < d->nodes.size(); ++i) 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) VNodeDetail &VDetail::operator [](int indx)
{ {
return d->nodes[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 const VNodeDetail &VDetail::at(int indx) const
{ {
return d->nodes.at(indx); 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 int VDetail::indexOfNode(const quint32 &id) const
{ {
return indexOfNode(d->nodes, id); return indexOfNode(d->nodes, id);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief id return id detail in list data.
* @return id.
*/
quint32 VDetail::id() const quint32 VDetail::id() const
{ {
return d->_id; return d->_id;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief setId set id detail in list data.
* @param id detail id.
*/
void VDetail::setId(const quint32 &id) void VDetail::setId(const quint32 &id)
{ {
d->_id = 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 bool VDetail::OnEdge(const quint32 &p1, const quint32 &p2) const
{ {
QVector<VNodeDetail> list = listNodePoint(); QVector<VNodeDetail> 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 int VDetail::Edge(const quint32 &p1, const quint32 &p2) const
{ {
if (OnEdge(p1, p2) == false) 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 void VDetail::NodeOnEdge(const quint32 &index, VNodeDetail &p1, VNodeDetail &p2) const
{ {
QVector<VNodeDetail> list = listNodePoint(); QVector<VNodeDetail> 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 VDetail::RemoveEdge(const quint32 &index) const
{ {
VDetail det(*this); 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<quint32> VDetail::Missing(const VDetail &det) const QList<quint32> VDetail::Missing(const VDetail &det) const
{ {
if (d->nodes.size() == det.CountNode()) if (d->nodes.size() == det.CountNode())
@ -275,6 +354,10 @@ QList<quint32> VDetail::Missing(const VDetail &det) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief listNodePoint return list nodes only with points.
* @return list points node.
*/
QVector<VNodeDetail> VDetail::listNodePoint() const QVector<VNodeDetail> VDetail::listNodePoint() const
{ {
QVector<VNodeDetail> list; QVector<VNodeDetail> list;
@ -289,6 +372,12 @@ QVector<VNodeDetail> 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<VNodeDetail> &list, const quint32 &id) int VDetail::indexOfNode(const QVector<VNodeDetail> &list, const quint32 &id)
{ {
for (int i = 0; i < list.size(); ++i) for (int i = 0; i < list.size(); ++i)
@ -303,96 +392,80 @@ int VDetail::indexOfNode(const QVector<VNodeDetail> &list, const quint32 &id)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief append append in the end of list node.
* @param node new node.
*/
void VDetail::append(const VNodeDetail &node) void VDetail::append(const VNodeDetail &node)
{ {
d->nodes.append(node); d->nodes.append(node);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief CountNode return count nodes.
* @return count.
*/
qint32 VDetail::CountNode() const qint32 VDetail::CountNode() const
{ {
return d->nodes.size(); return d->nodes.size();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VDetail::getName() const /**
{ * @brief getMx return bias for X axis.
return d->name; * @return x bias.
} */
//---------------------------------------------------------------------------------------------------------------------
void VDetail::setName(const QString &value)
{
d->name = value;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VDetail::getMx() const qreal VDetail::getMx() const
{ {
return d->mx; return d->mx;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief setMx set bias for X axis.
* @param value new x bias.
*/
void VDetail::setMx(const qreal &value) void VDetail::setMx(const qreal &value)
{ {
d->mx = value; d->mx = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief getMy get bias for y axis.
* @return y axis.
*/
qreal VDetail::getMy() const qreal VDetail::getMy() const
{ {
return d->my; return d->my;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief setMy set bias for y axis.
* @param value new y bias.
*/
void VDetail::setMy(const qreal &value) void VDetail::setMy(const qreal &value)
{ {
d->my = value; d->my = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VDetail::getSeamAllowance() const /**
{ * @brief getNodes return list of nodes.
return d->seamAllowance; * @return list of nodes.
} */
//---------------------------------------------------------------------------------------------------------------------
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;
}
//---------------------------------------------------------------------------------------------------------------------
QVector<VNodeDetail> VDetail::getNodes() const QVector<VNodeDetail> VDetail::getNodes() const
{ {
return d->nodes; return d->nodes;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/**
* @brief setNodes set list of nodes
* @param value list of nodes
*/
void VDetail::setNodes(const QVector<VNodeDetail> &value) void VDetail::setNodes(const QVector<VNodeDetail> &value)
{ {
d->nodes = value; d->nodes = value;

View File

@ -30,211 +30,55 @@
#define VDETAIL_H #define VDETAIL_H
#include "vnodedetail.h" #include "vnodedetail.h"
#include <QString>
#include <QVector> #include <QVector>
class QString; #include "../libs/vlayout/vabstractdetail.h"
class VDetailData; class VDetailData;
/** /**
* @brief The VDetail class for path of object (points, arcs, splines). * @brief The VDetail class for path of object (points, arcs, splines).
*/ */
class VDetail class VDetail :public VAbstractDetail
{ {
public: public:
/**
* @brief VDetail default contructor. Create empty detail.
*/
VDetail(); VDetail();
/**
* @brief VDetail constructor.
* @param name detail name.
* @param nodes list of nodes.
*/
VDetail(const QString &name, const QVector<VNodeDetail> &nodes); VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
/**
* @brief VDetail copy constructor.
* @param detail detail.
*/
VDetail(const VDetail &detail); VDetail(const VDetail &detail);
/**
* @brief operator = assignment operator.
* @param detail detail.
* @return new detail.
*/
VDetail &operator=(const VDetail &detail); VDetail &operator=(const VDetail &detail);
~VDetail(); virtual ~VDetail();
/**
* @brief append append in the end of list node.
* @param node new node.
*/
void append(const VNodeDetail &node); void append(const VNodeDetail &node);
/**
* @brief Clear detail full clear.
*/
void Clear(); void Clear();
/**
* @brief ClearNodes clear list of nodes.
*/
void ClearNodes(); void ClearNodes();
/**
* @brief CountNode return count nodes.
* @return count.
*/
qint32 CountNode() const; 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; 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); 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; 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; qreal getMx() const;
/**
* @brief setMx set bias for X axis.
* @param value new x bias.
*/
void setMx(const qreal &value); void setMx(const qreal &value);
/**
* @brief getMy get bias for y axis.
* @return y axis.
*/
qreal getMy() const; qreal getMy() const;
/**
* @brief setMy set bias for y axis.
* @param value new y bias.
*/
void setMy(const qreal &value); 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.
*/
QVector<VNodeDetail> getNodes() const;
/**
* @brief setNodes set list of nodes
* @param value list of nodes
*/
void setNodes(const QVector<VNodeDetail> &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; quint32 id() const;
/**
* @brief setId set id detail in list data.
* @param id detail id.
*/
void setId(const quint32 &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 QVector<VNodeDetail> getNodes() const;
* located arcs or splines ignore this. void setNodes(const QVector<VNodeDetail> &value);
* @param p1 id first point.
* @param p2 id second point. int indexOfNode(const quint32 &id) const;
* @return true - on edge, false - no.
*/
bool OnEdge(const quint32 &p1, const quint32 &p2)const; 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; 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; 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; 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<quint32> Missing(const VDetail &det) const; QList<quint32> Missing(const VDetail &det) const;
private: private:
QSharedDataPointer<VDetailData> d; QSharedDataPointer<VDetailData> d;
/**
* @brief listNodePoint return list nodes only with points.
* @return list points node.
*/
QVector<VNodeDetail> listNodePoint()const; QVector<VNodeDetail> 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<VNodeDetail> &list, const quint32 &id); static int indexOfNode(const QVector<VNodeDetail> &list, const quint32 &id);
}; };

View File

@ -42,53 +42,30 @@ class VDetailData : public QSharedData
{ {
public: public:
VDetailData() VDetailData()
:_id(NULL_ID), nodes(QVector<VNodeDetail>()), name(QString()), mx(0), my(0), seamAllowance(true), closed(true), :_id(NULL_ID), nodes(QVector<VNodeDetail>()), mx(0), my(0)
width(0)
{} {}
VDetailData(const QString &name, const QVector<VNodeDetail> &nodes) VDetailData(const QVector<VNodeDetail> &nodes)
:_id(NULL_ID), nodes(nodes), name(name), mx(0), my(0), seamAllowance(true), closed(true), width(0) :_id(NULL_ID), nodes(nodes), mx(0), my(0)
{} {}
VDetailData(const VDetailData &detail) VDetailData(const VDetailData &detail)
:QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), name(detail.name), mx(detail.mx), my(detail.my), :QSharedData(detail), _id(NULL_ID), nodes(detail.nodes), mx(detail.mx), my(detail.my)
seamAllowance(detail.seamAllowance), closed(detail.closed), width(detail.width)
{} {}
~VDetailData() {} ~VDetailData() {}
/** /** @brief _id id detail. */
* @brief _id id detail.
*/
quint32 _id; quint32 _id;
/**
* @brief nodes list detail nodes. /** @brief nodes list detail nodes. */
*/
QVector<VNodeDetail> nodes; QVector<VNodeDetail> nodes;
/**
* @brief name detail name. /** @brief mx bias x axis. */
*/
QString name;
/**
* @brief mx bias x axis.
*/
qreal mx; qreal mx;
/**
* @brief my bias y axis. /** @brief my bias y axis. */
*/
qreal my; 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 #ifdef Q_CC_GNU

View File

@ -44,7 +44,7 @@ public:
VAbstractDetail(const QString &name); VAbstractDetail(const QString &name);
VAbstractDetail(const VAbstractDetail &detail); VAbstractDetail(const VAbstractDetail &detail);
VAbstractDetail &operator=(const VAbstractDetail &detail); VAbstractDetail &operator=(const VAbstractDetail &detail);
~VAbstractDetail(); virtual ~VAbstractDetail();
void Clear(); void Clear();