190 static void writeObjects (const LDObjectList& objects, QString fname) |
190 static void writeObjects (const LDObjectList& objects, QString fname) |
191 { |
191 { |
192 // Write the input file |
192 // Write the input file |
193 QFile f (fname); |
193 QFile f (fname); |
194 |
194 |
195 if (!f.open (QIODevice::WriteOnly | QIODevice::Text)) |
195 if (not f.open (QIODevice::WriteOnly | QIODevice::Text)) |
196 { |
196 { |
197 critical (format ("Couldn't open temporary file %1 for writing: %2\n", fname, f.errorString())); |
197 critical (format ("Couldn't open temporary file %1 for writing: %2\n", fname, f.errorString())); |
198 return; |
198 return; |
199 } |
199 } |
200 |
200 |
245 } |
245 } |
246 #endif // _WIN32 |
246 #endif // _WIN32 |
247 |
247 |
248 print ("Running command: %1 %2\n", path, argv.join (" ")); |
248 print ("Running command: %1 %2\n", path, argv.join (" ")); |
249 |
249 |
250 if (!input.open()) |
250 if (not input.open()) |
251 return false; |
251 return false; |
252 |
252 |
253 QProcess proc; |
253 QProcess proc; |
254 |
254 |
255 // Begin! |
255 // Begin! |
256 proc.setStandardInputFile (input.fileName()); |
256 proc.setStandardInputFile (input.fileName()); |
257 proc.start (path, argv); |
257 proc.start (path, argv); |
258 |
258 |
259 if (!proc.waitForStarted()) |
259 if (not proc.waitForStarted()) |
260 { |
260 { |
261 critical (format ("Couldn't start %1: %2\n", g_extProgNames[prog], processErrorString (prog, proc))); |
261 critical (format ("Couldn't start %1: %2\n", g_extProgNames[prog], processErrorString (prog, proc))); |
262 return false; |
262 return false; |
263 } |
263 } |
264 |
264 |
275 |
275 |
276 // Check the return code |
276 // Check the return code |
277 if (proc.exitCode() != 0) |
277 if (proc.exitCode() != 0) |
278 err = format ("Program exited abnormally (return code %1).", proc.exitCode()); |
278 err = format ("Program exited abnormally (return code %1).", proc.exitCode()); |
279 |
279 |
280 if (!err.isEmpty()) |
280 if (not err.isEmpty()) |
281 { |
281 { |
282 critical (format ("%1 failed: %2\n", g_extProgNames[prog], err)); |
282 critical (format ("%1 failed: %2\n", g_extProgNames[prog], err)); |
283 return false; |
283 return false; |
284 } |
284 } |
285 |
285 |
335 // ============================================================================= |
335 // ============================================================================= |
336 DEFINE_ACTION (Ytruder, 0) |
336 DEFINE_ACTION (Ytruder, 0) |
337 { |
337 { |
338 setlocale (LC_ALL, "C"); |
338 setlocale (LC_ALL, "C"); |
339 |
339 |
340 if (!checkProgPath (Ytruder)) |
340 if (not checkProgPath (Ytruder)) |
341 return; |
341 return; |
342 |
342 |
343 QDialog* dlg = new QDialog; |
343 QDialog* dlg = new QDialog; |
344 Ui::YtruderUI ui; |
344 Ui::YtruderUI ui; |
345 ui.setupUi (dlg); |
345 ui.setupUi (dlg); |
346 |
346 |
347 if (!dlg->exec()) |
347 if (not dlg->exec()) |
348 return; |
348 return; |
349 |
349 |
350 // Read the user's choices |
350 // Read the user's choices |
351 const enum { Distance, Symmetry, Projection, Radial } mode = |
351 const enum { Distance, Symmetry, Projection, Radial } mode = |
352 ui.mode_distance->isChecked() ? Distance : |
352 ui.mode_distance->isChecked() ? Distance : |
362 |
362 |
363 QTemporaryFile indat, outdat; |
363 QTemporaryFile indat, outdat; |
364 QString inDATName, outDATName; |
364 QString inDATName, outDATName; |
365 |
365 |
366 // Make temp files for the input and output files |
366 // Make temp files for the input and output files |
367 if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName)) |
367 if (not mkTempFile (indat, inDATName) || not mkTempFile (outdat, outDATName)) |
368 return; |
368 return; |
369 |
369 |
370 // Compose the command-line arguments |
370 // Compose the command-line arguments |
371 QString argv = join ( |
371 QString argv = join ( |
372 { |
372 { |
392 // ============================================================================= |
392 // ============================================================================= |
393 DEFINE_ACTION (Rectifier, 0) |
393 DEFINE_ACTION (Rectifier, 0) |
394 { |
394 { |
395 setlocale (LC_ALL, "C"); |
395 setlocale (LC_ALL, "C"); |
396 |
396 |
397 if (!checkProgPath (Rectifier)) |
397 if (not checkProgPath (Rectifier)) |
398 return; |
398 return; |
399 |
399 |
400 QDialog* dlg = new QDialog; |
400 QDialog* dlg = new QDialog; |
401 Ui::RectifierUI ui; |
401 Ui::RectifierUI ui; |
402 ui.setupUi (dlg); |
402 ui.setupUi (dlg); |
403 |
403 |
404 if (!dlg->exec()) |
404 if (not dlg->exec()) |
405 return; |
405 return; |
406 |
406 |
407 QTemporaryFile indat, outdat; |
407 QTemporaryFile indat, outdat; |
408 QString inDATName, outDATName; |
408 QString inDATName, outDATName; |
409 |
409 |
410 // Make temp files for the input and output files |
410 // Make temp files for the input and output files |
411 if (!mkTempFile (indat, inDATName) || !mkTempFile (outdat, outDATName)) |
411 if (not mkTempFile (indat, inDATName) || not mkTempFile (outdat, outDATName)) |
412 return; |
412 return; |
413 |
413 |
414 // Compose arguments |
414 // Compose arguments |
415 QString argv = join ( |
415 QString argv = join ( |
416 { |
416 { |
417 (!ui.cb_condense->isChecked()) ? "-q" : "", |
417 (not ui.cb_condense->isChecked()) ? "-q" : "", |
418 (!ui.cb_subst->isChecked()) ? "-r" : "", |
418 (not ui.cb_subst->isChecked()) ? "-r" : "", |
419 (ui.cb_condlineCheck->isChecked()) ? "-a" : "", |
419 (ui.cb_condlineCheck->isChecked()) ? "-a" : "", |
420 (ui.cb_colorize->isChecked()) ? "-c" : "", |
420 (ui.cb_colorize->isChecked()) ? "-c" : "", |
421 "-t", |
421 "-t", |
422 ui.dsb_coplthres->value(), |
422 ui.dsb_coplthres->value(), |
423 inDATName, |
423 inDATName, |
424 outDATName |
424 outDATName |
425 }); |
425 }); |
426 |
426 |
427 writeSelection (inDATName); |
427 writeSelection (inDATName); |
428 |
428 |
429 if (!runUtilityProcess (Rectifier, prog_rectifier, argv)) |
429 if (not runUtilityProcess (Rectifier, prog_rectifier, argv)) |
430 return; |
430 return; |
431 |
431 |
432 insertOutput (outDATName, true, {}); |
432 insertOutput (outDATName, true, {}); |
433 } |
433 } |
434 |
434 |
437 // ============================================================================= |
437 // ============================================================================= |
438 DEFINE_ACTION (Intersector, 0) |
438 DEFINE_ACTION (Intersector, 0) |
439 { |
439 { |
440 setlocale (LC_ALL, "C"); |
440 setlocale (LC_ALL, "C"); |
441 |
441 |
442 if (!checkProgPath (Intersector)) |
442 if (not checkProgPath (Intersector)) |
443 return; |
443 return; |
444 |
444 |
445 QDialog* dlg = new QDialog; |
445 QDialog* dlg = new QDialog; |
446 Ui::IntersectorUI ui; |
446 Ui::IntersectorUI ui; |
447 ui.setupUi (dlg); |
447 ui.setupUi (dlg); |
479 // outdat2 = inverse output |
479 // outdat2 = inverse output |
480 // edgesdat = edges output (isecalc) |
480 // edgesdat = edges output (isecalc) |
481 QTemporaryFile indat, cutdat, outdat, outdat2, edgesdat; |
481 QTemporaryFile indat, cutdat, outdat, outdat2, edgesdat; |
482 QString inDATName, cutDATName, outDATName, outDAT2Name, edgesDATName; |
482 QString inDATName, cutDATName, outDATName, outDAT2Name, edgesDATName; |
483 |
483 |
484 if (!mkTempFile (indat, inDATName) || !mkTempFile (cutdat, cutDATName) || |
484 if (not mkTempFile (indat, inDATName) || |
485 !mkTempFile (outdat, outDATName) || !mkTempFile (outdat2, outDAT2Name) || |
485 not mkTempFile (cutdat, cutDATName) || |
486 !mkTempFile (edgesdat, edgesDATName)) |
486 not mkTempFile (outdat, outDATName) || |
|
487 not mkTempFile (outdat2, outDAT2Name) || |
|
488 not mkTempFile (edgesdat, edgesDATName)) |
487 { |
489 { |
488 return; |
490 return; |
489 } |
491 } |
490 |
492 |
491 QString parms = join ( |
493 QString parms = join ( |
513 }); |
515 }); |
514 |
516 |
515 writeColorGroup (inCol, inDATName); |
517 writeColorGroup (inCol, inDATName); |
516 writeColorGroup (cutCol, cutDATName); |
518 writeColorGroup (cutCol, cutDATName); |
517 |
519 |
518 if (!runUtilityProcess (Intersector, prog_intersector, argv_normal)) |
520 if (not runUtilityProcess (Intersector, prog_intersector, argv_normal)) |
519 return; |
521 return; |
520 |
522 |
521 insertOutput (outDATName, false, {inCol}); |
523 insertOutput (outDATName, false, {inCol}); |
522 |
524 |
523 if (repeatInverse && runUtilityProcess (Intersector, prog_intersector, argv_inverse)) |
525 if (repeatInverse && runUtilityProcess (Intersector, prog_intersector, argv_inverse)) |
566 } |
568 } |
567 |
569 |
568 QTemporaryFile in1dat, in2dat, outdat; |
570 QTemporaryFile in1dat, in2dat, outdat; |
569 QString in1DATName, in2DATName, outDATName; |
571 QString in1DATName, in2DATName, outDATName; |
570 |
572 |
571 if (!mkTempFile (in1dat, in1DATName) || !mkTempFile (in2dat, in2DATName) || !mkTempFile (outdat, outDATName)) |
573 if (not mkTempFile (in1dat, in1DATName) || |
572 return; |
574 not mkTempFile (in2dat, in2DATName) || |
|
575 not mkTempFile (outdat, outDATName)) |
|
576 { |
|
577 return; |
|
578 } |
573 |
579 |
574 QString argv = join ( |
580 QString argv = join ( |
575 { |
581 { |
576 (ui.cb_oldsweep->isChecked() ? "-s" : ""), |
582 (ui.cb_oldsweep->isChecked() ? "-s" : ""), |
577 (ui.cb_reverse->isChecked() ? "-r" : ""), |
583 (ui.cb_reverse->isChecked() ? "-r" : ""), |
583 }); |
589 }); |
584 |
590 |
585 writeColorGroup (in1Col, in1DATName); |
591 writeColorGroup (in1Col, in1DATName); |
586 writeColorGroup (in2Col, in2DATName); |
592 writeColorGroup (in2Col, in2DATName); |
587 |
593 |
588 if (!runUtilityProcess (Coverer, prog_coverer, argv)) |
594 if (not runUtilityProcess (Coverer, prog_coverer, argv)) |
589 return; |
595 return; |
590 |
596 |
591 insertOutput (outDATName, false, {}); |
597 insertOutput (outDATName, false, {}); |
592 } |
598 } |
593 |
599 |
628 } |
634 } |
629 |
635 |
630 QTemporaryFile in1dat, in2dat, outdat; |
636 QTemporaryFile in1dat, in2dat, outdat; |
631 QString in1DATName, in2DATName, outDATName; |
637 QString in1DATName, in2DATName, outDATName; |
632 |
638 |
633 if (!mkTempFile (in1dat, in1DATName) || !mkTempFile (in2dat, in2DATName) || !mkTempFile (outdat, outDATName)) |
639 if (not mkTempFile (in1dat, in1DATName) || |
634 return; |
640 not mkTempFile (in2dat, in2DATName) || |
|
641 not mkTempFile (outdat, outDATName)) |
|
642 { |
|
643 return; |
|
644 } |
635 |
645 |
636 QString argv = join ( |
646 QString argv = join ( |
637 { |
647 { |
638 in1DATName, |
648 in1DATName, |
639 in2DATName, |
649 in2DATName, |
650 // |
660 // |
651 DEFINE_ACTION (Edger2, 0) |
661 DEFINE_ACTION (Edger2, 0) |
652 { |
662 { |
653 setlocale (LC_ALL, "C"); |
663 setlocale (LC_ALL, "C"); |
654 |
664 |
655 if (!checkProgPath (Edger2)) |
665 if (not checkProgPath (Edger2)) |
656 return; |
666 return; |
657 |
667 |
658 QDialog* dlg = new QDialog; |
668 QDialog* dlg = new QDialog; |
659 Ui::Edger2Dialog ui; |
669 Ui::Edger2Dialog ui; |
660 ui.setupUi (dlg); |
670 ui.setupUi (dlg); |
661 |
671 |
662 if (!dlg->exec()) |
672 if (not dlg->exec()) |
663 return; |
673 return; |
664 |
674 |
665 QTemporaryFile in, out; |
675 QTemporaryFile in, out; |
666 QString inName, outName; |
676 QString inName, outName; |
667 |
677 |
668 if (!mkTempFile (in, inName) || !mkTempFile (out, outName)) |
678 if (not mkTempFile (in, inName) || not mkTempFile (out, outName)) |
669 return; |
679 return; |
670 |
680 |
671 int unmatched = ui.unmatched->currentIndex(); |
681 int unmatched = ui.unmatched->currentIndex(); |
672 |
682 |
673 QString argv = join ( |
683 QString argv = join ( |