2013-07-28 22:08:34 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// All declarations not grouped specially elsewhere.
|
|
|
|
//
|
|
|
|
// Copyright 2008-2013 Jonathan Westhues.
|
|
|
|
//-----------------------------------------------------------------------------
|
2008-03-25 10:02:13 +00:00
|
|
|
|
|
|
|
#ifndef __SOLVESPACE_H
|
|
|
|
#define __SOLVESPACE_H
|
|
|
|
|
2015-03-29 00:33:46 +00:00
|
|
|
#include <config.h>
|
2013-10-25 05:04:16 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
2015-03-23 17:49:04 +00:00
|
|
|
#include <stddef.h>
|
2013-10-25 05:04:16 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#ifdef HAVE_STDINT_H
|
|
|
|
# include <stdint.h>
|
|
|
|
#endif
|
|
|
|
#ifdef WIN32
|
|
|
|
# include <windows.h> // required by GL headers
|
|
|
|
#endif
|
2015-03-17 16:14:47 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
# include <OpenGL/gl.h>
|
|
|
|
# include <OpenGL/glu.h>
|
|
|
|
#else
|
|
|
|
# include <GL/gl.h>
|
|
|
|
# include <GL/glu.h>
|
|
|
|
#endif
|
2013-10-25 05:04:16 +00:00
|
|
|
|
2013-10-21 21:29:25 +00:00
|
|
|
// The few floating-point equality comparisons in SolveSpace have been
|
|
|
|
// carefully considered, so we disable the -Wfloat-equal warning for them
|
|
|
|
#ifdef __clang__
|
|
|
|
# define EXACT(expr) \
|
|
|
|
(_Pragma("clang diagnostic push") \
|
|
|
|
_Pragma("clang diagnostic ignored \"-Wfloat-equal\"") \
|
|
|
|
(expr) \
|
|
|
|
_Pragma("clang diagnostic pop"))
|
|
|
|
#else
|
|
|
|
# define EXACT(expr) (expr)
|
|
|
|
#endif
|
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
// Debugging functions
|
2015-03-17 16:17:51 +00:00
|
|
|
#ifdef NDEBUG
|
2013-09-19 06:35:56 +00:00
|
|
|
#define oops() do { dbp("oops at line %d, file %s\n", __LINE__, __FILE__); \
|
2015-03-17 16:17:51 +00:00
|
|
|
exit(-1); } while(0)
|
|
|
|
#else
|
|
|
|
#define oops() do { dbp("oops at line %d, file %s\n", __LINE__, __FILE__); \
|
|
|
|
abort(); } while(0)
|
|
|
|
#endif
|
2013-10-25 05:04:16 +00:00
|
|
|
|
2008-03-28 10:00:37 +00:00
|
|
|
#ifndef min
|
2013-10-19 05:36:45 +00:00
|
|
|
# define min(x, y) ((x) < (y) ? (x) : (y))
|
2008-03-28 10:00:37 +00:00
|
|
|
#endif
|
|
|
|
#ifndef max
|
2013-10-19 05:36:45 +00:00
|
|
|
# define max(x, y) ((x) > (y) ? (x) : (y))
|
2008-03-28 10:00:37 +00:00
|
|
|
#endif
|
|
|
|
|
2013-10-19 05:36:45 +00:00
|
|
|
#ifndef isnan
|
|
|
|
# define isnan(x) (((x) != (x)) || (x > 1e11) || (x < -1e11))
|
|
|
|
#endif
|
2008-06-03 18:28:41 +00:00
|
|
|
|
2015-03-23 17:49:04 +00:00
|
|
|
namespace SolveSpace {
|
|
|
|
|
2008-05-26 03:39:45 +00:00
|
|
|
inline int WRAP(int v, int n) {
|
2009-01-03 12:27:33 +00:00
|
|
|
// Clamp it to the range [0, n)
|
2008-05-26 03:39:45 +00:00
|
|
|
while(v >= n) v -= n;
|
|
|
|
while(v < 0) v += n;
|
|
|
|
return v;
|
|
|
|
}
|
2009-01-03 12:27:33 +00:00
|
|
|
inline double WRAP_NOT_0(double v, double n) {
|
|
|
|
// Clamp it to the range (0, n]
|
|
|
|
while(v > n) v -= n;
|
|
|
|
while(v <= 0) v += n;
|
|
|
|
return v;
|
|
|
|
}
|
2009-03-19 17:40:11 +00:00
|
|
|
inline double WRAP_SYMMETRIC(double v, double n) {
|
|
|
|
// Clamp it to the range (-n/2, n/2]
|
|
|
|
while(v > n/2) v -= n;
|
|
|
|
while(v <= -n/2) v += n;
|
|
|
|
return v;
|
|
|
|
}
|
2009-01-03 12:27:33 +00:00
|
|
|
|
2009-10-21 04:46:01 +00:00
|
|
|
// Why is this faster than the library function?
|
|
|
|
inline double ffabs(double v) { return (v > 0) ? v : (-v); }
|
|
|
|
|
2008-05-11 10:40:37 +00:00
|
|
|
#define SWAP(T, a, b) do { T temp = (a); (a) = (b); (b) = temp; } while(0)
|
2008-05-19 09:23:49 +00:00
|
|
|
#define ZERO(v) memset((v), 0, sizeof(*(v)))
|
2008-05-22 10:28:28 +00:00
|
|
|
#define CO(v) (v).x, (v).y, (v).z
|
|
|
|
|
2009-03-08 10:59:57 +00:00
|
|
|
#define LENGTH_EPS (1e-6)
|
2009-01-27 05:48:40 +00:00
|
|
|
#define VERY_POSITIVE (1e10)
|
|
|
|
#define VERY_NEGATIVE (-1e10)
|
2008-05-11 10:40:37 +00:00
|
|
|
|
2008-04-17 06:42:32 +00:00
|
|
|
#define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#')
|
|
|
|
|
2015-03-29 00:33:46 +00:00
|
|
|
#if defined(WIN32) && !defined(HAVE_STDINT_H)
|
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
|
|
|
// Define some useful C99 integer types.
|
|
|
|
typedef UINT64 uint64_t;
|
|
|
|
typedef INT64 int64_t;
|
|
|
|
typedef UINT32 uint32_t;
|
|
|
|
typedef INT32 int32_t;
|
|
|
|
typedef USHORT uint16_t;
|
|
|
|
typedef SHORT int16_t;
|
|
|
|
typedef UCHAR uint8_t;
|
|
|
|
typedef CHAR int8_t;
|
|
|
|
#endif
|
2008-04-01 10:48:44 +00:00
|
|
|
|
2009-02-09 12:40:48 +00:00
|
|
|
inline double Random(double vmax) {
|
|
|
|
return (vmax*rand()) / RAND_MAX;
|
|
|
|
}
|
|
|
|
|
2008-04-14 10:28:32 +00:00
|
|
|
class Expr;
|
2008-04-22 13:14:15 +00:00
|
|
|
class ExprVector;
|
2008-05-05 06:18:01 +00:00
|
|
|
class ExprQuaternion;
|
2015-07-10 11:54:39 +00:00
|
|
|
class RgbaColor;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2013-11-13 07:26:18 +00:00
|
|
|
#ifndef MAX_PATH
|
|
|
|
# define MAX_PATH PATH_MAX
|
|
|
|
#endif
|
2008-05-29 10:10:12 +00:00
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
//================
|
2008-04-14 10:28:32 +00:00
|
|
|
// From the platform-specific code.
|
2008-05-28 10:10:31 +00:00
|
|
|
#define MAX_RECENT 8
|
|
|
|
#define RECENT_OPEN (0xf000)
|
|
|
|
#define RECENT_IMPORT (0xf100)
|
|
|
|
extern char RecentFile[MAX_RECENT][MAX_PATH];
|
|
|
|
void RefreshRecentMenus(void);
|
|
|
|
|
2013-09-18 20:49:32 +00:00
|
|
|
#define SAVE_YES (1)
|
|
|
|
#define SAVE_NO (-1)
|
|
|
|
#define SAVE_CANCEL (0)
|
2008-04-18 11:11:48 +00:00
|
|
|
int SaveFileYesNoCancel(void);
|
2015-03-29 04:46:57 +00:00
|
|
|
int LoadAutosaveYesNo(void);
|
|
|
|
|
|
|
|
#define AUTOSAVE_SUFFIX "~"
|
2013-09-18 20:49:32 +00:00
|
|
|
|
2015-03-24 23:38:06 +00:00
|
|
|
#if defined(HAVE_GTK)
|
2015-03-18 17:02:11 +00:00
|
|
|
// Selection pattern format to be parsed by GTK3 glue code:
|
|
|
|
// "PNG File\t*.png\n"
|
|
|
|
// "JPEG File\t*.jpg\t*.jpeg\n"
|
|
|
|
// "All Files\t*"
|
|
|
|
# define PAT1(desc,e1) desc "\t*." e1 "\n"
|
|
|
|
# define PAT2(desc,e1,e2) desc "\t*." e1 "\t*." e2 "\n"
|
|
|
|
# define ENDPAT "All Files\t*"
|
2015-03-24 06:45:53 +00:00
|
|
|
#elif defined(__APPLE__)
|
|
|
|
// Selection pattern format to be parsed by Cocoa glue code:
|
|
|
|
// "PNG File\tpng\n"
|
|
|
|
// "JPEG file\tjpg,jpeg\n"
|
|
|
|
// "All Files\t*"
|
|
|
|
# define PAT1(desc,e1) desc "\t" e1 "\n"
|
|
|
|
# define PAT2(desc,e1,e2) desc "\t" e1 "," e2 "\n"
|
|
|
|
# define ENDPAT "All Files\t*"
|
2013-10-25 05:04:16 +00:00
|
|
|
#else
|
|
|
|
// Selection pattern format for Win32's OPENFILENAME.lpstrFilter:
|
|
|
|
// "PNG File (*.png)\0*.png\0"
|
|
|
|
// "JPEG File (*.jpg;*.jpeg)\0*.jpg;*.jpeg\0"
|
|
|
|
// "All Files (*)\0*\0\0"
|
|
|
|
# define PAT1(desc,e1) desc " (*." e1 ")\0*." e1 "\0"
|
|
|
|
# define PAT2(desc,e1,e2) desc " (*." e1 ";*." e2 ")\0*." e1 ";*." e2 "\0"
|
|
|
|
# define ENDPAT "All Files (*)\0*\0\0"
|
|
|
|
#endif
|
|
|
|
|
2009-10-12 10:40:48 +00:00
|
|
|
// SolveSpace native file format
|
2013-10-25 05:04:16 +00:00
|
|
|
#define SLVS_PATTERN PAT1("SolveSpace Models", "slvs") ENDPAT
|
2008-05-29 10:10:12 +00:00
|
|
|
#define SLVS_EXT "slvs"
|
2009-10-12 10:40:48 +00:00
|
|
|
// PNG format bitmap
|
2013-10-25 05:04:16 +00:00
|
|
|
#define PNG_PATTERN PAT1("PNG", "png") ENDPAT
|
2008-06-18 08:35:14 +00:00
|
|
|
#define PNG_EXT "png"
|
2009-10-12 10:40:48 +00:00
|
|
|
// Triangle mesh
|
2013-10-25 05:04:16 +00:00
|
|
|
#define MESH_PATTERN \
|
|
|
|
PAT1("STL Mesh", "stl") \
|
|
|
|
PAT1("Wavefront OBJ Mesh", "obj") \
|
|
|
|
ENDPAT
|
2009-10-12 11:34:43 +00:00
|
|
|
#define MESH_EXT "stl"
|
2009-10-12 10:40:48 +00:00
|
|
|
// NURBS surfaces
|
2013-10-25 05:04:16 +00:00
|
|
|
#define SRF_PATTERN PAT2("STEP File", "step", "stp") ENDPAT
|
2009-06-08 06:50:16 +00:00
|
|
|
#define SRF_EXT "step"
|
2009-10-12 10:40:48 +00:00
|
|
|
// 2d vector (lines and curves) format
|
2013-10-25 05:04:16 +00:00
|
|
|
#define VEC_PATTERN \
|
|
|
|
PAT1("PDF File", "pdf") \
|
|
|
|
PAT2("Encapsulated PostScript", "eps", "ps") \
|
|
|
|
PAT1("Scalable Vector Graphics", "svg") \
|
|
|
|
PAT2("STEP File", "step", "stp") \
|
|
|
|
PAT1("DXF File", "dxf") \
|
|
|
|
PAT2("HPGL File", "plt", "hpgl") \
|
|
|
|
PAT1("G Code", "txt") \
|
|
|
|
ENDPAT
|
2009-06-11 05:57:23 +00:00
|
|
|
#define VEC_EXT "pdf"
|
2009-10-12 10:40:48 +00:00
|
|
|
// 3d vector (wireframe lines and curves) format
|
2013-10-25 05:04:16 +00:00
|
|
|
#define V3D_PATTERN \
|
|
|
|
PAT2("STEP File", "step", "stp") \
|
|
|
|
PAT1("DXF File", "dxf") \
|
|
|
|
ENDPAT
|
2009-10-12 10:40:48 +00:00
|
|
|
#define V3D_EXT "step"
|
|
|
|
// Comma-separated value, like a spreadsheet would use
|
2013-10-25 05:04:16 +00:00
|
|
|
#define CSV_PATTERN PAT1("CSV File", "csv") ENDPAT
|
2008-07-20 11:27:22 +00:00
|
|
|
#define CSV_EXT "csv"
|
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 GetSaveFile(char *file, const char *defExtension, const char *selPattern);
|
|
|
|
bool GetOpenFile(char *file, const char *defExtension, const char *selPattern);
|
2008-06-25 05:14:49 +00:00
|
|
|
void GetAbsoluteFilename(char *file);
|
2008-06-30 09:09:17 +00:00
|
|
|
void LoadAllFontFiles(void);
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
void OpenWebsite(const char *url);
|
2008-02-09 13:52:01 +00:00
|
|
|
|
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
|
|
|
void CheckMenuById(int id, bool checked);
|
|
|
|
void RadioMenuById(int id, bool selected);
|
|
|
|
void EnableMenuById(int id, bool enabled);
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2008-04-21 10:12:04 +00:00
|
|
|
void ShowGraphicsEditControl(int x, int y, char *s);
|
|
|
|
void HideGraphicsEditControl(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
|
|
|
bool GraphicsEditControlIsVisible(void);
|
2010-07-12 07:51:12 +00:00
|
|
|
void ShowTextEditControl(int x, int y, char *s);
|
2008-05-27 06:36:59 +00:00
|
|
|
void HideTextEditControl(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
|
|
|
bool TextEditControlIsVisible(void);
|
2010-04-26 07:52:49 +00:00
|
|
|
void MoveTextScrollbarTo(int pos, int maxPos, int page);
|
2008-04-21 10:12:04 +00:00
|
|
|
|
2009-09-23 10:59:59 +00:00
|
|
|
#define CONTEXT_SUBMENU (-1)
|
|
|
|
#define CONTEXT_SEPARATOR (-2)
|
2013-08-26 18:58:35 +00:00
|
|
|
void AddContextMenuItem(const char *legend, int id);
|
2009-09-23 10:59:59 +00:00
|
|
|
void CreateContextSubmenu(void);
|
|
|
|
int ShowContextMenu(void);
|
|
|
|
|
2013-10-25 05:04:16 +00:00
|
|
|
void ToggleMenuBar(void);
|
|
|
|
bool MenuBarIsVisible(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
|
|
|
void ShowTextWindow(bool visible);
|
2008-04-14 10:28:32 +00:00
|
|
|
void InvalidateText(void);
|
2008-04-27 05:00:12 +00:00
|
|
|
void InvalidateGraphics(void);
|
2008-04-18 11:11:48 +00:00
|
|
|
void PaintGraphics(void);
|
2013-10-25 05:04:16 +00:00
|
|
|
void ToggleFullScreen(void);
|
|
|
|
bool FullScreenIsActive(void);
|
2008-06-12 07:31:41 +00:00
|
|
|
void GetGraphicsWindowSize(int *w, int *h);
|
2010-05-03 05:04:42 +00:00
|
|
|
void GetTextWindowSize(int *w, int *h);
|
2013-10-28 04:28:39 +00:00
|
|
|
int64_t GetMilliseconds(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
|
|
|
int64_t GetUnixTime(void);
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
void dbp(const char *str, ...);
|
2008-05-30 07:32:30 +00:00
|
|
|
#define DBPTRI(tri) \
|
|
|
|
dbp("tri: (%.3f %.3f %.3f) (%.3f %.3f %.3f) (%.3f %.3f %.3f)", \
|
|
|
|
CO((tri).a), CO((tri).b), CO((tri).c))
|
|
|
|
|
2015-03-24 06:45:53 +00:00
|
|
|
void SetCurrentFilename(const char *filename);
|
2010-04-26 07:52:49 +00:00
|
|
|
void SetMousePointerToHand(bool yes);
|
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
|
|
|
void DoMessageBox(const char *str, int rows, int cols, bool error);
|
2009-01-02 10:38:36 +00:00
|
|
|
void SetTimerFor(int milliseconds);
|
2015-03-29 04:46:57 +00:00
|
|
|
void SetAutosaveTimerFor(int minutes);
|
2015-03-18 17:02:11 +00:00
|
|
|
void ScheduleLater();
|
2008-06-03 18:48:47 +00:00
|
|
|
void ExitNow(void);
|
2008-07-08 08:02:22 +00:00
|
|
|
|
2013-08-26 18:58:35 +00:00
|
|
|
void CnfFreezeString(const char *str, const char *name);
|
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
|
|
|
void CnfFreezeInt(uint32_t v, const char *name);
|
2013-08-26 18:58:35 +00:00
|
|
|
void CnfFreezeFloat(float v, const char *name);
|
|
|
|
void CnfThawString(char *str, int maxLen, const char *name);
|
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 CnfThawInt(uint32_t v, const char *name);
|
2013-08-26 18:58:35 +00:00
|
|
|
float CnfThawFloat(float v, const char *name);
|
2008-04-18 11:11:48 +00:00
|
|
|
|
2013-08-26 20:40:25 +00:00
|
|
|
void *AllocTemporary(size_t n);
|
2008-07-13 12:58:52 +00:00
|
|
|
void FreeTemporary(void *p);
|
2008-04-25 10:11:29 +00:00
|
|
|
void FreeAllTemporary(void);
|
2013-08-26 20:40:25 +00:00
|
|
|
void *MemRealloc(void *p, size_t n);
|
|
|
|
void *MemAlloc(size_t n);
|
2008-04-18 07:06:37 +00:00
|
|
|
void MemFree(void *p);
|
2009-04-20 07:30:09 +00:00
|
|
|
void InitHeaps(void);
|
2008-06-30 09:09:17 +00:00
|
|
|
void vl(void); // debug function to validate heaps
|
|
|
|
|
|
|
|
// End of platform-specific functions
|
|
|
|
//================
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2009-05-24 11:37:07 +00:00
|
|
|
class Group;
|
2009-02-27 14:05:08 +00:00
|
|
|
class SSurface;
|
2008-03-25 10:02:13 +00:00
|
|
|
#include "dsc.h"
|
2008-04-23 07:29:19 +00:00
|
|
|
#include "polygon.h"
|
2009-01-15 03:55:42 +00:00
|
|
|
#include "srf/surface.h"
|
2008-05-29 10:10:12 +00:00
|
|
|
|
|
|
|
class Entity;
|
|
|
|
class hEntity;
|
2008-06-23 08:25:17 +00:00
|
|
|
class Param;
|
|
|
|
class hParam;
|
2008-05-29 10:10:12 +00:00
|
|
|
typedef IdList<Entity,hEntity> EntityList;
|
2008-06-23 08:25:17 +00:00
|
|
|
typedef IdList<Param,hParam> ParamList;
|
2008-05-29 10:10:12 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
#include "sketch.h"
|
2008-04-12 14:12:26 +00:00
|
|
|
#include "ui.h"
|
2008-04-08 12:54:53 +00:00
|
|
|
#include "expr.h"
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-04-11 11:13:47 +00:00
|
|
|
// Utility functions that are provided in the platform-independent code.
|
2015-03-22 13:39:12 +00:00
|
|
|
void ssglLineWidth(GLfloat width);
|
2013-10-22 04:45:06 +00:00
|
|
|
void ssglVertex3v(Vector u);
|
|
|
|
void ssglAxisAlignedQuad(double l, double r, double t, double b, bool lone = true);
|
|
|
|
void ssglAxisAlignedLineLoop(double l, double r, double t, double b);
|
2009-09-24 15:52:48 +00:00
|
|
|
#define DEFAULT_TEXT_HEIGHT (11.5)
|
2013-10-25 05:04:16 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
# define SSGL_CALLBACK __stdcall
|
|
|
|
#else
|
|
|
|
# define SSGL_CALLBACK
|
|
|
|
#endif
|
|
|
|
extern "C" { typedef void SSGL_CALLBACK ssglCallbackFptr(void); }
|
2013-10-22 04:45:06 +00:00
|
|
|
void ssglTesselatePolygon(GLUtesselator *gt, SPolygon *p);
|
|
|
|
void ssglFillPolygon(SPolygon *p);
|
2015-07-10 11:54:39 +00:00
|
|
|
void ssglFillMesh(bool useSpecColor, RgbaColor color,
|
2015-03-26 10:30:12 +00:00
|
|
|
SMesh *m, uint32_t h, uint32_t s1, uint32_t s2);
|
2013-10-22 04:45:06 +00:00
|
|
|
void ssglDebugPolygon(SPolygon *p);
|
|
|
|
void ssglDrawEdges(SEdgeList *l, bool endpointsToo);
|
|
|
|
void ssglDebugMesh(SMesh *m);
|
|
|
|
void ssglMarkPolygonNormal(SPolygon *p);
|
|
|
|
typedef void ssglLineFn(void *data, Vector a, Vector b);
|
|
|
|
void ssglWriteText(const char *str, double h, Vector t, Vector u, Vector v,
|
|
|
|
ssglLineFn *fn, void *fndata);
|
|
|
|
void ssglWriteTextRefCenter(const char *str, double h, Vector t, Vector u, Vector v,
|
|
|
|
ssglLineFn *fn, void *fndata);
|
|
|
|
double ssglStrWidth(const char *str, double h);
|
|
|
|
double ssglStrHeight(double h);
|
2015-07-10 11:54:39 +00:00
|
|
|
void ssglLockColorTo(RgbaColor rgb);
|
2013-10-22 04:45:06 +00:00
|
|
|
void ssglFatLine(Vector a, Vector b, double width);
|
|
|
|
void ssglUnlockColor(void);
|
2015-07-10 11:54:39 +00:00
|
|
|
void ssglColorRGB(RgbaColor rgb);
|
|
|
|
void ssglColorRGBa(RgbaColor rgb, double a);
|
2013-10-22 04:45:06 +00:00
|
|
|
void ssglDepthRangeOffset(int units);
|
|
|
|
void ssglDepthRangeLockToFront(bool yes);
|
|
|
|
void ssglDrawPixelsWithTexture(uint8_t *data, int w, int h);
|
|
|
|
void ssglCreateBitmapFont(void);
|
|
|
|
void ssglBitmapText(const char *str, Vector p);
|
|
|
|
void ssglBitmapCharQuad(char c, double x, double y);
|
2010-04-26 07:52:49 +00:00
|
|
|
#define TEXTURE_BACKGROUND_IMG 10
|
|
|
|
#define TEXTURE_BITMAP_FONT 20
|
2010-05-03 05:04:42 +00:00
|
|
|
#define TEXTURE_DRAW_PIXELS 30
|
2010-07-21 05:04:03 +00:00
|
|
|
#define TEXTURE_COLOR_PICKER_2D 40
|
|
|
|
#define TEXTURE_COLOR_PICKER_1D 50
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2008-03-26 09:18:12 +00:00
|
|
|
#define arraylen(x) (sizeof((x))/sizeof((x)[0]))
|
2008-03-27 09:53:51 +00:00
|
|
|
#define PI (3.1415926535897931)
|
|
|
|
void MakeMatrix(double *mat, double a11, double a12, double a13, double a14,
|
|
|
|
double a21, double a22, double a23, double a24,
|
|
|
|
double a31, double a32, double a33, double a34,
|
|
|
|
double a41, double a42, double a43, double a44);
|
2013-08-26 18:58:35 +00:00
|
|
|
void MakePathRelative(const char *base, char *path);
|
|
|
|
void MakePathAbsolute(const char *base, char *path);
|
2013-09-20 19:01:00 +00:00
|
|
|
bool MakeAcceleratorLabel(int accel, char *out);
|
2013-08-26 18:58:35 +00:00
|
|
|
bool StringAllPrintable(const char *str);
|
|
|
|
bool StringEndsIn(const char *str, const char *ending);
|
|
|
|
void Message(const char *str, ...);
|
|
|
|
void Error(const char *str, ...);
|
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
|
|
|
void CnfFreezeBool(bool v, const char *name);
|
2015-07-10 11:54:39 +00:00
|
|
|
void CnfFreezeColor(RgbaColor v, const char *name);
|
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
|
|
|
bool CnfThawBool(bool v, const char *name);
|
2015-07-10 11:54:39 +00:00
|
|
|
RgbaColor CnfThawColor(RgbaColor v, const char *name);
|
2008-03-27 09:53:51 +00:00
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
class System {
|
|
|
|
public:
|
2013-09-09 19:50:32 +00:00
|
|
|
enum { MAX_UNKNOWNS = 1024 };
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-06-23 08:25:17 +00:00
|
|
|
EntityList entity;
|
|
|
|
ParamList param;
|
2008-04-20 11:35:10 +00:00
|
|
|
IdList<Equation,hEquation> eq;
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
// A list of parameters that are being dragged; these are the ones that
|
|
|
|
// we should put as close as possible to their initial positions.
|
2009-11-03 18:54:49 +00:00
|
|
|
List<hParam> dragged;
|
2009-04-20 07:30:09 +00:00
|
|
|
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
// In general, the tag indicates the subsys that a variable/equation
|
|
|
|
// has been assigned to; these are exceptions for variables:
|
|
|
|
VAR_SUBSTITUTED = 10000,
|
|
|
|
VAR_DOF_TEST = 10001,
|
|
|
|
// and for equations:
|
|
|
|
EQ_SUBSTITUTED = 20000
|
|
|
|
};
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
// The system Jacobian matrix
|
2008-04-20 11:35:10 +00:00
|
|
|
struct {
|
2008-04-21 01:26:36 +00:00
|
|
|
// The corresponding equation for each row
|
|
|
|
hEquation eq[MAX_UNKNOWNS];
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
// The corresponding parameter for each column
|
|
|
|
hParam param[MAX_UNKNOWNS];
|
2008-05-01 06:25:38 +00:00
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
// We're solving AX = B
|
2008-04-20 11:35:10 +00:00
|
|
|
int m, n;
|
2008-04-21 01:26:36 +00:00
|
|
|
struct {
|
|
|
|
Expr *sym[MAX_UNKNOWNS][MAX_UNKNOWNS];
|
|
|
|
double num[MAX_UNKNOWNS][MAX_UNKNOWNS];
|
|
|
|
} A;
|
2008-05-01 06:25:38 +00:00
|
|
|
|
2008-05-13 02:35:31 +00:00
|
|
|
double scale[MAX_UNKNOWNS];
|
|
|
|
|
2008-05-12 07:29:50 +00:00
|
|
|
// Some helpers for the least squares solve
|
|
|
|
double AAt[MAX_UNKNOWNS][MAX_UNKNOWNS];
|
|
|
|
double Z[MAX_UNKNOWNS];
|
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
double X[MAX_UNKNOWNS];
|
2008-05-01 06:25:38 +00:00
|
|
|
|
2008-04-21 01:26:36 +00:00
|
|
|
struct {
|
|
|
|
Expr *sym[MAX_UNKNOWNS];
|
|
|
|
double num[MAX_UNKNOWNS];
|
|
|
|
} B;
|
|
|
|
} mat;
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-09-05 11:25:53 +00:00
|
|
|
static const double RANK_MAG_TOLERANCE, CONVERGE_TOLERANCE;
|
2008-07-02 08:18:25 +00:00
|
|
|
int CalculateRank(void);
|
2008-05-12 07:29:50 +00:00
|
|
|
static bool SolveLinearSystem(double X[], double A[][MAX_UNKNOWNS],
|
|
|
|
double B[], int N);
|
|
|
|
bool SolveLeastSquares(void);
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2009-04-19 20:37:51 +00:00
|
|
|
bool WriteJacobian(int tag);
|
2008-04-20 11:35:10 +00:00
|
|
|
void EvalJacobian(void);
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
void WriteEquationsExceptFor(hConstraint hc, Group *g);
|
|
|
|
void FindWhichToRemoveToFixJacobian(Group *g, List<hConstraint> *bad);
|
2008-05-07 07:10:20 +00:00
|
|
|
void SolveBySubstitution(void);
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
bool IsDragged(hParam p);
|
2008-05-01 06:25:38 +00:00
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
bool NewtonSolve(int tag);
|
2009-04-20 07:30:09 +00:00
|
|
|
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
SOLVED_OKAY = 0,
|
|
|
|
DIDNT_CONVERGE = 10,
|
|
|
|
SINGULAR_JACOBIAN = 11,
|
|
|
|
TOO_MANY_UNKNOWNS = 20
|
|
|
|
};
|
2009-04-21 07:56:17 +00:00
|
|
|
int Solve(Group *g, int *dof, List<hConstraint> *bad,
|
|
|
|
bool andFindBad, bool andFindFree);
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void);
|
2008-04-20 11:35:10 +00:00
|
|
|
};
|
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
class TtfFont {
|
|
|
|
public:
|
|
|
|
typedef struct {
|
|
|
|
bool onCurve;
|
|
|
|
bool lastInContour;
|
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
|
|
|
int16_t x;
|
|
|
|
int16_t y;
|
2008-06-30 09:09:17 +00:00
|
|
|
} FontPoint;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
FontPoint *pt;
|
|
|
|
int pts;
|
|
|
|
|
|
|
|
int xMax;
|
|
|
|
int xMin;
|
|
|
|
int leftSideBearing;
|
|
|
|
int advanceWidth;
|
|
|
|
} Glyph;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int x, y;
|
|
|
|
} IntPoint;
|
|
|
|
|
|
|
|
char fontFile[MAX_PATH];
|
|
|
|
NameStr name;
|
|
|
|
bool loaded;
|
|
|
|
|
|
|
|
// The font itself, plus the mapping from ASCII codes to glyphs
|
|
|
|
int useGlyph[256];
|
|
|
|
Glyph *glyph;
|
|
|
|
int glyphs;
|
|
|
|
|
|
|
|
int maxPoints;
|
|
|
|
int scale;
|
|
|
|
|
|
|
|
// The filehandle, while loading
|
|
|
|
FILE *fh;
|
|
|
|
// Some state while rendering a character to curves
|
2013-09-09 19:50:32 +00:00
|
|
|
enum {
|
|
|
|
NOTHING = 0,
|
|
|
|
ON_CURVE = 1,
|
|
|
|
OFF_CURVE = 2
|
|
|
|
};
|
2008-06-30 09:09:17 +00:00
|
|
|
int lastWas;
|
|
|
|
IntPoint lastOnCurve;
|
|
|
|
IntPoint lastOffCurve;
|
|
|
|
|
|
|
|
// And the state that the caller must specify, determines where we
|
|
|
|
// render to and how
|
2009-01-19 03:51:00 +00:00
|
|
|
SBezierList *beziers;
|
|
|
|
Vector origin, u, v;
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
int Getc(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
|
|
|
uint8_t GetBYTE(void);
|
|
|
|
uint16_t GetUSHORT(void);
|
|
|
|
uint32_t GetULONG(void);
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
void LoadGlyph(int index);
|
|
|
|
bool LoadFontFromFile(bool nameOnly);
|
2013-08-26 18:58:35 +00:00
|
|
|
const char *FontFileBaseName(void);
|
2015-03-29 00:30:52 +00:00
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
void Flush(void);
|
|
|
|
void Handle(int *dx, int x, int y, bool onCurve);
|
|
|
|
void PlotCharacter(int *dx, int c, double spacing);
|
|
|
|
void PlotString(char *str, double spacing,
|
2009-01-19 03:51:00 +00:00
|
|
|
SBezierList *sbl, Vector origin, Vector u, Vector v);
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
Vector TransformIntPoint(int x, int y);
|
|
|
|
void LineSegment(int x0, int y0, int x1, int y1);
|
|
|
|
void Bezier(int x0, int y0, int x1, int y1, int x2, int y2);
|
|
|
|
};
|
|
|
|
|
|
|
|
class TtfFontList {
|
|
|
|
public:
|
|
|
|
bool loaded;
|
2009-01-13 06:56:05 +00:00
|
|
|
List<TtfFont> l;
|
2008-06-30 09:09:17 +00:00
|
|
|
|
|
|
|
void LoadAll(void);
|
|
|
|
|
|
|
|
void PlotString(char *font, char *str, double spacing,
|
2009-01-19 03:51:00 +00:00
|
|
|
SBezierList *sbl, Vector origin, Vector u, Vector v);
|
2008-06-30 09:09:17 +00:00
|
|
|
};
|
2008-03-26 09:18:12 +00:00
|
|
|
|
2009-06-11 05:57:23 +00:00
|
|
|
class StepFileWriter {
|
|
|
|
public:
|
|
|
|
void ExportSurfacesTo(char *filename);
|
|
|
|
void WriteHeader(void);
|
2015-02-08 16:43:19 +00:00
|
|
|
void WriteProductHeader(void);
|
2009-06-11 05:57:23 +00:00
|
|
|
int ExportCurve(SBezier *sb);
|
|
|
|
int ExportCurveLoop(SBezierLoop *loop, bool inner);
|
2009-10-12 09:28:34 +00:00
|
|
|
void ExportSurface(SSurface *ss, SBezierList *sbl);
|
2009-06-11 05:57:23 +00:00
|
|
|
void WriteWireframe(void);
|
|
|
|
void WriteFooter(void);
|
|
|
|
|
|
|
|
List<int> curves;
|
|
|
|
List<int> advancedFaces;
|
|
|
|
FILE *f;
|
|
|
|
int id;
|
|
|
|
};
|
|
|
|
|
2009-01-14 05:10:42 +00:00
|
|
|
class VectorFileWriter {
|
|
|
|
public:
|
|
|
|
FILE *f;
|
2009-01-27 05:48:40 +00:00
|
|
|
Vector ptMin, ptMax;
|
2009-07-03 20:55:57 +00:00
|
|
|
|
2013-12-02 06:22:35 +00:00
|
|
|
// This quells the Clang++ warning "'VectorFileWriter' has virtual
|
|
|
|
// functions but non-virtual destructor"
|
|
|
|
virtual ~VectorFileWriter() {}
|
|
|
|
|
2009-04-15 06:50:06 +00:00
|
|
|
static double MmToPts(double mm);
|
|
|
|
|
2015-03-18 17:02:11 +00:00
|
|
|
static VectorFileWriter *ForFile(const char *file);
|
2009-01-14 05:10:42 +00:00
|
|
|
|
2009-10-30 10:38:34 +00:00
|
|
|
void Output(SBezierLoopSetSet *sblss, SMesh *sm);
|
2009-01-27 05:48:40 +00:00
|
|
|
|
2009-10-30 10:38:34 +00:00
|
|
|
void BezierAsPwl(SBezier *sb);
|
|
|
|
void BezierAsNonrationalCubic(SBezier *sb, int depth=0);
|
2009-09-22 05:46:30 +00:00
|
|
|
|
2015-07-10 11:54:39 +00:00
|
|
|
virtual void StartPath( RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb) = 0;
|
|
|
|
virtual void FinishPath(RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb) = 0;
|
2009-10-30 10:38:34 +00:00
|
|
|
virtual void Bezier(SBezier *sb) = 0;
|
2009-03-17 16:33:46 +00:00
|
|
|
virtual void Triangle(STriangle *tr) = 0;
|
2009-01-14 05:10:42 +00:00
|
|
|
virtual void StartFile(void) = 0;
|
|
|
|
virtual void FinishAndCloseFile(void) = 0;
|
2010-01-14 05:24:32 +00:00
|
|
|
virtual bool HasCanvasSize(void) = 0;
|
2013-10-19 05:36:45 +00:00
|
|
|
|
|
|
|
virtual void Dummy(void);
|
2009-01-14 05:10:42 +00:00
|
|
|
};
|
|
|
|
class DxfFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
2015-07-10 11:54:39 +00:00
|
|
|
void StartPath( RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
|
|
|
void FinishPath(RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
2009-03-17 16:33:46 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-01-27 05:48:40 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return false; }
|
2009-01-27 05:48:40 +00:00
|
|
|
};
|
|
|
|
class EpsFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
2009-10-30 10:38:34 +00:00
|
|
|
Vector prevPt;
|
|
|
|
void MaybeMoveTo(Vector s, Vector f);
|
|
|
|
|
2015-07-10 11:54:39 +00:00
|
|
|
void StartPath( RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
|
|
|
void FinishPath(RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
2009-04-15 06:50:06 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-04-15 06:50:06 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return true; }
|
2009-04-15 06:50:06 +00:00
|
|
|
};
|
|
|
|
class PdfFileWriter : public VectorFileWriter {
|
|
|
|
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 xref[10];
|
|
|
|
uint32_t bodyStart;
|
2009-10-30 10:38:34 +00:00
|
|
|
Vector prevPt;
|
|
|
|
void MaybeMoveTo(Vector s, Vector f);
|
2009-04-15 06:50:06 +00:00
|
|
|
|
2015-07-10 11:54:39 +00:00
|
|
|
void StartPath( RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
|
|
|
void FinishPath(RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
2009-03-17 16:33:46 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-01-27 05:48:40 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return true; }
|
2009-01-27 05:48:40 +00:00
|
|
|
};
|
|
|
|
class SvgFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
2009-10-30 10:38:34 +00:00
|
|
|
Vector prevPt;
|
|
|
|
void MaybeMoveTo(Vector s, Vector f);
|
|
|
|
|
2015-07-10 11:54:39 +00:00
|
|
|
void StartPath( RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
|
|
|
void FinishPath(RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
2009-03-17 16:33:46 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-01-27 05:48:40 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return true; }
|
2009-01-27 05:48:40 +00:00
|
|
|
};
|
|
|
|
class HpglFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
|
|
|
static double MmToHpglUnits(double mm);
|
2015-07-10 11:54:39 +00:00
|
|
|
void StartPath( RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
|
|
|
void FinishPath(RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
2009-03-17 16:33:46 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-01-14 05:10:42 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return false; }
|
2009-01-14 05:10:42 +00:00
|
|
|
};
|
2009-06-11 05:57:23 +00:00
|
|
|
class Step2dFileWriter : public VectorFileWriter {
|
|
|
|
StepFileWriter sfw;
|
2015-07-10 11:54:39 +00:00
|
|
|
void StartPath( RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
|
|
|
void FinishPath(RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
2009-06-11 05:57:23 +00:00
|
|
|
void Triangle(STriangle *tr);
|
2009-10-30 10:38:34 +00:00
|
|
|
void Bezier(SBezier *sb);
|
2009-06-11 05:57:23 +00:00
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return false; }
|
2009-06-08 06:50:16 +00:00
|
|
|
};
|
2010-01-14 04:47:17 +00:00
|
|
|
class GCodeFileWriter : public VectorFileWriter {
|
|
|
|
public:
|
|
|
|
SEdgeList sel;
|
2015-07-10 11:54:39 +00:00
|
|
|
void StartPath( RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
|
|
|
void FinishPath(RgbaColor strokeRgb, double lineWidth,
|
|
|
|
bool filled, RgbaColor fillRgb);
|
2010-01-14 04:47:17 +00:00
|
|
|
void Triangle(STriangle *tr);
|
|
|
|
void Bezier(SBezier *sb);
|
|
|
|
void StartFile(void);
|
|
|
|
void FinishAndCloseFile(void);
|
2010-01-14 05:24:32 +00:00
|
|
|
bool HasCanvasSize(void) { return false; }
|
2010-01-14 04:47:17 +00:00
|
|
|
};
|
2009-06-08 06:50:16 +00:00
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
#ifdef LIBRARY
|
|
|
|
# define ENTITY EntityBase
|
|
|
|
# define CONSTRAINT ConstraintBase
|
|
|
|
#else
|
|
|
|
# define ENTITY Entity
|
|
|
|
# define CONSTRAINT Constraint
|
|
|
|
#endif
|
2009-04-19 05:53:16 +00:00
|
|
|
class Sketch {
|
2008-03-28 10:00:37 +00:00
|
|
|
public:
|
2009-04-19 05:53:16 +00:00
|
|
|
// These are user-editable, and define the sketch.
|
2008-04-14 10:28:32 +00:00
|
|
|
IdList<Group,hGroup> group;
|
2009-04-20 07:30:09 +00:00
|
|
|
IdList<CONSTRAINT,hConstraint> constraint;
|
2009-04-19 05:53:16 +00:00
|
|
|
IdList<Request,hRequest> request;
|
2009-09-17 07:32:36 +00:00
|
|
|
IdList<Style,hStyle> style;
|
2008-04-14 10:28:32 +00:00
|
|
|
|
2009-04-19 05:53:16 +00:00
|
|
|
// These are generated from the above.
|
2009-04-20 07:30:09 +00:00
|
|
|
IdList<ENTITY,hEntity> entity;
|
2008-04-14 10:28:32 +00:00
|
|
|
IdList<Param,hParam> param;
|
|
|
|
|
2009-04-20 07:30:09 +00:00
|
|
|
inline CONSTRAINT *GetConstraint(hConstraint h)
|
2008-04-14 10:28:32 +00:00
|
|
|
{ return constraint.FindById(h); }
|
2009-04-20 07:30:09 +00:00
|
|
|
inline ENTITY *GetEntity (hEntity h) { return entity. FindById(h); }
|
2008-04-14 10:28:32 +00:00
|
|
|
inline Param *GetParam (hParam h) { return param. FindById(h); }
|
2009-04-19 05:53:16 +00:00
|
|
|
inline Request *GetRequest(hRequest h) { return request.FindById(h); }
|
2008-04-20 11:35:10 +00:00
|
|
|
inline Group *GetGroup (hGroup h) { return group. FindById(h); }
|
2009-09-17 07:32:36 +00:00
|
|
|
// Styles are handled a bit differently.
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void);
|
2009-04-19 05:53:16 +00:00
|
|
|
};
|
2009-09-17 07:32:36 +00:00
|
|
|
#undef ENTITY
|
|
|
|
#undef CONSTRAINT
|
2009-04-19 05:53:16 +00:00
|
|
|
|
2015-03-23 17:49:04 +00:00
|
|
|
class SolveSpaceUI {
|
2009-04-19 05:53:16 +00:00
|
|
|
public:
|
|
|
|
TextWindow TW;
|
|
|
|
GraphicsWindow GW;
|
2008-04-13 14:28:35 +00:00
|
|
|
|
2008-06-04 10:22:30 +00:00
|
|
|
// The state for undo/redo
|
|
|
|
typedef struct {
|
|
|
|
IdList<Group,hGroup> group;
|
|
|
|
IdList<Request,hRequest> request;
|
|
|
|
IdList<Constraint,hConstraint> constraint;
|
|
|
|
IdList<Param,hParam> param;
|
2009-09-17 07:32:36 +00:00
|
|
|
IdList<Style,hStyle> style;
|
2008-06-04 10:22:30 +00:00
|
|
|
hGroup activeGroup;
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void) {
|
|
|
|
group.Clear();
|
|
|
|
request.Clear();
|
|
|
|
constraint.Clear();
|
|
|
|
param.Clear();
|
|
|
|
style.Clear();
|
|
|
|
}
|
2008-06-04 10:22:30 +00:00
|
|
|
} UndoState;
|
2013-09-09 19:50:32 +00:00
|
|
|
enum { MAX_UNDO = 16 };
|
2008-06-04 10:22:30 +00:00
|
|
|
typedef struct {
|
|
|
|
UndoState d[MAX_UNDO];
|
|
|
|
int cnt;
|
|
|
|
int write;
|
|
|
|
} UndoStack;
|
|
|
|
UndoStack undo;
|
|
|
|
UndoStack redo;
|
|
|
|
void UndoEnableMenus(void);
|
|
|
|
void UndoRemember(void);
|
|
|
|
void UndoUndo(void);
|
|
|
|
void UndoRedo(void);
|
|
|
|
void PushFromCurrentOnto(UndoStack *uk);
|
|
|
|
void PopOntoCurrentFrom(UndoStack *uk);
|
|
|
|
void UndoClearState(UndoState *ut);
|
|
|
|
void UndoClearStack(UndoStack *uk);
|
|
|
|
|
2008-06-11 04:22:52 +00:00
|
|
|
// Little bits of extra configuration state
|
2013-09-09 19:50:32 +00:00
|
|
|
enum { MODEL_COLORS = 8 };
|
2015-07-10 11:54:39 +00:00
|
|
|
RgbaColor modelColor[MODEL_COLORS];
|
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
|
|
|
Vector lightDir[2];
|
|
|
|
double lightIntensity[2];
|
|
|
|
double ambientIntensity;
|
|
|
|
double chordTol;
|
|
|
|
int maxSegments;
|
|
|
|
double cameraTangent;
|
|
|
|
float gridSpacing;
|
|
|
|
float exportScale;
|
|
|
|
float exportOffset;
|
|
|
|
bool fixExportColors;
|
|
|
|
bool drawBackFaces;
|
|
|
|
bool checkClosedContour;
|
|
|
|
bool showToolbar;
|
2015-07-10 11:54:39 +00:00
|
|
|
RgbaColor backgroundColor;
|
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 exportShadedTriangles;
|
|
|
|
bool exportPwlCurves;
|
|
|
|
bool exportCanvasSizeAuto;
|
2009-09-03 08:13:09 +00:00
|
|
|
struct {
|
|
|
|
float left;
|
|
|
|
float right;
|
|
|
|
float bottom;
|
|
|
|
float top;
|
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
|
|
|
} exportMargin;
|
2009-09-03 08:13:09 +00:00
|
|
|
struct {
|
|
|
|
float width;
|
|
|
|
float height;
|
|
|
|
float dx;
|
|
|
|
float dy;
|
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
|
|
|
} exportCanvas;
|
2010-01-14 04:47:17 +00:00
|
|
|
struct {
|
|
|
|
float depth;
|
|
|
|
int passes;
|
|
|
|
float feed;
|
|
|
|
float plungeFeed;
|
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
|
|
|
} gCode;
|
2008-07-06 07:56:24 +00:00
|
|
|
|
2008-06-14 09:51:25 +00:00
|
|
|
typedef enum {
|
|
|
|
UNIT_MM = 0,
|
2013-08-26 20:54:04 +00:00
|
|
|
UNIT_INCHES
|
2008-06-14 09:51:25 +00:00
|
|
|
} Unit;
|
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
|
|
|
Unit viewUnits;
|
|
|
|
int afterDecimalMm;
|
|
|
|
int afterDecimalInch;
|
2015-03-29 04:46:57 +00:00
|
|
|
int autosaveInterval; // in minutes
|
2010-09-24 02:58:34 +00:00
|
|
|
|
2008-06-14 09:51:25 +00:00
|
|
|
char *MmToString(double v);
|
|
|
|
double ExprToMm(Expr *e);
|
2013-08-26 18:58:35 +00:00
|
|
|
double StringToMm(const char *s);
|
|
|
|
const char *UnitName(void);
|
2010-01-04 00:35:28 +00:00
|
|
|
double MmPerUnit(void);
|
2010-09-24 02:58:34 +00:00
|
|
|
int UnitDigitsAfterDecimal(void);
|
|
|
|
void SetUnitDigitsAfterDecimal(int v);
|
2009-03-08 10:59:57 +00:00
|
|
|
double ChordTolMm(void);
|
2010-05-03 05:15:28 +00:00
|
|
|
bool usePerspectiveProj;
|
2009-09-29 11:35:19 +00:00
|
|
|
double CameraTangent(void);
|
2008-06-14 09:51:25 +00:00
|
|
|
|
2010-05-16 16:36:23 +00:00
|
|
|
// Some stuff relating to the tangent arcs created non-parametrically
|
|
|
|
// as special requests.
|
|
|
|
double tangentArcRadius;
|
|
|
|
bool tangentArcManual;
|
|
|
|
bool tangentArcDeleteOld;
|
|
|
|
|
2008-06-14 09:51:25 +00:00
|
|
|
// The platform-dependent code calls this before entering the msg loop
|
2015-03-24 06:45:53 +00:00
|
|
|
void Init(void);
|
|
|
|
bool OpenFile(const char *filename);
|
2008-06-11 04:22:52 +00:00
|
|
|
void Exit(void);
|
|
|
|
|
2008-06-04 10:22:30 +00:00
|
|
|
// File load/save routines, including the additional files that get
|
|
|
|
// loaded when we have import groups.
|
2008-04-18 11:11:48 +00:00
|
|
|
FILE *fh;
|
2008-05-28 10:10:31 +00:00
|
|
|
void AfterNewFile(void);
|
2015-03-18 17:02:11 +00:00
|
|
|
static void RemoveFromRecentList(const char *file);
|
|
|
|
static void AddToRecentList(const char *file);
|
2008-04-24 06:22:16 +00:00
|
|
|
char saveFile[MAX_PATH];
|
2009-12-15 12:26:22 +00:00
|
|
|
bool fileLoadError;
|
2008-04-24 06:22:16 +00:00
|
|
|
bool unsaved;
|
|
|
|
typedef struct {
|
2013-08-26 18:58:35 +00:00
|
|
|
char type;
|
|
|
|
const char *desc;
|
|
|
|
char fmt;
|
|
|
|
void *ptr;
|
2008-04-24 06:22:16 +00:00
|
|
|
} SaveTable;
|
|
|
|
static const SaveTable SAVED[];
|
|
|
|
void SaveUsingTable(int type);
|
2008-04-27 10:01:23 +00:00
|
|
|
void LoadUsingTable(char *key, char *val);
|
2008-04-24 06:22:16 +00:00
|
|
|
struct {
|
|
|
|
Group g;
|
|
|
|
Request r;
|
|
|
|
Entity e;
|
|
|
|
Param p;
|
|
|
|
Constraint c;
|
2009-09-17 07:32:36 +00:00
|
|
|
Style s;
|
2008-04-24 06:22:16 +00:00
|
|
|
} sv;
|
2008-04-18 11:11:48 +00:00
|
|
|
static void MenuFile(int id);
|
2015-03-29 04:46:57 +00:00
|
|
|
bool Autosave();
|
|
|
|
void RemoveAutosave();
|
2008-06-03 18:28:41 +00:00
|
|
|
bool GetFilenameAndSave(bool saveAs);
|
|
|
|
bool OkayToStartNewFile(void);
|
2008-06-02 11:43:27 +00:00
|
|
|
hGroup CreateDefaultDrawingGroup(void);
|
2008-07-08 08:02:22 +00:00
|
|
|
void UpdateWindowTitle(void);
|
2010-02-28 19:23:01 +00:00
|
|
|
void ClearExisting(void);
|
2008-04-24 06:22:16 +00:00
|
|
|
void NewFile(void);
|
2015-03-18 17:02:11 +00:00
|
|
|
bool SaveToFile(const char *filename);
|
2015-03-29 04:46:57 +00:00
|
|
|
bool LoadAutosaveFor(const char *filename);
|
2015-03-18 17:02:11 +00:00
|
|
|
bool LoadFromFile(const char *filename);
|
|
|
|
bool LoadEntitiesFromFile(const char *filename, EntityList *le,
|
|
|
|
SMesh *m, SShell *sh);
|
2008-05-29 10:10:12 +00:00
|
|
|
void ReloadAllImported(void);
|
2008-07-06 09:24:31 +00:00
|
|
|
// And the various export options
|
2015-03-18 17:02:11 +00:00
|
|
|
void ExportAsPngTo(const char *file);
|
|
|
|
void ExportMeshTo(const char *file);
|
2009-10-12 11:34:43 +00:00
|
|
|
void ExportMeshAsStlTo(FILE *f, SMesh *sm);
|
|
|
|
void ExportMeshAsObjTo(FILE *f, SMesh *sm);
|
2015-03-18 17:02:11 +00:00
|
|
|
void ExportViewOrWireframeTo(const char *file, bool wireframe);
|
|
|
|
void ExportSectionTo(const char *file);
|
2009-10-12 10:40:48 +00:00
|
|
|
void ExportWireframeCurves(SEdgeList *sel, SBezierList *sbl,
|
|
|
|
VectorFileWriter *out);
|
2009-04-14 04:19:23 +00:00
|
|
|
void ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *sm,
|
2009-03-17 16:33:46 +00:00
|
|
|
Vector u, Vector v, Vector n, Vector origin,
|
|
|
|
double cameraTan,
|
|
|
|
VectorFileWriter *out);
|
2008-04-20 11:35:10 +00:00
|
|
|
|
2008-07-20 11:27:22 +00:00
|
|
|
static void MenuAnalyze(int id);
|
2009-11-08 01:11:38 +00:00
|
|
|
|
|
|
|
// Additional display stuff
|
2008-07-20 11:27:22 +00:00
|
|
|
struct {
|
|
|
|
SContour path;
|
|
|
|
hEntity point;
|
|
|
|
} traced;
|
2009-01-25 09:19:59 +00:00
|
|
|
SEdgeList nakedEdges;
|
2010-01-04 00:35:28 +00:00
|
|
|
struct {
|
|
|
|
bool draw;
|
|
|
|
Vector ptA;
|
|
|
|
Vector ptB;
|
|
|
|
} extraLine;
|
2009-11-08 01:11:38 +00:00
|
|
|
struct {
|
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
|
|
|
uint8_t *fromFile;
|
2009-11-08 01:11:38 +00:00
|
|
|
int w, h;
|
|
|
|
int rw, rh;
|
|
|
|
double scale; // pixels per mm
|
|
|
|
Vector origin;
|
|
|
|
} bgImage;
|
2010-01-14 05:24:32 +00:00
|
|
|
struct {
|
|
|
|
bool draw;
|
|
|
|
Vector pt, u, v;
|
|
|
|
} justExportedInfo;
|
2008-07-20 11:27:22 +00:00
|
|
|
|
2009-12-04 08:08:41 +00:00
|
|
|
class Clipboard {
|
|
|
|
public:
|
|
|
|
List<ClipboardRequest> r;
|
|
|
|
List<Constraint> c;
|
|
|
|
|
|
|
|
void Clear(void);
|
|
|
|
bool ContainsEntity(hEntity old);
|
|
|
|
hEntity NewEntityFor(hEntity old);
|
|
|
|
};
|
|
|
|
Clipboard clipboard;
|
|
|
|
|
2008-06-02 09:31:26 +00:00
|
|
|
void MarkGroupDirty(hGroup hg);
|
2008-06-02 11:43:27 +00:00
|
|
|
void MarkGroupDirtyByEntity(hEntity he);
|
2008-06-02 09:31:26 +00:00
|
|
|
|
2008-06-04 10:22:30 +00:00
|
|
|
// Consistency checking on the sketch: stuff with missing dependencies
|
|
|
|
// will get deleted automatically.
|
2008-05-17 06:04:55 +00:00
|
|
|
struct {
|
|
|
|
int requests;
|
|
|
|
int groups;
|
|
|
|
int constraints;
|
2009-01-03 12:27:33 +00:00
|
|
|
int nonTrivialConstraints;
|
2008-05-17 06:04:55 +00:00
|
|
|
} deleted;
|
|
|
|
bool GroupExists(hGroup hg);
|
|
|
|
bool PruneOrphans(void);
|
|
|
|
bool EntityExists(hEntity he);
|
|
|
|
bool GroupsInOrder(hGroup before, hGroup after);
|
|
|
|
bool PruneGroups(hGroup hg);
|
|
|
|
bool PruneRequests(hGroup hg);
|
|
|
|
bool PruneConstraints(hGroup hg);
|
2008-04-27 09:03:01 +00:00
|
|
|
|
2008-06-02 09:31:26 +00:00
|
|
|
void GenerateAll(void);
|
2009-01-04 12:01:46 +00:00
|
|
|
void GenerateAll(int first, int last, bool andFindFree=false);
|
|
|
|
void SolveGroup(hGroup hg, bool andFindFree);
|
2009-04-20 07:30:09 +00:00
|
|
|
void MarkDraggedParams(void);
|
2008-04-27 09:03:01 +00:00
|
|
|
void ForceReferences(void);
|
|
|
|
|
2008-07-20 11:27:22 +00:00
|
|
|
bool AllGroupsOkay(void);
|
|
|
|
|
2008-04-20 11:35:10 +00:00
|
|
|
// The system to be solved.
|
|
|
|
System sys;
|
2008-06-03 18:28:41 +00:00
|
|
|
|
2008-06-30 09:09:17 +00:00
|
|
|
// All the TrueType fonts in memory
|
|
|
|
TtfFontList fonts;
|
|
|
|
|
2008-06-25 05:14:49 +00:00
|
|
|
// Everything has been pruned, so we know there's no dangling references
|
|
|
|
// to entities that don't exist. Before that, we mustn't try to display
|
|
|
|
// the sketch!
|
|
|
|
bool allConsistent;
|
|
|
|
|
2008-06-03 18:28:41 +00:00
|
|
|
struct {
|
2015-03-18 17:02:11 +00:00
|
|
|
bool scheduled;
|
2008-06-03 18:28:41 +00:00
|
|
|
bool showTW;
|
|
|
|
bool generateAll;
|
|
|
|
} later;
|
2015-03-18 17:02:11 +00:00
|
|
|
void ScheduleShowTW();
|
|
|
|
void ScheduleGenerateAll();
|
2008-06-03 18:28:41 +00:00
|
|
|
void DoLater(void);
|
2008-02-09 13:52:01 +00:00
|
|
|
|
|
|
|
static void MenuHelp(int id);
|
2013-09-19 04:33:12 +00:00
|
|
|
|
|
|
|
void Clear(void);
|
2008-03-28 10:00:37 +00:00
|
|
|
};
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2015-03-23 17:49:04 +00:00
|
|
|
extern SolveSpaceUI SS;
|
2009-04-19 05:53:16 +00:00
|
|
|
extern Sketch SK;
|
2008-03-25 10:02:13 +00:00
|
|
|
|
2015-03-23 17:49:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef __OBJC__
|
|
|
|
using namespace SolveSpace;
|
|
|
|
#endif
|
|
|
|
|
2008-03-25 10:02:13 +00:00
|
|
|
#endif
|