Commit Graph

766 Commits (52af72560616b754564ebf3ba8a85ab5849a982d)

Author SHA1 Message Date
Andrew Downing 023f404475 add LDFLAGS for FLTK to exposed/Makefile.am and src/Makefile.am 2015-02-25 22:47:35 -05:00
Andrew Downing ce77197dac display GraphicsEditControl in its own tooltip window avoiding the need to hack FLTKs internals 2015-02-25 12:43:01 -05:00
Andrew Downing 396b1c63a4 fix fltk code 2015-02-24 16:07:32 -05:00
Andrew Downing 1bfba0df5f fix fltk code 2015-02-24 15:54:27 -05:00
Marc Britten 0f334cc040 Added updated header information for surfaces 2015-02-08 10:43:19 -06:00
Petteri Aimonen 12a29ddce0 FLTK: Don't oops() when unknown mouse button is pressed.
For example forward/backward buttons are present on many mouses
but are not used by solvespace. This oops() caused solvespace to
crash whenever those buttons were (accidentally) pressed.
2014-12-29 22:33:19 +02:00
Petteri Aimonen 8996833989 Fix crash on Ubuntu when opening assembly files.
Ubuntu enables GCC's buffer overflow checks by default. In SAVEDptr
union, the path was declared as 'char', even though MAX_PATH memory
was actually allocated. The buffer overflow check mistakenly thought
that the buffer size was only 1 and aborted the program whenever it
tried to read a path from a file.
2014-12-29 22:16:21 +02:00
Jonathan Westhues e587d0ebee Fix GUI bugs in FLTK port, per Xavier Thomas's forum post:
"There was some small but annoying bugs with the FLTK port:
-cursor disappear sometimes
-not all the area of the windows (graphic and text windows) is accessible
by the mouse after a re-size
-input widget for editing constraints value are not correctly placed"
2014-05-11 15:43:03 -07:00
Ilya Novoselov f5297093c0 Fix automake "option 'subdir-objects' is disabled" warning 2014-04-10 23:05:17 +06:00
Ilya Novoselov 01213bcafb Rest of code assumes that allocated memory is filled with zeroes 2014-04-08 07:56:57 +06:00
Jonathan Westhues f4916f9ee4 Compare ((char *)p)[0] against '\0', not (char *)p.
Also make the library example compile again under MSVC, and make the
perl scripts to build the image tables work.
2013-12-08 00:32:50 -08:00
Daniel Richard G 1bc73c4a75 Renamed the RGB() macro to RGBi() to avoid collisions with Microsoft
Microsoft defines an RGB() macro that at one point was compatible with our
version (returning a packed integer containing 8-bit red, green and blue
channels), but is no longer, and the incompatibility led to an awkward
situation in w32main.cpp where we had to restore Microsoft's form of the
macro in order for the commctrl.h header to compile. By renaming the macro
to RGBi()---analogous to the RGBf() macro we already define---we avoid the
hassle entirely.
2013-12-02 04:27:34 -05:00
Daniel Richard G f9f321ca84 Warning fixes 2013-12-02 04:27:33 -05:00
Daniel Richard G 3cc520e98c Overhauled the exposed/ Makefile for MSVC++ 2013-12-02 04:27:33 -05:00
Daniel Richard G fd9dc19a34 Added the exposed/ library and demo program to the Autotools build
The libslvs library and CDemo program can now be built by Autotools. A few
code changes were needed for this: C++ comments in C code had to be
converted, constraint.cpp required some massaging, and fltkutil.cpp needed
a stub for InitHeaps().
2013-12-02 04:27:33 -05:00
Daniel Richard G 6c68294249 Improved handling of generated files
Place a pre-built copy of generated source files in src/built/, so that
users building SolveSpace from Git without the tools or setup necessary to
generate these can still complete the process.

Makefile.msvc: Use slashes consistently, and added rules to copy files from
src/built/ if needed

