Completed Edger 2 interface

Sat, 06 Jul 2013 02:52:54 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 06 Jul 2013 02:52:54 +0300
changeset 343
75487752f3e6
parent 342
7af989362d4c
child 344
55fcf67230fd

Completed Edger 2 interface

src/configDialog.cpp file | annotate | diff | comparison | revisions
src/extprogs.cpp file | annotate | diff | comparison | revisions
src/ui/edger2.ui file | annotate | diff | comparison | revisions
--- a/src/configDialog.cpp	Sat Jul 06 02:30:48 2013 +0300
+++ b/src/configDialog.cpp	Sat Jul 06 02:52:54 2013 +0300
@@ -24,6 +24,7 @@
 #include <QGroupBox>
 #include <QDoubleSpinBox>
 #include <QLineEdit>
+#include <QCheckBox>
 
 #include "common.h"
 #include "configDialog.h"
@@ -203,11 +204,13 @@
 extern_cfg( str, prog_intersector );
 extern_cfg( str, prog_coverer );
 extern_cfg( str, prog_isecalc );
+extern_cfg( str, prog_edger2 );
 extern_cfg( bool, prog_ytruder_wine );
 extern_cfg( bool, prog_rectifier_wine );
 extern_cfg( bool, prog_intersector_wine );
 extern_cfg( bool, prog_coverer_wine );
 extern_cfg( bool, prog_isecalc_wine );
+extern_cfg( bool, prog_edger2_wine );
 
 static const struct extProgInfo
 {
@@ -221,15 +224,16 @@
 #endif // _WIN32
 } g_extProgInfo[] = {
 #ifndef _WIN32
-# define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null },
+# define EXTPROG( NAME, LOWNAME ) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null, &prog_##LOWNAME##_wine, null },
 #else
-# define EXTPROG(NAME, LOWNAME) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null },
+# define EXTPROG( NAME, LOWNAME ) { #NAME, #LOWNAME, &prog_##LOWNAME, null, null },
 #endif
 	EXTPROG( Ytruder, ytruder )
 	EXTPROG( Rectifier, rectifier )
 	EXTPROG( Intersector, intersector )
 	EXTPROG( Isecalc, isecalc )
 	EXTPROG( Coverer, coverer )
+	EXTPROG( Edger2, edger2 )
 #undef EXTPROG
 };
 
