src/extprogs.cpp

Thu, 12 Dec 2013 19:44:09 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 12 Dec 2013 19:44:09 +0200
changeset 553
2418d5955421
parent 541
0e38beeb050a
permissions
-rw-r--r--

- LDFile renamed to LDDocument, file.h -> document.h
- Added the INSTALL document

183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
4 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
9 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
14 *
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
19 #include <QProcess>
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
20 #include <QTemporaryFile>
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
21 #include <QDialog>
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
22 #include <QDialogButtonBox>
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
23 #include <QSpinBox>
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
24 #include <QCheckBox>
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
25 #include <QComboBox>
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
26 #include <QGridLayout>
541
0e38beeb050a - Renamed common.h to main.h, split the PROPERTY macro and supporting macros to property.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 539
diff changeset
27 #include "main.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 #include "config.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 #include "misc.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
30 #include "gui.h"
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 541
diff changeset
31 #include "document.h"
202
a027f6fc6141 Un-templated CheckBoxGroup, moved it and RadioButton into widgets.cpp/widgets.h; removed license text tab because I think LICENSE is enough.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 198
diff changeset
32 #include "widgets.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 #include "history.h"
345
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
34 #include "ui_ytruder.h"
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
35 #include "ui_intersector.h"
305
401b9e3f2d10 Exported Rectifier interface to .ui file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 303
diff changeset
36 #include "ui_rectifier.h"
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
37 #include "ui_coverer.h"
302
08bd2c185b25 Converted Isecalc front-end dialog to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
38 #include "ui_isecalc.h"
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
39 #include "ui_edger2.h"
452
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
40 #include "dialogs.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
42 enum extprog
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
43 { Isecalc,
387
248296088f2c moved ext program action definitions to extprogs.cpp rather than proxying it through gui_editactions.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
44 Intersector,
248296088f2c moved ext program action definitions to extprogs.cpp rather than proxying it through gui_editactions.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
45 Coverer,
248296088f2c moved ext program action definitions to extprogs.cpp rather than proxying it through gui_editactions.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
46 Ytruder,
248296088f2c moved ext program action definitions to extprogs.cpp rather than proxying it through gui_editactions.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
47 Rectifier,
248296088f2c moved ext program action definitions to extprogs.cpp rather than proxying it through gui_editactions.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
48 Edger2,
248296088f2c moved ext program action definitions to extprogs.cpp rather than proxying it through gui_editactions.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
49 };
248296088f2c moved ext program action definitions to extprogs.cpp rather than proxying it through gui_editactions.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 382
diff changeset
50
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
52 // -----------------------------------------------------------------------------
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
53 cfg (String, prog_isecalc, "");
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
54 cfg (String, prog_intersector, "");
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
55 cfg (String, prog_coverer, "");
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
56 cfg (String, prog_ytruder, "");
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
57 cfg (String, prog_rectifier, "");
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
58 cfg (String, prog_edger2, "");
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
60 StringConfig* const g_extProgPaths[] =
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
61 { &prog_isecalc,
452
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
62 &prog_intersector,
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
63 &prog_coverer,
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
64 &prog_ytruder,
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
65 &prog_rectifier,
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
66 &prog_edger2,
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
67 };
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
68
300
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
69 #ifndef _WIN32
461
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
70 cfg (Bool, prog_isecalc_wine, false);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
71 cfg (Bool, prog_intersector_wine, false);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
72 cfg (Bool, prog_coverer_wine, false);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
73 cfg (Bool, prog_ytruder_wine, false);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
74 cfg (Bool, prog_rectifier_wine, false);
fbcc91ae1dd2 - added "Go to line" action, renamed the config classes to proper camelcase
Santeri Piippo <crimsondusk64@gmail.com>
parents: 460
diff changeset
75 cfg (Bool, prog_edger2_wine, false);
300
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
76
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
77 BoolConfig* const g_extProgWine[] =
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
78 { &prog_isecalc_wine,
300
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
79 &prog_intersector_wine,
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
80 &prog_coverer_wine,
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
81 &prog_ytruder_wine,
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
82 &prog_rectifier_wine,
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
83 &prog_edger2_wine,
300
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
84 };
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
85 #endif // _WIN32
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
86
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
87 const char* g_extProgNames[] =
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
88 { "Isecalc",
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
89 "Intersector",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
90 "Coverer",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 "Ytruder",
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
92 "Rectifier",
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
93 "Edger2"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 };
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
96 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
97 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
98 static bool checkProgPath (const extprog prog)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
99 { alias path = g_extProgPaths[prog]->value;
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
100
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
101 if (path.length() > 0)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 return true;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
103
452
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
104 ExtProgPathPrompt* dlg = new ExtProgPathPrompt (g_extProgNames[prog]);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
105
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
106 if (dlg->exec() && !dlg->getPath().isEmpty())
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
107 { path = dlg->getPath();
452
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
108 return true;
47cc663e4ff4 ask the user for ext prog paths instead of telling to go to configuration if no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 421
diff changeset
109 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
110
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 return false;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
115 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
116 static str processErrorString (QProcess& proc)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
117 { switch (proc.error())
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
118 { case QProcess::FailedToStart:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
119 return "Failed to start (check your permissions)";
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
120
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
121 case QProcess::Crashed:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
122 return "Crashed.";
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
123
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
124 case QProcess::WriteError:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
125 case QProcess::ReadError:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
126 return "I/O error.";
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
127
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
128 case QProcess::UnknownError:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
129 return "Unknown error";
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
130
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
131 case QProcess::Timedout:
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
132 return fmt ("Timed out (30 seconds)");
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
134
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
135 return "";
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
136 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
137
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
139 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
140 static bool mkTempFile (QTemporaryFile& tmp, str& fname)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
141 { if (!tmp.open())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 return false;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
143
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
144 fname = tmp.fileName();
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
145 tmp.close();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 return true;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
150 // -----------------------------------------------------------------------------
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
151 static void writeObjects (const QList<LDObject*>& objects, File& f)
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
152 { for (LDObject* obj : objects)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
153 { if (obj->getType() == LDObject::Subfile)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
154 { LDSubfile* ref = static_cast<LDSubfile*> (obj);
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
155 QList<LDObject*> objs = ref->inlineContents (LDSubfile::DeepInline);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
156
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
157 writeObjects (objs, f);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
158
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
159 for (LDObject* obj : objs)
207
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
160 delete obj;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
161 }
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
162 else
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
163 f.write (obj->raw() + "\r\n");
207
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
164 }
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
165 }
e8c47e51e03d Made drawing an edit mode, allowing me to add more modes in the future
Santeri Piippo <crimsondusk64@gmail.com>
parents: 205
diff changeset
166
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
167 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
168 // -----------------------------------------------------------------------------
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
169 static void writeObjects (const QList<LDObject*>& objects, str fname)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
170 { // Write the input file
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
171 File f (fname, File::Write);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
172
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
173 if (!f)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
174 { critical (fmt ("Couldn't open temporary file %1 for writing.\n", fname));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
177
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
178 writeObjects (objects, f);
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
179 f.close();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
180 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
183 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
184 void writeSelection (str fname)
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
185 { writeObjects (selection(), fname);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
189 // -----------------------------------------------------------------------------
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 526
diff changeset
190 void writeColorGroup (const int colnum, str fname)
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
191 { QList<LDObject*> objects;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
192
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 541
diff changeset
193 for (LDObject* obj : getCurrentDocument()->getObjects())
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
194 { if (obj->isColored() == false || obj->getColor() != colnum)
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 continue;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
196
252
3f9067022d74 Take the aforementioned operator<< into use
Santeri Piippo <crimsondusk64@gmail.com>
parents: 251
diff changeset
197 objects << obj;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
199
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 writeObjects (objects, fname);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
202
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
203 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
204 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
205 bool runUtilityProcess (extprog prog, str path, str argvstr)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
206 { QTemporaryFile input, output;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
207 str inputname, outputname;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
208 QStringList argv = argvstr.split (" ", QString::SkipEmptyParts);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
209
300
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
210 #ifndef _WIN32
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
211 if (*g_extProgWine[prog])
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
212 { argv.insert (0, path);
300
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
213 path = "wine";
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
214 }
0c7e00cc3d44 Added support for launching external programs with Wine
Santeri Piippo <crimsondusk64@gmail.com>
parents: 288
diff changeset
215 #endif // _WIN32
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
216
513
29eb671b34f6 Added a crash catcher which trigger under Linux. It calls GDB and tries to get a backtrace. Also integrated assertion failure handling to this new system. Removed the print() function in the process (because the new bomb box uses a text edit and QTextDocuments's print method clashes with the macro and I figured it was a good idea to rid it anyway) and replaced all calls with log().
Santeri Piippo <crimsondusk64@gmail.com>
parents: 504
diff changeset
217 log ("cmdline: %1 %2\n", path, argv.join (" "));
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
218
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
219 // Temporary files for stdin and stdout
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
220 if (!mkTempFile (input, inputname) || !mkTempFile (output, outputname))
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
221 return false;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
222
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
223 QProcess proc;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
224
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
225 // Init stdin
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
226 File stdinfp (inputname, File::Write);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
227
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
228 // Begin!
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
229 proc.setStandardInputFile (inputname);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
230 proc.start (path, argv);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
231
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
232 // Write an enter, the utility tools all expect one
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
233 stdinfp.write ("\n");
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
234
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235 // Wait while it runs
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
236 proc.waitForFinished();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
237
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
238 str err = "";
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
239
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
240 if (proc.exitStatus() != QProcess::NormalExit)
305
401b9e3f2d10 Exported Rectifier interface to .ui file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 303
diff changeset
241 err = processErrorString (proc);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
242
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
243 // Check the return code
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
244 if (proc.exitCode() != 0)
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
245 err = fmt ("Program exited abnormally (return code %1).", proc.exitCode());
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
246
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
247 if (err.length() > 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
248 { critical (fmt ("%1 failed: %2\n", g_extProgNames[prog], err));
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
249 return false;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
250 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
251
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
252 return true;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
255 // =============================================================================
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
256 // -----------------------------------------------------------------------------
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 526
diff changeset
257 static void insertOutput (str fname, bool replace, QList<int> colorsToReplace)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
258 {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 #ifndef RELEASE
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260 QFile::copy (fname, "./debug_lastOutput");
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261 #endif // RELEASE
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
262
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
263 // Read the output file
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
264 File f (fname, File::Read);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
265
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
266 if (!f)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
267 { critical (fmt ("Couldn't open temporary file %1 for reading.\n", fname));
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
268 return;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
270
504
6a1fa662bfc1 Removed the List -> QList alias, use QList directly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 493
diff changeset
271 QList<LDObject*> objs = loadFileContents (&f, null);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
272
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 // If we replace the objects, delete the selection now.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
274 if (replace)
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
275 g_win->deleteSelection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
276
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 526
diff changeset
277 for (const int colnum : colorsToReplace)
265
955c0aabfebf Purged out the old history code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 252
diff changeset
278 g_win->deleteByColor (colnum);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
279
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280 // Insert the new objects
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 541
diff changeset
281 getCurrentDocument()->clearSelection();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
282
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
283 for (LDObject * obj : objs)
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
284 { if (!obj->isScemantic())
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
285 { delete obj;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286 continue;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
288
553
2418d5955421 - LDFile renamed to LDDocument, file.h -> document.h
Santeri Piippo <crimsondusk64@gmail.com>
parents: 541
diff changeset
289 getCurrentDocument()->addObject (obj);
522
afa691788bdb - migrated selection from ForgeWindow to individual LDFiles. Should've done this long ago.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 513
diff changeset
290 obj->select();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
292
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 526
diff changeset
293 g_win->doFullRefresh();
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
294 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
295
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
296 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
297 // Interface for Ytruder
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
298 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
299 DEFINE_ACTION (Ytruder, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
300 { setlocale (LC_ALL, "C");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
301
454
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
302 if (!checkProgPath (Ytruder))
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
303 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
304
345
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
305 QDialog* dlg = new QDialog;
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
306 Ui::YtruderUI ui;
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
307 ui.setupUi (dlg);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
308
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
309 if (!dlg->exec())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
310 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
311
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 // Read the user's choices
345
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
313 const enum { Distance, Symmetry, Projection, Radial } mode =
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
314 ui.mode_distance->isChecked() ? Distance :
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
315 ui.mode_symmetry->isChecked() ? Symmetry :
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
316 ui.mode_projection->isChecked() ? Projection : Radial;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
317
345
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
318 const Axis axis =
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
319 ui.axis_x->isChecked() ? X :
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
320 ui.axis_y->isChecked() ? Y : Z;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
321
345
1376ad3262ba Converted Ytruder interface to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 343
diff changeset
322 const double depth = ui.planeDepth->value(),
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
323 condAngle = ui.condAngle->value();
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
324
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
325 QTemporaryFile indat, outdat;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
326 str inDATName, outDATName;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
327
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
328 // Make temp files for the input and output files
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
329 if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName))
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
330 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
331
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
332 // Compose the command-line arguments
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
333 str argv = join (
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
334 { (axis == X) ? "-x" : (axis == Y) ? "-y" : "-z",
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
335 (mode == Distance) ? "-d" : (mode == Symmetry) ? "-s" : (mode == Projection) ? "-p" : "-r",
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
336 depth,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
337 "-a",
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
338 condAngle,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
339 inDATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
340 outDATName
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
341 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
342
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
343 writeSelection (inDATName);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
344
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
345 if (!runUtilityProcess (Ytruder, prog_ytruder, argv))
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
346 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
347
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
348 insertOutput (outDATName, false, {});
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
349 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
350
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
351 // =============================================================================
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
352 // Rectifier interface
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
353 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
354 DEFINE_ACTION (Rectifier, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
355 { setlocale (LC_ALL, "C");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
356
454
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
357 if (!checkProgPath (Rectifier))
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
358 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
359
305
401b9e3f2d10 Exported Rectifier interface to .ui file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 303
diff changeset
360 QDialog* dlg = new QDialog;
401b9e3f2d10 Exported Rectifier interface to .ui file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 303
diff changeset
361 Ui::RectifierUI ui;
401b9e3f2d10 Exported Rectifier interface to .ui file
Santeri Piippo <crimsondusk64@gmail.com>
parents: 303
diff changeset
362 ui.setupUi (dlg);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
363
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
364 if (!dlg->exec())
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
365 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
366
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
367 QTemporaryFile indat, outdat;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
368 str inDATName, outDATName;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
369
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
370 // Make temp files for the input and output files
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
371 if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName))
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
372 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
373
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
374 // Compose arguments
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
375 str argv = join (
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
376 { (!ui.cb_condense->isChecked()) ? "-q" : "",
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
377 (!ui.cb_subst->isChecked()) ? "-r" : "",
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
378 (ui.cb_condlineCheck->isChecked()) ? "-a" : "",
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
379 (ui.cb_colorize->isChecked()) ? "-c" : "",
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
380 "-t",
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
381 ui.dsb_coplthres->value(),
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
382 inDATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
383 outDATName
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
384 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
385
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
386 writeSelection (inDATName);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
387
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
388 if (!runUtilityProcess (Rectifier, prog_rectifier, argv))
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
389 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
390
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
391 insertOutput (outDATName, true, {});
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
392 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
393
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
394 // =============================================================================
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
395 // Intersector interface
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
396 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
397 DEFINE_ACTION (Intersector, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
398 { setlocale (LC_ALL, "C");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
399
454
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
400 if (!checkProgPath (Intersector))
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
401 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
402
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
403 QDialog* dlg = new QDialog;
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
404 Ui::IntersectorUI ui;
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
405 ui.setupUi (dlg);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
406
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
407 makeColorComboBox (ui.cmb_incol);
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
408 makeColorComboBox (ui.cmb_cutcol);
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
409 ui.cb_repeat->setWhatsThis ("If this is set, " APPNAME " runs Intersector a second time with inverse files to cut the "
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
410 " cutter group with the input group. Both groups are cut by the intersection.");
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
411 ui.cb_edges->setWhatsThis ("Makes " APPNAME " try run Isecalc to create edgelines for the intersection.");
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
412
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 526
diff changeset
413 int inCol, cutCol;
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
414 const bool repeatInverse = ui.cb_repeat->isChecked();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
415
526
b29b6fc45ba9 style corrections
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
416 forever
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
417 { if (!dlg->exec())
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
418 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
419
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
420 inCol = ui.cmb_incol->itemData (ui.cmb_incol->currentIndex()).toInt();
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
421 cutCol = ui.cmb_cutcol->itemData (ui.cmb_cutcol->currentIndex()).toInt();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
422
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
423 if (inCol == cutCol)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
424 { critical ("Cannot use the same color group for both input and cutter!");
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
425 continue;
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
426 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
427
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
428 break;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
430
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
431 // Five temporary files!
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
432 // indat = input group file
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
433 // cutdat = cutter group file
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434 // outdat = primary output
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435 // outdat2 = inverse output
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436 // edgesdat = edges output (isecalc)
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
437 QTemporaryFile indat, cutdat, outdat, outdat2, edgesdat;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
438 str inDATName, cutDATName, outDATName, outDAT2Name, edgesDATName;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
439
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 if (!mkTempFile (indat, inDATName) || !mkTempFile (cutdat, cutDATName) ||
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
441 !mkTempFile (outdat, outDATName) || !mkTempFile (outdat2, outDAT2Name) ||
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
442 !mkTempFile (edgesdat, edgesDATName))
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
443 { return;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
444 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
445
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
446 str parms = join (
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
447 { (ui.cb_colorize->isChecked()) ? "-c" : "",
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
448 (ui.cb_nocondense->isChecked()) ? "-t" : "",
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
449 "-s",
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
450 ui.dsb_prescale->value()
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
451 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
452
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
453 str argv_normal = join (
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
454 { parms,
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
455 inDATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
456 cutDATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
457 outDATName
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
458 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
459
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
460 str argv_inverse = join (
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
461 { parms,
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
462 cutDATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
463 inDATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
464 outDAT2Name
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
465 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
466
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
467 writeColorGroup (inCol, inDATName);
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
468 writeColorGroup (cutCol, cutDATName);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
469
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
470 if (!runUtilityProcess (Intersector, prog_intersector, argv_normal))
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
471 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
472
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473 insertOutput (outDATName, false, {inCol});
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
474
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
475 if (repeatInverse && runUtilityProcess (Intersector, prog_intersector, argv_inverse))
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
476 insertOutput (outDAT2Name, false, {cutCol});
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
477
454
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
478 if (
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
479 ui.cb_edges->isChecked() &&
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
480 checkProgPath (Isecalc) &&
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
481 runUtilityProcess (Isecalc, prog_isecalc, join ( {inDATName, cutDATName, edgesDATName}))
454
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
482 )
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483 insertOutput (edgesDATName, false, {});
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
484 }
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
485
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
486 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
487 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
488 DEFINE_ACTION (Coverer, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
489 { setlocale (LC_ALL, "C");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
490
454
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
491 if (!checkProgPath (Coverer))
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
492 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
493
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
494 QDialog* dlg = new QDialog;
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
495 Ui::CovererUI ui;
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
496 ui.setupUi (dlg);
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
497 makeColorComboBox (ui.cmb_col1);
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
498 makeColorComboBox (ui.cmb_col2);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
499
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 526
diff changeset
500 int in1Col, in2Col;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
501
526
b29b6fc45ba9 style corrections
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
502 forever
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
503 { if (!dlg->exec())
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
504 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
505
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
506 in1Col = ui.cmb_col1->itemData (ui.cmb_col1->currentIndex()).toInt();
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
507 in2Col = ui.cmb_col2->itemData (ui.cmb_col2->currentIndex()).toInt();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
508
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
509 if (in1Col == in2Col)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
510 { critical ("Cannot use the same color group for both input and cutter!");
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
511 continue;
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
512 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
513
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
514 break;
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
515 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
516
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
517 QTemporaryFile in1dat, in2dat, outdat;
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
518 str in1DATName, in2DATName, outDATName;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
519
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
520 if (!mkTempFile (in1dat, in1DATName) || !mkTempFile (in2dat, in2DATName) || !mkTempFile (outdat, outDATName))
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
521 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
522
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
523 str argv = join (
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
524 { (ui.cb_oldsweep->isChecked() ? "-s" : ""),
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
525 (ui.cb_reverse->isChecked() ? "-r" : ""),
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
526 (ui.dsb_segsplit->value() != 0 ? fmt ("-l %1", ui.dsb_segsplit->value()) : ""),
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
527 (ui.sb_bias->value() != 0 ? fmt ("-s %1", ui.sb_bias->value()) : ""),
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
528 in1DATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
529 in2DATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
530 outDATName
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
531 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
532
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
533 writeColorGroup (in1Col, in1DATName);
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
534 writeColorGroup (in2Col, in2DATName);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
535
303
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
536 if (!runUtilityProcess (Coverer, prog_coverer, argv))
8899806d382d Converted Intersector UI, improved handling of failed ext program launches, fixed launch of non-wine programs
Santeri Piippo <crimsondusk64@gmail.com>
parents: 302
diff changeset
537 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
538
203
ccde5e88f0b6 Added Coverer interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 202
diff changeset
539 insertOutput (outDATName, false, {});
205
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
540 }
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
541
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
542 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
543 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
544 DEFINE_ACTION (Isecalc, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
545 { setlocale (LC_ALL, "C");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
546
454
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
547 if (!checkProgPath (Isecalc))
205
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
548 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
549
302
08bd2c185b25 Converted Isecalc front-end dialog to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
550 Ui::IsecalcUI ui;
08bd2c185b25 Converted Isecalc front-end dialog to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
551 QDialog* dlg = new QDialog;
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
552 ui.setupUi (dlg);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
553
539
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
554 makeColorComboBox (ui.cmb_col1);
72ad83a67165 - upgraded the PROPERTY macro, resulting in a major code refactor
Santeri Piippo <crimsondusk64@gmail.com>
parents: 538
diff changeset
555 makeColorComboBox (ui.cmb_col2);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
556
538
2f85d4d286e5 - ensured header files' guards start with LDFORGE_
Santeri Piippo <crimsondusk64@gmail.com>
parents: 526
diff changeset
557 int in1Col, in2Col;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
558
302
08bd2c185b25 Converted Isecalc front-end dialog to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
559 // Run the dialog and validate input
526
b29b6fc45ba9 style corrections
Santeri Piippo <crimsondusk64@gmail.com>
parents: 522
diff changeset
560 forever
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
561 { if (!dlg->exec())
302
08bd2c185b25 Converted Isecalc front-end dialog to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
562 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
563
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
564 in1Col = ui.cmb_col1->itemData (ui.cmb_col1->currentIndex()).toInt(),
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
565 in2Col = ui.cmb_col1->itemData (ui.cmb_col2->currentIndex()).toInt();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
566
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
567 if (in1Col == in2Col)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
568 { critical ("Cannot use the same color group for both input and cutter!");
302
08bd2c185b25 Converted Isecalc front-end dialog to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
569 continue;
08bd2c185b25 Converted Isecalc front-end dialog to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
570 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
571
302
08bd2c185b25 Converted Isecalc front-end dialog to Designer UI
Santeri Piippo <crimsondusk64@gmail.com>
parents: 301
diff changeset
572 break;
205
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
573 }
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
574
205
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
575 QTemporaryFile in1dat, in2dat, outdat;
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
576 str in1DATName, in2DATName, outDATName;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
577
205
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
578 if (!mkTempFile (in1dat, in1DATName) || !mkTempFile (in2dat, in2DATName) || !mkTempFile (outdat, outDATName))
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
579 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
580
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
581 str argv = join (
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
582 { in1DATName,
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
583 in2DATName,
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
584 outDATName
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 274
diff changeset
585 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
586
205
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
587 writeColorGroup (in1Col, in1DATName);
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
588 writeColorGroup (in2Col, in2DATName);
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
589 runUtilityProcess (Isecalc, prog_isecalc, argv);
d60cf73fb164 Added Isecalc interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 203
diff changeset
590 insertOutput (outDATName, false, {});
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
591 }
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
592
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
593 // =============================================================================
455
c5d14d112034 Code formatting: use same separators everywhere, remove extra spaces from license headers, simplified message manager api a bit
Santeri Piippo <crimsondusk64@gmail.com>
parents: 454
diff changeset
594 // -----------------------------------------------------------------------------
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
595 DEFINE_ACTION (Edger2, 0)
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
596 { setlocale (LC_ALL, "C");
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
597
454
d6b4ed3bf169 ask the user for isecalc's path if adding edges to intersector output and no path is defined
Santeri Piippo <crimsondusk64@gmail.com>
parents: 452
diff changeset
598 if (!checkProgPath (Edger2))
343
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
599 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
600
343
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
601 QDialog* dlg = new QDialog;
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
602 Ui::Edger2Dialog ui;
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
603 ui.setupUi (dlg);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
604
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
605 if (!dlg->exec())
343
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
606 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
607
343
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
608 QTemporaryFile in, out;
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
609 str inName, outName;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
610
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
611 if (!mkTempFile (in, inName) || !mkTempFile (out, outName))
301
ef51681bb978 Added an ui file for a to-be edger2 launcher
Santeri Piippo <crimsondusk64@gmail.com>
parents: 300
diff changeset
612 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
613
343
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
614 int unmatched = ui.unmatched->currentIndex();
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
615
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
616 str argv = join (
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
617 { fmt ("-p %1", ui.precision->value()),
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
618 fmt ("-af %1", ui.flatAngle->value()),
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
619 fmt ("-ac %1", ui.condAngle->value()),
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
620 fmt ("-ae %1", ui.edgeAngle->value()),
343
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
621 ui.delLines->isChecked() ? "-de" : "",
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
622 ui.delCondLines->isChecked() ? "-dc" : "",
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
623 ui.colored->isChecked() ? "-c" : "",
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
624 ui.bfc->isChecked() ? "-b" : "",
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
625 ui.convex->isChecked() ? "-cx" : "",
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
626 ui.concave->isChecked() ? "-cv" : "",
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
627 unmatched == 0 ? "-u+" : (unmatched == 2 ? "-u-" : ""),
343
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
628 inName,
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
629 outName,
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
630 });
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
631
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
632 writeSelection (inName);
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
633
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
634 if (!runUtilityProcess (Edger2, prog_edger2, argv))
343
75487752f3e6 Completed Edger 2 interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 312
diff changeset
635 return;
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
636
378
bc3f40dcfa9e more formatting
Santeri Piippo <crimsondusk64@gmail.com>
parents: 377
diff changeset
637 insertOutput (outName, true, {});
493
16766ac1bbd9 last code reformatting i swear
Santeri Piippo <crimsondusk64@gmail.com>
parents: 484
diff changeset
638 }

mercurial