diff --git a/src/container/vcontainer.cpp b/src/container/vcontainer.cpp index fff72e6e8..0a7e7c59a 100644 --- a/src/container/vcontainer.cpp +++ b/src/container/vcontainer.cpp @@ -273,7 +273,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const { const VPointF *point = GeometricObject(detail.at(i).getId()); points.append(point->toQPointF()); - if (detail.getSupplement() == true) + if (detail.getSeamAllowance() == true) { QPointF pEkv = point->toQPointF(); pEkv.setX(pEkv.x()+detail.at(i).getMx()); @@ -290,7 +290,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const if (len1 <= lenReverse) { points << arc->GetPoints(); - if (detail.getSupplement() == true) + if (detail.getSeamAllowance() == true) { pointsEkv << biasPoints(arc->GetPoints(), detail.at(i).getMx(), detail.at(i).getMy()); } @@ -298,7 +298,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const else { points << GetReversePoint(arc->GetPoints()); - if (detail.getSupplement() == true) + if (detail.getSeamAllowance() == true) { pointsEkv << biasPoints(GetReversePoint(arc->GetPoints()), detail.at(i).getMx(), detail.at(i).getMy()); @@ -314,7 +314,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const if (len1 <= lenReverse) { points << spline->GetPoints(); - if (detail.getSupplement() == true) + if (detail.getSeamAllowance() == true) { pointsEkv << biasPoints(spline->GetPoints(), detail.at(i).getMx(), detail.at(i).getMy()); } @@ -322,7 +322,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const else { points << GetReversePoint(spline->GetPoints()); - if (detail.getSupplement() == true) + if (detail.getSeamAllowance() == true) { pointsEkv << biasPoints(GetReversePoint(spline->GetPoints()), detail.at(i).getMx(), detail.at(i).getMy()); @@ -338,7 +338,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const if (len1 <= lenReverse) { points << splinePath->GetPathPoints(); - if (detail.getSupplement() == true) + if (detail.getSeamAllowance() == true) { pointsEkv << biasPoints(splinePath->GetPathPoints(), detail.at(i).getMx(), detail.at(i).getMy()); } @@ -346,7 +346,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const else { points << GetReversePoint(splinePath->GetPathPoints()); - if (detail.getSupplement() == true) + if (detail.getSeamAllowance() == true) { pointsEkv << biasPoints(GetReversePoint(splinePath->GetPathPoints()), detail.at(i).getMx(), detail.at(i).getMy()); @@ -370,7 +370,7 @@ QPainterPath VContainer::ContourPath(qint64 idDetail) const pointsEkv = CorrectEquidistantPoints(pointsEkv); - if (detail.getSupplement() == true) + if (detail.getSeamAllowance() == true) { QPainterPath ekv; if (detail.getClosed() == true) diff --git a/src/dialogs/dialogdetail.cpp b/src/dialogs/dialogdetail.cpp index d0801cfff..6a9324cb6 100644 --- a/src/dialogs/dialogdetail.cpp +++ b/src/dialogs/dialogdetail.cpp @@ -97,7 +97,7 @@ void DialogDetail::DialogAccepted() } details.setWidth(ui.doubleSpinBoxSeams->value()); details.setName(ui.lineEditNameDetail->text()); - details.setSupplement(supplement); + details.setSeamAllowance(supplement); details.setClosed(closed); emit ToolTip(""); emit DialogClosed(QDialog::Accepted); @@ -166,10 +166,10 @@ void DialogDetail::setDetails(const VDetail &value) details[i].getMy()); } ui.lineEditNameDetail->setText(details.getName()); - ui.checkBoxSeams->setChecked(details.getSupplement()); + ui.checkBoxSeams->setChecked(details.getSeamAllowance()); ui.checkBoxClosed->setChecked(details.getClosed()); ClickedClosed(details.getClosed()); - ClickedSeams(details.getSupplement()); + ClickedSeams(details.getSeamAllowance()); ui.doubleSpinBoxSeams->setValue(details.getWidth()); ui.listWidget->setCurrentRow(0); ui.listWidget->setFocus(Qt::OtherFocusReason); diff --git a/src/geometry/vdetail.cpp b/src/geometry/vdetail.cpp index d771cdd59..fc9573850 100644 --- a/src/geometry/vdetail.cpp +++ b/src/geometry/vdetail.cpp @@ -29,11 +29,11 @@ #include "vdetail.h" VDetail::VDetail() - :_id(0), nodes(QVector()), name(QString()), mx(0), my(0), supplement(true), closed(true), + :_id(0), nodes(QVector()), name(QString()), mx(0), my(0), seamAllowance(true), closed(true), width(10){} VDetail::VDetail(const QString &name, const QVector &nodes) - :_id(0), nodes(QVector()), name(name), mx(0), my(0), supplement(true), closed(true), + :_id(0), nodes(QVector()), name(name), mx(0), my(0), seamAllowance(true), closed(true), width(10) { this->nodes = nodes; @@ -41,7 +41,7 @@ VDetail::VDetail(const QString &name, const QVector &nodes) VDetail::VDetail(const VDetail &detail) :_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) { @@ -50,7 +50,7 @@ VDetail &VDetail::operator =(const VDetail &detail) name = detail.getName(); mx = detail.getMx(); my = detail.getMy(); - supplement = detail.getSupplement(); + seamAllowance = detail.getSeamAllowance(); closed = detail.getClosed(); width = detail.getWidth(); return *this; @@ -62,7 +62,7 @@ void VDetail::Clear() name.clear(); mx = 0; my = 0; - supplement = true; + seamAllowance = true; closed = true; width = 10; } diff --git a/src/geometry/vdetail.h b/src/geometry/vdetail.h index 4825a8a13..189b2dcd0 100644 --- a/src/geometry/vdetail.h +++ b/src/geometry/vdetail.h @@ -37,13 +37,15 @@ 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 }; 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 }; Q_DECLARE_FLAGS(Equidistants, Equidistant) @@ -52,169 +54,234 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Contours) Q_DECLARE_OPERATORS_FOR_FLAGS(Detail::Equidistants) /** - * @brief The VDetail class + * @brief The VDetail class for path of object (points, arcs, splines). */ class VDetail { public: /** - * @brief VDetail + * @brief VDetail default contructor. Create empty detail. */ VDetail(); /** - * @brief VDetail - * @param name - * @param nodes + * @brief VDetail constructor. + * @param name detail name. + * @param nodes list of nodes. */ VDetail(const QString &name, const QVector &nodes); /** - * @brief VDetail - * @param detail + * @brief VDetail copy constructor. + * @param detail detail. */ VDetail(const VDetail &detail); /** - * @brief operator = - * @param detail - * @return + * @brief operator = assignment operator. + * @param detail detail. + * @return new detail. */ VDetail &operator=(const VDetail &detail); /** - * @brief append - * @param node + * @brief append append in the end of list node. + * @param node new node. */ inline void append(const VNodeDetail &node) {nodes.append(node);} /** - * @brief Clear + * @brief Clear detail full clear. */ void Clear(); + /** + * @brief ClearNodes clear list of nodes. + */ void ClearNodes(); /** - * @brief CountNode - * @return + * @brief CountNode return count nodes. + * @return count. */ inline qint32 CountNode() const {return nodes.size();} /** - * @brief Containes - * @param id - * @return + * @brief Containes check if detail containe this id. + * @param id object id. + * @return true if containe. */ bool Containes(const qint64 &id)const; /** - * @brief operator [] - * @param indx - * @return + * @brief operator [] find node by index in list. + * @param indx index node in list. + * @return node */ 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; /** - * @brief getName - * @return + * @brief getName return detail name. + * @return name. */ inline QString getName() const {return name;} /** - * @brief setName - * @param value + * @brief setName set detail name. + * @param value new name. */ inline void setName(const QString &value) {name = value;} /** - * @brief getMx - * @return + * @brief getMx return bias for X axis. + * @return x bias. */ inline qreal getMx() const {return mx;} /** - * @brief setMx - * @param value + * @brief setMx set bias for X axis. + * @param value new x bias. */ inline void setMx(const qreal &value) {mx = value;} /** - * @brief getMy - * @return + * @brief getMy get bias for y axis. + * @return y axis. */ inline qreal getMy() const {return my;} /** - * @brief setMy - * @param value + * @brief setMy set bias for y axis. + * @param value new y bias. */ inline void setMy(const qreal &value) {my = value;} /** - * @brief getSupplement - * @return + * @brief getSeamAllowance keep status for seam allowance detail. + * @return true - need seam allowance, false - no need seam allowance. */ - inline bool getSupplement() const {return supplement;} + inline bool getSeamAllowance() const {return seamAllowance;} /** - * @brief setSupplement - * @param value + * @brief setSeamAllowance set status for seam allowance detail. + * @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 - * @return + * @brief getClosed keep close status for detail equdistant. + * @return true - close equdistant, false - don't close equdistant. */ inline bool getClosed() const {return closed;} /** - * @brief setClosed - * @param value + * @brief setClosed set close status for detail equdistant. + * @param value true - close equdistant, false - don't close equdistant. */ inline void setClosed(bool value) {closed = value;} /** - * @brief getWidth - * @return + * @brief getWidth return value detail seam allowance. + * @return value in mm. */ inline qreal getWidth() const {return width;} /** - * @brief setWidth - * @param value + * @brief setWidth set value detail seam allowance. + * @param value width in mm. */ inline void setWidth(const qreal &value) {width = value;} /** - * @brief getNodes - * @return + * @brief getNodes return list of nodes. + * @return list of nodes. */ inline QVector getNodes() const {return nodes;} /** - * @brief setNodes - * @param value + * @brief setNodes set list of nodes + * @param value list of nodes */ inline void setNodes(const QVector &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; + /** + * @brief id return id detail in list data. + * @return id. + */ qint64 id() const; + /** + * @brief setId set id detail in list data. + * @param id detail 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; + /** + * @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; + /** + * @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; + /** + * @brief RemoveEdge return detail without edge with index. + * @param index idex of edge. + * @return + */ 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 Missing(const VDetail &det) const; private: + /** + * @brief _id id detail. + */ qint64 _id; /** - * @brief nodes + * @brief nodes list detail nodes. */ QVector nodes; /** - * @brief name + * @brief name detail name. */ QString name; /** - * @brief mx + * @brief mx bias x axis. */ qreal mx; /** - * @brief my + * @brief my bias y axis. */ qreal my; /** - * @brief supplement + * @brief seamAllowance status seamAllowance detail. */ - bool supplement; + bool seamAllowance; /** - * @brief closed + * @brief closed status equdistant detail. */ bool closed; /** - * @brief width + * @brief width value seamAllowance in mm. */ qreal width; + /** + * @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. + */ ptrdiff_t indexOfNode(const QVector &list, const qint64 &id) const; }; diff --git a/src/tools/vtooldetail.cpp b/src/tools/vtooldetail.cpp index b5861f466..8ac10239e 100644 --- a/src/tools/vtooldetail.cpp +++ b/src/tools/vtooldetail.cpp @@ -177,7 +177,7 @@ void VToolDetail::FullUpdateFromGui(int result) { VDetail det = dialogDetail->getDetails(); 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, AttrWidth, QString().setNum(det.getWidth())); RemoveAllChild(domElement); @@ -211,7 +211,7 @@ void VToolDetail::AddToFile() SetAttribute(domElement, AttrName, detail.getName()); SetAttribute(domElement, AttrMx, toMM(detail.getMx())); SetAttribute(domElement, AttrMy, toMM(detail.getMy())); - SetAttribute(domElement, AttrSupplement, detail.getSupplement()); + SetAttribute(domElement, AttrSupplement, detail.getSeamAllowance()); SetAttribute(domElement, AttrClosed, detail.getClosed()); SetAttribute(domElement, AttrWidth, detail.getWidth()); @@ -235,7 +235,7 @@ void VToolDetail::RefreshDataInFile() { VDetail det = VAbstractTool::data.GetDetail(id); 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, AttrWidth, QString().setNum(det.getWidth())); RemoveAllChild(domElement); diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp index 6012b4875..1d86ad8d2 100644 --- a/src/xml/vdomdocument.cpp +++ b/src/xml/vdomdocument.cpp @@ -637,7 +637,7 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo detail.setName(GetParametrString(domElement, VAbstractTool::AttrName, "")); detail.setMx(toPixel(GetParametrDouble(domElement, VAbstractTool::AttrMx, "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.setClosed(GetParametrLongLong(domElement, VToolDetail::AttrClosed, "1"));