Commit Graph

627 Commits (259d8e0d38809d4a647530152daa6b8cabbf5b04)

Author SHA1 Message Date
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
Daniel Richard G 66315d5eea Added const qualifiers to edit-control string handling
FLTK's Fl_Input widget, instantiated as {Graphics,Text}EditControl, returns
a 'const char *' string. In order to handle this properly, several of
SolveSpace's internal routines needed to gain a "const" qualifier on the
edit-control string argument.
2013-09-16 15:51:20 -04:00
Daniel Richard G bcb6c7b19b OpenGL fixes
glGetError() was returning GL_INVALID_OPERATION due to some minor missteps
2013-09-09 16:05:33 -04:00
Daniel Richard G 5cca524c62 Changed "static const int" class members into enums
Not only is the enum syntax more compact, it avoids inadvertent link
failures resulting from how C++ treats "static const int" members:

http://stackoverflow.com/questions/5391973/undefined-reference-to-static-const-int
http://stackoverflow.com/questions/5508182/static-const-int-causes-linking-error-undefined-reference

(And for what it's worth, MSVC6 gave silly errors for these members
wherever a non-zero value was assigned.)
2013-09-09 15:50:32 -04:00
Daniel Richard G a2a78b923f Renamed the MSVC makefile to Makefile.msvc
Automake and CMake both generate a makefile named "Makefile", so this will
prevent the hand-written MSVC makefile from getting clobbered.
2013-08-27 16:46:24 -04:00
Daniel Richard G 74b65e14f9 Revised the MSVC Makefile and build
* Generate icons.h and icons-proto.h in the source directory instead of
  obj/, so that pre-generated copies of these files can be distributed
  without being blown away by "make clean"; also updated the source files
  that #include these to reflect the new location

* Compilation rules rewritten as batch-mode inference rules

* Use Windows commands instead of Unix ones ("del" instead of "rm", "move"
  instead of "mv", etc.)

* Sorted the object lists

* Use tabs to indent rule bodies
2013-08-27 16:44:48 -04:00
Daniel Richard G 398e09fe9e Revised the Perl scripts
* Use "#!/usr/bin/env perl" instead of "#!/usr/bin/perl", as this is better
  practice (it allows e.g. /usr/local/bin/perl to work when executing via
  the shebang)

* Use "use strict" and "use warnings"

* Declare variables with "my" as required by "use strict"

* Take an optional "srcdir" argument so that the scripts can find the icon
  files in a location other than ./icons/ -- this will make building
  outside of the source tree possible in the future

* Add a "this is a generated file" banner to the output, so that it can be
  clearly recognized as a machine-generated file that should not be
  hand-edited

* Minor regex tweaks
2013-08-26 17:45:09 -04:00
Daniel Richard G 0f7a34ccca Fixed a typo: "==" was intended, not "=" 2013-08-26 17:06:53 -04:00
Daniel Richard G e256956d12 Added missing items to GraphicsWindow::menu[] elements
Several MenuEntry elements in GraphicsWindow::menu[] were being initialized
with four items instead of the requisite five, due to a missing fourth
column (corresponding to the .accel field of MenuEntry). This change simply
adds zeroes as the missing column to the appropriate elements.
2013-08-26 17:00:02 -04:00
Daniel Richard G 66f46b7b67 General compiler warning/error fixes
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.
2013-08-26 16:54:04 -04:00
Daniel Richard G 7715fd1bb8 Don't ignore the return value of fgets() and fread() 2013-08-26 16:48:41 -04:00
Daniel Richard G 1b00c8c3ab Use size_t instead of int in the memory allocation routines
size_t is the correct type to use when specifying the memory-size of an
object. That is why sizeof(), strlen() and malloc() all use it.
2013-08-26 16:40:25 -04:00
Daniel Richard G dcc963aa4b Modified Get{BYTE,WORD,DWORD}() to return the respective type
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().
2013-08-26 16:24:16 -04:00
Daniel Richard G a72575d04e Use casts to bridge mismatches in integer-type sizes and signedness
The compiler gets nervous when we (for example) pass in a size_t as an int
parameter, or assign an int to a char, or assign -1 to an unsigned type. By
adding appropriate casts, we inform the compiler that, yes, we know what
we're doing.

This change also upgrades a va_arg() type from char to int, as char is
always promoted to int when passed through '...'.
2013-08-26 16:19:23 -04:00
Daniel Richard G 8913d11fa5 Quash "variable may be used uninitialized" warnings
Whether or not there is any actual danger of these variables being used
without initialization, the warnings are noise, and getting rid of them is
trivial.
2013-08-26 15:36:00 -04:00
Daniel Richard G df6125efee Fix "jump to label 'foo' crosses initialization of 'bar'" errors
Newer C++ compilers do not allow goto-ing over an initialized variable
declaration, as this violates C++98. We address this by (in most cases)
separating the initialization from the declaration, or moving the goto to
an equivalent location.

Refer to the following discussions for more background:

http://stackoverflow.com/questions/11306799/why-does-c-enforce-such-behavior-in-crosses-initialization
http://stackoverflow.com/questions/12992108/crosses-initialization-of-variable-only-when-initialization-combined-with-decl
2013-08-26 15:24:50 -04:00
Daniel Richard G 02776ea535 Added const qualifiers
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.
2013-08-26 14:58:35 -04:00
Jonathan Westhues affbeafc6c Make a copy of "freeze" library for storing stuff in registry, to
make //depot/solvespace/... entirely self-contained.

