Export layout.
This commit is contained in:
parent
9b24f6ac08
commit
d5a02ac48c
713
src/app/puzzle/dialogs/dialogsavemanuallayout.cpp
Normal file
713
src/app/puzzle/dialogs/dialogsavemanuallayout.cpp
Normal file
|
@ -0,0 +1,713 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file dialogsavemanuallayout.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 3 9, 2021
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2021 Valentina project
|
||||||
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
#include "dialogsavemanuallayout.h"
|
||||||
|
#include "ui_dialogsavemanuallayout.h"
|
||||||
|
#include "../vpapplication.h"
|
||||||
|
#include "../ifc/exception/vexception.h"
|
||||||
|
#include "../vlayout/vlayoutexporter.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QShowEvent>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\/]+$")))
|
||||||
|
#else
|
||||||
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, baseFilenameRegExp, (QLatin1String("^[^\\:?\"*|\\/<>]+$")))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool DialogSaveManualLayout::havePdf = false;
|
||||||
|
bool DialogSaveManualLayout::tested = false;
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DialogSaveManualLayout::DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName, QWidget *parent)
|
||||||
|
: VAbstractLayoutDialog(parent),
|
||||||
|
ui(new Ui::DialogSaveManualLayout),
|
||||||
|
m_count(count),
|
||||||
|
m_consoleExport(consoleExport)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
setWindowFlags(Qt::Window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VPApplication::VApp()->PuzzleSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||||
|
|
||||||
|
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
SCASSERT(bOk != nullptr)
|
||||||
|
bOk->setEnabled(false);
|
||||||
|
|
||||||
|
ui->lineEditFileName->setValidator( new QRegularExpressionValidator(QRegularExpression(*baseFilenameRegExp), this));
|
||||||
|
|
||||||
|
const QString mask = m_count > 1 ? fileName + '_' : fileName;
|
||||||
|
if (not m_consoleExport)
|
||||||
|
{
|
||||||
|
ui->lineEditFileName->setText(mask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (QRegularExpression(*baseFilenameRegExp).match(mask).hasMatch())
|
||||||
|
{
|
||||||
|
ui->lineEditFileName->setText(mask);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw VException(tr("The base filename does not match a regular expression."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto &v : InitFormats())
|
||||||
|
{
|
||||||
|
ui->comboBoxFormat->addItem(v.first, QVariant(static_cast<int>(v.second)));
|
||||||
|
}
|
||||||
|
#ifdef V_NO_ASSERT // Temporarily unavailable
|
||||||
|
RemoveFormatFromList(LayoutExportFormats::OBJ);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// RemoveFormatFromList(LayoutExportFormats::NC); // No support for now
|
||||||
|
|
||||||
|
connect(bOk, &QPushButton::clicked, this, &DialogSaveManualLayout::Save);
|
||||||
|
connect(ui->lineEditFileName, &QLineEdit::textChanged, this, &DialogSaveManualLayout::ShowExample);
|
||||||
|
connect(ui->comboBoxFormat, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
this, &DialogSaveManualLayout::ShowExample);
|
||||||
|
|
||||||
|
connect(ui->pushButtonBrowse, &QPushButton::clicked, this, [this]()
|
||||||
|
{
|
||||||
|
const QString dirPath = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts();
|
||||||
|
bool usedNotExistedDir = false;
|
||||||
|
QDir directory(dirPath);
|
||||||
|
if (not directory.exists())
|
||||||
|
{
|
||||||
|
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString dir = QFileDialog::getExistingDirectory(
|
||||||
|
this, tr("Select folder"), dirPath,
|
||||||
|
VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly |
|
||||||
|
QFileDialog::DontResolveSymlinks));
|
||||||
|
if (not dir.isEmpty())
|
||||||
|
{// If paths equal the signal will not be called, we will do this manually
|
||||||
|
dir == ui->lineEditPath->text() ? PathChanged(dir) : ui->lineEditPath->setText(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (usedNotExistedDir)
|
||||||
|
{
|
||||||
|
QDir directory(dirPath);
|
||||||
|
directory.rmpath(QChar('.'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
connect(ui->lineEditPath, &QLineEdit::textChanged, this, &DialogSaveManualLayout::PathChanged);
|
||||||
|
|
||||||
|
ui->lineEditPath->setText(VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts());
|
||||||
|
|
||||||
|
connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, &DialogSaveManualLayout::ToggleScaleConnection);
|
||||||
|
|
||||||
|
connect(ui->doubleSpinBoxHorizontalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
|
this, &DialogSaveManualLayout::HorizontalScaleChanged);
|
||||||
|
connect(ui->doubleSpinBoxVerticalScale, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||||
|
this, &DialogSaveManualLayout::VerticalScaleChanged);
|
||||||
|
|
||||||
|
ReadSettings();
|
||||||
|
|
||||||
|
ShowExample();//Show example for current format.
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
DialogSaveManualLayout::~DialogSaveManualLayout()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogSaveManualLayout::Path() const
|
||||||
|
{
|
||||||
|
return ui->lineEditPath->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogSaveManualLayout::FileName() const
|
||||||
|
{
|
||||||
|
return ui->lineEditFileName->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
LayoutExportFormats DialogSaveManualLayout::Format() const
|
||||||
|
{
|
||||||
|
return static_cast<LayoutExportFormats>(ui->comboBoxFormat->currentData().toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::SelectFormat(LayoutExportFormats format)
|
||||||
|
{
|
||||||
|
if (static_cast<int>(format) < 0 || format >= LayoutExportFormats::COUNT)
|
||||||
|
{
|
||||||
|
throw VException(tr("Tried to use out of range format number."));
|
||||||
|
}
|
||||||
|
|
||||||
|
const int i = ui->comboBoxFormat->findData(static_cast<int>(format));
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
throw VException(tr("Selected not present format."));
|
||||||
|
}
|
||||||
|
ui->comboBoxFormat->setCurrentIndex(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::SetBinaryDXFFormat(bool binary)
|
||||||
|
{
|
||||||
|
switch(Format())
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
ui->checkBoxBinaryDXF->setChecked(binary);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
case LayoutExportFormats::PDFTiled:
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
case LayoutExportFormats::NC:
|
||||||
|
case LayoutExportFormats::RLD:
|
||||||
|
case LayoutExportFormats::TIF:
|
||||||
|
default:
|
||||||
|
ui->checkBoxBinaryDXF->setChecked(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogSaveManualLayout::IsBinaryDXFFormat() const
|
||||||
|
{
|
||||||
|
switch(Format())
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
return ui->checkBoxBinaryDXF->isChecked();
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
case LayoutExportFormats::PDFTiled:
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
case LayoutExportFormats::NC:
|
||||||
|
case LayoutExportFormats::RLD:
|
||||||
|
case LayoutExportFormats::TIF:
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::SetDestinationPath(const QString &cmdDestinationPath)
|
||||||
|
{
|
||||||
|
QString path;
|
||||||
|
if (cmdDestinationPath.isEmpty())
|
||||||
|
{
|
||||||
|
path = QDir::currentPath();
|
||||||
|
}
|
||||||
|
else if (QDir(cmdDestinationPath).isAbsolute())
|
||||||
|
{
|
||||||
|
path = cmdDestinationPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QDir dir;
|
||||||
|
if (not dir.cd(cmdDestinationPath))
|
||||||
|
{
|
||||||
|
throw VException(tr("The destination directory doesn't exists or is not readable."));
|
||||||
|
}
|
||||||
|
path = dir.absolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Output full path: " << path << "\n";
|
||||||
|
ui->lineEditPath->setText(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogSaveManualLayout::IsTextAsPaths() const
|
||||||
|
{
|
||||||
|
return ui->checkBoxTextAsPaths->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::SetTextAsPaths(bool textAsPaths)
|
||||||
|
{
|
||||||
|
ui->checkBoxTextAsPaths->setChecked(textAsPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::SetXScale(qreal scale)
|
||||||
|
{
|
||||||
|
ui->doubleSpinBoxHorizontalScale->setValue(scale * 100.);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal DialogSaveManualLayout::GetXScale() const
|
||||||
|
{
|
||||||
|
return ui->doubleSpinBoxHorizontalScale->value() / 100.;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::SetYScale(qreal scale)
|
||||||
|
{
|
||||||
|
ui->doubleSpinBoxVerticalScale->setValue(scale * 100.);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qreal DialogSaveManualLayout::GetYScale() const
|
||||||
|
{
|
||||||
|
return ui->doubleSpinBoxVerticalScale->value() / 100.;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::SetExportUnified(bool value)
|
||||||
|
{
|
||||||
|
switch(Format())
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
case LayoutExportFormats::PDFTiled:
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
ui->checkBoxExportUnified->setChecked(value);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
case LayoutExportFormats::NC:
|
||||||
|
case LayoutExportFormats::RLD:
|
||||||
|
case LayoutExportFormats::TIF:
|
||||||
|
default:
|
||||||
|
ui->checkBoxExportUnified->setChecked(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogSaveManualLayout::IsExportUnified() const
|
||||||
|
{
|
||||||
|
switch(Format())
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
case LayoutExportFormats::PDFTiled:
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
return ui->checkBoxExportUnified->isChecked();
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
case LayoutExportFormats::NC:
|
||||||
|
case LayoutExportFormats::RLD:
|
||||||
|
case LayoutExportFormats::TIF:
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
QDialog::showEvent( event );
|
||||||
|
if ( event->spontaneous() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_isInitialized)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// do your init stuff here
|
||||||
|
|
||||||
|
setFixedHeight(size().height());
|
||||||
|
|
||||||
|
m_isInitialized = true;//first show windows are held
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::Save()
|
||||||
|
{
|
||||||
|
WriteSettings();
|
||||||
|
|
||||||
|
for (int i=0; i < m_count; ++i)
|
||||||
|
{
|
||||||
|
QString name;
|
||||||
|
if (m_count > 1 && not IsExportUnified())
|
||||||
|
{
|
||||||
|
name = Path() + '/' + FileName() + QString::number(i+1) + VLayoutExporter::ExportFormatSuffix(Format());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = Path() + '/' + FileName() + VLayoutExporter::ExportFormatSuffix(Format());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QFile::exists(name))
|
||||||
|
{
|
||||||
|
QMessageBox::StandardButton res = QMessageBox::question(this, tr("Name conflict"),
|
||||||
|
tr("Folder already contain file with name %1. Rewrite all conflict file names?")
|
||||||
|
.arg(name), QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes);
|
||||||
|
if (res == QMessageBox::No)
|
||||||
|
{
|
||||||
|
reject();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::PathChanged(const QString &text)
|
||||||
|
{
|
||||||
|
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
SCASSERT(bOk != nullptr)
|
||||||
|
|
||||||
|
QPalette palette = ui->lineEditPath->palette();
|
||||||
|
|
||||||
|
QDir dir(text);
|
||||||
|
dir.setPath(text);
|
||||||
|
if (not text.isEmpty() && dir.exists(text))
|
||||||
|
{
|
||||||
|
bOk->setEnabled(true);
|
||||||
|
palette.setColor(ui->lineEditPath->foregroundRole(), Qt::black);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bOk->setEnabled(false);
|
||||||
|
palette.setColor(ui->lineEditPath->foregroundRole(), Qt::red);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui->lineEditPath->setPalette(palette);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::ShowExample()
|
||||||
|
{
|
||||||
|
const LayoutExportFormats currentFormat = Format();
|
||||||
|
|
||||||
|
QString example;
|
||||||
|
if (m_count > 1)
|
||||||
|
{
|
||||||
|
example = tr("Example:") + FileName() + QLatin1Char('1') + VLayoutExporter::ExportFormatSuffix(currentFormat);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
example = tr("Example:") + FileName() + VLayoutExporter::ExportFormatSuffix(currentFormat);
|
||||||
|
}
|
||||||
|
ui->labelExample->setText(example);
|
||||||
|
|
||||||
|
ui->checkBoxBinaryDXF->setEnabled(false);
|
||||||
|
ui->checkBoxTextAsPaths->setEnabled(true);
|
||||||
|
ui->checkBoxExportUnified->setEnabled(false);
|
||||||
|
|
||||||
|
switch(currentFormat)
|
||||||
|
{
|
||||||
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_AAMA:
|
||||||
|
case LayoutExportFormats::DXF_AC1006_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1009_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1012_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1014_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1015_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1018_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1021_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1024_ASTM:
|
||||||
|
case LayoutExportFormats::DXF_AC1027_ASTM:
|
||||||
|
ui->checkBoxBinaryDXF->setEnabled(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::RLD:
|
||||||
|
ui->checkBoxTextAsPaths->setEnabled(false);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::PDFTiled:
|
||||||
|
case LayoutExportFormats::PDF:
|
||||||
|
case LayoutExportFormats::PS:
|
||||||
|
case LayoutExportFormats::EPS:
|
||||||
|
ui->checkBoxExportUnified->setEnabled(true);
|
||||||
|
break;
|
||||||
|
case LayoutExportFormats::SVG:
|
||||||
|
case LayoutExportFormats::PNG:
|
||||||
|
case LayoutExportFormats::OBJ:
|
||||||
|
case LayoutExportFormats::NC:
|
||||||
|
case LayoutExportFormats::TIF:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::ToggleScaleConnection()
|
||||||
|
{
|
||||||
|
m_scaleConnected = not m_scaleConnected;
|
||||||
|
|
||||||
|
QIcon icon;
|
||||||
|
icon.addFile(m_scaleConnected ? QStringLiteral(":/icon/32x32/link.png")
|
||||||
|
: QStringLiteral(":/icon/32x32/broken_link.png"));
|
||||||
|
ui->toolButtonScaleConnected->setIcon(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::HorizontalScaleChanged(double d)
|
||||||
|
{
|
||||||
|
if (m_scaleConnected)
|
||||||
|
{
|
||||||
|
ui->doubleSpinBoxVerticalScale->blockSignals(true);
|
||||||
|
ui->doubleSpinBoxVerticalScale->setValue(d);
|
||||||
|
ui->doubleSpinBoxVerticalScale->blockSignals(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::VerticalScaleChanged(double d)
|
||||||
|
{
|
||||||
|
if (m_scaleConnected)
|
||||||
|
{
|
||||||
|
ui->doubleSpinBoxHorizontalScale->blockSignals(true);
|
||||||
|
ui->doubleSpinBoxHorizontalScale->setValue(d);
|
||||||
|
ui->doubleSpinBoxHorizontalScale->blockSignals(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool DialogSaveManualLayout::SupportPSTest()
|
||||||
|
{
|
||||||
|
if (!tested)
|
||||||
|
{
|
||||||
|
havePdf = VLayoutExporter::SupportPDFConversion();
|
||||||
|
tested = true;
|
||||||
|
}
|
||||||
|
return havePdf;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QVector<std::pair<QString, LayoutExportFormats> > DialogSaveManualLayout::InitFormats()
|
||||||
|
{
|
||||||
|
QVector<std::pair<QString, LayoutExportFormats>> list;
|
||||||
|
|
||||||
|
auto InitFormat = [&list](LayoutExportFormats format)
|
||||||
|
{
|
||||||
|
list.append(std::make_pair(VLayoutExporter::ExportFormatDescription(format), format));
|
||||||
|
};
|
||||||
|
|
||||||
|
InitFormat(LayoutExportFormats::SVG);
|
||||||
|
InitFormat(LayoutExportFormats::PDF);
|
||||||
|
InitFormat(LayoutExportFormats::PNG);
|
||||||
|
InitFormat(LayoutExportFormats::OBJ);
|
||||||
|
if (SupportPSTest())
|
||||||
|
{
|
||||||
|
InitFormat(LayoutExportFormats::PS);
|
||||||
|
InitFormat(LayoutExportFormats::EPS);
|
||||||
|
}
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1006_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1009_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1012_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1014_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1015_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1018_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1021_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1024_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1027_Flat);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1006_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1009_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1012_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1014_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1015_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1018_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1021_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1024_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1027_AAMA);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1006_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1009_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1012_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1014_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1015_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1018_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1021_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1024_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::DXF_AC1027_ASTM);
|
||||||
|
InitFormat(LayoutExportFormats::PDFTiled);
|
||||||
|
// InitFormat(LayoutExportFormats::NC);
|
||||||
|
InitFormat(LayoutExportFormats::RLD);
|
||||||
|
InitFormat(LayoutExportFormats::TIF);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::RemoveFormatFromList(LayoutExportFormats format)
|
||||||
|
{
|
||||||
|
const int index = ui->comboBoxFormat->findData(static_cast<int>(format));
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
ui->comboBoxFormat->removeItem(index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::ReadSettings()
|
||||||
|
{
|
||||||
|
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
|
||||||
|
SelectFormat(static_cast<LayoutExportFormats>(settings->GetLayoutExportFormat()));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSaveManualLayout::WriteSettings() const
|
||||||
|
{
|
||||||
|
if (m_consoleExport)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
|
||||||
|
settings->SetLayoutExportFormat(static_cast<qint8>(Format()));
|
||||||
|
}
|
101
src/app/puzzle/dialogs/dialogsavemanuallayout.h
Normal file
101
src/app/puzzle/dialogs/dialogsavemanuallayout.h
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file dialogsavemanuallayout.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 3 9, 2021
|
||||||
|
**
|
||||||
|
** @brief
|
||||||
|
** @copyright
|
||||||
|
** This source code is part of the Valentina project, a pattern making
|
||||||
|
** program, whose allow create and modeling patterns of clothing.
|
||||||
|
** Copyright (C) 2021 Valentina project
|
||||||
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
||||||
|
**
|
||||||
|
** Valentina is free software: you can redistribute it and/or modify
|
||||||
|
** it under the terms of the GNU General Public License as published by
|
||||||
|
** the Free Software Foundation, either version 3 of the License, or
|
||||||
|
** (at your option) any later version.
|
||||||
|
**
|
||||||
|
** Valentina is distributed in the hope that it will be useful,
|
||||||
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
** GNU General Public License for more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License
|
||||||
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**
|
||||||
|
*************************************************************************/
|
||||||
|
#ifndef DIALOGSAVEMANUALLAYOUT_H
|
||||||
|
#define DIALOGSAVEMANUALLAYOUT_H
|
||||||
|
|
||||||
|
#include "../vlayout/dialogs/vabstractlayoutdialog.h"
|
||||||
|
#include "../vlayout/vlayoutdef.h"
|
||||||
|
|
||||||
|
namespace Ui
|
||||||
|
{
|
||||||
|
class DialogSaveManualLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DialogSaveManualLayout : public VAbstractLayoutDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DialogSaveManualLayout(int count, bool consoleExport, const QString &fileName = QString(),
|
||||||
|
QWidget *parent = nullptr);
|
||||||
|
virtual ~DialogSaveManualLayout();
|
||||||
|
|
||||||
|
auto Path() const -> QString;
|
||||||
|
auto FileName() const -> QString;
|
||||||
|
|
||||||
|
auto Format() const -> LayoutExportFormats;
|
||||||
|
void SelectFormat(LayoutExportFormats format);
|
||||||
|
|
||||||
|
void SetBinaryDXFFormat(bool binary);
|
||||||
|
bool IsBinaryDXFFormat() const;
|
||||||
|
|
||||||
|
void SetDestinationPath(const QString& cmdDestinationPath);
|
||||||
|
|
||||||
|
bool IsTextAsPaths() const;
|
||||||
|
void SetTextAsPaths(bool textAsPaths);
|
||||||
|
|
||||||
|
void SetXScale(qreal scale);
|
||||||
|
qreal GetXScale() const;
|
||||||
|
|
||||||
|
void SetYScale(qreal scale);
|
||||||
|
qreal GetYScale() const;
|
||||||
|
|
||||||
|
void SetExportUnified(bool value);
|
||||||
|
bool IsExportUnified() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void showEvent(QShowEvent *event) override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void Save();
|
||||||
|
void PathChanged(const QString &text);
|
||||||
|
void ShowExample();
|
||||||
|
void ToggleScaleConnection();
|
||||||
|
void HorizontalScaleChanged(double d);
|
||||||
|
void VerticalScaleChanged(double d);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(DialogSaveManualLayout)
|
||||||
|
Ui::DialogSaveManualLayout *ui;
|
||||||
|
int m_count;
|
||||||
|
bool m_isInitialized{false};
|
||||||
|
bool m_scaleConnected{true};
|
||||||
|
bool m_consoleExport;
|
||||||
|
|
||||||
|
static bool havePdf;
|
||||||
|
static bool tested;
|
||||||
|
static bool SupportPSTest();
|
||||||
|
static QVector<std::pair<QString, LayoutExportFormats> > InitFormats();
|
||||||
|
|
||||||
|
void RemoveFormatFromList(LayoutExportFormats format);
|
||||||
|
|
||||||
|
void ReadSettings();
|
||||||
|
void WriteSettings() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOGSAVEMANUALLAYOUT_H
|
408
src/app/puzzle/dialogs/dialogsavemanuallayout.ui
Normal file
408
src/app/puzzle/dialogs/dialogsavemanuallayout.ui
Normal file
|
@ -0,0 +1,408 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogSaveManualLayout</class>
|
||||||
|
<widget class="QDialog" name="DialogSaveManualLayout">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>503</width>
|
||||||
|
<height>383</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>Path:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEditPath">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Destination folder</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Path to destination folder</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonBrowse">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select path to destination folder</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Browse…</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_10">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>File format:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBoxFormat">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_11">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBoxFormatOptions_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Options</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxBinaryDXF">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Binary form</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxTextAsPaths">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Text as paths</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="checkBoxExportUnified">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Export unified</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_6">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBoxScale_2">
|
||||||
|
<property name="title">
|
||||||
|
<string>Scale</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string>Horizontal:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_12">
|
||||||
|
<property name="text">
|
||||||
|
<string>Vertical:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxHorizontalScale">
|
||||||
|
<property name="suffix">
|
||||||
|
<string notr="true">%</string>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<double>1.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>300.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>100.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDoubleSpinBox" name="doubleSpinBoxVerticalScale">
|
||||||
|
<property name="suffix">
|
||||||
|
<string notr="true">%</string>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<double>1.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>300.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<double>100.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_13">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"><html><head/><body><p><span style=" font-size:16pt;">┐</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignHCenter">
|
||||||
|
<widget class="QToolButton" name="toolButtonScaleConnected">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/link.png</normaloff>:/icon/32x32/link.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="popupMode">
|
||||||
|
<enum>QToolButton::DelayedPopup</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignHCenter">
|
||||||
|
<widget class="QLabel" name="label_14">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true"><html><head/><body><p><span style=" font-size:16pt; font-weight:600;">┘</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetDefaultConstraint</enum>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_15">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>File name:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="lineEditFileName">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>File base name</string>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>File base name</string>
|
||||||
|
</property>
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelExample">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>130</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources>
|
||||||
|
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>DialogSaveManualLayout</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>DialogSaveManualLayout</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -30,6 +30,7 @@
|
||||||
#include "vppiece.h"
|
#include "vppiece.h"
|
||||||
#include "vpsheet.h"
|
#include "vpsheet.h"
|
||||||
#include "../vpapplication.h"
|
#include "../vpapplication.h"
|
||||||
|
#include "../vptilefactory.h"
|
||||||
|
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
@ -78,6 +79,11 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
|
||||||
layout->LayoutSettings().SetDescription(QString("Description of my Layout"));
|
layout->LayoutSettings().SetDescription(QString("Description of my Layout"));
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
|
|
||||||
|
// init the tile factory
|
||||||
|
auto *tileFactory = new VPTileFactory(layout, settings);
|
||||||
|
tileFactory->refreshTileInfos();
|
||||||
|
layout->SetTileFactory(tileFactory);
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +114,30 @@ void VPLayout::AddPiece(const VPPiecePtr &piece)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPTileFactory *VPLayout::TileFactory() const
|
||||||
|
{
|
||||||
|
return m_tileFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPLayout::SetTileFactory(VPTileFactory *newTileFactory)
|
||||||
|
{
|
||||||
|
m_tileFactory = newTileFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPLayout::RefreshScenePieces() const
|
||||||
|
{
|
||||||
|
for (const auto& sheet : GetSheets())
|
||||||
|
{
|
||||||
|
if (not sheet.isNull())
|
||||||
|
{
|
||||||
|
sheet->SceneData()->RefreshPieces(sheet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VPLayout::GetPieces() const -> QList<VPPiecePtr>
|
auto VPLayout::GetPieces() const -> QList<VPPiecePtr>
|
||||||
{
|
{
|
||||||
|
@ -159,7 +189,7 @@ auto VPLayout::AddSheet(const VPSheetPtr &sheet) -> VPSheetPtr
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VPLayout::GetSheets() -> QList<VPSheetPtr>
|
auto VPLayout::GetSheets() const -> QList<VPSheetPtr>
|
||||||
{
|
{
|
||||||
return m_sheets;
|
return m_sheets;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
class VPPiece;
|
class VPPiece;
|
||||||
class VPSheet;
|
class VPSheet;
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
|
class VPTileFactory;
|
||||||
|
|
||||||
class VPLayout : public QObject
|
class VPLayout : public QObject
|
||||||
{
|
{
|
||||||
|
@ -54,7 +55,7 @@ public:
|
||||||
auto GetTrashedPieces() const -> QList<VPPiecePtr>;
|
auto GetTrashedPieces() const -> QList<VPPiecePtr>;
|
||||||
|
|
||||||
auto AddSheet(const VPSheetPtr &sheet) -> VPSheetPtr;
|
auto AddSheet(const VPSheetPtr &sheet) -> VPSheetPtr;
|
||||||
auto GetSheets() -> QList<VPSheetPtr>;
|
auto GetSheets() const -> QList<VPSheetPtr>;
|
||||||
auto GetSheet(const QUuid &uuid) -> VPSheetPtr;
|
auto GetSheet(const QUuid &uuid) -> VPSheetPtr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,6 +88,11 @@ public:
|
||||||
|
|
||||||
void CheckPiecesPositionValidity() const;
|
void CheckPiecesPositionValidity() const;
|
||||||
|
|
||||||
|
auto TileFactory() const -> VPTileFactory *;
|
||||||
|
void SetTileFactory(VPTileFactory *newTileFactory);
|
||||||
|
|
||||||
|
void RefreshScenePieces() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void PieceSheetChanged(const VPPiecePtr &piece);
|
void PieceSheetChanged(const VPPiecePtr &piece);
|
||||||
void ActiveSheetChanged(const VPSheetPtr &focusedSheet);
|
void ActiveSheetChanged(const VPSheetPtr &focusedSheet);
|
||||||
|
@ -115,6 +121,8 @@ private:
|
||||||
VPLayoutSettings m_layoutSettings{};
|
VPLayoutSettings m_layoutSettings{};
|
||||||
|
|
||||||
QUndoStack *m_undoStack;
|
QUndoStack *m_undoStack;
|
||||||
|
|
||||||
|
VPTileFactory *m_tileFactory{nullptr};
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VPLayoutPtr)
|
Q_DECLARE_METATYPE(VPLayoutPtr)
|
||||||
|
|
|
@ -119,6 +119,12 @@ void VPLayoutSettings::SetTilesSizeConverted(const QSizeF &size)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VPLayoutSettings::GetTilesOrientation() const -> QPageLayout::Orientation
|
||||||
|
{
|
||||||
|
return m_tilesSize.height() >= m_tilesSize.width() ? QPageLayout::Portrait : QPageLayout::Landscape;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VPLayoutSettings::GetTilesSize() const -> QSizeF
|
auto VPLayoutSettings::GetTilesSize() const -> QSizeF
|
||||||
{
|
{
|
||||||
|
|
|
@ -153,6 +153,8 @@ public:
|
||||||
*/
|
*/
|
||||||
void SetTilesSizeConverted(const QSizeF &size);
|
void SetTilesSizeConverted(const QSizeF &size);
|
||||||
|
|
||||||
|
auto GetTilesOrientation() const -> QPageLayout::Orientation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief GetTilesSize Returns the size of the tiles in Unit::Px
|
* @brief GetTilesSize Returns the size of the tiles in Unit::Px
|
||||||
* @return tiles size in Unit::Px
|
* @return tiles size in Unit::Px
|
||||||
|
|
|
@ -30,12 +30,221 @@
|
||||||
#include "vplayout.h"
|
#include "vplayout.h"
|
||||||
#include "vppiece.h"
|
#include "vppiece.h"
|
||||||
#include "../vpapplication.h"
|
#include "../vpapplication.h"
|
||||||
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
|
#include "../scene/vpgraphicssheet.h"
|
||||||
|
#include "../scene/vpgraphicspiece.h"
|
||||||
|
#include "../scene/vpgraphicstilegrid.h"
|
||||||
|
#include "../scene/vpgraphicspiececontrols.h"
|
||||||
|
#include "../scene/vpgraphicstilegrid.h"
|
||||||
|
|
||||||
|
// VPSheetSceneData
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPSheetSceneData::VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid)
|
||||||
|
: m_layout(layout),
|
||||||
|
m_scene(new VMainGraphicsScene())
|
||||||
|
{
|
||||||
|
SCASSERT(not layout.isNull())
|
||||||
|
|
||||||
|
m_graphicsSheet = new VPGraphicsSheet(layout);
|
||||||
|
m_graphicsSheet->setPos(0, 0);
|
||||||
|
m_scene->addItem(m_graphicsSheet);
|
||||||
|
|
||||||
|
m_graphicsTileGrid = new VPGraphicsTileGrid(layout, sheetUuid);
|
||||||
|
m_scene->addItem(m_graphicsTileGrid);
|
||||||
|
|
||||||
|
m_rotationControls = new VPGraphicsPieceControls(layout);
|
||||||
|
m_rotationControls->setVisible(false);
|
||||||
|
m_scene->addItem(m_rotationControls);
|
||||||
|
|
||||||
|
m_rotationOrigin = new VPGraphicsTransformationOrigin(layout);
|
||||||
|
m_rotationOrigin->setVisible(false);
|
||||||
|
m_scene->addItem(m_rotationOrigin);
|
||||||
|
|
||||||
|
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::ShowOrigin,
|
||||||
|
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_ShowOrigin);
|
||||||
|
QObject::connect(m_rotationControls, &VPGraphicsPieceControls::TransformationOriginChanged,
|
||||||
|
m_rotationOrigin, &VPGraphicsTransformationOrigin::SetTransformationOrigin);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPSheet::VPSheet(const VPLayoutPtr &layout) :
|
VPSheetSceneData::~VPSheetSceneData()
|
||||||
m_layout(layout)
|
|
||||||
{
|
{
|
||||||
SCASSERT(layout != nullptr)
|
delete m_scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VPSheetSceneData::Scene() const -> VMainGraphicsScene *
|
||||||
|
{
|
||||||
|
return m_scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheetSceneData::RefreshLayout()
|
||||||
|
{
|
||||||
|
m_graphicsSheet->update();
|
||||||
|
|
||||||
|
m_graphicsTileGrid->update();
|
||||||
|
|
||||||
|
m_scene->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheetSceneData::RefreshPieces(const VPSheetPtr &sheet)
|
||||||
|
{
|
||||||
|
qDeleteAll(m_graphicsPieces);
|
||||||
|
m_graphicsPieces.clear();
|
||||||
|
|
||||||
|
if (not sheet.isNull())
|
||||||
|
{
|
||||||
|
QList<VPPiecePtr> pieces = sheet->GetPieces();
|
||||||
|
m_graphicsPieces.reserve(pieces.size());
|
||||||
|
|
||||||
|
for (const auto &piece : pieces)
|
||||||
|
{
|
||||||
|
if (not piece.isNull())
|
||||||
|
{
|
||||||
|
auto *graphicsPiece = new VPGraphicsPiece(piece);
|
||||||
|
m_graphicsPieces.append(graphicsPiece);
|
||||||
|
m_scene->addItem(graphicsPiece);
|
||||||
|
ConnectPiece(graphicsPiece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheetSceneData::PrepareForExport()
|
||||||
|
{
|
||||||
|
m_graphicsSheet->SetShowBorder(false);
|
||||||
|
m_graphicsSheet->SetShowMargin(false);
|
||||||
|
|
||||||
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
|
if (not layout.isNull())
|
||||||
|
{
|
||||||
|
m_showGridTmp = layout->LayoutSettings().GetShowGrid();
|
||||||
|
layout->LayoutSettings().SetShowGrid(false);
|
||||||
|
|
||||||
|
m_showTilesTmp = layout->LayoutSettings().GetShowTiles();
|
||||||
|
layout->LayoutSettings().SetShowTiles(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheetSceneData::CleanAfterExport()
|
||||||
|
{
|
||||||
|
m_graphicsSheet->SetShowBorder(true);
|
||||||
|
m_graphicsSheet->SetShowMargin(true);
|
||||||
|
|
||||||
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
|
if (not layout.isNull())
|
||||||
|
{
|
||||||
|
layout->LayoutSettings().SetShowGrid(m_showGridTmp);
|
||||||
|
layout->LayoutSettings().SetShowTiles(m_showTilesTmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
RefreshLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VPSheetSceneData::GraphicsPieces() const -> const QList<VPGraphicsPiece *> &
|
||||||
|
{
|
||||||
|
return m_graphicsPieces;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VPSheetSceneData::GraphicsPiecesAsItems() const -> QList<QGraphicsItem *>
|
||||||
|
{
|
||||||
|
QList<QGraphicsItem *> items;
|
||||||
|
items.reserve(m_graphicsPieces.size());
|
||||||
|
|
||||||
|
for(auto *item : m_graphicsPieces)
|
||||||
|
{
|
||||||
|
items.append(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VPSheetSceneData::RotationControls() const -> VPGraphicsPieceControls *
|
||||||
|
{
|
||||||
|
return m_rotationControls;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VPSheetSceneData::ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *
|
||||||
|
{
|
||||||
|
VPGraphicsPiece *_graphicsPiece = nullptr;
|
||||||
|
for(auto *graphicPiece : m_graphicsPieces)
|
||||||
|
{
|
||||||
|
if(graphicPiece->GetPiece() == piece)
|
||||||
|
{
|
||||||
|
_graphicsPiece = graphicPiece;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _graphicsPiece;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheetSceneData::RemovePiece(VPGraphicsPiece *piece)
|
||||||
|
{
|
||||||
|
m_graphicsPieces.removeAll(piece);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheetSceneData::AddPiece(VPGraphicsPiece *piece)
|
||||||
|
{
|
||||||
|
m_graphicsPieces.append(piece);
|
||||||
|
ConnectPiece(piece);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheetSceneData::SetTextAsPaths(bool textAsPaths) const
|
||||||
|
{
|
||||||
|
for (auto *piece : m_graphicsPieces)
|
||||||
|
{
|
||||||
|
if (piece != nullptr)
|
||||||
|
{
|
||||||
|
piece->SetTextAsPaths(textAsPaths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSheetSceneData::ConnectPiece(VPGraphicsPiece *piece)
|
||||||
|
{
|
||||||
|
SCASSERT(piece != nullptr)
|
||||||
|
|
||||||
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
|
if (layout.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QObject::connect(layout.get(), &VPLayout::PieceTransformationChanged, piece,
|
||||||
|
&VPGraphicsPiece::on_RefreshPiece);
|
||||||
|
QObject::connect(layout.get(), &VPLayout::PieceSelectionChanged,
|
||||||
|
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
||||||
|
QObject::connect(layout.get(), &VPLayout::PiecePositionValidityChanged,
|
||||||
|
piece, &VPGraphicsPiece::on_RefreshPiece);
|
||||||
|
QObject::connect(piece, &VPGraphicsPiece::PieceTransformationChanged,
|
||||||
|
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
||||||
|
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
||||||
|
m_rotationControls, &VPGraphicsPieceControls::on_HideHandles);
|
||||||
|
QObject::connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
||||||
|
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_HideHandles);
|
||||||
|
}
|
||||||
|
|
||||||
|
// VPSheet
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPSheet::VPSheet(const VPLayoutPtr &layout) :
|
||||||
|
m_layout(layout),
|
||||||
|
m_sceneData(new VPSheetSceneData(layout, Uuid()))
|
||||||
|
{
|
||||||
|
SCASSERT(not layout.isNull())
|
||||||
|
|
||||||
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
|
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
|
||||||
SetIgnoreMargins(settings->GetLayoutSheetIgnoreMargins());
|
SetIgnoreMargins(settings->GetLayoutSheetIgnoreMargins());
|
||||||
|
@ -86,6 +295,25 @@ auto VPSheet::GetSelectedPieces() const -> QList<VPPiecePtr>
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VPSheet::GetAsLayoutPieces() const -> QVector<VLayoutPiece>
|
||||||
|
{
|
||||||
|
QList<VPPiecePtr> pieces = GetPieces();
|
||||||
|
|
||||||
|
QVector<VLayoutPiece> details;
|
||||||
|
details.reserve(pieces.size());
|
||||||
|
|
||||||
|
for (auto piece : pieces)
|
||||||
|
{
|
||||||
|
if (not piece.isNull())
|
||||||
|
{
|
||||||
|
details.append(*piece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return details;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VPSheet::GetName() const -> QString
|
auto VPSheet::GetName() const -> QString
|
||||||
{
|
{
|
||||||
|
@ -362,7 +590,13 @@ void VPSheet::CheckPiecePositionValidity(const VPPiecePtr &piece) const
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Unit VPSheet::SheetUnits() const
|
auto VPSheet::SceneData() const -> VPSheetSceneData *
|
||||||
|
{
|
||||||
|
return m_sceneData;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
auto VPSheet::SheetUnits() const -> Unit
|
||||||
{
|
{
|
||||||
VPLayoutPtr layout = GetLayout();
|
VPLayoutPtr layout = GetLayout();
|
||||||
if (not layout.isNull())
|
if (not layout.isNull())
|
||||||
|
|
|
@ -39,6 +39,79 @@
|
||||||
|
|
||||||
class VPLayout;
|
class VPLayout;
|
||||||
class VPPiece;
|
class VPPiece;
|
||||||
|
class VMainGraphicsScene;
|
||||||
|
class VPGraphicsPieceControls;
|
||||||
|
class VPGraphicsTransformationOrigin;
|
||||||
|
class VPGraphicsPiece;
|
||||||
|
class VPGraphicsTileGrid;
|
||||||
|
class VPGraphicsSheet;
|
||||||
|
class VLayoutPiece;
|
||||||
|
|
||||||
|
class VPSheetSceneData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit VPSheetSceneData(const VPLayoutPtr &layout, const QUuid &sheetUuid);
|
||||||
|
~VPSheetSceneData();
|
||||||
|
|
||||||
|
VMainGraphicsScene *Scene() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief RefreshLayout Refreshes the rectangles for the layout border and the margin
|
||||||
|
*/
|
||||||
|
void RefreshLayout();
|
||||||
|
|
||||||
|
void RefreshPieces(const VPSheetPtr &sheet);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief PrepareForExport prepares the graphic for an export (i.e hide margin etc)
|
||||||
|
*/
|
||||||
|
void PrepareForExport();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief CleanAfterExport cleans the graphic for an export (i.e show margin etc)
|
||||||
|
*/
|
||||||
|
void CleanAfterExport();
|
||||||
|
|
||||||
|
auto GraphicsPieces() const -> const QList<VPGraphicsPiece *> &;
|
||||||
|
auto GraphicsPiecesAsItems() const -> QList<QGraphicsItem *>;
|
||||||
|
|
||||||
|
auto RotationControls() const -> VPGraphicsPieceControls *;
|
||||||
|
|
||||||
|
auto ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *;
|
||||||
|
|
||||||
|
void RemovePiece(VPGraphicsPiece *piece);
|
||||||
|
void AddPiece(VPGraphicsPiece *piece);
|
||||||
|
|
||||||
|
void SetTextAsPaths(bool textAsPaths) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VPSheetSceneData)
|
||||||
|
|
||||||
|
VPLayoutWeakPtr m_layout{};
|
||||||
|
|
||||||
|
VMainGraphicsScene *m_scene;
|
||||||
|
|
||||||
|
VPGraphicsSheet *m_graphicsSheet{nullptr};
|
||||||
|
|
||||||
|
VPGraphicsTileGrid *m_graphicsTileGrid{nullptr};
|
||||||
|
|
||||||
|
VPGraphicsPieceControls *m_rotationControls{nullptr};
|
||||||
|
VPGraphicsTransformationOrigin *m_rotationOrigin{nullptr};
|
||||||
|
|
||||||
|
QList<VPGraphicsPiece*> m_graphicsPieces{};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* variable to hold temporarly hte value of the show tiles
|
||||||
|
*/
|
||||||
|
bool m_showTilesTmp{false};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* variable to hold temporarly hte value of the show grid
|
||||||
|
*/
|
||||||
|
bool m_showGridTmp{false};
|
||||||
|
|
||||||
|
void ConnectPiece(VPGraphicsPiece *piece);
|
||||||
|
};
|
||||||
|
|
||||||
class VPSheet : public QObject
|
class VPSheet : public QObject
|
||||||
{
|
{
|
||||||
|
@ -58,6 +131,8 @@ public:
|
||||||
|
|
||||||
auto GetSelectedPieces() const -> QList<VPPiecePtr>;
|
auto GetSelectedPieces() const -> QList<VPPiecePtr>;
|
||||||
|
|
||||||
|
auto GetAsLayoutPieces() const -> QVector<VLayoutPiece>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief GetName Returns the name of the sheet
|
* @brief GetName Returns the name of the sheet
|
||||||
* @return the name
|
* @return the name
|
||||||
|
@ -178,6 +253,8 @@ public:
|
||||||
auto IgnoreMargins() const -> bool;
|
auto IgnoreMargins() const -> bool;
|
||||||
void SetIgnoreMargins(bool newIgnoreMargins);
|
void SetIgnoreMargins(bool newIgnoreMargins);
|
||||||
|
|
||||||
|
VPSheetSceneData *SceneData() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void CheckPiecePositionValidity(const VPPiecePtr &piece) const;
|
void CheckPiecePositionValidity(const VPPiecePtr &piece) const;
|
||||||
|
|
||||||
|
@ -210,6 +287,8 @@ private:
|
||||||
|
|
||||||
GrainlineType m_grainlineType{GrainlineType::NotFixed};
|
GrainlineType m_grainlineType{GrainlineType::NotFixed};
|
||||||
|
|
||||||
|
VPSheetSceneData *m_sceneData{nullptr};
|
||||||
|
|
||||||
auto SheetUnits() const -> Unit;
|
auto SheetUnits() const -> Unit;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,6 @@ SOURCES += \
|
||||||
$$PWD/carousel/vpcarrouselpiecelist.cpp \
|
$$PWD/carousel/vpcarrouselpiecelist.cpp \
|
||||||
$$PWD/vpcommandline.cpp \
|
$$PWD/vpcommandline.cpp \
|
||||||
$$PWD/vpcommands.cpp \
|
$$PWD/vpcommands.cpp \
|
||||||
$$PWD/vpexporter.cpp \
|
|
||||||
$$PWD/scene/vpgraphicspiece.cpp \
|
$$PWD/scene/vpgraphicspiece.cpp \
|
||||||
$$PWD/scene/vpgraphicspiececontrols.cpp \
|
$$PWD/scene/vpgraphicspiececontrols.cpp \
|
||||||
$$PWD/scene/vpgraphicssheet.cpp \
|
$$PWD/scene/vpgraphicssheet.cpp \
|
||||||
|
@ -38,7 +37,8 @@ SOURCES += \
|
||||||
$$PWD/vptilefactory.cpp \
|
$$PWD/vptilefactory.cpp \
|
||||||
$$PWD/xml/vplayoutfilereader.cpp \
|
$$PWD/xml/vplayoutfilereader.cpp \
|
||||||
$$PWD/xml/vplayoutfilewriter.cpp \
|
$$PWD/xml/vplayoutfilewriter.cpp \
|
||||||
$$PWD/xml/vplayoutliterals.cpp
|
$$PWD/xml/vplayoutliterals.cpp \
|
||||||
|
$$PWD/dialogs/dialogsavemanuallayout.cpp
|
||||||
|
|
||||||
*msvc*:SOURCES += $$PWD/stable.cpp
|
*msvc*:SOURCES += $$PWD/stable.cpp
|
||||||
|
|
||||||
|
@ -64,7 +64,6 @@ HEADERS += \
|
||||||
$$PWD/carousel/vpcarrouselpiecelist.h \
|
$$PWD/carousel/vpcarrouselpiecelist.h \
|
||||||
$$PWD/vpcommandline.h \
|
$$PWD/vpcommandline.h \
|
||||||
$$PWD/vpcommands.h \
|
$$PWD/vpcommands.h \
|
||||||
$$PWD/vpexporter.h \
|
|
||||||
$$PWD/scene/vpgraphicspiece.h \
|
$$PWD/scene/vpgraphicspiece.h \
|
||||||
$$PWD/scene/vpgraphicspiececontrols.h \
|
$$PWD/scene/vpgraphicspiececontrols.h \
|
||||||
$$PWD/scene/vpgraphicssheet.h \
|
$$PWD/scene/vpgraphicssheet.h \
|
||||||
|
@ -80,7 +79,8 @@ HEADERS += \
|
||||||
$$PWD/vptilefactory.h \
|
$$PWD/vptilefactory.h \
|
||||||
$$PWD/xml/vplayoutfilereader.h \
|
$$PWD/xml/vplayoutfilereader.h \
|
||||||
$$PWD/xml/vplayoutfilewriter.h \
|
$$PWD/xml/vplayoutfilewriter.h \
|
||||||
$$PWD/xml/vplayoutliterals.h
|
$$PWD/xml/vplayoutliterals.h \
|
||||||
|
$$PWD/dialogs/dialogsavemanuallayout.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$PWD/dialogs/configpages/puzzlepreferencesconfigurationpage.ui \
|
$$PWD/dialogs/configpages/puzzlepreferencesconfigurationpage.ui \
|
||||||
|
@ -89,4 +89,5 @@ FORMS += \
|
||||||
$$PWD/dialogs/dialogpuzzlepreferences.ui \
|
$$PWD/dialogs/dialogpuzzlepreferences.ui \
|
||||||
$$PWD/dialogs/vpdialogabout.ui \
|
$$PWD/dialogs/vpdialogabout.ui \
|
||||||
$$PWD/carousel/vpcarrousel.ui \
|
$$PWD/carousel/vpcarrousel.ui \
|
||||||
$$PWD/vpmainwindow.ui
|
$$PWD/vpmainwindow.ui \
|
||||||
|
$$PWD/dialogs/dialogsavemanuallayout.ui
|
||||||
|
|
|
@ -198,16 +198,7 @@ DEPENDPATH += $$PWD/../../libs/vwidgets
|
||||||
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib
|
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib
|
||||||
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a
|
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a
|
||||||
|
|
||||||
## VFormat static library (depend on VPatternDB, IFC)
|
# VLayout static library (depend on VGeometry, VFormat)
|
||||||
#unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat
|
|
||||||
|
|
||||||
#INCLUDEPATH += $$PWD/../../libs/vformat
|
|
||||||
#DEPENDPATH += $$PWD/../../libs/vformat
|
|
||||||
|
|
||||||
#win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib
|
|
||||||
#else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a
|
|
||||||
|
|
||||||
# VLayout static library (depend on VGeometry)
|
|
||||||
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout
|
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/../../libs/vlayout
|
INCLUDEPATH += $$PWD/../../libs/vlayout
|
||||||
|
@ -216,6 +207,15 @@ DEPENDPATH += $$PWD/../../libs/vlayout
|
||||||
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib
|
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib
|
||||||
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a
|
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a
|
||||||
|
|
||||||
|
# VFormat static library (depend on VPatternDB, IFC)
|
||||||
|
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD/../../libs/vformat
|
||||||
|
DEPENDPATH += $$PWD/../../libs/vformat
|
||||||
|
|
||||||
|
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib
|
||||||
|
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a
|
||||||
|
|
||||||
#VPatternDB static library (depend on vgeometry, vmisc)
|
#VPatternDB static library (depend on vgeometry, vmisc)
|
||||||
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb
|
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,17 @@
|
||||||
#include "../vptilefactory.h"
|
#include "../vptilefactory.h"
|
||||||
#include "../layout/vplayout.h"
|
#include "../layout/vplayout.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
namespace
|
||||||
VPGraphicsTileGrid::VPGraphicsTileGrid(const VPLayoutPtr &layout, VPTileFactory *tileFactory, QGraphicsItem *parent):
|
|
||||||
QGraphicsItem(parent),
|
|
||||||
m_tileFactory(tileFactory),
|
|
||||||
m_layout(layout)
|
|
||||||
{
|
{
|
||||||
|
constexpr qreal penWidth = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VPGraphicsTileGrid::VPGraphicsTileGrid(const VPLayoutPtr &layout, const QUuid &sheetUuid, QGraphicsItem *parent):
|
||||||
|
QGraphicsItem(parent),
|
||||||
|
m_layout(layout),
|
||||||
|
m_sheetUuid(sheetUuid)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -18,11 +22,15 @@ auto VPGraphicsTileGrid::boundingRect() const -> QRectF
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
if(not layout.isNull() && layout->LayoutSettings().GetShowTiles())
|
if(not layout.isNull() && layout->LayoutSettings().GetShowTiles())
|
||||||
{
|
{
|
||||||
return QRectF(0,
|
VPSheetPtr sheet = layout->GetSheet(m_sheetUuid);
|
||||||
0,
|
|
||||||
m_tileFactory->getColNb()* m_tileFactory->getDrawingAreaWidth(),
|
QRectF rect(0, 0,
|
||||||
m_tileFactory->getRowNb()* m_tileFactory->getDrawingAreaHeight()
|
layout->TileFactory()->ColNb(sheet) * layout->TileFactory()->DrawingAreaWidth(),
|
||||||
);
|
layout->TileFactory()->RowNb(sheet) * layout->TileFactory()->DrawingAreaHeight() );
|
||||||
|
|
||||||
|
constexpr qreal halfPenWidth = penWidth/2.;
|
||||||
|
|
||||||
|
return rect.adjusted(-halfPenWidth, -halfPenWidth, halfPenWidth, halfPenWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
@ -37,34 +45,36 @@ void VPGraphicsTileGrid::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
if(not layout.isNull() && layout->LayoutSettings().GetShowTiles())
|
if(not layout.isNull() && layout->LayoutSettings().GetShowTiles())
|
||||||
{
|
{
|
||||||
QPen pen(QColor(255,0,0,127), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
VPSheetPtr sheet = layout->GetSheet(m_sheetUuid);
|
||||||
|
|
||||||
|
QPen pen(QColor(255,0,0,127), penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
|
||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
pen.setStyle(Qt::DashLine);
|
pen.setStyle(Qt::DashLine);
|
||||||
QBrush noBrush(Qt::NoBrush);
|
QBrush noBrush(Qt::NoBrush);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
painter->setBrush(noBrush);
|
painter->setBrush(noBrush);
|
||||||
|
|
||||||
for(int i=0;i<=m_tileFactory->getColNb();i++)
|
for(int i=0;i<=layout->TileFactory()->ColNb(sheet);i++)
|
||||||
{
|
{
|
||||||
painter->drawLine(QPointF(
|
painter->drawLine(QPointF(
|
||||||
i*m_tileFactory->getDrawingAreaWidth(),
|
i*layout->TileFactory()->DrawingAreaWidth(),
|
||||||
0),
|
0),
|
||||||
QPointF(
|
QPointF(
|
||||||
i*m_tileFactory->getDrawingAreaWidth(),
|
i*layout->TileFactory()->DrawingAreaWidth(),
|
||||||
m_tileFactory->getRowNb()*m_tileFactory->getDrawingAreaHeight()
|
layout->TileFactory()->RowNb(sheet)*layout->TileFactory()->DrawingAreaHeight()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int j=0;j<=m_tileFactory->getRowNb();j++)
|
for(int j=0;j<=layout->TileFactory()->RowNb(sheet);j++)
|
||||||
{
|
{
|
||||||
painter->drawLine(QPointF(
|
painter->drawLine(QPointF(
|
||||||
0,
|
0,
|
||||||
j*m_tileFactory->getDrawingAreaHeight()
|
j*layout->TileFactory()->DrawingAreaHeight()
|
||||||
),
|
),
|
||||||
QPointF(
|
QPointF(
|
||||||
m_tileFactory->getColNb()*m_tileFactory->getDrawingAreaWidth(),
|
layout->TileFactory()->ColNb(sheet)*layout->TileFactory()->DrawingAreaWidth(),
|
||||||
j*m_tileFactory->getDrawingAreaHeight()
|
j*layout->TileFactory()->DrawingAreaHeight()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QUuid>
|
||||||
|
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../layout/layoutdef.h"
|
#include "../layout/layoutdef.h"
|
||||||
|
@ -41,18 +42,17 @@ class VPLayout;
|
||||||
class VPGraphicsTileGrid : public QGraphicsItem
|
class VPGraphicsTileGrid : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit VPGraphicsTileGrid(const VPLayoutPtr &layout, VPTileFactory *tileFactory, QGraphicsItem *parent = nullptr);
|
explicit VPGraphicsTileGrid(const VPLayoutPtr &layout, const QUuid &sheetUuid, QGraphicsItem *parent = nullptr);
|
||||||
~VPGraphicsTileGrid()=default;
|
~VPGraphicsTileGrid()=default;
|
||||||
|
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPGraphicsTileGrid)
|
Q_DISABLE_COPY(VPGraphicsTileGrid)
|
||||||
|
|
||||||
VPTileFactory * m_tileFactory{nullptr};
|
VPLayoutWeakPtr m_layout;
|
||||||
VPLayoutWeakPtr m_layout{};
|
QUuid m_sheetUuid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VPGRAPHICSTILEGRID_H
|
#endif // VPGRAPHICSTILEGRID_H
|
||||||
|
|
|
@ -34,17 +34,16 @@
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
|
||||||
#include "../scene/vpgraphicssheet.h"
|
|
||||||
#include "../scene/vpgraphicspiece.h"
|
|
||||||
#include "../vptilefactory.h"
|
#include "../vptilefactory.h"
|
||||||
#include "../scene/vpgraphicstilegrid.h"
|
|
||||||
#include "../carousel/vpmimedatapiece.h"
|
#include "../carousel/vpmimedatapiece.h"
|
||||||
#include "../layout/vplayout.h"
|
#include "../layout/vplayout.h"
|
||||||
#include "../layout/vpsheet.h"
|
#include "../layout/vpsheet.h"
|
||||||
#include "../layout/vppiece.h"
|
#include "../layout/vppiece.h"
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
#include "../vwidgets/vmaingraphicsscene.h"
|
||||||
#include "vptilefactory.h"
|
#include "vptilefactory.h"
|
||||||
|
#include "vpgraphicspiece.h"
|
||||||
#include "vpgraphicspiececontrols.h"
|
#include "vpgraphicspiececontrols.h"
|
||||||
|
|
||||||
#include "../undocommands/vpundopiecemove.h"
|
#include "../undocommands/vpundopiecemove.h"
|
||||||
#include "../undocommands/vpundopiecerotate.h"
|
#include "../undocommands/vpundopiecerotate.h"
|
||||||
#include "../undocommands/vpundooriginmove.h"
|
#include "../undocommands/vpundooriginmove.h"
|
||||||
|
@ -62,41 +61,19 @@ const QKeySequence restoreOriginShortcut = QKeySequence(Qt::ControlModifier + Qt
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, VPTileFactory *tileFactory, QWidget *parent) :
|
VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *parent) :
|
||||||
VMainGraphicsView(parent),
|
VMainGraphicsView(parent),
|
||||||
m_scene(new VMainGraphicsScene(this)),
|
|
||||||
m_layout(layout)
|
m_layout(layout)
|
||||||
{
|
{
|
||||||
SCASSERT(not m_layout.isNull())
|
SCASSERT(not layout.isNull())
|
||||||
setScene(m_scene);
|
|
||||||
|
|
||||||
connect(m_scene, &VMainGraphicsScene::ItemClicked, this, &VPMainGraphicsView::on_ItemClicked);
|
SwitchScene(layout->GetFocusedSheet());
|
||||||
|
|
||||||
m_graphicsSheet = new VPGraphicsSheet(m_layout);
|
|
||||||
m_graphicsSheet->setPos(0, 0);
|
|
||||||
m_scene->addItem(m_graphicsSheet);
|
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
m_graphicsTileGrid = new VPGraphicsTileGrid(m_layout, tileFactory);
|
|
||||||
m_scene->addItem(m_graphicsTileGrid);
|
|
||||||
|
|
||||||
m_rotationControls = new VPGraphicsPieceControls(m_layout);
|
|
||||||
m_rotationControls->setVisible(false);
|
|
||||||
m_scene->addItem(m_rotationControls);
|
|
||||||
|
|
||||||
m_rotationOrigin = new VPGraphicsTransformationOrigin(m_layout);
|
|
||||||
m_rotationOrigin->setVisible(false);
|
|
||||||
m_scene->addItem(m_rotationOrigin);
|
|
||||||
|
|
||||||
connect(m_rotationControls, &VPGraphicsPieceControls::ShowOrigin,
|
|
||||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_ShowOrigin);
|
|
||||||
connect(m_rotationControls, &VPGraphicsPieceControls::TransformationOriginChanged,
|
|
||||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::SetTransformationOrigin);
|
|
||||||
|
|
||||||
// add the connections
|
// add the connections
|
||||||
connect(layout.get(), &VPLayout::PieceSheetChanged, this, &VPMainGraphicsView::on_PieceSheetChanged);
|
connect(layout.get(), &VPLayout::PieceSheetChanged, this, &VPMainGraphicsView::on_PieceSheetChanged);
|
||||||
connect(layout.get(), &VPLayout::ActiveSheetChanged, this, &VPMainGraphicsView::RefreshPieces);
|
connect(layout.get(), &VPLayout::ActiveSheetChanged, this, &VPMainGraphicsView::on_ActiveSheetChanged);
|
||||||
|
|
||||||
auto *restoreOrigin = new QAction(this);
|
auto *restoreOrigin = new QAction(this);
|
||||||
restoreOrigin->setShortcut(restoreOriginShortcut);
|
restoreOrigin->setShortcut(restoreOriginShortcut);
|
||||||
|
@ -107,84 +84,29 @@ VPMainGraphicsView::VPMainGraphicsView(const VPLayoutPtr &layout, VPTileFactory
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainGraphicsView::RefreshLayout()
|
void VPMainGraphicsView::RefreshLayout()
|
||||||
{
|
{
|
||||||
// FIXME: Is that the way to go?
|
|
||||||
|
|
||||||
m_graphicsSheet->update();
|
|
||||||
|
|
||||||
m_graphicsTileGrid->update();
|
|
||||||
|
|
||||||
m_scene->update();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VPMainGraphicsView::RefreshPieces()
|
|
||||||
{
|
|
||||||
qDeleteAll(m_graphicsPieces);
|
|
||||||
m_graphicsPieces.clear();
|
|
||||||
|
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
if (not layout.isNull())
|
if (not layout.isNull())
|
||||||
{
|
{
|
||||||
VPSheetPtr sheet = layout->GetFocusedSheet();
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
if (not sheet.isNull())
|
if (not sheet.isNull())
|
||||||
{
|
{
|
||||||
QList<VPPiecePtr> pieces = sheet->GetPieces();
|
sheet->SceneData()->RefreshLayout();
|
||||||
m_graphicsPieces.reserve(pieces.size());
|
|
||||||
|
|
||||||
for (const auto &piece : pieces)
|
|
||||||
{
|
|
||||||
if (not piece.isNull())
|
|
||||||
{
|
|
||||||
auto *graphicsPiece = new VPGraphicsPiece(piece);
|
|
||||||
m_graphicsPieces.append(graphicsPiece);
|
|
||||||
scene()->addItem(graphicsPiece);
|
|
||||||
ConnectPiece(graphicsPiece);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VPMainGraphicsView::GetScene() -> VMainGraphicsScene*
|
void VPMainGraphicsView::RefreshPieces()
|
||||||
{
|
{
|
||||||
return m_scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VPMainGraphicsView::PrepareForExport()
|
|
||||||
{
|
|
||||||
m_graphicsSheet->SetShowBorder(false);
|
|
||||||
m_graphicsSheet->SetShowMargin(false);
|
|
||||||
|
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
if (not layout.isNull())
|
if (not layout.isNull())
|
||||||
{
|
{
|
||||||
m_showGridTmp = layout->GetFocusedSheet()->GetLayout()->LayoutSettings().GetShowGrid();
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
layout->GetFocusedSheet()->GetLayout()->LayoutSettings().SetShowGrid(false);
|
if (not sheet.isNull())
|
||||||
|
{
|
||||||
m_showTilesTmp = layout->LayoutSettings().GetShowTiles();
|
sheet->SceneData()->RefreshPieces(sheet);
|
||||||
layout->LayoutSettings().SetShowTiles(false);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VPMainGraphicsView::CleanAfterExport()
|
|
||||||
{
|
|
||||||
m_graphicsSheet->SetShowBorder(true);
|
|
||||||
m_graphicsSheet->SetShowMargin(true);
|
|
||||||
|
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
|
||||||
if (not layout.isNull())
|
|
||||||
{
|
|
||||||
layout->GetFocusedSheet()->GetLayout()->LayoutSettings().SetShowGrid(m_showGridTmp);
|
|
||||||
|
|
||||||
layout->LayoutSettings().SetShowTiles(m_showTilesTmp);
|
|
||||||
}
|
|
||||||
|
|
||||||
RefreshLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -253,7 +175,20 @@ void VPMainGraphicsView::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete)
|
if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete)
|
||||||
{
|
{
|
||||||
for(auto *graphicsPiece : m_graphicsPieces)
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
|
if (layout.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
|
||||||
|
for(auto *graphicsPiece : graphicsPieces)
|
||||||
{
|
{
|
||||||
VPPiecePtr piece = graphicsPiece->GetPiece();
|
VPPiecePtr piece = graphicsPiece->GetPiece();
|
||||||
|
|
||||||
|
@ -360,43 +295,50 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if (not event->isAutoRepeat())
|
if (not event->isAutoRepeat())
|
||||||
{
|
{
|
||||||
if (m_hasStickyPosition && not m_graphicsPieces.isEmpty())
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
|
if (layout.isNull())
|
||||||
{
|
{
|
||||||
VPPiecePtr piece = m_graphicsPieces.first()->GetPiece();
|
return;
|
||||||
if (not piece.isNull())
|
}
|
||||||
|
|
||||||
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
|
||||||
|
if (m_hasStickyPosition && not graphicsPieces.isEmpty())
|
||||||
|
{
|
||||||
|
if (layout->LayoutSettings().GetStickyEdges())
|
||||||
{
|
{
|
||||||
VPLayoutPtr layout = piece->Layout();
|
auto PreparePieces = [layout]()
|
||||||
if (not layout.isNull() && layout->LayoutSettings().GetStickyEdges())
|
|
||||||
{
|
{
|
||||||
auto PreparePieces = [layout]()
|
QList<VPPiecePtr> pieces;
|
||||||
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
|
if (not sheet.isNull())
|
||||||
{
|
{
|
||||||
QList<VPPiecePtr> pieces;
|
pieces = sheet->GetSelectedPieces();
|
||||||
VPSheetPtr sheet = layout->GetFocusedSheet();
|
}
|
||||||
if (not sheet.isNull())
|
|
||||||
{
|
|
||||||
pieces = sheet->GetSelectedPieces();
|
|
||||||
}
|
|
||||||
|
|
||||||
return pieces;
|
return pieces;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<VPPiecePtr> pieces = PreparePieces();
|
QList<VPPiecePtr> pieces = PreparePieces();
|
||||||
if (pieces.size() == 1)
|
if (pieces.size() == 1)
|
||||||
|
{
|
||||||
|
VPPiecePtr p = pieces.first();
|
||||||
|
|
||||||
|
auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY,
|
||||||
|
m_allowChangeMerge);
|
||||||
|
layout->UndoStack()->push(command);
|
||||||
|
|
||||||
|
VPGraphicsPiece * gPiece = sheet->SceneData()->ScenePiece(p);
|
||||||
|
if (gPiece != nullptr)
|
||||||
{
|
{
|
||||||
VPPiecePtr p = pieces.first();
|
gPiece->SetStickyPoints(QVector<QPointF>());
|
||||||
|
|
||||||
auto *command = new VPUndoPieceMove(p, m_stickyTranslateX, m_stickyTranslateY,
|
|
||||||
m_allowChangeMerge);
|
|
||||||
layout->UndoStack()->push(command);
|
|
||||||
|
|
||||||
VPGraphicsPiece * gPiece = ScenePiece(p);
|
|
||||||
if (gPiece != nullptr)
|
|
||||||
{
|
|
||||||
gPiece->SetStickyPoints(QVector<QPointF>());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,9 +351,20 @@ void VPMainGraphicsView::keyReleaseEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
if (not event->isAutoRepeat())
|
if (not event->isAutoRepeat())
|
||||||
{
|
{
|
||||||
m_rotationControls->SetIgnorePieceTransformation(false);
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
m_rotationControls->on_UpdateControls();
|
if (layout.isNull())
|
||||||
m_rotationControls->on_HideHandles(false);
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
sheet->SceneData()->RotationControls()->SetIgnorePieceTransformation(false);
|
||||||
|
sheet->SceneData()->RotationControls()->on_UpdateControls();
|
||||||
|
sheet->SceneData()->RotationControls()->on_HideHandles(false);
|
||||||
|
}
|
||||||
|
|
||||||
m_rotationSum = 0;
|
m_rotationSum = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,32 +499,14 @@ void VPMainGraphicsView::on_ItemClicked(QGraphicsItem *item)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainGraphicsView::ConnectPiece(VPGraphicsPiece *piece)
|
void VPMainGraphicsView::on_SceneMouseMove(const QPointF &scenePos)
|
||||||
{
|
{
|
||||||
SCASSERT(piece != nullptr)
|
emit mouseMove(scenePos);
|
||||||
|
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
|
||||||
|
|
||||||
connect(layout.get(), &VPLayout::PieceTransformationChanged, piece,
|
|
||||||
&VPGraphicsPiece::on_RefreshPiece);
|
|
||||||
connect(layout.get(), &VPLayout::PieceSelectionChanged,
|
|
||||||
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
|
||||||
connect(layout.get(), &VPLayout::PiecePositionValidityChanged,
|
|
||||||
piece, &VPGraphicsPiece::on_RefreshPiece);
|
|
||||||
connect(piece, &VPGraphicsPiece::PieceTransformationChanged,
|
|
||||||
m_rotationControls, &VPGraphicsPieceControls::on_UpdateControls);
|
|
||||||
connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
|
||||||
m_rotationControls, &VPGraphicsPieceControls::on_HideHandles);
|
|
||||||
connect(piece, &VPGraphicsPiece::HideTransformationHandles,
|
|
||||||
m_rotationOrigin, &VPGraphicsTransformationOrigin::on_HideHandles);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainGraphicsView::RotatePiecesByAngle(qreal angle)
|
void VPMainGraphicsView::RotatePiecesByAngle(qreal angle)
|
||||||
{
|
{
|
||||||
m_rotationControls->on_HideHandles(true);
|
|
||||||
m_rotationControls->SetIgnorePieceTransformation(true);
|
|
||||||
|
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
if (layout.isNull())
|
if (layout.isNull())
|
||||||
{
|
{
|
||||||
|
@ -584,6 +519,9 @@ void VPMainGraphicsView::RotatePiecesByAngle(qreal angle)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sheet->SceneData()->RotationControls()->on_HideHandles(true);
|
||||||
|
sheet->SceneData()->RotationControls()->SetIgnorePieceTransformation(true);
|
||||||
|
|
||||||
VPTransformationOrigon origin = sheet->TransformationOrigin();
|
VPTransformationOrigon origin = sheet->TransformationOrigin();
|
||||||
|
|
||||||
auto PreparePieces = [this]()
|
auto PreparePieces = [this]()
|
||||||
|
@ -637,23 +575,31 @@ void VPMainGraphicsView::RotatePiecesByAngle(qreal angle)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
|
void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
|
||||||
{
|
{
|
||||||
if (m_graphicsPieces.isEmpty())
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VPPiecePtr piece = m_graphicsPieces.first()->GetPiece();
|
|
||||||
if (piece.isNull())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VPLayoutPtr layout = piece->Layout();
|
|
||||||
if (layout.isNull())
|
if (layout.isNull())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QList<VPGraphicsPiece *> &graphicsPieces = sheet->SceneData()->GraphicsPieces();
|
||||||
|
|
||||||
|
if (graphicsPieces.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VPPiecePtr piece = graphicsPieces.first()->GetPiece();
|
||||||
|
if (piece.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto PreparePieces = [this]()
|
auto PreparePieces = [this]()
|
||||||
{
|
{
|
||||||
QList<VPPiecePtr> pieces;
|
QList<VPPiecePtr> pieces;
|
||||||
|
@ -693,7 +639,7 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
|
||||||
m_hasStickyPosition = false;
|
m_hasStickyPosition = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VPGraphicsPiece *gPiece = ScenePiece(p);
|
VPGraphicsPiece *gPiece = sheet->SceneData()->ScenePiece(p);
|
||||||
if (gPiece != nullptr)
|
if (gPiece != nullptr)
|
||||||
{
|
{
|
||||||
gPiece->SetStickyPoints(path);
|
gPiece->SetStickyPoints(path);
|
||||||
|
@ -710,38 +656,66 @@ void VPMainGraphicsView::TranslatePiecesOn(qreal dx, qreal dy)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VPMainGraphicsView::ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *
|
void VPMainGraphicsView::SwitchScene(const VPSheetPtr &sheet)
|
||||||
{
|
{
|
||||||
VPGraphicsPiece *_graphicsPiece = nullptr;
|
if (not sheet.isNull())
|
||||||
for(auto *graphicPiece : m_graphicsPieces)
|
|
||||||
{
|
{
|
||||||
if(graphicPiece->GetPiece() == piece)
|
VMainGraphicsScene *scene = sheet->SceneData()->Scene();
|
||||||
{
|
setScene(scene);
|
||||||
_graphicsPiece = graphicPiece;
|
connect(scene, &VMainGraphicsScene::ItemClicked, this, &VPMainGraphicsView::on_ItemClicked,
|
||||||
}
|
Qt::UniqueConnection);
|
||||||
|
connect(scene, &VMainGraphicsScene::mouseMove, this, &VPMainGraphicsView::on_SceneMouseMove,
|
||||||
|
Qt::UniqueConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
return _graphicsPiece;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPMainGraphicsView::on_PieceSheetChanged(const VPPiecePtr &piece)
|
void VPMainGraphicsView::ClearSelection()
|
||||||
{
|
{
|
||||||
VPGraphicsPiece *graphicsPiece = ScenePiece(piece);
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
|
|
||||||
VPLayoutPtr layout = piece->Layout();
|
|
||||||
if (layout.isNull())
|
if (layout.isNull())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (piece->Sheet().isNull() || piece->Sheet() == layout->GetTrashSheet() ||
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
piece->Sheet() != layout->GetFocusedSheet()) // remove
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<VPPiecePtr> pieces = sheet->GetSelectedPieces();
|
||||||
|
for (const auto& piece : pieces)
|
||||||
|
{
|
||||||
|
piece->SetSelected(false);
|
||||||
|
emit layout->PieceSelectionChanged(piece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPMainGraphicsView::on_PieceSheetChanged(const VPPiecePtr &piece)
|
||||||
|
{
|
||||||
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
|
if (layout.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VPSheetPtr sheet = layout->GetFocusedSheet();
|
||||||
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VPGraphicsPiece *graphicsPiece = sheet->SceneData()->ScenePiece(piece);
|
||||||
|
|
||||||
|
if (piece != nullptr && (piece->Sheet().isNull() || piece->Sheet() == layout->GetTrashSheet() ||
|
||||||
|
piece->Sheet() != layout->GetFocusedSheet())) // remove
|
||||||
{
|
{
|
||||||
if (graphicsPiece != nullptr)
|
if (graphicsPiece != nullptr)
|
||||||
{
|
{
|
||||||
scene()->removeItem(graphicsPiece);
|
sheet->SceneData()->Scene()->removeItem(graphicsPiece);
|
||||||
m_graphicsPieces.removeAll(graphicsPiece);
|
sheet->SceneData()->RemovePiece(graphicsPiece);
|
||||||
delete graphicsPiece;
|
delete graphicsPiece;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -750,13 +724,24 @@ void VPMainGraphicsView::on_PieceSheetChanged(const VPPiecePtr &piece)
|
||||||
if(graphicsPiece == nullptr)
|
if(graphicsPiece == nullptr)
|
||||||
{
|
{
|
||||||
graphicsPiece = new VPGraphicsPiece(piece);
|
graphicsPiece = new VPGraphicsPiece(piece);
|
||||||
m_graphicsPieces.append(graphicsPiece);
|
sheet->SceneData()->AddPiece(graphicsPiece);
|
||||||
ConnectPiece(graphicsPiece);
|
|
||||||
}
|
}
|
||||||
scene()->addItem(graphicsPiece);
|
sheet->SceneData()->Scene()->addItem(graphicsPiece);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_rotationControls->on_UpdateControls();
|
sheet->SceneData()->RotationControls()->on_UpdateControls();
|
||||||
|
|
||||||
VMainGraphicsView::NewSceneRect(scene(), this);
|
VMainGraphicsView::NewSceneRect(scene(), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPMainGraphicsView::on_ActiveSheetChanged(const VPSheetPtr &focusedSheet)
|
||||||
|
{
|
||||||
|
if (not focusedSheet.isNull())
|
||||||
|
{
|
||||||
|
ClearSelection();
|
||||||
|
SwitchScene(focusedSheet);
|
||||||
|
RefreshLayout();
|
||||||
|
RefreshPieces();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class VPMainGraphicsView : public VMainGraphicsView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VPMainGraphicsView(const VPLayoutPtr &layout, VPTileFactory *tileFactory, QWidget *parent);
|
VPMainGraphicsView(const VPLayoutPtr &layout, QWidget *parent);
|
||||||
~VPMainGraphicsView() = default;
|
~VPMainGraphicsView() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,22 +54,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void RefreshLayout();
|
void RefreshLayout();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief GetScene Returns the scene of the view
|
|
||||||
* @return scene of the view
|
|
||||||
*/
|
|
||||||
auto GetScene() -> VMainGraphicsScene*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief PrepareForExport prepares the graphic for an export (i.e hide margin etc)
|
|
||||||
*/
|
|
||||||
void PrepareForExport();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief CleanAfterExport cleans the graphic for an export (i.e show margin etc)
|
|
||||||
*/
|
|
||||||
void CleanAfterExport();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief on_PieceSheetChanged The slot is called when the given piece was moved from the given piece list to
|
* @brief on_PieceSheetChanged The slot is called when the given piece was moved from the given piece list to
|
||||||
|
@ -78,8 +62,17 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void on_PieceSheetChanged(const VPPiecePtr &piece);
|
void on_PieceSheetChanged(const VPPiecePtr &piece);
|
||||||
|
|
||||||
|
void on_ActiveSheetChanged(const VPSheetPtr &focusedSheet);
|
||||||
|
|
||||||
void RefreshPieces();
|
void RefreshPieces();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
/**
|
||||||
|
* @brief mouseMove send new mouse position.
|
||||||
|
* @param scenePos new mouse position.
|
||||||
|
*/
|
||||||
|
void mouseMove(const QPointF &scenePos);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void dragEnterEvent(QDragEnterEvent *event) override;
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
||||||
void dragMoveEvent(QDragMoveEvent *event) override;
|
void dragMoveEvent(QDragMoveEvent *event) override;
|
||||||
|
@ -96,32 +89,13 @@ protected:
|
||||||
private slots:
|
private slots:
|
||||||
void RestoreOrigin() const;
|
void RestoreOrigin() const;
|
||||||
void on_ItemClicked(QGraphicsItem* item);
|
void on_ItemClicked(QGraphicsItem* item);
|
||||||
|
void on_SceneMouseMove(const QPointF &scenePos);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPMainGraphicsView)
|
Q_DISABLE_COPY(VPMainGraphicsView)
|
||||||
|
|
||||||
VMainGraphicsScene *m_scene;
|
|
||||||
|
|
||||||
VPGraphicsSheet *m_graphicsSheet{nullptr};
|
|
||||||
|
|
||||||
VPGraphicsTileGrid *m_graphicsTileGrid{nullptr};
|
|
||||||
|
|
||||||
VPGraphicsPieceControls *m_rotationControls{nullptr};
|
|
||||||
VPGraphicsTransformationOrigin *m_rotationOrigin{nullptr};
|
|
||||||
|
|
||||||
VPLayoutWeakPtr m_layout;
|
VPLayoutWeakPtr m_layout;
|
||||||
|
|
||||||
QList<VPGraphicsPiece*> m_graphicsPieces{};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* variable to hold temporarly hte value of the show tiles
|
|
||||||
*/
|
|
||||||
bool m_showTilesTmp{false};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* variable to hold temporarly hte value of the show grid
|
|
||||||
*/
|
|
||||||
bool m_showGridTmp{false};
|
|
||||||
bool m_allowChangeMerge{false};
|
bool m_allowChangeMerge{false};
|
||||||
|
|
||||||
qreal m_rotationSum{0};
|
qreal m_rotationSum{0};
|
||||||
|
@ -130,12 +104,11 @@ private:
|
||||||
qreal m_stickyTranslateX{0};
|
qreal m_stickyTranslateX{0};
|
||||||
qreal m_stickyTranslateY{0};
|
qreal m_stickyTranslateY{0};
|
||||||
|
|
||||||
void ConnectPiece(VPGraphicsPiece *piece);
|
|
||||||
|
|
||||||
void RotatePiecesByAngle(qreal angle);
|
void RotatePiecesByAngle(qreal angle);
|
||||||
void TranslatePiecesOn(qreal dx, qreal dy);
|
void TranslatePiecesOn(qreal dx, qreal dy);
|
||||||
|
|
||||||
auto ScenePiece(const VPPiecePtr &piece) const -> VPGraphicsPiece *;
|
void SwitchScene(const VPSheetPtr &sheet);
|
||||||
|
void ClearSelection();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VPMAINGRAPHICSVIEW_H
|
#endif // VPMAINGRAPHICSVIEW_H
|
||||||
|
|
|
@ -1,143 +0,0 @@
|
||||||
#include "vpexporter.h"
|
|
||||||
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QMessageBox>
|
|
||||||
|
|
||||||
#include "../vwidgets/vmaingraphicsscene.h"
|
|
||||||
#include "layout/vpsheet.h"
|
|
||||||
#include "scene/vpmaingraphicsview.h"
|
|
||||||
#include "../vobj/vobjpaintdevice.h"
|
|
||||||
#include "../vdxf/vdxfpaintdevice.h"
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
VPExporter::VPExporter()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
VPExporter::~VPExporter()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VPExporter::Export(VPLayout* layout, LayoutExportFormats format, VPMainGraphicsView *mainGraphicsView)
|
|
||||||
{
|
|
||||||
QString dir = QDir::homePath();
|
|
||||||
QString filters(ExportFormatDescription(format));
|
|
||||||
|
|
||||||
// is it ok to have a null ptr hier as a parent?
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save as"),
|
|
||||||
dir + QLatin1String("/") + layout->GetFocusedSheet()->GetName() + ExportFormatSuffix(format),
|
|
||||||
filters, nullptr
|
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
, QFileDialog::DontUseNativeDialog
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
if(not fileName.isEmpty())
|
|
||||||
{
|
|
||||||
mainGraphicsView->PrepareForExport();
|
|
||||||
|
|
||||||
SetFileName(fileName);
|
|
||||||
|
|
||||||
QSizeF size = QSizeF(layout->GetFocusedSheet()->GetSheetSize());
|
|
||||||
const QRectF rect = QRectF(0, 0, size.width(), size.height());
|
|
||||||
|
|
||||||
SetImageRect(rect);
|
|
||||||
|
|
||||||
switch(format)
|
|
||||||
{
|
|
||||||
case LayoutExportFormats::SVG:
|
|
||||||
ExportToSVG(mainGraphicsView->scene());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LayoutExportFormats::PDF:
|
|
||||||
ExportToPDF(mainGraphicsView->scene());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LayoutExportFormats::TIF:
|
|
||||||
ExportToTIF(mainGraphicsView->scene());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LayoutExportFormats::OBJ:
|
|
||||||
ExportToOBJ(mainGraphicsView->scene());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LayoutExportFormats::PS:
|
|
||||||
ExportToPS(mainGraphicsView->scene());
|
|
||||||
break;
|
|
||||||
|
|
||||||
case LayoutExportFormats::EPS:
|
|
||||||
ExportToEPS(mainGraphicsView->scene());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
// just for test purpuses, to be removed:
|
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setText(QString("TODO VPExporter, Handling for format %1 is still missing.").arg(ExportFormatDescription(format)));
|
|
||||||
int ret = msgBox.exec();
|
|
||||||
Q_UNUSED(ret);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
mainGraphicsView->CleanAfterExport();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QVector<std::pair<QString, LayoutExportFormats> > VPExporter::InitFormats()
|
|
||||||
{
|
|
||||||
QVector<std::pair<QString, LayoutExportFormats>> list;
|
|
||||||
|
|
||||||
auto InitFormat = [&list](LayoutExportFormats format)
|
|
||||||
{
|
|
||||||
list.append(std::make_pair(ExportFormatDescription(format), format));
|
|
||||||
};
|
|
||||||
|
|
||||||
InitFormat(LayoutExportFormats::SVG);
|
|
||||||
InitFormat(LayoutExportFormats::PDF);
|
|
||||||
// InitFormat(LayoutExportFormats::PNG);
|
|
||||||
InitFormat(LayoutExportFormats::TIF);
|
|
||||||
|
|
||||||
InitFormat(LayoutExportFormats::OBJ);
|
|
||||||
|
|
||||||
InitFormat(LayoutExportFormats::PS);
|
|
||||||
InitFormat(LayoutExportFormats::EPS);
|
|
||||||
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1006_Flat);
|
|
||||||
/* InitFormat(LayoutExportFormats::DXF_AC1009_Flat);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1012_Flat);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1014_Flat);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1015_Flat);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1018_Flat);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1021_Flat);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1024_Flat);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1027_Flat);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1006_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1009_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1012_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1014_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1015_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1018_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1021_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1024_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1027_AAMA);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1006_ASTM);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1009_ASTM);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1012_ASTM);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1014_ASTM);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1015_ASTM);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1018_ASTM);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1021_ASTM);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1024_ASTM);
|
|
||||||
InitFormat(LayoutExportFormats::DXF_AC1027_ASTM);*/
|
|
||||||
|
|
||||||
// InitFormat(LayoutExportFormats::PDFTiled);
|
|
||||||
// InitFormat(LayoutExportFormats::NC);
|
|
||||||
// InitFormat(LayoutExportFormats::RLD);
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
#ifndef VPEXPORTER_H
|
|
||||||
#define VPEXPORTER_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include "layout/vplayout.h"
|
|
||||||
#include "../vmisc/def.h"
|
|
||||||
#include "vcommonsettings.h"
|
|
||||||
#include "../vlayout/vlayoutdef.h"
|
|
||||||
#include "../vlayout/vlayoutexporter.h"
|
|
||||||
|
|
||||||
//#include "../dialogs/dialogsavelayout.h"
|
|
||||||
|
|
||||||
class VPMainGraphicsView;
|
|
||||||
|
|
||||||
class VPExporter : VLayoutExporter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VPExporter();
|
|
||||||
~VPExporter();
|
|
||||||
|
|
||||||
void Export(VPLayout* layout, LayoutExportFormats format, VPMainGraphicsView *mainGraphicsView);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief InitFormats
|
|
||||||
* @return returns the list of formats, that we can export in puzzle
|
|
||||||
*/
|
|
||||||
QVector<std::pair<QString, LayoutExportFormats> > InitFormats();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // VPEXPORTER_H
|
|
File diff suppressed because it is too large
Load Diff
|
@ -40,7 +40,6 @@
|
||||||
#include "layout/vppiece.h"
|
#include "layout/vppiece.h"
|
||||||
#include "../vlayout/vlayoutpiece.h"
|
#include "../vlayout/vlayoutpiece.h"
|
||||||
#include "vptilefactory.h"
|
#include "vptilefactory.h"
|
||||||
#include "vpexporter.h"
|
|
||||||
#include "vpcommandline.h"
|
#include "vpcommandline.h"
|
||||||
#include "../vlayout/vlayoutdef.h"
|
#include "../vlayout/vlayoutdef.h"
|
||||||
#include "../vwidgets/vabstractmainwindow.h"
|
#include "../vwidgets/vabstractmainwindow.h"
|
||||||
|
@ -55,6 +54,7 @@ namespace Ui
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
template <typename T> class QSharedPointer;
|
template <typename T> class QSharedPointer;
|
||||||
class DialogPuzzlePreferences;
|
class DialogPuzzlePreferences;
|
||||||
|
struct VPExportData;
|
||||||
|
|
||||||
class VPMainWindow : public VAbstractMainWindow
|
class VPMainWindow : public VAbstractMainWindow
|
||||||
{
|
{
|
||||||
|
@ -221,18 +221,6 @@ private slots:
|
||||||
*/
|
*/
|
||||||
void on_TilesMarginChanged();
|
void on_TilesMarginChanged();
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief on_pushButtonTilesExport_clicked When the export tiles button is clicked
|
|
||||||
*/
|
|
||||||
void on_pushButtonTilesExport_clicked();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief on_pushButtonLayoutExport_clicked When the button
|
|
||||||
* "Export layout" in the layout property is clicked.
|
|
||||||
* The slot is automatically connected through name convention.
|
|
||||||
*/
|
|
||||||
void on_pushButtonSheetExport_clicked();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief CarrouselLocationChanged When the piece carrousel's location
|
* @brief CarrouselLocationChanged When the piece carrousel's location
|
||||||
* has been changed
|
* has been changed
|
||||||
|
@ -272,6 +260,19 @@ private slots:
|
||||||
|
|
||||||
void on_ConvertPaperSize();
|
void on_ConvertPaperSize();
|
||||||
|
|
||||||
|
void on_ExportLayout();
|
||||||
|
void on_ExportSheet();
|
||||||
|
|
||||||
|
void on_actionPrintLayout_triggered();
|
||||||
|
void on_actionPrintPreviewLayout_triggered();
|
||||||
|
void on_actionPrintTiledLayout_triggered();
|
||||||
|
void on_actionPrintPreviewTiledLayout_triggered();
|
||||||
|
|
||||||
|
void on_actionPrintSheet_triggered();
|
||||||
|
void on_actionPrintPreviewSheet_triggered();
|
||||||
|
void on_actionPrintTiledSheet_triggered();
|
||||||
|
void on_actionPrintPreviewTiledSheet_triggered();
|
||||||
|
|
||||||
#if defined(Q_OS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
void AboutToShowDockMenu();
|
void AboutToShowDockMenu();
|
||||||
#endif //defined(Q_OS_MAC)
|
#endif //defined(Q_OS_MAC)
|
||||||
|
@ -289,8 +290,6 @@ private:
|
||||||
|
|
||||||
VPLayoutPtr m_layout;
|
VPLayoutPtr m_layout;
|
||||||
|
|
||||||
VPTileFactory *m_tileFactory{nullptr};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief spin box with the scale factor of the graphic view
|
* @brief spin box with the scale factor of the graphic view
|
||||||
*/
|
*/
|
||||||
|
@ -402,12 +401,6 @@ private:
|
||||||
|
|
||||||
auto MaybeSave() -> bool;
|
auto MaybeSave() -> bool;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief generateTiledPdf Generates the tiled Pdf in the given filename
|
|
||||||
* @param fileName output file name
|
|
||||||
*/
|
|
||||||
void generateTiledPdf(QString fileName);
|
|
||||||
|
|
||||||
void CreateWindowMenu(QMenu *menu);
|
void CreateWindowMenu(QMenu *menu);
|
||||||
|
|
||||||
auto IsLayoutReadOnly() const -> bool;
|
auto IsLayoutReadOnly() const -> bool;
|
||||||
|
@ -443,6 +436,16 @@ private:
|
||||||
void CorrectMaxMargins();
|
void CorrectMaxMargins();
|
||||||
|
|
||||||
void RotatePiecesToGrainline();
|
void RotatePiecesToGrainline();
|
||||||
|
|
||||||
|
void ExportData(const VPExportData &data);
|
||||||
|
void ExportApparelLayout(const VPExportData &data, const QVector<VLayoutPiece> &details, const QString &name,
|
||||||
|
const QSize &size) const;
|
||||||
|
void ExportFlatLayout(const VPExportData &data);
|
||||||
|
void ExportScene(const VPExportData &data);
|
||||||
|
void ExportUnifiedPdfFile(const VPExportData &data);
|
||||||
|
void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name);
|
||||||
|
void ExportPdfTiledFile(const VPExportData &data);
|
||||||
|
void GeneratePdfTiledFile(const VPSheetPtr &sheet, QPainter *painter, QPrinter *printer, bool firstSheet);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VPMAINWINDOW_H
|
#endif // VPMAINWINDOW_H
|
||||||
|
|
|
@ -57,12 +57,19 @@
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionExit"/>
|
<addaction name="actionExit"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuEdit">
|
<widget class="QMenu" name="menuSheet">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Edit</string>
|
<string>&Sheet</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionAddSheet"/>
|
<addaction name="actionAddSheet"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionPrintSheet"/>
|
||||||
|
<addaction name="actionPrintPreviewSheet"/>
|
||||||
|
<addaction name="actionPrintTiledSheet"/>
|
||||||
|
<addaction name="actionPrintPreviewTiledSheet"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionExportSheet"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuWindow">
|
<widget class="QMenu" name="menuWindow">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
@ -77,8 +84,20 @@
|
||||||
<addaction name="actionAboutQt"/>
|
<addaction name="actionAboutQt"/>
|
||||||
<addaction name="actionAboutPuzzle"/>
|
<addaction name="actionAboutPuzzle"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QMenu" name="menuLayout">
|
||||||
|
<property name="title">
|
||||||
|
<string>&Layout</string>
|
||||||
|
</property>
|
||||||
|
<addaction name="actionPrintLayout"/>
|
||||||
|
<addaction name="actionPrintPreviewLayout"/>
|
||||||
|
<addaction name="actionPrintTiledLayout"/>
|
||||||
|
<addaction name="actionPrintPreviewTiledLayout"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
|
<addaction name="actionExportLayout"/>
|
||||||
|
</widget>
|
||||||
<addaction name="menuFile"/>
|
<addaction name="menuFile"/>
|
||||||
<addaction name="menuEdit"/>
|
<addaction name="menuLayout"/>
|
||||||
|
<addaction name="menuSheet"/>
|
||||||
<addaction name="menuWindow"/>
|
<addaction name="menuWindow"/>
|
||||||
<addaction name="menuHelp"/>
|
<addaction name="menuHelp"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -1504,22 +1523,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="groupBoxTilesExport">
|
|
||||||
<property name="title">
|
|
||||||
<string>Export</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_20">
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButtonTilesExport">
|
|
||||||
<property name="text">
|
|
||||||
<string>Export Tiled Pdf</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacerTiles">
|
<spacer name="verticalSpacerTiles">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -1770,6 +1773,9 @@
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+O</string>
|
<string>Ctrl+O</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSave">
|
<action name="actionSave">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
|
@ -1785,6 +1791,9 @@
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+S</string>
|
<string>Ctrl+S</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionSaveAs">
|
<action name="actionSaveAs">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
|
@ -1800,6 +1809,9 @@
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+Shift+S</string>
|
<string>Ctrl+Shift+S</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionImportRawLayout">
|
<action name="actionImportRawLayout">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
|
@ -1838,6 +1850,9 @@
|
||||||
<property name="shortcut">
|
<property name="shortcut">
|
||||||
<string>Ctrl+N</string>
|
<string>Ctrl+N</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAboutQt">
|
<action name="actionAboutQt">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -1931,11 +1946,129 @@
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Preferences</string>
|
<string>Preferences</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::PreferencesRole</enum>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAddSheet">
|
<action name="actionAddSheet">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add Sheet</string>
|
<string>Add Sheet</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrintLayout">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-print">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrintPreviewLayout">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-print-preview">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print preview</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrintTiledLayout">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-print">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print tiled</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrintPreviewTiledLayout">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-print-preview">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print preview tiled</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionExportLayout">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrintSheet">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-print">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrintPreviewSheet">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-print-preview">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print preview</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrintTiledSheet">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-print">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print tiled</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionPrintPreviewTiledSheet">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-print-preview">
|
||||||
|
<normaloff>.</normaloff>.</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Print preview tiled</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionExportSheet">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuRole">
|
||||||
|
<enum>QAction::ApplicationSpecificRole</enum>
|
||||||
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
@ -1953,7 +2086,6 @@
|
||||||
<tabstop>lineEditSheetName</tabstop>
|
<tabstop>lineEditSheetName</tabstop>
|
||||||
<tabstop>pushButtonSheetExport</tabstop>
|
<tabstop>pushButtonSheetExport</tabstop>
|
||||||
<tabstop>checkBoxTilesShowTiles</tabstop>
|
<tabstop>checkBoxTilesShowTiles</tabstop>
|
||||||
<tabstop>pushButtonTilesExport</tabstop>
|
|
||||||
<tabstop>lineEditLayoutName</tabstop>
|
<tabstop>lineEditLayoutName</tabstop>
|
||||||
<tabstop>plainTextEditLayoutDescription</tabstop>
|
<tabstop>plainTextEditLayoutDescription</tabstop>
|
||||||
<tabstop>checkBoxLayoutWarningPiecesSuperposition</tabstop>
|
<tabstop>checkBoxLayoutWarningPiecesSuperposition</tabstop>
|
||||||
|
|
|
@ -50,6 +50,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutWarningPiecesOutOfBound,
|
||||||
(QLatin1String("layout/warningPiecesOutOfBound")))
|
(QLatin1String("layout/warningPiecesOutOfBound")))
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline")))
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutFollowGrainline, (QLatin1String("layout/followGrainline")))
|
||||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, (QLatin1String("layout/pieceGap")))
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutPieceGap, (QLatin1String("layout/pieceGap")))
|
||||||
|
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingLayoutExportFormat, (QLatin1String("layout/exportFormat")))
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QMarginsF)
|
Q_DECLARE_METATYPE(QMarginsF)
|
||||||
|
@ -290,3 +291,15 @@ auto VPSettings::GetLayoutPieceGap() const -> qreal
|
||||||
{
|
{
|
||||||
return ValueOrDef<qreal>(*this, *settingLayoutPieceGap, UnitConvertor(5, Unit::Mm, Unit::Px));
|
return ValueOrDef<qreal>(*this, *settingLayoutPieceGap, UnitConvertor(5, Unit::Mm, Unit::Px));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
qint8 VPSettings::GetLayoutExportFormat() const
|
||||||
|
{
|
||||||
|
return qvariant_cast<qint8>(value(*settingLayoutExportFormat, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPSettings::SetLayoutExportFormat(qint8 format)
|
||||||
|
{
|
||||||
|
setValue(*settingLayoutExportFormat, format);
|
||||||
|
}
|
||||||
|
|
|
@ -94,6 +94,9 @@ public:
|
||||||
void SetLayoutPieceGap(qreal value);
|
void SetLayoutPieceGap(qreal value);
|
||||||
auto GetLayoutPieceGap() const -> qreal;
|
auto GetLayoutPieceGap() const -> qreal;
|
||||||
|
|
||||||
|
auto GetLayoutExportFormat() const -> qint8;
|
||||||
|
void SetLayoutExportFormat(qint8 format);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPSettings)
|
Q_DISABLE_COPY(VPSettings)
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,13 +7,14 @@
|
||||||
#include "scene/vpmaingraphicsview.h"
|
#include "scene/vpmaingraphicsview.h"
|
||||||
#include "../vmisc/def.h"
|
#include "../vmisc/def.h"
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
|
#include "../vlayout/vprintlayout.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonSettings):
|
VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonSettings):
|
||||||
m_layout(layout),
|
m_layout(layout),
|
||||||
m_commonSettings(commonSettings)
|
m_commonSettings(commonSettings),
|
||||||
|
m_infoStripeWidth(UnitConvertor(1, Unit::Cm, Unit::Px))
|
||||||
{
|
{
|
||||||
m_infoStripeWidth = UnitConvertor(1, Unit::Cm, Unit::Px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -48,34 +49,53 @@ void VPTileFactory::refreshTileInfos()
|
||||||
{
|
{
|
||||||
m_drawingAreaWidth += m_infoStripeWidth;
|
m_drawingAreaWidth += m_infoStripeWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF sheetSize;
|
|
||||||
VPSheetPtr sheet = layout->GetFocusedSheet();
|
|
||||||
if (not sheet.isNull())
|
|
||||||
{
|
|
||||||
sheetSize = sheet->GetSheetSize();
|
|
||||||
}
|
|
||||||
m_nbCol = qCeil(sheetSize.width()/m_drawingAreaWidth);
|
|
||||||
m_nbRow = qCeil(sheetSize.height()/m_drawingAreaHeight);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView, int row, int col)
|
void VPTileFactory::drawTile(QPainter *painter, QPrinter *printer, const VPSheetPtr &sheet, int row, int col)
|
||||||
{
|
{
|
||||||
|
SCASSERT(painter != nullptr)
|
||||||
|
SCASSERT(printer != nullptr)
|
||||||
|
|
||||||
VPLayoutPtr layout = m_layout.toStrongRef();
|
VPLayoutPtr layout = m_layout.toStrongRef();
|
||||||
if(layout.isNull())
|
if(layout.isNull())
|
||||||
{
|
{
|
||||||
return
|
return;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int nbCol = ColNb(sheet);
|
||||||
|
const int nbRow = RowNb(sheet);
|
||||||
|
|
||||||
|
if (row < 0 || row > nbRow || col < 0 || col > nbCol)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QMarginsF tilesMargins = layout->LayoutSettings().GetTilesMargins();
|
QMarginsF tilesMargins = layout->LayoutSettings().GetTilesMargins();
|
||||||
QPen penTileInfos = QPen(QColor(180,180,180), m_commonSettings->WidthHairLine(), Qt::DashLine, Qt::RoundCap,
|
QPen penTileInfos = QPen(QColor(180,180,180), m_commonSettings->WidthHairLine(), Qt::DashLine, Qt::RoundCap,
|
||||||
Qt::RoundJoin);
|
Qt::RoundJoin);
|
||||||
QPen penTileDrawing = QPen(Qt::black, m_commonSettings->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
|
QPen penTileDrawing = QPen(Qt::black, m_commonSettings->WidthMainLine(), Qt::SolidLine, Qt::RoundCap,
|
||||||
Qt::RoundJoin);
|
Qt::RoundJoin);
|
||||||
|
|
||||||
QSvgRenderer* svgRenderer = new QSvgRenderer();
|
// paint the content of the page
|
||||||
|
QRectF source = QRectF(col*m_drawingAreaWidth,
|
||||||
|
row*m_drawingAreaHeight,
|
||||||
|
m_drawingAreaWidth + m_infoStripeWidth,
|
||||||
|
m_drawingAreaHeight + m_infoStripeWidth
|
||||||
|
);
|
||||||
|
|
||||||
|
painter->setPen(penTileDrawing);
|
||||||
|
|
||||||
|
sheet->SceneData()->Scene()->render(painter, VPrintLayout::SceneTargetRect(printer, source), source,
|
||||||
|
Qt::IgnoreAspectRatio);
|
||||||
|
|
||||||
|
QScopedPointer<QSvgRenderer> svgRenderer(new QSvgRenderer());
|
||||||
|
|
||||||
// ------------- prepare triangles for position marks
|
// ------------- prepare triangles for position marks
|
||||||
QRectF rectBasic = QRectF(-UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
QRectF rectBasic = QRectF(-UnitConvertor(0.5, Unit::Cm, Unit::Px),
|
||||||
|
@ -91,7 +111,6 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
|
|
||||||
QBrush triangleBush = QBrush(QColor(200,200,200));
|
QBrush triangleBush = QBrush(QColor(200,200,200));
|
||||||
|
|
||||||
|
|
||||||
// add the tiles decorations (cutting and gluing lines, scissors, infos etc.)
|
// add the tiles decorations (cutting and gluing lines, scissors, infos etc.)
|
||||||
painter->setPen(penTileInfos);
|
painter->setPen(penTileInfos);
|
||||||
|
|
||||||
|
@ -107,19 +126,17 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
// scissors along the top line
|
// scissors along the top line
|
||||||
svgRenderer->load(QStringLiteral("://puzzleicon/svg/icon_scissors_horizontal.svg"));
|
svgRenderer->load(QStringLiteral("://puzzleicon/svg/icon_scissors_horizontal.svg"));
|
||||||
svgRenderer->render(painter, QRectF(tilesMargins.left() + m_drawingAreaWidth,
|
svgRenderer->render(painter, QRectF(tilesMargins.left() + m_drawingAreaWidth,
|
||||||
tilesMargins.top(),
|
tilesMargins.top(),
|
||||||
UnitConvertor(1, Unit::Cm, Unit::Px),
|
UnitConvertor(1, Unit::Cm, Unit::Px),
|
||||||
UnitConvertor(0.56, Unit::Cm, Unit::Px)
|
UnitConvertor(0.56, Unit::Cm, Unit::Px)));
|
||||||
));
|
|
||||||
|
|
||||||
// dashed top line (for cutting)
|
// dashed top line (for cutting)
|
||||||
penTileInfos.setStyle(Qt::DashLine);
|
penTileInfos.setStyle(Qt::DashLine);
|
||||||
painter->setPen(penTileInfos);
|
painter->setPen(penTileInfos);
|
||||||
painter->drawLine(QPointF(tilesMargins.left(),
|
painter->drawLine(QPointF(tilesMargins.left(),
|
||||||
tilesMargins.top()),
|
tilesMargins.top()),
|
||||||
QPointF(tilesMargins.left() + m_drawingAreaWidth + m_infoStripeWidth,
|
QPointF(tilesMargins.left() + m_drawingAreaWidth + m_infoStripeWidth,
|
||||||
tilesMargins.top())
|
tilesMargins.top()));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -127,10 +144,9 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
penTileInfos.setStyle(Qt::SolidLine);
|
penTileInfos.setStyle(Qt::SolidLine);
|
||||||
painter->setPen(penTileInfos);
|
painter->setPen(penTileInfos);
|
||||||
painter->drawLine(QPointF(tilesMargins.left(),
|
painter->drawLine(QPointF(tilesMargins.left(),
|
||||||
tilesMargins.top()),
|
tilesMargins.top()),
|
||||||
QPointF(tilesMargins.left() + m_drawingAreaWidth + ((col < m_nbCol-1)? m_infoStripeWidth : 0),
|
QPointF(tilesMargins.left() + m_drawingAreaWidth + ((col < nbCol-1)? m_infoStripeWidth : 0),
|
||||||
tilesMargins.top())
|
tilesMargins.top()));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(col > 0)
|
if(col > 0)
|
||||||
|
@ -168,11 +184,11 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
painter->drawLine(QPointF(tilesMargins.left(),
|
painter->drawLine(QPointF(tilesMargins.left(),
|
||||||
tilesMargins.top()),
|
tilesMargins.top()),
|
||||||
QPointF(tilesMargins.left(),
|
QPointF(tilesMargins.left(),
|
||||||
tilesMargins.top() + m_drawingAreaHeight + ((row < m_nbRow-1)? m_infoStripeWidth : 0))
|
tilesMargins.top() + m_drawingAreaHeight + ((row < nbRow-1)? m_infoStripeWidth : 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(row < m_nbRow-1)
|
if(row < nbRow-1)
|
||||||
{
|
{
|
||||||
// add bottom triangle
|
// add bottom triangle
|
||||||
QPainterPath triangleBottom =
|
QPainterPath triangleBottom =
|
||||||
|
@ -191,19 +207,20 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
QPointF(tilesMargins.left() + m_drawingAreaWidth + m_infoStripeWidth,
|
QPointF(tilesMargins.left() + m_drawingAreaWidth + m_infoStripeWidth,
|
||||||
tilesMargins.top() + m_drawingAreaHeight)
|
tilesMargins.top() + m_drawingAreaHeight)
|
||||||
);
|
);
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// solid bottom line at the edge
|
// solid bottom line at the edge
|
||||||
penTileInfos.setStyle(Qt::SolidLine);
|
penTileInfos.setStyle(Qt::SolidLine);
|
||||||
painter->setPen(penTileInfos);
|
painter->setPen(penTileInfos);
|
||||||
painter->drawLine(QPointF(tilesMargins.left(),
|
painter->drawLine(QPointF(tilesMargins.left(),
|
||||||
tilesMargins.top() + m_drawingAreaHeight),
|
tilesMargins.top() + m_drawingAreaHeight),
|
||||||
QPointF(tilesMargins.left() + m_drawingAreaWidth + ((col < m_nbCol-1)? m_infoStripeWidth : 0),
|
QPointF(tilesMargins.left() + m_drawingAreaWidth + ((col < nbCol-1)? m_infoStripeWidth : 0),
|
||||||
tilesMargins.top() + m_drawingAreaHeight)
|
tilesMargins.top() + m_drawingAreaHeight)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(col < m_nbCol-1)
|
if(col < nbCol-1)
|
||||||
{
|
{
|
||||||
// add right triangle
|
// add right triangle
|
||||||
QPainterPath triangleRight =
|
QPainterPath triangleRight =
|
||||||
|
@ -230,25 +247,10 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
painter->drawLine(QPointF(tilesMargins.left() + m_drawingAreaWidth,
|
painter->drawLine(QPointF(tilesMargins.left() + m_drawingAreaWidth,
|
||||||
tilesMargins.top()),
|
tilesMargins.top()),
|
||||||
QPointF(tilesMargins.left() + m_drawingAreaWidth,
|
QPointF(tilesMargins.left() + m_drawingAreaWidth,
|
||||||
tilesMargins.top()+ m_drawingAreaHeight + ((row < m_nbRow-1) ? m_infoStripeWidth : 0))
|
tilesMargins.top()+ m_drawingAreaHeight + ((row < nbRow-1) ? m_infoStripeWidth : 0))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// paint the content of the page
|
|
||||||
QRectF source = QRectF(col*m_drawingAreaWidth,
|
|
||||||
row*m_drawingAreaHeight,
|
|
||||||
m_drawingAreaWidth + m_infoStripeWidth,
|
|
||||||
m_drawingAreaHeight + m_infoStripeWidth
|
|
||||||
);
|
|
||||||
QRectF target = QRectF(tilesMargins.left(),
|
|
||||||
tilesMargins.top(),
|
|
||||||
source.width(),
|
|
||||||
source.height()
|
|
||||||
);
|
|
||||||
|
|
||||||
painter->setPen(penTileDrawing);
|
|
||||||
graphicsView->GetScene()->render(painter, target, source, Qt::IgnoreAspectRatio);
|
|
||||||
|
|
||||||
// prepare the painting for the text information
|
// prepare the painting for the text information
|
||||||
QTextDocument td;
|
QTextDocument td;
|
||||||
td.setPageSize(QSizeF(
|
td.setPageSize(QSizeF(
|
||||||
|
@ -274,15 +276,20 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
||||||
// paint the page information
|
// paint the page information
|
||||||
const QString page = tr("Page %1 of %2").arg(row*m_nbCol+col+1).arg(m_nbCol*m_nbRow);
|
const QString page = tr("Page %1 of %2").arg(row*nbCol+col+1).arg(nbCol*nbRow);
|
||||||
|
|
||||||
td.setPageSize(QSizeF(m_drawingAreaHeight - UnitConvertor(2, Unit::Cm, Unit::Px), m_drawingAreaWidth));
|
td.setPageSize(QSizeF(m_drawingAreaHeight - UnitConvertor(2, Unit::Cm, Unit::Px), m_drawingAreaWidth));
|
||||||
|
|
||||||
|
QFontMetrics metrix = QFontMetrics(td.defaultFont());
|
||||||
|
QString clippedSheetName = metrix.elidedText(sheet->GetName(), Qt::ElideMiddle,
|
||||||
|
metrix.width(QString().fill('z', 50)));
|
||||||
|
|
||||||
td.setHtml(QString("<table width='100%' style='color:rgb(180,180,180);'>"
|
td.setHtml(QString("<table width='100%' style='color:rgb(180,180,180);'>"
|
||||||
"<tr>"
|
"<tr>"
|
||||||
"<td align='center'>%1 - %2</td>"
|
"<td align='center'>%1 - %2</td>"
|
||||||
"</tr>"
|
"</tr>"
|
||||||
"</table>")
|
"</table>")
|
||||||
.arg(page).arg(layout->GetFocusedSheet()->GetName()));
|
.arg(page).arg(clippedSheetName));
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->rotate(-90);
|
painter->rotate(-90);
|
||||||
painter->translate(QPointF(-(m_drawingAreaHeight+tilesMargins.top()) + UnitConvertor(1, Unit::Cm, Unit::Px),
|
painter->translate(QPointF(-(m_drawingAreaHeight+tilesMargins.top()) + UnitConvertor(1, Unit::Cm, Unit::Px),
|
||||||
|
@ -290,29 +297,38 @@ void VPTileFactory::drawTile(QPainter *painter, VPMainGraphicsView *graphicsView
|
||||||
));
|
));
|
||||||
td.drawContents(painter);
|
td.drawContents(painter);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VPTileFactory::getRowNb()
|
auto VPTileFactory::RowNb(const VPSheetPtr &sheet) const -> int
|
||||||
{
|
{
|
||||||
return m_nbRow;
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
QSizeF sheetSize = sheet->GetSheetSize();
|
||||||
|
return qCeil(sheetSize.height() / m_drawingAreaHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
int VPTileFactory::getColNb()
|
auto VPTileFactory::ColNb(const VPSheetPtr &sheet) const -> int
|
||||||
{
|
{
|
||||||
return m_nbCol;
|
if (sheet.isNull())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
QSizeF sheetSize = sheet->GetSheetSize();
|
||||||
|
return qCeil(sheetSize.width() / m_drawingAreaWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal VPTileFactory::getDrawingAreaHeight()
|
auto VPTileFactory::DrawingAreaHeight() const -> qreal
|
||||||
{
|
{
|
||||||
return m_drawingAreaHeight;
|
return m_drawingAreaHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
qreal VPTileFactory::getDrawingAreaWidth()
|
auto VPTileFactory::DrawingAreaWidth() const -> qreal
|
||||||
{
|
{
|
||||||
return m_drawingAreaWidth;
|
return m_drawingAreaWidth;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
|
|
||||||
#include "layout/vplayout.h"
|
#include "layout/vplayout.h"
|
||||||
|
|
||||||
class VPMainGraphicsView;
|
class QGraphicsScene;
|
||||||
class VCommonSettings;
|
class VCommonSettings;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
|
@ -54,36 +54,36 @@ public:
|
||||||
* @param row current row
|
* @param row current row
|
||||||
* @param col current column
|
* @param col current column
|
||||||
*/
|
*/
|
||||||
void drawTile(QPainter *painter, VPMainGraphicsView *graphicsView, int row, int col);
|
void drawTile(QPainter *painter, QPrinter *printer, const VPSheetPtr &sheet, int row, int col);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief refreshTileInfos Resfreshes the tile infos (m_nbCol, m_nbRow, m_drawingAreaHeight, m_drawingAreaWidth)
|
* @brief refreshTileInfos Resfreshes the tile infos (m_drawingAreaHeight, m_drawingAreaWidth)
|
||||||
*/
|
*/
|
||||||
void refreshTileInfos();
|
void refreshTileInfos();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getRowNb Returns the number of row pages
|
* @brief RowNb Returns the number of row pages
|
||||||
* @return number of row pages
|
* @return number of row pages
|
||||||
*/
|
*/
|
||||||
int getRowNb();
|
auto RowNb(const VPSheetPtr &sheet) const -> int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getColNb Returns the number of col pages
|
* @brief ColNb Returns the number of col pages
|
||||||
* @return number of col pages
|
* @return number of col pages
|
||||||
*/
|
*/
|
||||||
int getColNb();
|
auto ColNb(const VPSheetPtr &sheet) const -> int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getDrawingAreaHeight Returns the usable height of the tile in Px
|
* @brief DrawingAreaHeight Returns the usable height of the tile in Px
|
||||||
* @return usable height of the tile in Px
|
* @return usable height of the tile in Px
|
||||||
*/
|
*/
|
||||||
qreal getDrawingAreaHeight();
|
auto DrawingAreaHeight() const -> qreal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief getDrawingAreaWidth Returns the usable width of the tile in Px
|
* @brief DrawingAreaWidth Returns the usable width of the tile in Px
|
||||||
* @return usable width of the tile in Px
|
* @return usable width of the tile in Px
|
||||||
*/
|
*/
|
||||||
qreal getDrawingAreaWidth();
|
auto DrawingAreaWidth() const -> qreal;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPTileFactory)
|
Q_DISABLE_COPY(VPTileFactory)
|
||||||
|
@ -91,16 +91,6 @@ private:
|
||||||
VPLayoutWeakPtr m_layout;
|
VPLayoutWeakPtr m_layout;
|
||||||
VCommonSettings *m_commonSettings{nullptr};
|
VCommonSettings *m_commonSettings{nullptr};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief m_nbCol the number of column-pages for the current sheet of the layout
|
|
||||||
*/
|
|
||||||
int m_nbCol{0};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief m_nbRow the number of row-pages for the current sheet of the layout
|
|
||||||
*/
|
|
||||||
int m_nbRow{0};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief m_drawingAreaHeight the height of the drawing area
|
* @brief m_drawingAreaHeight the height of the drawing area
|
||||||
*/
|
*/
|
||||||
|
@ -114,7 +104,7 @@ private:
|
||||||
/**
|
/**
|
||||||
* @brief m_infoStripeWidth the width of the info / glueing stripe in Px
|
* @brief m_infoStripeWidth the width of the info / glueing stripe in Px
|
||||||
*/
|
*/
|
||||||
qreal m_infoStripeWidth{0};
|
qreal m_infoStripeWidth;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -69,8 +69,7 @@ DialogSaveLayout::DialogSaveLayout(int count, Draw mode, const QString &fileName
|
||||||
ui->lineEditPath->setClearButtonEnabled(true);
|
ui->lineEditPath->setClearButtonEnabled(true);
|
||||||
ui->lineEditFileName->setClearButtonEnabled(true);
|
ui->lineEditFileName->setClearButtonEnabled(true);
|
||||||
|
|
||||||
VAbstractValApplication::VApp()->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale())
|
VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||||
: setLocale(QLocale::c());
|
|
||||||
|
|
||||||
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
SCASSERT(bOk != nullptr)
|
SCASSERT(bOk != nullptr)
|
||||||
|
|
|
@ -1172,55 +1172,55 @@ void MainWindowsNoGUI::ExportScene(const QList<QGraphicsScene *> &scenes,
|
||||||
case LayoutExportFormats::DXF_AC1006_Flat:
|
case LayoutExportFormats::DXF_AC1006_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1006);
|
exporter.SetDxfVersion(DRW::AC1006);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::DXF_AC1009_Flat:
|
case LayoutExportFormats::DXF_AC1009_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1009);
|
exporter.SetDxfVersion(DRW::AC1009);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::DXF_AC1012_Flat:
|
case LayoutExportFormats::DXF_AC1012_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1012);
|
exporter.SetDxfVersion(DRW::AC1012);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::DXF_AC1014_Flat:
|
case LayoutExportFormats::DXF_AC1014_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1014);
|
exporter.SetDxfVersion(DRW::AC1014);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::DXF_AC1015_Flat:
|
case LayoutExportFormats::DXF_AC1015_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1015);
|
exporter.SetDxfVersion(DRW::AC1015);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::DXF_AC1018_Flat:
|
case LayoutExportFormats::DXF_AC1018_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1018);
|
exporter.SetDxfVersion(DRW::AC1018);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::DXF_AC1021_Flat:
|
case LayoutExportFormats::DXF_AC1021_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1021);
|
exporter.SetDxfVersion(DRW::AC1021);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::DXF_AC1024_Flat:
|
case LayoutExportFormats::DXF_AC1024_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1024);
|
exporter.SetDxfVersion(DRW::AC1024);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::DXF_AC1027_Flat:
|
case LayoutExportFormats::DXF_AC1027_Flat:
|
||||||
paper->setVisible(false);
|
paper->setVisible(false);
|
||||||
exporter.SetDxfVersion(DRW::AC1027);
|
exporter.SetDxfVersion(DRW::AC1027);
|
||||||
exporter.ExportToFlatDXF(scene, details);
|
exporter.ExportToFlatDXF(scene, details.at(i));
|
||||||
paper->setVisible(true);
|
paper->setVisible(true);
|
||||||
break;
|
break;
|
||||||
case LayoutExportFormats::TIF:
|
case LayoutExportFormats::TIF:
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "vrawlayout.h"
|
#include "vrawlayout.h"
|
||||||
#include "../vmisc/vabstractvalapplication.h"
|
#include "../vmisc/vabstractvalapplication.h"
|
||||||
#include "../ifc/exception/vexception.h"
|
#include "../ifc/exception/vexception.h"
|
||||||
|
#include "vprintlayout.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -66,21 +67,18 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, PDFTOPS, (QLatin1String("pdftops")))
|
||||||
*
|
*
|
||||||
* @param placeholder placeholder that will be appended to each QGraphicsSimpleTextItem item's text string.
|
* @param placeholder placeholder that will be appended to each QGraphicsSimpleTextItem item's text string.
|
||||||
*/
|
*/
|
||||||
void PrepareTextForDXF(const QString &placeholder, const QList<QList<QGraphicsItem *> > &details)
|
void PrepareTextForDXF(const QString &placeholder, const QList<QGraphicsItem *> &paperItems)
|
||||||
{
|
{
|
||||||
for (const auto &paperItems : details)
|
for (auto *item : paperItems)
|
||||||
{
|
{
|
||||||
for (auto *item : paperItems)
|
QList<QGraphicsItem *> pieceChildren = item->childItems();
|
||||||
|
for (auto *child : qAsConst(pieceChildren))
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> pieceChildren = item->childItems();
|
if (child->type() == QGraphicsSimpleTextItem::Type)
|
||||||
for (auto *child : qAsConst(pieceChildren))
|
|
||||||
{
|
{
|
||||||
if (child->type() == QGraphicsSimpleTextItem::Type)
|
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
|
||||||
{
|
{
|
||||||
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
|
textItem->setText(textItem->text() + placeholder);
|
||||||
{
|
|
||||||
textItem->setText(textItem->text() + placeholder);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,23 +94,20 @@ void PrepareTextForDXF(const QString &placeholder, const QList<QList<QGraphicsIt
|
||||||
*
|
*
|
||||||
* @param placeholder placeholder that will be removed from each QGraphicsSimpleTextItem item's text string.
|
* @param placeholder placeholder that will be removed from each QGraphicsSimpleTextItem item's text string.
|
||||||
*/
|
*/
|
||||||
void RestoreTextAfterDXF(const QString &placeholder, const QList<QList<QGraphicsItem *> > &details)
|
void RestoreTextAfterDXF(const QString &placeholder, const QList<QGraphicsItem *> &paperItems)
|
||||||
{
|
{
|
||||||
for (const auto &paperItems : details)
|
for (auto *item : paperItems)
|
||||||
{
|
{
|
||||||
for (auto *item : paperItems)
|
QList<QGraphicsItem *> pieceChildren = item->childItems();
|
||||||
|
for (auto *child : qAsConst(pieceChildren))
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> pieceChildren = item->childItems();
|
if (child->type() == QGraphicsSimpleTextItem::Type)
|
||||||
for (auto *child : qAsConst(pieceChildren))
|
|
||||||
{
|
{
|
||||||
if (child->type() == QGraphicsSimpleTextItem::Type)
|
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
|
||||||
{
|
{
|
||||||
if(auto *textItem = qgraphicsitem_cast<QGraphicsSimpleTextItem *>(child))
|
QString text = textItem->text();
|
||||||
{
|
text.replace(placeholder, QString());
|
||||||
QString text = textItem->text();
|
textItem->setText(text);
|
||||||
text.replace(placeholder, QString());
|
|
||||||
textItem->setText(text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,46 +204,7 @@ void VLayoutExporter::ExportToTIF(QGraphicsScene *scene) const
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VLayoutExporter::ExportToPDF(QGraphicsScene *scene) const
|
void VLayoutExporter::ExportToPDF(QGraphicsScene *scene) const
|
||||||
{
|
{
|
||||||
QPrinter printer;
|
ExportToPDF(scene, m_fileName);
|
||||||
printer.setCreator(QGuiApplication::applicationDisplayName() + QChar(QChar::Space) +
|
|
||||||
QCoreApplication::applicationVersion());
|
|
||||||
printer.setOutputFormat(QPrinter::PdfFormat);
|
|
||||||
printer.setOutputFileName(m_fileName);
|
|
||||||
printer.setDocName(QFileInfo(m_fileName).fileName());
|
|
||||||
printer.setResolution(static_cast<int>(PrintDPI));
|
|
||||||
printer.setPageOrientation(QPageLayout::Portrait);
|
|
||||||
printer.setFullPage(m_ignorePrinterMargins);
|
|
||||||
|
|
||||||
qreal width = FromPixel(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right(), Unit::Mm);
|
|
||||||
qreal height = FromPixel(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom(), Unit::Mm);
|
|
||||||
|
|
||||||
if (not printer.setPageSize(QPageSize(QSizeF(width, height), QPageSize::Millimeter)))
|
|
||||||
{
|
|
||||||
qWarning() << tr("Cannot set printer page size");
|
|
||||||
}
|
|
||||||
|
|
||||||
const qreal left = FromPixel(m_margins.left(), Unit::Mm);
|
|
||||||
const qreal top = FromPixel(m_margins.top(), Unit::Mm);
|
|
||||||
const qreal right = FromPixel(m_margins.right(), Unit::Mm);
|
|
||||||
const qreal bottom = FromPixel(m_margins.bottom(), Unit::Mm);
|
|
||||||
|
|
||||||
if (not printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter))
|
|
||||||
{
|
|
||||||
qWarning() << tr("Cannot set printer margins");
|
|
||||||
}
|
|
||||||
|
|
||||||
QPainter painter;
|
|
||||||
if (not painter.begin(&printer))
|
|
||||||
{ // failed to open file
|
|
||||||
qCritical() << qUtf8Printable(tr("Can't open file '%1'").arg(m_fileName));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
|
||||||
painter.setPen(m_pen);
|
|
||||||
painter.setBrush(QBrush(Qt::NoBrush));
|
|
||||||
painter.scale(m_xScale, m_yScale);
|
|
||||||
scene->render(&painter, m_imageRect, m_imageRect, Qt::IgnoreAspectRatio);
|
|
||||||
painter.end();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -271,8 +227,9 @@ void VLayoutExporter::ExportToPS(QGraphicsScene *scene) const
|
||||||
QTemporaryFile tmp;
|
QTemporaryFile tmp;
|
||||||
if (tmp.open())
|
if (tmp.open())
|
||||||
{
|
{
|
||||||
ExportToPDF(scene);
|
const QString fileName = m_fileName;
|
||||||
PdfToPs(QStringList{tmp.fileName(), m_fileName});
|
ExportToPDF(scene, tmp.fileName());
|
||||||
|
PdfToPs(QStringList{tmp.fileName(), fileName});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,13 +239,14 @@ void VLayoutExporter::ExportToEPS(QGraphicsScene *scene) const
|
||||||
QTemporaryFile tmp;
|
QTemporaryFile tmp;
|
||||||
if (tmp.open())
|
if (tmp.open())
|
||||||
{
|
{
|
||||||
ExportToPDF(scene);
|
const QString fileName = m_fileName;
|
||||||
PdfToPs(QStringList{QStringLiteral("-eps"), tmp.fileName(), m_fileName});
|
ExportToPDF(scene, tmp.fileName());
|
||||||
|
PdfToPs(QStringList{QStringLiteral("-eps"), tmp.fileName(), fileName});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList<QList<QGraphicsItem *> > &details) const
|
void VLayoutExporter::ExportToFlatDXF(QGraphicsScene *scene, const QList<QGraphicsItem *> &details) const
|
||||||
{
|
{
|
||||||
PrepareTextForDXF(endStringPlaceholder, details);
|
PrepareTextForDXF(endStringPlaceholder, details);
|
||||||
|
|
||||||
|
@ -447,6 +405,53 @@ void VLayoutExporter::PdfToPs(const QStringList ¶ms)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VLayoutExporter::ExportToPDF(QGraphicsScene *scene, const QString &filename) const
|
||||||
|
{
|
||||||
|
QPrinter printer;
|
||||||
|
printer.setCreator(QGuiApplication::applicationDisplayName() + QChar(QChar::Space) +
|
||||||
|
QCoreApplication::applicationVersion());
|
||||||
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
||||||
|
printer.setOutputFileName(filename);
|
||||||
|
printer.setDocName(QFileInfo(filename).fileName());
|
||||||
|
printer.setResolution(static_cast<int>(PrintDPI));
|
||||||
|
printer.setPageOrientation(QPageLayout::Portrait);
|
||||||
|
printer.setFullPage(m_ignorePrinterMargins);
|
||||||
|
|
||||||
|
qreal width = FromPixel(m_imageRect.width() * m_xScale + m_margins.left() + m_margins.right(), Unit::Mm);
|
||||||
|
qreal height = FromPixel(m_imageRect.height() * m_yScale + m_margins.top() + m_margins.bottom(), Unit::Mm);
|
||||||
|
|
||||||
|
if (not printer.setPageSize(QPageSize(QSizeF(width, height), QPageSize::Millimeter)))
|
||||||
|
{
|
||||||
|
qWarning() << tr("Cannot set printer page size");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not m_ignorePrinterMargins)
|
||||||
|
{
|
||||||
|
const qreal left = FromPixel(m_margins.left(), Unit::Mm);
|
||||||
|
const qreal top = FromPixel(m_margins.top(), Unit::Mm);
|
||||||
|
const qreal right = FromPixel(m_margins.right(), Unit::Mm);
|
||||||
|
const qreal bottom = FromPixel(m_margins.bottom(), Unit::Mm);
|
||||||
|
|
||||||
|
if (not printer.setPageMargins(QMarginsF(left, top, right, bottom), QPageLayout::Millimeter))
|
||||||
|
{
|
||||||
|
qWarning() << tr("Cannot set printer margins");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPainter painter;
|
||||||
|
if (not painter.begin(&printer))
|
||||||
|
{ // failed to open file
|
||||||
|
qCritical() << qUtf8Printable(tr("Can't open file '%1'").arg(m_fileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||||
|
painter.setPen(m_pen);
|
||||||
|
painter.setBrush(QBrush(Qt::NoBrush));
|
||||||
|
painter.scale(m_xScale, m_yScale);
|
||||||
|
scene->render(&painter, VPrintLayout::SceneTargetRect(&printer, m_imageRect), m_imageRect, Qt::IgnoreAspectRatio);
|
||||||
|
painter.end();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VLayoutExporter::ExportFormatDescription(LayoutExportFormats format)
|
QString VLayoutExporter::ExportFormatDescription(LayoutExportFormats format)
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
void ExportToOBJ(QGraphicsScene *scene) const;
|
void ExportToOBJ(QGraphicsScene *scene) const;
|
||||||
void ExportToPS(QGraphicsScene *scene) const;
|
void ExportToPS(QGraphicsScene *scene) const;
|
||||||
void ExportToEPS(QGraphicsScene *scene) const;
|
void ExportToEPS(QGraphicsScene *scene) const;
|
||||||
void ExportToFlatDXF(QGraphicsScene *scene, const QList<QList<QGraphicsItem *> > &details) const;
|
void ExportToFlatDXF(QGraphicsScene *scene, const QList<QGraphicsItem *> &details) const;
|
||||||
void ExportToAAMADXF(const QVector<VLayoutPiece> &details) const;
|
void ExportToAAMADXF(const QVector<VLayoutPiece> &details) const;
|
||||||
void ExportToASTMDXF(const QVector<VLayoutPiece> &details) const;
|
void ExportToASTMDXF(const QVector<VLayoutPiece> &details) const;
|
||||||
void ExportToRLD(const QVector<VLayoutPiece> &details) const;
|
void ExportToRLD(const QVector<VLayoutPiece> &details) const;
|
||||||
|
@ -96,6 +96,7 @@ public:
|
||||||
|
|
||||||
static QString ExportFormatDescription(LayoutExportFormats format);
|
static QString ExportFormatDescription(LayoutExportFormats format);
|
||||||
static QString ExportFormatSuffix(LayoutExportFormats format);
|
static QString ExportFormatSuffix(LayoutExportFormats format);
|
||||||
|
static void PdfToPs(const QStringList ¶ms);
|
||||||
|
|
||||||
auto offset() const -> QPointF;
|
auto offset() const -> QPointF;
|
||||||
void SetOffset(const QPointF &newOffset);
|
void SetOffset(const QPointF &newOffset);
|
||||||
|
@ -114,7 +115,7 @@ private:
|
||||||
int m_dxfVersion{0};
|
int m_dxfVersion{0};
|
||||||
QPointF m_offset{};
|
QPointF m_offset{};
|
||||||
|
|
||||||
static void PdfToPs(const QStringList ¶ms);
|
void ExportToPDF(QGraphicsScene *scene, const QString &filename) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -386,14 +386,6 @@ void VPrintLayout::PrintPages(QPrinter *printer)
|
||||||
|
|
||||||
VWatermarkData data = WatermarkData();
|
VWatermarkData data = WatermarkData();
|
||||||
|
|
||||||
// Here we try understand difference between printer's dpi and our.
|
|
||||||
// Get printer rect acording to our dpi.
|
|
||||||
const QRectF printerPageRect(0, 0, ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm),
|
|
||||||
ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm));
|
|
||||||
const QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution());
|
|
||||||
const double xscale = pageRect.width() / printerPageRect.width();
|
|
||||||
const double yscale = pageRect.height() / printerPageRect.height();
|
|
||||||
|
|
||||||
for (int i = 0; i < copyCount; ++i)
|
for (int i = 0; i < copyCount; ++i)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < numPages; ++j)
|
for (int j = 0; j < numPages; ++j)
|
||||||
|
@ -437,24 +429,8 @@ void VPrintLayout::PrintPages(QPrinter *printer)
|
||||||
QRectF source;
|
QRectF source;
|
||||||
m_isTiled ? source = poster->at(index).rect : source = paper->rect();
|
m_isTiled ? source = poster->at(index).rect : source = paper->rect();
|
||||||
|
|
||||||
qreal x;
|
m_layoutScenes.at(paperIndex)->render(&painter, VPrintLayout::SceneTargetRect(printer, source), source,
|
||||||
qreal y;
|
Qt::IgnoreAspectRatio);
|
||||||
if(printer->fullPage())
|
|
||||||
{
|
|
||||||
QPageLayout layout = printer->pageLayout();
|
|
||||||
layout.setUnits(QPageLayout::Millimeter);
|
|
||||||
QMarginsF printerMargins = layout.margins();
|
|
||||||
x = qFloor(ToPixel(printerMargins.left(), Unit::Mm));
|
|
||||||
y = qFloor(ToPixel(printerMargins.top(), Unit::Mm));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
x = 0; y = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF target(x * xscale, y * yscale, source.width() * xscale, source.height() * yscale);
|
|
||||||
|
|
||||||
m_layoutScenes.at(paperIndex)->render(&painter, target, source, Qt::IgnoreAspectRatio);
|
|
||||||
|
|
||||||
if (m_isTiled)
|
if (m_isTiled)
|
||||||
{
|
{
|
||||||
|
@ -762,3 +738,34 @@ auto VPrintLayout::ContinueIfLayoutStale(QWidget *parent) -> int
|
||||||
|
|
||||||
return QMessageBox::Yes;
|
return QMessageBox::Yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QRectF VPrintLayout::SceneTargetRect(QPrinter *printer, const QRectF &source)
|
||||||
|
{
|
||||||
|
SCASSERT(printer != nullptr)
|
||||||
|
|
||||||
|
qreal x;
|
||||||
|
qreal y;
|
||||||
|
if(printer->fullPage())
|
||||||
|
{
|
||||||
|
QPageLayout layout = printer->pageLayout();
|
||||||
|
layout.setUnits(QPageLayout::Millimeter);
|
||||||
|
QMarginsF printerMargins = layout.margins();
|
||||||
|
x = qFloor(ToPixel(printerMargins.left(), Unit::Mm));
|
||||||
|
y = qFloor(ToPixel(printerMargins.top(), Unit::Mm));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = 0; y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Here we try understand difference between printer's dpi and our.
|
||||||
|
// Get printer rect acording to our dpi.
|
||||||
|
const QRectF printerPageRect(0, 0, ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm),
|
||||||
|
ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm));
|
||||||
|
const QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution());
|
||||||
|
const double xscale = pageRect.width() / printerPageRect.width();
|
||||||
|
const double yscale = pageRect.height() / printerPageRect.height();
|
||||||
|
|
||||||
|
return QRectF(x * xscale, y * yscale, source.width() * xscale, source.height() * yscale);
|
||||||
|
}
|
||||||
|
|
|
@ -121,6 +121,7 @@ public:
|
||||||
void CleanLayout();
|
void CleanLayout();
|
||||||
|
|
||||||
static auto ContinueIfLayoutStale(QWidget *parent) -> int;
|
static auto ContinueIfLayoutStale(QWidget *parent) -> int;
|
||||||
|
static auto SceneTargetRect(QPrinter *printer, const QRectF &source) -> QRectF;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void PrintPages (QPrinter *printer);
|
void PrintPages (QPrinter *printer);
|
||||||
|
|
|
@ -793,7 +793,7 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QG
|
||||||
{
|
{
|
||||||
QRectF rect = item->sceneBoundingRect();
|
QRectF rect = item->sceneBoundingRect();
|
||||||
const QList<QGraphicsItem *> children = item->childItems();
|
const QList<QGraphicsItem *> children = item->childItems();
|
||||||
for (auto child : children)
|
for (auto *child : children)
|
||||||
{
|
{
|
||||||
if(child->isVisible())
|
if(child->isVisible())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user