Corrected all the issues reported by Roman till 10:11 AM

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-07-22 11:56:45 +02:00
parent 28af32f027
commit 0e7b369c2e
13 changed files with 88 additions and 75 deletions

View File

@ -488,8 +488,7 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
{ {
date = QDate::currentDate(); date = QDate::currentDate();
} }
det.SetPatternInfo(pDoc->GetPatternName(), pDoc->GetPatternNumber(), pDoc->GetPatternSize(), det.SetPatternInfo(pDoc, geom, qApp->font());
pDoc->GetCompanyName(), pDoc->GetCustomerName(), date, geom, qApp->font());
} }
det.setWidth(qApp->toPixel(d.getWidth())); det.setWidth(qApp->toPixel(d.getWidth()));
det.CreateTextItems(); det.CreateTextItems();

View File

@ -656,21 +656,27 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
} }
else if (element.tagName() == TagData) else if (element.tagName() == TagData)
{ {
QString qsVisible = element.attribute(AttrVisible, "1"); bool bVisible = GetParametrBool(element, AttrVisible, trueStr);
detail.GetPatternPieceData().SetVisible(qsVisible.toInt() != 0); detail.GetPatternPieceData().SetVisible(bVisible);
QString qsLetter = element.attribute(AttrLetter, ""); try
detail.GetPatternPieceData().SetLetter(qsLetter); {
QString qsLetter = GetParametrString(element, AttrLetter, "");
detail.GetPatternPieceData().SetLetter(qsLetter);
} catch(...)
{
detail.GetPatternPieceData().SetLetter("");
}
QPointF ptPos; QPointF ptPos;
ptPos.setX(element.attribute(AttrMx, "0").toDouble()); ptPos.setX(GetParametrDouble(element, AttrMx, "0"));
ptPos.setY(element.attribute(AttrMy, "0").toDouble()); ptPos.setY(GetParametrDouble(element, AttrMy, "0"));
detail.GetPatternPieceData().SetPos(ptPos); detail.GetPatternPieceData().SetPos(ptPos);
qreal dLW = element.attribute(VToolDetail::AttrWidth, "0").toDouble(); qreal dLW = GetParametrDouble(element, VToolDetail::AttrWidth, "0");
detail.GetPatternPieceData().SetLabelWidth(dLW); detail.GetPatternPieceData().SetLabelWidth(dLW);
qreal dLH = element.attribute(VToolDetail::AttrHeight, "0").toDouble(); qreal dLH = GetParametrDouble(element, VToolDetail::AttrHeight, "0");
detail.GetPatternPieceData().SetLabelHeight(dLH); detail.GetPatternPieceData().SetLabelHeight(dLH);
int iFS = element.attribute(VToolDetail::AttrFont, "0").toInt(); int iFS = GetParametrUInt(element, VToolDetail::AttrFont, "0");
detail.GetPatternPieceData().SetFontSize(iFS); detail.GetPatternPieceData().SetFontSize(iFS);
qreal dRot = element.attribute(VToolDetail::AttrRotation, "0").toDouble(); qreal dRot = GetParametrDouble(element, VToolDetail::AttrRotation, "0");
detail.GetPatternPieceData().SetRotation(dRot); detail.GetPatternPieceData().SetRotation(dRot);
QDomNodeList nodeListMCP = element.childNodes(); QDomNodeList nodeListMCP = element.childNodes();
@ -687,24 +693,23 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
} }
else if (element.tagName() == TagPatternInfo) else if (element.tagName() == TagPatternInfo)
{ {
detail.GetPatternInfo().SetVisible(element.attribute(AttrVisible, "1").toInt() != 0); detail.GetPatternInfo().SetVisible(GetParametrBool(element, AttrVisible, trueStr));
QPointF ptPos; QPointF ptPos;
ptPos.setX(element.attribute(AttrMx, "0").toDouble()); ptPos.setX(GetParametrDouble(element, AttrMx, "0"));
ptPos.setY(element.attribute(AttrMy, "0").toDouble()); ptPos.setY(GetParametrDouble(element, AttrMy, "0"));
detail.GetPatternInfo().SetPos(ptPos); detail.GetPatternInfo().SetPos(ptPos);
qreal dLW = element.attribute(VToolDetail::AttrWidth, "0").toDouble(); qreal dLW = GetParametrDouble(element, VToolDetail::AttrWidth, "0");
detail.GetPatternInfo().SetLabelWidth(dLW); detail.GetPatternInfo().SetLabelWidth(dLW);
qreal dLH = element.attribute(VToolDetail::AttrHeight, "0").toDouble(); qreal dLH = GetParametrDouble(element, VToolDetail::AttrHeight, "0");
detail.GetPatternInfo().SetLabelHeight(dLH); detail.GetPatternInfo().SetLabelHeight(dLH);
int iFS = element.attribute(VToolDetail::AttrFont, "0").toInt(); int iFS = GetParametrUInt(element, VToolDetail::AttrFont, "0");
detail.GetPatternInfo().SetFontSize(iFS); detail.GetPatternInfo().SetFontSize(iFS);
qreal dRot = element.attribute(VToolDetail::AttrRotation, "0").toDouble(); qreal dRot = GetParametrDouble(element, VToolDetail::AttrRotation, "0");
detail.GetPatternInfo().SetRotation(dRot); detail.GetPatternInfo().SetRotation(dRot);
} }
} }
} }
VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Source::FromFile); VToolDetail::Create(id, detail, sceneDetail, this, data, parse, Source::FromFile);
SetVersion();
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)
{ {

View File

@ -18,12 +18,6 @@
<xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element> <xs:element name="author" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element> <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element> <xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="patternName" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="patternNumber" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="company" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="showDate" type="xs:boolean" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="gradation" minOccurs="0" maxOccurs="1"> <xs:element name="gradation" minOccurs="0" maxOccurs="1">
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
@ -79,6 +73,12 @@
<xs:attribute name="defSize" type="baseSize"></xs:attribute> <xs:attribute name="defSize" type="baseSize"></xs:attribute>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="patternName" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="patternNumber" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="company" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="customer" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="size" type="xs:string" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="showDate" type="xs:boolean" minOccurs="0" maxOccurs="1"></xs:element>
<xs:element name="measurements" type="xs:string"></xs:element> <xs:element name="measurements" type="xs:string"></xs:element>
<xs:element name="increments" minOccurs="0" maxOccurs="1"> <xs:element name="increments" minOccurs="0" maxOccurs="1">
<xs:complexType> <xs:complexType>
@ -346,13 +346,13 @@
<xs:complexType> <xs:complexType>
<xs:attribute name="cutNumber" type="xs:unsignedInt"/> <xs:attribute name="cutNumber" type="xs:unsignedInt"/>
<xs:attribute name="userDef" type="xs:string"/> <xs:attribute name="userDef" type="xs:string"/>
<xs:attribute name="material" type="xs:unsignedInt"/> <xs:attribute name="material" type="materialType"/>
<xs:attribute name="placement" type="xs:unsignedInt"/> <xs:attribute name="placement" type="placementType"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
</xs:sequence> </xs:sequence>
<xs:attribute name="letter" type="xs:string"></xs:attribute> <xs:attribute name="letter" type="xs:string"></xs:attribute>
<xs:attribute name="visible" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="visible" type="xs:boolean"></xs:attribute>
<xs:attribute name="fontSize" 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="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute> <xs:attribute name="my" type="xs:double"></xs:attribute>
@ -363,7 +363,7 @@
</xs:element> </xs:element>
<xs:element name="patternInfo" minOccurs="0" maxOccurs="1"> <xs:element name="patternInfo" minOccurs="0" maxOccurs="1">
<xs:complexType> <xs:complexType>
<xs:attribute name="visible" type="xs:unsignedInt"></xs:attribute> <xs:attribute name="visible" type="xs:boolean"></xs:attribute>
<xs:attribute name="fontSize" 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="mx" type="xs:double"></xs:attribute>
<xs:attribute name="my" type="xs:double"></xs:attribute> <xs:attribute name="my" type="xs:double"></xs:attribute>
@ -552,4 +552,19 @@
<xs:enumeration value="2"/> <xs:enumeration value="2"/>
</xs:restriction> </xs:restriction>
</xs:simpleType> </xs:simpleType>
<xs:simpleType name="materialType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--Fabric-->
<xs:enumeration value="1"/><!--Lining-->
<xs:enumeration value="2"/><!--Interfacing-->
<xs:enumeration value="3"/><!--Interlining-->
<xs:enumeration value="4"/><!--UserDefined-->
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="placementType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/><!--No placement-->
<xs:enumeration value="1"/><!--Cut on Fold-->
</xs:restriction>
</xs:simpleType>
</xs:schema> </xs:schema>

View File

@ -1073,14 +1073,14 @@ void VAbstractPattern::SetPatternSize(QString qsSize)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VAbstractPattern::IsDateVisible() const bool VAbstractPattern::IsDateVisible() const
{ {
return UniqueTagText(TagShowDate) != QStringLiteral("false"); return UniqueTagText(TagShowDate) != falseStr;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetDateVisible(bool bVisible) void VAbstractPattern::SetDateVisible(bool bVisible)
{ {
CheckTagExists(TagShowDate); CheckTagExists(TagShowDate);
setTagText(TagShowDate, bVisible == true? QStringLiteral("true") : QStringLiteral("false")); setTagText(TagShowDate, bVisible == true? trueStr : falseStr);
modified = true; modified = true;
emit patternChanged(false); emit patternChanged(false);
} }
@ -1245,17 +1245,17 @@ QDomElement VAbstractPattern::CheckTagExists(const QString &tag)
element = createElement(TagPatternName); element = createElement(TagPatternName);
break; break;
} }
case 7: // TagPatternName case 7: // TagPatternNum
{ {
element = createElement(TagPatternNum); element = createElement(TagPatternNum);
break; break;
} }
case 8: // TagPatternName case 8: // TagCompanyName
{ {
element = createElement(TagCompanyName); element = createElement(TagCompanyName);
break; break;
} }
case 9: // TagPatternName case 9: // TagCustomerName
{ {
element = createElement(TagCustomerName); element = createElement(TagCustomerName);
break; break;

View File

@ -7,7 +7,7 @@
# File with common stuff for whole project # File with common stuff for whole project
include(../../../common.pri) include(../../../common.pri)
QT += core gui widgets printsupport QT += core gui widgets printsupport xml
# Name of library # Name of library
TARGET = vlayout TARGET = vlayout

View File

@ -133,7 +133,7 @@ void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& da
<< QPointF(ptPos.x(), ptPos.y() + data.GetLabelHeight()); << QPointF(ptPos.x(), ptPos.y() + data.GetLabelHeight());
for (int i = 0; i < v.count(); ++i) for (int i = 0; i < v.count(); ++i)
{ {
v[i] = RotatePoint(ptCenter, v[i], dAng); v[i] = RotatePoint(ptCenter, v.at(i), dAng);
} }
d->detailLabel = RoundPoints(v); d->detailLabel = RoundPoints(v);
@ -147,9 +147,7 @@ void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& da
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutDetail::SetPatternInfo(const QString& qsPattern, const QString& qsNumber, const QString& qsSize, void VLayoutDetail::SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont &font)
const QString& qsCompany, const QString& qsCustomer, const QDate& date,
const VPatternInfoGeometry& geom, const QFont &font)
{ {
d->patternGeom = geom; d->patternGeom = geom;
qreal dAng = qDegreesToRadians(geom.GetRotation()); qreal dAng = qDegreesToRadians(geom.GetRotation());
@ -169,7 +167,7 @@ void VLayoutDetail::SetPatternInfo(const QString& qsPattern, const QString& qsNu
m_tmPattern.SetFont(font); m_tmPattern.SetFont(font);
m_tmPattern.SetFontSize(geom.GetFontSize()); m_tmPattern.SetFontSize(geom.GetFontSize());
m_tmPattern.Update(qsPattern, qsNumber, qsSize, qsCompany, qsCustomer, date); m_tmPattern.Update(pDoc);
// generate lines of text // generate lines of text
m_tmPattern.SetFontSize(geom.GetFontSize()); m_tmPattern.SetFontSize(geom.GetFontSize());
m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight()); m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight());

View File

@ -60,9 +60,7 @@ public:
void SetDetail(const QString &qsName, const VPatternPieceData& data, const QFont& font); void SetDetail(const QString &qsName, const VPatternPieceData& data, const QFont& font);
void SetPatternInfo(const QString& qsPattern, const QString& qsNumber, const QString& qsSize, void SetPatternInfo(const VAbstractPattern* pDoc, const VPatternInfoGeometry& geom, const QFont& font);
const QString& qsCompany, const QString& qsCustomer, const QDate& date,
const VPatternInfoGeometry& geom, const QFont& font);
QTransform GetMatrix() const; QTransform GetMatrix() const;
void SetMatrix(const QTransform &matrix); void SetMatrix(const QTransform &matrix);

View File

@ -155,8 +155,7 @@ void VTextManager::Update(const QString& qsName, const VPatternPieceData& data)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, const QString &qsSize, void VTextManager::Update(const VAbstractPattern *pDoc)
const QString &qsCompany, const QString &qsCustomer, const QDate& date)
{ {
Clear(); Clear();
TextLine tl; TextLine tl;
@ -164,7 +163,7 @@ void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, con
tl.m_eAlign = Qt::AlignCenter; tl.m_eAlign = Qt::AlignCenter;
// Company name // Company name
tl.m_qsText = qsCompany; tl.m_qsText = pDoc->GetCompanyName();
if (tl.m_qsText.isEmpty() == false) if (tl.m_qsText.isEmpty() == false)
{ {
tl.m_eFontWeight = QFont::DemiBold; tl.m_eFontWeight = QFont::DemiBold;
@ -173,7 +172,7 @@ void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, con
AddLine(tl); AddLine(tl);
} }
// Pattern name // Pattern name
tl.m_qsText = qsPattern; tl.m_qsText = pDoc->GetPatternName();
if (tl.m_qsText.isEmpty() == false) if (tl.m_qsText.isEmpty() == false)
{ {
tl.m_eFontWeight = QFont::Normal; tl.m_eFontWeight = QFont::Normal;
@ -182,7 +181,7 @@ void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, con
AddLine(tl); AddLine(tl);
} }
// Pattern number // Pattern number
tl.m_qsText = qsNumber; tl.m_qsText = pDoc->GetPatternNumber();
if (tl.m_qsText.isEmpty() == false) if (tl.m_qsText.isEmpty() == false)
{ {
tl.m_eFontWeight = QFont::Normal; tl.m_eFontWeight = QFont::Normal;
@ -191,7 +190,7 @@ void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, con
AddLine(tl); AddLine(tl);
} }
// Customer name // Customer name
tl.m_qsText = qsCustomer; tl.m_qsText = pDoc->GetCustomerName();
if (tl.m_qsText.isEmpty() == false) if (tl.m_qsText.isEmpty() == false)
{ {
tl.m_eFontWeight = QFont::Normal; tl.m_eFontWeight = QFont::Normal;
@ -200,7 +199,7 @@ void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, con
AddLine(tl); AddLine(tl);
} }
// Size // Size
tl.m_qsText = qsSize; tl.m_qsText = pDoc->GetPatternSize();
if (tl.m_qsText.isEmpty() == false) if (tl.m_qsText.isEmpty() == false)
{ {
tl.m_eFontWeight = QFont::Normal; tl.m_eFontWeight = QFont::Normal;
@ -209,6 +208,11 @@ void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, con
AddLine(tl); AddLine(tl);
} }
// Date // Date
QDate date;
if (pDoc->IsDateVisible() == true)
{
date = QDate::currentDate();
}
if (date.isValid() == true) if (date.isValid() == true)
{ {
tl.m_qsText = date.toString("dd MMMM yyyy"); tl.m_qsText = date.toString("dd MMMM yyyy");
@ -217,6 +221,7 @@ void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, con
tl.m_iFontSize = 0; tl.m_iFontSize = 0;
AddLine(tl); AddLine(tl);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -6,6 +6,7 @@
#include <QDate> #include <QDate>
#include "../vpatterndb/vpatternpiecedata.h" #include "../vpatterndb/vpatternpiecedata.h"
#include "../ifc/xml/vabstractpattern.h"
#define MIN_FONT_SIZE 12 #define MIN_FONT_SIZE 12
#define MAX_FONT_SIZE 128 #define MAX_FONT_SIZE 128
@ -43,12 +44,9 @@ public:
* Updates the manager with detail name and detail data * Updates the manager with detail name and detail data
*/ */
void Update(const QString& qsName, const VPatternPieceData& data); void Update(const QString& qsName, const VPatternPieceData& data);
/** @brief Updateconst QString& qsPattern, const QString& qsNumber, const QString& qsSize, /** @brief Update(const VAbstractPattern* pDoc) updates the manager with pattern data
const QString& qsCompany, const QString& qsCustomer, const QDate& date)
Updates the manager with pattern data
*/ */
void Update(const QString& qsPattern, const QString& qsNumber, const QString& qsSize, void Update(const VAbstractPattern* pDoc);
const QString& qsCompany, const QString& qsCustomer, const QDate& date);
protected: protected:
QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm); QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm);

View File

@ -37,14 +37,18 @@
enum class MaterialType : char enum class MaterialType : char
{ {
mtFabric, mtFabric = 0,
mtLining, mtLining = 1,
mtInterfacing, mtInterfacing = 2,
mtInterlining, mtInterlining = 3,
mtUserDefined mtUserDefined = 4
}; };
enum class PlacementType : char { ptNone, ptCutOnFold }; enum class PlacementType : char
{
ptNone = 0,
ptCutOnFold = 1
};
/** /**
* @brief This structure holds a material, cut number and placement 3-tuple * @brief This structure holds a material, cut number and placement 3-tuple

View File

@ -227,10 +227,9 @@ void VTextGraphicsItem::UpdateData(const QString &qsName, const VPatternPieceDat
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VTextGraphicsItem::UpdateData(const QString &qsPattern, const QString &qsNumber, const QString &qsSize, void VTextGraphicsItem::UpdateData(const VAbstractPattern* pDoc)
const QString &qsCompany, const QString &qsCustomer, const QDate &date)
{ {
m_tm.Update(qsPattern, qsNumber, qsSize, qsCompany, qsCustomer, date); m_tm.Update(pDoc);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -63,8 +63,7 @@ public:
void Update(); void Update();
bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const; bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const;
void UpdateData(const QString& qsName, const VPatternPieceData& data); void UpdateData(const QString& qsName, const VPatternPieceData& data);
void UpdateData(const QString& qsPattern, const QString& qsNumber, const QString& qsSize, void UpdateData(const VAbstractPattern* pDoc);
const QString& qsCompany, const QString& qsCustomer, const QDate& date);
protected: protected:
void mousePressEvent(QGraphicsSceneMouseEvent* pME); void mousePressEvent(QGraphicsSceneMouseEvent* pME);

View File

@ -730,14 +730,7 @@ void VToolDetail::UpdatePatternInfo()
fnt.setPixelSize(iFS); fnt.setPixelSize(iFS);
patternInfo->SetFont(fnt); patternInfo->SetFont(fnt);
patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight()); patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight());
patternInfo->UpdateData(doc);
QDate date;
if (doc->IsDateVisible() == true)
{
date = QDate::currentDate();
}
patternInfo->UpdateData(doc->GetPatternName(), doc->GetPatternNumber(), doc->GetPatternSize(),
doc->GetCompanyName(), doc->GetCustomerName(), date);
QPointF pt = geom.GetPos(); QPointF pt = geom.GetPos();
QRectF rectBB; QRectF rectBB;