Added possibility to hide both labels for each detail individually
--HG-- branch : feature
This commit is contained in:
parent
aa1d1f8ce1
commit
192c4d33a7
|
@ -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());
|
||||
|
|
|
@ -351,6 +351,7 @@
|
|||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="letter" type="xs:string"></xs:attribute>
|
||||
<xs:attribute name="visible" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="fontSize" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
|
@ -361,6 +362,7 @@
|
|||
</xs:element>
|
||||
<xs:element name="patternInfo" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="visible" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="fontSize" type="xs:unsignedInt"></xs:attribute>
|
||||
<xs:attribute name="mx" type="xs:double"></xs:attribute>
|
||||
<xs:attribute name="my" type="xs:double"></xs:attribute>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -529,6 +529,32 @@
|
|||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBoxDetail">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>230</y>
|
||||
<width>141</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Detail label visible</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBoxPattern">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>260</y>
|
||||
<width>141</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Pattern label visible</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue
Block a user