mirror of https://github.com/vitalif/openscad
Decoupled PRINT functionality from MainWindow API
git-svn-id: http://svn.clifford.at/openscad/trunk@153 b57f626f-c46c-0410-a088-ec61d464b74cstl_dim
parent
4585a5b64d
commit
e7f0df6313
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
Context::Context(const Context *parent)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define INCLUDE_ABSTRACT_NODE_DETAILS
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
enum control_type_e {
|
||||
ECHO,
|
||||
|
|
57
dxfdata.cc
57
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
Value builtin_dxf_dim(const QVector<QString> &argnames, const QVector<Value> &args)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define INCLUDE_ABSTRACT_NODE_DETAILS
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#define INCLUDE_ABSTRACT_NODE_DETAILS
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
#undef DEBUG_TRIANGLE_SPLITTING
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define INCLUDE_ABSTRACT_NODE_DETAILS
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
|
|
1
lexer.l
1
lexer.l
|
@ -21,6 +21,7 @@
|
|||
%{
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
#include "parser_yacc.h"
|
||||
|
||||
int lexerget_lineno(void);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define INCLUDE_ABSTRACT_NODE_DETAILS
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
AbstractModule::~AbstractModule()
|
||||
{
|
||||
|
|
1
parser.y
1
parser.y
|
@ -21,6 +21,7 @@
|
|||
%{
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
int parser_error_pos = -1;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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
|
|
@ -21,6 +21,8 @@
|
|||
#define INCLUDE_ABSTRACT_NODE_DETAILS
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
#include <QProgressDialog>
|
||||
#include <QApplication>
|
||||
#include <QTime>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define INCLUDE_ABSTRACT_NODE_DETAILS
|
||||
|
||||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
|
|
Loading…
Reference in New Issue