Change the unregistered behavior: instead of limiting the number of

constraints, print a message in anything that we export.

[git-p4: depot-paths = "//depot/solvespace/": change = 2038]
This commit is contained in:
Jonathan Westhues 2009-09-29 04:31:07 -08:00
parent db565438e3
commit f7f73bc900
2 changed files with 38 additions and 15 deletions

View File

@ -103,21 +103,6 @@ void Constraint::ConstrainCoincident(hEntity ptA, hEntity ptB) {
}
void Constraint::MenuConstrain(int id) {
int nt = 0;
Constraint *ct;
for(ct = SK.constraint.First(); ct; ct = SK.constraint.NextAfter(ct)) {
if(ct->type != POINTS_COINCIDENT) nt++;
}
if(nt > 25) {
if((!SS.license.licensed) && SS.license.trialDaysRemaining <= 0) {
Error("The 90-day trial of SolveSpace has expired, and the light "
"version does not support more than 25 constraints in a "
"single file.\r\n\r\n"
"Choose Help -> Website / Manual to purchase a license.");
return;
}
}
Constraint c;
ZERO(&c);
c.group = SS.GW.activeGroup;

View File

@ -369,6 +369,12 @@ VectorFileWriter *VectorFileWriter::ForFile(char *filename) {
return ret;
}
static void AddUnregMessageCallback(void *fndata, Vector a, Vector b)
{
SEdgeList *sel = (SEdgeList *)fndata;
sel->AddEdge(a, b, Style::SELECTED);
}
void VectorFileWriter::Output(SEdgeList *sel, SBezierList *sbl, SMesh *sm) {
STriangle *tr;
SEdge *e;
@ -415,6 +421,38 @@ void VectorFileWriter::Output(SEdgeList *sel, SBezierList *sbl, SMesh *sm) {
ptMax.y = ptMin.y + (s*SS.exportCanvas.height);
}
// If the demo period has expired and there's no license, then print
// a message in any exported file.
if((!SS.license.licensed) && (SS.license.trialDaysRemaining <= 0)) {
char *str =
"eval / nonprofit use only -- buy at http://solvespace.com/";
double aspect = (glxStrWidth(str, 1) / glxStrHeight(1));
double w = ptMax.x - ptMin.x, h = ptMax.y - ptMin.y;
Vector u, v, t;
double th;
if(w > h) {
th = w / aspect;
u = Vector::From(1, 0, 0);
v = Vector::From(0, 1, 0);
t = Vector::From(ptMin.x + (w/2), ptMin.y - 1.5*th, 0);
} else {
th = h / aspect;
u = Vector::From( 0, 1, 0);
v = Vector::From(-1, 0, 0);
t = Vector::From(ptMax.x + 1.5*th, ptMin.y + (h/2) , 0);
}
glxWriteTextRefCenter(
str,
0.9 * th * SS.GW.scale,
t, u, v,
AddUnregMessageCallback, sel);
if(w > h) {
ptMin.y -= th*3;
} else {
ptMax.x += th*3;
}
}
StartFile();
if(sm && SS.exportShadedTriangles) {
for(tr = sm->l.First(); tr; tr = sm->l.NextAfter(tr)) {