Documentation for VDetail class.

--HG--
branch : develop
This commit is contained in:
dismine 2014-01-21 15:51:41 +02:00
parent b5731ebc04
commit 0bf384f1e3
6 changed files with 148 additions and 81 deletions

View File

@ -273,7 +273,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
{ {
const VPointF *point = GeometricObject<const VPointF*>(detail.at(i).getId()); const VPointF *point = GeometricObject<const VPointF*>(detail.at(i).getId());
points.append(point->toQPointF()); points.append(point->toQPointF());
if (detail.getSupplement() == true) if (detail.getSeamAllowance() == true)
{ {
QPointF pEkv = point->toQPointF(); QPointF pEkv = point->toQPointF();
pEkv.setX(pEkv.x()+detail.at(i).getMx()); pEkv.setX(pEkv.x()+detail.at(i).getMx());
@ -290,7 +290,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
if (len1 <= lenReverse) if (len1 <= lenReverse)
{ {
points << arc->GetPoints(); points << arc->GetPoints();
if (detail.getSupplement() == true) if (detail.getSeamAllowance() == true)
{ {
pointsEkv << biasPoints(arc->GetPoints(), detail.at(i).getMx(), detail.at(i).getMy()); pointsEkv << biasPoints(arc->GetPoints(), detail.at(i).getMx(), detail.at(i).getMy());
} }
@ -298,7 +298,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
else else
{ {
points << GetReversePoint(arc->GetPoints()); points << GetReversePoint(arc->GetPoints());
if (detail.getSupplement() == true) if (detail.getSeamAllowance() == true)
{ {
pointsEkv << biasPoints(GetReversePoint(arc->GetPoints()), detail.at(i).getMx(), pointsEkv << biasPoints(GetReversePoint(arc->GetPoints()), detail.at(i).getMx(),
detail.at(i).getMy()); detail.at(i).getMy());
@ -314,7 +314,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
if (len1 <= lenReverse) if (len1 <= lenReverse)
{ {
points << spline->GetPoints(); points << spline->GetPoints();
if (detail.getSupplement() == true) if (detail.getSeamAllowance() == true)
{ {
pointsEkv << biasPoints(spline->GetPoints(), detail.at(i).getMx(), detail.at(i).getMy()); pointsEkv << biasPoints(spline->GetPoints(), detail.at(i).getMx(), detail.at(i).getMy());
} }
@ -322,7 +322,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
else else
{ {
points << GetReversePoint(spline->GetPoints()); points << GetReversePoint(spline->GetPoints());
if (detail.getSupplement() == true) if (detail.getSeamAllowance() == true)
{ {
pointsEkv << biasPoints(GetReversePoint(spline->GetPoints()), detail.at(i).getMx(), pointsEkv << biasPoints(GetReversePoint(spline->GetPoints()), detail.at(i).getMx(),
detail.at(i).getMy()); detail.at(i).getMy());
@ -338,7 +338,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
if (len1 <= lenReverse) if (len1 <= lenReverse)
{ {
points << splinePath->GetPathPoints(); points << splinePath->GetPathPoints();
if (detail.getSupplement() == true) if (detail.getSeamAllowance() == true)
{ {
pointsEkv << biasPoints(splinePath->GetPathPoints(), detail.at(i).getMx(), detail.at(i).getMy()); pointsEkv << biasPoints(splinePath->GetPathPoints(), detail.at(i).getMx(), detail.at(i).getMy());
} }
@ -346,7 +346,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
else else
{ {
points << GetReversePoint(splinePath->GetPathPoints()); points << GetReversePoint(splinePath->GetPathPoints());
if (detail.getSupplement() == true) if (detail.getSeamAllowance() == true)
{ {
pointsEkv << biasPoints(GetReversePoint(splinePath->GetPathPoints()), detail.at(i).getMx(), pointsEkv << biasPoints(GetReversePoint(splinePath->GetPathPoints()), detail.at(i).getMx(),
detail.at(i).getMy()); detail.at(i).getMy());
@ -370,7 +370,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const
pointsEkv = CorrectEquidistantPoints(pointsEkv); pointsEkv = CorrectEquidistantPoints(pointsEkv);
if (detail.getSupplement() == true) if (detail.getSeamAllowance() == true)
{ {
QPainterPath ekv; QPainterPath ekv;
if (detail.getClosed() == true) if (detail.getClosed() == true)

View File

@ -97,7 +97,7 @@ void DialogDetail::DialogAccepted()
} }
details.setWidth(ui.doubleSpinBoxSeams->value()); details.setWidth(ui.doubleSpinBoxSeams->value());
details.setName(ui.lineEditNameDetail->text()); details.setName(ui.lineEditNameDetail->text());
details.setSupplement(supplement); details.setSeamAllowance(supplement);
details.setClosed(closed); details.setClosed(closed);
emit ToolTip(""); emit ToolTip("");
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
@ -166,10 +166,10 @@ void DialogDetail::setDetails(const VDetail &value)
details[i].getMy()); details[i].getMy());
} }
ui.lineEditNameDetail->setText(details.getName()); ui.lineEditNameDetail->setText(details.getName());
ui.checkBoxSeams->setChecked(details.getSupplement()); ui.checkBoxSeams->setChecked(details.getSeamAllowance());
ui.checkBoxClosed->setChecked(details.getClosed()); ui.checkBoxClosed->setChecked(details.getClosed());
ClickedClosed(details.getClosed()); ClickedClosed(details.getClosed());
ClickedSeams(details.getSupplement()); ClickedSeams(details.getSeamAllowance());
ui.doubleSpinBoxSeams->setValue(details.getWidth()); ui.doubleSpinBoxSeams->setValue(details.getWidth());
ui.listWidget->setCurrentRow(0); ui.listWidget->setCurrentRow(0);
ui.listWidget->setFocus(Qt::OtherFocusReason); ui.listWidget->setFocus(Qt::OtherFocusReason);

View File

@ -29,11 +29,11 @@
#include "vdetail.h" #include "vdetail.h"
VDetail::VDetail() VDetail::VDetail()
:_id(0), nodes(QVector<VNodeDetail>()), name(QString()), mx(0), my(0), supplement(true), closed(true), :_id(0), nodes(QVector<VNodeDetail>()), name(QString()), mx(0), my(0), seamAllowance(true), closed(true),
width(10){} width(10){}
VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes) VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes)
:_id(0), nodes(QVector<VNodeDetail>()), name(name), mx(0), my(0), supplement(true), closed(true), :_id(0), nodes(QVector<VNodeDetail>()), name(name), mx(0), my(0), seamAllowance(true), closed(true),
width(10) width(10)
{ {
this->nodes = nodes; this->nodes = nodes;
@ -41,7 +41,7 @@ VDetail::VDetail(const QString &name, const QVector<VNodeDetail> &nodes)
VDetail::VDetail(const VDetail &detail) VDetail::VDetail(const VDetail &detail)
:_id(0), nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), my(detail.getMy()), :_id(0), nodes(detail.getNodes()), name(detail.getName()), mx(detail.getMx()), my(detail.getMy()),
supplement(detail.getSupplement()), closed(detail.getClosed()), width(detail.getWidth()){} seamAllowance(detail.getSeamAllowance()), closed(detail.getClosed()), width(detail.getWidth()){}
VDetail &VDetail::operator =(const VDetail &detail) VDetail &VDetail::operator =(const VDetail &detail)
{ {
@ -50,7 +50,7 @@ VDetail &VDetail::operator =(const VDetail &detail)
name = detail.getName(); name = detail.getName();
mx = detail.getMx(); mx = detail.getMx();
my = detail.getMy(); my = detail.getMy();
supplement = detail.getSupplement(); seamAllowance = detail.getSeamAllowance();
closed = detail.getClosed(); closed = detail.getClosed();
width = detail.getWidth(); width = detail.getWidth();
return *this; return *this;
@ -62,7 +62,7 @@ void VDetail::Clear()
name.clear(); name.clear();
mx = 0; mx = 0;
my = 0; my = 0;
supplement = true; seamAllowance = true;
closed = true; closed = true;
width = 10; width = 10;
} }

View File

@ -37,13 +37,15 @@
namespace Detail namespace Detail
{ {
/** /**
* @brief The Contour enum * @brief The Contour enum OpenContour - first and last points contour don't match,
* CloseContour - first and last points contour match.
*/ */
enum Contour { OpenContour, CloseContour }; enum Contour { OpenContour, CloseContour };
Q_DECLARE_FLAGS(Contours, Contour) Q_DECLARE_FLAGS(Contours, Contour)
/** /**
* @brief The Equidistant enum * @brief The Equidistant enum OpenEquidistant - first and last points equidistant don't match,
* CloseEquidistant - first and last points equidistant match.
*/ */
enum Equidistant { OpenEquidistant, CloseEquidistant }; enum Equidistant { OpenEquidistant, CloseEquidistant };
Q_DECLARE_FLAGS(Equidistants, Equidistant) Q_DECLARE_FLAGS(Equidistants, Equidistant)
@ -52,169 +54,234 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours)
Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants) Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants)
/** /**
* @brief The VDetail class * @brief The VDetail class for path of object (points, arcs, splines).
*/ */
class VDetail class VDetail
{ {
public: public:
/** /**
* @brief VDetail * @brief VDetail default contructor. Create empty detail.
*/ */
VDetail(); VDetail();
/** /**
* @brief VDetail * @brief VDetail constructor.
* @param name * @param name detail name.
* @param nodes * @param nodes list of nodes.
*/ */
VDetail(const QString &name, const QVector<VNodeDetail> &nodes); VDetail(const QString &name, const QVector<VNodeDetail> &nodes);
/** /**
* @brief VDetail * @brief VDetail copy constructor.
* @param detail * @param detail detail.
*/ */
VDetail(const VDetail &detail); VDetail(const VDetail &detail);
/** /**
* @brief operator = * @brief operator = assignment operator.
* @param detail * @param detail detail.
* @return * @return new detail.
*/ */
VDetail &operator=(const VDetail &detail); VDetail &operator=(const VDetail &detail);
/** /**
* @brief append * @brief append append in the end of list node.
* @param node * @param node new node.
*/ */
inline void append(const VNodeDetail &node) {nodes.append(node);} inline void append(const VNodeDetail &node) {nodes.append(node);}
/** /**
* @brief Clear * @brief Clear detail full clear.
*/ */
void Clear(); void Clear();
/**
* @brief ClearNodes clear list of nodes.
*/
void ClearNodes(); void ClearNodes();
/** /**
* @brief CountNode * @brief CountNode return count nodes.
* @return * @return count.
*/ */
inline qint32 CountNode() const {return nodes.size();} inline qint32 CountNode() const {return nodes.size();}
/** /**
* @brief Containes * @brief Containes check if detail containe this id.
* @param id * @param id object id.
* @return * @return true if containe.
*/ */
bool Containes(const qint64 &id)const; bool Containes(const qint64 &id)const;
/** /**
* @brief operator [] * @brief operator [] find node by index in list.
* @param indx * @param indx index node in list.
* @return * @return node
*/ */
VNodeDetail & operator[](ptrdiff_t indx); VNodeDetail & operator[](ptrdiff_t indx);
/**
* @brief at find node by index in list.
* @param indx index node in list.
* @return const node.
*/
const VNodeDetail & at ( ptrdiff_t indx ) const; const VNodeDetail & at ( ptrdiff_t indx ) const;
/** /**
* @brief getName * @brief getName return detail name.
* @return * @return name.
*/ */
inline QString getName() const {return name;} inline QString getName() const {return name;}
/** /**
* @brief setName * @brief setName set detail name.
* @param value * @param value new name.
*/ */
inline void setName(const QString &value) {name = value;} inline void setName(const QString &value) {name = value;}
/** /**
* @brief getMx * @brief getMx return bias for X axis.
* @return * @return x bias.
*/ */
inline qreal getMx() const {return mx;} inline qreal getMx() const {return mx;}
/** /**
* @brief setMx * @brief setMx set bias for X axis.
* @param value * @param value new x bias.
*/ */
inline void setMx(const qreal &value) {mx = value;} inline void setMx(const qreal &value) {mx = value;}
/** /**
* @brief getMy * @brief getMy get bias for y axis.
* @return * @return y axis.
*/ */
inline qreal getMy() const {return my;} inline qreal getMy() const {return my;}
/** /**
* @brief setMy * @brief setMy set bias for y axis.
* @param value * @param value new y bias.
*/ */
inline void setMy(const qreal &value) {my = value;} inline void setMy(const qreal &value) {my = value;}
/** /**
* @brief getSupplement * @brief getSeamAllowance keep status for seam allowance detail.
* @return * @return true - need seam allowance, false - no need seam allowance.
*/ */
inline bool getSupplement() const {return supplement;} inline bool getSeamAllowance() const {return seamAllowance;}
/** /**
* @brief setSupplement * @brief setSeamAllowance set status for seam allowance detail.
* @param value * @param value true - need seam allowance, false - no need seam allowance.
*/ */
inline void setSupplement(bool value) {supplement = value;} inline void setSeamAllowance(bool value) {seamAllowance = value;}
/** /**
* @brief getClosed * @brief getClosed keep close status for detail equdistant.
* @return * @return true - close equdistant, false - don't close equdistant.
*/ */
inline bool getClosed() const {return closed;} inline bool getClosed() const {return closed;}
/** /**
* @brief setClosed * @brief setClosed set close status for detail equdistant.
* @param value * @param value true - close equdistant, false - don't close equdistant.
*/ */
inline void setClosed(bool value) {closed = value;} inline void setClosed(bool value) {closed = value;}
/** /**
* @brief getWidth * @brief getWidth return value detail seam allowance.
* @return * @return value in mm.
*/ */
inline qreal getWidth() const {return width;} inline qreal getWidth() const {return width;}
/** /**
* @brief setWidth * @brief setWidth set value detail seam allowance.
* @param value * @param value width in mm.
*/ */
inline void setWidth(const qreal &value) {width = value;} inline void setWidth(const qreal &value) {width = value;}
/** /**
* @brief getNodes * @brief getNodes return list of nodes.
* @return * @return list of nodes.
*/ */
inline QVector<VNodeDetail> getNodes() const {return nodes;} inline QVector<VNodeDetail> getNodes() const {return nodes;}
/** /**
* @brief setNodes * @brief setNodes set list of nodes
* @param value * @param value list of nodes
*/ */
inline void setNodes(const QVector<VNodeDetail> &value) {nodes = value;} inline void setNodes(const QVector<VNodeDetail> &value) {nodes = 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.
*/
ptrdiff_t indexOfNode(const qint64 &id) const; ptrdiff_t indexOfNode(const qint64 &id) const;
/**
* @brief id return id detail in list data.
* @return id.
*/
qint64 id() const; qint64 id() const;
/**
* @brief setId set id detail in list data.
* @param id detail id.
*/
void setId(const qint64 &id); void setId(const qint64 &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 qint64 &p1, const qint64 &p2)const; bool OnEdge(const qint64 &p1, const qint64 &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
*/
ptrdiff_t Edge(const qint64 &p1, const qint64 &p2)const; ptrdiff_t Edge(const qint64 &p1, const qint64 &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 ptrdiff_t &index, VNodeDetail &p1, VNodeDetail &p2)const; void NodeOnEdge(const ptrdiff_t &index, VNodeDetail &p1, VNodeDetail &p2)const;
/**
* @brief RemoveEdge return detail without edge with index.
* @param index idex of edge.
* @return
*/
VDetail RemoveEdge(const ptrdiff_t &index) const; VDetail RemoveEdge(const ptrdiff_t &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<qint64> Missing(const VDetail &det) const; QList<qint64> Missing(const VDetail &det) const;
private: private:
/**
* @brief _id id detail.
*/
qint64 _id; qint64 _id;
/** /**
* @brief nodes * @brief nodes list detail nodes.
*/ */
QVector<VNodeDetail> nodes; QVector<VNodeDetail> nodes;
/** /**
* @brief name * @brief name detail name.
*/ */
QString name; QString name;
/** /**
* @brief mx * @brief mx bias x axis.
*/ */
qreal mx; qreal mx;
/** /**
* @brief my * @brief my bias y axis.
*/ */
qreal my; qreal my;
/** /**
* @brief supplement * @brief seamAllowance status seamAllowance detail.
*/ */
bool supplement; bool seamAllowance;
/** /**
* @brief closed * @brief closed status equdistant detail.
*/ */
bool closed; bool closed;
/** /**
* @brief width * @brief width value seamAllowance in mm.
*/ */
qreal width; qreal width;
/**
* @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.
*/
ptrdiff_t indexOfNode(const QVector<VNodeDetail> &list, const qint64 &id) const; ptrdiff_t indexOfNode(const QVector<VNodeDetail> &list, const qint64 &id) const;
}; };

View File

@ -177,7 +177,7 @@ void VToolDetail::FullUpdateFromGui(int result)
{ {
VDetail det = dialogDetail->getDetails(); VDetail det = dialogDetail->getDetails();
SetAttribute(domElement, AttrName, det.getName()); SetAttribute(domElement, AttrName, det.getName());
SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSupplement())); SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance()));
SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed()));
SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth()));
RemoveAllChild(domElement); RemoveAllChild(domElement);
@ -211,7 +211,7 @@ void VToolDetail::AddToFile()
SetAttribute(domElement, AttrName, detail.getName()); SetAttribute(domElement, AttrName, detail.getName());
SetAttribute(domElement, AttrMx, toMM(detail.getMx())); SetAttribute(domElement, AttrMx, toMM(detail.getMx()));
SetAttribute(domElement, AttrMy, toMM(detail.getMy())); SetAttribute(domElement, AttrMy, toMM(detail.getMy()));
SetAttribute(domElement, AttrSupplement, detail.getSupplement()); SetAttribute(domElement, AttrSupplement, detail.getSeamAllowance());
SetAttribute(domElement, AttrClosed, detail.getClosed()); SetAttribute(domElement, AttrClosed, detail.getClosed());
SetAttribute(domElement, AttrWidth, detail.getWidth()); SetAttribute(domElement, AttrWidth, detail.getWidth());
@ -235,7 +235,7 @@ void VToolDetail::RefreshDataInFile()
{ {
VDetail det = VAbstractTool::data.GetDetail(id); VDetail det = VAbstractTool::data.GetDetail(id);
SetAttribute(domElement, AttrName, det.getName()); SetAttribute(domElement, AttrName, det.getName());
SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSupplement())); SetAttribute(domElement, AttrSupplement, QString().setNum(det.getSeamAllowance()));
SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed())); SetAttribute(domElement, AttrClosed, QString().setNum(det.getClosed()));
SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth())); SetAttribute(domElement, AttrWidth, QString().setNum(det.getWidth()));
RemoveAllChild(domElement); RemoveAllChild(domElement);

View File

@ -637,7 +637,7 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo
detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, "")); detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, ""));
detail.setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0"))); detail.setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")));
detail.setMy(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0"))); detail.setMy(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")));
detail.setSupplement(GetParametrLongLong(domElement, VToolDetail::AttrSupplement, "1")); detail.setSeamAllowance(GetParametrLongLong(domElement, VToolDetail::AttrSupplement, "1"));
detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0")); detail.setWidth(GetParametrDouble(domElement, VToolDetail::AttrWidth, "10.0"));
detail.setClosed(GetParametrLongLong(domElement, VToolDetail::AttrClosed, "1")); detail.setClosed(GetParametrLongLong(domElement, VToolDetail::AttrClosed, "1"));