summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--context.cc1
-rw-r--r--control.cc1
-rw-r--r--dxfdata.cc57
-rw-r--r--dxfdim.cc1
-rw-r--r--dxflinextrude.cc1
-rw-r--r--dxftess.cc1
-rw-r--r--import.cc1
-rw-r--r--lexer.l1
-rw-r--r--module.cc1
-rw-r--r--parser.y1
-rw-r--r--printutils.cc14
-rw-r--r--printutils.h10
-rw-r--r--render.cc2
-rw-r--r--surface.cc1
14 files changed, 65 insertions, 28 deletions
diff --git a/context.cc b/context.cc
index f7e8cf3..83fa424 100644
--- a/context.cc
+++ b/context.cc
@@ -19,6 +19,7 @@
*/
#include "openscad.h"
+#include "printutils.h"
Context::Context(const Context *parent)
{
diff --git a/control.cc b/control.cc
index fed6090..6cae8eb 100644
--- a/control.cc
+++ b/control.cc
@@ -21,6 +21,7 @@
#define INCLUDE_ABSTRACT_NODE_DETAILS
#include "openscad.h"
+#include "printutils.h"
enum control_type_e {
ECHO,
diff --git a/dxfdata.cc b/dxfdata.cc
index 3c98678..8949ad8 100644
--- a/dxfdata.cc
+++ b/dxfdata.cc
@@ -19,6 +19,7 @@
*/
#include "openscad.h"
+#include "printutils.h"
#include <QFile>
@@ -40,23 +41,23 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
bool in_blocks_section = false;
QString current_block;
-#define ADD_LINE(_x1, _y1, _x2, _y2) do { \
- double _p1x = _x1, _p1y = _y1, _p2x = _x2, _p2y = _y2; \
- if (!in_entities_section && !in_blocks_section) \
- break; \
- if (in_entities_section && \
- !(layername.isNull() || layername == layer)) \
- break; \
- grid.align(_p1x, _p1y); \
- grid.align(_p2x, _p2y); \
- grid.data(_p1x, _p1y).append(lines.count()); \
- grid.data(_p2x, _p2y).append(lines.count()); \
- if (in_entities_section) \
- lines.append(Line(p(_p1x, _p1y), p(_p2x, _p2y))); \
- if (in_blocks_section && !current_block.isNull()) \
- blockdata[current_block].append( \
- Line(p(_p1x, _p1y), p(_p2x, _p2y))); \
- } while (0)
+#define ADD_LINE(_x1, _y1, _x2, _y2) do { \
+ double _p1x = _x1, _p1y = _y1, _p2x = _x2, _p2y = _y2; \
+ if (!in_entities_section && !in_blocks_section) \
+ break; \
+ if (in_entities_section && \
+ !(layername.isNull() || layername == layer)) \
+ break; \
+ grid.align(_p1x, _p1y); \
+ grid.align(_p2x, _p2y); \
+ grid.data(_p1x, _p1y).append(lines.count()); \
+ grid.data(_p2x, _p2y).append(lines.count()); \
+ if (in_entities_section) \
+ lines.append(Line(p(_p1x, _p1y), p(_p2x, _p2y))); \
+ if (in_blocks_section && !current_block.isNull()) \
+ blockdata[current_block].append( \
+ Line(p(_p1x, _p1y), p(_p2x, _p2y))); \
+ } while (0)
QString mode, layer, name, iddata;
int dimtype = 0;
@@ -65,8 +66,8 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
double radius = 0, start_angle = 0, stop_angle = 0;
for (int i = 0; i < 7; i++)
- for (int j = 0; j < 2; j++)
- coords[i][j] = 0;
+ for (int j = 0; j < 2; j++)
+ coords[i][j] = 0;
QHash<QString, int> unsupported_entities_list;
@@ -111,7 +112,7 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
double a1 = (2*M_PI*i)/n;
double a2 = (2*M_PI*(i+1))/n;
ADD_LINE(cos(a1)*radius + x1, sin(a1)*radius + y1,
- cos(a2)*radius + x1, sin(a2)*radius + y1);
+ cos(a2)*radius + x1, sin(a2)*radius + y1);
}
}
if (mode == "ARC") {
@@ -125,7 +126,7 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
a1 = (start_angle + a1) * M_PI / 180.0;
a2 = (start_angle + a2) * M_PI / 180.0;
ADD_LINE(cos(a1)*radius + x1, sin(a1)*radius + y1,
- cos(a2)*radius + x1, sin(a2)*radius + y1);
+ cos(a2)*radius + x1, sin(a2)*radius + y1);
}
}
if (mode == "INSERT") {
@@ -148,8 +149,8 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
dims.append(Dim());
dims.last().type = dimtype;
for (int i = 0; i < 7; i++)
- for (int j = 0; j < 2; j++)
- dims.last().coords[i][j] = coords[i][j];
+ for (int j = 0; j < 2; j++)
+ dims.last().coords[i][j] = coords[i][j];
dims.last().angle = start_angle;
dims.last().name = name;
}
@@ -160,7 +161,7 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
current_block = QString();
}
if (in_blocks_section || (in_entities_section &&
- (layername.isNull() || layername == layer))) {
+ (layername.isNull() || layername == layer))) {
if (mode != "SECTION" && mode != "ENDSEC" && mode != "DIMENSION" &&
mode != "LINE" && mode != "ARC" && mode != "CIRCLE" &&
mode != "BLOCK" && mode != "ENDBLK" && mode != "INSERT")
@@ -172,8 +173,8 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
iddata = QString();
dimtype = 0;
for (int i = 0; i < 7; i++)
- for (int j = 0; j < 2; j++)
- coords[i][j] = 0;
+ for (int j = 0; j < 2; j++)
+ coords[i][j] = 0;
x1 = x2 = y1 = y2 = 0;
radius = start_angle = stop_angle = 0;
break;
@@ -218,10 +219,10 @@ DxfData::DxfData(double fn, double fs, double fa, QString filename, QString laye
i.next();
if (layername.isNull()) {
PRINTA("WARNING: Unsupported DXF Entity `%1' (%2x) in `%3'.",
- i.key(), QString::number(i.value()), filename);
+ i.key(), QString::number(i.value()), filename);
} else {
PRINTA("WARNING: Unsupported DXF Entity `%1' (%2x) in layer `%3' of `%4'.",
- i.key(), QString::number(i.value()), layername, filename);
+ i.key(), QString::number(i.value()), layername, filename);
}
}
diff --git a/dxfdim.cc b/dxfdim.cc
index d97f6c3..e46c4bb 100644
--- a/dxfdim.cc
+++ b/dxfdim.cc
@@ -19,6 +19,7 @@
*/
#include "openscad.h"
+#include "printutils.h"
Value builtin_dxf_dim(const QVector<QString> &argnames, const QVector<Value> &args)
{
diff --git a/dxflinextrude.cc b/dxflinextrude.cc
index cf3e52d..06d7891 100644
--- a/dxflinextrude.cc
+++ b/dxflinextrude.cc
@@ -21,6 +21,7 @@
#define INCLUDE_ABSTRACT_NODE_DETAILS
#include "openscad.h"
+#include "printutils.h"
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/dxftess.cc b/dxftess.cc
index 427c7e6..3a567fa 100644
--- a/dxftess.cc
+++ b/dxftess.cc
@@ -27,6 +27,7 @@
#define INCLUDE_ABSTRACT_NODE_DETAILS
#include "openscad.h"
+#include "printutils.h"
#undef DEBUG_TRIANGLE_SPLITTING
diff --git a/import.cc b/import.cc
index 3d8b8dc..116e91e 100644
--- a/import.cc
+++ b/import.cc
@@ -21,6 +21,7 @@
#define INCLUDE_ABSTRACT_NODE_DETAILS
#include "openscad.h"
+#include "printutils.h"
#include <QFile>
diff --git a/lexer.l b/lexer.l
index fea9cd1..ebd5f1a 100644
--- a/lexer.l
+++ b/lexer.l
@@ -21,6 +21,7 @@
%{
#include "openscad.h"
+#include "printutils.h"
#include "parser_yacc.h"
int lexerget_lineno(void);
diff --git a/module.cc b/module.cc
index 7b7c5ec..6e89e18 100644
--- a/module.cc
+++ b/module.cc
@@ -21,6 +21,7 @@
#define INCLUDE_ABSTRACT_NODE_DETAILS
#include "openscad.h"
+#include "printutils.h"
AbstractModule::~AbstractModule()
{
diff --git a/parser.y b/parser.y
index b01abeb..61a672a 100644
--- a/parser.y
+++ b/parser.y
@@ -21,6 +21,7 @@
%{
#include "openscad.h"
+#include "printutils.h"
int parser_error_pos = -1;
diff --git a/printutils.cc b/printutils.cc
new file mode 100644
index 0000000..8f53cd3
--- /dev/null
+++ b/printutils.cc
@@ -0,0 +1,14 @@
+#include "printutils.h"
+#include "MainWindow.h"
+
+void PRINT(const QString &msg)
+{
+ do {
+ if (MainWindow::current_win.isNull()) {
+ fprintf(stderr, "%s\n", msg.toAscii().data());
+ }
+ else {
+ MainWindow::current_win->console->append(msg);
+ }
+ } while (0);
+}
diff --git a/printutils.h b/printutils.h
new file mode 100644
index 0000000..9fce113
--- /dev/null
+++ b/printutils.h
@@ -0,0 +1,10 @@
+#ifndef PRINTUTILS_H_
+#define PRINTUTILS_H_
+
+#include <QString>
+
+void PRINT(const QString &msg);
+#define PRINTF(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT(_m); } while (0)
+#define PRINTA(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT(_m); } while (0)
+
+#endif
diff --git a/render.cc b/render.cc
index db891dd..d5478f3 100644
--- a/render.cc
+++ b/render.cc
@@ -21,6 +21,8 @@
#define INCLUDE_ABSTRACT_NODE_DETAILS
#include "openscad.h"
+#include "printutils.h"
+
#include <QProgressDialog>
#include <QApplication>
#include <QTime>
diff --git a/surface.cc b/surface.cc
index e8e59e1..ebf720f 100644
--- a/surface.cc
+++ b/surface.cc
@@ -21,6 +21,7 @@
#define INCLUDE_ABSTRACT_NODE_DETAILS
#include "openscad.h"
+#include "printutils.h"
#include <QFile>
contact: Jan Huwald // Impressum