Seamly2D
Code documentation
mainwindowsnogui.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file mainwindowsnogui.h
3  ** @author Douglas S Caskey
4  ** @date Dec 31, 2022
5  **
6  ** @copyright
7  ** Copyright (C) 2017 - 2022 Seamly, LLC
8  ** https://github.com/fashionfreedom/seamly2d
9  **
10  ** @brief
11  ** Seamly2D is free software: you can redistribute it and/or modify
12  ** it under the terms of the GNU General Public License as published by
13  ** the Free Software Foundation, either version 3 of the License, or
14  ** (at your option) any later version.
15  **
16  ** Seamly2D is distributed in the hope that it will be useful,
17  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  ** GNU General Public License for more details.
20  **
21  ** You should have received a copy of the GNU General Public License
22  ** along with Seamly2D. if not, see <http://www.gnu.org/licenses/>.
23  **************************************************************************/
24 
25 /************************************************************************
26  **
27  ** @file mainwindowsnogui.h
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 12 5, 2015
30  **
31  ** @brief
32  ** @copyright
33  ** This source code is part of the Valentina project, a pattern making
34  ** program, whose allow create and modeling patterns of clothing.
35  ** Copyright (C) 2015 Valentina project
36  ** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
37  **
38  ** Valentina is free software: you can redistribute it and/or modify
39  ** it under the terms of the GNU General Public License as published by
40  ** the Free Software Foundation, either version 3 of the License, or
41  ** (at your option) any later version.
42  **
43  ** Valentina is distributed in the hope that it will be useful,
44  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
45  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46  ** GNU General Public License for more details.
47  **
48  ** You should have received a copy of the GNU General Public License
49  ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
50  **
51  *************************************************************************/
52 
53 #ifndef MAINWINDOWSNOGUI_H
54 #define MAINWINDOWSNOGUI_H
55 
56 #include <QMainWindow>
57 #include <QPrinter>
58 #include <QToolButton>
59 
60 #include "../vlayout/vlayoutpiece.h"
61 #include "xml/vpattern.h"
63 #include "../vlayout/vlayoutgenerator.h"
64 #include "../vwidgets/vabstractmainwindow.h"
65 
66 class QGraphicsScene;
67 struct PosterData;
68 class QGraphicsRectItem;
69 
71 {
72  Q_OBJECT
73 public:
74  explicit MainWindowsNoGUI(QWidget *parent = nullptr);
75  virtual ~MainWindowsNoGUI() Q_DECL_OVERRIDE;
76 
77 public slots:
78  void toolLayoutSettings(QToolButton *tButton, bool checked);
79  void PrintPreviewOrigin();
80  void PrintPreviewTiled();
81  void PrintOrigin();
82  void PrintTiled();
83  void refreshLabels();
84  void refreshGrainLines();
85  void refreshSeamAllowances();
86  void exportSVG(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene)const;
87  void exportPNG(const QString &name, QGraphicsScene *scene)const;
88  void exportTIF(const QString &name, QGraphicsScene *scene)const;
89  void exportJPG(const QString &name, QGraphicsScene *scene)const;
90  void exportBMP(const QString &name, QGraphicsScene *scene)const;
91  void exportPPM(const QString &name, QGraphicsScene *scene)const;
92  void exportPDF(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins,
93  const QMarginsF &margins)const;
94  void exportEPS(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins,
95  const QMarginsF &margins)const;
96  void exportPS(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins,
97  const QMarginsF &margins)const;
98 
99 protected:
101 
102  QGraphicsScene *currentScene; /** @brief currentScene pointer to current scene. */
103  QGraphicsScene *tempSceneLayout; /** @brief pattern container with data (points, arcs, splines, spline paths, variables) */
104  VContainer *pattern; /** @brief pattern container with data (points, arcs, splines, spline paths, variables) */
105  VPattern *doc; /** @brief doc dom document container */
106 
112 
113  QAction *undoAction;
114  QAction *redoAction;
119 
123  QMarginsF margins;
124  QSizeF paperSize;
125 
127 
128  void ExportData(const QVector<VLayoutPiece> &pieceList, const ExportLayoutDialog &dialog);
129 
130  void InitTempLayoutScene();
131  virtual void CleanLayout()=0;
132  virtual void PrepareSceneList()=0;
133  QIcon ScenePreview(int i) const;
134  bool LayoutSettings(VLayoutGenerator& lGenerator);
135  int ContinueIfLayoutStale();
136  QString FileName() const;
137  void SetSizeHeightForIndividualM() const;
138 
139 private slots:
140  void PrintPages (QPrinter *printer);
141  void ErrorConsoleMode(const LayoutErrors &state);
142 
143 private:
144  Q_DISABLE_COPY(MainWindowsNoGUI)
145 
146  bool isTiled;
149 
151 
152  static QList<QGraphicsItem *> CreateShadows(const QList<QGraphicsItem *> &papers);
153  static QList<QGraphicsScene *> CreateScenes(const QList<QGraphicsItem *> &papers,
154  const QList<QGraphicsItem *> &shadows,
155  const QList<QList<QGraphicsItem *> > &pieces);
156 
157 
158 
159  void PdfTiledFile(const QString &name);
160 
161  void convertPdfToPs(const QStringList &params)const;
162  void ObjFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene)const;
163  void FlatDxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, QGraphicsScene *scene,
164  const QList<QList<QGraphicsItem *> > &pieces)const;
165  void AAMADxfFile(const QString &name, int version, bool binary, const QSize &size,
166  const QVector<VLayoutPiece> &pieces) const;
167 
168  void PreparePaper(int index) const;
169  void RestorePaper(int index) const;
170 
171  void PrepareTextForDXF(const QString &placeholder, const QList<QList<QGraphicsItem *> > &pieces) const;
172  void RestoreTextAfterDXF(const QString &placeholder, const QList<QList<QGraphicsItem *> > &pieces) const;
173 
174  void PrintPreview();
175  void LayoutPrint();
176 
177  enum class PrintType : char {PrintPDF, PrintPreview, PrintNative};
178 
179  void SetPrinterSettings(QPrinter *printer, const PrintType &printType);
180  bool IsLayoutGrayscale() const;
181  QPageSize FindQPrinterPageSize(const QSizeF &size) const;
182 
183  bool isPagesUniform() const;
184  bool IsPagesFit(const QSizeF &printPaper) const;
185 
186  void ExportScene(const ExportLayoutDialog &dialog,
191  bool ignoreMargins, const QMarginsF &margins) const;
192 
193  void ExportApparelLayout(const ExportLayoutDialog &dialog, const QVector<VLayoutPiece> &pieces, const QString &name,
194  const QSize &size) const;
195 
197 
198  void ExportFlatLayout(const ExportLayoutDialog &dialog,
203  bool ignoreMargins, const QMarginsF &margins);
204 
206 };
207 
208 #endif // MAINWINDOWSNOGUI_H
void ExportApparelLayout(const ExportLayoutDialog &dialog, const QVector< VLayoutPiece > &pieces, const QString &name, const QSize &size) const
QGraphicsScene * tempSceneLayout
currentScene pointer to current scene.
virtual ~MainWindowsNoGUI() Q_DECL_OVERRIDE
void exportPPM(const QString &name, QGraphicsScene *scene) const
exportPPM save layout to gif file.
void PrepareTextForDXF(const QString &placeholder, const QList< QList< QGraphicsItem * > > &pieces) const
PrepareTextForDXF prepare QGraphicsSimpleTextItem items for export to flat dxf.
void exportSVG(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene) const
exportSVG save layout to svg file.
VContainer * pattern
pattern container with data (points, arcs, splines, spline paths, variables)
bool IsPagesFit(const QSizeF &printPaper) const
void ExportData(const QVector< VLayoutPiece > &pieceList, const ExportLayoutDialog &dialog)
void refreshLabels()
refreshLabels call to recalculate piece labels. For example after changing a font.
QVector< QVector< VLayoutPiece > > piecesOnLayout
void convertPdfToPs(const QStringList &params) const
convertPdfToPs use external tool "pdftops" for converting pdf to eps or ps format.
MainWindowsNoGUI(QWidget *parent=nullptr)
void AAMADxfFile(const QString &name, int version, bool binary, const QSize &size, const QVector< VLayoutPiece > &pieces) const
void exportTIF(const QString &name, QGraphicsScene *scene) const
exportTIF save layout to tif file.
void exportJPG(const QString &name, QGraphicsScene *scene) const
exportJPG save layout to jpg file.
void FlatDxfFile(const QString &name, int version, bool binary, QGraphicsRectItem *paper, QGraphicsScene *scene, const QList< QList< QGraphicsItem * > > &pieces) const
void PreparePaper(int index) const
void ObjFile(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene) const
void exportEPS(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins, const QMarginsF &margins) const
exportEPS( save layout to eps file.
QList< QList< QGraphicsItem * > > pieces
QList< QGraphicsItem * > shadows
bool isPagesUniform() const
virtual void PrepareSceneList()=0
QPageSize FindQPrinterPageSize(const QSizeF &size) const
MainWindowsNoGUI::FindTemplate.
static QVector< VLayoutPiece > preparePiecesForLayout(const QHash< quint32, VPiece > &pieces)
void ExportFlatLayout(const ExportLayoutDialog &dialog, const QList< QGraphicsScene * > &scenes, const QList< QGraphicsItem * > &papers, const QList< QGraphicsItem * > &shadows, const QList< QList< QGraphicsItem * > > &pieces, bool ignoreMargins, const QMarginsF &margins)
QList< QGraphicsItem * > papers
doc dom document container
QAction * actionDockWidgetGroups
QIcon ScenePreview(int i) const
void exportBMP(const QString &name, QGraphicsScene *scene) const
exportBMP save layout to bmp file.
bool IsLayoutGrayscale() const
void exportPNG(const QString &name, QGraphicsScene *scene) const
exportPNG save layout to png file.
virtual void CleanLayout()=0
void exportPDF(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins, const QMarginsF &margins) const
exportPDF save layout to pdf file.
QVector< VLayoutPiece > pieceList
void SetSizeHeightForIndividualM() const
void exportPiecesAsApparelLayout(const ExportLayoutDialog &dialog, QVector< VLayoutPiece > pieceList)
void RestorePaper(int index) const
void exportPS(const QString &name, QGraphicsRectItem *paper, QGraphicsScene *scene, bool ignoreMargins, const QMarginsF &margins) const
exportPS save layout to ps file.
QAction * actionDockWidgetToolOptions
void ErrorConsoleMode(const LayoutErrors &state)
void PrintPages(QPrinter *printer)
static QList< QGraphicsScene * > CreateScenes(const QList< QGraphicsItem * > &papers, const QList< QGraphicsItem * > &shadows, const QList< QList< QGraphicsItem * > > &pieces)
void exportPiecesAsFlatLayout(const ExportLayoutDialog &dialog, const QVector< VLayoutPiece > &pieceList)
bool LayoutSettings(VLayoutGenerator &lGenerator)
QAction * actionDockWidgetToolbox
void toolLayoutSettings(QToolButton *tButton, bool checked)
void SetPrinterSettings(QPrinter *printer, const PrintType &printType)
QList< QGraphicsScene * > scenes
QAction * actionDockWidgetLayouts
VPattern * doc
pattern container with data (points, arcs, splines, spline paths, variables)
void refreshSeamAllowances()
refreshSeamAllowances call to show / hide seam allowances.
static QList< QGraphicsItem * > CreateShadows(const QList< QGraphicsItem * > &papers)
void refreshGrainLines()
refreshGrainLines call to recalculate piece grainlines. For example after show / hide grainlines.
void ExportScene(const ExportLayoutDialog &dialog, const QList< QGraphicsScene * > &scenes, const QList< QGraphicsItem * > &papers, const QList< QGraphicsItem * > &shadows, const QList< QList< QGraphicsItem * > > &pieces, bool ignoreMargins, const QMarginsF &margins) const
void PdfTiledFile(const QString &name)
QString FileName() const
void RestoreTextAfterDXF(const QString &placeholder, const QList< QList< QGraphicsItem * > > &pieces) const
MainWindowsNoGUI::RestoreTextAfterDXF restore QGraphicsSimpleTextItem items after export to flat dxf.
QGraphicsScene * currentScene
The VContainer class container of all variables.
Definition: vcontainer.h:141
The VPattern class working with pattern file.
Definition: vpattern.h:68
LayoutErrors
Definition: vlayoutdef.h:60