Tue, 07 May 2013 19:48:51 +0300
Added Intersector interface. I'm beginning to think that groups were a bad idea...
166
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
1 | /* |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
4 | * |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
8 | * (at your option) any later version. |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
9 | * |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
13 | * GNU General Public License for more details. |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
14 | * |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
17 | */ |
72ec7b60da54
add missing license headers from new files
Santeri Piippo <crimsondusk64@gmail.com>
parents:
165
diff
changeset
|
18 | |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
19 | #include <qprocess.h> |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
20 | #include <qtemporaryfile.h> |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
21 | #include <qeventloop.h> |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
22 | #include <qdialog.h> |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
23 | #include <qdialogbuttonbox.h> |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
24 | #include <qspinbox.h> |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
25 | #include <qcheckbox.h> |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
26 | #include <qcombobox.h> |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | #include "common.h" |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | #include "config.h" |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | #include "misc.h" |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | #include "extprogs.h" |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #include "gui.h" |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
32 | #include "file.h" |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
33 | #include "radiobox.h" |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
34 | #include "history.h" |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
35 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | // ============================================================================= |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | cfg (str, prog_isecalc, ""); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | cfg (str, prog_intersector, ""); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | cfg (str, prog_coverer, ""); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
40 | cfg (str, prog_ytruder, ""); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
41 | cfg (str, prog_datheader, ""); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
42 | cfg (str, prog_rectifier, ""); |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
43 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
44 | const char* g_extProgNames[] = { |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | "Isecalc", |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | "Intersector", |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
47 | "Coverer", |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
48 | "Ytruder", |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
49 | "Rectifier", |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
50 | "DATHeader", |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
51 | }; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
52 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
53 | // ============================================================================= |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
54 | static bool checkProgPath (str path, const extprog prog) { |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
55 | if (~path) |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
56 | return true; |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
57 | |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
58 | const char* name = g_extProgNames[prog]; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
59 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
60 | critical (fmt ("Couldn't run %s as no path has " |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
61 | "been defined for it. Use the configuration dialog's External Programs " |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
62 | "tab to define a path for %s.", name, name)); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
63 | return false; |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
64 | } |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
65 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
66 | // ============================================================================= |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
67 | static void processError (const extprog prog, QProcess& proc) { |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
68 | const char* name = g_extProgNames[prog]; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
69 | str errmsg; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
70 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
71 | switch (proc.error ()) { |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
72 | case QProcess::FailedToStart: |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
73 | errmsg = fmt ("Failed to launch %s. Check that you have set the proper path " |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
74 | "to %s and that you have the proper permissions to launch it.", name, name); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
75 | break; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
76 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
77 | case QProcess::Crashed: |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
78 | errmsg = fmt ("%s crashed.", name); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
79 | break; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
80 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
81 | case QProcess::WriteError: |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
82 | case QProcess::ReadError: |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
83 | errmsg = fmt ("I/O error while interacting with %s.", name); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
84 | break; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
85 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
86 | case QProcess::UnknownError: |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
87 | errmsg = fmt ("Unknown error occurred while executing %s.", name); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
88 | break; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
89 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
90 | case QProcess::Timedout: |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
91 | errmsg = fmt ("%s timed out.", name); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
92 | break; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
93 | } |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
94 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
95 | critical (errmsg); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
96 | } |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
97 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
98 | // ============================================================================= |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
99 | static bool mkTempFile (QTemporaryFile& tmp, str& fname) { |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
100 | if (!tmp.open ()) |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
101 | return false; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
102 | |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
103 | fname = tmp.fileName (); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
104 | tmp.close (); |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
105 | return true; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
106 | } |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
107 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
108 | // ============================================================================= |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
109 | void writeObjects (std::vector<LDObject*>& objects, str fname) { |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
110 | // Write the input file |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
111 | FILE* fp = fopen (fname, "w"); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
112 | if (!fp) { |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
113 | critical (fmt ("Couldn't open temporary file %s for writing.\n", fname.chars ())); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
114 | return; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
115 | } |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
116 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
117 | for (LDObject* obj : objects) { |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
118 | str line = fmt ("%s\r\n", obj->getContents ().chars ()); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
119 | fwrite (line.chars(), 1, ~line, fp); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
120 | } |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
121 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
122 | fclose (fp); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
123 | } |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
124 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
125 | // ============================================================================= |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
126 | void writeSelection (str fname) { |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
127 | writeObjects (g_win->sel (), fname); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
128 | } |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
129 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
130 | // ============================================================================= |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
131 | void writeGroup (const LDObject::Group group, str fname) { |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
132 | std::vector<LDObject*> objects; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
133 | for (LDObject*& obj : g_curfile->m_objs) { |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
134 | if (obj->group() != group) |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
135 | continue; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
136 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
137 | objects.push_back (obj); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
138 | } |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
139 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
140 | writeObjects (objects, fname); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
141 | } |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
142 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
143 | // ============================================================================= |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
144 | void runUtilityProcess (extprog prog, str path, QString argvstr) { |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
145 | QTemporaryFile input, output; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
146 | str inputname, outputname; |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
147 | QStringList argv = argvstr.split (" ", QString::SkipEmptyParts); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
148 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
149 | printf ("cmdline: %s %s\n", path.chars (), qchars (argvstr)); |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
150 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
151 | if (!mkTempFile (input, inputname) || !mkTempFile (output, outputname)) |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
152 | return; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
153 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
154 | QProcess proc; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
155 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
156 | // Init stdin |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
157 | FILE* stdinfp = fopen (inputname, "w"); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
158 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
159 | // Begin! |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
160 | proc.setStandardInputFile (inputname); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
161 | proc.start (path, argv); |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
162 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
163 | // Write an enter - one is expected |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
164 | char enter[2] = "\n"; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
165 | enter[1] = '\0'; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
166 | fwrite (enter, 1, sizeof enter, stdinfp); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
167 | fflush (stdinfp); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
168 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
169 | // Wait while it runs |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
170 | proc.waitForFinished (); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
171 | |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
172 | #ifndef RELASE |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
173 | printf ("%s", qchars (QString (proc.readAllStandardOutput ()))); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
174 | #endif |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
175 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
176 | if (proc.exitStatus () == QProcess::CrashExit) { |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
177 | processError (prog, proc); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
178 | return; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
179 | } |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
180 | } |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
181 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
182 | // ======================================================================================================================================== |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
183 | static void insertOutput (str fname, bool replace, vector<LDObject::Group> groupsToReplace) { |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
184 | #ifndef RELEASE |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
185 | QFile::copy (fname, "./output.dat"); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
186 | #endif |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
187 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
188 | // Read the output file |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
189 | FILE* fp = fopen (fname, "r"); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
190 | if (!fp) { |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
191 | critical (fmt ("Couldn't open temporary file %s for reading.\n", fname.chars ())); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
192 | return; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
193 | } |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
194 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
195 | ComboHistory* cmb = new ComboHistory ({}); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
196 | std::vector<LDObject*> objs = loadFileContents (fp, null), |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
197 | copies; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
198 | std::vector<ulong> indices; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
199 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
200 | // If we replace the objects, delete the selection now. |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
201 | if (replace) |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
202 | *cmb << g_win->deleteSelection (); |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
203 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
204 | for (const LDObject::Group group : groupsToReplace) |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
205 | *cmb << g_win->deleteGroup (group); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
206 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
207 | // Insert the new objects |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
208 | g_win->sel ().clear (); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
209 | for (LDObject* obj : objs) { |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
210 | if (!obj->isSchemantic ()) { |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
211 | delete obj; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
212 | continue; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
213 | } |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
214 | |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
215 | ulong idx = g_curfile->addObject (obj); |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
216 | indices.push_back (idx); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
217 | copies.push_back (obj->clone ()); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
218 | g_win->sel ().push_back (obj); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
219 | } |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
220 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
221 | if (indices.size() > 0) |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
222 | *cmb << new AddHistory ({indices, copies}); |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
223 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
224 | if (cmb->paEntries.size () > 0) |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
225 | History::addEntry (cmb); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
226 | else |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
227 | delete cmb; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
228 | |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
229 | fclose (fp); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
230 | g_win->refresh (); |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
231 | } |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
232 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
233 | QDialogButtonBox* makeButtonBox (QDialog& dlg) { |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
234 | QDialogButtonBox* bbx_buttons = new QDialogButtonBox (QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
235 | QWidget::connect (bbx_buttons, SIGNAL (accepted ()), &dlg, SLOT (accept ())); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
236 | QWidget::connect (bbx_buttons, SIGNAL (rejected ()), &dlg, SLOT (reject ())); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
237 | return bbx_buttons; |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
238 | } |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
239 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
240 | // ============================================================================= |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
241 | // Interface for Ytruder |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
242 | MAKE_ACTION (ytruder, "Ytruder", "ytruder", "Extrude selected lines to a given plane", KEY (F8)) { |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
243 | setlocale (LC_ALL, "C"); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
244 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
245 | if (!checkProgPath (prog_ytruder, Ytruder)) |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
246 | return; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
247 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
248 | QDialog dlg; |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
249 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
250 | RadioBox* rb_mode = new RadioBox ("Extrusion mode", {"Distance", "Symmetry", "Projection", "Radial"}, 0, Qt::Horizontal); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
251 | RadioBox* rb_axis = new RadioBox ("Axis", {"X", "Y", "Z"}, 0, Qt::Horizontal); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
252 | LabeledWidget<QDoubleSpinBox>* dsb_depth = new LabeledWidget<QDoubleSpinBox> ("Plane depth"), |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
253 | *dsb_condAngle = new LabeledWidget<QDoubleSpinBox> ("Conditional line threshold"); |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
254 | |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
255 | rb_axis->setValue (Y); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
256 | dsb_depth->w ()->setMinimum (-10000.0); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
257 | dsb_depth->w ()->setMaximum (10000.0); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
258 | dsb_depth->w ()->setDecimals (3); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
259 | dsb_condAngle->w ()->setValue (30.0f); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
260 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
261 | QVBoxLayout* layout = new QVBoxLayout (&dlg); |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
262 | layout->addWidget (rb_mode); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
263 | layout->addWidget (rb_axis); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
264 | layout->addWidget (dsb_depth); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
265 | layout->addWidget (dsb_condAngle); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
266 | layout->addWidget (makeButtonBox (dlg)); |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
267 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
268 | dlg.setWindowIcon (getIcon ("extrude")); |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
269 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
270 | if (!dlg.exec ()) |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
271 | return; |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
272 | |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
273 | // Read the user's choices |
167
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
274 | const enum modetype { Distance, Symmetry, Projection, Radial } mode = (modetype) rb_mode->value (); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
275 | const Axis axis = (Axis) rb_axis->value (); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
276 | const double depth = dsb_depth->w ()->value (), |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
277 | condAngle = dsb_condAngle->w ()->value (); |
df78c894ae24
Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents:
166
diff
changeset
|
278 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
279 | QTemporaryFile indat, outdat; |
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
280 | str inDATName, outDATName; |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
281 | |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
282 | // Make temp files for the input and output files |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
283 | if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName)) |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
284 | return; |
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
285 | |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
286 | // Compose the command-line arguments |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
287 | str argv = fmt ("%s %s %f -a %f %s %s", |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
288 | (axis == X) ? "-x" : (axis == Y) ? "-y" : "-z", |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
289 | (mode == Distance) ? "-d" : (mode == Symmetry) ? "-s" : (mode == Projection) ? "-p" : "-r", |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
290 | depth, condAngle, inDATName.chars (), outDATName.chars ()); |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
291 | |
168
96691a009dff
Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents:
167
diff
changeset
|
292 | writeSelection (inDATName); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
293 | runUtilityProcess (Ytruder, prog_ytruder, argv); |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
294 | insertOutput (outDATName, false, {}); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
295 | } |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
296 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
297 | // ======================================================================================================================================== |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
298 | // Rectifier interface |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
299 | MAKE_ACTION (rectifier, "Rectifier", "rectifier", "Optimizes quads into rect primitives.", (0)) { |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
300 | setlocale (LC_ALL, "C"); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
301 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
302 | if (!checkProgPath (prog_rectifier, Rectifier)) |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
303 | return; |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
304 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
305 | QDialog dlg; |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
306 | QCheckBox* cb_condense = new QCheckBox ("Condense triangles to quads"), |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
307 | *cb_subst = new QCheckBox ("Substitute rect primitives"), |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
308 | *cb_condlineCheck = new QCheckBox ("Don't replace quads with adj. condlines"), |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
309 | *cb_colorize = new QCheckBox ("Colorize resulting objects"); |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
310 | LabeledWidget<QDoubleSpinBox>* dsb_coplthres = new LabeledWidget<QDoubleSpinBox> ("Coplanarity threshold"); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
311 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
312 | dsb_coplthres->w ()->setMinimum (0.0f); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
313 | dsb_coplthres->w ()->setMaximum (360.0f); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
314 | dsb_coplthres->w ()->setDecimals (3); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
315 | dsb_coplthres->w ()->setValue (0.95f); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
316 | cb_condense->setChecked (true); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
317 | cb_subst->setChecked (true); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
318 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
319 | QVBoxLayout* layout = new QVBoxLayout (&dlg); |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
320 | layout->addWidget (cb_condense); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
321 | layout->addWidget (cb_subst); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
322 | layout->addWidget (cb_condlineCheck); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
323 | layout->addWidget (cb_colorize); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
324 | layout->addWidget (dsb_coplthres); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
325 | layout->addWidget (makeButtonBox (dlg)); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
326 | |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
327 | if (!dlg.exec ()) |
174
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
328 | return; |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
329 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
330 | const bool condense = cb_condense->isChecked (), |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
331 | subst = cb_subst->isChecked (), |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
332 | condlineCheck = cb_condlineCheck->isChecked (), |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
333 | colorize = cb_colorize->isChecked (); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
334 | const double coplthres = dsb_coplthres->w ()->value (); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
335 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
336 | QTemporaryFile indat, outdat; |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
337 | str inDATName, outDATName; |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
338 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
339 | // Make temp files for the input and output files |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
340 | if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName)) |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
341 | return; |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
342 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
343 | // Compose arguments |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
344 | str argv = fmt ("%s %s %s %s -t %f %s %s", |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
345 | (condense == false) ? "-q" : "", |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
346 | (subst == false) ? "-r" : "", |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
347 | (condlineCheck) ? "-a" : "", |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
348 | (colorize) ? "-c" : "", |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
349 | coplthres, inDATName.chars (), outDATName.chars ()); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
350 | |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
351 | writeSelection (inDATName); |
963697b36118
Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents:
168
diff
changeset
|
352 | runUtilityProcess (Rectifier, prog_rectifier, argv); |
175
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
353 | insertOutput (outDATName, true, {}); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
354 | } |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
355 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
356 | // ======================================================================================================================================= |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
357 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
358 | // ======================================================================================================================================= |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
359 | // Intersector interface |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
360 | MAKE_ACTION (intersector, "Intersector", "intersector", "Perform clipping between two input groups.", (0)) { |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
361 | setlocale (LC_ALL, "C"); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
362 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
363 | if (!checkProgPath (prog_intersector, Intersector)) |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
364 | return; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
365 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
366 | QDialog dlg; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
367 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
368 | LabeledWidget<QComboBox>* cmb_ingroup = new LabeledWidget<QComboBox> ("Input group", new QComboBox), |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
369 | *cmb_cutgroup = new LabeledWidget<QComboBox> ("Cutter group", new QComboBox); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
370 | QCheckBox* cb_colorize = new QCheckBox ("Colorize output"), |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
371 | *cb_nocondense = new QCheckBox ("No condensing"), |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
372 | *cb_repeatInverse = new QCheckBox ("Repeat inverse"), |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
373 | *cb_edges = new QCheckBox ("Add edges"); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
374 | LabeledWidget<QDoubleSpinBox>* dsb_prescale = new LabeledWidget<QDoubleSpinBox> ("Prescaling factor"); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
375 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
376 | cb_repeatInverse->setWhatsThis ("If this is set, " APPNAME " runs Intersector a second time with inverse files to cut the " |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
377 | " cutter group with the input group. Both groups are cut by the intersection."); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
378 | cb_edges->setWhatsThis ("Makes " APPNAME " try run Isecalc to create edgelines for the intersection."); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
379 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
380 | makeGroupSelector (cmb_ingroup->w ()); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
381 | makeGroupSelector (cmb_cutgroup->w ()); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
382 | dsb_prescale->w ()->setMinimum (0.0f); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
383 | dsb_prescale->w ()->setMaximum (10000.0f); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
384 | dsb_prescale->w ()->setSingleStep (0.01f); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
385 | dsb_prescale->w ()->setValue (1.0f); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
386 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
387 | QVBoxLayout* layout = new QVBoxLayout (&dlg); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
388 | layout->addWidget (cmb_ingroup); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
389 | layout->addWidget (cmb_cutgroup); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
390 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
391 | QHBoxLayout* cblayout = new QHBoxLayout; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
392 | cblayout->addWidget (cb_colorize); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
393 | cblayout->addWidget (cb_nocondense); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
394 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
395 | QHBoxLayout* cb2layout = new QHBoxLayout; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
396 | cb2layout->addWidget (cb_repeatInverse); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
397 | cb2layout->addWidget (cb_edges); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
398 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
399 | layout->addLayout (cblayout); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
400 | layout->addLayout (cb2layout); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
401 | layout->addWidget (dsb_prescale); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
402 | layout->addWidget (makeButtonBox (dlg)); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
403 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
404 | exec: |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
405 | if (!dlg.exec ()) |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
406 | return; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
407 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
408 | const LDObject::Group inGroup = (LDObject::Group) cmb_ingroup->w ()->currentIndex (), |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
409 | cutGroup = (LDObject::Group) cmb_cutgroup->w ()->currentIndex (); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
410 | const bool repeatInverse = cb_repeatInverse->isChecked (); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
411 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
412 | if (inGroup == cutGroup) { |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
413 | critical ("Cannot use the same group for both input and cutter!"); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
414 | goto exec; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
415 | } |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
416 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
417 | // Five temporary files! |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
418 | // indat = input group file |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
419 | // cutdat = cutter group file |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
420 | // outdat = primary output |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
421 | // outdat2 = inverse output |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
422 | // edgesdat = edges output (isecalc) |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
423 | QTemporaryFile indat, cutdat, outdat, outdat2, edgesdat; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
424 | str inDATName, cutDATName, outDATName, outDAT2Name, edgesDATName; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
425 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
426 | if (!mkTempFile (indat, inDATName) || !mkTempFile (cutdat, cutDATName) || |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
427 | !mkTempFile (outdat, outDATName) || !mkTempFile (outdat2, outDAT2Name) || |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
428 | !mkTempFile (edgesdat, edgesDATName)) |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
429 | { |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
430 | return; |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
431 | } |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
432 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
433 | str parms = fmt ("%s %s -s %f", |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
434 | (cb_colorize->isChecked ()) ? "-c" : "", |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
435 | (cb_nocondense->isChecked ()) ? "-t" : "", |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
436 | dsb_prescale->w ()->value ()); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
437 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
438 | str argv_normal = fmt ("%s %s %s %s", parms.chars (), inDATName.chars (), cutDATName.chars (), outDATName.chars ()); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
439 | str argv_inverse = fmt ("%s %s %s %s", parms.chars (), cutDATName.chars (), inDATName.chars (), outDAT2Name.chars ()); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
440 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
441 | writeGroup (inGroup, inDATName); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
442 | writeGroup (cutGroup, cutDATName); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
443 | runUtilityProcess (Intersector, prog_intersector, argv_normal); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
444 | insertOutput (outDATName, false, {inGroup}); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
445 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
446 | if (repeatInverse) { |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
447 | runUtilityProcess (Intersector, prog_intersector, argv_inverse); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
448 | insertOutput (outDAT2Name, false, {cutGroup}); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
449 | } |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
450 | |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
451 | if (cb_edges->isChecked ()) { |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
452 | runUtilityProcess (Isecalc, prog_isecalc, fmt ("%s %s %s", inDATName.chars (), cutDATName.chars (), edgesDATName.chars ())); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
453 | insertOutput (edgesDATName, false, {}); |
b094d5e9d6e0
Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents:
174
diff
changeset
|
454 | } |
165
88a03c1a52d9
Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
455 | } |