--- a/src/extprogs.cpp	Sat Jul 06 02:30:48 2013 +0300
+++ b/src/extprogs.cpp	Sat Jul 06 02:52:54 2013 +0300
@@ -597,14 +597,48 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
-MAKE_ACTION( edger2, "Edger 2", "edger2", "Compute edgelines", 0 ) {
-	QDialog* form = new QDialog;
+MAKE_ACTION( edger2, "Edger 2", "edger2", "Compute edgelines", 0 )
+{
+	setlocale (LC_ALL, "C");
+	
+	if( !checkProgPath( prog_edger2, Edger2 ))
+		return;
+	
+	QDialog* dlg = new QDialog;
 	Ui::Edger2Dialog ui;
-	ui.setupUi( form );
+	ui.setupUi( dlg );
+	
+	if( !dlg->exec() )
+		return;
 	
-exec:
-	if( !form->exec() )
+	QTemporaryFile in, out;
+	str inName, outName;
+	
+	if( !mkTempFile( in, inName ) || !mkTempFile( out, outName ))
 		return;
 	
+	int unmatched = ui.unmatched->currentIndex();
 	
+	str argv = join({
+		fmt( "-p %1", ui.precision->value() ),
+		fmt( "-af %1", ui.flatAngle->value() ),
+		fmt( "-ac %1", ui.condAngle->value() ),
+		fmt( "-ae %1", ui.edgeAngle->value() ),
+		ui.delLines->isChecked()     ? "-de" : "",
+		ui.delCondLines->isChecked() ? "-dc" : "",
+		ui.colored->isChecked()      ? "-c" : "",
+		ui.bfc->isChecked()          ? "-b" : "",
+		ui.convex->isChecked()       ? "-cx" : "",
+		ui.concave->isChecked()      ? "-cv" : "",
+		unmatched == 0 ? "-u+" : ( unmatched == 2 ? "-u-" : "" ),
+		inName,
+		outName,
+	});
+	
+	writeSelection( inName );
+	
+	if( !runUtilityProcess( Edger2, prog_edger2, argv ))
+		return;
+	
+	insertOutput( outName, true, {} );
 }
\ No newline at end of file
--- a/src/ui/edger2.ui	Sat Jul 06 02:30:48 2013 +0300
+++ b/src/ui/edger2.ui	Sat Jul 06 02:52:54 2013 +0300
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>418</width>
+    <width>357</width>
     <height>257</height>
    </rect>
   </property>
@@ -16,220 +16,216 @@
   <property name="windowOpacity">
    <double>1.000000000000000</double>
   </property>
-  <widget class="QDialogButtonBox" name="buttonBox">
-   <property name="geometry">
-    <rect>
-     <x>30</x>
-     <y>220</y>
-     <width>341</width>
-     <height>32</height>
-    </rect>
-   </property>
-   <property name="orientation">
-    <enum>Qt::Horizontal</enum>
-   </property>
-   <property name="standardButtons">
-    <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
-   </property>
-  </widget>
-  <widget class="QWidget" name="gridLayoutWidget">
-   <property name="geometry">
-    <rect>
-     <x>10</x>
-     <y>0</y>
-     <width>401</width>
-     <height>220</height>
-    </rect>
-   </property>
-   <layout class="QGridLayout" name="gridLayout">
-    <item row="6" column="1">
-     <layout class="QVBoxLayout" name="verticalLayout">
-      <item>
-       <widget class="QCheckBox" name="cb_colored">
-        <property name="text">
-         <string>Color-coded</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QCheckBox" name="cb_dellines">
-        <property name="text">
-         <string>Delete existing lines</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QCheckBox" name="cb_delcond">
-        <property name="text">
-         <string>Delete existing cond. lines</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </item>
-    <item row="3" column="2">
-     <widget class="QDoubleSpinBox" name="dsb_edgeangle">
-      <property name="suffix">
-       <string>°</string>
-      </property>
-      <property name="decimals">
-       <number>4</number>
-      </property>
-      <property name="maximum">
-       <double>360.000000000000000</double>
-      </property>
-      <property name="singleStep">
-       <double>0.100000000000000</double>
-      </property>
-      <property name="value">
-       <double>60.000000000000000</double>
-      </property>
-     </widget>
-    </item>
-    <item row="2" column="1">
-     <widget class="QLabel" name="label_2">
-      <property name="text">
-       <string>Conditional line angle</string>
-      </property>
-     </widget>
-    </item>
-    <item row="2" column="2">
-     <widget class="QDoubleSpinBox" name="dsb_condangle">
-      <property name="suffix">
-       <string>°</string>
-      </property>
-      <property name="decimals">
-       <number>4</number>
-      </property>
-      <property name="maximum">
-       <double>360.000000000000000</double>
-      </property>
-      <property name="singleStep">
-       <double>0.100000000000000</double>
-      </property>
-      <property name="value">
-       <double>60.000000000000000</double>
-      </property>
-     </widget>
-    </item>
-    <item row="1" column="1">
-     <widget class="QLabel" name="label_3">
-      <property name="text">
-       <string>Flat angle</string>
-      </property>
-     </widget>
-    </item>
-    <item row="3" column="1">
-     <widget class="QLabel" name="label_4">
-      <property name="text">
-       <string>Edge line angle</string>
-      </property>
-     </widget>
-    </item>
-    <item row="0" column="2">
-     <widget class="QDoubleSpinBox" name="dsb_precision">
-      <property name="suffix">
-       <string/>
-      </property>
-      <property name="decimals">
-       <number>4</number>
-      </property>
-      <property name="value">
-       <double>0.001000000000000</double>
-      </property>
-     </widget>
-    </item>
-    <item row="4" column="2">
-     <widget class="QComboBox" name="cmb_unmatched">
-      <property name="currentIndex">
-       <number>1</number>
-      </property>
-      <item>
-       <property name="text">
-        <string>Only</string>
-       </property>
-      </item>
-      <item>
-       <property name="text">
-        <string>Normally</string>
-       </property>
-      </item>
-      <item>
-       <property name="text">
-        <string>Never</string>
-       </property>
-      </item>
-     </widget>
-    </item>
-    <item row="0" column="1">
-     <widget class="QLabel" name="label">
-      <property name="text">
-       <string>Precision</string>
-      </property>
-     </widget>
-    </item>
-    <item row="1" column="2">
-     <widget class="QDoubleSpinBox" name="dsb_flatangle">
-      <property name="suffix">
-       <string>°</string>
-      </property>
-      <property name="decimals">
-       <number>4</number>
-      </property>
-      <property name="minimum">
-       <double>0.000000000000000</double>
-      </property>
-      <property name="maximum">
-       <double>360.000000000000000</double>
-      </property>
-      <property name="singleStep">
-       <double>0.100000000000000</double>
-      </property>
-      <property name="value">
-       <double>0.100000000000000</double>
-      </property>
-     </widget>
-    </item>
-    <item row="4" column="1">
-     <widget class="QLabel" name="label_5">
-      <property name="text">
-       <string>Create unmatched edges</string>
-      </property>
-     </widget>
-    </item>
-    <item row="6" column="2">
-     <layout class="QVBoxLayout" name="verticalLayout_2">
-      <item>
-       <widget class="QCheckBox" name="cb_bfc">
-        <property name="text">
-         <string>File is BFCd</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QCheckBox" name="cb_convex">
-        <property name="enabled">
-         <bool>false</bool>
-        </property>
-        <property name="text">
-         <string>Convex cond. lines only</string>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QCheckBox" name="cb_concave">
-        <property name="enabled">
-         <bool>false</bool>
-        </property>
-        <property name="text">
-         <string>Concave cond. lines only</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </item>
-   </layout>
-  </widget>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_4">
+     <item>
+      <layout class="QFormLayout" name="formLayout">
+       <item row="0" column="0">
+        <widget class="QLabel" name="label">
+         <property name="text">
+          <string>Precision</string>
+         </property>
+        </widget>
+       </item>
+       <item row="0" column="1">
+        <widget class="QDoubleSpinBox" name="precision">
+         <property name="suffix">
+          <string/>
+         </property>
+         <property name="decimals">
+          <number>4</number>
+         </property>
+         <property name="value">
+          <double>0.001000000000000</double>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <widget class="QDoubleSpinBox" name="flatAngle">
+         <property name="suffix">
+          <string>°</string>
+         </property>
+         <property name="decimals">
+          <number>4</number>
+         </property>
+         <property name="minimum">
+          <double>0.000000000000000</double>
+         </property>
+         <property name="maximum">
+          <double>360.000000000000000</double>
+         </property>
+         <property name="singleStep">
+          <double>0.100000000000000</double>
+         </property>
+         <property name="value">
+          <double>0.100000000000000</double>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="0">
+        <widget class="QLabel" name="label_3">
+         <property name="text">
+          <string>Flat angle</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="0">
+        <widget class="QLabel" name="label_2">
+         <property name="text">
+          <string>Conditional line angle</string>
+         </property>
+        </widget>
+       </item>
+       <item row="2" column="1">
+        <widget class="QDoubleSpinBox" name="condAngle">
+         <property name="suffix">
+          <string>°</string>
+         </property>
+         <property name="decimals">
+          <number>4</number>
+         </property>
+         <property name="maximum">
+          <double>360.000000000000000</double>
+         </property>
+         <property name="singleStep">
+          <double>0.100000000000000</double>
+         </property>
+         <property name="value">
+          <double>60.000000000000000</double>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="1">
+        <widget class="QDoubleSpinBox" name="edgeAngle">
+         <property name="suffix">
+          <string>°</string>
+         </property>
+         <property name="decimals">
+          <number>4</number>
+         </property>
+         <property name="maximum">
+          <double>360.000000000000000</double>
+         </property>
+         <property name="singleStep">
+          <double>0.100000000000000</double>
+         </property>
+         <property name="value">
+          <double>60.000000000000000</double>
+         </property>
+        </widget>
+       </item>
+       <item row="3" column="0">
+        <widget class="QLabel" name="label_4">
+         <property name="text">
+          <string>Edge line angle</string>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="1">
+        <widget class="QComboBox" name="unmatched">
+         <property name="currentIndex">
+          <number>1</number>
+         </property>
+         <item>
+          <property name="text">
+           <string>Only</string>
+          </property>
+         </item>
+         <item>
+          <property name="text">
+           <string>Normally</string>
+          </property>
+         </item>
+         <item>
+          <property name="text">
+           <string>Never</string>
+          </property>
+         </item>
+        </widget>
+       </item>
+       <item row="4" column="0">
+        <widget class="QLabel" name="label_5">
+         <property name="text">
+          <string>Create unmatched edges</string>
+         </property>
+        </widget>
+       </item>
+      </layout>
+     </item>
+     <item>
+      <layout class="QHBoxLayout" name="horizontalLayout">
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout_5">
+         <item>
+          <widget class="QCheckBox" name="colored">
+           <property name="text">
+            <string>Color-coded result</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="delLines">
+           <property name="text">
+            <string>Delete existing lines</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="delCondLines">
+           <property name="text">
+            <string>Delete existing cond. lines</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item>
+        <layout class="QVBoxLayout" name="verticalLayout_6">
+         <item>
+          <widget class="QCheckBox" name="bfc">
+           <property name="text">
+            <string>File is BFCd</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="convex">
+           <property name="enabled">
+            <bool>false</bool>
+           </property>
+           <property name="text">
+            <string>Convex cond. lines only</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QCheckBox" name="concave">
+           <property name="enabled">
+            <bool>false</bool>
+           </property>
+           <property name="text">
+            <string>Concave cond. lines only</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
  </widget>
  <resources/>
  <connections>
@@ -240,12 +236,12 @@
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>248</x>
-     <y>254</y>
+     <x>254</x>
+     <y>250</y>
     </hint>
     <hint type="destinationlabel">
      <x>157</x>
-     <y>274</y>
+     <y>256</y>
     </hint>
    </hints>
   </connection>
@@ -256,12 +252,44 @@
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>316</x>
-     <y>260</y>
+     <x>322</x>
+     <y>250</y>
     </hint>
     <hint type="destinationlabel">
      <x>286</x>
-     <y>274</y>
+     <y>256</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>bfc</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>convex</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>249</x>
+     <y>157</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>248</x>
+     <y>185</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>bfc</sender>
+   <signal>clicked(bool)</signal>
+   <receiver>concave</receiver>
+   <slot>setEnabled(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>283</x>
+     <y>154</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>283</x>
+     <y>205</y>
     </hint>
    </hints>
   </connection>

mercurial