src/ExternalPrograms.cc

changeset 690
9e9c52ca955e
parent 681
c1cc036c6e1f
parent 644
93dcd1a0e4bd
--- a/src/ExternalPrograms.cc	Sun Mar 09 14:04:06 2014 +0200
+++ b/src/ExternalPrograms.cc	Sun Mar 09 14:59:46 2014 +0200
@@ -50,7 +50,7 @@
 };
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 cfg (String, prog_isecalc, "");
 cfg (String, prog_intersector, "");
 cfg (String, prog_coverer, "");
@@ -98,7 +98,7 @@
 };
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 static bool mkTempFile (QTemporaryFile& tmp, QString& fname)
 {
 	if (!tmp.open())
@@ -110,7 +110,7 @@
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 static bool checkProgPath (const extprog prog)
 {
 	QString& path = *g_extProgPaths[prog];
@@ -130,7 +130,7 @@
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 static QString processErrorString (extprog prog, QProcess& proc)
 {
 	switch (proc.error())
@@ -144,7 +144,7 @@
 				wineblurb = "make sure Wine is installed and ";
 #endif
 
-			return fmt ("Program failed to start, %1check your permissions", wineblurb);
+			return format ("Program failed to start, %1check your permissions", wineblurb);
 		} break;
 
 		case QProcess::Crashed:
@@ -158,19 +158,19 @@
 			return "Unknown error";
 
 		case QProcess::Timedout:
-			return fmt ("Timed out (30 seconds)");
+			return format ("Timed out (30 seconds)");
 	}
 
 	return "";
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 static void writeObjects (const LDObjectList& objects, QFile& f)
 {
 	for (LDObject* obj : objects)
 	{
-		if (obj->getType() == LDObject::ESubfile)
+		if (obj->type() == LDObject::ESubfile)
 		{
 			LDSubfile* ref = static_cast<LDSubfile*> (obj);
 			LDObjectList objs = ref->inlineContents (true, false);
@@ -178,15 +178,15 @@
 			writeObjects (objs, f);
 
 			for (LDObject* obj : objs)
-				obj->deleteSelf();
+				obj->destroy();
 		}
 		else
-			f.write ((obj->raw() + "\r\n").toUtf8());
+			f.write ((obj->asText() + "\r\n").toUtf8());
 	}
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 static void writeObjects (const LDObjectList& objects, QString fname)
 {
 	// Write the input file
@@ -194,7 +194,7 @@
 
 	if (!f.open (QIODevice::WriteOnly | QIODevice::Text))
 	{
-		critical (fmt ("Couldn't open temporary file %1 for writing: %2\n", fname, f.errorString()));
+		critical (format ("Couldn't open temporary file %1 for writing: %2\n", fname, f.errorString()));
 		return;
 	}
 
@@ -207,21 +207,21 @@
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 void writeSelection (QString fname)
 {
 	writeObjects (selection(), fname);
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 void writeColorGroup (const int colnum, QString fname)
 {
 	LDObjectList objects;
 
-	for (LDObject* obj : getCurrentDocument()->getObjects())
+	for (LDObject* obj : getCurrentDocument()->objects())
 	{
-		if (obj->isColored() == false || obj->getColor() != colnum)
+		if (obj->isColored() == false || obj->color() != colnum)
 			continue;
 
 		objects << obj;
@@ -231,7 +231,7 @@
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 bool runUtilityProcess (extprog prog, QString path, QString argvstr)
 {
 	QTemporaryFile input;
@@ -245,7 +245,7 @@
 	}
 #endif // _WIN32
 
-	log ("cmdline: %1 %2\n", path, argv.join (" "));
+	print ("Running command: %1 %2\n", path, argv.join (" "));
 
 	if (!input.open())
 		return false;
@@ -258,7 +258,7 @@
 
 	if (!proc.waitForStarted())
 	{
-		critical (fmt ("Couldn't start %1: %2\n", g_extProgNames[prog], processErrorString (prog, proc)));
+		critical (format ("Couldn't start %1: %2\n", g_extProgNames[prog], processErrorString (prog, proc)));
 		return false;
 	}
 
@@ -275,11 +275,11 @@
 
 	// Check the return code
 	if (proc.exitCode() != 0)
-		err = fmt ("Program exited abnormally (return code %1).",  proc.exitCode());
+		err = format ("Program exited abnormally (return code %1).",  proc.exitCode());
 
 	if (!err.isEmpty())
 	{
-		critical (fmt ("%1 failed: %2\n", g_extProgNames[prog], err));
+		critical (format ("%1 failed: %2\n", g_extProgNames[prog], err));
 		return false;
 	}
 
@@ -287,7 +287,7 @@
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 static void insertOutput (QString fname, bool replace, QList<int> colorsToReplace)
 {
 #ifdef DEBUG
@@ -299,7 +299,7 @@
 
 	if (!f.open (QIODevice::ReadOnly))
 	{
-		critical (fmt ("Couldn't open temporary file %1 for reading.\n", fname));
+		critical (format ("Couldn't open temporary file %1 for reading.\n", fname));
 		return;
 	}
 
@@ -319,7 +319,7 @@
 	{
 		if (!obj->isScemantic())
 		{
-			obj->deleteSelf();
+			obj->destroy();
 			continue;
 		}
 
@@ -332,7 +332,7 @@
 
 // =============================================================================
 // Interface for Ytruder
-// -----------------------------------------------------------------------------
+// =============================================================================
 DEFINE_ACTION (Ytruder, 0)
 {
 	setlocale (LC_ALL, "C");
@@ -389,7 +389,7 @@
 
 // =============================================================================
 // Rectifier interface
-// -----------------------------------------------------------------------------
+// =============================================================================
 DEFINE_ACTION (Rectifier, 0)
 {
 	setlocale (LC_ALL, "C");
@@ -434,7 +434,7 @@
 
 // =============================================================================
 // Intersector interface
-// -----------------------------------------------------------------------------
+// =============================================================================
 DEFINE_ACTION (Intersector, 0)
 {
 	setlocale (LC_ALL, "C");
@@ -532,7 +532,7 @@
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 DEFINE_ACTION (Coverer, 0)
 {
 	setlocale (LC_ALL, "C");
@@ -575,8 +575,8 @@
 	{
 		(ui.cb_oldsweep->isChecked() ? "-s" : ""),
 		(ui.cb_reverse->isChecked() ? "-r" : ""),
-		(ui.dsb_segsplit->value() != 0 ? fmt ("-l %1", ui.dsb_segsplit->value()) : ""),
-		(ui.sb_bias->value() != 0 ? fmt ("-s %1", ui.sb_bias->value()) : ""),
+		(ui.dsb_segsplit->value() != 0 ? format ("-l %1", ui.dsb_segsplit->value()) : ""),
+		(ui.sb_bias->value() != 0 ? format ("-s %1", ui.sb_bias->value()) : ""),
 		in1DATName,
 		in2DATName,
 		outDATName
@@ -592,7 +592,7 @@
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 DEFINE_ACTION (Isecalc, 0)
 {
 	setlocale (LC_ALL, "C");
@@ -647,7 +647,7 @@
 }
 
 // =============================================================================
-// -----------------------------------------------------------------------------
+//
 DEFINE_ACTION (Edger2, 0)
 {
 	setlocale (LC_ALL, "C");
@@ -672,10 +672,10 @@
 
 	QString 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()),
+		format ("-p %1", ui.precision->value()),
+		format ("-af %1", ui.flatAngle->value()),
+		format ("-ac %1", ui.condAngle->value()),
+		format ("-ae %1", ui.edgeAngle->value()),
 		ui.delLines->isChecked()     ? "-de" : "",
 		ui.delCondLines->isChecked() ? "-dc" : "",
 		ui.colored->isChecked()      ? "-c" : "",

mercurial