configure.ac: Check for presence of src/built/ at configure time

src/Makefile.am: Handle the generated *.table.h files together with
icon*.h; updated the source-generation rules so that the files are created
in builddir, not srcdir; added rules to copy files from src/built/ if
needed
2013-11-20 01:25:48 -05:00
Daniel Richard G 174ed76ef9 Added libspnav configure option and support to the Autotools build system 2013-11-19 18:17:55 -05:00
Daniel Richard G 4dffdb20e2 Added a .gitattributes file
This will allow checkouts of the SolveSpace source tree on Unix and Windows
to use the system's native line endings (i.e. LF vs. CRLF), while keeping
Unix line endings in the repository.

Created using the template at

	https://help.github.com/articles/dealing-with-line-endings
2013-11-19 18:17:55 -05:00
Daniel Richard G bb3e5e9bb1 Minor follow-up changes
solvespace.h: Need to #define MAX_PATH on POSIX systems

resource.rc: icon.ico now lives in the same directory as this file
2013-11-19 18:17:55 -05:00
Daniel Richard G 0a24cf40f0 Moved most of the source into a src/ subdirectory
The SolveSpace top-level directory was getting a bit cluttered, so
following the example of numerous other free-software projects, we move the
main application source into a subdirectory and adjust the build systems
accordingly.

Also, got rid of the obj/ directory in favor of creating it on the fly in
Makefile.msvc.
2013-11-19 18:17:32 -05:00
Daniel Richard G 5429295492 Use a union for pointer polymorphism in the .slvs file I/O routines
The .slvs file I/O code was using "*((type *)pointer) = value" type-punning
dereferences, which are syntactically unwieldy and prone to annoying modern
compilers. A union pointer is more elegant, and better expresses the
polymorphism at issue.
2013-11-13 00:46:40 -05:00
Daniel Richard G 442197c907 Updated the bundled LibPNG/zlib, and polished the MSVC makefile further
The bundled copies of LibPNG and zlib have been updated to the versions
shipped with FLTK (as these were convenient to build), and I've put in new
static libraries compiled with Visual Studio 2003 .NET. These libraries
link cleanly even with Visual Studio 2013 Express, so they should work for
just about every version of MSVC out there that can compile SolveSpace.

The MSVC makefile is also now a little nicer, and the SpaceWare Input
library header #includes have been adjusted to drop the si/ prefix (for
consistency with how LibPNG/zlib are handled).
2013-11-13 00:33:23 -05:00
Daniel Richard G 3a46c97fd0 Reorganized the extlib/ subdirectory
LibPNG and zlib have been moved into their own subdirectories, consistent
with the SpaceWare Input library
2013-11-13 00:23:06 -05:00
Jonathan Westhues 511c513035 Oops, fix Style.fillColor export/import too. 2013-11-03 15:41:11 -08:00
Jonathan Westhues f09ae15586 Fix broken colors in file import/export.
The move to RgbColor() missed the code that reads and writes Style.color
and Group.color. Also clarify redefinition of RGB() in w32main.cpp.
2013-11-03 15:09:17 -08:00
Daniel Richard G c60e3dd34e Initial Autotools and FLTK support
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
2013-10-28 01:28:42 -04:00
Daniel Richard G 7ca137f5fe Changed GetMilliseconds() to return a 64-bit value
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.
2013-10-28 00:43:38 -04:00
Daniel Richard G 873811d865 Preliminary changes for FLTK support
* 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
2013-10-28 00:43:38 -04:00
Daniel Richard G c6203678e1 Renamed GL helper routines/identifiers to use "ssgl" prefix instead of "glx"
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.
2013-10-28 00:43:38 -04:00
Daniel Richard G 0afb5618ce Quash warnings for floating-point equality comparisons
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.)
2013-10-28 00:43:37 -04:00
Daniel Richard G 8bc322eb47 Various fixes for warnings and minutia
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
2013-10-28 00:42:39 -04:00
Daniel Richard G a5176f4545 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-25 01:49:12 -04:00
Daniel Richard G dd168ad22c 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 01:45:13 -04:00
Jonathan Westhues 505e3d869c Update Help -> About to note that license is GPLv3. 2013-09-22 03:50:59 -07:00
Daniel Richard G e7f3a3c0db Build fix for Visual Studio 2003
INT_MAX was not being defined, so #include <limits.h>.
2013-09-20 21:38:53 -04:00
Daniel Richard G fb766d1cf9 Make optional the use of the SpaceNavigator libraries 2013-09-20 15:25:14 -04:00
Daniel Richard G 3cfe6b6da1 Synthesize accelerator labels (e.g. "Ctrl+S") instead of hard-coding them
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().
2013-09-20 15:01:00 -04:00
Daniel Richard G 2499a02f2f Minor changes to GraphicsWindow::menu[]
* Added a comment header identifying the columns

