
points are now entities like any others; so a line segment request will generate three entities, the line segment and its endpoints. I think that's cleaner. When I do step and repeats (and imports, and other similar), I'll need a consistent way to assign those entity ids. That assignment must not change if the sketch is edited. I don't have a clean way to do that; best thought right now is to keep a record of what maps have been used previously, and not pick a new map as long as it's possible to use one that was used previously. This all means that more crap gets pushed in to the Entity structure, so that they can keep track of what solver variables define them. Still seems better, though. I'm closer to ready to start solving. [git-p4: depot-paths = "//depot/solvespace/": change = 1673]
78 lines
1.5 KiB
C++
78 lines
1.5 KiB
C++
#include "solvespace.h"
|
|
|
|
// A public-domain Hershey vector font ("Simplex").
|
|
#include "font.table"
|
|
|
|
static bool ColorLocked;
|
|
|
|
void glxWriteText(char *str)
|
|
{
|
|
double scale = 0.7/SS.GW.scale;
|
|
int xo = 5;
|
|
int yo = 5;
|
|
|
|
for(; *str; str++) {
|
|
int c = *str;
|
|
if(c < 32 || c > 126) c = 32;
|
|
|
|
c -= 32;
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
int j;
|
|
for(j = 0; j < Font[c].points; j++) {
|
|
int x = Font[c].coord[j*2];
|
|
int y = Font[c].coord[j*2+1];
|
|
|
|
if(x == PEN_UP && y == PEN_UP) {
|
|
glEnd();
|
|
glBegin(GL_LINE_STRIP);
|
|
} else {
|
|
glVertex3d((xo + x)*scale, (yo + y)*scale, 0);
|
|
}
|
|
}
|
|
glEnd();
|
|
|
|
xo += Font[c].width;
|
|
}
|
|
}
|
|
|
|
void glxVertex3v(Vector u)
|
|
{
|
|
glVertex3f((GLfloat)u.x, (GLfloat)u.y, (GLfloat)u.z);
|
|
}
|
|
|
|
void glxTranslatev(Vector u)
|
|
{
|
|
glTranslated((GLdouble)u.x, (GLdouble)u.y, (GLdouble)u.z);
|
|
}
|
|
|
|
void glxOntoCsys(Vector u, Vector v)
|
|
{
|
|
double mat[16];
|
|
Vector n = u.Cross(v);
|
|
MakeMatrix(mat, u.x, v.x, n.x, 0,
|
|
u.y, v.y, n.y, 0,
|
|
u.z, v.z, n.z, 0,
|
|
0, 0, 0, 1);
|
|
glMultMatrixd(mat);
|
|
}
|
|
|
|
void glxLockColorTo(double r, double g, double b)
|
|
{
|
|
ColorLocked = false;
|
|
glxColor(r, g, b);
|
|
ColorLocked = true;
|
|
}
|
|
|
|
void glxUnlockColor(void)
|
|
{
|
|
ColorLocked = false;
|
|
}
|
|
|
|
void glxColor(double r, double g, double b)
|
|
{
|
|
if(!ColorLocked) {
|
|
glColor3f((GLfloat)r, (GLfloat)g, (GLfloat)b);
|
|
}
|
|
}
|