Add option to treat all dimensions as reference dimensions. This is

useful because it makes it possible to add cosmetic dimensions to
an existing model, without REF appended.

[git-p4: depot-paths = "//depot/solvespace/": change = 2140]
This commit is contained in:
Jonathan Westhues 2010-05-09 17:06:09 -08:00
parent 8481c54012
commit 9f7ff34b98
9 changed files with 40 additions and 22 deletions

View File

@ -2,6 +2,24 @@
const hConstraint ConstraintBase::NO_CONSTRAINT = { 0 }; const hConstraint ConstraintBase::NO_CONSTRAINT = { 0 };
bool ConstraintBase::HasLabel(void) {
switch(type) {
case PT_LINE_DISTANCE:
case PT_PLANE_DISTANCE:
case PT_FACE_DISTANCE:
case PT_PT_DISTANCE:
case PROJ_PT_DISTANCE:
case DIAMETER:
case LENGTH_RATIO:
case ANGLE:
case COMMENT:
return true;
default:
return false;
}
}
Expr *ConstraintBase::VectorsParallel(int eq, ExprVector a, ExprVector b) { Expr *ConstraintBase::VectorsParallel(int eq, ExprVector a, ExprVector b) {
ExprVector r = a.Cross(b); ExprVector r = a.Cross(b);
// Hairy ball theorem screws me here. There's no clean solution that I // Hairy ball theorem screws me here. There's no clean solution that I

View File

@ -1,23 +1,5 @@
#include "solvespace.h" #include "solvespace.h"
bool Constraint::HasLabel(void) {
switch(type) {
case PT_LINE_DISTANCE:
case PT_PLANE_DISTANCE:
case PT_FACE_DISTANCE:
case PT_PT_DISTANCE:
case PROJ_PT_DISTANCE:
case DIAMETER:
case LENGTH_RATIO:
case ANGLE:
case COMMENT:
return true;
default:
return false;
}
}
void Constraint::LineDrawOrGetDistance(Vector a, Vector b) { void Constraint::LineDrawOrGetDistance(Vector a, Vector b) {
if(dogd.drawing) { if(dogd.drawing) {
// Draw comments in the specified style, but everything else in the // Draw comments in the specified style, but everything else in the

View File

@ -107,6 +107,7 @@ const SolveSpace::SaveTable SolveSpace::SAVED[] = {
{ 'g', "Group.visible", 'b', &(SS.sv.g.visible) }, { 'g', "Group.visible", 'b', &(SS.sv.g.visible) },
{ 'g', "Group.suppress", 'b', &(SS.sv.g.suppress) }, { 'g', "Group.suppress", 'b', &(SS.sv.g.suppress) },
{ 'g', "Group.relaxConstraints", 'b', &(SS.sv.g.relaxConstraints) }, { 'g', "Group.relaxConstraints", 'b', &(SS.sv.g.relaxConstraints) },
{ 'g', "Group.allDimsReference", 'b', &(SS.sv.g.allDimsReference) },
{ 'g', "Group.scale", 'f', &(SS.sv.g.scale) }, { 'g', "Group.scale", 'f', &(SS.sv.g.scale) },
{ 'g', "Group.remap", 'M', &(SS.sv.g.remap) }, { 'g', "Group.remap", 'M', &(SS.sv.g.remap) },
{ 'g', "Group.impFile", 'P', &(SS.sv.g.impFile) }, { 'g', "Group.impFile", 'P', &(SS.sv.g.impFile) },

View File

@ -344,7 +344,7 @@ pruned:
} }
void SolveSpace::ForceReferences(void) { void SolveSpace::ForceReferences(void) {
// Force the values of the paramters that define the three reference // Force the values of the parameters that define the three reference
// coordinate systems. // coordinate systems.
static const struct { static const struct {
hRequest hr; hRequest hr;

View File

@ -100,6 +100,7 @@ public:
bool visible; bool visible;
bool suppress; bool suppress;
bool relaxConstraints; bool relaxConstraints;
bool allDimsReference;
double scale; double scale;
bool clean; bool clean;
@ -561,6 +562,8 @@ public:
bool reference; // a ref dimension, that generates no eqs bool reference; // a ref dimension, that generates no eqs
NameStr comment; // since comments are represented as constraints NameStr comment; // since comments are represented as constraints
bool HasLabel(void);
void Generate(IdList<Equation,hEquation> *l); void Generate(IdList<Equation,hEquation> *l);
void GenerateReal(IdList<Equation,hEquation> *l); void GenerateReal(IdList<Equation,hEquation> *l);
// Some helpers when generating symbolic constraint equations // Some helpers when generating symbolic constraint equations
@ -611,7 +614,6 @@ public:
void DoEqualLenTicks(Vector a, Vector b, Vector gn); void DoEqualLenTicks(Vector a, Vector b, Vector gn);
void DoEqualRadiusTicks(hEntity he); void DoEqualRadiusTicks(hEntity he);
bool HasLabel(void);
char *DescriptionString(void); char *DescriptionString(void);
static void AddConstraint(Constraint *c, bool rememberForUndo); static void AddConstraint(Constraint *c, bool rememberForUndo);

View File

@ -320,6 +320,14 @@ void System::WriteEquationsExceptFor(hConstraint hc, Group *g) {
if(c->group.v != g->h.v) continue; if(c->group.v != g->h.v) continue;
if(c->h.v == hc.v) continue; if(c->h.v == hc.v) continue;
if(c->HasLabel() && c->type != Constraint::COMMENT &&
g->allDimsReference)
{
// When all dimensions are reference, we adjust them to display
// the correct value, and then don't generate any equations.
c->ModifyToSatisfy();
continue;
}
if(g->relaxConstraints && c->type != Constraint::POINTS_COINCIDENT) { if(g->relaxConstraints && c->type != Constraint::POINTS_COINCIDENT) {
// When the constraints are relaxed, we keep only the point- // When the constraints are relaxed, we keep only the point-
// coincident constraints, and the constraints generated by // coincident constraints, and the constraints generated by

View File

@ -222,6 +222,8 @@ void TextWindow::ScreenChangeGroupOption(int link, DWORD v) {
case 'r': g->relaxConstraints = !(g->relaxConstraints); break; case 'r': g->relaxConstraints = !(g->relaxConstraints); break;
case 'd': g->allDimsReference = !(g->allDimsReference); break;
case 'f': g->forceToMesh = !(g->forceToMesh); break; case 'f': g->forceToMesh = !(g->forceToMesh); break;
} }
@ -409,10 +411,14 @@ void TextWindow::ShowGroupInfo(void) {
Printf(false, " (model already forced to triangle mesh)"); Printf(false, " (model already forced to triangle mesh)");
} }
Printf(false, " %f%Lr%Fd%c relax constraints and dimensions", Printf(true, " %f%Lr%Fd%c relax constraints and dimensions",
&TextWindow::ScreenChangeGroupOption, &TextWindow::ScreenChangeGroupOption,
g->relaxConstraints ? CHECK_TRUE : CHECK_FALSE); g->relaxConstraints ? CHECK_TRUE : CHECK_FALSE);
Printf(false, " %f%Ld%Fd%c treat all dimensions as reference",
&TextWindow::ScreenChangeGroupOption,
g->allDimsReference ? CHECK_TRUE : CHECK_FALSE);
if(g->booleanFailed) { if(g->booleanFailed) {
Printf(false, ""); Printf(false, "");
Printf(false, "The Boolean operation failed. It may be "); Printf(false, "The Boolean operation failed. It may be ");

View File

@ -387,6 +387,8 @@ void TextWindow::DrawOrHitTestIcons(int how, double mx, double my)
} }
double ox = oldMousePos.x, oy = oldMousePos.y - LINE_HEIGHT; double ox = oldMousePos.x, oy = oldMousePos.y - LINE_HEIGHT;
ox += 3;
oy -= 3;
int tw = (strlen(str) + 1)*CHAR_WIDTH; int tw = (strlen(str) + 1)*CHAR_WIDTH;
ox = min(ox, (width - 25) - tw); ox = min(ox, (width - 25) - tw);
oy = max(oy, 5); oy = max(oy, 5);

View File

@ -1,5 +1,4 @@
fix bug with rotation in plane where green line stays displayed fix bug with rotation in plane where green line stays displayed
group option to make dimensions always reference?
more tangencies, and rounding (of requests, not parametric) more tangencies, and rounding (of requests, not parametric)
----- -----