Seamly2D
Code documentation
pattern_piece_dialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  ** @file pattern_piece_dialog.h
3  ** @author Douglas S Caskey
4  ** @date Dec 27, 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 dialogseamallowance.h
28  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
29  ** @date 3 11, 2016
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) 2016 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 PATTERN_PIECE_DIALOG
54 #define PATTERN_PIECE_DIALOG
55 
56 #include "../dialogtool.h"
57 #include "../vpatterndb/vpiece.h"
58 #include "../vpatterndb/floatItemData/vgrainlinedata.h"
59 #include "../vpatterndb/floatItemData/vpatternlabeldata.h"
60 #include "../vpatterndb/floatItemData/vpiecelabeldata.h"
61 
62 #include <QSound>
63 
65 
66 namespace Ui
67 {
68  class PatternPieceDialog;
69  class PathsTab;
70  class LabelsTab;
71  class GrainlineTab;
72  class AnchorPointsTab;
73  class NotchesTab;
74 }
75 
77 
79 {
80  Q_OBJECT
81 
82 public:
83  PatternPieceDialog(const VContainer *data, const quint32 &toolId,
84  QWidget *parent = nullptr);
85  //PatternPieceDialog(const VContainer *data, const quint32 &toolId,
86  // QWidget *parent = nullptr);
87  virtual ~PatternPieceDialog();
88 
89  void pageChanged(QListWidgetItem *current, QListWidgetItem *previous);
90  void enableApply(bool enable);
91 
92  VPiece GetPiece() const;
93  void SetPiece(const VPiece &piece);
94 
95  QString getSeamAllowanceWidthFormula() const;
96 
97 public slots:
98  virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
99  virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
100 
101 protected:
102  virtual void SaveData() Q_DECL_OVERRIDE; //! @brief SaveData Put dialog data in local variables
103  virtual void CheckState() Q_DECL_FINAL;
104  virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
105 
106  virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
107  virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE;
108  virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
109 
110 private slots:
111  void setErrorText(TabOrder tab, QString text);
112  void clearErrorText(TabOrder tab, QString text);
113  void pieceNameChanged();
114  void pieceColorChanged();
115  void showMainPathContextMenu(const QPoint &pos);
116  void showCustomSAContextMenu(const QPoint &pos);
117  void showInternalPathsContextMenu(const QPoint &pos);
118  void showAnchorsContextMenu(const QPoint &pos);
119 
120  void nodeListChanged();
121  void enableSeamAllowance(bool enable);
122  void enableBuiltIn(bool enable);
123  void nodeChanged(int index);
124  void notchChanged(int index);
125  void customSAStartPointChanged(int index);
126  void customSAEndPointChanged(int index);
127  void customSAIncludeTypeChanged(int index);
128  void nodeAngleChanged(int index);
131  void customSeamAllowanceChanged(int row);
132  void pathDialogClosed(int result);
133 
134  void notchTypeChanged(int id);
135  void notchSubTypeChanged(int id);
136  void showNotchChanged(int state);
137  void showSeamlineNotchChanged(int state);
138  void notchLengthChanged(qreal value);
139  void resetNotchLength();
140  void notchWidthChanged(qreal value);
141  void resetNotchWidth();
142  void notchAngleChanged(qreal value);
143  void resetNotchAngle();
144  void notchCountChanged(int value);
145 
146  void updateGrainlineValues();
147  void updatePieceLabelValues();
149 
150  void editGrainlineFormula();
151  void editPieceLabelFormula();
153 
155  void expandGrainlineLength();
156 
157  void expandPieceLabelWidth();
158  void expandPieceLabelHeight();
159  void expandPieceLabelAngle();
160 
164 
165  void resetGrainlineWarning();
166  void resetLabelsWarning();
167 
168  void enabledGrainline();
169  void enabledPieceLabel();
170  void enabledPatternLabel();
171 
172  void evaluateDefaultWidth();
173  void evaluateBeforeWidth();
174  void evaluateAfterWidth();
175 
179 
180  void defaultWidthChanged();
181  void beforeWidthChanged();
182  void afterWidthChanged();
183 
187 
188  void grainlineAnchorChanged();
191 
192  void editPieceLabel();
193  void editPatternLabel();
194 
195 private:
196  Q_DISABLE_COPY(PatternPieceDialog)
197 
212  qreal m_mx;
213  qreal m_my;
216 
217  QPointer<DialogTool> m_dialog;
219 
234  QTimer *m_timerWidth;
237  qreal m_saWidth;
240  QSound *m_beep;
241 
242  VPiece CreatePiece() const;
243 
244  void newMainPathItem(const VPieceNode &node);
245  void newCustomSeamAllowance(const CustomSARecord &record);
246  void newInternalPath(quint32 path);
247  void newAnchorPoint(quint32 anchorPoint);
248  QString getPathName(quint32 path, bool reverse = false) const;
249 
250  QString getPieceColor() const;
251  void setPieceColor(const QString &value);
252 
253  QString getPieceFill() const;
254  void setPieceFill(const QString &value);
255 
256  bool isInLayout() const;
257  void setInLayout(const bool &state);
258 
259  bool getPieceLock() const;
260  void setPieceLock(const bool &state);
261 
262  bool isMainPathValid() const;
263  void validateObjects(bool value);
264  bool isMainPathClockwise() const;
267 
268  QListWidgetItem *getItemById(quint32 id);
269 
270  quint32 getPreviousId() const;
271  VPieceNode getLastNode() const;
272  bool pointNodesExist() const;
273 
274  void setCurrentBeforeSeamAllowance(const QString &formula);
275  void setCurrentAfterSeamAllowance(const QString &formula);
276 
277  void updateNodeBeforeSeamAllowance(const QString &formula);
278  void updateNodeAfterSeamAllowance(const QString &formula);
279 
280  void initializeMainPathTab();
282  void initializeNodesList();
283  void initializeNotchesList();
284  void initializeCSAPoint(QComboBox *box);
285  void initAnchorPoint(QComboBox *box);
289  void initializeLabelsTab();
290  void initializeGrainlineTab();
291  void initializeAnchorsTab();
292  void initializeNotchesTab();
294 
295  void setSeamAllowanceWidthFormula(const QString &formula);
296 
297  void setGrainlineAngle(QString angleFormula);
298  void setGrainlineLength(QString lengthFormula);
299 
300  void setPieceLabelWidth(QString widthFormula);
301  void setPieceLabelHeight(QString heightFormula);
302  void setPieceLabelAngle(QString angleFormula);
303 
304  void setPatternLabelWidth(QString widthFormula);
305  void setPatternLabelHeight(QString heightFormula);
306  void setPatternLabelAngle(QString angleFormula);
307 
308  void showAnchorPoints();
309  void setMoveExclusions();
310 
311  QString createPieceName() const;
312  void reverseNode(QListWidgetItem *rowItem);
313  void duplicateNode(QListWidgetItem *rowItem);
314  void excludeNode(QListWidgetItem *rowItem);
315  void setNotch(QListWidgetItem *rowItem, bool isNotch, NotchType notchType);
316  void setCurrentText(QComboBox *box, const QString &text) const;
317  qreal getFormulaValue(QPlainTextEdit *text) const;
318 };
319 
320 #endif // PATTERN_PIECE_DIALOG
The DialogTool class parent for all dialog of tools.
Definition: dialogtool.h:107
quint32 toolId
Definition: dialogtool.h:225
const VContainer * data
data container with data
Definition: dialogtool.h:177
void updateNodeBeforeSeamAllowance(const QString &formula)
void notchLengthChanged(qreal value)
void setPieceLabelAngle(QString angleFormula)
virtual void CheckState() Q_DECL_FINAL
SaveData Put dialog data in local variables.
VPieceNode getLastNode() const
void setErrorText(TabOrder tab, QString text)
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
closeEvent handle when dialog cloded
void setSeamAllowanceWidthFormula(const QString &formula)
void showAnchorsContextMenu(const QPoint &pos)
void setPatternLabelHeight(QString heightFormula)
void customSAEndPointChanged(int index)
void setPieceLock(const bool &state)
void setPieceColor(const QString &value)
void notchCountChanged(int value)
void setPieceLabelWidth(QString widthFormula)
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE
ChosenObject adds selected object of id and type to list of path items.
void customSAStartPointChanged(int index)
QString getPathName(quint32 path, bool reverse=false) const
VPatternLabelData m_oldGeom
void setGrainlineLength(QString lengthFormula)
void initAnchorPoint(QComboBox *box)
QPointer< PieceAnchorPointVisual > m_anchorPoints
QPointer< DialogTool > m_dialog
void setPatternLabelWidth(QString widthFormula)
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE
void updateNodeAfterSeamAllowance(const QString &formula)
void setNotch(QListWidgetItem *rowItem, bool isNotch, NotchType notchType)
VPieceLabelData m_oldData
void enableApply(bool enable)
QVector< VLabelTemplateLine > m_pieceLabelLines
void enableBuiltIn(bool enable)
void setCurrentAfterSeamAllowance(const QString &formula)
void setCurrentBeforeSeamAllowance(const QString &formula)
void showCustomSAContextMenu(const QPoint &pos)
QString createPieceName() const
void customSeamAllowanceChanged(int row)
qreal getFormulaValue(QPlainTextEdit *text) const
virtual void SaveData() Q_DECL_OVERRIDE
SaveData Put dialog data in local variables.
void setPieceLabelHeight(QString heightFormula)
void duplicateNode(QListWidgetItem *rowItem)
Ui::PatternPieceDialog * ui
void enableSeamAllowance(bool enable)
void notchWidthChanged(qreal value)
void setCurrentText(QComboBox *box, const QString &text) const
void validateObjects(bool value)
void showNotchChanged(int state)
void setPatternLabelAngle(QString angleFormula)
void setInLayout(const bool &state)
void clearErrorText(TabOrder tab, QString text)
void SetPiece(const VPiece &piece)
void newInternalPath(quint32 path)
QVector< VLabelTemplateLine > m_patternLabelLines
void newCustomSeamAllowance(const CustomSARecord &record)
QString getSeamAllowanceWidthFormula() const
void showInternalPathsContextMenu(const QPoint &pos)
void showSeamlineNotchChanged(int state)
void initializeCSAPoint(QComboBox *box)
PatternPieceDialog(const VContainer *data, const quint32 &toolId, QWidget *parent=nullptr)
void pathDialogClosed(int result)
void newAnchorPoint(quint32 anchorPoint)
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE
void newMainPathItem(const VPieceNode &node)
QListWidgetItem * getItemById(quint32 id)
void nodeAngleChanged(int index)
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
showEvent handle when window show
void setPieceFill(const QString &value)
void reverseNode(QListWidgetItem *rowItem)
void pageChanged(QListWidgetItem *current, QListWidgetItem *previous)
void setGrainlineAngle(QString angleFormula)
void excludeNode(QListWidgetItem *rowItem)
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE
void showMainPathContextMenu(const QPoint &pos)
void customSAIncludeTypeChanged(int index)
void notchAngleChanged(qreal value)
VGrainlineData m_oldGrainline
The VContainer class container of all variables.
Definition: vcontainer.h:141
The VGrainlineData class holds information about a grainline like position, size, rotation and visibi...
The VPatternLabelData class holds the information about pattern info label geometry.
The VPieceLabelData class holds some information about a single piece like letter,...
Definition: vpiece.h:88
NotchType
Definition: def.h:123
SceneObject
Definition: def.h:103
@ Grainline
@ SeamAllowance
@ Properties
@ AnchorPoints
The CustomSA struct contains record about custom seam allowanse (SA).
Definition: def.h:510