* Added Ctrl-Q accelerator for "Exit", as this is standard

* Replaced a Latin-1 "degree" character with an octal escape, to avoid
  source-file encoding issues

* Undefine (some of) the convenience macros used to define the table
  (the method aliases are numerous and unlikely to collide with anything)
2013-09-20 14:34:03 -04:00
Daniel Richard G 4a2711476c Record accelerator for "Show Snap Grid" as '>' instead of Shift-'.'
If we are to synthesize accelerator labels from values of
GraphicsWindow::menu[].accel, it will be more straightforward if
accelerators are represented in the same way that they appear in the menu.
(Windows does return the keystroke as VK_OEM_PERIOD with a Shift modifier,
so we add some special-case logic to recognize that.)
2013-09-20 14:01:31 -04:00
Daniel Richard G 9da2a3a6c7 Use symbolic names for special keys and modifiers
Easier to remember e.g. DELETE_KEY instead of 127 or CTRL_MASK instead of
0x200, and better to have a single definition of each.
2013-09-20 13:54:57 -04:00
Daniel Richard G 37063840db Don't use magic values in GraphicsWindow::menu[].level
We can identify the "Open Recent" and "Import Recent" submenus just as
easily by looking at the value of the .id field (MNU_OPEN_RECENT and
MNU_GROUP_RECENT, respectively).
2013-09-20 13:40:17 -04:00
Daniel Richard G 66758b9595 Miscellaneous adjustments for warnings and code quality
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
2013-09-19 02:35:56 -04:00
Daniel Richard G 07b128b877 Define some menu-bar menu items as radio buttons
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.)
2013-09-19 00:59:18 -04:00
Daniel Richard G 30ca4ec8ac Use a '*' printf() field width rather than an intermediate format string 2013-09-19 00:50:11 -04:00
Daniel Richard G 16179f34cd Enabled freeing of (most) allocated memory on program exit
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.
2013-09-19 00:33:12 -04:00
Daniel Richard G 42a46e83fa Use system-agnostic return values for SaveFileYesNoCancel()
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.
2013-09-18 16:49:32 -04:00
Daniel Richard G 70b6bad551 Use '\b' instead of ('h' - 'a' + 1) 2013-09-18 16:41:23 -04:00
Daniel Richard G 718d411699 Renamed *.table files to *.table.h
The *.table files are in fact C header files, and with an *.h extension,
tools will be able to recognize them as such
2013-09-16 17:14:53 -04:00
Daniel Richard G 93145387f4 Fixed uninitialized-memory errors detected by Valgrind 2013-09-16 16:22:14 -04:00
Daniel Richard G 44a3981fbf Use png_get_image_{width,height}() instead of info_ptr->{width,height}
Later versions of libpng (1.5.x) have made the png_info structure opaque,
breaking direct access to its fields. Fortunately, the library also
provides getter routines, and these are available in the more-widely-
deployed 1.2.x series.
2013-09-16 15:57:32 -04:00