Changed "static const int" class members into enums

Not only is the enum syntax more compact, it avoids inadvertent link
failures resulting from how C++ treats "static const int" members:

http://stackoverflow.com/questions/5391973/undefined-reference-to-static-const-int
http://stackoverflow.com/questions/5508182/static-const-int-causes-linking-error-undefined-reference

(And for what it's worth, MSVC6 gave silly errors for these members
wherever a non-zero value was assigned.)
This commit is contained in:
Daniel Richard G 2013-09-09 15:50:32 -04:00
parent a2a78b923f
commit 5cca524c62
7 changed files with 353 additions and 293 deletions

8
dsc.h
View File

@ -381,9 +381,11 @@ public:
class BandedMatrix { class BandedMatrix {
public: public:
static const int MAX_UNKNOWNS = 16; enum {
static const int RIGHT_OF_DIAG = 1; MAX_UNKNOWNS = 16,
static const int LEFT_OF_DIAG = 2; RIGHT_OF_DIAG = 1,
LEFT_OF_DIAG = 2
};
double A[MAX_UNKNOWNS][MAX_UNKNOWNS]; double A[MAX_UNKNOWNS][MAX_UNKNOWNS];
double B[MAX_UNKNOWNS]; double B[MAX_UNKNOWNS];

60
expr.h
View File

@ -14,39 +14,41 @@ class Expr {
public: public:
DWORD marker; DWORD marker;
// A parameter, by the hParam handle enum {
static const int PARAM = 0; // A parameter, by the hParam handle
// A parameter, by a pointer straight in to the param table (faster, PARAM = 0,
// if we know that the param table won't move around) // A parameter, by a pointer straight in to the param table (faster,
static const int PARAM_PTR = 1; // if we know that the param table won't move around)
PARAM_PTR = 1,
// These are used only for user-entered expressions. // These are used only for user-entered expressions.
static const int POINT = 10; POINT = 10,
static const int ENTITY = 11; ENTITY = 11,
static const int CONSTANT = 20; CONSTANT = 20,
static const int PLUS = 100; PLUS = 100,
static const int MINUS = 101; MINUS = 101,
static const int TIMES = 102; TIMES = 102,
static const int DIV = 103; DIV = 103,
static const int NEGATE = 104; NEGATE = 104,
static const int SQRT = 105; SQRT = 105,
static const int SQUARE = 106; SQUARE = 106,
static const int SIN = 107; SIN = 107,
static const int COS = 108; COS = 108,
static const int ASIN = 109; ASIN = 109,
static const int ACOS = 110; ACOS = 110,
// Special helpers for when we're parsing an expression from text. // Special helpers for when we're parsing an expression from text.
// Initially, literals (like a constant number) appear in the same // Initially, literals (like a constant number) appear in the same
// format as they will in the finished expression, but the operators // format as they will in the finished expression, but the operators
// are different until the parser fixes things up (and builds the // are different until the parser fixes things up (and builds the
// tree from the flat list that the lexer outputs). // tree from the flat list that the lexer outputs).
static const int ALL_RESOLVED = 1000; ALL_RESOLVED = 1000,
static const int PAREN = 1001; PAREN = 1001,
static const int BINARY_OP = 1002; BINARY_OP = 1002,
static const int UNARY_OP = 1003; UNARY_OP = 1003
};
int op; int op;
Expr *a; Expr *a;

View File

@ -74,9 +74,11 @@ class SPoint {
public: public:
int tag; int tag;
static const int UNKNOWN = 0; enum {
static const int NOT_EAR = 1; UNKNOWN = 0,
static const int EAR = 2; NOT_EAR = 1,
EAR = 2
};
int ear; int ear;
Vector p; Vector p;
@ -174,7 +176,7 @@ public:
SBsp2 *more; SBsp2 *more;
static const int POS = 100, NEG = 101, COPLANAR = 200; enum { POS = 100, NEG = 101, COPLANAR = 200 };
void InsertTriangleHow(int how, STriangle *tr, SMesh *m, SBsp3 *bsp3); void InsertTriangleHow(int how, STriangle *tr, SMesh *m, SBsp3 *bsp3);
void InsertTriangle(STriangle *tr, SMesh *m, SBsp3 *bsp3); void InsertTriangle(STriangle *tr, SMesh *m, SBsp3 *bsp3);
Vector IntersectionWith(Vector a, Vector b); Vector IntersectionWith(Vector a, Vector b);
@ -202,7 +204,7 @@ public:
Vector IntersectionWith(Vector a, Vector b); Vector IntersectionWith(Vector a, Vector b);
static const int POS = 100, NEG = 101, COPLANAR = 200; enum { POS = 100, NEG = 101, COPLANAR = 200 };
void InsertHow(int how, STriangle *str, SMesh *instead); void InsertHow(int how, STriangle *str, SMesh *instead);
SBsp3 *Insert(STriangle *str, SMesh *instead); SBsp3 *Insert(STriangle *str, SMesh *instead);
@ -283,10 +285,12 @@ public:
void FindEdgeOn(Vector a, Vector b, int *n, int cnt, bool coplanarIsInter, void FindEdgeOn(Vector a, Vector b, int *n, int cnt, bool coplanarIsInter,
bool *inter, bool *fwd, bool *inter, bool *fwd,
DWORD *face); DWORD *face);
static const int NAKED_OR_SELF_INTER_EDGES = 100; enum {
static const int SELF_INTER_EDGES = 200; NAKED_OR_SELF_INTER_EDGES = 100,
static const int TURNING_EDGES = 300; SELF_INTER_EDGES = 200,
static const int EMPHASIZED_EDGES = 400; TURNING_EDGES = 300,
EMPHASIZED_EDGES = 400
};
void MakeCertainEdgesInto(SEdgeList *sel, int how, bool coplanarIsInter, void MakeCertainEdgesInto(SEdgeList *sel, int how, bool coplanarIsInter,
bool *inter, bool *leaky); bool *inter, bool *leaky);

260
sketch.h
View File

@ -90,13 +90,15 @@ public:
int tag; int tag;
hGroup h; hGroup h;
static const int DRAWING_3D = 5000; enum {
static const int DRAWING_WORKPLANE = 5001; DRAWING_3D = 5000,
static const int EXTRUDE = 5100; DRAWING_WORKPLANE = 5001,
static const int LATHE = 5101; EXTRUDE = 5100,
static const int ROTATE = 5200; LATHE = 5101,
static const int TRANSLATE = 5201; ROTATE = 5200,
static const int IMPORTED = 5300; TRANSLATE = 5201,
IMPORTED = 5300
};
int type; int type;
int order; int order;
@ -122,12 +124,14 @@ public:
List<hConstraint> remove; List<hConstraint> remove;
} solved; } solved;
// For drawings in 2d enum {
static const int WORKPLANE_BY_POINT_ORTHO = 6000; // For drawings in 2d
static const int WORKPLANE_BY_LINE_SEGMENTS = 6001; WORKPLANE_BY_POINT_ORTHO = 6000,
// For extrudes, translates, and rotates WORKPLANE_BY_LINE_SEGMENTS = 6001,
static const int ONE_SIDED = 7000; // For extrudes, translates, and rotates
static const int TWO_SIDED = 7001; ONE_SIDED = 7000,
TWO_SIDED = 7001
};
int subtype; int subtype;
bool skipFirst; // for step and repeat ops bool skipFirst; // for step and repeat ops
@ -145,11 +149,13 @@ public:
SPolygon polyLoops; SPolygon polyLoops;
SBezierLoopSetSet bezierLoops; SBezierLoopSetSet bezierLoops;
SBezierList bezierOpens; SBezierList bezierOpens;
static const int POLY_GOOD = 0; enum {
static const int POLY_NOT_CLOSED = 1; POLY_GOOD = 0,
static const int POLY_NOT_COPLANAR = 2; POLY_NOT_CLOSED = 1,
static const int POLY_SELF_INTERSECTING = 3; POLY_NOT_COPLANAR = 2,
static const int POLY_ZERO_LEN_EDGE = 4; POLY_SELF_INTERSECTING = 3,
POLY_ZERO_LEN_EDGE = 4
};
struct { struct {
int how; int how;
SEdge notClosedAt; SEdge notClosedAt;
@ -168,15 +174,17 @@ public:
SMesh displayMesh; SMesh displayMesh;
SEdgeList displayEdges; SEdgeList displayEdges;
static const int COMBINE_AS_UNION = 0; enum {
static const int COMBINE_AS_DIFFERENCE = 1; COMBINE_AS_UNION = 0,
static const int COMBINE_AS_ASSEMBLE = 2; COMBINE_AS_DIFFERENCE = 1,
COMBINE_AS_ASSEMBLE = 2
};
int meshCombine; int meshCombine;
bool forceToMesh; bool forceToMesh;
IdList<EntityMap,EntityId> remap; IdList<EntityMap,EntityId> remap;
static const int REMAP_PRIME = 19477; enum { REMAP_PRIME = 19477 };
int remapCache[REMAP_PRIME]; int remapCache[REMAP_PRIME];
char impFile[MAX_PATH]; char impFile[MAX_PATH];
@ -199,11 +207,13 @@ public:
// entities may have come from multiple requests, it's necessary to // entities may have come from multiple requests, it's necessary to
// remap the entity ID so that it's still unique. We do this with a // remap the entity ID so that it's still unique. We do this with a
// mapping list. // mapping list.
static const int REMAP_LAST = 1000; enum {
static const int REMAP_TOP = 1001; REMAP_LAST = 1000,
static const int REMAP_BOTTOM = 1002; REMAP_TOP = 1001,
static const int REMAP_PT_TO_LINE = 1003; REMAP_BOTTOM = 1002,
static const int REMAP_LINE_TO_FACE = 1004; REMAP_PT_TO_LINE = 1003,
REMAP_LINE_TO_FACE = 1004
};
hEntity Remap(hEntity in, int copyNumber); hEntity Remap(hEntity in, int copyNumber);
void MakeExtrusionLines(EntityList *el, hEntity in); void MakeExtrusionLines(EntityList *el, hEntity in);
void MakeExtrusionTopBottomFaces(EntityList *el, hEntity pt); void MakeExtrusionTopBottomFaces(EntityList *el, hEntity pt);
@ -253,14 +263,16 @@ public:
hRequest h; hRequest h;
// Types of requests // Types of requests
static const int WORKPLANE = 100; enum {
static const int DATUM_POINT = 101; WORKPLANE = 100,
static const int LINE_SEGMENT = 200; DATUM_POINT = 101,
static const int CUBIC = 300; LINE_SEGMENT = 200,
static const int CUBIC_PERIODIC = 301; CUBIC = 300,
static const int CIRCLE = 400; CUBIC_PERIODIC = 301,
static const int ARC_OF_CIRCLE = 500; CIRCLE = 400,
static const int TTF_TEXT = 600; ARC_OF_CIRCLE = 500,
TTF_TEXT = 600
};
int type; int type;
int extraPoints; int extraPoints;
@ -288,36 +300,38 @@ public:
static const hEntity FREE_IN_3D; static const hEntity FREE_IN_3D;
static const hEntity NO_ENTITY; static const hEntity NO_ENTITY;
static const int POINT_IN_3D = 2000; enum {
static const int POINT_IN_2D = 2001; POINT_IN_3D = 2000,
static const int POINT_N_TRANS = 2010; POINT_IN_2D = 2001,
static const int POINT_N_ROT_TRANS = 2011; POINT_N_TRANS = 2010,
static const int POINT_N_COPY = 2012; POINT_N_ROT_TRANS = 2011,
static const int POINT_N_ROT_AA = 2013; POINT_N_COPY = 2012,
POINT_N_ROT_AA = 2013,
static const int NORMAL_IN_3D = 3000; NORMAL_IN_3D = 3000,
static const int NORMAL_IN_2D = 3001; NORMAL_IN_2D = 3001,
static const int NORMAL_N_COPY = 3010; NORMAL_N_COPY = 3010,
static const int NORMAL_N_ROT = 3011; NORMAL_N_ROT = 3011,
static const int NORMAL_N_ROT_AA = 3012; NORMAL_N_ROT_AA = 3012,
static const int DISTANCE = 4000; DISTANCE = 4000,
static const int DISTANCE_N_COPY = 4001; DISTANCE_N_COPY = 4001,
static const int FACE_NORMAL_PT = 5000; FACE_NORMAL_PT = 5000,
static const int FACE_XPROD = 5001; FACE_XPROD = 5001,
static const int FACE_N_ROT_TRANS = 5002; FACE_N_ROT_TRANS = 5002,
static const int FACE_N_TRANS = 5003; FACE_N_TRANS = 5003,
static const int FACE_N_ROT_AA = 5004; FACE_N_ROT_AA = 5004,
static const int WORKPLANE = 10000; WORKPLANE = 10000,
static const int LINE_SEGMENT = 11000; LINE_SEGMENT = 11000,
static const int CUBIC = 12000; CUBIC = 12000,
static const int CUBIC_PERIODIC = 12001; CUBIC_PERIODIC = 12001,
static const int CIRCLE = 13000; CIRCLE = 13000,
static const int ARC_OF_CIRCLE = 14000; ARC_OF_CIRCLE = 14000,
static const int TTF_TEXT = 15000; TTF_TEXT = 15000
};
int type; int type;
@ -517,41 +531,43 @@ public:
static const hConstraint NO_CONSTRAINT; static const hConstraint NO_CONSTRAINT;
static const int POINTS_COINCIDENT = 20; enum {
static const int PT_PT_DISTANCE = 30; POINTS_COINCIDENT = 20,
static const int PT_PLANE_DISTANCE = 31; PT_PT_DISTANCE = 30,
static const int PT_LINE_DISTANCE = 32; PT_PLANE_DISTANCE = 31,
static const int PT_FACE_DISTANCE = 33; PT_LINE_DISTANCE = 32,
static const int PROJ_PT_DISTANCE = 34; PT_FACE_DISTANCE = 33,
static const int PT_IN_PLANE = 41; PROJ_PT_DISTANCE = 34,
static const int PT_ON_LINE = 42; PT_IN_PLANE = 41,
static const int PT_ON_FACE = 43; PT_ON_LINE = 42,
static const int EQUAL_LENGTH_LINES = 50; PT_ON_FACE = 43,
static const int LENGTH_RATIO = 51; EQUAL_LENGTH_LINES = 50,
static const int EQ_LEN_PT_LINE_D = 52; LENGTH_RATIO = 51,
static const int EQ_PT_LN_DISTANCES = 53; EQ_LEN_PT_LINE_D = 52,
static const int EQUAL_ANGLE = 54; EQ_PT_LN_DISTANCES = 53,
static const int EQUAL_LINE_ARC_LEN = 55; EQUAL_ANGLE = 54,
static const int SYMMETRIC = 60; EQUAL_LINE_ARC_LEN = 55,
static const int SYMMETRIC_HORIZ = 61; SYMMETRIC = 60,
static const int SYMMETRIC_VERT = 62; SYMMETRIC_HORIZ = 61,
static const int SYMMETRIC_LINE = 63; SYMMETRIC_VERT = 62,
static const int AT_MIDPOINT = 70; SYMMETRIC_LINE = 63,
static const int HORIZONTAL = 80; AT_MIDPOINT = 70,
static const int VERTICAL = 81; HORIZONTAL = 80,
static const int DIAMETER = 90; VERTICAL = 81,
static const int PT_ON_CIRCLE = 100; DIAMETER = 90,
static const int SAME_ORIENTATION = 110; PT_ON_CIRCLE = 100,
static const int ANGLE = 120; SAME_ORIENTATION = 110,
static const int PARALLEL = 121; ANGLE = 120,
static const int PERPENDICULAR = 122; PARALLEL = 121,
static const int ARC_LINE_TANGENT = 123; PERPENDICULAR = 122,
static const int CUBIC_LINE_TANGENT = 124; ARC_LINE_TANGENT = 123,
static const int CURVE_CURVE_TANGENT = 125; CUBIC_LINE_TANGENT = 124,
static const int EQUAL_RADIUS = 130; CURVE_CURVE_TANGENT = 125,
static const int WHERE_DRAGGED = 200; EQUAL_RADIUS = 130,
WHERE_DRAGGED = 200,
static const int COMMENT = 1000; COMMENT = 1000
};
int type; int type;
@ -659,40 +675,46 @@ class Style {
public: public:
int tag; int tag;
hStyle h; hStyle h;
// If an entity has no style, then it will be colored according to
// whether the group that it's in is active or not, whether it's
// construction or not, and so on.
static const int NO_STYLE = 0;
static const int ACTIVE_GRP = 1; enum {
static const int CONSTRUCTION = 2; // If an entity has no style, then it will be colored according to
static const int INACTIVE_GRP = 3; // whether the group that it's in is active or not, whether it's
static const int DATUM = 4; // construction or not, and so on.
static const int SOLID_EDGE = 5; NO_STYLE = 0,
static const int CONSTRAINT = 6;
static const int SELECTED = 7;
static const int HOVERED = 8;
static const int CONTOUR_FILL = 9;
static const int NORMALS = 10;
static const int ANALYZE = 11;
static const int DRAW_ERROR = 12;
static const int DIM_SOLID = 13;
static const int FIRST_CUSTOM = 0x100; ACTIVE_GRP = 1,
CONSTRUCTION = 2,
INACTIVE_GRP = 3,
DATUM = 4,
SOLID_EDGE = 5,
CONSTRAINT = 6,
SELECTED = 7,
HOVERED = 8,
CONTOUR_FILL = 9,
NORMALS = 10,
ANALYZE = 11,
DRAW_ERROR = 12,
DIM_SOLID = 13,
FIRST_CUSTOM = 0x100
};
NameStr name; NameStr name;
static const int UNITS_AS_PIXELS = 0; enum {
static const int UNITS_AS_MM = 1; UNITS_AS_PIXELS = 0,
UNITS_AS_MM = 1
};
double width; double width;
int widthAs; int widthAs;
double textHeight; double textHeight;
int textHeightAs; int textHeightAs;
static const int ORIGIN_LEFT = 0x01; enum {
static const int ORIGIN_RIGHT = 0x02; ORIGIN_LEFT = 0x01,
static const int ORIGIN_BOT = 0x04; ORIGIN_RIGHT = 0x02,
static const int ORIGIN_TOP = 0x08; ORIGIN_BOT = 0x04,
ORIGIN_TOP = 0x08
};
int textOrigin; int textOrigin;
double textAngle; double textAngle;
DWORD color; DWORD color;

View File

@ -251,7 +251,7 @@ void Error(const char *str, ...);
class System { class System {
public: public:
static const int MAX_UNKNOWNS = 1024; enum { MAX_UNKNOWNS = 1024 };
EntityList entity; EntityList entity;
ParamList param; ParamList param;
@ -261,12 +261,14 @@ public:
// we should put as close as possible to their initial positions. // we should put as close as possible to their initial positions.
List<hParam> dragged; List<hParam> dragged;
// In general, the tag indicates the subsys that a variable/equation enum {
// has been assigned to; these are exceptions for variables: // In general, the tag indicates the subsys that a variable/equation
static const int VAR_SUBSTITUTED = 10000; // has been assigned to; these are exceptions for variables:
static const int VAR_DOF_TEST = 10001; VAR_SUBSTITUTED = 10000,
// and for equations: VAR_DOF_TEST = 10001,
static const int EQ_SUBSTITUTED = 20000; // and for equations:
EQ_SUBSTITUTED = 20000
};
// The system Jacobian matrix // The system Jacobian matrix
struct { struct {
@ -314,10 +316,12 @@ public:
bool NewtonSolve(int tag); bool NewtonSolve(int tag);
static const int SOLVED_OKAY = 0; enum {
static const int DIDNT_CONVERGE = 10; SOLVED_OKAY = 0,
static const int SINGULAR_JACOBIAN = 11; DIDNT_CONVERGE = 10,
static const int TOO_MANY_UNKNOWNS = 20; SINGULAR_JACOBIAN = 11,
TOO_MANY_UNKNOWNS = 20
};
int Solve(Group *g, int *dof, List<hConstraint> *bad, int Solve(Group *g, int *dof, List<hConstraint> *bad,
bool andFindBad, bool andFindFree); bool andFindBad, bool andFindFree);
}; };
@ -360,9 +364,11 @@ public:
// The filehandle, while loading // The filehandle, while loading
FILE *fh; FILE *fh;
// Some state while rendering a character to curves // Some state while rendering a character to curves
static const int NOTHING = 0; enum {
static const int ON_CURVE = 1; NOTHING = 0,
static const int OFF_CURVE = 2; ON_CURVE = 1,
OFF_CURVE = 2
};
int lastWas; int lastWas;
IntPoint lastOnCurve; IntPoint lastOnCurve;
IntPoint lastOffCurve; IntPoint lastOffCurve;
@ -585,7 +591,7 @@ public:
IdList<Style,hStyle> style; IdList<Style,hStyle> style;
hGroup activeGroup; hGroup activeGroup;
} UndoState; } UndoState;
static const int MAX_UNDO = 16; enum { MAX_UNDO = 16 };
typedef struct { typedef struct {
UndoState d[MAX_UNDO]; UndoState d[MAX_UNDO];
int cnt; int cnt;
@ -603,7 +609,7 @@ public:
void UndoClearStack(UndoStack *uk); void UndoClearStack(UndoStack *uk);
// Little bits of extra configuration state // Little bits of extra configuration state
static const int MODEL_COLORS = 8; enum { MODEL_COLORS = 8 };
int modelColor[MODEL_COLORS]; int modelColor[MODEL_COLORS];
Vector lightDir[2]; Vector lightDir[2];
double lightIntensity[2]; double lightIntensity[2];

View File

@ -28,11 +28,13 @@ public:
SBspUv *more; SBspUv *more;
static const int INSIDE = 100; enum {
static const int OUTSIDE = 200; INSIDE = 100,
static const int EDGE_PARALLEL = 300; OUTSIDE = 200,
static const int EDGE_ANTIPARALLEL = 400; EDGE_PARALLEL = 300,
static const int EDGE_OTHER = 500; EDGE_ANTIPARALLEL = 400,
EDGE_OTHER = 500
};
static SBspUv *Alloc(void); static SBspUv *Alloc(void);
static SBspUv *From(SEdgeList *el, SSurface *srf); static SBspUv *From(SEdgeList *el, SSurface *srf);
@ -184,9 +186,11 @@ public:
// therefore must get new hSCurves assigned. For the curves in A and B, // therefore must get new hSCurves assigned. For the curves in A and B,
// we use newH to record their new handle in C. // we use newH to record their new handle in C.
hSCurve newH; hSCurve newH;
static const int FROM_A = 100; enum {
static const int FROM_B = 200; FROM_A = 100,
static const int FROM_INTERSECTION = 300; FROM_B = 200,
FROM_INTERSECTION = 300
};
int source; int source;
bool isExact; bool isExact;
@ -328,8 +332,10 @@ public:
void TriangulateInto(SShell *shell, SMesh *sm); void TriangulateInto(SShell *shell, SMesh *sm);
// these are intended as bitmasks, even though there's just one now // these are intended as bitmasks, even though there's just one now
static const int AS_UV = 0x01; enum {
static const int AS_XYZ = 0x00; AS_UV = 0x01,
AS_XYZ = 0x00
};
void MakeTrimEdgesInto(SEdgeList *sel, int flags, SCurve *sc, STrimBy *stb); void MakeTrimEdgesInto(SEdgeList *sel, int flags, SCurve *sc, STrimBy *stb);
void MakeEdgesInto(SShell *shell, SEdgeList *sel, int flags, void MakeEdgesInto(SShell *shell, SEdgeList *sel, int flags,
SShell *useCurvesFrom=NULL); SShell *useCurvesFrom=NULL);
@ -361,9 +367,11 @@ public:
void MakeFromUnionOf(SShell *a, SShell *b); void MakeFromUnionOf(SShell *a, SShell *b);
void MakeFromDifferenceOf(SShell *a, SShell *b); void MakeFromDifferenceOf(SShell *a, SShell *b);
static const int AS_UNION = 10; enum {
static const int AS_DIFFERENCE = 11; AS_UNION = 10,
static const int AS_INTERSECT = 12; AS_DIFFERENCE = 11,
AS_INTERSECT = 12
};
void MakeFromBoolean(SShell *a, SShell *b, int type); void MakeFromBoolean(SShell *a, SShell *b, int type);
void CopyCurvesSplitAgainst(bool opA, SShell *agnst, SShell *into); void CopyCurvesSplitAgainst(bool opA, SShell *agnst, SShell *into);
void CopySurfacesTrimAgainst(SShell *sha, SShell *shb, SShell *into, void CopySurfacesTrimAgainst(SShell *sha, SShell *shb, SShell *into,
@ -380,10 +388,12 @@ public:
// Definitions when classifying regions of a surface; it is either inside, // Definitions when classifying regions of a surface; it is either inside,
// outside, or coincident (with parallel or antiparallel normal) with a // outside, or coincident (with parallel or antiparallel normal) with a
// shell. // shell.
static const int INSIDE = 100; enum {
static const int OUTSIDE = 200; INSIDE = 100,
static const int COINC_SAME = 300; OUTSIDE = 200,
static const int COINC_OPP = 400; COINC_SAME = 300,
COINC_OPP = 400
};
static const double DOTP_TOL; static const double DOTP_TOL;
int ClassifyRegion(Vector edge_n, Vector inter_surf_n, Vector edge_surf_n); int ClassifyRegion(Vector edge_n, Vector inter_surf_n, Vector edge_surf_n);
bool ClassifyEdge(int *indir, int *outdir, bool ClassifyEdge(int *indir, int *outdir,

214
ui.h
View File

@ -10,9 +10,11 @@
class TextWindow { class TextWindow {
public: public:
static const int MAX_COLS = 100; enum {
static const int MIN_COLS = 45; MAX_COLS = 100,
static const int MAX_ROWS = 2000; MIN_COLS = 45,
MAX_ROWS = 2000
};
#ifndef RGB #ifndef RGB
#define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16)) #define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
@ -34,22 +36,24 @@ public:
float bgColorTable[256*3]; float bgColorTable[256*3];
float fgColorTable[256*3]; float fgColorTable[256*3];
static const int CHAR_WIDTH = 9; enum {
static const int CHAR_HEIGHT = 16; CHAR_WIDTH = 9,
static const int LINE_HEIGHT = 20; CHAR_HEIGHT = 16,
static const int LEFT_MARGIN = 6; LINE_HEIGHT = 20,
LEFT_MARGIN = 6,
static const int CHECK_FALSE = 0x80; CHECK_FALSE = 0x80,
static const int CHECK_TRUE = 0x81; CHECK_TRUE = 0x81,
static const int RADIO_FALSE = 0x82; RADIO_FALSE = 0x82,
static const int RADIO_TRUE = 0x83; RADIO_TRUE = 0x83
};
int scrollPos; // The scrollbar position, in half-row units int scrollPos; // The scrollbar position, in half-row units
int halfRows; // The height of our window, in half-row units int halfRows; // The height of our window, in half-row units
BYTE text[MAX_ROWS][MAX_COLS]; BYTE text[MAX_ROWS][MAX_COLS];
typedef void LinkFunction(int link, DWORD v); typedef void LinkFunction(int link, DWORD v);
static const int NOT_A_LINK = 0; enum { NOT_A_LINK = 0 };
struct { struct {
char fg; char fg;
int bg; int bg;
@ -80,9 +84,11 @@ public:
void MouseLeave(void); void MouseLeave(void);
void ScrollbarEvent(int newPos); void ScrollbarEvent(int newPos);
static const int PAINT = 0; enum {
static const int HOVER = 1; PAINT = 0,
static const int CLICK = 2; HOVER = 1,
CLICK = 2
};
void DrawOrHitTestIcons(int how, double mx, double my); void DrawOrHitTestIcons(int how, double mx, double my);
void TimerCallback(void); void TimerCallback(void);
Point2d oldMousePos; Point2d oldMousePos;
@ -102,16 +108,18 @@ public:
void Show(void); void Show(void);
// State for the screen that we are showing in the text window. // State for the screen that we are showing in the text window.
static const int SCREEN_LIST_OF_GROUPS = 0; enum {
static const int SCREEN_GROUP_INFO = 1; SCREEN_LIST_OF_GROUPS = 0,
static const int SCREEN_GROUP_SOLVE_INFO = 2; SCREEN_GROUP_INFO = 1,
static const int SCREEN_CONFIGURATION = 3; SCREEN_GROUP_SOLVE_INFO = 2,
static const int SCREEN_STEP_DIMENSION = 4; SCREEN_CONFIGURATION = 3,
static const int SCREEN_LIST_OF_STYLES = 5; SCREEN_STEP_DIMENSION = 4,
static const int SCREEN_STYLE_INFO = 6; SCREEN_LIST_OF_STYLES = 5,
static const int SCREEN_PASTE_TRANSFORMED = 7; SCREEN_STYLE_INFO = 6,
static const int SCREEN_EDIT_VIEW = 8; SCREEN_PASTE_TRANSFORMED = 7,
static const int SCREEN_TANGENT_ARC = 9; SCREEN_EDIT_VIEW = 8,
SCREEN_TANGENT_ARC = 9
};
typedef struct { typedef struct {
int screen; int screen;
@ -133,53 +141,55 @@ public:
} ShownState; } ShownState;
ShownState shown; ShownState shown;
static const int EDIT_NOTHING = 0; enum {
// For multiple groups EDIT_NOTHING = 0,
static const int EDIT_TIMES_REPEATED = 1; // For multiple groups
static const int EDIT_GROUP_NAME = 2; EDIT_TIMES_REPEATED = 1,
static const int EDIT_GROUP_SCALE = 3; EDIT_GROUP_NAME = 2,
static const int EDIT_GROUP_COLOR = 4; EDIT_GROUP_SCALE = 3,
// For the configuraiton screen EDIT_GROUP_COLOR = 4,
static const int EDIT_LIGHT_DIRECTION = 100; // For the configuraiton screen
static const int EDIT_LIGHT_INTENSITY = 101; EDIT_LIGHT_DIRECTION = 100,
static const int EDIT_COLOR = 102; EDIT_LIGHT_INTENSITY = 101,
static const int EDIT_CHORD_TOLERANCE = 103; EDIT_COLOR = 102,
static const int EDIT_MAX_SEGMENTS = 104; EDIT_CHORD_TOLERANCE = 103,
static const int EDIT_CAMERA_TANGENT = 105; EDIT_MAX_SEGMENTS = 104,
static const int EDIT_GRID_SPACING = 106; EDIT_CAMERA_TANGENT = 105,
static const int EDIT_DIGITS_AFTER_DECIMAL = 107; EDIT_GRID_SPACING = 106,
static const int EDIT_EXPORT_SCALE = 108; EDIT_DIGITS_AFTER_DECIMAL = 107,
static const int EDIT_EXPORT_OFFSET = 109; EDIT_EXPORT_SCALE = 108,
static const int EDIT_CANVAS_SIZE = 110; EDIT_EXPORT_OFFSET = 109,
static const int EDIT_G_CODE_DEPTH = 120; EDIT_CANVAS_SIZE = 110,
static const int EDIT_G_CODE_PASSES = 121; EDIT_G_CODE_DEPTH = 120,
static const int EDIT_G_CODE_FEED = 122; EDIT_G_CODE_PASSES = 121,
static const int EDIT_G_CODE_PLUNGE_FEED = 123; EDIT_G_CODE_FEED = 122,
// For TTF text EDIT_G_CODE_PLUNGE_FEED = 123,
static const int EDIT_TTF_TEXT = 300; // For TTF text
// For the step dimension screen EDIT_TTF_TEXT = 300,
static const int EDIT_STEP_DIM_FINISH = 400; // For the step dimension screen
static const int EDIT_STEP_DIM_STEPS = 401; EDIT_STEP_DIM_FINISH = 400,
// For the styles stuff EDIT_STEP_DIM_STEPS = 401,
static const int EDIT_STYLE_WIDTH = 500; // For the styles stuff
static const int EDIT_STYLE_TEXT_HEIGHT = 501; EDIT_STYLE_WIDTH = 500,
static const int EDIT_STYLE_TEXT_ANGLE = 502; EDIT_STYLE_TEXT_HEIGHT = 501,
static const int EDIT_STYLE_COLOR = 503; EDIT_STYLE_TEXT_ANGLE = 502,
static const int EDIT_STYLE_FILL_COLOR = 504; EDIT_STYLE_COLOR = 503,
static const int EDIT_STYLE_NAME = 505; EDIT_STYLE_FILL_COLOR = 504,
static const int EDIT_BACKGROUND_COLOR = 506; EDIT_STYLE_NAME = 505,
static const int EDIT_BACKGROUND_IMG_SCALE = 507; EDIT_BACKGROUND_COLOR = 506,
// For paste transforming EDIT_BACKGROUND_IMG_SCALE = 507,
static const int EDIT_PASTE_TIMES_REPEATED = 600; // For paste transforming
static const int EDIT_PASTE_ANGLE = 601; EDIT_PASTE_TIMES_REPEATED = 600,
static const int EDIT_PASTE_SCALE = 602; EDIT_PASTE_ANGLE = 601,
// For view EDIT_PASTE_SCALE = 602,
static const int EDIT_VIEW_SCALE = 700; // For view
static const int EDIT_VIEW_ORIGIN = 701; EDIT_VIEW_SCALE = 700,
static const int EDIT_VIEW_PROJ_RIGHT = 702; EDIT_VIEW_ORIGIN = 701,
static const int EDIT_VIEW_PROJ_UP = 703; EDIT_VIEW_PROJ_RIGHT = 702,
// For tangent arc EDIT_VIEW_PROJ_UP = 703,
static const int EDIT_TANGENT_ARC_RADIUS = 800; // For tangent arc
EDIT_TANGENT_ARC_RADIUS = 800
};
struct { struct {
bool showAgain; bool showAgain;
int meaning; int meaning;
@ -487,17 +497,19 @@ public:
// Operations that must be completed by doing something with the mouse // Operations that must be completed by doing something with the mouse
// are noted here. These occupy the same space as the menu ids. // are noted here. These occupy the same space as the menu ids.
static const int FIRST_PENDING = 0x0f000000; enum {
static const int DRAGGING_POINTS = 0x0f000000; FIRST_PENDING = 0x0f000000,
static const int DRAGGING_NEW_POINT = 0x0f000001; DRAGGING_POINTS = 0x0f000000,
static const int DRAGGING_NEW_LINE_POINT = 0x0f000002; DRAGGING_NEW_POINT = 0x0f000001,
static const int DRAGGING_NEW_CUBIC_POINT = 0x0f000003; DRAGGING_NEW_LINE_POINT = 0x0f000002,
static const int DRAGGING_NEW_ARC_POINT = 0x0f000004; DRAGGING_NEW_CUBIC_POINT = 0x0f000003,
static const int DRAGGING_CONSTRAINT = 0x0f000005; DRAGGING_NEW_ARC_POINT = 0x0f000004,
static const int DRAGGING_RADIUS = 0x0f000006; DRAGGING_CONSTRAINT = 0x0f000005,
static const int DRAGGING_NORMAL = 0x0f000007; DRAGGING_RADIUS = 0x0f000006,
static const int DRAGGING_NEW_RADIUS = 0x0f000008; DRAGGING_NORMAL = 0x0f000007,
static const int DRAGGING_MARQUEE = 0x0f000009; DRAGGING_NEW_RADIUS = 0x0f000008,
DRAGGING_MARQUEE = 0x0f000009
};
struct { struct {
int operation; int operation;
@ -568,7 +580,7 @@ public:
void HitTestMakeSelection(Point2d mp); void HitTestMakeSelection(Point2d mp);
void ClearSelection(void); void ClearSelection(void);
void ClearNonexistentSelectionItems(void); void ClearNonexistentSelectionItems(void);
static const int MAX_SELECTED = 32; enum { MAX_SELECTED = 32 };
struct { struct {
hEntity point[MAX_SELECTED]; hEntity point[MAX_SELECTED];
hEntity entity[MAX_SELECTED]; hEntity entity[MAX_SELECTED];
@ -603,22 +615,24 @@ public:
void SelectByMarquee(void); void SelectByMarquee(void);
void ClearSuper(void); void ClearSuper(void);
static const int CMNU_UNSELECT_ALL = 0x100; enum {
static const int CMNU_UNSELECT_HOVERED = 0x101; CMNU_UNSELECT_ALL = 0x100,
static const int CMNU_CUT_SEL = 0x102; CMNU_UNSELECT_HOVERED = 0x101,
static const int CMNU_COPY_SEL = 0x103; CMNU_CUT_SEL = 0x102,
static const int CMNU_PASTE_SEL = 0x104; CMNU_COPY_SEL = 0x103,
static const int CMNU_DELETE_SEL = 0x105; CMNU_PASTE_SEL = 0x104,
static const int CMNU_SELECT_CHAIN = 0x106; CMNU_DELETE_SEL = 0x105,
static const int CMNU_NEW_CUSTOM_STYLE = 0x110; CMNU_SELECT_CHAIN = 0x106,
static const int CMNU_NO_STYLE = 0x111; CMNU_NEW_CUSTOM_STYLE = 0x110,
static const int CMNU_GROUP_INFO = 0x120; CMNU_NO_STYLE = 0x111,
static const int CMNU_STYLE_INFO = 0x121; CMNU_GROUP_INFO = 0x120,
static const int CMNU_REFERENCE_DIM = 0x130; CMNU_STYLE_INFO = 0x121,
static const int CMNU_OTHER_ANGLE = 0x131; CMNU_REFERENCE_DIM = 0x130,
static const int CMNU_DEL_COINCIDENT = 0x132; CMNU_OTHER_ANGLE = 0x131,
static const int CMNU_SNAP_TO_GRID = 0x140; CMNU_DEL_COINCIDENT = 0x132,
static const int CMNU_FIRST_STYLE = 0x40000000; CMNU_SNAP_TO_GRID = 0x140,
CMNU_FIRST_STYLE = 0x40000000
};
void ContextMenuListStyles(void); void ContextMenuListStyles(void);
SDWORD contextMenuCancelTime; SDWORD contextMenuCancelTime;