Indicate the just-exported origin and basis x and y vectors after

exporting our view to any file that doesn't have a canvas size (and
therefore doesn't get everything shifted to fit with the requested
margins around it in the canvas).

[git-p4: depot-paths = "//depot/solvespace/": change = 2107]
solver
Jonathan Westhues 2010-01-13 21:24:32 -08:00
parent a0a7feda89
commit 342729d9a4
4 changed files with 54 additions and 0 deletions

View File

@ -771,6 +771,8 @@ nogrid:;
glEnd(); glEnd();
} }
// An extra line, used to indicate the origin when rotating within the
// plane of the monitor.
if(SS.extraLine.draw) { if(SS.extraLine.draw) {
glLineWidth(1); glLineWidth(1);
glxLockColorTo(Style::Color(Style::DATUM)); glxLockColorTo(Style::Color(Style::DATUM));
@ -780,6 +782,32 @@ nogrid:;
glEnd(); glEnd();
} }
// A note to indicate the origin in the just-exported file.
if(SS.justExportedInfo.draw) {
glxColorRGB(Style::Color(Style::DATUM));
Vector p = SS.justExportedInfo.pt,
u = SS.justExportedInfo.u,
v = SS.justExportedInfo.v;
glLineWidth(1.5);
glBegin(GL_LINES);
glxVertex3v(p.Plus(u.WithMagnitude(-15/scale)));
glxVertex3v(p.Plus(u.WithMagnitude(30/scale)));
glxVertex3v(p.Plus(v.WithMagnitude(-15/scale)));
glxVertex3v(p.Plus(v.WithMagnitude(30/scale)));
glEnd();
glxWriteText("(x, y) = (0, 0) for file just exported",
DEFAULT_TEXT_HEIGHT,
p.Plus(u.ScaledBy(10/scale)).Plus(v.ScaledBy(10/scale)),
u, v, NULL, NULL);
glxWriteText("press Esc to clear this message",
DEFAULT_TEXT_HEIGHT,
p.Plus(u.ScaledBy(40/scale)).Plus(
v.ScaledBy(-(DEFAULT_TEXT_HEIGHT)/scale)),
u, v, NULL, NULL);
}
// And finally the toolbar. // And finally the toolbar.
if(SS.showToolbar) { if(SS.showToolbar) {
ToolbarDraw(); ToolbarDraw();

View File

@ -175,6 +175,17 @@ void SolveSpace::ExportViewOrWireframeTo(char *filename, bool wireframe) {
u, v, n, origin, SS.CameraTangent()*SS.GW.scale, u, v, n, origin, SS.CameraTangent()*SS.GW.scale,
out); out);
} }
if(!out->HasCanvasSize()) {
// These file formats don't have a canvas size, so they just
// get exported in the raw coordinate system. So indicate what
// that was on-screen.
SS.justExportedInfo.draw = true;
SS.justExportedInfo.pt = origin;
SS.justExportedInfo.u = u;
SS.justExportedInfo.v = v;
InvalidateGraphics();
}
} }
edges.Clear(); edges.Clear();

View File

@ -334,10 +334,12 @@ void GraphicsWindow::MenuView(int id) {
switch(id) { switch(id) {
case MNU_ZOOM_IN: case MNU_ZOOM_IN:
SS.GW.scale *= 1.2; SS.GW.scale *= 1.2;
SS.later.showTW = true;
break; break;
case MNU_ZOOM_OUT: case MNU_ZOOM_OUT:
SS.GW.scale /= 1.2; SS.GW.scale /= 1.2;
SS.later.showTW = true;
break; break;
case MNU_ZOOM_TO_FIT: case MNU_ZOOM_TO_FIT:
@ -626,6 +628,7 @@ void GraphicsWindow::MenuEdit(int id) {
SS.GW.ClearSuper(); SS.GW.ClearSuper();
HideTextEditControl(); HideTextEditControl();
SS.nakedEdges.Clear(); SS.nakedEdges.Clear();
SS.justExportedInfo.draw = false;
break; break;
case MNU_SELECT_ALL: { case MNU_SELECT_ALL: {

View File

@ -428,6 +428,7 @@ public:
virtual void Triangle(STriangle *tr) = 0; virtual void Triangle(STriangle *tr) = 0;
virtual void StartFile(void) = 0; virtual void StartFile(void) = 0;
virtual void FinishAndCloseFile(void) = 0; virtual void FinishAndCloseFile(void) = 0;
virtual bool HasCanvasSize(void) = 0;
}; };
class DxfFileWriter : public VectorFileWriter { class DxfFileWriter : public VectorFileWriter {
public: public:
@ -439,6 +440,7 @@ public:
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
void FinishAndCloseFile(void); void FinishAndCloseFile(void);
bool HasCanvasSize(void) { return false; }
}; };
class EpsFileWriter : public VectorFileWriter { class EpsFileWriter : public VectorFileWriter {
public: public:
@ -453,6 +455,7 @@ public:
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
void FinishAndCloseFile(void); void FinishAndCloseFile(void);
bool HasCanvasSize(void) { return true; }
}; };
class PdfFileWriter : public VectorFileWriter { class PdfFileWriter : public VectorFileWriter {
public: public:
@ -469,6 +472,7 @@ public:
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
void FinishAndCloseFile(void); void FinishAndCloseFile(void);
bool HasCanvasSize(void) { return true; }
}; };
class SvgFileWriter : public VectorFileWriter { class SvgFileWriter : public VectorFileWriter {
public: public:
@ -483,6 +487,7 @@ public:
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
void FinishAndCloseFile(void); void FinishAndCloseFile(void);
bool HasCanvasSize(void) { return true; }
}; };
class HpglFileWriter : public VectorFileWriter { class HpglFileWriter : public VectorFileWriter {
public: public:
@ -495,6 +500,7 @@ public:
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
void FinishAndCloseFile(void); void FinishAndCloseFile(void);
bool HasCanvasSize(void) { return false; }
}; };
class Step2dFileWriter : public VectorFileWriter { class Step2dFileWriter : public VectorFileWriter {
StepFileWriter sfw; StepFileWriter sfw;
@ -506,6 +512,7 @@ class Step2dFileWriter : public VectorFileWriter {
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
void FinishAndCloseFile(void); void FinishAndCloseFile(void);
bool HasCanvasSize(void) { return false; }
}; };
class GCodeFileWriter : public VectorFileWriter { class GCodeFileWriter : public VectorFileWriter {
public: public:
@ -518,6 +525,7 @@ public:
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
void FinishAndCloseFile(void); void FinishAndCloseFile(void);
bool HasCanvasSize(void) { return false; }
}; };
#ifdef LIBRARY #ifdef LIBRARY
@ -710,6 +718,10 @@ public:
double scale; // pixels per mm double scale; // pixels per mm
Vector origin; Vector origin;
} bgImage; } bgImage;
struct {
bool draw;
Vector pt, u, v;
} justExportedInfo;
class Clipboard { class Clipboard {
public: public: