New option Export text as paths.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-07-01 20:32:54 +03:00
parent 53502e3dd9
commit f94967d02e
18 changed files with 152 additions and 29 deletions

View File

@ -72,6 +72,8 @@ The path to output destination folder. By default the directory at which the app
.RE .RE
.IP "--bdxf" .IP "--bdxf"
.RB "Export dxf in binary form." .RB "Export dxf in binary form."
.IP "--text2paths"
.RB "Export text as paths."
.IP "-x, --gsize <The size value>" .IP "-x, --gsize <The size value>"
.RB "Set size value a pattern file, that was opened with standard measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm." .RB "Set size value a pattern file, that was opened with standard measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm."
.IP "-e, --gheight <The height value>" .IP "-e, --gheight <The height value>"

View File

@ -72,6 +72,8 @@ The path to output destination folder. By default the directory at which the app
.RE .RE
.IP "--bdxf" .IP "--bdxf"
.RB "Export dxf in binary form." .RB "Export dxf in binary form."
.IP "--text2paths"
.RB "Export text as paths."
.IP "-x, --gsize <The size value>" .IP "-x, --gsize <The size value>"
.RB "Set size value a pattern file, that was opened with standard measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm." .RB "Set size value a pattern file, that was opened with standard measurements " "(export mode)" ". Valid values: 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56cm."
.IP "-e, --gheight <The height value>" .IP "-e, --gheight <The height value>"

View File

@ -104,6 +104,10 @@ void VCommandLine::InitOptions(VCommandLineOptions &options, QMap<QString, int>
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_BINARYDXF, options.append(new QCommandLineOption(QStringList() << LONG_OPTION_BINARYDXF,
translate("VCommandLine", "Export dxf in binary form."))); translate("VCommandLine", "Export dxf in binary form.")));
optionsIndex.insert(LONG_OPTION_TEXT2PATHS, index++);
options.append(new QCommandLineOption(QStringList() << LONG_OPTION_TEXT2PATHS,
translate("VCommandLine", "Export text as paths.")));
optionsIndex.insert(LONG_OPTION_GRADATIONSIZE, index++); optionsIndex.insert(LONG_OPTION_GRADATIONSIZE, index++);
options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE, options.append(new QCommandLineOption(QStringList() << SINGLE_OPTION_GRADATIONSIZE << LONG_OPTION_GRADATIONSIZE,
translate("VCommandLine", "Set size value a pattern file, that was opened " translate("VCommandLine", "Set size value a pattern file, that was opened "
@ -624,10 +628,13 @@ int VCommandLine::OptExportType() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::IsBinaryDXF() const int VCommandLine::IsBinaryDXF() const
{ {
if (parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_BINARYDXF)))) return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_BINARYDXF)));
{ }
return true;
} //---------------------------------------------------------------------------------------------------------------------
int VCommandLine::IsTextAsPaths() const
{
return parser.isSet(*optionsUsed.value(optionsIndex.value(LONG_OPTION_TEXT2PATHS)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -76,6 +76,7 @@ public:
int OptExportType() const; int OptExportType() const;
int IsBinaryDXF() const; int IsBinaryDXF() const;
int IsTextAsPaths() const;
//generator creation is moved here ... because most options are for it only, so no need to create extra getters... //generator creation is moved here ... because most options are for it only, so no need to create extra getters...
//@brief creates VLayoutGenerator //@brief creates VLayoutGenerator

View File

@ -337,6 +337,18 @@ void DialogLayoutSettings::SetIgnoreAllFields(bool value)
ui->checkBoxIgnoreFileds->setChecked(value); ui->checkBoxIgnoreFileds->setChecked(value);
} }
//---------------------------------------------------------------------------------------------------------------------
bool DialogLayoutSettings::IsTextAsPaths() const
{
return ui->checkBoxTextAsPaths->isChecked();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLayoutSettings::SetTextAsPaths(bool value)
{
ui->checkBoxTextAsPaths->setChecked(value);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogLayoutSettings::SelectedPrinter() const QString DialogLayoutSettings::SelectedPrinter() const
{ {
@ -568,6 +580,7 @@ void DialogLayoutSettings::DialogAccepted()
generator->SetUnitePages(IsUnitePages()); generator->SetUnitePages(IsUnitePages());
generator->SetStripOptimization(IsStripOptimization()); generator->SetStripOptimization(IsStripOptimization());
generator->SetMultiplier(GetMultiplier()); generator->SetMultiplier(GetMultiplier());
generator->SetTestAsPaths(IsTextAsPaths());
if (IsIgnoreAllFields()) if (IsIgnoreAllFields())
{ {
@ -659,6 +672,8 @@ void DialogLayoutSettings::RestoreDefaults()
CorrectMaxFileds(); CorrectMaxFileds();
IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked()); IgnoreAllFields(ui->checkBoxIgnoreFileds->isChecked());
ui->checkBoxTextAsPaths->setChecked(false);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1070,6 +1085,7 @@ void DialogLayoutSettings::ReadSettings()
SetIgnoreAllFields(settings->GetIgnoreAllFields()); SetIgnoreAllFields(settings->GetIgnoreAllFields());
SetStripOptimization(settings->GetStripOptimization()); SetStripOptimization(settings->GetStripOptimization());
SetMultiplier(settings->GetMultiplier()); SetMultiplier(settings->GetMultiplier());
SetTextAsPaths(settings->GetTextAsPaths());
FindTemplate(); FindTemplate();
@ -1095,6 +1111,7 @@ void DialogLayoutSettings::WriteSettings() const
settings->SetIgnoreAllFields(IsIgnoreAllFields()); settings->SetIgnoreAllFields(IsIgnoreAllFields());
settings->SetStripOptimization(IsStripOptimization()); settings->SetStripOptimization(IsStripOptimization());
settings->SetMultiplier(GetMultiplier()); settings->SetMultiplier(GetMultiplier());
settings->SetTextAsPaths(IsTextAsPaths());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -110,6 +110,9 @@ public:
bool IsIgnoreAllFields() const; bool IsIgnoreAllFields() const;
void SetIgnoreAllFields(bool value); void SetIgnoreAllFields(bool value);
bool IsTextAsPaths() const;
void SetTextAsPaths(bool value);
QString SelectedPrinter() const; QString SelectedPrinter() const;
//support functions for the command line parser which uses invisible dialog to properly build layout generator //support functions for the command line parser which uses invisible dialog to properly build layout generator

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>600</width> <width>600</width>
<height>531</height> <height>533</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -17,7 +17,7 @@
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc"> <iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset> <normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout_4">
<item> <item>
@ -308,6 +308,29 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QGroupBox" name="groupBoxText">
<property name="title">
<string>Text</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="checkBoxTextAsPaths">
<property name="toolTip">
<string>Text will be converted to paths</string>
</property>
<property name="text">
<string>Export text as paths</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -732,7 +755,7 @@
</connection> </connection>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="buttonGroupPrinciple"/>
<buttongroup name="buttonGroup"/> <buttongroup name="buttonGroup"/>
<buttongroup name="buttonGroupPrinciple"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -4678,8 +4678,6 @@ void MainWindow::ZoomFirstShow()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::DoExport(const VCommandLinePtr &expParams) void MainWindow::DoExport(const VCommandLinePtr &expParams)
{ {
auto settings = expParams->DefaultGenerator();
const QHash<quint32, VPiece> *details = pattern->DataPieces(); const QHash<quint32, VPiece> *details = pattern->DataPieces();
if(not qApp->getOpeningPattern()) if(not qApp->getOpeningPattern())
{ {
@ -4691,6 +4689,10 @@ void MainWindow::DoExport(const VCommandLinePtr &expParams)
} }
} }
PrepareDetailsForLayout(details); PrepareDetailsForLayout(details);
auto settings = expParams->DefaultGenerator();
settings->SetTestAsPaths(expParams->IsTextAsPaths());
if (LayoutSettings(*settings.get())) if (LayoutSettings(*settings.get()))
{ {
try try

View File

@ -61,7 +61,8 @@ VLayoutGenerator::VLayoutGenerator(QObject *parent)
unitePages(false), unitePages(false),
stripOptimizationEnabled(false), stripOptimizationEnabled(false),
multiplier(1), multiplier(1),
stripOptimization(false) stripOptimization(false),
textAsPaths(false)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -209,7 +210,7 @@ QList<QGraphicsItem *> VLayoutGenerator::GetPapersItems() const
QList<QGraphicsItem *> list; QList<QGraphicsItem *> list;
for (int i=0; i < papers.count(); ++i) for (int i=0; i < papers.count(); ++i)
{ {
list.append(papers.at(i).GetPaperItem(autoCrop)); list.append(papers.at(i).GetPaperItem(autoCrop, IsTestAsPaths()));
} }
return list; return list;
} }
@ -220,7 +221,7 @@ QList<QList<QGraphicsItem *> > VLayoutGenerator::GetAllDetails() const
QList<QList<QGraphicsItem *> > list; QList<QList<QGraphicsItem *> > list;
for (int i=0; i < papers.count(); ++i) for (int i=0; i < papers.count(); ++i)
{ {
list.append(papers.at(i).GetItemDetails()); list.append(papers.at(i).GetItemDetails(IsTestAsPaths()));
} }
return list; return list;
} }
@ -245,6 +246,18 @@ void VLayoutGenerator::SetStripOptimization(bool value)
stripOptimization = value; stripOptimization = value;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VLayoutGenerator::IsTestAsPaths() const
{
return textAsPaths;
}
//---------------------------------------------------------------------------------------------------------------------
void VLayoutGenerator::SetTestAsPaths(bool value)
{
textAsPaths = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint8 VLayoutGenerator::GetMultiplier() const quint8 VLayoutGenerator::GetMultiplier() const
{ {

View File

@ -106,6 +106,9 @@ public:
bool IsStripOptimization() const; bool IsStripOptimization() const;
void SetStripOptimization(bool value); void SetStripOptimization(bool value);
bool IsTestAsPaths() const;
void SetTestAsPaths(bool value);
signals: signals:
void Start(); void Start();
void Arranged(int count); void Arranged(int count);
@ -134,6 +137,7 @@ private:
bool stripOptimizationEnabled; bool stripOptimizationEnabled;
quint8 multiplier; quint8 multiplier;
bool stripOptimization; bool stripOptimization;
bool textAsPaths;
int PageHeight() const; int PageHeight() const;
int PageWidth() const; int PageWidth() const;

View File

@ -315,13 +315,13 @@ bool VLayoutPaper::SaveResult(const VBestSquare &bestResult, const VLayoutPiece
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop) const QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop, bool textAsPaths) const
{ {
QGraphicsRectItem *paper; QGraphicsRectItem *paper;
if (autoCrop) if (autoCrop)
{ {
QScopedPointer<QGraphicsScene> scene(new QGraphicsScene()); QScopedPointer<QGraphicsScene> scene(new QGraphicsScene());
QList<QGraphicsItem *> list = GetItemDetails(); QList<QGraphicsItem *> list = GetItemDetails(textAsPaths);
for (int i=0; i < list.size(); ++i) for (int i=0; i < list.size(); ++i)
{ {
scene->addItem(list.at(i)); scene->addItem(list.at(i));
@ -346,12 +346,12 @@ QGraphicsRectItem *VLayoutPaper::GetPaperItem(bool autoCrop) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QList<QGraphicsItem *> VLayoutPaper::GetItemDetails() const QList<QGraphicsItem *> VLayoutPaper::GetItemDetails(bool textAsPaths) const
{ {
QList<QGraphicsItem *> list; QList<QGraphicsItem *> list;
for (int i=0; i < d->details.count(); ++i) for (int i=0; i < d->details.count(); ++i)
{ {
list.append(d->details.at(i).GetItem()); list.append(d->details.at(i).GetItem(textAsPaths));
} }
return list; return list;
} }

View File

@ -88,8 +88,8 @@ public:
bool ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &stop); bool ArrangeDetail(const VLayoutPiece &detail, std::atomic_bool &stop);
int Count() const; int Count() const;
QGraphicsRectItem *GetPaperItem(bool autoCrop) const Q_REQUIRED_RESULT; QGraphicsRectItem *GetPaperItem(bool autoCrop, bool textAsPaths) const Q_REQUIRED_RESULT;
QList<QGraphicsItem *> GetItemDetails() const Q_REQUIRED_RESULT; QList<QGraphicsItem *> GetItemDetails(bool textAsPaths) const Q_REQUIRED_RESULT;
QVector<VLayoutPiece> GetDetails() const; QVector<VLayoutPiece> GetDetails() const;
void SetDetails(const QList<VLayoutPiece>& details); void SetDetails(const QList<VLayoutPiece>& details);

View File

@ -923,7 +923,7 @@ QPainterPath VLayoutPiece::LayoutAllowancePath() const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGraphicsItem *VLayoutPiece::GetItem() const QGraphicsItem *VLayoutPiece::GetItem(bool textAsPaths) const
{ {
QGraphicsPathItem *item = GetMainItem(); QGraphicsPathItem *item = GetMainItem();
@ -932,8 +932,8 @@ QGraphicsItem *VLayoutPiece::GetItem() const
CreateInternalPathItem(i, item); CreateInternalPathItem(i, item);
} }
CreateLabelStrings(item, d->detailLabel, d->m_tmDetail); CreateLabelStrings(item, d->detailLabel, d->m_tmDetail, textAsPaths);
CreateLabelStrings(item, d->patternInfo, d->m_tmPattern); CreateLabelStrings(item, d->patternInfo, d->m_tmPattern, textAsPaths);
CreateGrainlineItem(item); CreateGrainlineItem(item);
return item; return item;
@ -941,7 +941,7 @@ QGraphicsItem *VLayoutPiece::GetItem() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPointF> &labelShape, void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPointF> &labelShape,
const VTextManager &tm) const const VTextManager &tm, bool textAsPaths) const
{ {
SCASSERT(parent != nullptr) SCASSERT(parent != nullptr)
@ -963,6 +963,11 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
QFontMetrics fm(fnt); QFontMetrics fm(fnt);
if (textAsPaths)
{
dY += fm.height();
}
if (dY > dH) if (dY > dH)
{ {
break; break;
@ -1004,12 +1009,27 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
labelMatrix *= d->matrix; labelMatrix *= d->matrix;
QGraphicsSimpleTextItem* item = new QGraphicsSimpleTextItem(parent); if (textAsPaths)
item->setFont(fnt); {
item->setText(qsText); QPainterPath path;
item->setTransform(labelMatrix); path.addText(0, - static_cast<qreal>(fm.ascent())/6., fnt, qsText);
dY += (fm.height() + tm.GetSpacing()); QGraphicsPathItem* item = new QGraphicsPathItem(parent);
item->setPath(path);
item->setBrush(QBrush(Qt::black));
item->setTransform(labelMatrix);
dY += tm.GetSpacing();
}
else
{
QGraphicsSimpleTextItem* item = new QGraphicsSimpleTextItem(parent);
item->setFont(fnt);
item->setText(qsText);
item->setTransform(labelMatrix);
dY += (fm.height() + tm.GetSpacing());
}
} }
} }
} }

View File

@ -126,7 +126,7 @@ public:
QPainterPath ContourPath() const; QPainterPath ContourPath() const;
QPainterPath LayoutAllowancePath() const; QPainterPath LayoutAllowancePath() const;
QGraphicsItem *GetItem() const Q_REQUIRED_RESULT; QGraphicsItem *GetItem(bool textAsPaths) const Q_REQUIRED_RESULT;
private: private:
QSharedDataPointer<VLayoutPieceData> d; QSharedDataPointer<VLayoutPieceData> d;
@ -136,7 +136,8 @@ private:
QGraphicsPathItem *GetMainItem() const Q_REQUIRED_RESULT; QGraphicsPathItem *GetMainItem() const Q_REQUIRED_RESULT;
void CreateInternalPathItem(int i, QGraphicsItem *parent) const; void CreateInternalPathItem(int i, QGraphicsItem *parent) const;
void CreateLabelStrings(QGraphicsItem *parent, const QVector<QPointF> &labelShape, const VTextManager &tm) const; void CreateLabelStrings(QGraphicsItem *parent, const QVector<QPointF> &labelShape, const VTextManager &tm,
bool textAsPaths) const;
void CreateGrainlineItem(QGraphicsItem *parent) const; void CreateGrainlineItem(QGraphicsItem *parent) const;
template <class T> template <class T>

View File

@ -50,6 +50,7 @@ const QString LONG_OPTION_EXP2FORMAT = QStringLiteral("format");
const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f"); const QString SINGLE_OPTION_EXP2FORMAT = QStringLiteral("f");
const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf"); const QString LONG_OPTION_BINARYDXF = QStringLiteral("bdxf");
const QString LONG_OPTION_TEXT2PATHS = QStringLiteral("text2paths");
const QString LONG_OPTION_ROTATE = QStringLiteral("rotate"); const QString LONG_OPTION_ROTATE = QStringLiteral("rotate");
const QString SINGLE_OPTION_ROTATE = QStringLiteral("r"); const QString SINGLE_OPTION_ROTATE = QStringLiteral("r");

View File

@ -47,6 +47,7 @@ extern const QString LONG_OPTION_EXP2FORMAT;
extern const QString SINGLE_OPTION_EXP2FORMAT; extern const QString SINGLE_OPTION_EXP2FORMAT;
extern const QString LONG_OPTION_BINARYDXF; extern const QString LONG_OPTION_BINARYDXF;
extern const QString LONG_OPTION_TEXT2PATHS;
extern const QString LONG_OPTION_ROTATE; extern const QString LONG_OPTION_ROTATE;
extern const QString SINGLE_OPTION_ROTATE; extern const QString SINGLE_OPTION_ROTATE;

View File

@ -44,6 +44,8 @@
Q_DECLARE_METATYPE(QMarginsF) Q_DECLARE_METATYPE(QMarginsF)
namespace
{
const QString settingConfigurationLabelLanguage = QStringLiteral("configuration/label_language"); const QString settingConfigurationLabelLanguage = QStringLiteral("configuration/label_language");
const QString settingPathsPattern = QStringLiteral("paths/pattern"); const QString settingPathsPattern = QStringLiteral("paths/pattern");
@ -76,6 +78,8 @@ const QString settingFields = QStringLiteral("layout/fields");
const QString settingIgnoreFields = QStringLiteral("layout/ignoreFields"); const QString settingIgnoreFields = QStringLiteral("layout/ignoreFields");
const QString settingStripOptimization = QStringLiteral("layout/stripOptimization"); const QString settingStripOptimization = QStringLiteral("layout/stripOptimization");
const QString settingMultiplier = QStringLiteral("layout/multiplier"); const QString settingMultiplier = QStringLiteral("layout/multiplier");
const QString settingTextAsPaths = QStringLiteral("layout/textAsPaths");
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application, VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application,
@ -584,3 +588,21 @@ void VSettings::SetMultiplier(quint8 value)
setValue(settingMultiplier, value); setValue(settingMultiplier, value);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetTextAsPaths() const
{
return value(settingTextAsPaths, GetDefTextAsPaths()).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetDefTextAsPaths()
{
return false;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetTextAsPaths(bool value)
{
setValue(settingTextAsPaths, value);
}

View File

@ -151,6 +151,10 @@ public:
static quint8 GetDefMultiplier(); static quint8 GetDefMultiplier();
void SetMultiplier(quint8 value); void SetMultiplier(quint8 value);
bool GetTextAsPaths() const;
static bool GetDefTextAsPaths();
void SetTextAsPaths(bool value);
private: private:
Q_DISABLE_COPY(VSettings) Q_DISABLE_COPY(VSettings)
}; };