# HG changeset patch # User Santeri Piippo # Date 1368545554 -10800 # Node ID ccde5e88f0b61dd53d9c456849b035ab00f1e26d # Parent a027f6fc614110abb4c0c613482958ae0a2a04b6 Added Coverer interface diff -r a027f6fc6141 -r ccde5e88f0b6 src/configDialog.cpp --- a/src/configDialog.cpp Tue May 14 18:00:50 2013 +0300 +++ b/src/configDialog.cpp Tue May 14 18:32:34 2013 +0300 @@ -315,6 +315,7 @@ extern_cfg (str, prog_ytruder); extern_cfg (str, prog_rectifier); extern_cfg (str, prog_intersector); +extern_cfg (str, prog_coverer); extern_cfg (str, prog_isecalc); static const struct extProgInfo { const char* const name, *iconname; @@ -326,6 +327,7 @@ { "Rectifier", "rectifier", &prog_rectifier, null, null }, { "Intersector", "intersector", &prog_intersector, null, null }, { "Isecalc", "isecalc", &prog_isecalc, null, null }, + { "Coverer", "coverer", &prog_coverer, null, null }, }; void ConfigDialog::initExtProgTab () { diff -r a027f6fc6141 -r ccde5e88f0b6 src/extprogs.cpp --- a/src/extprogs.cpp Tue May 14 18:00:50 2013 +0300 +++ b/src/extprogs.cpp Tue May 14 18:32:34 2013 +0300 @@ -23,6 +23,7 @@ #include #include #include +#include #include "common.h" #include "config.h" @@ -353,6 +354,12 @@ insertOutput (outDATName, true, {}); } +LabeledWidget* buildColorSelector (const char* label) { + LabeledWidget* widget = new LabeledWidget (label, new QComboBox); + makeColorSelector (widget->w ()); + return widget; +} + // ======================================================================================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ======================================================================================================================================= @@ -365,8 +372,8 @@ QDialog dlg; - LabeledWidget* cmb_incol = new LabeledWidget ("Input", new QComboBox), - *cmb_cutcol = new LabeledWidget ("Cutter", new QComboBox); + LabeledWidget* cmb_incol = buildColorSelector ("Input"), + *cmb_cutcol = buildColorSelector ("Cutter"); QCheckBox* cb_colorize = new QCheckBox ("Colorize output"), *cb_nocondense = new QCheckBox ("No condensing"), *cb_repeatInverse = new QCheckBox ("Repeat inverse"), @@ -377,8 +384,6 @@ " cutter group with the input group. Both groups are cut by the intersection."); cb_edges->setWhatsThis ("Makes " APPNAME " try run Isecalc to create edgelines for the intersection."); - makeColorSelector (cmb_incol->w ()); - makeColorSelector (cmb_cutcol->w ()); dsb_prescale->w ()->setMinimum (0.0f); dsb_prescale->w ()->setMaximum (10000.0f); dsb_prescale->w ()->setSingleStep (0.01f); @@ -452,4 +457,75 @@ runUtilityProcess (Isecalc, prog_isecalc, fmt ("%s %s %s", inDATName.chars (), cutDATName.chars (), edgesDATName.chars ())); insertOutput (edgesDATName, false, {}); } +} + +// ======================================================================================================================================= +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +// ======================================================================================================================================= +void runCoverer () { + setlocale (LC_ALL, "C"); + + if (!checkProgPath (prog_coverer, Coverer)) + return; + + QDialog dlg; + + LabeledWidget* cmb_col1 = buildColorSelector ("Shape 1"), + *cmb_col2 = buildColorSelector ("Shape 2"); + + QDoubleSpinBox* dsb_segsplit = new QDoubleSpinBox; + QLabel* lb_segsplit = new QLabel ("Segment split length:"); + QSpinBox* sb_bias = new QSpinBox; + QLabel* lb_bias = new QLabel ("Bias:"); + QCheckBox* cb_reverse = new QCheckBox ("Reverse shape 2"), + *cb_oldsweep = new QCheckBox ("Old sweep method"); + + dsb_segsplit->setSpecialValueText ("No splitting"); + dsb_segsplit->setRange (0.0f, 10000.0f); + sb_bias->setSpecialValueText ("No bias"); + sb_bias->setRange (-100, 100); + + QGridLayout* spinboxlayout = new QGridLayout; + spinboxlayout->addWidget (lb_segsplit, 0, 0); + spinboxlayout->addWidget (dsb_segsplit, 0, 1); + spinboxlayout->addWidget (lb_bias, 1, 0); + spinboxlayout->addWidget (sb_bias, 1, 1); + + QVBoxLayout* layout = new QVBoxLayout (&dlg); + layout->addWidget (cmb_col1); + layout->addWidget (cmb_col2); + layout->addLayout (spinboxlayout); + layout->addWidget (cb_reverse); + layout->addWidget (cb_oldsweep); + layout->addWidget (makeButtonBox (dlg)); + +exec: + if (!dlg.exec ()) + return; + + const short in1Col = cmb_col1->w ()->itemData (cmb_col1->w ()->currentIndex ()).toInt (), + in2Col = cmb_col1->w ()->itemData (cmb_col2->w ()->currentIndex ()).toInt (); + + if (in1Col == in2Col) { + critical ("Cannot use the same color group for both input and cutter!"); + goto exec; + } + + QTemporaryFile in1dat, in2dat, outdat; + str in1DATName, in2DATName, outDATName; + + if (!mkTempFile (in1dat, in1DATName) || !mkTempFile (in2dat, in2DATName) || !mkTempFile (outdat, outDATName)) + return; + + str argv = fmt ("%s %s %s %s %s %s %s", + (cb_oldsweep->isChecked () ? "-s" : ""), + (cb_reverse->isChecked () ? "-r" : ""), + (dsb_segsplit->value () != 0 ? fmt ("-l %f", dsb_segsplit->value ()).c () : ""), + (sb_bias->value () != 0 ? fmt ("-s %d", sb_bias->value ()).c () : ""), + in1DATName.c (), in2DATName.c (), outDATName.c ()); + + writeColorGroup (in1Col, in1DATName); + writeColorGroup (in2Col, in2DATName); + runUtilityProcess (Coverer, prog_coverer, argv); + insertOutput (outDATName, false, {}); } \ No newline at end of file diff -r a027f6fc6141 -r ccde5e88f0b6 src/extprogs.h --- a/src/extprogs.h Tue May 14 18:00:50 2013 +0300 +++ b/src/extprogs.h Tue May 14 18:32:34 2013 +0300 @@ -33,5 +33,6 @@ void runYtruder (); void runRectifier (); void runIntersector (); +void runCoverer (); #endif // EXTPROGS_H \ No newline at end of file diff -r a027f6fc6141 -r ccde5e88f0b6 src/gui.cpp --- a/src/gui.cpp Tue May 14 18:00:50 2013 +0300 +++ b/src/gui.cpp Tue May 14 18:32:34 2013 +0300 @@ -246,6 +246,7 @@ addMenuAction ("ytruder"); addMenuAction ("rectifier"); addMenuAction ("intersector"); + addMenuAction ("coverer"); // Help menu initMenu ("&Help"); @@ -394,6 +395,7 @@ addToolBarAction ("ytruder"); addToolBarAction ("rectifier"); addToolBarAction ("intersector"); + addToolBarAction ("coverer"); updateToolBars (); } diff -r a027f6fc6141 -r ccde5e88f0b6 src/gui_editactions.cpp --- a/src/gui_editactions.cpp Tue May 14 18:00:50 2013 +0300 +++ b/src/gui_editactions.cpp Tue May 14 18:32:34 2013 +0300 @@ -668,18 +668,22 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -MAKE_ACTION (ytruder, "Ytruder", "ytruder", "Extrude selected lines to a given plane", KEY (F4)) { +MAKE_ACTION (ytruder, "Ytruder", "ytruder", "Extrude selected lines to a given plane", (0)) { runYtruder (); } -MAKE_ACTION (rectifier, "Rectifier", "rectifier", "Optimizes quads into rect primitives.", KEY (F8)) { +MAKE_ACTION (rectifier, "Rectifier", "rectifier", "Optimizes quads into rect primitives.", (0)) { runRectifier (); } -MAKE_ACTION (intersector, "Intersector", "intersector", "Perform clipping between two input groups.", KEY (F5)) { +MAKE_ACTION (intersector, "Intersector", "intersector", "Perform clipping between two input groups.", (0)) { runIntersector (); } +MAKE_ACTION (coverer, "Coverer", "coverer", "Fill the space between two line shapes", (0)) { + runCoverer (); +} + // ========================================================================================================================================= MAKE_ACTION (replaceCoords, "Replace Coordinates", "replace-coords", "Find and replace coordinate values", CTRL (R)) { ReplaceCoordsDialog dlg;