Remove Windows-isms and add a CMake buildsystem.

This commit is contained in:
whitequark 2016-10-25 13:42:13 +00:00
parent 2ecc612801
commit 479c406d2b
20 changed files with 417 additions and 209 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build*

67
CMakeLists.txt Normal file
View File

@ -0,0 +1,67 @@
# cmake configuration
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
cmake_policy(VERSION 3.1.0)
# project
project(solvespace)
# common compiler flags
if(MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
endif()
if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
# solvespace-only compiler flags
if(WIN32)
add_definitions(
-D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS
-D_SCL_SECURE_NO_WARNINGS
-D_WIN32_WINNT=0x500
-D_WIN32_IE=_WIN32_WINNT
-DISOLATION_AWARE_ENABLED
-DWIN32
-DWIN32_LEAN_AND_MEAN
-DUNICODE
-D_UNICODE
-DNOMINMAX
-D_USE_MATH_DEFINES)
endif()
if(MSVC)
# Many versions of MSVC do not have the (C99) inline keyword, instead
# they have their own __inline; this breaks `static inline` functions.
# We do not want to care and so we fix this with a definition.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Dinline=__inline")
# Same for the (C99) __func__ special variable; we use it only in C++ code.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D__func__=__FUNCTION__")
# We rely on these /we flags. They correspond to the GNU-style flags below as
# follows: /w4062=-Wswitch
set(WARNING_FLAGS "${WARNING_FLAGS} /we4062")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(WARNING_FLAGS "${WARNING_FLAGS} -Wfloat-conversion")
endif()
# We rely on these -Werror flags.
set(WARNING_FLAGS "${WARNING_FLAGS} -Werror=switch")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}")
# components
add_subdirectory(src)
add_subdirectory(exposed)

View File

@ -5,7 +5,6 @@
// //
// Copyright 2008-2013 Jonathan Westhues. // Copyright 2008-2013 Jonathan Westhues.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h> #include <stdio.h>
#include "slvs.h" #include "slvs.h"

8
exposed/CMakeLists.txt Normal file
View File

@ -0,0 +1,8 @@
include_directories(
${CMAKE_SOURCE_DIR}/include)
add_executable(CDemo
CDemo.c)
target_link_libraries(CDemo
slvs)

View File

@ -10,20 +10,26 @@
#ifndef __SLVS_H #ifndef __SLVS_H
#define __SLVS_H #define __SLVS_H
#ifdef EXPORT_DLL #include <stdint.h>
#if defined(WIN32)
#ifdef slvs_EXPORTS
#define DLL __declspec( dllexport ) #define DLL __declspec( dllexport )
#else #else
#define DLL __declspec( dllimport ) #define DLL __declspec( dllimport )
#endif #endif
#else
#define DLL
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
typedef DWORD Slvs_hParam; typedef uint32_t Slvs_hParam;
typedef DWORD Slvs_hEntity; typedef uint32_t Slvs_hEntity;
typedef DWORD Slvs_hConstraint; typedef uint32_t Slvs_hConstraint;
typedef DWORD Slvs_hGroup; typedef uint32_t Slvs_hGroup;
// To obtain the 3d (not projected into a workplane) of a constraint or // To obtain the 3d (not projected into a workplane) of a constraint or
// an entity, specify this instead of the workplane. // an entity, specify this instead of the workplane.

37
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
# platform utilities
if(WIN32)
set(util_SOURCES
platform/w32util.cpp)
else()
set(util_SOURCES
platform/unixutil.cpp)
endif()
# libslvs
set(libslvs_SOURCES
util.cpp
entity.cpp
expr.cpp
constraint.cpp
constrainteq.cpp
system.cpp)
set(libslvs_HEADERS
solvespace.h)
add_library(slvs SHARED
${libslvs_SOURCES}
${libslvs_HEADERS}
${util_SOURCES}
lib.cpp)
target_compile_definitions(slvs
PRIVATE -DLIBRARY)
target_include_directories(slvs
PUBLIC ${CMAKE_SOURCE_DIR}/include)
set_target_properties(slvs PROPERTIES
PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/slvs.h)

View File