[git-p4: depot-paths = "//depot/solvespace/": change = 2216]
2013-08-20 21:54:54 -08:00
Jonathan Westhues defeb6411a Clean up SolveSpace makefile, and add forgotten copyright notice.
[git-p4: depot-paths = "//depot/solvespace/": change = 2213]
2013-07-28 14:53:30 -08:00
Jonathan Westhues bc426a2a7f Delete obsolete text in solvespace/doc/..., superseded by the
stuff on the website.

[git-p4: depot-paths = "//depot/solvespace/": change = 2212]
2013-07-28 14:40:37 -08:00
Jonathan Westhues 0ee8ba1457 Changes in preparation for the release of SolveSpace under the GPL,
to add that license, and change all copyright notices to me, not
Useful Subset, LLC.

[git-p4: depot-paths = "//depot/solvespace/": change = 2211]
2013-07-28 14:08:34 -08:00
Jonathan Westhues 1abd87954c Oops, fix gross memory leak in SolveSpace library due to failure
to destroy temporary heap.

[git-p4: depot-paths = "//depot/solvespace/": change = 2210]
2013-03-15 08:43:35 -08:00
Jonathan Westhues 7919e7171d Make SolveSpace work unrestricted without a license file, and
increase its version number to 1.9.

[git-p4: depot-paths = "//depot/solvespace/": change = 2198]
2012-01-21 12:12:00 -08:00
Jonathan Westhues e11347f613 Oops, update copyright date to 2011 for SolveSpace.
[git-p4: depot-paths = "//depot/solvespace/": change = 2195]
2011-07-04 11:25:17 -08:00
Jonathan Westhues c98a0b381f Increment SolveSpace's version number to 1.8.
[git-p4: depot-paths = "//depot/solvespace/": change = 2194]
2011-07-04 11:10:00 -08:00
Jonathan Westhues fc3dc68f83 Check in the VB.NET example for the SolveSpace library, and update
the documentation accordingly. Also rename the C example for
consistency, and update copyright dates.

[git-p4: depot-paths = "//depot/solvespace/": change = 2190]
2011-03-13 00:04:09 -08:00
Jonathan Westhues b3bdadfeb8 Fix that typo elsewhere in the slvs.dll examples, and note that
VB.NET example in the documentation.

[git-p4: depot-paths = "//depot/solvespace/": change = 2188]
2011-03-05 14:33:05 -08:00
Jonathan Westhues 3dc21ec8dd Make oops() calls exit instead of entering debugger by default,
since the latter looks worse if it happens to someone else.

[git-p4: depot-paths = "//depot/solvespace/": change = 2187]
2011-03-05 12:52:57 -08:00
Jonathan Westhues dcfae0f341 Typo in SolveSpace library example, embarrassing.
[git-p4: depot-paths = "//depot/solvespace/": change = 2186]
2011-03-05 12:22:59 -08:00
Jonathan Westhues 3dea64af47 Make default text in dimension box the exact (up to ten digits
after decimal) current value of the dimension, not the value
truncated to the same number of digits that are usually displayed.

And make the paste transformed screen accept expressions, not
just integers, for the count, angle, and scale.

[git-p4: depot-paths = "//depot/solvespace/": change = 2181]
2010-10-11 19:13:41 -08:00
Jonathan Westhues cc3b17f60e Make the number of digits after the decimal point (for dimensions,
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]
2010-09-23 18:58:34 -08:00
Jonathan Westhues e672706770 Due to questionable decision to use copy-number values of 1000
and up for special things, the number of times that a group may
be stepped is limited to 999. So avoid a crash by not letting
the user specify more than that.

[git-p4: depot-paths = "//depot/solvespace/": change = 2178]
2010-09-17 18:20:08 -08:00
Jonathan Westhues 307965d53f Update selection of extrusion/lathe solid model color to use new
color picker.

And apply same rule to rewrite nearly-white colors (when exporting
with a file format typically viewed on a white background) for fill
color as for stroke color.

[git-p4: depot-paths = "//depot/solvespace/": change = 2176]
2010-08-14 11:00:25 -08:00
Jonathan Westhues 439e4d3124 Add a color picker, with a fancy HSV (actually, a modified version
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]
2010-07-20 21:04:03 -08:00
Jonathan Westhues 98897af77b Fix typo in SolveSpace library documentation.
[git-p4: depot-paths = "//depot/solvespace/": change = 2173]
2010-07-15 02:07:54 -08:00
Jonathan Westhues cedb360af2 Note in documentation for SolveSpace library that the constraint to
place a point on a circle also works for arcs.

[git-p4: depot-paths = "//depot/solvespace/": change = 2172]
2010-07-14 06:55:54 -08:00
Jonathan Westhues 824cc00915 Put wrappers around the functions to show and hide the edit control
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]
2010-07-11 23:51:12 -08:00
Jonathan Westhues 319ba16541 When curves to be split intersect at multiple points, don't just
choose arbitrarily. Instead, split at the point closest to the
mouse pointer.

[git-p4: depot-paths = "//depot/solvespace/": change = 2170]
2010-07-11 22:47:14 -08:00
Jonathan Westhues 9ae29aa0e9 Build the demo version of the solver library as a DLL, not a static
library. If I understand correctly, that will avoid all the
compiler version issues with different required versions of libc.

[git-p4: depot-paths = "//depot/solvespace/": change = 2167]
2010-07-10 10:53:30 -08:00
Jonathan Westhues 46a7d0f719 Disable buffer overrun protection in the library that we build,
since that makes it more difficult to interoperate with the MSVC6
compiler.

[git-p4: depot-paths = "//depot/solvespace/": change = 2165]
2010-07-06 21:01:17 -08:00