src/extprogs.cpp

changeset 203
ccde5e88f0b6
parent 202
a027f6fc6141
child 205
d60cf73fb164
equal deleted inserted replaced
202:a027f6fc6141 203:ccde5e88f0b6
21 #include <QDialog> 21 #include <QDialog>
22 #include <QDialogButtonBox> 22 #include <QDialogButtonBox>
23 #include <QSpinBox> 23 #include <QSpinBox>
24 #include <QCheckBox> 24 #include <QCheckBox>
25 #include <QComboBox> 25 #include <QComboBox>
26 #include <QGridLayout>
26 27
27 #include "common.h" 28 #include "common.h"
28 #include "config.h" 29 #include "config.h"
29 #include "misc.h" 30 #include "misc.h"
30 #include "extprogs.h" 31 #include "extprogs.h"
351 writeSelection (inDATName); 352 writeSelection (inDATName);
352 runUtilityProcess (Rectifier, prog_rectifier, argv); 353 runUtilityProcess (Rectifier, prog_rectifier, argv);
353 insertOutput (outDATName, true, {}); 354 insertOutput (outDATName, true, {});
354 } 355 }
355 356
357 LabeledWidget<QComboBox>* buildColorSelector (const char* label) {
358 LabeledWidget<QComboBox>* widget = new LabeledWidget<QComboBox> (label, new QComboBox);
359 makeColorSelector (widget->w ());
360 return widget;
361 }
362
356 // ======================================================================================================================================= 363 // =======================================================================================================================================
357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
358 // ======================================================================================================================================= 365 // =======================================================================================================================================
359 // Intersector interface 366 // Intersector interface
360 void runIntersector () { 367 void runIntersector () {
363 if (!checkProgPath (prog_intersector, Intersector)) 370 if (!checkProgPath (prog_intersector, Intersector))
364 return; 371 return;
365 372
366 QDialog dlg; 373 QDialog dlg;
367 374
368 LabeledWidget<QComboBox>* cmb_incol = new LabeledWidget<QComboBox> ("Input", new QComboBox), 375 LabeledWidget<QComboBox>* cmb_incol = buildColorSelector ("Input"),
369 *cmb_cutcol = new LabeledWidget<QComboBox> ("Cutter", new QComboBox); 376 *cmb_cutcol = buildColorSelector ("Cutter");
370 QCheckBox* cb_colorize = new QCheckBox ("Colorize output"), 377 QCheckBox* cb_colorize = new QCheckBox ("Colorize output"),
371 *cb_nocondense = new QCheckBox ("No condensing"), 378 *cb_nocondense = new QCheckBox ("No condensing"),
372 *cb_repeatInverse = new QCheckBox ("Repeat inverse"), 379 *cb_repeatInverse = new QCheckBox ("Repeat inverse"),
373 *cb_edges = new QCheckBox ("Add edges"); 380 *cb_edges = new QCheckBox ("Add edges");
374 LabeledWidget<QDoubleSpinBox>* dsb_prescale = new LabeledWidget<QDoubleSpinBox> ("Prescaling factor"); 381 LabeledWidget<QDoubleSpinBox>* dsb_prescale = new LabeledWidget<QDoubleSpinBox> ("Prescaling factor");
375 382
376 cb_repeatInverse->setWhatsThis ("If this is set, " APPNAME " runs Intersector a second time with inverse files to cut the " 383 cb_repeatInverse->setWhatsThis ("If this is set, " APPNAME " runs Intersector a second time with inverse files to cut the "
377 " cutter group with the input group. Both groups are cut by the intersection."); 384 " cutter group with the input group. Both groups are cut by the intersection.");
378 cb_edges->setWhatsThis ("Makes " APPNAME " try run Isecalc to create edgelines for the intersection."); 385 cb_edges->setWhatsThis ("Makes " APPNAME " try run Isecalc to create edgelines for the intersection.");
379 386
380 makeColorSelector (cmb_incol->w ());
381 makeColorSelector (cmb_cutcol->w ());
382 dsb_prescale->w ()->setMinimum (0.0f); 387 dsb_prescale->w ()->setMinimum (0.0f);
383 dsb_prescale->w ()->setMaximum (10000.0f); 388 dsb_prescale->w ()->setMaximum (10000.0f);
384 dsb_prescale->w ()->setSingleStep (0.01f); 389 dsb_prescale->w ()->setSingleStep (0.01f);
385 dsb_prescale->w ()->setValue (1.0f); 390 dsb_prescale->w ()->setValue (1.0f);
386 391
451 if (cb_edges->isChecked ()) { 456 if (cb_edges->isChecked ()) {
452 runUtilityProcess (Isecalc, prog_isecalc, fmt ("%s %s %s", inDATName.chars (), cutDATName.chars (), edgesDATName.chars ())); 457 runUtilityProcess (Isecalc, prog_isecalc, fmt ("%s %s %s", inDATName.chars (), cutDATName.chars (), edgesDATName.chars ()));
453 insertOutput (edgesDATName, false, {}); 458 insertOutput (edgesDATName, false, {});
454 } 459 }
455 } 460 }
461
462 // =======================================================================================================================================
463 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
464 // =======================================================================================================================================
465 void runCoverer () {
466 setlocale (LC_ALL, "C");
467
468 if (!checkProgPath (prog_coverer, Coverer))
469 return;
470
471 QDialog dlg;
472
473 LabeledWidget<QComboBox>* cmb_col1 = buildColorSelector ("Shape 1"),
474 *cmb_col2 = buildColorSelector ("Shape 2");
475
476 QDoubleSpinBox* dsb_segsplit = new QDoubleSpinBox;
477 QLabel* lb_segsplit = new QLabel ("Segment split length:");
478 QSpinBox* sb_bias = new QSpinBox;
479 QLabel* lb_bias = new QLabel ("Bias:");
480 QCheckBox* cb_reverse = new QCheckBox ("Reverse shape 2"),
481 *cb_oldsweep = new QCheckBox ("Old sweep method");
482
483 dsb_segsplit->setSpecialValueText ("No splitting");
484 dsb_segsplit->setRange (0.0f, 10000.0f);
485 sb_bias->setSpecialValueText ("No bias");
486 sb_bias->setRange (-100, 100);
487
488 QGridLayout* spinboxlayout = new QGridLayout;
489 spinboxlayout->addWidget (lb_segsplit, 0, 0);
490 spinboxlayout->addWidget (dsb_segsplit, 0, 1);
491 spinboxlayout->addWidget (lb_bias, 1, 0);
492 spinboxlayout->addWidget (sb_bias, 1, 1);
493
494 QVBoxLayout* layout = new QVBoxLayout (&dlg);
495 layout->addWidget (cmb_col1);
496 layout->addWidget (cmb_col2);
497 layout->addLayout (spinboxlayout);
498 layout->addWidget (cb_reverse);
499 layout->addWidget (cb_oldsweep);
500 layout->addWidget (makeButtonBox (dlg));
501
502 exec:
503 if (!dlg.exec ())
504 return;
505
506 const short in1Col = cmb_col1->w ()->itemData (cmb_col1->w ()->currentIndex ()).toInt (),
507 in2Col = cmb_col1->w ()->itemData (cmb_col2->w ()->currentIndex ()).toInt ();
508
509 if (in1Col == in2Col) {
510 critical ("Cannot use the same color group for both input and cutter!");
511 goto exec;
512 }
513
514 QTemporaryFile in1dat, in2dat, outdat;
515 str in1DATName, in2DATName, outDATName;
516
517 if (!mkTempFile (in1dat, in1DATName) || !mkTempFile (in2dat, in2DATName) || !mkTempFile (outdat, outDATName))
518 return;
519
520 str argv = fmt ("%s %s %s %s %s %s %s",
521 (cb_oldsweep->isChecked () ? "-s" : ""),
522 (cb_reverse->isChecked () ? "-r" : ""),
523 (dsb_segsplit->value () != 0 ? fmt ("-l %f", dsb_segsplit->value ()).c () : ""),
524 (sb_bias->value () != 0 ? fmt ("-s %d", sb_bias->value ()).c () : ""),
525 in1DATName.c (), in2DATName.c (), outDATName.c ());
526
527 writeColorGroup (in1Col, in1DATName);
528 writeColorGroup (in2Col, in2DATName);
529 runUtilityProcess (Coverer, prog_coverer, argv);
530 insertOutput (outDATName, false, {});
531 }

mercurial