Seamly2D
Code documentation
dialoglayoutsettings.h
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file dialoglayoutsettings.h
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 13 1, 2015
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2013-2015 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #ifndef DIALOGLAYOUTSETTINGS_H
53 #define DIALOGLAYOUTSETTINGS_H
54 
55 #include "vabstractlayoutdialog.h"
56 
57 #include "../vlayout/vbank.h"
58 #include "../ifc/ifcdef.h"
59 
60 #include <QCloseEvent>
61 #include <QMargins>
62 
63 namespace Ui
64 {
66 }
67 
68 class VLayoutGenerator;
69 
71 {
72  Q_OBJECT
73 public:
74  explicit DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent = nullptr, bool disableSettings = false);
75  virtual ~DialogLayoutSettings();
76 
77  qreal GetPaperHeight() const;
78  void SetPaperHeight(qreal value);
79 
80  qreal GetPaperWidth() const;
81  void SetPaperWidth(qreal value);
82 
83  qreal GetShift() const;
84  void SetShift(qreal value);
85 
86  qreal GetLayoutWidth() const;
87  void SetLayoutWidth(qreal value);
88 
89  QMarginsF GetFields() const;
90  void SetFields(const QMarginsF &value);
91 
92  Cases GetGroup() const;
93  void SetGroup(const Cases &value);
94 
95  bool GetRotate() const;
96  void SetRotate(bool state);
97 
98  int GetIncrease() const;
99  bool SetIncrease(int increase);
100 
101  bool GetAutoCrop() const;
102  void SetAutoCrop(bool autoCrop);
103 
104  bool IsSaveLength() const;
105  void SetSaveLength(bool save);
106 
107  bool IsUnitePages() const;
108  void SetUnitePages(bool save);
109 
110  bool IsStripOptimization() const;
111  void SetStripOptimization(bool save);
112 
113  quint8 GetMultiplier() const;
114  void SetMultiplier(const quint8 &value);
115 
116  bool IsIgnoreAllFields() const;
117  void SetIgnoreAllFields(bool value);
118 
119  bool isTextAsPaths() const;
120  void setTextAsPaths(bool value);
121 
122  QString SelectedPrinter() const;
123 
124  //support functions for the command line parser which uses invisible dialog to properly build layout generator
125  bool SelectTemplate(const PaperSizeTemplate& id);
126  static QString MakeHelpTemplateList();
127  bool SelectPaperUnit(const QString& units);
128  bool SelectLayoutUnit(const QString& units);
129  qreal LayoutToPixels(qreal value) const;
130  qreal PageToPixels(qreal value) const;
131  static QString MakeGroupsHelp();
132 protected:
133  virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
134  QSizeF getTemplateSize(const PaperSizeTemplate &tmpl, const Unit &unit) const;
135 
136 public slots:
137  void DialogAccepted();
138 private slots:
139  void ConvertPaperSize();
140  void ConvertLayoutSize();
141  void TemplateSelected();
142  void FindTemplate();
143  void PaperSizeChanged();
144  void Swap(bool checked);
145  void RestoreDefaults();
146  void PrinterMargins();
147 
148  void CorrectMaxFileds();
149  void IgnoreAllFields(int state);
150 private:
151  Q_DISABLE_COPY(DialogLayoutSettings)
152  typedef QStringList FormatsVector;
153  typedef int VIndexType;
155 
157 
163 
164  void InitPaperUnits();
165  void InitLayoutUnits();
166  void InitPrinter();
167  QSizeF Template();
168 
169  QMarginsF MinPrinterFields() const;
170  QMarginsF GetDefPrinterFields() const;
171 
172  Unit PaperUnit() const;
173  Unit LayoutUnit() const;
174 
175  void CorrectPaperDecimals();
176  void CorrectLayoutDecimals();
177 
178  void MinimumPaperSize();
179  void MinimumLayoutSize();
180 
181  void ReadSettings();
182  void WriteSettings() const;
183 
184  void SheetSize(const QSizeF &size);
185  void SetAdditionalOptions(bool value);
186 };
187 
188 #endif // DIALOGLAYOUTSETTINGS_H
qreal PageToPixels(qreal value) const
bool SelectLayoutUnit(const QString &units)
void SheetSize(const QSizeF &size)
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
void SetGroup(const Cases &value)
void SetMultiplier(const quint8 &value)
qreal LayoutToPixels(qreal value) const
void SetIgnoreAllFields(bool value)
void SetAutoCrop(bool autoCrop)
void setTextAsPaths(bool value)
VLayoutGenerator * generator
Ui::DialogLayoutSettings * ui
static QString MakeHelpTemplateList()
static QString MakeGroupsHelp()
QMarginsF MinPrinterFields() const
DialogLayoutSettings(VLayoutGenerator *generator, QWidget *parent=nullptr, bool disableSettings=false)
void SetAdditionalOptions(bool value)
void SetLayoutWidth(qreal value)
bool SelectPaperUnit(const QString &units)
QMarginsF GetDefPrinterFields() const
QSizeF getTemplateSize(const PaperSizeTemplate &tmpl, const Unit &unit) const
DialogLayoutSettings::TemplateSize.
bool SetIncrease(int increase)
static const FormatsVector pageFormatNames
void SetPaperHeight(qreal value)
void SetFields(const QMarginsF &value)
bool SelectTemplate(const PaperSizeTemplate &id)
void SetPaperWidth(qreal value)
void SetStripOptimization(bool save)
Unit
Definition: def.h:105
Cases
Definition: vbank.h:71