From 192c4d33a7507e0aaa67051b555d31004676e5da Mon Sep 17 00:00:00 2001 From: BojanKverh Date: Wed, 6 Jul 2016 21:56:52 +0200 Subject: [PATCH] Added possibility to hide both labels for each detail individually --HG-- branch : feature --- src/app/valentina/xml/vpattern.cpp | 3 + src/libs/ifc/schema/pattern/v0.3.3.xsd | 2 + src/libs/vpatterndb/vpatterninfogeometry.cpp | 18 ++- src/libs/vpatterndb/vpatterninfogeometry.h | 6 + src/libs/vpatterndb/vpatternpiecedata.cpp | 14 ++- src/libs/vpatterndb/vpatternpiecedata.h | 6 + .../vtools/dialogs/tools/dialogdetail.cpp | 6 + src/libs/vtools/dialogs/tools/dialogdetail.ui | 26 +++++ src/libs/vtools/tools/vtooldetail.cpp | 106 ++++++++++-------- .../vtools/undocommands/savedetailoptions.cpp | 2 + 10 files changed, 139 insertions(+), 50 deletions(-) diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 53493e5f8..d83a82193 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -658,6 +658,8 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document } else if (element.tagName() == TagData) { + QString qsVisible = element.attribute(AttrVisible, "1"); + detail.GetPatternPieceData().SetVisible(qsVisible.toInt() != 0); QString qsLetter = element.attribute(AttrLetter, ""); detail.GetPatternPieceData().SetLetter(qsLetter); QPointF ptPos; @@ -687,6 +689,7 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document } else if (element.tagName() == TagPatternInfo) { + detail.GetPatternInfo().SetVisible(element.attribute(AttrVisible, "1").toInt() != 0); QPointF ptPos; ptPos.setX(element.attribute(AttrMx, "0").toDouble()); ptPos.setY(element.attribute(AttrMy, "0").toDouble()); diff --git a/src/libs/ifc/schema/pattern/v0.3.3.xsd b/src/libs/ifc/schema/pattern/v0.3.3.xsd index db2bb2d03..9f622d42e 100644 --- a/src/libs/ifc/schema/pattern/v0.3.3.xsd +++ b/src/libs/ifc/schema/pattern/v0.3.3.xsd @@ -351,6 +351,7 @@ + @@ -361,6 +362,7 @@ + diff --git a/src/libs/vpatterndb/vpatterninfogeometry.cpp b/src/libs/vpatterndb/vpatterninfogeometry.cpp index cb0728454..11881bdbd 100644 --- a/src/libs/vpatterndb/vpatterninfogeometry.cpp +++ b/src/libs/vpatterndb/vpatterninfogeometry.cpp @@ -29,8 +29,9 @@ #include "vpatterninfogeometry.h" //--------------------------------------------------------------------------------------------------------------------- -VPatternInfoGeometry::VPatternInfoGeometry() : - m_ptPos(0, 0) +VPatternInfoGeometry::VPatternInfoGeometry() + :m_ptPos(0, 0), m_dLabelWidth(0), m_dLabelHeight(0), m_iFontSize(MIN_FONT_SIZE), + m_dRotation(0), m_bVisible(true) { m_iFontSize = MIN_FONT_SIZE; // 0 means unknown width @@ -106,3 +107,16 @@ void VPatternInfoGeometry::SetRotation(qreal dRot) m_dRotation = dRot; } +//--------------------------------------------------------------------------------------------------------------------- +bool VPatternInfoGeometry::IsVisible() const +{ + return m_bVisible; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPatternInfoGeometry::SetVisible(bool bVal) +{ + m_bVisible = bVal; +} + +//--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpatterninfogeometry.h b/src/libs/vpatterndb/vpatterninfogeometry.h index 36c8217c7..0f9ff5cfd 100644 --- a/src/libs/vpatterndb/vpatterninfogeometry.h +++ b/src/libs/vpatterndb/vpatterninfogeometry.h @@ -50,6 +50,8 @@ public: void SetFontSize(int iSize); qreal GetRotation() const; void SetRotation(qreal dRot); + bool IsVisible() const; + void SetVisible(bool bVal); private: QPointF m_ptPos; @@ -65,6 +67,10 @@ private: /** @brief Label rotation */ qreal m_dRotation; + /** @brief Visibility flag + */ + bool m_bVisible; + }; #endif // VPATTERNINFOGEOMETRY_H diff --git a/src/libs/vpatterndb/vpatternpiecedata.cpp b/src/libs/vpatterndb/vpatternpiecedata.cpp index 3ae853501..20b694bb0 100644 --- a/src/libs/vpatterndb/vpatternpiecedata.cpp +++ b/src/libs/vpatterndb/vpatternpiecedata.cpp @@ -36,7 +36,7 @@ MaterialCutPlacement::MaterialCutPlacement() //--------------------------------------------------------------------------------------------------------------------- VPatternPieceData::VPatternPieceData() :m_qsLetter(), m_conMCP(), m_ptPos(0, 0), m_dLabelWidth(0), m_dLabelHeight(0), - m_iFontSize(MIN_FONT_SIZE), m_dRotation(0) + m_iFontSize(MIN_FONT_SIZE), m_dRotation(0), m_bVisible(true) {} //--------------------------------------------------------------------------------------------------------------------- @@ -170,4 +170,16 @@ void VPatternPieceData::SetRotation(qreal dRot) } //--------------------------------------------------------------------------------------------------------------------- +bool VPatternPieceData::IsVisible() const +{ + return m_bVisible; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VPatternPieceData::SetVisible(bool bVal) +{ + m_bVisible = bVal; +} + +//--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpatternpiecedata.h b/src/libs/vpatterndb/vpatternpiecedata.h index 4ce3c22be..833249f2d 100644 --- a/src/libs/vpatterndb/vpatternpiecedata.h +++ b/src/libs/vpatterndb/vpatternpiecedata.h @@ -95,6 +95,8 @@ public: void SetFontSize(int iSize); qreal GetRotation() const; void SetRotation(qreal dRot); + bool IsVisible() const; + void SetVisible(bool bVal); private: /** @brief Pattern piece letter (should be no more than 3 letters) @@ -118,6 +120,10 @@ private: /** @brief Label rotation */ qreal m_dRotation; + /** @brief Visibility flag + */ + bool m_bVisible; + }; #endif // VPATTERNPIECEDATA_H diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.cpp b/src/libs/vtools/dialogs/tools/dialogdetail.cpp index a8ae201af..3f6da9a01 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.cpp +++ b/src/libs/vtools/dialogs/tools/dialogdetail.cpp @@ -372,8 +372,12 @@ VDetail DialogDetail::CreateDetail() const detail.GetPatternPieceData().SetLabelHeight(m_oldData.GetLabelHeight()); detail.GetPatternPieceData().SetFontSize(m_oldData.GetFontSize()); detail.GetPatternPieceData().SetRotation(m_oldData.GetRotation()); + detail.GetPatternPieceData().SetVisible(ui.checkBoxDetail->isChecked()); + + qDebug() << "DD VISIBLE" << detail.GetPatternPieceData().IsVisible(); detail.GetPatternInfo() = m_oldGeom; + detail.GetPatternInfo().SetVisible(ui.checkBoxPattern->isChecked()); return detail; } @@ -433,6 +437,8 @@ void DialogDetail::setDetail(const VDetail &value) ui.toolButtonDelete->setEnabled(true); ui.lineEditLetter->setText(detail.GetPatternPieceData().GetLetter()); + ui.checkBoxDetail->setChecked(detail.GetPatternPieceData().IsVisible()); + ui.checkBoxPattern->setChecked(detail.GetPatternInfo().IsVisible()); m_conMCP.clear(); for (int i = 0; i < detail.GetPatternPieceData().GetMCPCount(); ++i) diff --git a/src/libs/vtools/dialogs/tools/dialogdetail.ui b/src/libs/vtools/dialogs/tools/dialogdetail.ui index 3b220ca70..165a4b4b7 100644 --- a/src/libs/vtools/dialogs/tools/dialogdetail.ui +++ b/src/libs/vtools/dialogs/tools/dialogdetail.ui @@ -529,6 +529,32 @@ 3 + + + + 10 + 230 + 141 + 21 + + + + Detail label visible + + + + + + 10 + 260 + 141 + 21 + + + + Pattern label visible + + diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index cddf349c0..1929c3e3c 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -353,6 +353,7 @@ 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::AttrVisible, data.IsVisible() == true? 1:0); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, AttrWidth, data.GetLabelWidth()); @@ -374,6 +375,7 @@ void VToolDetail::AddToFile() domData = doc->createElement(VAbstractPattern::TagPatternInfo); const VPatternInfoGeometry& geom = detail.GetPatternInfo(); + doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible() == true? 1:0); doc->SetAttribute(domData, AttrMx, geom.GetPos().x()); doc->SetAttribute(domData, AttrMy, geom.GetPos().y()); doc->SetAttribute(domData, AttrWidth, geom.GetLabelWidth()); @@ -409,6 +411,8 @@ 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::AttrVisible, data.IsVisible() == true? 1:0); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, AttrWidth, data.GetLabelWidth()); @@ -430,6 +434,7 @@ void VToolDetail::RefreshDataInFile() domData = doc->createElement(VAbstractPattern::TagPatternInfo); const VPatternInfoGeometry& geom = det.GetPatternInfo(); + doc->SetAttribute(domData, VAbstractPattern::AttrVisible, geom.IsVisible() == true? 1:0); doc->SetAttribute(domData, AttrMx, geom.GetPos().x()); doc->SetAttribute(domData, AttrMy, geom.GetPos().y()); doc->SetAttribute(domData, AttrWidth, geom.GetLabelWidth()); @@ -669,9 +674,9 @@ void VToolDetail::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) void VToolDetail::UpdateLabel() { const VDetail detail = VAbstractTool::data.GetDetail(id); - const VPatternPieceData& data = detail.GetPatternPieceData(); - if (data.GetLetter().isEmpty() == false || detail.getName().isEmpty() == false || data.GetMCPCount() > 0) + + if (data.IsVisible() == true) { //dataLabel->Reset(); @@ -736,62 +741,69 @@ void VToolDetail::UpdatePatternInfo() const VDetail detail = VAbstractTool::data.GetDetail(id); const VPatternInfoGeometry& geom = detail.GetPatternInfo(); - //patternInfo->Reset(); - QFont fnt = qApp->font(); - int iFS = geom.GetFontSize(); - if (iFS < MIN_FONT_SIZE) + if (geom.IsVisible() == true) { - iFS = MIN_FONT_SIZE; - } - fnt.setPixelSize(iFS); - patternInfo->SetFont(fnt); - patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight()); - patternInfo->Clear(); - TextLine tl; + QFont fnt = qApp->font(); + int iFS = geom.GetFontSize(); + if (iFS < MIN_FONT_SIZE) + { + iFS = MIN_FONT_SIZE; + } + fnt.setPixelSize(iFS); + patternInfo->SetFont(fnt); + patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight()); + patternInfo->Clear(); + TextLine tl; - // Company name - tl.m_qsText = doc->GetCompanyName(); - tl.m_eAlign = Qt::AlignCenter; - tl.m_eFontWeight = QFont::DemiBold; - tl.m_eStyle = QFont::StyleNormal; - tl.m_iFontSize = 4; - patternInfo->AddLine(tl); + // Company name + tl.m_qsText = doc->GetCompanyName(); + tl.m_eAlign = Qt::AlignCenter; + tl.m_eFontWeight = QFont::DemiBold; + tl.m_eStyle = QFont::StyleNormal; + tl.m_iFontSize = 4; + patternInfo->AddLine(tl); - // Pattern name - tl.m_qsText = doc->GetPatternName(); - tl.m_eFontWeight = QFont::Normal; - tl.m_iFontSize = 2; - patternInfo->AddLine(tl); + // Pattern name + tl.m_qsText = doc->GetPatternName(); + tl.m_eFontWeight = QFont::Normal; + tl.m_iFontSize = 2; + patternInfo->AddLine(tl); - // Pattern number - tl.m_qsText = doc->GetPatternNumber(); - tl.m_iFontSize = 0; - tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter; - patternInfo->AddLine(tl); + // Pattern number + tl.m_qsText = doc->GetPatternNumber(); + tl.m_iFontSize = 0; + tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter; + patternInfo->AddLine(tl); - // Customer name - tl.m_qsText = doc->GetCustomerName(); - tl.m_eStyle = QFont::StyleItalic; - patternInfo->AddLine(tl); + // Customer name + tl.m_qsText = doc->GetCustomerName(); + tl.m_eStyle = QFont::StyleItalic; + patternInfo->AddLine(tl); - // Creation date - QStringList qslDate = doc->GetCreationDate().toString(Qt::SystemLocaleLongDate).split(", "); - tl.m_qsText = qslDate.last(); - patternInfo->AddLine(tl); + // Creation date + QStringList qslDate = doc->GetCreationDate().toString(Qt::SystemLocaleLongDate).split(", "); + tl.m_qsText = qslDate.last(); + patternInfo->AddLine(tl); - // check if center is inside - QPointF pt; - if (boundingRect().contains(geom.GetPos() + QPointF(geom.GetLabelWidth()/2, geom.GetLabelHeight()/2)) == false) - { - pt = boundingRect().topLeft(); + // check if center is inside + QPointF pt; + if (boundingRect().contains(geom.GetPos() + QPointF(geom.GetLabelWidth()/2, geom.GetLabelHeight()/2)) == false) + { + pt = boundingRect().topLeft(); + } + else + { + pt = geom.GetPos(); + } + patternInfo->setPos(pt); + patternInfo->setRotation(geom.GetRotation()); + patternInfo->Update(); + patternInfo->show(); } else { - pt = geom.GetPos(); + patternInfo->hide(); } - patternInfo->setPos(pt); - patternInfo->setRotation(geom.GetRotation()); - patternInfo->Update(); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/undocommands/savedetailoptions.cpp b/src/libs/vtools/undocommands/savedetailoptions.cpp index af6ec446b..85320bcd4 100644 --- a/src/libs/vtools/undocommands/savedetailoptions.cpp +++ b/src/libs/vtools/undocommands/savedetailoptions.cpp @@ -139,6 +139,7 @@ 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::AttrVisible, data.IsVisible() == true? 1:0); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, VToolDetail::AttrWidth, data.GetLabelWidth()); @@ -164,6 +165,7 @@ void SaveDetailOptions::SavePatternInfo(QDomElement &domElement, const VDetail & { QDomElement domData = doc->createElement(VAbstractPattern::TagPatternInfo); const VPatternInfoGeometry& data = det.GetPatternInfo(); + doc->SetAttribute(domData, VAbstractPattern::AttrVisible, data.IsVisible() == true? 1:0); doc->SetAttribute(domData, AttrMx, data.GetPos().x()); doc->SetAttribute(domData, AttrMy, data.GetPos().y()); doc->SetAttribute(domData, VToolDetail::AttrWidth, data.GetLabelWidth());