diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index b6e3374cc..53493e5f8 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -658,8 +658,6 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document } else if (element.tagName() == TagData) { - QString qsName = element.attribute(AttrName, ""); - detail.GetPatternPieceData().SetName(qsName); QString qsLetter = element.attribute(AttrLetter, ""); detail.GetPatternPieceData().SetLetter(qsLetter); QPointF ptPos; diff --git a/src/libs/ifc/schema/pattern/v0.3.3.xsd b/src/libs/ifc/schema/pattern/v0.3.3.xsd index 3bdf8d2f3..db2bb2d03 100644 --- a/src/libs/ifc/schema/pattern/v0.3.3.xsd +++ b/src/libs/ifc/schema/pattern/v0.3.3.xsd @@ -350,7 +350,6 @@ - diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index 6347e58e4..fab73e12a 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -241,6 +241,8 @@ int VPoster::CountColumns(int width) const //--------------------------------------------------------------------------------------------------------------------- PosterData VPoster::Cut(int i, int j, const QRect &imageRect) const { + Q_UNUSED(imageRect); + const int x = j*PageRect().width() - j*static_cast(allowence); const int y = i*PageRect().height() - i*static_cast(allowence); diff --git a/src/libs/vpatterndb/vpatternpiecedata.cpp b/src/libs/vpatterndb/vpatternpiecedata.cpp index afb44d731..3ae853501 100644 --- a/src/libs/vpatterndb/vpatternpiecedata.cpp +++ b/src/libs/vpatterndb/vpatternpiecedata.cpp @@ -29,15 +29,15 @@ #include "vpatternpiecedata.h" //--------------------------------------------------------------------------------------------------------------------- -VPatternPieceData::VPatternPieceData() : - m_ptPos(0, 0) -{ - m_iFontSize = MIN_FONT_SIZE; - // 0 means unknown width - m_dLabelWidth = 0; - m_dLabelHeight = 0; - m_dRotation = 0; -} +MaterialCutPlacement::MaterialCutPlacement() + :m_eMaterial(MaterialType::mtFabric), m_qsMaterialUserDef(), m_iCutNumber(0), m_ePlacement(PlacementType::ptNone) +{} + +//--------------------------------------------------------------------------------------------------------------------- +VPatternPieceData::VPatternPieceData() + :m_qsLetter(), m_conMCP(), m_ptPos(0, 0), m_dLabelWidth(0), m_dLabelHeight(0), + m_iFontSize(MIN_FONT_SIZE), m_dRotation(0) +{} //--------------------------------------------------------------------------------------------------------------------- VPatternPieceData::~VPatternPieceData() @@ -91,7 +91,6 @@ void VPatternPieceData::RemoveMCP(int i) void VPatternPieceData::Clear() { m_qsLetter.clear(); - m_qsName.clear(); m_conMCP.clear(); } @@ -107,18 +106,6 @@ void VPatternPieceData::SetLetter(QString qsLetter) m_qsLetter = qsLetter.left(3); } -//--------------------------------------------------------------------------------------------------------------------- -const QString& VPatternPieceData::GetName() const -{ - return m_qsName; -} - -//--------------------------------------------------------------------------------------------------------------------- -void VPatternPieceData::SetName(QString qsName) -{ - m_qsName = qsName; -} - //--------------------------------------------------------------------------------------------------------------------- QPointF VPatternPieceData::GetPos() const { diff --git a/src/libs/vpatterndb/vpatternpiecedata.h b/src/libs/vpatterndb/vpatternpiecedata.h index 11997cc36..4ce3c22be 100644 --- a/src/libs/vpatterndb/vpatternpiecedata.h +++ b/src/libs/vpatterndb/vpatternpiecedata.h @@ -55,6 +55,8 @@ struct MaterialCutPlacement QString m_qsMaterialUserDef; int m_iCutNumber; PlacementType m_ePlacement; + + MaterialCutPlacement(); }; typedef QList MCPContainer; @@ -81,8 +83,6 @@ public: // methods, which operate on other members const QString& GetLetter() const; void SetLetter(QString qsLetter); - const QString& GetName() const; - void SetName(QString qsName); // methods, which set up label parameters QPointF GetPos() const; @@ -97,9 +97,6 @@ public: void SetRotation(qreal dRot); private: - /** @brief Pattern piece name - */ - QString m_qsName; /** @brief Pattern piece letter (should be no more than 3 letters) */ QString m_qsLetter; diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index 44f25234d..a8ae201af 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -44,15 +44,16 @@ * @param parent parent widget */ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true) + :DialogTool(data, toolId, parent), ui(), detail(VDetail()), supplement(true), closed(true), flagWidth(true), + m_bAddMode(true), m_qslMaterials(), m_qslPlacements(), m_conMCP(), m_oldData(), m_oldGeom() { ui.setupUi(this); #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) - ui.lineEditNameDetail->setClearButtonEnabled(true); + ui.lineEditName->setClearButtonEnabled(true); #endif - labelEditNamePoint = ui.labelEditNameDetail; + labelEditNamePoint = ui.labelEditName; ui.labelUnit->setText( VDomDocument::UnitsToStr(qApp->patternUnit(), true)); ui.labelUnitX->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); ui.labelUnitY->setText(VDomDocument::UnitsToStr(qApp->patternUnit(), true)); @@ -85,7 +86,7 @@ DialogDetail::DialogDetail(const VContainer *data, const quint32 &toolId, QWidge connect(ui.checkBoxSeams, &QCheckBox::clicked, this, &DialogDetail::ClickedSeams); connect(ui.checkBoxClosed, &QCheckBox::clicked, this, &DialogDetail::ClickedClosed); connect(ui.checkBoxReverse, &QCheckBox::clicked, this, &DialogDetail::ClickedReverse); - connect(ui.lineEditNameDetail, &QLineEdit::textChanged, this, &DialogDetail::NameDetailChanged); + connect(ui.lineEditName, &QLineEdit::textChanged, this, &DialogDetail::NameDetailChanged); connect(ui.toolButtonDelete, &QToolButton::clicked, this, &DialogDetail::DeleteItem); connect(ui.toolButtonUp, &QToolButton::clicked, this, &DialogDetail::ScrollUp); @@ -355,19 +356,24 @@ VDetail DialogDetail::CreateDetail() const detail.append( qvariant_cast(item->data(Qt::UserRole))); } detail.setWidth(ui.doubleSpinBoxSeams->value()); - detail.setName(ui.lineEditNameDetail->text()); + detail.setName(ui.lineEditName->text()); detail.setSeamAllowance(supplement); detail.setClosed(closed); detail.GetPatternPieceData().SetLetter(ui.lineEditLetter->text()); - detail.GetPatternPieceData().SetName(ui.lineEditName->text()); for (int i = 0; i < m_conMCP.count(); ++i) { detail.GetPatternPieceData().Append(m_conMCP[i]); } - detail.GetPatternPieceData().SetPos(m_ptPos); + detail.GetPatternPieceData().SetPos(m_oldData.GetPos()); + detail.GetPatternPieceData().SetLabelWidth(m_oldData.GetLabelWidth()); + detail.GetPatternPieceData().SetLabelHeight(m_oldData.GetLabelHeight()); + detail.GetPatternPieceData().SetFontSize(m_oldData.GetFontSize()); + detail.GetPatternPieceData().SetRotation(m_oldData.GetRotation()); + + detail.GetPatternInfo() = m_oldGeom; return detail; } @@ -416,7 +422,7 @@ void DialogDetail::setDetail(const VDetail &value) NewItem(node.getId(), node.getTypeTool(), node.getTypeNode(), node.getMx(), node.getMy(), node.getReverse()); } - ui.lineEditNameDetail->setText(detail.getName()); + ui.lineEditName->setText(detail.getName()); ui.checkBoxSeams->setChecked(detail.getSeamAllowance()); ui.checkBoxClosed->setChecked(detail.getClosed()); ClickedClosed(detail.getClosed()); @@ -427,7 +433,6 @@ void DialogDetail::setDetail(const VDetail &value) ui.toolButtonDelete->setEnabled(true); ui.lineEditLetter->setText(detail.GetPatternPieceData().GetLetter()); - ui.lineEditName->setText(detail.GetPatternPieceData().GetName()); m_conMCP.clear(); for (int i = 0; i < detail.GetPatternPieceData().GetMCPCount(); ++i) @@ -436,7 +441,8 @@ void DialogDetail::setDetail(const VDetail &value) } UpdateList(); - m_ptPos = detail.GetPatternPieceData().GetPos(); + m_oldData = detail.GetPatternPieceData(); + m_oldGeom = detail.GetPatternInfo(); ValidObjects(DetailIsValid()); } diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.h b/src/libs/vtools/dialogs/tools/dialogdetail.h index 6dd932ab8..482a5ee5d 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.h +++ b/src/libs/vtools/dialogs/tools/dialogdetail.h @@ -33,6 +33,7 @@ #include "dialogtool.h" #include "../vpatterndb/vdetail.h" #include "../vpatterndb/vpatternpiecedata.h" +#include "../vpatterndb/vpatterninfogeometry.h" /** * @brief The DialogDetail class dialog for ToolDetai. Help create detail and edit option. @@ -92,7 +93,8 @@ private: QStringList m_qslPlacements; // temporary container for Material/Cut/Placement 3-tuples MCPContainer m_conMCP; - QPointF m_ptPos; + VPatternPieceData m_oldData; + VPatternInfoGeometry m_oldGeom; bool DetailIsValid() const; diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.ui b/src/libs/vtools/dialogs/tools/dialogdetail.ui index 8faa4a01f..3b220ca70 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.ui +++ b/src/libs/vtools/dialogs/tools/dialogdetail.ui @@ -191,74 +191,7 @@ - - - - - - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 255 - 0 - 0 - - - - - - - - - 159 - 158 - 158 - - - - - - - - - - - Name of detail: - - - - - - - - 0 - 0 - - - - Detail - - - - + @@ -457,25 +390,25 @@ - + - 9 - 38 - 40 + 10 + 40 + 101 16 - Name: + Name of detail: - 55 - 38 - 125 + 110 + 40 + 151 23 @@ -586,9 +519,9 @@ - 55 - 9 - 125 + 110 + 10 + 151 23 @@ -633,7 +566,6 @@ doubleSpinBoxBiasX doubleSpinBoxBiasY checkBoxReverse - lineEditNameDetail checkBoxSeams doubleSpinBoxSeams toolButtonDown diff --git a/src/libs/vtools/tools/vtextgraphicsitem.cpp b/src/libs/vtools/tools/vtextgraphicsitem.cpp index 025ba13af..2e3c2fe68 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.cpp +++ b/src/libs/vtools/tools/vtextgraphicsitem.cpp @@ -33,6 +33,7 @@ #include #include +#include "../vmisc/def.h" #include "vtextgraphicsitem.h" #define RESIZE_SQUARE 30 @@ -46,14 +47,20 @@ #define SPACING 2 #define TOP_Z 2 +//--------------------------------------------------------------------------------------------------------------------- +TextLine::TextLine() + :m_qsText(), m_iFontSize(MIN_FONT_SIZE), m_eFontWeight(QFont::Normal), m_eStyle(QFont::StyleNormal), + m_eAlign(Qt::AlignCenter), m_iHeight(0) +{} + //--------------------------------------------------------------------------------------------------------------------- VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent) - : QGraphicsObject(pParent) + :QGraphicsObject(pParent), m_eMode(VTextGraphicsItem::mNormal), m_bReleased(false), + m_ptStartPos(), m_ptStart(), m_ptRotCenter(), m_szStart(), m_dRotation(0), m_dAngle(0), + m_rectResize(), m_iMinH(MIN_H), m_rectBoundingBox(), m_font(), m_liLines(), m_liOutput() + { - m_eMode = mNormal; - m_bReleased = false; m_rectBoundingBox.setTopLeft(QPointF(0, 0)); - m_iMinH = MIN_H; SetSize(MIN_W, m_iMinH); setZValue(TOP_Z); } @@ -219,6 +226,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME) else { m_eMode = mMove; + SetOverrideCursor(cursorArrowCloseHand, 1, 1); } } setZValue(TOP_Z + 1); @@ -232,14 +240,25 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME) QPointF ptDiff = pME->scenePos() - m_ptStart; if (m_eMode == mMove) { - setPos(m_ptStartPos + ptDiff); - UpdateBox(); + QPointF pt = m_ptStartPos + ptDiff; + pt.setX(pt.x() + m_rectBoundingBox.width()/2); + pt.setY(pt.y() + m_rectBoundingBox.height()/2); + if (parentItem()->boundingRect().contains(pt) == true) + { + setPos(m_ptStartPos + ptDiff); + UpdateBox(); + } } else if (m_eMode == mResize) { - SetSize(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y()); - Update(); - emit SignalShrink(); + QPointF pt = m_ptStartPos; + pt.setX(pt.x() + (m_szStart.width() + ptDiff.x())/2); + pt.setY(pt.y() + (m_szStart.height() + ptDiff.y())/2); + if (parentItem()->boundingRect().contains(pt) == true) { + SetSize(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y()); + Update(); + emit SignalShrink(); + } } else if (m_eMode == mRotate) { @@ -260,6 +279,7 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) { if (pME->button() == Qt::LeftButton) { + RestoreOverrideCursor(cursorArrowCloseHand); double dDist = fabs(pME->scenePos().x() - m_ptStart.x()) + fabs(pME->scenePos().y() - m_ptStart.y()); bool bShort = (dDist < 2); @@ -289,6 +309,7 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME) if (bShort == true) { m_eMode = mMove; + SetOverrideCursor(cursorArrowCloseHand, 1, 1); UpdateBox(); } else diff --git a/src/libs/vtools/tools/vtextgraphicsitem.h b/src/libs/vtools/tools/vtextgraphicsitem.h index 7f01e987c..703ba289f 100644 --- a/src/libs/vtools/tools/vtextgraphicsitem.h +++ b/src/libs/vtools/tools/vtextgraphicsitem.h @@ -41,6 +41,8 @@ struct TextLine QFont::Style m_eStyle; Qt::Alignment m_eAlign; int m_iHeight; + + TextLine(); }; class VTextGraphicsItem : public QGraphicsObject diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index 3df76dab0..cddf349c0 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -81,7 +81,8 @@ const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath"); VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation, VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem *parent) :VAbstractTool(doc, data, id), VNoBrushScalePathItem(parent), dialog(nullptr), sceneDetails(scene), - drawName(drawName), seamAllowance(new VNoBrushScalePathItem(this)) + drawName(drawName), seamAllowance(new VNoBrushScalePathItem(this)), dataLabel(new VTextGraphicsItem(this)), + patternInfo(new VTextGraphicsItem(this)) { VDetail detail = data->GetDetail(id); for (int i = 0; i< detail.CountNode(); ++i) @@ -130,13 +131,11 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 } setAcceptHoverEvents(true); - dataLabel = new VTextGraphicsItem(this); connect(dataLabel, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMoveDetail); connect(dataLabel, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizeDetail); connect(dataLabel, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationDetail); //connect(dataLabel, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll); - patternInfo = new VTextGraphicsItem(this); connect(patternInfo, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMovePattern); connect(patternInfo, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizePattern); connect(patternInfo, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationPattern); @@ -354,7 +353,6 @@ void VToolDetail::AddToFile() QDomElement domData = doc->createElement(VAbstractPattern::TagData); const VPatternPieceData& data = detail.GetPatternPieceData(); doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter()); - doc->SetAttribute(domData, VAbstractPattern::AttrName, data.GetName()); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, AttrWidth, data.GetLabelWidth()); @@ -411,8 +409,6 @@ void VToolDetail::RefreshDataInFile() QDomElement domData = doc->createElement(VAbstractPattern::TagData); const VPatternPieceData& data = det.GetPatternPieceData(); - doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter()); - doc->SetAttribute(domData, VAbstractPattern::AttrName, data.GetName()); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, AttrWidth, data.GetLabelWidth()); @@ -675,7 +671,7 @@ void VToolDetail::UpdateLabel() const VDetail detail = VAbstractTool::data.GetDetail(id); const VPatternPieceData& data = detail.GetPatternPieceData(); - if (data.GetLetter().isEmpty() == false || data.GetName().isEmpty() == false || data.GetMCPCount() > 0) + if (data.GetLetter().isEmpty() == false || detail.getName().isEmpty() == false || data.GetMCPCount() > 0) { //dataLabel->Reset(); @@ -695,7 +691,7 @@ void VToolDetail::UpdateLabel() tl.m_eStyle = QFont::StyleNormal; tl.m_iFontSize = 6; dataLabel->AddLine(tl); - tl.m_qsText = data.GetName(); + tl.m_qsText = detail.getName(); tl.m_eAlign = Qt::AlignCenter; tl.m_eFontWeight = QFont::DemiBold; tl.m_iFontSize = 2; diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index f6776638a..af6ec446b 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -139,7 +139,6 @@ void SaveDetailOptions::SavePatternPieceData(QDomElement &domElement, const VDet QDomElement domData = doc->createElement(VAbstractPattern::TagData); const VPatternPieceData& data = det.GetPatternPieceData(); doc->SetAttribute(domData, VAbstractPattern::AttrLetter, data.GetLetter()); - doc->SetAttribute(domData, VAbstractPattern::AttrName, data.GetName()); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, VToolDetail::AttrWidth, data.GetLabelWidth());