@ -9,7 +9,7 @@
char *Constraint::DescriptionString(void) { char *Constraint::DescriptionString(void) {
static char ret[1024]; static char ret[1024];
char *s; const char *s;
switch(type) { switch(type) {
case POINTS_COINCIDENT: s = "pts-coincident"; break; case POINTS_COINCIDENT: s = "pts-coincident"; break;
case PT_PT_DISTANCE: s = "pt-pt-distance"; break; case PT_PT_DISTANCE: s = "pt-pt-distance"; break;
@ -52,6 +52,8 @@ char *Constraint::DescriptionString(void) {
return ret; return ret;
} }
#ifndef LIBRARY
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Delete all constraints with the specified type, entityA, ptA. We use this // Delete all constraints with the specified type, entityA, ptA. We use this
// when auto-removing constraints that would become redundant. // when auto-removing constraints that would become redundant.
@ -707,3 +709,5 @@ void Constraint::MenuConstrain(int id) {
InvalidateGraphics(); InvalidateGraphics();
} }
#endif

View File

@ -7,9 +7,6 @@
#ifndef __DSC_H #ifndef __DSC_H
#define __DSC_H #define __DSC_H
typedef unsigned long DWORD;
typedef unsigned char BYTE;
class Vector; class Vector;
class Vector4; class Vector4;
class Point2d; class Point2d;
@ -232,8 +229,8 @@ public:
int n; int n;
int elemsAllocated; int elemsAllocated;
DWORD MaximumId(void) { uint32_t MaximumId(void) {
DWORD id = 0; uint32_t id = 0;
int i; int i;
for(i = 0; i < n; i++) { for(i = 0; i < n; i++) {

View File

@ -372,10 +372,10 @@ Expr *Expr::PartialWrt(hParam p) {
} }
} }
QWORD Expr::ParamsUsed(void) { uint64_t Expr::ParamsUsed(void) {
QWORD r = 0; uint64_t r = 0;
if(op == PARAM) r |= ((QWORD)1 << (x.parh.v % 61)); if(op == PARAM) r |= ((uint64_t)1 << (x.parh.v % 61));
if(op == PARAM_PTR) r |= ((QWORD)1 << (x.parp->h.v % 61)); if(op == PARAM_PTR) r |= ((uint64_t)1 << (x.parp->h.v % 61));
int c = Children(); int c = Children();
if(c >= 1) r |= a->ParamsUsed(); if(c >= 1) r |= a->ParamsUsed();
@ -519,12 +519,12 @@ hParam Expr::ReferencedParams(ParamList *pl) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static char StringBuffer[4096]; static char StringBuffer[4096];
void Expr::App(char *s, ...) { void Expr::App(const char *s, ...) {
va_list f; va_list f;
va_start(f, s); va_start(f, s);
vsprintf(StringBuffer+strlen(StringBuffer), s, f); vsprintf(StringBuffer+strlen(StringBuffer), s, f);
} }
char *Expr::Print(void) { const char *Expr::Print(void) {
if(!this) return "0"; if(!this) return "0";
StringBuffer[0] = '\0'; StringBuffer[0] = '\0';

View File

@ -12,7 +12,7 @@ class Expr;
class Expr { class Expr {
public: public:
DWORD marker; uint32_t marker;
// A parameter, by the hParam handle // A parameter, by the hParam handle
static const int PARAM = 0; static const int PARAM = 0;
@ -83,7 +83,7 @@ public:
Expr *PartialWrt(hParam p); Expr *PartialWrt(hParam p);
double Eval(void); double Eval(void);
QWORD ParamsUsed(void); uint64_t ParamsUsed(void);
bool DependsOn(hParam p); bool DependsOn(hParam p);
static bool Tol(double a, double b); static bool Tol(double a, double b);
Expr *FoldConstants(void); Expr *FoldConstants(void);
@ -94,8 +94,8 @@ public:
void ParamsToPointers(void); void ParamsToPointers(void);
void App(char *str, ...); void App(const char *str, ...);
char *Print(void); const char *Print(void);
void PrintW(void); // worker void PrintW(void); // worker
// number of child nodes: 0 (e.g. constant), 1 (sqrt), or 2 (+) // number of child nodes: 0 (e.g. constant), 1 (sqrt), or 2 (+)

View File

@ -17,7 +17,7 @@ void Group::GenerateEquations(IdList<Equation,hEquation> *l) {
// Nothing to do for now. // Nothing to do for now.
} }
void DoMessageBox(char *str, int rows, int cols, BOOL error) void DoMessageBox(char *str, int rows, int cols, bool error)
{ {
} }

81
src/platform/unixutil.cpp Normal file
View File

@ -0,0 +1,81 @@
//-----------------------------------------------------------------------------
// Utility functions that run on Unix. Notably, our memory allocation;
// we use two separate allocators, one for long-lived stuff and one for
// stuff that gets freed after every regeneration of the model, to save us
// the trouble of freeing the latter explicitly.
//
// Copyright 2016 whitequark@whitequark.org.
//-----------------------------------------------------------------------------
#include "../solvespace.h"
void dbp(const char *str, ...)
{
va_list f;
static char buf[1024*50];
va_start(f, str);
vsnprintf(buf, sizeof(buf), str, f);
va_end(f);
fputs(buf, stderr);
fputc('\n', stderr);
}
void GetAbsoluteFilename(char *file)
{
}
//-----------------------------------------------------------------------------
// A separate heap, on which we allocate expressions. Maybe a bit faster,
// since no fragmentation issues whatsoever, and it also makes it possible
// to be sloppy with our memory management, and just free everything at once
// at the end.
//-----------------------------------------------------------------------------
struct HeapList {
HeapList *next;
};
static HeapList *TempHeap;
void *AllocTemporary(int n)
{
HeapList *l = (HeapList*)malloc(n + sizeof(HeapList));
if(!l) oops();
l->next = TempHeap;
TempHeap = l;
return (void*)((intptr_t)l + sizeof(HeapList));
}
void FreeTemporary(void *p) {
}
void FreeAllTemporary(void)
{
while(TempHeap) {
HeapList *next = TempHeap->next;
free(TempHeap);
TempHeap = next;
}
}
void *MemRealloc(void *p, int n) {
if(!p) {
return MemAlloc(n);
}
p = realloc(p, n);
if(!p) oops();
return p;
}
void *MemAlloc(int n) {
void *p = malloc(n);
if(!p) oops();
return p;
}
void MemFree(void *p) {
free(p);
}
void vl(void) {
}
void InitHeaps(void) {
}

View File

@ -11,7 +11,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "solvespace.h" #include "../solvespace.h"
static HANDLE PermHeap, TempHeap; static HANDLE PermHeap, TempHeap;

View File

@ -120,7 +120,7 @@ public:
}; };
typedef struct { typedef struct {
DWORD face; uint32_t face;
int color; int color;
} STriMeta; } STriMeta;
@ -249,7 +249,7 @@ public:
bool IsEmpty(void); bool IsEmpty(void);
void RemapFaces(Group *g, int remap); void RemapFaces(Group *g, int remap);
DWORD FirstIntersectionWith(Point2d mp); uint32_t FirstIntersectionWith(Point2d mp);
}; };
// A linked list of triangles // A linked list of triangles
@ -282,7 +282,7 @@ public:
void FindEdgeOn(Vector a, Vector b, int *n, int cnt, bool coplanarIsInter, void FindEdgeOn(Vector a, Vector b, int *n, int cnt, bool coplanarIsInter,
bool *inter, bool *fwd, bool *inter, bool *fwd,
DWORD *face); uint32_t *face);
static const int NAKED_OR_SELF_INTER_EDGES = 100; static const int NAKED_OR_SELF_INTER_EDGES = 100;
static const int SELF_INTER_EDGES = 200; static const int SELF_INTER_EDGES = 200;
static const int TURNING_EDGES = 300; static const int TURNING_EDGES = 300;

View File

@ -26,7 +26,7 @@ class Equation;
class hGroup { class hGroup {
public: public:
// bits 15: 0 -- group index // bits 15: 0 -- group index
DWORD v; uint32_t v;
inline hEntity entity(int i); inline hEntity entity(int i);
inline hParam param(int i); inline hParam param(int i);
@ -35,7 +35,7 @@ public:
class hRequest { class hRequest {
public: public:
// bits 15: 0 -- request index // bits 15: 0 -- request index
DWORD v; uint32_t v;
inline hEntity entity(int i); inline hEntity entity(int i);
inline hParam param(int i); inline hParam param(int i);
@ -46,7 +46,7 @@ class hEntity {
public: public:
// bits 15: 0 -- entity index // bits 15: 0 -- entity index
// 31:16 -- request index // 31:16 -- request index
DWORD v; uint32_t v;
inline bool isFromRequest(void); inline bool isFromRequest(void);
inline hRequest request(void); inline hRequest request(void);
@ -57,20 +57,20 @@ class hParam {
public: public:
// bits 15: 0 -- param index // bits 15: 0 -- param index
// 31:16 -- request index // 31:16 -- request index
DWORD v; uint32_t v;
inline hRequest request(void); inline hRequest request(void);
}; };
class hStyle { class hStyle {
public: public:
DWORD v; uint32_t v;
}; };
class EntityId { class EntityId {
public: public:
DWORD v; // entity ID, starting from 0 uint32_t v; // entity ID, starting from 0
}; };
class EntityMap { class EntityMap {
public: public:
@ -114,7 +114,7 @@ public:
double valA; double valA;
double valB; double valB;
double valC; double valC;
DWORD color; uint32_t color;
struct { struct {
int how; int how;
@ -230,7 +230,7 @@ public:
void GenerateDisplayItems(void); void GenerateDisplayItems(void);
void DrawDisplayItems(int t); void DrawDisplayItems(int t);
void Draw(void); void Draw(void);
DWORD GetLoopSetFillColor(SBezierLoopSet *sbls, uint32_t GetLoopSetFillColor(SBezierLoopSet *sbls,
bool *allSame, Vector *errorAt); bool *allSame, Vector *errorAt);
void FillLoopSetAsPolygon(SBezierLoopSet *sbls); void FillLoopSetAsPolygon(SBezierLoopSet *sbls);
void DrawFilledPaths(void); void DrawFilledPaths(void);
@ -505,7 +505,7 @@ public:
class hConstraint { class hConstraint {
public: public:
DWORD v; uint32_t v;
inline hEquation equation(int i); inline hEquation equation(int i);
}; };
@ -640,7 +640,7 @@ public:
class hEquation { class hEquation {
public: public:
DWORD v; uint32_t v;
inline bool isFromConstraint(void); inline bool isFromConstraint(void);
inline hConstraint constraint(void); inline hConstraint constraint(void);
@ -695,9 +695,9 @@ public:
static const int ORIGIN_TOP = 0x08; static const int ORIGIN_TOP = 0x08;
int textOrigin; int textOrigin;
double textAngle; double textAngle;
DWORD color; uint32_t color;
bool filled; bool filled;
DWORD fillColor; uint32_t fillColor;
bool visible; bool visible;
bool exportable; bool exportable;
@ -706,7 +706,7 @@ public:
typedef struct { typedef struct {
hStyle h; hStyle h;
char *cnfPrefix; char *cnfPrefix;
DWORD color; uint32_t color;
double width; double width;
} Default; } Default;
static const Default Defaults[]; static const Default Defaults[];
@ -720,16 +720,16 @@ public:
static void FreezeDefaultStyles(void); static void FreezeDefaultStyles(void);
static void LoadFactoryDefaults(void); static void LoadFactoryDefaults(void);
static void AssignSelectionToStyle(DWORD v); static void AssignSelectionToStyle(uint32_t v);
static DWORD CreateCustomStyle(void); static uint32_t CreateCustomStyle(void);
static DWORD RewriteColor(DWORD rgb); static uint32_t RewriteColor(uint32_t rgb);
static Style *Get(hStyle hs); static Style *Get(hStyle hs);
static DWORD Color(hStyle hs, bool forExport=false); static uint32_t Color(hStyle hs, bool forExport=false);
static DWORD FillColor(hStyle hs, bool forExport=false); static uint32_t FillColor(hStyle hs, bool forExport=false);
static float Width(hStyle hs); static float Width(hStyle hs);
static DWORD Color(int hs, bool forExport=false); static uint32_t Color(int hs, bool forExport=false);
static float Width(int hs); static float Width(int hs);
static double WidthMm(int hs); static double WidthMm(int hs);
static double TextHeight(hStyle hs); static double TextHeight(hStyle hs);

View File

@ -51,19 +51,13 @@ inline double ffabs(double v) { return (v > 0) ? v : (-v); }
#define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#') #define isforname(c) (isalnum(c) || (c) == '_' || (c) == '-' || (c) == '#')
typedef unsigned __int64 QWORD; #include <stdint.h>
typedef signed __int64 SQWORD;
typedef signed long SDWORD;
typedef signed short SWORD;
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h>
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <windows.h> // required for GL stuff
#include <gl/gl.h>
#include <gl/glu.h>
inline double Random(double vmax) { inline double Random(double vmax) {
return (vmax*rand()) / RAND_MAX; return (vmax*rand()) / RAND_MAX;
@ -76,6 +70,15 @@ class ExprQuaternion;
//================ //================
// From the platform-specific code. // From the platform-specific code.
#if !defined(WIN32)
#include <limits.h>
#define MAX_PATH PATH_MAX
#include <algorithm>
using std::min;
using std::max;
#endif
#define MAX_RECENT 8 #define MAX_RECENT 8
#define RECENT_OPEN (0xf000) #define RECENT_OPEN (0xf000)
#define RECENT_IMPORT (0xf100) #define RECENT_IMPORT (0xf100)
@ -116,22 +119,22 @@ int SaveFileYesNoCancel(void);
// Comma-separated value, like a spreadsheet would use // Comma-separated value, like a spreadsheet would use
#define CSV_PATTERN "CSV File (*.csv)\0*.csv\0All Files (*)\0*\0\0" #define CSV_PATTERN "CSV File (*.csv)\0*.csv\0All Files (*)\0*\0\0"
#define CSV_EXT "csv" #define CSV_EXT "csv"
BOOL GetSaveFile(char *file, char *defExtension, char *selPattern); bool GetSaveFile(char *file, char *defExtension, char *selPattern);
BOOL GetOpenFile(char *file, char *defExtension, char *selPattern); bool GetOpenFile(char *file, char *defExtension, char *selPattern);
void GetAbsoluteFilename(char *file); void GetAbsoluteFilename(char *file);
void LoadAllFontFiles(void); void LoadAllFontFiles(void);
void OpenWebsite(char *url); void OpenWebsite(char *url);
void CheckMenuById(int id, BOOL checked); void CheckMenuById(int id, bool checked);
void EnableMenuById(int id, BOOL checked); void EnableMenuById(int id, bool checked);
void ShowGraphicsEditControl(int x, int y, char *s); void ShowGraphicsEditControl(int x, int y, char *s);
void HideGraphicsEditControl(void); void HideGraphicsEditControl(void);
BOOL GraphicsEditControlIsVisible(void); bool GraphicsEditControlIsVisible(void);
void ShowTextEditControl(int x, int y, char *s); void ShowTextEditControl(int x, int y, char *s);
void HideTextEditControl(void); void HideTextEditControl(void);
BOOL TextEditControlIsVisible(void); bool TextEditControlIsVisible(void);
void MoveTextScrollbarTo(int pos, int maxPos, int page); void MoveTextScrollbarTo(int pos, int maxPos, int page);
#define CONTEXT_SUBMENU (-1) #define CONTEXT_SUBMENU (-1)
@ -140,31 +143,31 @@ void AddContextMenuItem(char *legend, int id);
void CreateContextSubmenu(void); void CreateContextSubmenu(void);
int ShowContextMenu(void); int ShowContextMenu(void);
void ShowTextWindow(BOOL visible); void ShowTextWindow(bool visible);
void InvalidateText(void); void InvalidateText(void);
void InvalidateGraphics(void); void InvalidateGraphics(void);
void PaintGraphics(void); void PaintGraphics(void);
void GetGraphicsWindowSize(int *w, int *h); void GetGraphicsWindowSize(int *w, int *h);
void GetTextWindowSize(int *w, int *h); void GetTextWindowSize(int *w, int *h);
SDWORD GetMilliseconds(void); int32_t GetMilliseconds(void);
SQWORD GetUnixTime(void); int64_t GetUnixTime(void);
void dbp(char *str, ...); void dbp(const char *str, ...);
#define DBPTRI(tri) \ #define DBPTRI(tri) \
dbp("tri: (%.3f %.3f %.3f) (%.3f %.3f %.3f) (%.3f %.3f %.3f)", \ dbp("tri: (%.3f %.3f %.3f) (%.3f %.3f %.3f) (%.3f %.3f %.3f)", \
CO((tri).a), CO((tri).b), CO((tri).c)) CO((tri).a), CO((tri).b), CO((tri).c))
void SetWindowTitle(char *str); void SetWindowTitle(char *str);
void SetMousePointerToHand(bool yes); void SetMousePointerToHand(bool yes);
void DoMessageBox(char *str, int rows, int cols, BOOL error); void DoMessageBox(char *str, int rows, int cols, bool error);
void SetTimerFor(int milliseconds); void SetTimerFor(int milliseconds);
void ExitNow(void); void ExitNow(void);
void CnfFreezeString(char *str, char *name); void CnfFreezeString(char *str, char *name);
void CnfFreezeDWORD(DWORD v, char *name); void CnfFreezeuint32_t(uint32_t v, char *name);
void CnfFreezeFloat(float v, char *name); void CnfFreezeFloat(float v, char *name);
void CnfThawString(char *str, int maxLen, char *name); void CnfThawString(char *str, int maxLen, char *name);
DWORD CnfThawDWORD(DWORD v, char *name); uint32_t CnfThawuint32_t(uint32_t v, char *name);
float CnfThawFloat(float v, char *name); float CnfThawFloat(float v, char *name);
void *AllocTemporary(int n); void *AllocTemporary(int n);
@ -202,11 +205,16 @@ void glxVertex3v(Vector u);
void glxAxisAlignedQuad(double l, double r, double t, double b); void glxAxisAlignedQuad(double l, double r, double t, double b);
void glxAxisAlignedLineLoop(double l, double r, double t, double b); void glxAxisAlignedLineLoop(double l, double r, double t, double b);
#define DEFAULT_TEXT_HEIGHT (11.5) #define DEFAULT_TEXT_HEIGHT (11.5)
#if defined(WIN32)
#define GLX_CALLBACK __stdcall #define GLX_CALLBACK __stdcall
#else
#define GLX_CALLBACK
#endif
typedef void GLX_CALLBACK glxCallbackFptr(void); typedef void GLX_CALLBACK glxCallbackFptr(void);
struct GLUtesselator;
void glxTesselatePolygon(GLUtesselator *gt, SPolygon *p); void glxTesselatePolygon(GLUtesselator *gt, SPolygon *p);
void glxFillPolygon(SPolygon *p); void glxFillPolygon(SPolygon *p);
void glxFillMesh(int color, SMesh *m, DWORD h, DWORD s1, DWORD s2); void glxFillMesh(int color, SMesh *m, uint32_t h, uint32_t s1, uint32_t s2);
void glxDebugPolygon(SPolygon *p); void glxDebugPolygon(SPolygon *p);
void glxDrawEdges(SEdgeList *l, bool endpointsToo); void glxDrawEdges(SEdgeList *l, bool endpointsToo);
void glxDebugMesh(SMesh *m); void glxDebugMesh(SMesh *m);
@ -218,14 +226,14 @@ void glxWriteTextRefCenter(char *str, double h, Vector t, Vector u, Vector v,
glxLineFn *fn, void *fndata); glxLineFn *fn, void *fndata);
double glxStrWidth(char *str, double h); double glxStrWidth(char *str, double h);
double glxStrHeight(double h); double glxStrHeight(double h);
void glxLockColorTo(DWORD rgb); void glxLockColorTo(uint32_t rgb);
void glxFatLine(Vector a, Vector b, double width); void glxFatLine(Vector a, Vector b, double width);
void glxUnlockColor(void); void glxUnlockColor(void);
void glxColorRGB(DWORD rgb); void glxColorRGB(uint32_t rgb);
void glxColorRGBa(DWORD rgb, double a); void glxColorRGBa(uint32_t rgb, double a);
void glxDepthRangeOffset(int units); void glxDepthRangeOffset(int units);
void glxDepthRangeLockToFront(bool yes); void glxDepthRangeLockToFront(bool yes);
void glxDrawPixelsWithTexture(BYTE *data, int w, int h); void glxDrawPixelsWithTexture(uint8_t *data, int w, int h);
void glxCreateBitmapFont(void); void glxCreateBitmapFont(void);
void glxBitmapText(char *str, Vector p); void glxBitmapText(char *str, Vector p);
void glxBitmapCharQuad(char c, double x, double y); void glxBitmapCharQuad(char c, double x, double y);
@ -242,12 +250,12 @@ void MakeMatrix(double *mat, double a11, double a12, double a13, double a14,
double a21, double a22, double a23, double a24, double a21, double a22, double a23, double a24,
double a31, double a32, double a33, double a34, double a31, double a32, double a33, double a34,
double a41, double a42, double a43, double a44); double a41, double a42, double a43, double a44);
void MakePathRelative(char *base, char *path); void MakePathRelative(const char *base, char *path);
void MakePathAbsolute(char *base, char *path); void MakePathAbsolute(const char *base, char *path);
bool StringAllPrintable(char *str); bool StringAllPrintable(const char *str);
bool StringEndsIn(char *str, char *ending); bool StringEndsIn(const char *str, const char *ending);
void Message(char *str, ...); void Message(const char *str, ...);
void Error(char *str, ...); void Error(const char *str, ...);
class System { class System {
public: public:
@ -327,8 +335,8 @@ public:
typedef struct { typedef struct {
bool onCurve; bool onCurve;
bool lastInContour; bool lastInContour;
SWORD x; int16_t x;
SWORD y; int16_t y;
} FontPoint; } FontPoint;
typedef struct { typedef struct {
@ -373,9 +381,9 @@ public:
Vector origin, u, v; Vector origin, u, v;
int Getc(void); int Getc(void);
int GetBYTE(void); int Getuint8_t(void);
int GetWORD(void); int Getuint16_t(void);
int GetDWORD(void); int Getuint32_t(void);
void LoadGlyph(int index); void LoadGlyph(int index);
bool LoadFontFromFile(bool nameOnly); bool LoadFontFromFile(bool nameOnly);
@ -433,10 +441,10 @@ public:
void BezierAsPwl(SBezier *sb); void BezierAsPwl(SBezier *sb);
void BezierAsNonrationalCubic(SBezier *sb, int depth=0); void BezierAsNonrationalCubic(SBezier *sb, int depth=0);
virtual void StartPath( DWORD strokeRgb, double lineWidth, virtual void StartPath( uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb) = 0; bool filled, uint32_t fillRgb) = 0;
virtual void FinishPath(DWORD strokeRgb, double lineWidth, virtual void FinishPath(uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb) = 0; bool filled, uint32_t fillRgb) = 0;
virtual void Bezier(SBezier *sb) = 0; virtual void Bezier(SBezier *sb) = 0;
virtual void Triangle(STriangle *tr) = 0; virtual void Triangle(STriangle *tr) = 0;
virtual void StartFile(void) = 0; virtual void StartFile(void) = 0;
@ -445,10 +453,10 @@ public:
}; };
class DxfFileWriter : public VectorFileWriter { class DxfFileWriter : public VectorFileWriter {
public: public:
void StartPath( DWORD strokeRgb, double lineWidth, void StartPath( uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void FinishPath(DWORD strokeRgb, double lineWidth, void FinishPath(uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void Triangle(STriangle *tr); void Triangle(STriangle *tr);
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
@ -460,10 +468,10 @@ public:
Vector prevPt; Vector prevPt;
void MaybeMoveTo(Vector s, Vector f); void MaybeMoveTo(Vector s, Vector f);
void StartPath( DWORD strokeRgb, double lineWidth, void StartPath( uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void FinishPath(DWORD strokeRgb, double lineWidth, void FinishPath(uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void Triangle(STriangle *tr); void Triangle(STriangle *tr);
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
@ -472,15 +480,15 @@ public:
}; };
class PdfFileWriter : public VectorFileWriter { class PdfFileWriter : public VectorFileWriter {
public: public:
DWORD xref[10]; uint32_t xref[10];
DWORD bodyStart; uint32_t bodyStart;
Vector prevPt; Vector prevPt;
void MaybeMoveTo(Vector s, Vector f); void MaybeMoveTo(Vector s, Vector f);
void StartPath( DWORD strokeRgb, double lineWidth, void StartPath( uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void FinishPath(DWORD strokeRgb, double lineWidth, void FinishPath(uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void Triangle(STriangle *tr); void Triangle(STriangle *tr);
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
@ -492,10 +500,10 @@ public:
Vector prevPt; Vector prevPt;
void MaybeMoveTo(Vector s, Vector f); void MaybeMoveTo(Vector s, Vector f);
void StartPath( DWORD strokeRgb, double lineWidth, void StartPath( uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void FinishPath(DWORD strokeRgb, double lineWidth, void FinishPath(uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void Triangle(STriangle *tr); void Triangle(STriangle *tr);
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
@ -505,10 +513,10 @@ public:
class HpglFileWriter : public VectorFileWriter { class HpglFileWriter : public VectorFileWriter {
public: public:
static double MmToHpglUnits(double mm); static double MmToHpglUnits(double mm);
void StartPath( DWORD strokeRgb, double lineWidth, void StartPath( uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void FinishPath(DWORD strokeRgb, double lineWidth, void FinishPath(uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void Triangle(STriangle *tr); void Triangle(STriangle *tr);
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
@ -517,10 +525,10 @@ public:
}; };
class Step2dFileWriter : public VectorFileWriter { class Step2dFileWriter : public VectorFileWriter {
StepFileWriter sfw; StepFileWriter sfw;
void StartPath( DWORD strokeRgb, double lineWidth, void StartPath( uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void FinishPath(DWORD strokeRgb, double lineWidth, void FinishPath(uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void Triangle(STriangle *tr); void Triangle(STriangle *tr);
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
@ -530,10 +538,10 @@ class Step2dFileWriter : public VectorFileWriter {
class GCodeFileWriter : public VectorFileWriter { class GCodeFileWriter : public VectorFileWriter {
public: public:
SEdgeList sel; SEdgeList sel;
void StartPath( DWORD strokeRgb, double lineWidth, void StartPath( uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void FinishPath(DWORD strokeRgb, double lineWidth, void FinishPath(uint32_t strokeRgb, double lineWidth,
bool filled, DWORD fillRgb); bool filled, uint32_t fillRgb);
void Triangle(STriangle *tr); void Triangle(STriangle *tr);
void Bezier(SBezier *sb); void Bezier(SBezier *sb);
void StartFile(void); void StartFile(void);
@ -618,7 +626,7 @@ public:
int drawBackFaces; int drawBackFaces;
int checkClosedContour; int checkClosedContour;
int showToolbar; int showToolbar;
DWORD backgroundColor; uint32_t backgroundColor;
int exportShadedTriangles; int exportShadedTriangles;
int exportPwlCurves; int exportPwlCurves;
int exportCanvasSizeAuto; int exportCanvasSizeAuto;
@ -736,7 +744,7 @@ public:
Vector ptB; Vector ptB;
} extraLine; } extraLine;
struct { struct {
BYTE *fromFile; uint8_t *fromFile;
int w, h; int w, h;
int rw, rh; int rw, rh;
double scale; // pixels per mm double scale; // pixels per mm

View File

@ -56,12 +56,12 @@ class SShell;
class hSSurface { class hSSurface {
public: public:
DWORD v; uint32_t v;
}; };
class hSCurve { class hSCurve {
public: public:
DWORD v; uint32_t v;
}; };
// Stuff for rational polynomial curves, of degree one to three. These are // Stuff for rational polynomial curves, of degree one to three. These are
@ -222,7 +222,7 @@ public:
Vector start; Vector start;
Vector finish; Vector finish;
static STrimBy STrimBy::EntireCurve(SShell *shell, hSCurve hsc, bool bkwds); static STrimBy EntireCurve(SShell *shell, hSCurve hsc, bool bkwds);
}; };
// An intersection point between a line and a surface // An intersection point between a line and a surface
@ -247,7 +247,7 @@ public:
hSSurface newH; hSSurface newH;
int color; int color;
DWORD face; uint32_t face;
int degm, degn; int degm, degn;
Vector ctrl[4][4]; Vector ctrl[4][4];
@ -275,7 +275,7 @@ public:
void EdgeNormalsWithinSurface(Point2d auv, Point2d buv, void EdgeNormalsWithinSurface(Point2d auv, Point2d buv,
Vector *pt, Vector *enin, Vector *enout, Vector *pt, Vector *enin, Vector *enout,
Vector *surfn, Vector *surfn,
DWORD auxA, uint32_t auxA,
SShell *shell, SShell *sha, SShell *shb); SShell *shell, SShell *sha, SShell *shb);
void FindChainAvoiding(SEdgeList *src, SEdgeList *dest, SPointList *avoid); void FindChainAvoiding(SEdgeList *src, SEdgeList *dest, SPointList *avoid);
SSurface MakeCopyTrimAgainst(SShell *parent, SShell *a, SShell *b, SSurface MakeCopyTrimAgainst(SShell *parent, SShell *a, SShell *b,

View File

@ -45,10 +45,10 @@ bool System::WriteJacobian(int tag) {
f = f->FoldConstants(); f = f->FoldConstants();
// Hash table (61 bits) to accelerate generation of zero partials. // Hash table (61 bits) to accelerate generation of zero partials.
QWORD scoreboard = f->ParamsUsed(); uint64_t scoreboard = f->ParamsUsed();
for(j = 0; j < mat.n; j++) { for(j = 0; j < mat.n; j++) {
Expr *pd; Expr *pd;
if(scoreboard & ((QWORD)1 << (mat.param[j].v % 61)) && if(scoreboard & ((uint64_t)1 << (mat.param[j].v % 61)) &&
f->DependsOn(mat.param[j])) f->DependsOn(mat.param[j]))
{ {
pd = f->PartialWrt(mat.param[j]); pd = f->PartialWrt(mat.param[j]);
@ -449,7 +449,7 @@ int System::Solve(Group *g, int *dof, List<hConstraint> *bad,
EvalJacobian(); EvalJacobian();
int rank = CalculateRank(); int rank; rank = CalculateRank();
if(rank != mat.m) { if(rank != mat.m) {
if(andFindBad) { if(andFindBad) {
FindWhichToRemoveToFixJacobian(g, bad); FindWhichToRemoveToFixJacobian(g, bad);

146
src/ui.h
View File

@ -47,14 +47,14 @@ public:
int scrollPos; // The scrollbar position, in half-row units int scrollPos; // The scrollbar position, in half-row units
int halfRows; // The height of our window, in half-row units int halfRows; // The height of our window, in half-row units
BYTE text[MAX_ROWS][MAX_COLS]; uint8_t text[MAX_ROWS][MAX_COLS];
typedef void LinkFunction(int link, DWORD v); typedef void LinkFunction(int link, uint32_t v);
static const int NOT_A_LINK = 0; static const int NOT_A_LINK = 0;
struct { struct {
char fg; char fg;
int bg; int bg;
int link; int link;
DWORD data; uint32_t data;
LinkFunction *f; LinkFunction *f;
LinkFunction *h; LinkFunction *h;
} meta[MAX_ROWS][MAX_COLS]; } meta[MAX_ROWS][MAX_COLS];
@ -67,7 +67,7 @@ public:
// The row of icons at the top of the text window, to hide/show things // The row of icons at the top of the text window, to hide/show things
typedef struct { typedef struct {
bool *var; bool *var;
BYTE *icon; uint8_t *icon;
char *tip; char *tip;
} HideShowIcon; } HideShowIcon;
static HideShowIcon hideShowIcons[]; static HideShowIcon hideShowIcons[];
@ -89,8 +89,8 @@ public:
HideShowIcon *hoveredIcon, *tooltippedIcon; HideShowIcon *hoveredIcon, *tooltippedIcon;
Vector HsvToRgb(Vector hsv); Vector HsvToRgb(Vector hsv);
BYTE *HsvPattern2d(void); uint8_t *HsvPattern2d(void);
BYTE *HsvPattern1d(double h, double s); uint8_t *HsvPattern1d(double h, double s);
void ColorPickerDone(void); void ColorPickerDone(void);
bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y); bool DrawOrHitTestColorPicker(int how, bool leftDown, double x, double y);
@ -196,7 +196,7 @@ public:
int col; int col;
struct { struct {
DWORD rgb; uint32_t rgb;
double h, s, v; double h, s, v;
bool show; bool show;
bool picker1dActive; bool picker1dActive;
@ -206,7 +206,7 @@ public:
void HideEditControl(void); void HideEditControl(void);
void ShowEditControl(int halfRow, int col, char *s); void ShowEditControl(int halfRow, int col, char *s);
void ShowEditControlWithColorPicker(int halfRow, int col, DWORD rgb); void ShowEditControlWithColorPicker(int halfRow, int col, uint32_t rgb);
void ClearSuper(void); void ClearSuper(void);
@ -230,82 +230,82 @@ public:
// All of these are callbacks from the GUI code; first from when // All of these are callbacks from the GUI code; first from when
// we're describing an entity // we're describing an entity
static void ScreenEditTtfText(int link, DWORD v); static void ScreenEditTtfText(int link, uint32_t v);
static void ScreenSetTtfFont(int link, DWORD v); static void ScreenSetTtfFont(int link, uint32_t v);
static void ScreenUnselectAll(int link, DWORD v); static void ScreenUnselectAll(int link, uint32_t v);
// and the rest from the stuff in textscreens.cpp // and the rest from the stuff in textscreens.cpp
static void ScreenSelectGroup(int link, DWORD v); static void ScreenSelectGroup(int link, uint32_t v);
static void ScreenActivateGroup(int link, DWORD v); static void ScreenActivateGroup(int link, uint32_t v);
static void ScreenToggleGroupShown(int link, DWORD v); static void ScreenToggleGroupShown(int link, uint32_t v);
static void ScreenHowGroupSolved(int link, DWORD v); static void ScreenHowGroupSolved(int link, uint32_t v);
static void ScreenShowGroupsSpecial(int link, DWORD v); static void ScreenShowGroupsSpecial(int link, uint32_t v);
static void ScreenDeleteGroup(int link, DWORD v); static void ScreenDeleteGroup(int link, uint32_t v);
static void ScreenHoverConstraint(int link, DWORD v); static void ScreenHoverConstraint(int link, uint32_t v);
static void ScreenHoverRequest(int link, DWORD v); static void ScreenHoverRequest(int link, uint32_t v);
static void ScreenSelectRequest(int link, DWORD v); static void ScreenSelectRequest(int link, uint32_t v);
static void ScreenSelectConstraint(int link, DWORD v); static void ScreenSelectConstraint(int link, uint32_t v);
static void ScreenChangeGroupOption(int link, DWORD v); static void ScreenChangeGroupOption(int link, uint32_t v);
static void ScreenColor(int link, DWORD v); static void ScreenColor(int link, uint32_t v);
static void ScreenShowListOfStyles(int link, DWORD v); static void ScreenShowListOfStyles(int link, uint32_t v);
static void ScreenShowStyleInfo(int link, DWORD v); static void ScreenShowStyleInfo(int link, uint32_t v);
static void ScreenDeleteStyle(int link, DWORD v); static void ScreenDeleteStyle(int link, uint32_t v);
static void ScreenChangeStyleYesNo(int link, DWORD v); static void ScreenChangeStyleYesNo(int link, uint32_t v);
static void ScreenCreateCustomStyle(int link, DWORD v); static void ScreenCreateCustomStyle(int link, uint32_t v);
static void ScreenLoadFactoryDefaultStyles(int link, DWORD v); static void ScreenLoadFactoryDefaultStyles(int link, uint32_t v);
static void ScreenAssignSelectionToStyle(int link, DWORD v); static void ScreenAssignSelectionToStyle(int link, uint32_t v);
static void ScreenBackgroundImage(int link, DWORD v); static void ScreenBackgroundImage(int link, uint32_t v);
static void ScreenShowConfiguration(int link, DWORD v); static void ScreenShowConfiguration(int link, uint32_t v);
static void ScreenShowEditView(int link, DWORD v); static void ScreenShowEditView(int link, uint32_t v);
static void ScreenGoToWebsite(int link, DWORD v); static void ScreenGoToWebsite(int link, uint32_t v);
static void ScreenChangeFixExportColors(int link, DWORD v); static void ScreenChangeFixExportColors(int link, uint32_t v);
static void ScreenChangeBackFaces(int link, DWORD v); static void ScreenChangeBackFaces(int link, uint32_t v);
static void ScreenChangeCheckClosedContour(int link, DWORD v); static void ScreenChangeCheckClosedContour(int link, uint32_t v);
static void ScreenChangePwlCurves(int link, DWORD v); static void ScreenChangePwlCurves(int link, uint32_t v);
static void ScreenChangeCanvasSizeAuto(int link, DWORD v); static void ScreenChangeCanvasSizeAuto(int link, uint32_t v);
static void ScreenChangeCanvasSize(int link, DWORD v); static void ScreenChangeCanvasSize(int link, uint32_t v);
static void ScreenChangeShadedTriangles(int link, DWORD v); static void ScreenChangeShadedTriangles(int link, uint32_t v);
static void ScreenStepDimSteps(int link, DWORD v); static void ScreenStepDimSteps(int link, uint32_t v);
static void ScreenStepDimFinish(int link, DWORD v); static void ScreenStepDimFinish(int link, uint32_t v);
static void ScreenStepDimGo(int link, DWORD v); static void ScreenStepDimGo(int link, uint32_t v);
static void ScreenChangeTangentArc(int link, DWORD v); static void ScreenChangeTangentArc(int link, uint32_t v);
static void ScreenPasteTransformed(int link, DWORD v); static void ScreenPasteTransformed(int link, uint32_t v);
static void ScreenHome(int link, DWORD v); static void ScreenHome(int link, uint32_t v);
// These ones do stuff with the edit control // These ones do stuff with the edit control
static void ScreenChangeExprA(int link, DWORD v); static void ScreenChangeExprA(int link, uint32_t v);
static void ScreenChangeGroupName(int link, DWORD v); static void ScreenChangeGroupName(int link, uint32_t v);
static void ScreenChangeGroupScale(int link, DWORD v); static void ScreenChangeGroupScale(int link, uint32_t v);
static void ScreenChangeLightDirection(int link, DWORD v); static void ScreenChangeLightDirection(int link, uint32_t v);
static void ScreenChangeLightIntensity(int link, DWORD v); static void ScreenChangeLightIntensity(int link, uint32_t v);
static void ScreenChangeColor(int link, DWORD v); static void ScreenChangeColor(int link, uint32_t v);
static void ScreenChangeChordTolerance(int link, DWORD v); static void ScreenChangeChordTolerance(int link, uint32_t v);
static void ScreenChangeMaxSegments(int link, DWORD v); static void ScreenChangeMaxSegments(int link, uint32_t v);
static void ScreenChangeCameraTangent(int link, DWORD v); static void ScreenChangeCameraTangent(int link, uint32_t v);
static void ScreenChangeGridSpacing(int link, DWORD v); static void ScreenChangeGridSpacing(int link, uint32_t v);
static void ScreenChangeDigitsAfterDecimal(int link, DWORD v); static void ScreenChangeDigitsAfterDecimal(int link, uint32_t v);
static void ScreenChangeExportScale(int link, DWORD v); static void ScreenChangeExportScale(int link, uint32_t v);
static void ScreenChangeExportOffset(int link, DWORD v); static void ScreenChangeExportOffset(int link, uint32_t v);
static void ScreenChangeGCodeParameter(int link, DWORD v); static void ScreenChangeGCodeParameter(int link, uint32_t v);
static void ScreenChangeStyleName(int link, DWORD v); static void ScreenChangeStyleName(int link, uint32_t v);
static void ScreenChangeStyleWidthOrTextHeight(int link, DWORD v); static void ScreenChangeStyleWidthOrTextHeight(int link, uint32_t v);
static void ScreenChangeStyleTextAngle(int link, DWORD v); static void ScreenChangeStyleTextAngle(int link, uint32_t v);
static void ScreenChangeStyleColor(int link, DWORD v); static void ScreenChangeStyleColor(int link, uint32_t v);
static void ScreenChangeBackgroundColor(int link, DWORD v); static void ScreenChangeBackgroundColor(int link, uint32_t v);
static void ScreenChangeBackgroundImageScale(int link, DWORD v); static void ScreenChangeBackgroundImageScale(int link, uint32_t v);
static void ScreenChangePasteTransformed(int link, DWORD v); static void ScreenChangePasteTransformed(int link, uint32_t v);
static void ScreenChangeViewScale(int link, DWORD v); static void ScreenChangeViewScale(int link, uint32_t v);
static void ScreenChangeViewOrigin(int link, DWORD v); static void ScreenChangeViewOrigin(int link, uint32_t v);
static void ScreenChangeViewProjection(int link, DWORD v); static void ScreenChangeViewProjection(int link, uint32_t v);
bool EditControlDoneForStyles(char *s); bool EditControlDoneForStyles(char *s);
bool EditControlDoneForConfiguration(char *s); bool EditControlDoneForConfiguration(char *s);
@ -620,7 +620,7 @@ public:
static const int CMNU_SNAP_TO_GRID = 0x140; static const int CMNU_SNAP_TO_GRID = 0x140;
static const int CMNU_FIRST_STYLE = 0x40000000; static const int CMNU_FIRST_STYLE = 0x40000000;
void ContextMenuListStyles(void); void ContextMenuListStyles(void);
SDWORD contextMenuCancelTime; int32_t contextMenuCancelTime;
// The toolbar, in toolbar.cpp // The toolbar, in toolbar.cpp
bool ToolbarDrawOrHitTest(int x, int y, bool paint, int *menu); bool ToolbarDrawOrHitTest(int x, int y, bool paint, int *menu);
@ -667,7 +667,7 @@ public:
bool KeyDown(int c); bool KeyDown(int c);
void EditControlDone(char *s); void EditControlDone(char *s);
SDWORD lastSpaceNavigatorTime; int32_t lastSpaceNavigatorTime;
hGroup lastSpaceNavigatorGroup; hGroup lastSpaceNavigatorGroup;
void SpaceNavigatorMoved(double tx, double ty, double tz, void SpaceNavigatorMoved(double tx, double ty, double tz,
double rx, double ry, double rz, bool shiftDown); double rx, double ry, double rz, bool shiftDown);

View File

@ -6,10 +6,10 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "solvespace.h" #include "solvespace.h"
void MakePathRelative(char *basep, char *pathp) void MakePathRelative(const char *basep, char *pathp)
{ {
int i; int i;
char *p; const char *p;
char base[MAX_PATH], path[MAX_PATH], out[MAX_PATH]; char base[MAX_PATH], path[MAX_PATH], out[MAX_PATH];
// Convert everything to lowercase // Convert everything to lowercase
@ -65,7 +65,7 @@ void MakePathRelative(char *basep, char *pathp)
strcpy(pathp, out); strcpy(pathp, out);
} }
void MakePathAbsolute(char *basep, char *pathp) { void MakePathAbsolute(const char *basep, char *pathp) {
char out[MAX_PATH]; char out[MAX_PATH];
strcpy(out, basep); strcpy(out, basep);
@ -83,9 +83,9 @@ void MakePathAbsolute(char *basep, char *pathp) {
strcpy(pathp, out); strcpy(pathp, out);
} }
bool StringAllPrintable(char *str) bool StringAllPrintable(const char *str)
{ {
char *t; const char *t;
for(t = str; *t; t++) { for(t = str; *t; t++) {
if(!(isalnum(*t) || *t == '-' || *t == '_')) { if(!(isalnum(*t) || *t == '-' || *t == '_')) {
return false; return false;
@ -94,7 +94,7 @@ bool StringAllPrintable(char *str)
return true; return true;
} }
bool StringEndsIn(char *str, char *ending) bool StringEndsIn(const char *str, const char *ending)
{ {
int i, ls = strlen(str), le = strlen(ending); int i, ls = strlen(str), le = strlen(ending);
@ -135,7 +135,7 @@ void MakeMatrix(double *mat, double a11, double a12, double a13, double a14,
// Word-wrap the string for our message box appropriately, and then display // Word-wrap the string for our message box appropriately, and then display
// that string. // that string.
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static void DoStringForMessageBox(char *str, va_list f, bool error) static void DoStringForMessageBox(const char *str, va_list f, bool error)
{ {
char inBuf[1024*50]; char inBuf[1024*50];
vsprintf(inBuf, str, f); vsprintf(inBuf, str, f);
@ -190,14 +190,14 @@ static void DoStringForMessageBox(char *str, va_list f, bool error)
// And then display the text with our actual longest line length. // And then display the text with our actual longest line length.
DoMessageBox(outBuf, rows, cols, error); DoMessageBox(outBuf, rows, cols, error);
} }
void Error(char *str, ...) void Error(const char *str, ...)
{ {
va_list f; va_list f;
va_start(f, str); va_start(f, str);
DoStringForMessageBox(str, f, true); DoStringForMessageBox(str, f, true);
va_end(f); va_end(f);
} }
void Message(char *str, ...) void Message(const char *str, ...)
{ {
va_list f; va_list f;
va_start(f, str); va_start(f, str);