Print layout.

This commit is contained in:
Roman Telezhynskyi 2021-09-13 17:27:46 +03:00
parent f1e49a7fd6
commit 2306d4a67c
13 changed files with 953 additions and 249 deletions

View File

@ -93,7 +93,7 @@ void VPCarrousel::Refresh()
QList<VPSheetPtr> sheets = layout->GetSheets(); QList<VPSheetPtr> sheets = layout->GetSheets();
for (const auto &sheet : sheets) for (const auto &sheet : sheets)
{ {
if (not sheet.isNull() && sheet->IsVisible()) if (not sheet.isNull())
{ {
VPCarrouselSheet carrouselSheet; VPCarrouselSheet carrouselSheet;
carrouselSheet.unplaced = false; carrouselSheet.unplaced = false;

View File

@ -58,7 +58,7 @@ auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr
// create a standard sheet // create a standard sheet
VPSheetPtr sheet(new VPSheet(layout)); VPSheetPtr sheet(new VPSheet(layout));
sheet->SetName(tr("Sheet %1").arg(layout->GetSheets().size()+1)); sheet->SetName(tr("Sheet %1").arg(layout->GetAllSheets().size()+1));
layout->AddSheet(sheet); layout->AddSheet(sheet);
layout->SetFocusedSheet(sheet); layout->SetFocusedSheet(sheet);
@ -156,7 +156,7 @@ auto VPLayout::WatermarkData() const -> VWatermarkData
watermark.setXMLContent(converter.Convert()); watermark.setXMLContent(converter.Convert());
data = watermark.GetWatermark(); data = watermark.GetWatermark();
} }
catch (VException &e) catch (VException &)
{ {
data.invalidFile = true; data.invalidFile = true;
data.opacity = 20; data.opacity = 20;
@ -170,6 +170,34 @@ auto VPLayout::WatermarkData() const -> VWatermarkData
return data; return data;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VPLayout::IsSheetsUniform() const -> bool
{
QList<VPSheetPtr> sheets = GetSheets();
if (sheets.size() < 2)
{
return true;
}
VPSheetPtr sheet = sheets.first();
if (sheet.isNull())
{
return false;
}
QSizeF sheetSize = sheet->GetSheetSize().toSize();
return std::all_of(sheets.begin(), sheets.end(), [sheetSize](const VPSheetPtr &sheet)
{
if (sheet.isNull())
{
return false;
}
QSize size = sheet->GetSheetSize().toSize();
return size == sheetSize || size.transposed() == sheetSize;
});
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPLayout::GetPieces() const -> QList<VPPiecePtr> auto VPLayout::GetPieces() const -> QList<VPPiecePtr>
{ {
@ -221,11 +249,27 @@ auto VPLayout::AddSheet(const VPSheetPtr &sheet) -> VPSheetPtr
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPLayout::GetSheets() const -> QList<VPSheetPtr> QList<VPSheetPtr> VPLayout::GetAllSheets() const
{ {
return m_sheets; return m_sheets;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VPLayout::GetSheets() const -> QList<VPSheetPtr>
{
QList<VPSheetPtr> sheets;
sheets.reserve(m_sheets.size());
for (const auto &sheet : m_sheets)
{
if (not sheet.isNull() && sheet->IsVisible())
{
sheets.append(sheet);
}
}
return sheets;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
auto VPLayout::GetSheet(const QUuid &uuid) -> VPSheetPtr auto VPLayout::GetSheet(const QUuid &uuid) -> VPSheetPtr
{ {

View File

@ -56,6 +56,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 GetAllSheets() const -> QList<VPSheetPtr>;
auto GetSheets() const -> QList<VPSheetPtr>; auto GetSheets() const -> QList<VPSheetPtr>;
auto GetSheet(const QUuid &uuid) -> VPSheetPtr; auto GetSheet(const QUuid &uuid) -> VPSheetPtr;
@ -96,6 +97,8 @@ public:
auto WatermarkData() const -> VWatermarkData; auto WatermarkData() const -> VWatermarkData;
auto IsSheetsUniform() const -> bool;
signals: signals:
void PieceSheetChanged(const VPPiecePtr &piece); void PieceSheetChanged(const VPPiecePtr &piece);
void ActiveSheetChanged(const VPSheetPtr &focusedSheet); void ActiveSheetChanged(const VPSheetPtr &focusedSheet);

View File

@ -376,3 +376,15 @@ void VPLayoutSettings::SetShowWatermark(bool newShowWatermark)
{ {
m_showWatermark = newShowWatermark; m_showWatermark = newShowWatermark;
} }
//---------------------------------------------------------------------------------------------------------------------
bool VPLayoutSettings::GetPrintTilesScheme() const
{
return m_printTilesScheme;
}
//---------------------------------------------------------------------------------------------------------------------
void VPLayoutSettings::SetPrintTilesScheme(bool newPrintTilesScheme)
{
m_printTilesScheme = newPrintTilesScheme;
}

View File

@ -312,6 +312,9 @@ public:
auto GetShowWatermark() const -> bool; auto GetShowWatermark() const -> bool;
void SetShowWatermark(bool newShowWatermark); void SetShowWatermark(bool newShowWatermark);
bool GetPrintTilesScheme() const;
void SetPrintTilesScheme(bool newPrintTilesScheme);
private: private:
Unit m_unit{Unit::Cm}; Unit m_unit{Unit::Cm};
@ -366,6 +369,8 @@ private:
qreal m_verticalScale{1.0}; qreal m_verticalScale{1.0};
QString m_watermarkPath{}; QString m_watermarkPath{};
bool m_printTilesScheme{false};
}; };
#endif // VPLAYOUTSETTINGS_H #endif // VPLAYOUTSETTINGS_H

File diff suppressed because it is too large Load Diff

View File

@ -269,11 +269,17 @@ private slots:
void on_actionPrintTiledLayout_triggered(); void on_actionPrintTiledLayout_triggered();
void on_actionPrintPreviewTiledLayout_triggered(); void on_actionPrintPreviewTiledLayout_triggered();
void on_printLayoutSheets(QPrinter *printer);
void on_printLayoutTiledPages(QPrinter *printer);
void on_actionPrintSheet_triggered(); void on_actionPrintSheet_triggered();
void on_actionPrintPreviewSheet_triggered(); void on_actionPrintPreviewSheet_triggered();
void on_actionPrintTiledSheet_triggered(); void on_actionPrintTiledSheet_triggered();
void on_actionPrintPreviewTiledSheet_triggered(); void on_actionPrintPreviewTiledSheet_triggered();
void on_printLayoutSheet(QPrinter *printer);
void on_printLayoutSheetTiledPages(QPrinter *printer);
void CreateWatermark(); void CreateWatermark();
void EditCurrentWatermark(); void EditCurrentWatermark();
void LoadWatermark(); void LoadWatermark();
@ -457,13 +463,20 @@ private:
void ExportUnifiedPdfFile(const VPExportData &data); void ExportUnifiedPdfFile(const VPExportData &data);
void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name); void GenerateUnifiedPdfFile(const VPExportData &data, const QString &name);
void ExportPdfTiledFile(const VPExportData &data); void ExportPdfTiledFile(const VPExportData &data);
void GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter, QPrinter *printer, void GeneratePdfTiledFile(const VPSheetPtr &sheet, bool showTilesScheme, QPainter *painter,
bool &firstPage); const QSharedPointer<QPrinter> &printer, bool &firstPage);
void UpdateScaleConnection() const; void UpdateScaleConnection() const;
void OpenWatermark(const QString &path = QString()); void OpenWatermark(const QString &path = QString());
void CleanWaterkmarkEditors(); void CleanWaterkmarkEditors();
void DrawTilesScheme(QPrinter *printer, QPainter *painter, const VPSheetPtr &sheet, bool &firstPage);
auto AskLayoutIsInvalid(const QList<VPSheetPtr> &sheets) -> bool;
void PrintLayoutSheets(QPrinter *printer, const QList<VPSheetPtr> &sheets);
void PrintLayoutTiledSheets(QPrinter *printer, const QList<VPSheetPtr> &sheets);
}; };
#endif // VPMAINWINDOW_H #endif // VPMAINWINDOW_H

View File

@ -1541,6 +1541,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="checkBoxPrintTilesScheme">
<property name="text">
<string>Print tiles scheme</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -2266,7 +2273,8 @@
</action> </action>
<action name="actionWatermarkEditor"> <action name="actionWatermarkEditor">
<property name="icon"> <property name="icon">
<iconset theme="document-new"/> <iconset theme="document-new">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Editor</string> <string>Editor</string>
@ -2294,7 +2302,8 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="document-open"/> <iconset theme="document-open">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Load</string> <string>Load</string>
@ -2308,7 +2317,8 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="icon"> <property name="icon">
<iconset theme="edit-delete"/> <iconset theme="edit-delete">
<normaloff>.</normaloff>.</iconset>
</property> </property>
<property name="text"> <property name="text">
<string>Remove</string> <string>Remove</string>

View File

@ -320,6 +320,7 @@ void VPLayoutFileReader::ReadTiles(const VPLayoutPtr &layout)
QXmlStreamAttributes attribs = attributes(); QXmlStreamAttributes attribs = attributes();
layout->LayoutSettings().SetShowTiles(ReadAttributeBool(attribs, ML::AttrVisible, falseStr)); layout->LayoutSettings().SetShowTiles(ReadAttributeBool(attribs, ML::AttrVisible, falseStr));
layout->LayoutSettings().SetPrintTilesScheme(ReadAttributeBool(attribs, ML::AttrPrintScheme, falseStr));
// attribs.value(ML::AttrMatchingMarks); // TODO // attribs.value(ML::AttrMatchingMarks); // TODO
const QStringList tags const QStringList tags

View File

@ -201,7 +201,7 @@ void VPLayoutFileWriter::WriteSheets(const VPLayoutPtr &layout)
QList<VPSheetPtr> sheets = layout->GetSheets(); QList<VPSheetPtr> sheets = layout->GetSheets();
for (const auto &sheet : sheets) for (const auto &sheet : sheets)
{ {
if (not sheet.isNull() && sheet->IsVisible()) if (not sheet.isNull())
{ {
WriteSheet(sheet); WriteSheet(sheet);
} }
@ -224,7 +224,6 @@ void VPLayoutFileWriter::WriteSheet(const VPSheetPtr &sheet)
WritePieceList(sheet->GetPieces(), ML::TagPieces); WritePieceList(sheet->GetPieces(), ML::TagPieces);
writeEndElement(); // sheet writeEndElement(); // sheet
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -235,6 +234,8 @@ void VPLayoutFileWriter::WriteTiles(const VPLayoutPtr &layout)
writeStartElement(ML::TagTiles); writeStartElement(ML::TagTiles);
SetAttribute(ML::AttrVisible, layout->LayoutSettings().GetShowTiles()); SetAttribute(ML::AttrVisible, layout->LayoutSettings().GetShowTiles());
SetAttribute(ML::AttrMatchingMarks, "standard"); // TODO / Fixme get the right value SetAttribute(ML::AttrMatchingMarks, "standard"); // TODO / Fixme get the right value
SetAttributeOrRemoveIf<bool>(ML::AttrPrintScheme, layout->LayoutSettings().GetPrintTilesScheme(),
[](bool print){return not print;});
WriteSize(layout->LayoutSettings().GetTilesSize()); WriteSize(layout->LayoutSettings().GetTilesSize());
WriteMargins(layout->LayoutSettings().GetTilesMargins(), layout->LayoutSettings().IgnoreTilesMargins()); WriteMargins(layout->LayoutSettings().GetTilesMargins(), layout->LayoutSettings().IgnoreTilesMargins());

View File

@ -104,6 +104,7 @@ const QString AttrXScale = QStringLiteral("xScale");
const QString AttrYScale = QStringLiteral("yScale"); const QString AttrYScale = QStringLiteral("yScale");
const QString AttrIgnoreMargins = QStringLiteral("ignoreMargins"); const QString AttrIgnoreMargins = QStringLiteral("ignoreMargins");
const QString AttrShowPreview = QStringLiteral("showPreview"); const QString AttrShowPreview = QStringLiteral("showPreview");
const QString AttrPrintScheme = QStringLiteral("printScheme");
const QString atFrontStr = QStringLiteral("atFront"); const QString atFrontStr = QStringLiteral("atFront");
const QString atRearStr = QStringLiteral("atRear"); const QString atRearStr = QStringLiteral("atRear");

View File

@ -109,6 +109,7 @@ extern const QString AttrXScale;
extern const QString AttrYScale; extern const QString AttrYScale;
extern const QString AttrIgnoreMargins; extern const QString AttrIgnoreMargins;
extern const QString AttrShowPreview; extern const QString AttrShowPreview;
extern const QString AttrPrintScheme;
extern const QString atFrontStr; extern const QString atFrontStr;
extern const QString atRearStr; extern const QString atRearStr;

View File

@ -38,6 +38,7 @@
</xs:sequence> </xs:sequence>
<xs:attribute type="xs:boolean" name="visible"/> <xs:attribute type="xs:boolean" name="visible"/>
<xs:attribute type="xs:string" name="matchingMarks"/> <xs:attribute type="xs:string" name="matchingMarks"/>
<xs:attribute type="xs:boolean" name="printScheme"/>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
<xs:element name="scale"> <xs:element name="scale">