With this commit, SolveSpace gains an Autotools build system and a new
platform-dependent backend implemented using the FLTK GUI toolkit. These
will allow the application to be built and run on Linux and other Unix-like
operating systems, and prospectively, MacOS X.
A number of new files have been added:
* Makefile.am: Automake makefile template; this contains some experimental
support for MinGW and MSVC++ builds that needs further development
* ac-aux/ax_fltk.m4: Autoconf M4 macro to locate and query the system's
installation of FLTK; this will eventually be contributed to the GNU
Autoconf Archive
* autogen.sh: Script to bootstrap the Autotools build system, usually for a
tree just checked out from source control
* configure.ac: Source for the Autoconf configure script; note that this
file specifies a version of 2.1, near the top
* fltk/fltkmain.cpp: Main FLTK backend implementation
* fltk/fltkutil.cpp: Utility functions for the FLTK backend
* fltk/xFl_Gl_Window_Group.{H,cxx}: Implementation of a new
Fl_Gl_Window_Group widget for FLTK, needed to facilitate drawing FLTK
widgets on top of OpenGL graphics as SolveSpace does. This has been
submitted to the FLTK project for (hopefully) eventual upstream
inclusion:
http://www.fltk.org/str.php?L2992
The following minor changes are also a part of this commit:
* Makefile.msvc: Define PACKAGE_VERSION=2.1 for the benefit of
solvespace.cpp in MSVC++ builds
* solvespace.cpp: In the About dialog text, use PACKAGE_VERSION rather than
hard-coding the version of the program
* solvespace.h: Don't define the C99 integer types if
HAVE_C99_INTEGER_TYPES is defined, to facilitate MinGW builds
This function previously returned an int32_t. Presuming that it measures
the length of time since the application was started, the 32-bit type would
cause the returned value to wrap from 2^31-1 to -2^31 after a little less
than twenty-five days.
* Added "Show Menu Bar" and "Full Screen" menu items, which will be
implemented in the FLTK interface. These are currently prevented from
appearing in the Win32 interface by the HAVE_FLTK and
HAVE_FLTK_FULLSCREEN macros.
* Moved the "Show Text Window" down below the "Show Toolbar" item, so that
"Show Menu Bar", "Show Toolbar" and "Show Text Window" are in the same
vertical order as their corresponding UI elements typically take on
* Added new platform-dependent routines to back the new menu items:
void ToggleMenuBar(void);
bool MenuBarIsVisible(void);
void ToggleFullScreen(void);
bool FullScreenIsActive(void);
These are stubs in the Win32 code.
* Fleshed out the system header #includes in solvespace.h, and moved them
to the top of the file per convention
* Rewrote the file dialog selection patterns in terms of macros that allow
them to expand to either the FLTK or Windows formats
* Don't use __stdcall in SSGL_CALLBACK, and make SSGL_CALLBACK 'extern "C"'
as OpenGL usually expects function pointers to point to C functions
The "glx" prefix on the names of SolveSpace's various GL helper routines
was confusingly similar to those used by official OpenGL-associated
libraries (e.g. "glu" used by the GL Utility library, and "glX" used by
GLX), and could thus give the erroneous impression that it represented a
system API rather than ordinary application logic. We thus rename these
routines to have an "ssgl" prefix, clearly identifying them with SolveSpace
while retaining some visual kinship to GL function names.
GCC and Clang's -Wfloat-equal warning notes that comparing floating-point
values with == or != may be questionable. But the few instances of these in
SolveSpace are defensibly correct (as discussed with Jonathan), so to keep
folks from getting nervous that a CAD application isn't handling its floats
correctly, we define an EXACT() macro inside which the -Wfloat-equal
warning is disabled. This macro will also serve as a source-code
annotation, like a comment but better.
(The warning is only disabled for Clang, alas, because GCC is particular
about where _Pragma() can be used. This isn't so bad, however, because the
warning is much easier to enable on Clang [thanks to -Weverything], whereas
with GCC it has to be requested explicitly.)
This commit consists of numerous small changes, none significant enough to
merit a commit on their own:
* Added extra braces to quash for-loop variable scoping issues for older
compilers (or "g++ -fno-for-scope")
* Appeased "unreachable code" warnings, spurious or otherwise
* Added casts to fix integer-variable signedness warnings
* Added a dummy virtual method to the VectorFileWriter class to silence the
-Wweak-vtables warning from Clang++
* Renamed some parameters in the Expr and GraphicsWindow classes to
eliminate "parameter shadows a field" warnings
* Removed an inert "0 ||" from a conditional, and changed a "&& 0" into an
"#if 0"
* Added missing elements to array/struct/class initializers to zap further
warnings
* Indented some cpp conditionals where appropriate
* Qualified some variables and functions as static to quiet "no previous
declaration" warnings
* toolbar.cpp needed to #include<icons-proto.h> to fix those same "no
previous declaration" warnings from icons.h
* Added some casts and const qualifiers to the Win32 code to address
warnings produced by g++ when compiling under MinGW
* Rewrote Cnf{Freeze,Thaw}Float() to use a union rather than pointer
aliasing; this makes g++ a lot happier
* Removed redundant #includes from win32/w32util.cpp
* With Jonathan's blessing, shortened the last line of the About dialog
text to better match the preceding lines
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.
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
GraphicsWindow::menu[] previously recorded both item names (e.g. "Open...")
and accelerator labels ("Ctrl+O") in .label, and accelerator key/mask
values in .accel. Not only were the accelerator labels redundant given the
latter, they are not needed by GUI toolkits like FLTK, which generate them
from key/mask values.
So we remove the accelerator portion from each menu-item label, and define
a new MakeAcceleratorLabel() routine which takes a key/mask value and
returns the appropriate label. We make use of this new routine in
CreateGraphicsWindowMenus() and GraphicsWindow::ToolbarDrawOrHitTest().
This commit contains a grab bag of minor changes not worth committing
individually:
* Replaced raw Latin-1 characters with octal escapes to avoid source-file
encoding issues
* Undefined some convenience macros after they've served their purpose
* Rewrote SEdge::From() to avoid confusing less-capable C++ compilers
* Have oops() print a newline at the end of its message
* Removed "static" keyword from the Bernstein() function definition, as it
has a non-static prototype in srf/surface.h
* Added casts (and changed a variable type) to quell warnings about integer
size and signedness
* Simplified an expression with our handy arraylen() macro
Some menu items in the menu-bar are toggles (each representing an option
that can be turned on or off independently), and some are 1-of-N selections
(e.g. mm or inches), like tuner buttons on a car radio. Windows can draw an
optional check-mark besides a menu item, and SolveSpace has been using this
feature to implement both kinds of menu items, with the backend logic
making them behave as a toggle or radio button as appropriate.
Other GUI platforms can draw proper radio-button menu items that are
distinct from toggles, however. To allow the platform-specific logic to
tell the two kinds of menu items apart, this change adds the
RadioMenuById() routine, and replaces the appropriate calls to
CheckMenuById() with it. (Note that nothing is changed in the Windows GUI
code; radio-menu items are still drawn with check-marks.)
The Valgrind tool can give a full accounting of what memory allocations
have yet to be free()d when the program exits. It is easier to find actual
memory leaks in the code if all non-leaked allocations are elided from that
accounting, which is most easily accomplished by free()ing them.
The "most" qualifier is there because some allocations are difficult/
impossible to free, as they are internal to libraries like OpenGL and Xft.
The best we can hope for is to cover all allocations made by SolveSpace
directly.
This function was returning ID{YES,NO,CANCEL}, which are specific to
Windows as return values for MessageBox(). These have been replaced with
SAVE_{YES,NO,CANCEL}, which we define ourselves.
This addresses a grab bag of compiler grievances relating to C++ syntax,
type, and scope, as observed on Linux with g++ and Solaris with Sun
WorkShop 6.
Having e.g. GetWORD() return a WORD rather than int eliminates the need for
a cast when assigning to WORD variables. We use casts only when assigning
to a different (but same-sized) type.
Also, check for EOF explicitly when calling fgetc().
String literals in C++ are implicitly typed as 'const char *', and with
this change, their const-ness is maintained when assigning them to
variables or passing them as arguments. This significantly cuts down the
number of warnings generated by the compiler.
as they are displayed on the drawing, and for many other places) a
user-configurable parameter.
Also reshuffle some options in the configuration screen, to put all
the stuff relating to exports together.
[git-p4: depot-paths = "//depot/solvespace/": change = 2179]
of that, where you can pick the hue and blackness, and then the
whiteness) color picker and some swatches.
This is used in three places now: the special colors in the config
screen, the background color, and the style colors.
[git-p4: depot-paths = "//depot/solvespace/": change = 2174]
in the text window. This means that I can move the conversion from
half-row and column to (x, y) into the platform-independent code,
and that I'll be ready to add my color picker.
[git-p4: depot-paths = "//depot/solvespace/": change = 2171]
circles, using a numerical method. And the user can specify a
radius, instead of letting us choose automatically, and specify
whether the original lines should be kept and made construction, or
deleted.
[git-p4: depot-paths = "//depot/solvespace/": change = 2146]
default, let's do a "use perspective projection" item that's off by
default. Same meaning, but less confusion.
[git-p4: depot-paths = "//depot/solvespace/": change = 2132]
to draw those, and hit test with the mouse, and display tool tips
when the user hovers with the mouse. Also, underline links only
when they're hovered, and not otherwise.
And add a separate menu option to align the view to the active
workplane, vs. activating the active group's workplane, and
remap the bottom two graphics window toolbar icons to that and
"nearest iso view" instead of draw in 2d/3d, since people tended
to click on those without understanding and cause trouble.
And by default, we force a parallel projection; so the factory
default camera tangent is now 0.3, not 0.
[git-p4: depot-paths = "//depot/solvespace/": change = 2131]
code. This is now drawn using gl, and the bitmap font (both there
and in the graphics window) is drawn from a texture from a static
table, not from the Win32 functions, since that's ~1000x faster.
So this adds a tool to generate that table. With luck that will
also fix my font issues under WINE, which won't have to render the
TTF itself.
Still needs some cleanup, and to make all the cosmetic improvements
that I want.
[git-p4: depot-paths = "//depot/solvespace/": change = 2130]
File -> New or File -> Open, I freed the Group structures
themselves, but none of their children.
[git-p4: depot-paths = "//depot/solvespace/": change = 2120]
consistently across multiple versionf of Windows, and perhaps not
be immediately ignored by the user.
[git-p4: depot-paths = "//depot/solvespace/": change = 2108]
exporting our view to any file that doesn't have a canvas size (and
therefore doesn't get everything shifted to fit with the requested
margins around it in the canvas).
[git-p4: depot-paths = "//depot/solvespace/": change = 2107]
requires user interface to specify the depth, number of passes,
feed, and plunge feed, unfortunately.
[git-p4: depot-paths = "//depot/solvespace/": change = 2106]
rotation. Also clean up the handling of units, by putting the
conversion factors in only one place, and clean up the
expression-parsing but removing all the copies of the same error
message.
[git-p4: depot-paths = "//depot/solvespace/": change = 2093]
does that, and adds a scale factor to that transformation (instead
of just mirroring, as before), but also:
* Replace the "import mirrored" mechanism with a scale factor,
which if negative corresponds to a reflection as well.
* Fix self-intersection checker to report a meaningful point
when edges are collinear.
* Don't blow an assertion on some types of invalid file;
instead provide a nice error message to the user.
* Clear the naked edges before each regen.
* Don't create zero-length line segments by snapping a line
segment's end to its beginning.
[git-p4: depot-paths = "//depot/solvespace/": change = 2086]
only in a workplane; but this means that plane sketches are
conveniently transformed from one plane to another.
Also tweak snap to grid to ignore unsnappable entities instead of
triggering an error, and to remove arbitrary limit on the number of
entities / comments that will be snapped.
[git-p4: depot-paths = "//depot/solvespace/": change = 2084]
load it as a texture, and show it instead of a flat-color
background. Includes user interface to specify scale and
translation of image, but the rotation is always aligned to the
view.
[git-p4: depot-paths = "//depot/solvespace/": change = 2071]
one point to be dragged simultaneously. So now a dragged point
drags all the selected points and entities, and a dragged entity
drags its points (except for circles, which drag the radius).
This means that the number of forced points for the solver must now
be unlimited, and it is.
Also add commands to invert the selection within the active group,
and to select an edge chain starting from the current selection.
And redo the context menus a bit; still not great, but less
cluttered and more systematic.
[git-p4: depot-paths = "//depot/solvespace/": change = 2064]
also means that closed contours will get output as a single path
now, vs. one open path per Bezier segment before.
I've simplified the 2d/3d wireframe export targets somewhat; they
now support only Beziers, without an additional special case for
line segments. The performance penalty for that should not be worth
caring about, since that's infrequent.
And fix a memory leak in FindOuterFacesFrom(), fix ugly output of
filled triangles in PDF (because the line join style did bad things
on long skinny triangles), fix non-zero Z coordinates for exported
views or sections in DXF or STEP.
[git-p4: depot-paths = "//depot/solvespace/": change = 2061]
loop), and open-ended splines, with their tangents specified at
their endpoints.
Also change constraint solver matrix size to 1024, on the theory
that a power of two will generate better array indexing, and
replace fabs() with my own function that for some reason is
faster.
[git-p4: depot-paths = "//depot/solvespace/": change = 2055]
the same plumbing as the 2d vector output.
Also fix piecewise linear tolerance when the export scale factor is
not equal to one; have to scale the chord tol along with that.
[git-p4: depot-paths = "//depot/solvespace/": change = 2053]
instead of tying that to whether the shaded model is shown. And
rewrite all URLs to solvespace.com, not www.solvespace.com, and get
rid of the nag screen that I just added because opening the website
with ShellExecute seems to freeze a bit on startup.
[git-p4: depot-paths = "//depot/solvespace/": change = 2044]
perspective and parallel projections. Add a snap grid, for points
and for text comments. Draw text comments in the plane of their
workplane if they have one, otherwise always facing forward.
And fix a few nasty bugs: the possibility of an extremely long
animation onto a workplane, accidental use of the wrong style line
width for constraints, misplaced text box in style screen for
default styles, other little stuff.
[git-p4: depot-paths = "//depot/solvespace/": change = 2037]
Constraint::COMMENTs), including line width and color, and text
height and origin location.
[git-p4: depot-paths = "//depot/solvespace/": change = 2033]
formats, with the proper color and width. This may need a bit of
cleanup for stuff like the hidden line removal, which currently
loses the style.
Also fix a bug in the test for arcs of a circle. A second-order
Bezier with collinear control points really is an arc, but it's an
arc with infinite radius so stuff tends to blow up. So return false
for that one.
[git-p4: depot-paths = "//depot/solvespace/": change = 2030]
line width units, on-screen and export visibility. So now we can
use that to modify the default styles, or to create custom styles.
Also add code to draw fat lines, with round endcaps, since gl
doesn't do that.
Next we need some user interface to assign styles to entities, and
to make all the export file formats support the style attributes.
[git-p4: depot-paths = "//depot/solvespace/": change = 2029]