extprogs.cpp

Wed, 08 May 2013 14:57:48 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 08 May 2013 14:57:48 +0300
changeset 182
9374fea8f77f
parent 178
bc30a6d59f7c
permissions
-rw-r--r--

Viewport no longer offsets stuff based on bbox size, that was stupid. Only use bbox size for initial zoom.

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
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
122 #ifndef RELEASE
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
123 ushort idx = rand ();
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
124 printf ("%s -> debug_%u\n", fname.chars (), idx);
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
125 QFile::copy (fname.chars (), fmt ("debug_%u", idx));
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
126 #endif // RELEASE
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
127
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
128 fclose (fp);
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
129 }
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
130
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
131 // =============================================================================
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
132 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
133 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
134 }
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
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 // =============================================================================
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
137 void writeColorGroup (const short colnum, str fname) {
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
138 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
139 for (LDObject*& obj : g_curfile->m_objs) {
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
140 if (obj->isColored () == false || obj->dColor != colnum)
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
141 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
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 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
144 }
b094d5e9d6e0 Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 174
diff changeset
145
b094d5e9d6e0 Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 174
diff changeset
146 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
147 }
b094d5e9d6e0 Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 174
diff changeset
148
b094d5e9d6e0 Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 174
diff changeset
149 // =============================================================================
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
150 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
151 QTemporaryFile input, output;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
152 str inputname, outputname;
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
153 QStringList argv = argvstr.split (" ", QString::SkipEmptyParts);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
154
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
155 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
156
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
157 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
158 return;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
159
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
160 QProcess proc;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
161
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
162 // Init stdin
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
163 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
164
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
165 // Begin!
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
166 proc.setStandardInputFile (inputname);
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
167 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
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
169 // 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
170 char enter[2] = "\n";
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
171 enter[1] = '\0';
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
172 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
173 fflush (stdinfp);
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
174
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
175 // Wait while it runs
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
176 proc.waitForFinished ();
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
177
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
178 #ifndef RELASE
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
179 printf ("%s", qchars (QString (proc.readAllStandardOutput ())));
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
180 #endif // RELEASE
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
181
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
182 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
183 processError (prog, proc);
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
184 return;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
185 }
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
186 }
165
88a03c1a52d9 Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187
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
188 // ========================================================================================================================================
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
189 static void insertOutput (str fname, bool replace, vector<short> colorsToReplace) {
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
190 #ifndef RELEASE
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
191 QFile::copy (fname, "./debug_lastOutput");
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
192 #endif // RELEASE
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
193
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
194 // Read the output file
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
195 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
196 if (!fp) {
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
197 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
198 return;
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
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
201 ComboHistory* cmb = new ComboHistory ({});
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
202 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
203 copies;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
204 std::vector<ulong> indices;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
205
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
206 // If we replace the objects, delete the selection now.
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
207 if (replace)
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
208 *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
209
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
210 for (const short colnum : colorsToReplace)
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
211 *cmb << g_win->deleteByColor (colnum);
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
212
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
213 // Insert the new objects
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
214 g_win->sel ().clear ();
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
215 for (LDObject* obj : objs) {
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
216 if (!obj->isSchemantic ()) {
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
217 delete obj;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
218 continue;
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
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
221 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
222 indices.push_back (idx);
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
223 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
224 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
225 }
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
226
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
227 if (indices.size() > 0)
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
228 *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
229
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
230 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
231 History::addEntry (cmb);
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
232 else
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
233 delete cmb;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
234
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
235 fclose (fp);
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
236 g_win->refresh ();
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
237 }
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
238
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
239 QDialogButtonBox* makeButtonBox (QDialog& dlg) {
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
240 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
241 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
242 QWidget::connect (bbx_buttons, SIGNAL (rejected ()), &dlg, SLOT (reject ()));
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
243 return bbx_buttons;
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
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
246 // =============================================================================
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
247 // Interface for Ytruder
178
bc30a6d59f7c Added icon for intersector
Santeri Piippo <crimsondusk64@gmail.com>
parents: 177
diff changeset
248 MAKE_ACTION (ytruder, "Ytruder", "ytruder", "Extrude selected lines to a given plane", KEY (F4)) {
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
249 setlocale (LC_ALL, "C");
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
250
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
251 if (!checkProgPath (prog_ytruder, Ytruder))
165
88a03c1a52d9 Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252 return;
88a03c1a52d9 Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253
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
254 QDialog dlg;
167
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
255
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
256 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
257 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
258 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
259 *dsb_condAngle = new LabeledWidget<QDoubleSpinBox> ("Conditional line threshold");
167
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
260
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
261 rb_axis->setValue (Y);
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
262 dsb_depth->w ()->setMinimum (-10000.0);
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
263 dsb_depth->w ()->setMaximum (10000.0);
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
264 dsb_depth->w ()->setDecimals (3);
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
265 dsb_condAngle->w ()->setValue (30.0f);
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
266
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
267 QVBoxLayout* layout = new QVBoxLayout (&dlg);
167
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
268 layout->addWidget (rb_mode);
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
269 layout->addWidget (rb_axis);
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
270 layout->addWidget (dsb_depth);
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
271 layout->addWidget (dsb_condAngle);
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
272 layout->addWidget (makeButtonBox (dlg));
167
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
273
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
274 dlg.setWindowIcon (getIcon ("extrude"));
167
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
275
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
276 if (!dlg.exec ())
167
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
277 return;
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
278
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
279 // Read the user's choices
167
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
280 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
281 const Axis axis = (Axis) rb_axis->value ();
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
282 const double depth = dsb_depth->w ()->value (),
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
283 condAngle = dsb_condAngle->w ()->value ();
df78c894ae24 Further ytruder support
Santeri Piippo <crimsondusk64@gmail.com>
parents: 166
diff changeset
284
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
285 QTemporaryFile indat, outdat;
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
286 str inDATName, outDATName;
165
88a03c1a52d9 Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
287
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
288 // 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
289 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
290 return;
88a03c1a52d9 Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
291
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
292 // Compose the command-line arguments
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
293 str argv = fmt ("%s %s %f -a %f %s %s",
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
294 (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
295 (mode == Distance) ? "-d" : (mode == Symmetry) ? "-s" : (mode == Projection) ? "-p" : "-r",
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
296 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
297
168
96691a009dff Further work on ext programs, LDObjectType_e integrated into LDObject
Santeri Piippo <crimsondusk64@gmail.com>
parents: 167
diff changeset
298 writeSelection (inDATName);
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
299 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
300 insertOutput (outDATName, false, {});
174
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
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
303 // ========================================================================================================================================
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
304 // Rectifier interface
178
bc30a6d59f7c Added icon for intersector
Santeri Piippo <crimsondusk64@gmail.com>
parents: 177
diff changeset
305 MAKE_ACTION (rectifier, "Rectifier", "rectifier", "Optimizes quads into rect primitives.", KEY (F8)) {
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
306 setlocale (LC_ALL, "C");
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
307
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
308 if (!checkProgPath (prog_rectifier, Rectifier))
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
309 return;
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
310
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
311 QDialog dlg;
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
312 QCheckBox* cb_condense = new QCheckBox ("Condense triangles to quads"),
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
313 *cb_subst = new QCheckBox ("Substitute rect primitives"),
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
314 *cb_condlineCheck = new QCheckBox ("Don't replace quads with adj. condlines"),
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
315 *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
316 LabeledWidget<QDoubleSpinBox>* dsb_coplthres = new LabeledWidget<QDoubleSpinBox> ("Coplanarity threshold");
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
317
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
318 dsb_coplthres->w ()->setMinimum (0.0f);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
319 dsb_coplthres->w ()->setMaximum (360.0f);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
320 dsb_coplthres->w ()->setDecimals (3);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
321 dsb_coplthres->w ()->setValue (0.95f);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
322 cb_condense->setChecked (true);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
323 cb_subst->setChecked (true);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
324
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
325 QVBoxLayout* layout = new QVBoxLayout (&dlg);
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
326 layout->addWidget (cb_condense);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
327 layout->addWidget (cb_subst);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
328 layout->addWidget (cb_condlineCheck);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
329 layout->addWidget (cb_colorize);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
330 layout->addWidget (dsb_coplthres);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
331 layout->addWidget (makeButtonBox (dlg));
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
332
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
333 if (!dlg.exec ())
174
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
334 return;
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 const bool condense = cb_condense->isChecked (),
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
337 subst = cb_subst->isChecked (),
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
338 condlineCheck = cb_condlineCheck->isChecked (),
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
339 colorize = cb_colorize->isChecked ();
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
340 const double coplthres = dsb_coplthres->w ()->value ();
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
341
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
342 QTemporaryFile indat, outdat;
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
343 str inDATName, outDATName;
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
344
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
345 // Make temp files for the input and output files
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
346 if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName))
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
347 return;
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
348
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
349 // Compose arguments
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
350 str argv = fmt ("%s %s %s %s -t %f %s %s",
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
351 (condense == false) ? "-q" : "",
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
352 (subst == false) ? "-r" : "",
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
353 (condlineCheck) ? "-a" : "",
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
354 (colorize) ? "-c" : "",
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
355 coplthres, inDATName.chars (), outDATName.chars ());
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
356
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
357 writeSelection (inDATName);
963697b36118 Added rectifier interface
Santeri Piippo <crimsondusk64@gmail.com>
parents: 168
diff changeset
358 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
359 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
360 }
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
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
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 // =======================================================================================================================================
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 // Intersector interface
178
bc30a6d59f7c Added icon for intersector
Santeri Piippo <crimsondusk64@gmail.com>
parents: 177
diff changeset
366 MAKE_ACTION (intersector, "Intersector", "intersector", "Perform clipping between two input groups.", KEY (F5)) {
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
367 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
368
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 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
370 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
371
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 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
373
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
374 LabeledWidget<QComboBox>* cmb_incol = new LabeledWidget<QComboBox> ("Input", new QComboBox),
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
375 *cmb_cutcol = new LabeledWidget<QComboBox> ("Cutter", new QComboBox);
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
376 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
377 *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
378 *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
379 *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
380 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
381
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 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
383 " 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
384 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
385
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
386 makeColorSelector (cmb_incol->w ());
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
387 makeColorSelector (cmb_cutcol->w ());
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
388 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
389 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
390 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
391 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
392
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 QVBoxLayout* layout = new QVBoxLayout (&dlg);
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
394 layout->addWidget (cmb_incol);
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
395 layout->addWidget (cmb_cutcol);
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
396
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 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
398 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
399 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
400
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 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
402 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
403 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
404
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 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
406 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
407 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
408 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
409
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 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
411 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
412 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
413
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
414 const short inCol = cmb_incol->w ()->itemData (cmb_incol->w ()->currentIndex ()).toInt (),
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
415 cutCol = cmb_cutcol->w ()->itemData (cmb_cutcol->w ()->currentIndex ()).toInt ();
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
416 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
417
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
418 if (inCol == cutCol) {
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
419 critical ("Cannot use the same color group for both input and cutter!");
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
420 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
421 }
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
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 // 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
424 // 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
425 // 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
426 // 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
427 // 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
428 // 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
429 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
430 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
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 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
433 !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
434 !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
435 {
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 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
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
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 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
440 (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
441 (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
442 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
443
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 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
445 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
446
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
447 writeColorGroup (inCol, inDATName);
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
448 writeColorGroup (cutCol, cutDATName);
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
449 runUtilityProcess (Intersector, prog_intersector, argv_normal);
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
450 insertOutput (outDATName, false, {inCol});
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
451
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 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
453 runUtilityProcess (Intersector, prog_intersector, argv_inverse);
177
4cdd408f2863 Removed groups.. that was stupid. Intersector input now based on colors.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 175
diff changeset
454 insertOutput (outDAT2Name, false, {cutCol});
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
455 }
b094d5e9d6e0 Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 174
diff changeset
456
b094d5e9d6e0 Added Intersector interface. I'm beginning to think that groups were a bad idea...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 174
diff changeset
457 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
458 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
459 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
460 }
165
88a03c1a52d9 Begin work on external program support (Ytruder partially supported)
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461 }

mercurial