2013-07-28 22:08:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// The parametric structure of our sketch, in multiple groups, that generate
|
|
|
|
// geometric entities and surfaces.
|
|
|
|
//
|
|
|
|
// Copyright 2008-2013 Jonathan Westhues.
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-03-26 09:18:12 +00:00
|
|
|
|
|
|
|
#ifndef __SKETCH_H
|
|
|
|
#define __SKETCH_H
|
|
|
|
|
2008-04-12 16:28:48 +00:00
|
|
|
class hGroup;
|
2008-03-28 10:00:37 +00:00
|
|
|
class hRequest;
|
2008-04-12 16:28:48 +00:00
|
|
|
class hEntity;
|
2008-03-28 10:00:37 +00:00
|
|
|
class hParam;
|
2009-07-20 01:47:59 +00:00
|
|
|
class hStyle;
|
|
|
|
class hConstraint;
|
|
|
|
class hEquation;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
class Entity;
|
2008-04-12 16:28:48 +00:00
|
|
|
class Param;
|
2008-04-14 10:28:32 +00:00
|
|
|
class Equation;
|
|
|
|
|
2009-07-20 01:47:59 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
// All of the hWhatever handles are a 32-bit ID, that is used to represent
|
|
|
|
// some data structure in the sketch.
|
2008-04-08 12:54:53 +00:00
|
|
|
class hGroup {
|
|
|
|
public:
|
2008-04-19 11:09:47 +00:00
|
|
|
// bits 15: 0 -- group index
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t v;
|
2008-04-27 09:03:01 +00:00
|
|
|
|
|
|
|
inline hEntity entity(int i);
|
|
|
|
inline hParam param(int i);
|
2008-05-11 06:09:46 +00:00
|
|
|
inline hEquation equation(int i);
|
2008-04-08 12:54:53 +00:00
|
|
|
};
|
2008-03-28 10:00:37 +00:00
|
|
|
class hRequest {
|
|
|
|
public:
|
2008-04-19 11:09:47 +00:00
|
|
|
// bits 15: 0 -- request index
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t v;
|
2008-04-13 10:57:41 +00:00
|
|
|
|
|
|
|
inline hEntity entity(int i);
|
2008-04-19 11:09:47 +00:00
|
|
|
inline hParam param(int i);
|
2008-04-21 08:16:38 +00:00
|
|
|
|
|
|
|
inline bool IsFromReferences(void);
|
2008-04-09 08:39:01 +00:00
|
|
|
};
|
|
|
|
class hEntity {
|
|
|
|
public:
|
2008-04-19 11:09:47 +00:00
|
|
|
// bits 15: 0 -- entity index
|
|
|
|
// 31:16 -- request index
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t v;
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
inline bool isFromRequest(void);
|
2008-04-13 10:57:41 +00:00
|
|
|
inline hRequest request(void);
|
2008-05-11 10:40:37 +00:00
|
|
|
inline hGroup group(void);
|
2008-05-08 07:30:30 +00:00
|
|
|
inline hEquation equation(int i);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-04-08 12:54:53 +00:00
|
|
|
class hParam {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-19 11:09:47 +00:00
|
|
|
// bits 15: 0 -- param index
|
|
|
|
// 31:16 -- request index
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t v;
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
inline hRequest request(void);
|
2008-04-08 12:54:53 +00:00
|
|
|
};
|
|
|
|
|
2009-07-20 01:47:59 +00:00
|
|
|
class hStyle {
|
|
|
|
public:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t v;
|
2009-07-20 01:47:59 +00:00
|
|
|
};
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
|
|
|
|
class EntityId {
|
2008-04-27 09:03:01 +00:00
|
|
|
public:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t v; // entity ID, starting from 0
|
2008-04-27 03:26:27 +00:00
|
|
|
};
|
|
|
|
class EntityMap {
|
2008-04-27 09:03:01 +00:00
|
|
|
public:
|
2008-04-27 03:26:27 +00:00
|
|
|
int tag;
|
|
|
|
|
|
|
|
EntityId h;
|
|
|
|
hEntity input;
|
|
|
|
int copyNumber;
|
|
|
|
// (input, copyNumber) gets mapped to ((Request)xxx).entity(h.v)
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void) {}
|
2008-04-27 03:26:27 +00:00
|
|
|
};
|
|
|
|
|
2008-04-18 07:06:37 +00:00
|
|
|
// A set of requests. Every request must have an associated group.
|
2008-04-08 12:54:53 +00:00
|
|
|
class Group {
|
|
|
|
public:
|
|
|
|
static const hGroup HGROUP_REFERENCES;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-09 08:39:01 +00:00
|
|
|
hGroup h;
|
|
|
|
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
DRAWING_3D = 5000,
|
|
|
|
DRAWING_WORKPLANE = 5001,
|
|
|
|
EXTRUDE = 5100,
|
|
|
|
LATHE = 5101,
|
|
|
|
ROTATE = 5200,
|
|
|
|
TRANSLATE = 5201,
|
|
|
|
IMPORTED = 5300
|
|
|
|
};
|
2008-04-24 06:22:16 +00:00
|
|
|
int type;
|
|
|
|
|
2008-02-07 09:53:52 +00:00
|
|
|
int order;
|
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
hGroup opA;
|
2008-06-21 10:18:20 +00:00
|
|
|
hGroup opB;
|
2008-04-23 07:29:19 +00:00
|
|
|
bool visible;
|
2008-02-15 11:35:15 +00:00
|
|
|
bool suppress;
|
2009-10-01 11:22:56 +00:00
|
|
|
bool relaxConstraints;
|
2010-05-10 01:06:09 +00:00
|
|
|
bool allDimsReference;
|
2009-12-15 12:26:22 +00:00
|
|
|
double scale;
|
2008-02-15 11:35:15 +00:00
|
|
|
|
2008-06-02 09:31:26 +00:00
|
|
|
bool clean;
|
2008-05-27 02:22:20 +00:00
|
|
|
hEntity activeWorkplane;
|
2008-06-14 08:43:38 +00:00
|
|
|
double valA;
|
2008-06-23 08:25:17 +00:00
|
|
|
double valB;
|
|
|
|
double valC;
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
RgbColor color;
|
2008-04-23 07:29:19 +00:00
|
|
|
|
2008-05-26 09:56:50 +00:00
|
|
|
struct {
|
|
|
|
int how;
|
2008-07-10 07:42:35 +00:00
|
|
|
int dof;
|
2009-01-13 06:56:05 +00:00
|
|
|
List<hConstraint> remove;
|
2008-05-26 09:56:50 +00:00
|
|
|
} solved;
|
|
|
|
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
// For drawings in 2d
|
|
|
|
WORKPLANE_BY_POINT_ORTHO = 6000,
|
|
|
|
WORKPLANE_BY_LINE_SEGMENTS = 6001,
|
|
|
|
// For extrudes, translates, and rotates
|
|
|
|
ONE_SIDED = 7000,
|
|
|
|
TWO_SIDED = 7001
|
|
|
|
};
|
2008-05-17 08:02:39 +00:00
|
|
|
int subtype;
|
|
|
|
|
2008-06-12 04:36:33 +00:00
|
|
|
bool skipFirst; // for step and repeat ops
|
|
|
|
|
2008-05-11 10:40:37 +00:00
|
|
|
struct {
|
|
|
|
Quaternion q;
|
|
|
|
hEntity origin;
|
|
|
|
hEntity entityB;
|
|
|
|
hEntity entityC;
|
|
|
|
bool swapUV;
|
|
|
|
bool negateU;
|
|
|
|
bool negateV;
|
2008-06-01 08:29:59 +00:00
|
|
|
} predef;
|
2008-05-11 10:40:37 +00:00
|
|
|
|
2009-10-29 07:16:28 +00:00
|
|
|
SPolygon polyLoops;
|
|
|
|
SBezierLoopSetSet bezierLoops;
|
|
|
|
SBezierList bezierOpens;
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
POLY_GOOD = 0,
|
|
|
|
POLY_NOT_CLOSED = 1,
|
|
|
|
POLY_NOT_COPLANAR = 2,
|
|
|
|
POLY_SELF_INTERSECTING = 3,
|
|
|
|
POLY_ZERO_LEN_EDGE = 4
|
|
|
|
};
|
2008-05-02 10:54:22 +00:00
|
|
|
struct {
|
2008-06-12 04:36:33 +00:00
|
|
|
int how;
|
2008-05-02 10:54:22 +00:00
|
|
|
SEdge notClosedAt;
|
2009-01-23 03:30:30 +00:00
|
|
|
Vector errorPointAt;
|
2008-05-02 10:54:22 +00:00
|
|
|
} polyError;
|
2008-06-12 04:36:33 +00:00
|
|
|
|
2009-05-30 08:49:09 +00:00
|
|
|
bool booleanFailed;
|
|
|
|
|
2009-01-23 03:30:30 +00:00
|
|
|
SShell thisShell;
|
|
|
|
SShell runningShell;
|
2009-03-29 06:05:28 +00:00
|
|
|
|
2009-05-21 09:06:26 +00:00
|
|
|
SMesh thisMesh;
|
2008-06-21 10:18:20 +00:00
|
|
|
SMesh runningMesh;
|
2009-05-21 09:06:26 +00:00
|
|
|
|
|
|
|
bool displayDirty;
|
|
|
|
SMesh displayMesh;
|
|
|
|
SEdgeList displayEdges;
|
2008-04-25 07:04:09 +00:00
|
|
|
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
COMBINE_AS_UNION = 0,
|
|
|
|
COMBINE_AS_DIFFERENCE = 1,
|
|
|
|
COMBINE_AS_ASSEMBLE = 2
|
|
|
|
};
|
2008-05-25 13:11:44 +00:00
|
|
|
int meshCombine;
|
|
|
|
|
2009-05-21 09:06:26 +00:00
|
|
|
bool forceToMesh;
|
|
|
|
|
2008-05-29 10:10:12 +00:00
|
|
|
IdList<EntityMap,EntityId> remap;
|
2013-09-09 19:50:32 +00:00
|
|
|
enum { REMAP_PRIME = 19477 };
|
2008-06-12 04:36:33 +00:00
|
|
|
int remapCache[REMAP_PRIME];
|
2008-05-29 10:10:12 +00:00
|
|
|
|
|
|
|
char impFile[MAX_PATH];
|
2008-06-25 05:14:49 +00:00
|
|
|
char impFileRel[MAX_PATH];
|
2008-05-29 10:10:12 +00:00
|
|
|
SMesh impMesh;
|
2009-05-19 07:26:38 +00:00
|
|
|
SShell impShell;
|
2008-05-29 10:10:12 +00:00
|
|
|
EntityList impEntity;
|
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
NameStr name;
|
2008-05-29 10:10:12 +00:00
|
|
|
|
|
|
|
|
2008-06-02 05:38:12 +00:00
|
|
|
void Activate(void);
|
2008-04-12 14:12:26 +00:00
|
|
|
char *DescriptionString(void);
|
2010-02-28 19:23:01 +00:00
|
|
|
void Clear(void);
|
2008-04-23 07:29:19 +00:00
|
|
|
|
2008-06-23 08:25:17 +00:00
|
|
|
static void AddParam(ParamList *param, hParam hp, double v);
|
|
|
|
void Generate(EntityList *entity, ParamList *param);
|
2009-07-20 19:05:33 +00:00
|
|
|
void TransformImportedBy(Vector t, Quaternion q);
|
2008-04-27 03:26:27 +00:00
|
|
|
// When a request generates entities from entities, and the source
|
|
|
|
// 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
|
|
|
|
// mapping list.
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
REMAP_LAST = 1000,
|
|
|
|
REMAP_TOP = 1001,
|
|
|
|
REMAP_BOTTOM = 1002,
|
|
|
|
REMAP_PT_TO_LINE = 1003,
|
|
|
|
REMAP_LINE_TO_FACE = 1004
|
|
|
|
};
|
2008-04-27 03:26:27 +00:00
|
|
|
hEntity Remap(hEntity in, int copyNumber);
|
2008-06-23 08:25:17 +00:00
|
|
|
void MakeExtrusionLines(EntityList *el, hEntity in);
|
|
|
|
void MakeExtrusionTopBottomFaces(EntityList *el, hEntity pt);
|
|
|
|
void CopyEntity(EntityList *el,
|
2008-06-06 07:50:08 +00:00
|
|
|
Entity *ep, int timesApplied, int remap,
|
2008-06-01 08:29:59 +00:00
|
|
|
hParam dx, hParam dy, hParam dz,
|
2008-05-11 06:09:46 +00:00
|
|
|
hParam qw, hParam qvx, hParam qvy, hParam qvz,
|
2008-06-01 08:29:59 +00:00
|
|
|
bool asTrans, bool asAxisAngle);
|
2008-05-11 06:09:46 +00:00
|
|
|
|
2008-06-01 08:29:59 +00:00
|
|
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
2008-05-11 06:09:46 +00:00
|
|
|
void GenerateEquations(IdList<Equation,hEquation> *l);
|
2009-10-29 07:16:28 +00:00
|
|
|
bool IsVisible(void);
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2009-01-19 03:33:15 +00:00
|
|
|
// Assembling the curves into loops, and into a piecewise linear polygon
|
|
|
|
// at the same time.
|
2009-12-03 19:14:34 +00:00
|
|
|
void AssembleLoops(bool *allClosed, bool *allCoplanar, bool *allNonZeroLen);
|
2009-01-19 03:33:15 +00:00
|
|
|
void GenerateLoops(void);
|
2008-06-21 10:18:20 +00:00
|
|
|
// And the mesh stuff
|
2009-05-22 10:02:02 +00:00
|
|
|
Group *PreviousGroup(void);
|
2009-07-20 01:47:59 +00:00
|
|
|
Group *RunningMeshGroup(void);
|
2009-01-23 03:30:30 +00:00
|
|
|
void GenerateShellAndMesh(void);
|
2009-07-20 01:47:59 +00:00
|
|
|
template<class T> void GenerateForStepAndRepeat(T *steps, T *outs);
|
|
|
|
template<class T> void GenerateForBoolean(T *a, T *b, T *o, int how);
|
2009-06-30 07:24:36 +00:00
|
|
|
void GenerateDisplayItems(void);
|
|
|
|
void DrawDisplayItems(int t);
|
2008-04-25 07:04:09 +00:00
|
|
|
void Draw(void);
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
RgbColor GetLoopSetFillColor(SBezierLoopSet *sbls,
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
bool *allSame, Vector *errorAt);
|
2009-10-29 07:16:28 +00:00
|
|
|
void FillLoopSetAsPolygon(SBezierLoopSet *sbls);
|
|
|
|
void DrawFilledPaths(void);
|
2008-04-25 07:04:09 +00:00
|
|
|
|
2008-04-23 07:29:19 +00:00
|
|
|
SPolygon GetPolygon(void);
|
2008-04-27 09:03:01 +00:00
|
|
|
|
|
|
|
static void MenuGroup(int id);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
// A user request for some primitive or derived operation; for example a
|
2008-04-20 11:35:10 +00:00
|
|
|
// line, or a step and repeat.
|
2008-04-08 12:54:53 +00:00
|
|
|
class Request {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-09 08:39:01 +00:00
|
|
|
// Some predefined requests, that are present in every sketch.
|
2008-04-08 12:54:53 +00:00
|
|
|
static const hRequest HREQUEST_REFERENCE_XY;
|
|
|
|
static const hRequest HREQUEST_REFERENCE_YZ;
|
|
|
|
static const hRequest HREQUEST_REFERENCE_ZX;
|
|
|
|
|
2008-04-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-18 07:06:37 +00:00
|
|
|
hRequest h;
|
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
// Types of requests
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
WORKPLANE = 100,
|
|
|
|
DATUM_POINT = 101,
|
|
|
|
LINE_SEGMENT = 200,
|
|
|
|
CUBIC = 300,
|
|
|
|
CUBIC_PERIODIC = 301,
|
|
|
|
CIRCLE = 400,
|
|
|
|
ARC_OF_CIRCLE = 500,
|
|
|
|
TTF_TEXT = 600
|
|
|
|
};
|
2008-04-08 12:54:53 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
int type;
|
2009-10-21 04:46:01 +00:00
|
|
|
int extraPoints;
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
hEntity workplane; // or Entity::FREE_IN_3D
|
2008-04-08 12:54:53 +00:00
|
|
|
hGroup group;
|
2009-07-20 01:47:59 +00:00
|
|
|
hStyle style;
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2008-04-22 13:14:15 +00:00
|
|
|
bool construction;
|
2008-06-30 09:09:17 +00:00
|
|
|
NameStr str;
|
|
|
|
NameStr font;
|
2015-03-29 00:30:52 +00:00
|
|
|
|
2008-06-23 08:25:17 +00:00
|
|
|
static hParam AddParam(ParamList *param, hParam hp);
|
|
|
|
void Generate(EntityList *entity, ParamList *param);
|
2008-04-12 14:12:26 +00:00
|
|
|
|
|
|
|
char *DescriptionString(void);
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void) {}
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2009-12-03 19:14:34 +00:00
|
|
|
#define MAX_POINTS_IN_ENTITY (12)
|
2009-04-19 04:28:21 +00:00
|
|
|
class EntityBase {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-18 11:11:48 +00:00
|
|
|
int tag;
|
|
|
|
hEntity h;
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
static const hEntity FREE_IN_3D;
|
2008-05-08 07:30:30 +00:00
|
|
|
static const hEntity NO_ENTITY;
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
POINT_IN_3D = 2000,
|
|
|
|
POINT_IN_2D = 2001,
|
|
|
|
POINT_N_TRANS = 2010,
|
|
|
|
POINT_N_ROT_TRANS = 2011,
|
|
|
|
POINT_N_COPY = 2012,
|
|
|
|
POINT_N_ROT_AA = 2013,
|
|
|
|
|
|
|
|
NORMAL_IN_3D = 3000,
|
|
|
|
NORMAL_IN_2D = 3001,
|
|
|
|
NORMAL_N_COPY = 3010,
|
|
|
|
NORMAL_N_ROT = 3011,
|
|
|
|
NORMAL_N_ROT_AA = 3012,
|
|
|
|
|
|
|
|
DISTANCE = 4000,
|
|
|
|
DISTANCE_N_COPY = 4001,
|
|
|
|
|
|
|
|
FACE_NORMAL_PT = 5000,
|
|
|
|
FACE_XPROD = 5001,
|
|
|
|
FACE_N_ROT_TRANS = 5002,
|
|
|
|
FACE_N_TRANS = 5003,
|
|
|
|
FACE_N_ROT_AA = 5004,
|
|
|
|
|
|
|
|
|
|
|
|
WORKPLANE = 10000,
|
|
|
|
LINE_SEGMENT = 11000,
|
|
|
|
CUBIC = 12000,
|
|
|
|
CUBIC_PERIODIC = 12001,
|
|
|
|
CIRCLE = 13000,
|
|
|
|
ARC_OF_CIRCLE = 14000,
|
|
|
|
TTF_TEXT = 15000
|
|
|
|
};
|
2008-05-05 06:18:01 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
int type;
|
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
hGroup group;
|
|
|
|
hEntity workplane; // or Entity::FREE_IN_3D
|
|
|
|
|
2008-04-27 03:26:27 +00:00
|
|
|
// When it comes time to draw an entity, we look here to get the
|
|
|
|
// defining variables.
|
2009-12-03 19:14:34 +00:00
|
|
|
hEntity point[MAX_POINTS_IN_ENTITY];
|
2009-10-21 04:46:01 +00:00
|
|
|
int extraPoints;
|
2008-05-05 06:18:01 +00:00
|
|
|
hEntity normal;
|
2008-05-07 08:19:37 +00:00
|
|
|
hEntity distance;
|
|
|
|
// The only types that have their own params are points, normals,
|
|
|
|
// and directions.
|
2008-05-11 06:09:46 +00:00
|
|
|
hParam param[7];
|
2008-05-05 06:18:01 +00:00
|
|
|
|
2008-05-29 10:10:12 +00:00
|
|
|
// Transformed points/normals/distances have their numerical base
|
2008-05-05 06:18:01 +00:00
|
|
|
Vector numPoint;
|
|
|
|
Quaternion numNormal;
|
2008-05-07 08:19:37 +00:00
|
|
|
double numDistance;
|
2008-06-13 04:41:27 +00:00
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
NameStr str;
|
|
|
|
NameStr font;
|
2008-05-07 04:17:29 +00:00
|
|
|
|
2008-04-27 09:03:01 +00:00
|
|
|
// For entities that are derived by a transformation, the number of
|
|
|
|
// times to apply the transformation.
|
|
|
|
int timesApplied;
|
|
|
|
|
2008-06-21 22:49:57 +00:00
|
|
|
Quaternion GetAxisAngleQuaternion(int param0);
|
|
|
|
ExprQuaternion GetAxisAngleQuaternionExprs(int param0);
|
2008-06-02 09:31:26 +00:00
|
|
|
|
2008-05-08 07:30:30 +00:00
|
|
|
bool IsCircle(void);
|
2008-05-12 10:01:44 +00:00
|
|
|
Expr *CircleGetRadiusExpr(void);
|
|
|
|
double CircleGetRadiusNum(void);
|
|
|
|
void ArcGetAngles(double *thetaa, double *thetab, double *dtheta);
|
2008-05-08 07:30:30 +00:00
|
|
|
|
2008-05-09 05:33:23 +00:00
|
|
|
bool HasVector(void);
|
|
|
|
ExprVector VectorGetExprs(void);
|
2008-05-11 10:40:37 +00:00
|
|
|
Vector VectorGetNum(void);
|
2008-05-09 05:33:23 +00:00
|
|
|
Vector VectorGetRefPoint(void);
|
2008-05-07 04:17:29 +00:00
|
|
|
|
2008-05-07 08:19:37 +00:00
|
|
|
// For distances
|
2009-11-03 18:54:49 +00:00
|
|
|
bool IsDistance(void);
|
2008-05-07 08:19:37 +00:00
|
|
|
double DistanceGetNum(void);
|
|
|
|
Expr *DistanceGetExpr(void);
|
|
|
|
void DistanceForceTo(double v);
|
|
|
|
|
2008-05-05 11:17:00 +00:00
|
|
|
bool IsWorkplane(void);
|
|
|
|
// The plane is points P such that P dot (xn, yn, zn) - d = 0
|
|
|
|
void WorkplaneGetPlaneExprs(ExprVector *n, Expr **d);
|
2008-04-27 03:26:27 +00:00
|
|
|
ExprVector WorkplaneGetOffsetExprs(void);
|
2008-05-05 11:17:00 +00:00
|
|
|
Vector WorkplaneGetOffset(void);
|
2009-04-20 07:30:09 +00:00
|
|
|
EntityBase *Normal(void);
|
2008-04-13 14:28:35 +00:00
|
|
|
|
2008-06-02 03:31:37 +00:00
|
|
|
bool IsFace(void);
|
|
|
|
ExprVector FaceGetNormalExprs(void);
|
|
|
|
Vector FaceGetNormalNum(void);
|
|
|
|
ExprVector FaceGetPointExprs(void);
|
2008-06-06 08:46:55 +00:00
|
|
|
Vector FaceGetPointNum(void);
|
2008-06-02 03:31:37 +00:00
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
bool IsPoint(void);
|
|
|
|
// Applies for any of the point types
|
2008-05-05 06:18:01 +00:00
|
|
|
Vector PointGetNum(void);
|
2008-04-22 13:14:15 +00:00
|
|
|
ExprVector PointGetExprs(void);
|
2008-04-27 05:00:12 +00:00
|
|
|
void PointGetExprsInWorkplane(hEntity wrkpl, Expr **u, Expr **v);
|
2008-04-19 11:44:44 +00:00
|
|
|
void PointForceTo(Vector v);
|
2008-05-11 06:09:46 +00:00
|
|
|
// These apply only the POINT_N_ROT_TRANS, which has an assoc rotation
|
|
|
|
Quaternion PointGetQuaternion(void);
|
|
|
|
void PointForceQuaternionTo(Quaternion q);
|
2008-04-21 08:16:38 +00:00
|
|
|
|
2008-05-05 06:18:01 +00:00
|
|
|
bool IsNormal(void);
|
|
|
|
// Applies for any of the normal types
|
|
|
|
Quaternion NormalGetNum(void);
|
|
|
|
ExprQuaternion NormalGetExprs(void);
|
|
|
|
void NormalForceTo(Quaternion q);
|
|
|
|
|
2008-05-05 11:17:00 +00:00
|
|
|
Vector NormalU(void);
|
|
|
|
Vector NormalV(void);
|
|
|
|
Vector NormalN(void);
|
|
|
|
ExprVector NormalExprsU(void);
|
|
|
|
ExprVector NormalExprsV(void);
|
|
|
|
ExprVector NormalExprsN(void);
|
2008-04-19 11:09:47 +00:00
|
|
|
|
2009-10-21 04:46:01 +00:00
|
|
|
Vector CubicGetStartNum(void);
|
|
|
|
Vector CubicGetFinishNum(void);
|
|
|
|
ExprVector CubicGetStartTangentExprs(void);
|
|
|
|
ExprVector CubicGetFinishTangentExprs(void);
|
2010-05-10 04:14:06 +00:00
|
|
|
Vector CubicGetStartTangentNum(void);
|
|
|
|
Vector CubicGetFinishTangentNum(void);
|
2009-10-21 04:46:01 +00:00
|
|
|
|
2009-11-03 18:54:49 +00:00
|
|
|
bool HasEndpoints(void);
|
|
|
|
Vector EndpointStart();
|
|
|
|
Vector EndpointFinish();
|
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
|
|
|
void GenerateEquations(IdList<Equation,hEquation> *l);
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void) {}
|
2009-04-19 04:28:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Entity : public EntityBase {
|
|
|
|
public:
|
|
|
|
// An imported entity that was hidden in the source file ends up hidden
|
|
|
|
// here too.
|
|
|
|
bool forceHidden;
|
|
|
|
|
|
|
|
// All points/normals/distances have their numerical value; this is
|
|
|
|
// a convenience, to simplify the import/assembly code, so that the
|
|
|
|
// part is entirely described by the entities.
|
|
|
|
Vector actPoint;
|
|
|
|
Quaternion actNormal;
|
|
|
|
double actDistance;
|
|
|
|
// and the shown state also gets saved here, for later import
|
|
|
|
bool actVisible;
|
|
|
|
|
2009-07-20 01:47:59 +00:00
|
|
|
hStyle style;
|
2009-04-19 04:28:21 +00:00
|
|
|
bool construction;
|
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
// Routines to draw and hit-test the representation of the entity
|
|
|
|
// on-screen.
|
2008-04-12 14:12:26 +00:00
|
|
|
struct {
|
2008-04-25 07:04:09 +00:00
|
|
|
bool drawing;
|
|
|
|
Point2d mp;
|
|
|
|
double dmin;
|
2008-05-26 09:56:50 +00:00
|
|
|
Vector refp;
|
2009-09-18 08:14:15 +00:00
|
|
|
double lineWidth;
|
2008-04-25 07:04:09 +00:00
|
|
|
} dogd; // state for drawing or getting distance (for hit testing)
|
2009-09-18 08:14:15 +00:00
|
|
|
void LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat=false);
|
2008-06-06 07:50:08 +00:00
|
|
|
void DrawOrGetDistance(void);
|
2008-04-25 07:04:09 +00:00
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
bool IsVisible(void);
|
2009-04-20 07:30:09 +00:00
|
|
|
bool PointIsFromReferences(void);
|
2009-04-19 04:28:21 +00:00
|
|
|
|
2009-10-21 04:46:01 +00:00
|
|
|
void ComputeInterpolatingSpline(SBezierList *sbl, bool periodic);
|
2009-01-19 03:51:00 +00:00
|
|
|
void GenerateBezierCurves(SBezierList *sbl);
|
2009-01-15 03:55:42 +00:00
|
|
|
void GenerateEdges(SEdgeList *el, bool includingConstruction=false);
|
2008-07-10 05:26:08 +00:00
|
|
|
|
2008-06-06 07:50:08 +00:00
|
|
|
static void DrawAll(void);
|
|
|
|
void Draw(void);
|
2008-04-12 14:12:26 +00:00
|
|
|
double GetDistance(Point2d mp);
|
2008-05-26 09:56:50 +00:00
|
|
|
Vector GetReferencePos(void);
|
2008-04-19 11:09:47 +00:00
|
|
|
|
2008-06-13 04:41:27 +00:00
|
|
|
void CalculateNumerical(bool forExport);
|
2008-05-29 10:10:12 +00:00
|
|
|
|
2008-04-19 11:09:47 +00:00
|
|
|
char *DescriptionString(void);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2009-10-22 14:02:08 +00:00
|
|
|
class EntReqTable {
|
|
|
|
public:
|
|
|
|
typedef struct {
|
2013-08-26 18:58:35 +00:00
|
|
|
int reqType;
|
|
|
|
int entType;
|
|
|
|
int points;
|
|
|
|
bool useExtraPoints;
|
|
|
|
bool hasNormal;
|
|
|
|
bool hasDistance;
|
|
|
|
const char *description;
|
2009-10-22 14:02:08 +00:00
|
|
|
} TableEntry;
|
|
|
|
|
|
|
|
static const TableEntry Table[];
|
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
static const char *DescriptionForRequest(int req);
|
2009-10-22 14:02:08 +00:00
|
|
|
static void CopyEntityInfo(const TableEntry *te, int extraPoints,
|
|
|
|
int *ent, int *req, int *pts, bool *hasNormal, bool *hasDistance);
|
2009-12-04 08:08:41 +00:00
|
|
|
static bool GetRequestInfo(int req, int extraPoints,
|
2009-10-22 14:02:08 +00:00
|
|
|
int *ent, int *pts, bool *hasNormal, bool *hasDistance);
|
2009-12-04 08:08:41 +00:00
|
|
|
static bool GetEntityInfo(int ent, int extraPoints,
|
2009-10-22 14:02:08 +00:00
|
|
|
int *req, int *pts, bool *hasNormal, bool *hasDistance);
|
|
|
|
static int GetRequestForEntity(int ent);
|
|
|
|
};
|
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
class Param {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2008-04-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-09 08:39:01 +00:00
|
|
|
hParam h;
|
2008-04-18 07:21:17 +00:00
|
|
|
|
2008-04-09 08:39:01 +00:00
|
|
|
double val;
|
|
|
|
bool known;
|
2009-01-04 12:01:46 +00:00
|
|
|
bool free;
|
2008-05-07 07:10:20 +00:00
|
|
|
|
|
|
|
// Used only in the solver
|
|
|
|
hParam substd;
|
2008-05-11 06:09:46 +00:00
|
|
|
|
|
|
|
static const hParam NO_PARAM;
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void) {}
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
class hConstraint {
|
|
|
|
public:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t v;
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-05-11 06:09:46 +00:00
|
|
|
inline hEquation equation(int i);
|
2008-04-14 10:28:32 +00:00
|
|
|
};
|
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
class ConstraintBase {
|
2008-04-14 10:28:32 +00:00
|
|
|
public:
|
2009-04-19 04:28:21 +00:00
|
|
|
int tag;
|
|
|
|
hConstraint h;
|
|
|
|
|
2008-05-26 09:56:50 +00:00
|
|
|
static const hConstraint NO_CONSTRAINT;
|
|
|
|
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
POINTS_COINCIDENT = 20,
|
|
|
|
PT_PT_DISTANCE = 30,
|
|
|
|
PT_PLANE_DISTANCE = 31,
|
|
|
|
PT_LINE_DISTANCE = 32,
|
|
|
|
PT_FACE_DISTANCE = 33,
|
|
|
|
PROJ_PT_DISTANCE = 34,
|
|
|
|
PT_IN_PLANE = 41,
|
|
|
|
PT_ON_LINE = 42,
|
|
|
|
PT_ON_FACE = 43,
|
|
|
|
EQUAL_LENGTH_LINES = 50,
|
|
|
|
LENGTH_RATIO = 51,
|
|
|
|
EQ_LEN_PT_LINE_D = 52,
|
|
|
|
EQ_PT_LN_DISTANCES = 53,
|
|
|
|
EQUAL_ANGLE = 54,
|
|
|
|
EQUAL_LINE_ARC_LEN = 55,
|
|
|
|
SYMMETRIC = 60,
|
|
|
|
SYMMETRIC_HORIZ = 61,
|
|
|
|
SYMMETRIC_VERT = 62,
|
|
|
|
SYMMETRIC_LINE = 63,
|
|
|
|
AT_MIDPOINT = 70,
|
|
|
|
HORIZONTAL = 80,
|
|
|
|
VERTICAL = 81,
|
|
|
|
DIAMETER = 90,
|
|
|
|
PT_ON_CIRCLE = 100,
|
|
|
|
SAME_ORIENTATION = 110,
|
|
|
|
ANGLE = 120,
|
|
|
|
PARALLEL = 121,
|
|
|
|
PERPENDICULAR = 122,
|
|
|
|
ARC_LINE_TANGENT = 123,
|
|
|
|
CUBIC_LINE_TANGENT = 124,
|
|
|
|
CURVE_CURVE_TANGENT = 125,
|
|
|
|
EQUAL_RADIUS = 130,
|
|
|
|
WHERE_DRAGGED = 200,
|
|
|
|
|
|
|
|
COMMENT = 1000
|
|
|
|
};
|
2008-06-12 08:58:58 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
int type;
|
2008-04-27 03:26:27 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
hGroup group;
|
2008-04-27 03:26:27 +00:00
|
|
|
hEntity workplane;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
|
|
|
// These are the parameters for the constraint.
|
2008-06-14 08:43:38 +00:00
|
|
|
double valA;
|
2008-04-19 11:09:47 +00:00
|
|
|
hEntity ptA;
|
|
|
|
hEntity ptB;
|
2008-04-14 10:28:32 +00:00
|
|
|
hEntity entityA;
|
|
|
|
hEntity entityB;
|
2008-07-20 12:24:43 +00:00
|
|
|
hEntity entityC;
|
|
|
|
hEntity entityD;
|
2008-07-13 12:44:05 +00:00
|
|
|
bool other;
|
2010-05-10 04:14:06 +00:00
|
|
|
bool other2;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
bool reference; // a ref dimension, that generates no eqs
|
|
|
|
NameStr comment; // since comments are represented as constraints
|
2008-06-09 09:03:21 +00:00
|
|
|
|
2010-05-10 01:06:09 +00:00
|
|
|
bool HasLabel(void);
|
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
void Generate(IdList<Equation,hEquation> *l);
|
|
|
|
void GenerateReal(IdList<Equation,hEquation> *l);
|
|
|
|
// Some helpers when generating symbolic constraint equations
|
|
|
|
void ModifyToSatisfy(void);
|
|
|
|
void AddEq(IdList<Equation,hEquation> *l, Expr *expr, int index);
|
|
|
|
static Expr *DirectionCosine(hEntity wrkpl, ExprVector ae, ExprVector be);
|
|
|
|
static Expr *Distance(hEntity workplane, hEntity pa, hEntity pb);
|
|
|
|
static Expr *PointLineDistance(hEntity workplane, hEntity pt, hEntity ln);
|
|
|
|
static Expr *PointPlaneDistance(ExprVector p, hEntity plane);
|
|
|
|
static Expr *VectorsParallel(int eq, ExprVector a, ExprVector b);
|
|
|
|
static ExprVector PointInThreeSpace(hEntity workplane, Expr *u, Expr *v);
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void) {}
|
2009-04-19 04:28:21 +00:00
|
|
|
};
|
2008-06-12 08:58:58 +00:00
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
class Constraint : public ConstraintBase {
|
|
|
|
public:
|
2008-04-14 10:28:32 +00:00
|
|
|
// These define how the constraint is drawn on-screen.
|
|
|
|
struct {
|
|
|
|
Vector offset;
|
2009-07-20 01:47:59 +00:00
|
|
|
hStyle style;
|
2008-04-14 10:28:32 +00:00
|
|
|
} disp;
|
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
// State for drawing or getting distance (for hit testing).
|
2008-04-14 10:28:32 +00:00
|
|
|
struct {
|
2008-04-25 07:04:09 +00:00
|
|
|
bool drawing;
|
|
|
|
Point2d mp;
|
|
|
|
double dmin;
|
2008-05-26 09:56:50 +00:00
|
|
|
Vector refp;
|
2009-07-03 20:55:57 +00:00
|
|
|
SEdgeList *sel;
|
2009-04-19 04:28:21 +00:00
|
|
|
} dogd;
|
|
|
|
|
|
|
|
double GetDistance(Point2d mp);
|
|
|
|
Vector GetLabelPos(void);
|
|
|
|
Vector GetReferencePos(void);
|
|
|
|
void Draw(void);
|
2009-07-03 20:55:57 +00:00
|
|
|
void GetEdges(SEdgeList *sel);
|
2009-04-19 04:28:21 +00:00
|
|
|
|
2008-04-21 08:16:38 +00:00
|
|
|
void LineDrawOrGetDistance(Vector a, Vector b);
|
2008-04-21 10:12:04 +00:00
|
|
|
void DrawOrGetDistance(Vector *labelPos);
|
2008-05-07 08:19:37 +00:00
|
|
|
double EllipticalInterpolation(double rx, double ry, double theta);
|
2008-06-11 04:22:52 +00:00
|
|
|
char *Label(void);
|
2008-07-20 12:24:43 +00:00
|
|
|
void DoArcForAngle(Vector a0, Vector da, Vector b0, Vector db,
|
|
|
|
Vector offset, Vector *ref);
|
2009-09-03 08:13:09 +00:00
|
|
|
void DoLineWithArrows(Vector ref, Vector a, Vector b, bool onlyOneExt);
|
|
|
|
int DoLineTrimmedAgainstBox(Vector ref, Vector a, Vector b);
|
2008-05-07 08:19:37 +00:00
|
|
|
void DoLabel(Vector ref, Vector *labelPos, Vector gr, Vector gu);
|
2010-01-27 18:15:06 +00:00
|
|
|
void StippledLine(Vector a, Vector b);
|
2008-05-08 07:30:30 +00:00
|
|
|
void DoProjectedPoint(Vector *p);
|
2008-06-14 11:16:14 +00:00
|
|
|
void DoEqualLenTicks(Vector a, Vector b, Vector gn);
|
2009-01-08 17:22:59 +00:00
|
|
|
void DoEqualRadiusTicks(hEntity he);
|
2008-04-21 10:12:04 +00:00
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
char *DescriptionString(void);
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2009-04-19 04:28:21 +00:00
|
|
|
static void AddConstraint(Constraint *c, bool rememberForUndo);
|
|
|
|
static void AddConstraint(Constraint *c);
|
|
|
|
static void MenuConstrain(int id);
|
|
|
|
static void DeleteAllConstraintsFor(int type, hEntity entityA, hEntity ptA);
|
2008-04-23 07:29:19 +00:00
|
|
|
|
|
|
|
static void ConstrainCoincident(hEntity ptA, hEntity ptB);
|
2008-05-08 07:30:30 +00:00
|
|
|
static void Constrain(int type, hEntity ptA, hEntity ptB, hEntity entityA);
|
2008-07-14 02:45:11 +00:00
|
|
|
static void Constrain(int type, hEntity ptA, hEntity ptB,
|
|
|
|
hEntity entityA, hEntity entityB,
|
2010-05-16 16:36:23 +00:00
|
|
|
bool other, bool other2);
|
2008-04-14 10:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class hEquation {
|
|
|
|
public:
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
uint32_t v;
|
2008-09-05 11:25:53 +00:00
|
|
|
|
|
|
|
inline bool isFromConstraint(void);
|
|
|
|
inline hConstraint constraint(void);
|
2008-04-14 10:28:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Equation {
|
|
|
|
public:
|
2008-04-18 07:21:17 +00:00
|
|
|
int tag;
|
2008-04-14 10:28:32 +00:00
|
|
|
hEquation h;
|
2008-04-18 07:21:17 +00:00
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
Expr *e;
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void) {}
|
2008-04-14 10:28:32 +00:00
|
|
|
};
|
|
|
|
|
2008-05-08 07:30:30 +00:00
|
|
|
|
2009-07-20 01:47:59 +00:00
|
|
|
class Style {
|
2009-09-17 07:32:36 +00:00
|
|
|
public:
|
2009-07-20 01:47:59 +00:00
|
|
|
int tag;
|
|
|
|
hStyle h;
|
2013-09-09 19:50:32 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
// 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.
|
|
|
|
NO_STYLE = 0,
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
2009-07-20 01:47:59 +00:00
|
|
|
|
2009-09-17 07:32:36 +00:00
|
|
|
NameStr name;
|
|
|
|
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
UNITS_AS_PIXELS = 0,
|
|
|
|
UNITS_AS_MM = 1
|
|
|
|
};
|
2009-07-20 01:47:59 +00:00
|
|
|
double width;
|
2009-09-24 15:52:48 +00:00
|
|
|
int widthAs;
|
|
|
|
double textHeight;
|
|
|
|
int textHeightAs;
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
ORIGIN_LEFT = 0x01,
|
|
|
|
ORIGIN_RIGHT = 0x02,
|
|
|
|
ORIGIN_BOT = 0x04,
|
|
|
|
ORIGIN_TOP = 0x08
|
|
|
|
};
|
2009-09-24 15:52:48 +00:00
|
|
|
int textOrigin;
|
2009-09-29 11:35:19 +00:00
|
|
|
double textAngle;
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
RgbColor color;
|
2009-10-22 17:16:20 +00:00
|
|
|
bool filled;
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
RgbColor fillColor;
|
2009-07-20 01:47:59 +00:00
|
|
|
bool visible;
|
|
|
|
bool exportable;
|
2009-09-17 07:32:36 +00:00
|
|
|
|
|
|
|
// The default styles, for entities that don't have a style assigned yet,
|
|
|
|
// and for datums and such.
|
|
|
|
typedef struct {
|
2013-08-26 18:58:35 +00:00
|
|
|
hStyle h;
|
|
|
|
const char *cnfPrefix;
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
RgbColor color;
|
2013-08-26 18:58:35 +00:00
|
|
|
double width;
|
2009-09-17 07:32:36 +00:00
|
|
|
} Default;
|
|
|
|
static const Default Defaults[];
|
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
static char *CnfColor(const char *prefix);
|
|
|
|
static char *CnfWidth(const char *prefix);
|
|
|
|
static char *CnfPrefixToName(const char *prefix);
|
2009-09-18 08:14:15 +00:00
|
|
|
|
|
|
|
static void CreateAllDefaultStyles(void);
|
2009-09-17 07:32:36 +00:00
|
|
|
static void CreateDefaultStyle(hStyle h);
|
|
|
|
static void FreezeDefaultStyles(void);
|
|
|
|
static void LoadFactoryDefaults(void);
|
|
|
|
|
Use C99 integer types and C++ boolean types/values
This change comprehensively replaces the use of Microsoft-standard integer
and boolean types with their C99/C++ standard equivalents, as the latter is
more appropriate for a cross-platform application. With matter-of-course
exceptions in the Win32-specific code, the types/values have been converted
as follows:
QWORD --> uint64_t
SQWORD --> int64_t
DWORD --> uint32_t
SDWORD --> int32_t
WORD --> uint16_t
SWORD --> int16_t
BYTE --> uint8_t
BOOL --> bool
TRUE --> true
FALSE --> false
The following related changes are also included:
* Added C99 integer type definitions for Windows, as stdint.h is not
available prior to Visual Studio 2010
* Changed types of some variables in the SolveSpace class from 'int' to
'bool', as they actually represent boolean settings
* Implemented new Cnf{Freeze,Thaw}Bool() functions to support boolean
variables in the Registry
* Cnf{Freeze,Thaw}DWORD() are now Cnf{Freeze,Thaw}Int()
* TtfFont::Get{WORD,DWORD}() are now TtfFont::Get{USHORT,ULONG}() (names
inspired by the OpenType spec)
* RGB colors are packed into an integer of type uint32_t (nee DWORD), but
in a few places, these were represented by an int; these have been
corrected to uint32_t
2013-10-02 05:45:13 +00:00
|
|
|
static void AssignSelectionToStyle(uint32_t v);
|
|
|
|
static uint32_t CreateCustomStyle(void);
|
2009-09-23 10:59:59 +00:00
|
|
|
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
static RgbColor RewriteColor(RgbColor rgb);
|
2010-08-14 19:00:25 +00:00
|
|
|
|
2009-09-17 07:32:36 +00:00
|
|
|
static Style *Get(hStyle hs);
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
static RgbColor Color(hStyle hs, bool forExport=false);
|
|
|
|
static RgbColor FillColor(hStyle hs, bool forExport=false);
|
2009-09-17 07:32:36 +00:00
|
|
|
static float Width(hStyle hs);
|
Replaced RGB-color integers with dedicated data structure
RGB colors were represented using a uint32_t with the red, green and blue
values stuffed into the lower three octets (i.e. 0x00BBGGRR), like
Microsoft's COLORREF. This approach did not lend itself to type safety,
however, so this change replaces it with an RgbColor class that provides
the same infomation plus a handful of useful methods to work with it. (Note
that sizeof(RgbColor) == sizeof(uint32_t), so this change should not lead
to memory bloat.)
Some of the new methods/fields replace what were previously macro calls;
e.g. RED(c) is now c.red, REDf(c) is now c.redF(). The .Equals() method is
now used instead of == to compare colors.
RGB colors still need to be represented as packed integers in file I/O and
preferences, so the methods .FromPackedInt() and .ToPackedInt() are
provided. Also implemented are Cnf{Freeze,Thaw}Color(), type-safe wrappers
around Cnf{Freeze,Thaw}Int() that facilitate I/O with preferences.
(Cnf{Freeze,Thaw}Color() are defined outside of the system-dependent code
to minimize the footprint of the latter; because the same can be done with
Cnf{Freeze,Thaw}Bool(), those are also moved out of the system code with
this commit.)
Color integers were being OR'ed with 0x80000000 in some places for two
distinct purposes: One, to indicate use of a default color in
glxFillMesh(); this has been replaced by use of the .UseDefault() method.
Two, to indicate to TextWindow::Printf() that the format argument of a
"%Bp"/"%Fp" specifier is an RGB color rather than a color "code" from
TextWindow::bgColors[] or TextWindow::fgColors[] (as the specifier can
accept either); instead, we define a new flag "z" (as in "%Bz" or "%Fz") to
indicate an RGBcolor pointer, leaving "%Bp"/"%Fp" to indicate a color code
exclusively.
(This also allows TextWindow::meta[][].bg to be a char instead of an int,
partly compensating for the new .bgRgb field added immediately after.)
In array declarations, RGB colors could previously be specified as 0 (often
in a terminating element). As that no longer works, we define NULL_COLOR,
which serves much the same purpose for RgbColor variables as NULL serves
for pointers.
2013-10-16 20:00:58 +00:00
|
|
|
static RgbColor Color(int hs, bool forExport=false);
|
2009-09-17 07:32:36 +00:00
|
|
|
static float Width(int hs);
|
2009-09-22 05:46:30 +00:00
|
|
|
static double WidthMm(int hs);
|
2009-09-24 15:52:48 +00:00
|
|
|
static double TextHeight(hStyle hs);
|
2009-09-22 05:46:30 +00:00
|
|
|
static bool Exportable(int hs);
|
2009-09-17 07:32:36 +00:00
|
|
|
static hStyle ForEntity(hEntity he);
|
2009-09-18 08:14:15 +00:00
|
|
|
|
|
|
|
char *DescriptionString(void);
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void) {}
|
2009-07-20 01:47:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-08 07:30:30 +00:00
|
|
|
inline hEntity hGroup::entity(int i)
|
2013-10-19 05:36:45 +00:00
|
|
|
{ hEntity r; r.v = 0x80000000 | (v << 16) | (uint32_t)i; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
inline hParam hGroup::param(int i)
|
2013-10-19 05:36:45 +00:00
|
|
|
{ hParam r; r.v = 0x80000000 | (v << 16) | (uint32_t)i; return r; }
|
2008-05-11 06:09:46 +00:00
|
|
|
inline hEquation hGroup::equation(int i)
|
2013-10-19 05:36:45 +00:00
|
|
|
{ hEquation r; r.v = (v << 16) | 0x80000000 | (uint32_t)i; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
|
|
|
|
inline bool hRequest::IsFromReferences(void) {
|
|
|
|
if(v == Request::HREQUEST_REFERENCE_XY.v) return true;
|
|
|
|
if(v == Request::HREQUEST_REFERENCE_YZ.v) return true;
|
|
|
|
if(v == Request::HREQUEST_REFERENCE_ZX.v) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
inline hEntity hRequest::entity(int i)
|
2013-10-19 05:36:45 +00:00
|
|
|
{ hEntity r; r.v = (v << 16) | (uint32_t)i; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
inline hParam hRequest::param(int i)
|
2013-10-19 05:36:45 +00:00
|
|
|
{ hParam r; r.v = (v << 16) | (uint32_t)i; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
|
|
|
|
inline bool hEntity::isFromRequest(void)
|
|
|
|
{ if(v & 0x80000000) return false; else return true; }
|
|
|
|
inline hRequest hEntity::request(void)
|
|
|
|
{ hRequest r; r.v = (v >> 16); return r; }
|
2008-05-11 10:40:37 +00:00
|
|
|
inline hGroup hEntity::group(void)
|
|
|
|
{ hGroup r; r.v = (v >> 16) & 0x3fff; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
inline hEquation hEntity::equation(int i)
|
2008-05-11 06:09:46 +00:00
|
|
|
{ if(i != 0) oops(); hEquation r; r.v = v | 0x40000000; return r; }
|
2008-05-08 07:30:30 +00:00
|
|
|
|
|
|
|
inline hRequest hParam::request(void)
|
|
|
|
{ hRequest r; r.v = (v >> 16); return r; }
|
|
|
|
|
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
inline hEquation hConstraint::equation(int i)
|
2013-10-19 05:36:45 +00:00
|
|
|
{ hEquation r; r.v = (v << 16) | (uint32_t)i; return r; }
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-09-05 11:25:53 +00:00
|
|
|
inline bool hEquation::isFromConstraint(void)
|
|
|
|
{ if(v & 0xc0000000) return false; else return true; }
|
|
|
|
inline hConstraint hEquation::constraint(void)
|
|
|
|
{ hConstraint r; r.v = (v >> 16); return r; }
|
|
|
|
|
2009-12-03 19:14:34 +00:00
|
|
|
// The format for entities stored on the clipboard.
|
2009-12-04 08:08:41 +00:00
|
|
|
class ClipboardRequest {
|
2009-12-03 19:14:34 +00:00
|
|
|
public:
|
|
|
|
int type;
|
|
|
|
int extraPoints;
|
|
|
|
hStyle style;
|
|
|
|
NameStr str;
|
|
|
|
NameStr font;
|
|
|
|
bool construction;
|
2009-12-04 08:08:41 +00:00
|
|
|
|
|
|
|
Vector point[MAX_POINTS_IN_ENTITY];
|
|
|
|
double distance;
|
|
|
|
|
|
|
|
hEntity oldEnt;
|
|
|
|
hEntity oldPointEnt[MAX_POINTS_IN_ENTITY];
|
|
|
|
hRequest newReq;
|
2009-12-03 19:14:34 +00:00
|
|
|
};
|
2008-04-13 10:57:41 +00:00
|
|
|
|
2008-04-08 12:54:53 +00:00
|
|
|
#endif
|