-
Notifications
You must be signed in to change notification settings - Fork 1
/
gerberstencilgenerator.h
executable file
·223 lines (200 loc) · 7.68 KB
/
gerberstencilgenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#ifndef GERBERSTENCILGENERATOR_H
#define GERBERSTENCILGENERATOR_H
#include "enums.h"
#include <QWidget>
#include <QDir>
#include <QStandardItemModel>
#include <QMessageBox>
#include <QProcess>
#include <QTemporaryFile>
#include <QSettings>
#include <QSplitter>
#include "apertureeditview.h"
#include "slidersizelabel.h"
#include "aperturelistwidget.h"
#include "settingsdialog.h"
#include "gerberplotterdialog.h"
#include "color.h"
#include "shapeicon.h"
#include "tipoftheday.h"
#include "snapslider.h"
#include "renderthread.h"
#include "QtColorWidgets/color_dialog.hpp"
#define APPLICATION_NAME "Gerber Stencil Generator"
#define APPLICATION_AUTHOR "Tobias X Vogel"
#define ORGANISATION_NAME "Tobias Vogel"
#define ORGANISATION_DOMAIN "tobiasvogel.tv"
typedef struct flash_aperture_struct {
int originalId = 0;
QString replacementDesignator;
shape_type originalShape = UNSET;
shape_type replacementShape = UNSET;
bool isHollow = false;
double originalAspectRatio = 1.0;
int originalVertices = 1;
int replacementVertices = 0;
double originalOuterDiameter = 0.0;
double replacementOuterDiameter = 0.0;
double originalInnerDiameter = 0.0;
double replacementInnerDiameter = 0.0;
double originalWidth = 0.0;
double replacementWidth = 0.0;
double originalHeight = 0.0;
double replacementHeight = 0.0;
double maxCornerRadius = 0.0;
float rotation = 0.0;
int resizePercentage = 100;
int initialResizePercentage = 100;
int roundnessPercentage = 0;
int initialRoundnessPercentage = 0;
signed int innerResizePercentage = 0;
signed int initialInnerResizePercentage = 0;
QStringList replacementGerber;
bool hasUnsavedChanges = false;
bool toBeDeleted = false;
change_type changeState = UNCHANGED;
ShapeIcon icon;
} flash_aperture_struct;
namespace Ui {
class GerberStencilGenerator;
class settingsDialog;
class sliderSizeLabel;
class snapSlider;
class apertureListWidget;
}
class GerberStencilGenerator : public QWidget {
Q_OBJECT
public:
explicit GerberStencilGenerator( QWidget *parent = nullptr );
~GerberStencilGenerator();
QColor getColor( QString colorId = "" );
bool setColor( QString colorId = "", QColor newColor = Qt::transparent );
Q_ENUM( unit_type );
Q_ENUM( change_type );
Q_ENUM( shape_type );
private:
Ui::GerberStencilGenerator *ui;
settingsDialog *settingsUi;
TipOfTheDay *tipOfTheDayDialog;
GerberPlotterDialog *plotterDialog;
QSettings *userSettings;
QString gerbvApplicationPath;
QDir lastInputFileDir = QDir::homePath();
bool inputFileLock = false;
QDir lastOutputFileDir = QDir::homePath();
QStringList inputFileData;
unit_type unitFormat = UNKNOWN;
QList<int> numberFormat;
QList<flash_aperture_struct> apertureList;
QGraphicsScene *apertureEditScene;
QGraphicsScene *gerberPreviewScene;
QPainter *previewPainter;
QColor flashColor;
QColor adjustmentColor;
QColor backgroundColor;
QColor lineColor;
QColor lightGreen;
QColor lightRed;
QColor greyedOutColor;
QStandardItemModel *aperturesWidgetList;
QPixmap gerberPreviewPixmap;
bool gerbv_confirmed = false;
bool autoPreview = true;
bool hasUnsavedChanges = false;
QLabel *loadingLabel;
QMovie *loadingMovie;
QStringList processArguments;
QTemporaryFile overlayGerber;
#ifdef QT_DEBUG
QTemporaryFile tempLogFile;
#endif
QTemporaryFile tempImageFile;
bool _showTipAtStartup = true;
int _showTipOfTheDayNumber = 0;
QPushButton *previewZoomInButton;
QPushButton *previewZoomOutButton;
QPushButton *previewNormalZoomButton;
double previewScaleFactor = 1.00;
color_widgets::ColorDialog *colorDialog;
RenderThread thread;
bool _gerberDataLoaded = false;
protected:
void resizeEvent( QResizeEvent *event );
void showEvent( QShowEvent *event ) {
QWidget::showEvent( event );
QMetaObject::invokeMethod( this, "afterWindowIsShown", Qt::ConnectionType::QueuedConnection );
}
void saveUserSettings( void );
void restoreUserSettings( void );
QString currentSelectedItem( void );
int currentSelectedIndex( void );
int getIndexFromItemText( QString itemText );
QStandardItemModel *getWidgetListModel( void );
QStringList generateHighlightedGerber( int selectedApertureId );
void invokeRenderer( int width, int height, QStringList overlayData, bool useTempOverlay );
void showTipOfTheDay( void );
Q_SIGNALS:
void gerberDataLoaded( bool loaded );
protected Q_SLOTS:
void sizeSettingChanged( int percentage );
void roundnessSettingChanged( int percentage );
void innerSizeSettingChanged( int percentage );
void inputFileBrowse();
void outputFileBrowse();
void readGerberInputFile();
void lockInputFile( bool lock );
bool isInputFileLocked( void );
void alertMessage( QString message, QString subtext );
int confirmQuestion( QString question, QString subtext, QMessageBox::StandardButton defaultButton );
void displayError( QString message, QString subtext, bool fatal );
void checkGerberData();
void parseGerberData();
void updateEditingAperture( QString selectedAperture );
void drawRoundedRectangle( double origFlashWidth, double origFlashHeight, double origInnerDiameter, double maxCornerRadius, int resizePercentage, int roundnessPercentage,
int innerResizePercentage, bool hollow );
void drawEllipse( double origOuterDiameter, double origInnerDiameter, int resizePercentage, int innerResizePercentage, bool hollow );
void drawObroundShape( double origFlashWidth, double origFlashHeight, double origOuterDiameter, double origInnerDiameter, int resizePercentage, int innerResizePercentage,
bool hollow );
void drawRoundedPolygon( double origOuterDiameter, int origVertices, float origRotation, double origInnerDiameter, int resizePercentage, int roundnessPercentage,
int innerResizePercentage, bool hollow );
void toggleSizeAdjustControls( bool enabled );
void toggleRoundnessAjustControls( bool enabled );
void toggleInnerSizeAdjustControls( bool enabled );
bool checkHasUnsavedChanges( QString selectedAperture );
void markUnsavedChanges( bool hasChanges = true );
void openSettingsDialog( void );
void redrawChangedColorSettings( void );
void resetCurrentChanges();
void setChangeState( change_type chg = UNCHANGED );
void setListItemBackground( int idx, QColor color );
change_type getChangeState( QString selectedAperture );
void acceptChanges( void );
void generatePreview( void );
void processStateChanged( QProcess::ProcessState );
bool getAutoPreviewEnabled( void );
void setAutoPreviewEnabled( bool option );
void enableAutoPreview( bool enable );
void previewUpdate( const QImage image, QSize size );
void removeApertureItem( void );
void restoreApertureItem( void );
QColor pickColor( QColor initialColor, QString windowTitle );
void setShowTipAtStartup( bool toggle );
void openGerberPlotterDialog( bool toggle );
void openCompilationDialog( bool toggle );
void openEmbedTextDialog( bool toggle );
bool isGerberDataLoaded( void );
void setGerberDataLoaded( bool loaded );
void requestQuit( void );
#ifdef QT_DEBUG
void dumpApertureList();
void dumpApertureMacro();
#endif
private Q_SLOTS:
void afterWindowIsShown( void );
friend class sliderSizeLabel;
friend class snapSlider;
friend class apertureEditView;
friend class settingsDialog;
friend class apertureListWidget;
};
#endif // GERBERSTENCILGENERATOR_H