Centered the label texts and did some refactoring, so that the label content is generated in one place
--HG-- branch : feature
This commit is contained in:
parent
5ba40aad8c
commit
312b8e458b
|
@ -486,10 +486,10 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash<quint32, VDetail> *de
|
|||
QDate date;
|
||||
if (pDoc->IsDateVisible() == true)
|
||||
{
|
||||
date = QDate::currentDate();
|
||||
date = QDate::currentDate();
|
||||
}
|
||||
det.SetPatternInfo(pDoc->GetPatternName(), pDoc->GetPatternNumber(), pDoc->GetPatternSize(),
|
||||
pDoc->GetCompanyName(), pDoc->GetCustomerName(), date, geom, qApp->font());
|
||||
pDoc->GetCompanyName(), pDoc->GetCustomerName(), date, geom, qApp->font());
|
||||
qApp->getCurrentDocument();
|
||||
}
|
||||
det.setWidth(qApp->toPixel(d.getWidth()));
|
||||
|
|
|
@ -140,47 +140,8 @@ void VLayoutDetail::SetDetail(const QString& qsName, const VPatternPieceData& da
|
|||
// generate text
|
||||
m_tmDetail.SetFont(font);
|
||||
m_tmDetail.SetFontSize(data.GetFontSize());
|
||||
m_tmDetail.Clear();
|
||||
TextLine tl;
|
||||
// letter
|
||||
tl.m_qsText = data.GetLetter();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
tl.m_eFontWeight = QFont::Bold;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 6;
|
||||
m_tmDetail.AddLine(tl);
|
||||
}
|
||||
// name
|
||||
if (qsName.isEmpty() == false)
|
||||
{
|
||||
tl.m_qsText = qsName;
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
tl.m_eFontWeight = QFont::DemiBold;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 2;
|
||||
m_tmDetail.AddLine(tl);
|
||||
}
|
||||
|
||||
// MCP
|
||||
QString qsText = "Cut %1 of %2%3";
|
||||
QStringList qslPlace;
|
||||
qslPlace << "" << " on Fold";
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
for (int i = 0; i < data.GetMCPCount(); ++i)
|
||||
{
|
||||
MaterialCutPlacement mcp = data.GetMCP(i);
|
||||
if (mcp.m_iCutNumber > 0)
|
||||
{
|
||||
tl.m_qsText = qsText.arg(mcp.m_iCutNumber).arg(mcp.m_qsMaterialUserDef).arg(qslPlace[int(mcp.m_ePlacement)]);
|
||||
m_tmDetail.AddLine(tl);
|
||||
}
|
||||
}
|
||||
// will generate the lines of text
|
||||
m_tmDetail.Update(qsName, data);
|
||||
// this will generate the lines of text
|
||||
m_tmDetail.SetFontSize(data.GetFontSize());
|
||||
m_tmDetail.FitFontSize(data.GetLabelWidth(), data.GetLabelHeight());
|
||||
}
|
||||
|
@ -207,69 +168,8 @@ void VLayoutDetail::SetPatternInfo(const QString& qsPattern, const QString& qsNu
|
|||
// Generate text
|
||||
m_tmPattern.SetFont(font);
|
||||
m_tmPattern.SetFontSize(geom.GetFontSize());
|
||||
m_tmPattern.Clear();
|
||||
TextLine tl;
|
||||
// Company name
|
||||
tl.m_qsText = qsCompany;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
tl.m_eFontWeight = QFont::DemiBold;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 4;
|
||||
m_tmPattern.AddLine(tl);
|
||||
}
|
||||
// Pattern name
|
||||
tl.m_qsText = qsPattern;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 2;
|
||||
m_tmPattern.AddLine(tl);
|
||||
}
|
||||
// Pattern number
|
||||
tl.m_qsText = qsNumber;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
m_tmPattern.AddLine(tl);
|
||||
}
|
||||
// Customer name
|
||||
tl.m_qsText = qsCustomer;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleItalic;
|
||||
tl.m_iFontSize = 0;
|
||||
m_tmPattern.AddLine(tl);
|
||||
}
|
||||
// Size
|
||||
tl.m_qsText = qsSize;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
m_tmPattern.AddLine(tl);
|
||||
}
|
||||
// Creation date
|
||||
if (date.isValid() == true)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
QStringList qslDate = date.toString(Qt::SystemLocaleLongDate).split(", ");
|
||||
tl.m_qsText = qslDate.last();
|
||||
m_tmPattern.AddLine(tl);
|
||||
}
|
||||
|
||||
m_tmPattern.Update(qsPattern, qsNumber, qsSize, qsCompany, qsCustomer, date);
|
||||
// generate lines of text
|
||||
m_tmPattern.SetFontSize(geom.GetFontSize());
|
||||
m_tmPattern.FitFontSize(geom.GetLabelWidth(), geom.GetLabelHeight());
|
||||
|
|
|
@ -111,6 +111,114 @@ void VTextManager::FitFontSize(qreal fW, qreal fH)
|
|||
SetFontSize(iFontSize);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VTextManager::Update(const QString& qsName, const VPatternPieceData& data)
|
||||
{
|
||||
Clear();
|
||||
TextLine tl;
|
||||
// all text must be centered and normal style!
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
|
||||
// letter
|
||||
tl.m_qsText = data.GetLetter();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eFontWeight = QFont::Bold;
|
||||
tl.m_iFontSize = 6;
|
||||
AddLine(tl);
|
||||
}
|
||||
// name
|
||||
tl.m_qsText = qsName;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eFontWeight = QFont::DemiBold;
|
||||
tl.m_iFontSize = 2;
|
||||
AddLine(tl);
|
||||
}
|
||||
// MCP
|
||||
QString qsText = "Cut %1 on %2%3";
|
||||
QStringList qslPlace;
|
||||
qslPlace << "" << " on Fold";
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_iFontSize = 0;
|
||||
for (int i = 0; i < data.GetMCPCount(); ++i)
|
||||
{
|
||||
MaterialCutPlacement mcp = data.GetMCP(i);
|
||||
if (mcp.m_iCutNumber > 0)
|
||||
{
|
||||
tl.m_qsText = qsText.arg(mcp.m_iCutNumber).arg(mcp.m_qsMaterialUserDef).
|
||||
arg(qslPlace[int(mcp.m_ePlacement)]);
|
||||
AddLine(tl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VTextManager::Update(const QString &qsPattern, const QString &qsNumber, const QString &qsSize,
|
||||
const QString &qsCompany, const QString &qsCustomer, const QDate& date)
|
||||
{
|
||||
Clear();
|
||||
TextLine tl;
|
||||
// all information must be centered
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
|
||||
// Company name
|
||||
tl.m_qsText = qsCompany;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eFontWeight = QFont::DemiBold;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 4;
|
||||
AddLine(tl);
|
||||
}
|
||||
// Pattern name
|
||||
tl.m_qsText = qsPattern;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 2;
|
||||
AddLine(tl);
|
||||
}
|
||||
// Pattern number
|
||||
tl.m_qsText = qsNumber;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
AddLine(tl);
|
||||
}
|
||||
// Customer name
|
||||
tl.m_qsText = qsCustomer;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleItalic;
|
||||
tl.m_iFontSize = 0;
|
||||
AddLine(tl);
|
||||
}
|
||||
// Size
|
||||
tl.m_qsText = qsSize;
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
AddLine(tl);
|
||||
}
|
||||
// Date
|
||||
if (date.isValid() == true)
|
||||
{
|
||||
tl.m_qsText = date.toString("dd MMMM yyyy");
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
AddLine(tl);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList VTextManager::SplitString(const QString &qs, qreal fW, const QFontMetrics &fm)
|
||||
{
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
#include <QString>
|
||||
#include <QFont>
|
||||
#include <QDate>
|
||||
|
||||
#include "../vpatterndb/vpatternpiecedata.h"
|
||||
|
||||
#define MIN_FONT_SIZE 12
|
||||
#define MAX_FONT_SIZE 128
|
||||
|
@ -36,6 +39,16 @@ public:
|
|||
const TextLine& GetLine(int i) const;
|
||||
bool IsBigEnough(qreal fW, qreal fH, int iFontSize);
|
||||
void FitFontSize(qreal fW, qreal fH);
|
||||
/** @brief Update(const QString& qsName, const VPatternPieceData& data)
|
||||
* Updates the manager with detail name and detail data
|
||||
*/
|
||||
void Update(const QString& qsName, const VPatternPieceData& data);
|
||||
/** @brief Updateconst QString& qsPattern, const QString& qsNumber, const QString& qsSize,
|
||||
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,
|
||||
const QString& qsCompany, const QString& qsCustomer, const QDate& date);
|
||||
|
||||
protected:
|
||||
QStringList SplitString(const QString& qs, qreal fW, const QFontMetrics& fm);
|
||||
|
|
|
@ -220,6 +220,19 @@ bool VTextGraphicsItem::IsContained(QRectF rectBB, qreal dRot, qreal &dX, qreal
|
|||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VTextGraphicsItem::UpdateData(const QString &qsName, const VPatternPieceData &data)
|
||||
{
|
||||
m_tm.Update(qsName, data);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VTextGraphicsItem::UpdateData(const QString &qsPattern, const QString &qsNumber, const QString &qsSize,
|
||||
const QString &qsCompany, const QString &qsCustomer, const QDate &date)
|
||||
{
|
||||
m_tm.Update(qsPattern, qsNumber, qsSize, qsCompany, qsCustomer, date);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VTextGraphicsItem::GetFontSize() const
|
||||
{
|
||||
|
|
|
@ -62,6 +62,9 @@ public:
|
|||
void SetSize(qreal fW, qreal fH);
|
||||
void Update();
|
||||
bool IsContained(QRectF rectBB, qreal dRot, qreal& dX, qreal& dY) const;
|
||||
void UpdateData(const QString& qsName, const VPatternPieceData& data);
|
||||
void UpdateData(const QString& qsPattern, const QString& qsNumber, const QString& qsSize,
|
||||
const QString& qsCompany, const QString& qsCustomer, const QDate& date);
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent* pME);
|
||||
|
|
|
@ -685,45 +685,7 @@ void VToolDetail::UpdateLabel()
|
|||
fnt.setPixelSize(data.GetFontSize());
|
||||
dataLabel->SetFont(fnt);
|
||||
dataLabel->SetSize(data.GetLabelWidth(), data.GetLabelHeight());
|
||||
dataLabel->Clear();
|
||||
TextLine tl;
|
||||
// letter
|
||||
tl.m_qsText = data.GetLetter();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
tl.m_eFontWeight = QFont::Bold;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 6;
|
||||
dataLabel->AddLine(tl);
|
||||
}
|
||||
|
||||
// name
|
||||
tl.m_qsText = detail.getName();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
tl.m_eFontWeight = QFont::DemiBold;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 2;
|
||||
dataLabel->AddLine(tl);
|
||||
}
|
||||
|
||||
// MCP
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
for (int i = 0; i < data.GetMCPCount(); ++i)
|
||||
{
|
||||
MaterialCutPlacement mcp = data.GetMCP(i);
|
||||
if (mcp.m_iCutNumber > 0)
|
||||
{
|
||||
tl.m_qsText = qsText.arg(mcp.m_iCutNumber).arg(mcp.m_qsMaterialUserDef).arg(qslPlace[int(mcp.m_ePlacement)]);
|
||||
dataLabel->AddLine(tl);
|
||||
}
|
||||
}
|
||||
|
||||
dataLabel->UpdateData(detail.getName(), data);
|
||||
QPointF pt = data.GetPos();
|
||||
QRectF rectBB;
|
||||
rectBB.setTopLeft(pt);
|
||||
|
@ -768,75 +730,14 @@ void VToolDetail::UpdatePatternInfo()
|
|||
fnt.setPixelSize(iFS);
|
||||
patternInfo->SetFont(fnt);
|
||||
patternInfo->SetSize(geom.GetLabelWidth(), geom.GetLabelHeight());
|
||||
patternInfo->Clear();
|
||||
TextLine tl;
|
||||
|
||||
// Company name
|
||||
tl.m_qsText = doc->GetCompanyName();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
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();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 2;
|
||||
patternInfo->AddLine(tl);
|
||||
}
|
||||
|
||||
// Pattern number
|
||||
tl.m_qsText = doc->GetPatternNumber();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
patternInfo->AddLine(tl);
|
||||
}
|
||||
|
||||
// Customer name
|
||||
tl.m_qsText = doc->GetCustomerName();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleItalic;
|
||||
tl.m_iFontSize = 0;
|
||||
patternInfo->AddLine(tl);
|
||||
}
|
||||
|
||||
// Size
|
||||
tl.m_qsText = doc->GetPatternSize();
|
||||
if (tl.m_qsText.isEmpty() == false)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
patternInfo->AddLine(tl);
|
||||
}
|
||||
|
||||
// Creation date
|
||||
QDate date;
|
||||
if (doc->IsDateVisible() == true)
|
||||
{
|
||||
tl.m_eAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
||||
tl.m_eFontWeight = QFont::Normal;
|
||||
tl.m_eStyle = QFont::StyleNormal;
|
||||
tl.m_iFontSize = 0;
|
||||
QStringList qslDate = QDate::currentDate().toString(Qt::SystemLocaleLongDate).split(", ");
|
||||
tl.m_qsText = qslDate.last();
|
||||
patternInfo->AddLine(tl);
|
||||
date = QDate::currentDate();
|
||||
}
|
||||
patternInfo->UpdateData(doc->GetPatternName(), doc->GetPatternNumber(), doc->GetPatternSize(),
|
||||
doc->GetCompanyName(), doc->GetCustomerName(), date);
|
||||
|
||||
QPointF pt = geom.GetPos();
|
||||
QRectF rectBB;
|
||||
|
|
Loading…
Reference in New Issue
Block a user