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
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.
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.
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]
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]
and cubics. Also add that to the library interface.
It might have been better to use a single constraint for that,
plus all the line-curve or line-line cases, but it would break
backwards compatibility if I did that now, and perhaps be
confusing with the 'other' member (which is meaningless for
lines) anyways.
[git-p4: depot-paths = "//depot/solvespace/": change = 2141]
useful because it makes it possible to add cosmetic dimensions to
an existing model, without REF appended.
[git-p4: depot-paths = "//depot/solvespace/": change = 2140]
possible. This replaces all of the color-coded links, that I liked
but that were nonstandard.
Also rip out the old sweep and helical sweep UI; that was disabled,
but the code was still present.
And fix dependencies in makefile, since textwin.cpp depends on the
icons now.
[git-p4: depot-paths = "//depot/solvespace/": change = 2139]
File -> New or File -> Open, I freed the Group structures
themselves, but none of their children.
[git-p4: depot-paths = "//depot/solvespace/": change = 2120]
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]
those screw a lot of things up. And add data structure for
clipboard entities, though no code yet.
[git-p4: depot-paths = "//depot/solvespace/": change = 2082]
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]
to assemble Beziers into outer and inner loops, and find those
loops made up of entities with filled styles. The open paths are
maintained in a separate list, and we assemble as many closed paths
as possible even when open paths exist.
This changes many things. The coplanar check is now performed on
the Beziers, not the resulting polygon. The way that the polygon is
used to determine loop directions is also modified.
Also fix the mouse behavior when dragging a point: drop it when the
mouse is released, even if it is released outside the window, but
don't drop it if the pointer is dragged out of and then back into
our window.
Also special-case SSurface::ClosestPointTo() for planes, for speed.
[git-p4: depot-paths = "//depot/solvespace/": change = 2058]
contours go with which outer contour) out of exportstep.cpp, since
I'll need that to do filled contour export for the 2d file formats.
Also add user interface to specify fill color.
[git-p4: depot-paths = "//depot/solvespace/": change = 2057]
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]
and parametric entities. Also consolidate the text screen functions
to change group options into a single function for everything.
[git-p4: depot-paths = "//depot/solvespace/": change = 2051]
point-coincident constraints and the entity- or group-generated
constraints. Also fix a bug where a dragged point was not released
when the mouse pointer left the window.
[git-p4: depot-paths = "//depot/solvespace/": change = 2045]
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]
mechanism. This gets filled in from some defaults, and stored in
the registry. The default styles do not get saved in the file, but
user-created styles (which aren't supported yet) do.
[git-p4: depot-paths = "//depot/solvespace/": change = 2028]
size for EPS, etc.). This can either be fixed, with a given width
and height and offset, or automatic, by the left right bottom top
margins.
And draw nicer dimensions for length, with arrows and more
extension lines. Add code to trim those lines against the
(rectangular, axis-aligned) box that contains the actual number,
and use that (instead of the elliptical interpolation, which was
only approximately right) for diameter dimensions too.
[git-p4: depot-paths = "//depot/solvespace/": change = 2027]
(in my case, a SpaceNavigator). I can transform the view of the
part, or transform a part in an assembly.
Also fix up mouse wheel input, so that it works even if it comes in
chunks of less than 120 units.
[git-p4: depot-paths = "//depot/solvespace/": change = 2019]
steps in thisShell or thisMesh, and then let the Boolean proceed as
usual. If everything works, then this is equivalent. And it's less
code, and it makes stuff like stepping the step and repeat work.
Also begin to work on line/entity/constraint styles, but no real
work yet.
[git-p4: depot-paths = "//depot/solvespace/": change = 2018]
constraint, so that we can export that too. This includes the lines
for the vector font.
A little ugly; it needs some kind of line style (color or width) to
distinguish those lines from the real geometry in the exported
file.
[git-p4: depot-paths = "//depot/solvespace/": change = 2007]
identical to the previous group's (because our thisShell and
thisMesh are empty), then display the previous group's instead.
This saves us re-triangulating the shell (or recalculating the
edges of a triangle mesh) every time our group gets regenerated,
which was horribly slow.
[git-p4: depot-paths = "//depot/solvespace/": change = 2004]
window screen, and remind the user that they could 'fix' the
problem by working with meshes instead.
[git-p4: depot-paths = "//depot/solvespace/": change = 1962]
according to the user's preference. I templated the housekeeping
stuff for Boolean operations and step and repeat, so it's
relatively clean.
Still need to add the stuff to make a mesh vertex-to-vertex, and to
export sections of a mesh.
[git-p4: depot-paths = "//depot/solvespace/": change = 1959]
exact surface shells. And add interference checking; I'll be lazy
and just do that on the meshes, by modifying the self-intersection
tester to ignore coplanar triangles (since that can happen in an
assembly).
[git-p4: depot-paths = "//depot/solvespace/": change = 1958]
a mesh than that's a copy, and if we're working with a shell then
it's the shell's triangulation.
[git-p4: depot-paths = "//depot/solvespace/": change = 1957]
little test app that links against it. I still need to polish a few
things, but this is more or less as it should be.
[git-p4: depot-paths = "//depot/solvespace/": change = 1944]
the fundamental geometric stuff in XxxBase. Next I hope to make the
constraint solver use only the XxxBase types.
[git-p4: depot-paths = "//depot/solvespace/": change = 1941]
and curve.cpp and surface.cpp contain the rest.
Also get rid of the meshError stuff; will just use the nakedEdges
mechanism for that. And I won't run the interference test
continuously, have added a menu item for that.
[git-p4: depot-paths = "//depot/solvespace/": change = 1934]
Add stubs for functions to perform Booleans, and get rid of mesh
stuff, including the kd tree accelerated snap to vertex (which
should not be required if the shell triangulation performs as it
should).
Also check that a sketch is not self-intersecting before extruding
it or whatever. This is dead slow, needs n*log(n) implementation.
[git-p4: depot-paths = "//depot/solvespace/": change = 1902]
from an extrusion, with piecewise linear trim curves for everything
(that are shared, so that they appear only once for the two
surfaces that each trims). No Boolean operations on them, and the
triangulation is bad, because gl seems to merge collinear edges.
So before going further, I seem to need my own triangulation code.
I have not had great luck in the past, but I can't live without it
now.
[git-p4: depot-paths = "//depot/solvespace/": change = 1899]
so now we've got the exact curve loops, with their direction
standardized so that we can tell which direction is out. We still
need the polygon in any case, since that's a convenient way to find
each curve's winding number.
And remove some more leftover code from mesh sweeps.
[git-p4: depot-paths = "//depot/solvespace/": change = 1897]
piecwise linear segments. These are piecewise linear approximated
for display, and currently for the mesh too, but that's the first
step to replace the mesh with exact curved surfaces.
[git-p4: depot-paths = "//depot/solvespace/": change = 1895]