summaryrefslogtreecommitdiff
path: root/app/bin/trkseg.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/bin/trkseg.c')
-rw-r--r--app/bin/trkseg.c1699
1 files changed, 853 insertions, 846 deletions
diff --git a/app/bin/trkseg.c b/app/bin/trkseg.c
index ebe1916..82396a2 100644
--- a/app/bin/trkseg.c
+++ b/app/bin/trkseg.c
@@ -17,13 +17,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "common.h"
#include "fileio.h"
#include "param.h"
#include "track.h"
+#include "trkendpt.h"
#include "misc.h"
#include "cbezier.h"
#include "tbezier.h"
@@ -49,10 +50,10 @@
* that the center of curve is always on an orthogonal line through the bisection of a chord.
*/
EXPORT void ComputeCurvedSeg(
- trkSeg_p s,
- DIST_T radius,
- coOrd p0,
- coOrd p1 )
+ trkSeg_p s,
+ DIST_T radius,
+ coOrd p0,
+ coOrd p1 )
{
DIST_T d;
ANGLE_T a, aa, aaa;
@@ -76,10 +77,10 @@ EXPORT void ComputeCurvedSeg(
EXPORT coOrd GetSegEndPt(
- trkSeg_p segPtr,
- EPINX_T ep,
- BOOL_T bounds,
- ANGLE_T * angleR )
+ trkSeg_p segPtr,
+ EPINX_T ep,
+ BOOL_T bounds,
+ ANGLE_T * angleR )
{
coOrd pos;
ANGLE_T angle, a, a0, a1 = 0.0;
@@ -114,38 +115,41 @@ EXPORT coOrd GetSegEndPt(
y1 = r * cos(D2R(a0+a1));
if (ep == 0) {
pos.x = segPtr->u.c.center.x + (((a0<=270.0)&&(a0+a1>=270.0)) ?
- (-r) : min(x0,x1));
+ (-r) : min(x0,x1));
pos.y = segPtr->u.c.center.y + (((a0<=180.0)&&(a0+a1>=180.0)) ?
- (-r) : min(y0,y1));
+ (-r) : min(y0,y1));
} else {
pos.x = segPtr->u.c.center.x + (((a0<= 90.0)&&(a0+a1>= 90.0)) ?
- (r) : max(x0,x1));
+ (r) : max(x0,x1));
pos.y = segPtr->u.c.center.y + ((a0+a1>=360.0) ?
- (r) : max(y0,y1));
+ (r) : max(y0,y1));
}
} else {
PointOnCircle( &pos, segPtr->u.c.center, fabs(segPtr->u.c.radius), a );
}
break;
case SEG_JNTTRK:
- pos = GetJointSegEndPos( segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.flip, segPtr->u.j.Scurve, ep, &angle );
+ pos = GetJointSegEndPos( segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0,
+ segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate,
+ segPtr->u.j.flip, segPtr->u.j.Scurve, ep, &angle );
break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- if (ep ==1) {
- pos = segPtr->u.b.pos[3]; //For Bezier, use the End Points of the overall curve
- angle = FindAngle(segPtr->u.b.pos[2],segPtr->u.b.pos[3]);
- } else {
- pos = segPtr->u.b.pos[0];
- angle = FindAngle(segPtr->u.b.pos[1],segPtr->u.b.pos[0]);
- }
-
- break;
- default:
- AbortProg("GetSegCntPt(%c)", segPtr->type );
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ if (ep ==1) {
+ pos = segPtr->u.b.pos[3]; //For Bezier, use the End Points of the overall curve
+ angle = FindAngle(segPtr->u.b.pos[2],segPtr->u.b.pos[3]);
+ } else {
+ pos = segPtr->u.b.pos[0];
+ angle = FindAngle(segPtr->u.b.pos[1],segPtr->u.b.pos[0]);
+ }
+
+ break;
+ default:
+ CHECKMSG( FALSE, ("GetSegCntPt(%c)", segPtr->type ) );
}
- if ( angleR )
+ if ( angleR ) {
*angleR = angle;
+ }
return pos;
}
@@ -160,12 +164,12 @@ EXPORT coOrd GetSegEndPt(
* \param hiR OUT top right corner
*/
EXPORT void GetTextBounds(
- coOrd pos,
- ANGLE_T angle,
- char * str,
- FONTSIZE_T fs,
- coOrd * loR,
- coOrd * hiR )
+ coOrd pos,
+ ANGLE_T angle,
+ char * str,
+ FONTSIZE_T fs,
+ coOrd * loR,
+ coOrd * hiR )
{
coOrd size, size2;
@@ -186,25 +190,24 @@ EXPORT void GetTextBounds(
lo = hi = zero;
// rotate each point
- for (i=0; i<4; i++)
- {
- Rotate(&p[i], zero, angle);
+ for (i=0; i<4; i++) {
+ Rotate(&p[i], zero, angle);
- if (p[i].x < lo.x) {
- lo.x = p[i].x;
- }
+ if (p[i].x < lo.x) {
+ lo.x = p[i].x;
+ }
- if (p[i].y < lo.y) {
- lo.y = p[i].y;
- }
+ if (p[i].y < lo.y) {
+ lo.y = p[i].y;
+ }
- if (p[i].x > hi.x) {
- hi.x = p[i].x;
- }
+ if (p[i].x > hi.x) {
+ hi.x = p[i].x;
+ }
- if (p[i].y > hi.y) {
- hi.y = p[i].y;
- }
+ if (p[i].y > hi.y) {
+ hi.y = p[i].y;
+ }
}
// now recaclulate the corners
@@ -215,15 +218,25 @@ EXPORT void GetTextBounds(
}
-static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, coOrd *lo, coOrd *hi )
+static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle,
+ coOrd *lo, coOrd *hi )
{
int inx;
- coOrd p0, p1, pBez[4], pc;
+ coOrd p0, p1, pBez, pc;
ANGLE_T a0, a1;
coOrd width;
DIST_T radius;
+ LWIDTH_T lwidth;
width = zero;
+ if (segPtr->lineWidth < 0) {
+ // TO DO: Using scale is correct, but the correct context may not be mainD
+ // For now, we're assuming it will be close enough to zero
+ lwidth = 0; // -(DIST_T)segPtr->lineWidth / mainD.scale;
+ } else {
+ lwidth = (LWIDTH_T)segPtr->lineWidth;
+ }
+
switch ( segPtr->type ) {
case ' ':
return;
@@ -235,78 +248,91 @@ static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, coOrd *lo
case SEG_TBLEDGE:
case SEG_CRVLIN:
case SEG_JNTTRK:
- REORIGIN( p0, GetSegEndPt( segPtr, 0, FALSE, NULL ), angle, xlat )
- REORIGIN( p1, GetSegEndPt( segPtr, 1, FALSE, NULL ), angle, xlat )
- if (p0.x < p1.x) {
- lo->x = p0.x;
- hi->x = p1.x;
- } else {
- lo->x = p1.x;
- hi->x = p0.x;
- }
- if (p0.y < p1.y) {
- lo->y = p0.y;
- hi->y = p1.y;
- } else {
- lo->y = p1.y;
- hi->y = p0.y;
+ REORIGIN( p0, GetSegEndPt( segPtr, 0, FALSE, NULL ), angle, xlat )
+ REORIGIN( p1, GetSegEndPt( segPtr, 1, FALSE, NULL ), angle, xlat )
+ if (p0.x < p1.x) {
+ lo->x = p0.x;
+ hi->x = p1.x;
+ } else {
+ lo->x = p1.x;
+ hi->x = p0.x;
+ }
+ if (p0.y < p1.y) {
+ lo->y = p0.y;
+ hi->y = p1.y;
+ } else {
+ lo->y = p1.y;
+ hi->y = p0.y;
+ }
+ if ( (segPtr->type == SEG_CRVTRK) ||
+ (segPtr->type == SEG_CRVLIN) ) {
+ /* TODO: be more precise about curved line width */
+ width.x = width.y = lwidth;
+ REORIGIN( pc, segPtr->u.c.center, angle, xlat );
+ a0 = NormalizeAngle( segPtr->u.c.a0 + angle );
+ a1 = segPtr->u.c.a1;
+ radius = fabs(segPtr->u.c.radius);
+ if ( a1 >= 360.0 ) {
+ lo->x = pc.x - radius;
+ lo->y = pc.y - radius;
+ hi->x = pc.x + radius;
+ hi->y = pc.y + radius;
+ break;
}
- if ( (segPtr->type == SEG_CRVTRK) ||
- (segPtr->type == SEG_CRVLIN) ) {
- /* TODO: be more precise about curved line width */
- width.x = width.y = fabs(segPtr->width)/2.0;
- REORIGIN( pc, segPtr->u.c.center, angle, xlat );
- a0 = NormalizeAngle( segPtr->u.c.a0 + angle );
- a1 = segPtr->u.c.a1;
- radius = fabs(segPtr->u.c.radius);
- if ( a1 >= 360.0 ) {
- lo->x = pc.x - radius;
- lo->y = pc.y - radius;
- hi->x = pc.x + radius;
- hi->y = pc.y + radius;
- break;
- }
- if ( a0 + a1 >= 360.0 )
- hi->y = pc.y + radius;
- if ( a0 < 90.0 && a0+a1 >= 90.0 )
- hi->x = pc.x + radius;
- if ( a0 > 90.0 && a0+a1 >= 450.0 )
- hi->x = pc.x + radius;
- if ( a0 < 180.0 && a0+a1 >= 180.0 )
- lo->y = pc.y - radius;
- if (a0 > 180.0 && a0+a1 >= 540.0 )
- lo->y = pc.y - radius;
- if ( a0 < 270.0 && a0+a1 >= 270.0 )
- lo->x = pc.x - radius;
- if ( a0 > 270.0 && a0+a1 >= 630.0 )
- lo->x = pc.x - radius;
+ if ( a0 + a1 >= 360.0 ) {
+ hi->y = pc.y + radius;
+ }
+ if ( a0 < 90.0 && a0+a1 >= 90.0 ) {
+ hi->x = pc.x + radius;
+ }
+ if ( a0 > 90.0 && a0+a1 >= 450.0 ) {
+ hi->x = pc.x + radius;
+ }
+ if ( a0 < 180.0 && a0+a1 >= 180.0 ) {
+ lo->y = pc.y - radius;
+ }
+ if (a0 > 180.0 && a0+a1 >= 540.0 ) {
+ lo->y = pc.y - radius;
+ }
+ if ( a0 < 270.0 && a0+a1 >= 270.0 ) {
+ lo->x = pc.x - radius;
}
- if ( segPtr->type == SEG_STRLIN ) {
- width.x = fabs(segPtr->width) * fabs(cos( D2R( FindAngle(p0, p1) ) ) ) / 2.0;
- width.y = fabs(segPtr->width) * fabs(sin( D2R( FindAngle(p0, p1) ) ) ) / 2.0;
- } else if ( segPtr->type == SEG_BENCH ) {
- width.x = BenchGetWidth( segPtr->u.l.option ) * fabs(cos( D2R( FindAngle(p0, p1) ) ) ) / 2.0;
- width.y = BenchGetWidth( segPtr->u.l.option ) * fabs(sin( D2R( FindAngle(p0, p1) ) ) ) / 2.0;
+ if ( a0 > 270.0 && a0+a1 >= 630.0 ) {
+ lo->x = pc.x - radius;
}
+ }
+ if ( segPtr->type == SEG_STRLIN ) {
+ width.x = lwidth * fabs(cos(D2R(FindAngle(p0, p1))));
+ width.y = lwidth * fabs(sin(D2R(FindAngle(p0, p1))));
+ } else if ( segPtr->type == SEG_BENCH ) {
+ width.x = BenchGetWidth( segPtr->u.l.option ) * fabs(cos( D2R( FindAngle(p0,
+ p1) ) ) ) / 2.0;
+ width.y = BenchGetWidth( segPtr->u.l.option ) * fabs(sin( D2R( FindAngle(p0,
+ p1) ) ) ) / 2.0;
+ }
break;
case SEG_POLY:
/* TODO: be more precise about poly line width */
- width.x = width.y = fabs(segPtr->width)/2.0;
+ width.x = width.y = lwidth;
case SEG_FILPOLY:
for (inx=0; inx<segPtr->u.p.cnt; inx++ ) {
REORIGIN( p0, segPtr->u.p.pts[inx].pt, angle, xlat )
if (inx==0) {
*lo = *hi = p0;
} else {
- if (p0.x < lo->x)
+ if (p0.x < lo->x) {
lo->x = p0.x;
- if (p0.y < lo->y)
+ }
+ if (p0.y < lo->y) {
lo->y = p0.y;
- if (p0.x > hi->x)
+ }
+ if (p0.x > hi->x) {
hi->x = p0.x;
- if (p0.y > hi->y)
+ }
+ if (p0.y > hi->y) {
hi->y = p0.y;
+ }
}
}
break;
@@ -319,23 +345,23 @@ static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, coOrd *lo
break;
case SEG_TEXT:
REORIGIN( p0, segPtr->u.t.pos, angle, xlat )
- GetTextBounds( p0, angle+segPtr->u.t.angle, segPtr->u.t.string, segPtr->u.t.fontSize, lo, hi );
+ GetTextBounds( p0, angle+segPtr->u.t.angle, segPtr->u.t.string,
+ segPtr->u.t.fontSize, lo, hi );
break;
+ /* The following code is executed only for Cornu track */
case SEG_BEZLIN:
case SEG_BEZTRK: //Bezier control arms form a "tent" around the curve
- REORIGIN( pBez[0], segPtr->u.b.pos[0], angle, xlat )
- REORIGIN( pBez[1], segPtr->u.b.pos[1], angle, xlat )
- REORIGIN( pBez[2], segPtr->u.b.pos[2], angle, xlat )
- REORIGIN( pBez[3], segPtr->u.b.pos[3], angle, xlat )
- lo->x = hi->x = pBez[0].x;
- lo->y = hi->y = pBez[0].y;
- for (int i=1;i<4;i++) {
- lo->x = lo->x>pBez[i].x?pBez[i].x:lo->x;
- lo->y = lo->y>pBez[i].y?pBez[i].y:lo->y;
- hi->x = hi->x<pBez[i].x?pBez[i].x:hi->x;
- hi->y = hi->y<pBez[i].y?pBez[i].y:hi->y;
+ REORIGIN( pBez, segPtr->u.b.pos[0], angle, xlat )
+ lo->x = hi->x = pBez.x;
+ lo->y = hi->y = pBez.y;
+ for (int i=1; i<4; i++) {
+ REORIGIN(pBez, segPtr->u.b.pos[i], angle, xlat)
+ lo->x = lo->x>pBez.x?pBez.x:lo->x;
+ lo->y = lo->y>pBez.y?pBez.y:lo->y;
+ hi->x = hi->x<pBez.x?pBez.x:hi->x;
+ hi->y = hi->y<pBez.y?pBez.y:hi->y;
}
- width.x = width.y = fabs(segPtr->width)/2.0;
+ width.x = width.y = lwidth;
break;
default:
;
@@ -348,12 +374,12 @@ static void Get1SegBounds( trkSeg_p segPtr, coOrd xlat, ANGLE_T angle, coOrd *lo
EXPORT void GetSegBounds(
- coOrd xlat,
- ANGLE_T angle,
- wIndex_t segCnt,
- trkSeg_p segs,
- coOrd * orig_ret,
- coOrd * size_ret )
+ coOrd xlat,
+ ANGLE_T angle,
+ wIndex_t segCnt,
+ trkSeg_p segs,
+ coOrd * orig_ret,
+ coOrd * size_ret )
{
trkSeg_p s;
coOrd lo, hi, tmpLo, tmpHi;
@@ -361,21 +387,27 @@ EXPORT void GetSegBounds(
first = TRUE;
for (s=segs; s<&segs[segCnt]; s++) {
- if (s->type == ' ')
+ if (s->type == ' ') {
continue;
+ }
+
if (first) {
Get1SegBounds( s, xlat, angle, &lo, &hi );
first = FALSE;
} else {
Get1SegBounds( s, xlat, angle, &tmpLo, &tmpHi );
- if (tmpLo.x < lo.x)
+ if (tmpLo.x < lo.x) {
lo.x = tmpLo.x;
- if (tmpLo.y < lo.y)
+ }
+ if (tmpLo.y < lo.y) {
lo.y = tmpLo.y;
- if (tmpHi.x > hi.x)
+ }
+ if (tmpHi.x > hi.x) {
hi.x = tmpHi.x;
- if (tmpHi.y > hi.y)
+ }
+ if (tmpHi.y > hi.y) {
hi.y = tmpHi.y;
+ }
}
}
if (first) {
@@ -401,9 +433,9 @@ EXPORT void GetSegBounds(
EXPORT void MoveSegs(
- wIndex_t segCnt,
- trkSeg_p segs,
- coOrd orig )
+ wIndex_t segCnt,
+ trkSeg_p segs,
+ coOrd orig )
{
trkSeg_p s;
int inx;
@@ -441,24 +473,24 @@ EXPORT void MoveSegs(
s->u.j.pos.x += orig.x;
s->u.j.pos.y += orig.y;
break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- for (inx=0;inx<4;inx++) {
- s->u.b.pos[inx].x +=orig.x;
- s->u.b.pos[inx].y +=orig.y;
- }
- FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK);
- break;
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ for (inx=0; inx<4; inx++) {
+ s->u.b.pos[inx].x +=orig.x;
+ s->u.b.pos[inx].y +=orig.y;
+ }
+ FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK);
+ break;
}
}
}
EXPORT void RotateSegs(
- wIndex_t segCnt,
- trkSeg_p segs,
- coOrd orig,
- ANGLE_T angle )
+ wIndex_t segCnt,
+ trkSeg_p segs,
+ coOrd orig,
+ ANGLE_T angle )
{
trkSeg_p s;
int inx;
@@ -493,23 +525,23 @@ EXPORT void RotateSegs(
Rotate( &s->u.j.pos, orig, angle );
s->u.j.angle = NormalizeAngle( s->u.j.angle+angle );
break;
- case SEG_BEZLIN:
- case SEG_BEZTRK:
- Rotate( &s->u.b.pos[0], orig, angle );
- Rotate( &s->u.b.pos[1], orig, angle );
- Rotate( &s->u.b.pos[2], orig, angle );
- Rotate( &s->u.b.pos[3], orig, angle );
- FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK);
- break;
- }
+ case SEG_BEZLIN:
+ case SEG_BEZTRK:
+ Rotate( &s->u.b.pos[0], orig, angle );
+ Rotate( &s->u.b.pos[1], orig, angle );
+ Rotate( &s->u.b.pos[2], orig, angle );
+ Rotate( &s->u.b.pos[3], orig, angle );
+ FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK);
+ break;
+ }
}
}
EXPORT void FlipSegs(
- wIndex_t segCnt,
- trkSeg_p segs,
- coOrd orig,
- ANGLE_T angle )
+ wIndex_t segCnt,
+ trkSeg_p segs,
+ coOrd orig,
+ ANGLE_T angle )
{
trkSeg_p s;
int inx;
@@ -530,12 +562,13 @@ EXPORT void FlipSegs(
case SEG_CRVLIN:
case SEG_FILCRCL:
s->u.c.center.y = -s->u.c.center.y;
- if ( s->u.c.a1 < 360.0 )
+ if ( s->u.c.a1 < 360.0 ) {
s->u.c.a0 = NormalizeAngle( 180.0 - s->u.c.a0 - s->u.c.a1 );
+ }
break;
case SEG_TEXT:
s->u.t.pos.y = -s->u.t.pos.y;
-/* TODO flip text angle */
+ /* TODO flip text angle */
break;
case SEG_POLY:
case SEG_FILPOLY:
@@ -553,32 +586,33 @@ EXPORT void FlipSegs(
s->u.j.angle = NormalizeAngle( 180.0 - s->u.j.angle );
s->u.j.negate = ! s->u.j.negate;
break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- s->u.b.pos[0].y = -s->u.b.pos[0].y;
- s->u.b.pos[1].y = -s->u.b.pos[1].y;
- s->u.b.pos[2].y = -s->u.b.pos[2].y;
- s->u.b.pos[3].y = -s->u.b.pos[3].y;
- FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK);
- break;
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ s->u.b.pos[0].y = -s->u.b.pos[0].y;
+ s->u.b.pos[1].y = -s->u.b.pos[1].y;
+ s->u.b.pos[2].y = -s->u.b.pos[2].y;
+ s->u.b.pos[3].y = -s->u.b.pos[3].y;
+ FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK);
+ break;
}
}
}
EXPORT void RescaleSegs(
- wIndex_t segCnt,
- trkSeg_p segs,
- DIST_T scale_x,
- DIST_T scale_y,
- DIST_T scale_w )
+ wIndex_t segCnt,
+ trkSeg_p segs,
+ DIST_T scale_x,
+ DIST_T scale_y,
+ DIST_T scale_w )
{
trkSeg_p s;
int inx;
for (s=segs; s<&segs[segCnt]; s++) {
- if (s->width>0)
- s->width *= scale_w;
+ if (s->lineWidth>0) {
+ s->lineWidth *= scale_w;
+ }
switch (s->type) {
case SEG_STRLIN:
case SEG_DIMLIN:
@@ -617,19 +651,19 @@ EXPORT void RescaleSegs(
s->u.j.l0 *= scale_w;
s->u.j.l1 *= scale_w;
break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- s->u.b.pos[0].y *= scale_y;
- s->u.b.pos[0].x *= scale_x;
- s->u.b.pos[1].x *= scale_x;
- s->u.b.pos[1].y *= scale_y;
- s->u.b.pos[2].y *= scale_y;
- s->u.b.pos[2].x *= scale_x;
- s->u.b.pos[3].x *= scale_x;
- s->u.b.pos[3].y *= scale_y;
- FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK);
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ s->u.b.pos[0].y *= scale_y;
+ s->u.b.pos[0].x *= scale_x;
+ s->u.b.pos[1].x *= scale_x;
+ s->u.b.pos[1].y *= scale_y;
+ s->u.b.pos[2].y *= scale_y;
+ s->u.b.pos[2].x *= scale_x;
+ s->u.b.pos[3].x *= scale_x;
+ s->u.b.pos[3].y *= scale_y;
+ FixUpBezierSeg(s->u.b.pos,s,s->type == SEG_BEZTRK);
- break;
+ break;
}
}
@@ -637,9 +671,9 @@ EXPORT void RescaleSegs(
EXPORT void CloneFilledDraw(
- int segCnt,
- trkSeg_p segs,
- BOOL_T reorigin )
+ int segCnt,
+ trkSeg_p segs,
+ BOOL_T reorigin )
{
pts_t * newPts;
trkSeg_p sp;
@@ -652,8 +686,9 @@ EXPORT void CloneFilledDraw(
newPts = (pts_t*)MyMalloc( sp->u.p.cnt * sizeof (pts_t) );
memcpy( newPts, sp->u.p.pts, sp->u.p.cnt * sizeof (pts_t) );
if ( reorigin ) {
- for ( inx = 0; inx<sp->u.p.cnt; inx++ )
+ for ( inx = 0; inx<sp->u.p.cnt; inx++ ) {
REORIGIN( newPts[inx].pt, sp->u.p.pts[inx].pt, sp->u.p.angle, sp->u.p.orig );
+ }
sp->u.p.angle = 0;
sp->u.p.orig = zero;
}
@@ -666,10 +701,8 @@ EXPORT void CloneFilledDraw(
break;
case SEG_BEZTRK:
case SEG_BEZLIN:
- sp->bezSegs.cnt = 0;
- //if (sp->bezSegs.ptr) MyFree(sp->bezSegs.ptr); Make sure no update to static
- sp->bezSegs.ptr = NULL;
- sp->bezSegs.max = 0;
+ // NOTE Don't free storage See CS:036e709b4ca9
+ DYNARR_INIT( trkSeg_t, sp->bezSegs );
FixUpBezierSeg(sp->u.b.pos,sp,sp->type == SEG_BEZTRK);
break;
default:
@@ -680,8 +713,8 @@ EXPORT void CloneFilledDraw(
EXPORT void FreeFilledDraw(
- int segCnt,
- trkSeg_p segs )
+ int segCnt,
+ trkSeg_p segs )
{
trkSeg_p sp;
@@ -689,13 +722,15 @@ EXPORT void FreeFilledDraw(
switch (sp->type) {
case SEG_POLY:
case SEG_FILPOLY:
- if ( sp->u.p.pts )
+ if ( sp->u.p.pts ) {
MyFree( sp->u.p.pts );
+ }
sp->u.p.pts = NULL;
break;
case SEG_TEXT:
- if (sp->u.t.string)
+ if (sp->u.t.string) {
MyFree(sp->u.t.string);
+ }
sp->u.t.string = NULL;
break;
default:
@@ -713,12 +748,12 @@ EXPORT void FreeFilledDraw(
*/
EXPORT DIST_T DistanceSegs(
- coOrd orig,
- ANGLE_T angle,
- wIndex_t segCnt,
- trkSeg_p segPtr,
- coOrd * pos,
- wIndex_t * inx_ret )
+ coOrd orig,
+ ANGLE_T angle,
+ wIndex_t segCnt,
+ trkSeg_p segPtr,
+ coOrd * pos,
+ wIndex_t * inx_ret )
{
DIST_T d, dd = DIST_INF, ddd;
coOrd p0, p1, p2, pt, lo, hi;
@@ -740,76 +775,85 @@ EXPORT DIST_T DistanceSegs(
case SEG_TBLEDGE:
dd = LineDistance( &p1, segPtr->u.l.pos[0], segPtr->u.l.pos[1] );
if ( segPtr->type == SEG_BENCH ) {
- if ( dd < BenchGetWidth( segPtr->u.l.option )/2.0 )
+ if ( dd < BenchGetWidth( segPtr->u.l.option )/2.0 ) {
dd = 0.0;
+ }
}
break;
case SEG_CRVTRK:
case SEG_CRVLIN:
case SEG_FILCRCL:
- dd = CircleDistance( &p1, segPtr->u.c.center, fabs(segPtr->u.c.radius), segPtr->u.c.a0, segPtr->u.c.a1 );
+ dd = CircleDistance( &p1, segPtr->u.c.center, fabs(segPtr->u.c.radius),
+ segPtr->u.c.a0, segPtr->u.c.a1 );
break;
case SEG_POLY:
case SEG_FILPOLY:
ddd = DIST_INF;
- for (lin=0;lin<segPtr->u.p.cnt;lin++) {
+ for (lin=0; lin<segPtr->u.p.cnt; lin++) {
pt = p0;
- if (lin < segPtr->u.p.cnt-1 )
+ if (lin < segPtr->u.p.cnt-1 ) {
ddd = LineDistance( &pt, segPtr->u.p.pts[lin].pt, segPtr->u.p.pts[lin+1].pt );
- else if (segPtr->u.p.polyType != POLYLINE)
+ } else if (segPtr->u.p.polyType != POLYLINE) {
ddd = LineDistance( &pt, segPtr->u.p.pts[lin].pt, segPtr->u.p.pts[0].pt );
+ }
if ( ddd < dd ) {
dd = ddd;
p1 = pt;
}
}
break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- dd = DIST_INF;
- pt = p0;
- for (int i = 0;i<segPtr->bezSegs.cnt;i++) {
- segProcData2.distance.pos1 = pt;
- SegProc(SEGPROC_DISTANCE,&DYNARR_N(trkSeg_t,segPtr->bezSegs,i),&segProcData2);
- if (segProcData2.distance.dd<dd) {
- dd = segProcData2.distance.dd;
- p1 = segProcData2.distance.pos1;
- }
- }
- break;
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ dd = DIST_INF;
+ pt = p0;
+ for (int i = 0; i<segPtr->bezSegs.cnt; i++) {
+ segProcData2.distance.pos1 = pt;
+ SegProc(SEGPROC_DISTANCE,&DYNARR_N(trkSeg_t,segPtr->bezSegs,i),&segProcData2);
+ if (segProcData2.distance.dd<dd) {
+ dd = segProcData2.distance.dd;
+ p1 = segProcData2.distance.pos1;
+ }
+ }
+ break;
case SEG_TEXT:
/*GetTextBounds( segPtr->u.t.pos, angle+segPtr->u.t.angle, segPtr->u.t.string, segPtr->u.t.fontSize, &lo, &hi );*/
- GetTextBounds( zero, 0, segPtr->u.t.string, segPtr->u.t.fontSize, &lo, &hi ); //lo and hi are relative to seg origin
- p0.x -= segPtr->u.t.pos.x;
- p0.y -= segPtr->u.t.pos.y;
- Rotate( &p0, zero, -segPtr->u.t.angle );
- if (p0.x > lo.x && p0.x < hi.x && p0.y >lo.y && p0.y < hi.y) { //Within rectangle - therefore small dist
+ GetTextBounds( zero, 0, segPtr->u.t.string, segPtr->u.t.fontSize, &lo,
+ &hi ); //lo and hi are relative to seg origin
+ p1.x -= segPtr->u.t.pos.x;
+ p1.y -= segPtr->u.t.pos.y;
+ Rotate( &p1, zero, -segPtr->u.t.angle );
+ if (p1.x > lo.x && p1.x < hi.x && p1.y >lo.y
+ && p1.y < hi.y) { //Within rectangle - therefore small dist
hi.x /= 2.0;
hi.y /= 2.0;
- dd = 0.1*FindDistance(hi, p0)/FindDistance(lo,hi); // Proportion to mean that the closer we to the center or the smaller the target in overlapping cases, the more likely we pick it
+ dd = 0.1*FindDistance(hi, p1)/FindDistance(lo,
+ hi); // Proportion to mean that the closer we to the center or the smaller the target in overlapping cases, the more likely we pick it
break;
}
hi.x /= 2.0; // rough center of rectangle
hi.y /= 2.0;
- if (fabs((p0.x-hi.x)/hi.x)<fabs((p0.y-hi.y)/hi.y)) { // Proportionally closer to x
- if (p0.x > hi.x) dd = (p0.x - hi.x);
- else dd = fabs(p0.x-hi.x);
+ if (fabs((p1.x-hi.x)/hi.x)<fabs((p1.y
+ -hi.y)/hi.y)) { // Proportionally closer to x
+ if (p1.x > hi.x) { dd = (p1.x - hi.x); }
+ else { dd = fabs(p1.x-hi.x); }
} else { // Closer to y
- if (p0.y > hi.y) dd = (p0.y - hi.y);
- else dd = fabs(p0.y-hi.y);
+ if (p1.y > hi.y) { dd = (p1.y - hi.y); }
+ else { dd = fabs(p1.y-hi.y); }
}
/*printf( "dx=%0.4f dy=%0.4f dd=%0.3f\n", dx, dy, dd );*/
-/*
- if ( p0.x >= lo.x && p0.x <= hi.x &&
- p0.y >= lo.y && p0.y <= hi.y ) {
- p1.x = (lo.x+hi.x)/2.0;
- p1.y = (lo.y+hi.y)/2.0;
- dd = FindDistance( p0, p1 );
- }
-*/
+ /*
+ if ( p1.x >= lo.x && p1.x <= hi.x &&
+ p1.y >= lo.y && p1.y <= hi.y ) {
+ p1.x = (lo.x+hi.x)/2.0;
+ p1.y = (lo.y+hi.y)/2.0;
+ dd = FindDistance( p1, p1 );
+ }
+ */
break;
case SEG_JNTTRK:
- dd = JointDistance( &p1, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.Scurve );
+ dd = JointDistance( &p1, segPtr->u.j.pos, segPtr->u.j.angle, segPtr->u.j.l0,
+ segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate,
+ segPtr->u.j.Scurve );
break;
default:
dd = DIST_INF;
@@ -817,8 +861,9 @@ EXPORT DIST_T DistanceSegs(
if (dd < d) {
d = dd;
p2 = p1;
- if (inx_ret)
+ if (inx_ret) {
*inx_ret = inx;
+ }
found = TRUE;
}
}
@@ -837,14 +882,14 @@ EXPORT DIST_T DistanceSegs(
*
*/
EXPORT ANGLE_T GetAngleSegs(
- wIndex_t segCnt,
- trkSeg_p segPtr,
- coOrd * pos1, // Now IN/OUT OUT =
- wIndex_t * segInxR,
- DIST_T * dist,
- BOOL_T * seg_backwards,
- wIndex_t * subSegInxR,
- BOOL_T * negative_radius)
+ wIndex_t segCnt,
+ trkSeg_p segPtr,
+ coOrd * pos1, // Now IN/OUT OUT =
+ wIndex_t * segInxR,
+ DIST_T * dist,
+ BOOL_T * seg_backwards,
+ wIndex_t * subSegInxR,
+ BOOL_T * negative_radius)
{
wIndex_t inx;
ANGLE_T angle = 0.0;
@@ -854,10 +899,10 @@ EXPORT ANGLE_T GetAngleSegs(
coOrd pos2 = * pos1;
BOOL_T negative = FALSE;
BOOL_T backwards = FALSE;
- if (subSegInxR) *subSegInxR = -1;
+ if (subSegInxR) { *subSegInxR = -1; }
d = DistanceSegs( zero, 0.0, segCnt, segPtr, &pos2, &inx ); //
- if (dist) * dist = d;
+ if (dist) { * dist = d; }
segPtr += inx;
segProcData.getAngle.pos = pos2;
switch ( segPtr->type ) {
@@ -881,26 +926,28 @@ EXPORT ANGLE_T GetAngleSegs(
JointSegProc( SEGPROC_GETANGLE, segPtr, &segProcData );
angle = segProcData.getAngle.angle;
break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- BezierSegProc( SEGPROC_GETANGLE, segPtr, &segProcData );
- angle = segProcData.getAngle.angle;
- negative = segProcData.getAngle.negative_radius;
- backwards = segProcData.getAngle.backwards;
- if (subSegInxR) *subSegInxR = segProcData.getAngle.bezSegInx;
- break;
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ BezierSegProc( SEGPROC_GETANGLE, segPtr, &segProcData );
+ angle = segProcData.getAngle.angle;
+ negative = segProcData.getAngle.negative_radius;
+ backwards = segProcData.getAngle.backwards;
+ if (subSegInxR) { *subSegInxR = segProcData.getAngle.bezSegInx; }
+ break;
case SEG_POLY:
case SEG_FILPOLY:
p0 = p1 = pos2;
- dd = LineDistance( &p0, segPtr->u.p.pts[segPtr->u.p.cnt-1].pt, segPtr->u.p.pts[0].pt );
- angle = FindAngle( segPtr->u.p.pts[segPtr->u.p.cnt-1].pt, segPtr->u.p.pts[0].pt );
+ dd = LineDistance( &p0, segPtr->u.p.pts[segPtr->u.p.cnt-1].pt,
+ segPtr->u.p.pts[0].pt );
+ angle = FindAngle( segPtr->u.p.pts[segPtr->u.p.cnt-1].pt,
+ segPtr->u.p.pts[0].pt );
for ( inx=0; inx<segPtr->u.p.cnt-1; inx++ ) {
p0 = p1;
d = LineDistance( &p0, segPtr->u.p.pts[inx].pt, segPtr->u.p.pts[inx+1].pt );
if ( d < dd ) {
dd = d;
angle = FindAngle( segPtr->u.p.pts[inx].pt, segPtr->u.p.pts[inx+1].pt );
- if (subSegInxR) *subSegInxR = inx;
+ if (subSegInxR) { *subSegInxR = inx; }
pos2 = p0;
}
}
@@ -909,11 +956,11 @@ EXPORT ANGLE_T GetAngleSegs(
angle = segPtr->u.t.angle;
break;
default:
- AbortProg( "GetAngleSegs(%d)", segPtr->type );
+ CHECKMSG( FALSE, ( "GetAngleSegs(%d)", segPtr->type ) );
}
- if ( segInxR ) *segInxR = inx;
- if (seg_backwards) *seg_backwards = backwards;
- if (negative_radius) *negative_radius = negative;
+ if ( segInxR ) { *segInxR = inx; }
+ if (seg_backwards) { *seg_backwards = backwards; }
+ if (negative_radius) { *negative_radius = negative; }
* pos1 = pos2;
return angle;
@@ -926,72 +973,70 @@ EXPORT ANGLE_T GetAngleSegs(
****************************************************************************/
typedef struct {
- FLOAT_T h, s, v;
- } hsv_t;
+ FLOAT_T h, s, v;
+} hsv_t;
static FLOAT_T max_s;
static FLOAT_T max_v;
static dynArr_t hsv_da;
#define hsv(N) DYNARR_N( hsv_t, hsv_da, N )
static void Hsv2rgb(
- hsv_t hsv,
- long *rgb )
+ hsv_t hsv,
+ long *rgb )
{
- int i;
- FLOAT_T f, w, q, t, r=0, g=0, b=0;
-
- if (hsv.s == 0.0)
- hsv.s = 0.000001;
+ int i;
+ FLOAT_T f, w, q, t, r=0, g=0, b=0;
- if (hsv.h == -1.0)
- {
- r = hsv.v;
- g = hsv.v;
- b = hsv.v;
+ if (hsv.s == 0.0) {
+ hsv.s = 0.000001;
}
- else
- {
- if (hsv.h == 360.0)
- hsv.h = 0.0;
- hsv.h = hsv.h / 60.0;
- i = (int) hsv.h;
- f = hsv.h - i;
- w = hsv.v * (1.0 - hsv.s);
- q = hsv.v * (1.0 - (hsv.s * f));
- t = hsv.v * (1.0 - (hsv.s * (1.0 - f)));
-
- switch (i)
- {
+
+ if (hsv.h == -1.0) {
+ r = hsv.v;
+ g = hsv.v;
+ b = hsv.v;
+ } else {
+ if (hsv.h == 360.0) {
+ hsv.h = 0.0;
+ }
+ hsv.h = hsv.h / 60.0;
+ i = (int) hsv.h;
+ f = hsv.h - i;
+ w = hsv.v * (1.0 - hsv.s);
+ q = hsv.v * (1.0 - (hsv.s * f));
+ t = hsv.v * (1.0 - (hsv.s * (1.0 - f)));
+
+ switch (i) {
case 0:
- r = hsv.v;
- g = t;
- b = w;
- break;
+ r = hsv.v;
+ g = t;
+ b = w;
+ break;
case 1:
- r = q;
- g = hsv.v;
- b = w;
- break;
+ r = q;
+ g = hsv.v;
+ b = w;
+ break;
case 2:
- r = w;
- g = hsv.v;
- b = t;
- break;
+ r = w;
+ g = hsv.v;
+ b = t;
+ break;
case 3:
- r = w;
- g = q;
- b = hsv.v;
- break;
+ r = w;
+ g = q;
+ b = hsv.v;
+ break;
case 4:
- r = t;
- g = w;
- b = hsv.v;
- break;
+ r = t;
+ g = w;
+ b = hsv.v;
+ break;
case 5:
- r = hsv.v;
- g = w;
- b = q;
- break;
+ r = hsv.v;
+ g = w;
+ b = q;
+ break;
}
}
*rgb = wRGB( (int)(r*255), (int)(g*255), (int)(b*255) );
@@ -999,60 +1044,66 @@ static void Hsv2rgb(
static void Rgb2hsv(
- long rgb,
- hsv_t *hsv )
+ long rgb,
+ hsv_t *hsv )
{
- FLOAT_T r, g, b;
- FLOAT_T max, min, delta;
-
- r = ((rgb>>16)&0xFF)/255.0;
- g = ((rgb>>8)&0xFF)/255.0;
- b = ((rgb)&0xFF)/255.0;
-
- max = r;
- if (g > max)
- max = g;
- if (b > max)
- max = b;
-
- min = r;
- if (g < min)
- min = g;
- if (b < min)
- min = b;
-
- hsv->v = max;
-
- if (max != 0.0)
- hsv->s = (max - min) / max;
- else
- hsv->s = 0.0;
-
- if (hsv->s == 0.0)
- hsv->h = -1.0;
- else
- {
- delta = max - min;
-
- if (r == max)
- hsv->h = (g - b) / delta;
- else if (g == max)
- hsv->h = 2.0 + (b - r) / delta;
- else if (b == max)
- hsv->h = 4.0 + (r - g) / delta;
-
- hsv->h = hsv->h * 60.0;
-
- if (hsv->h < 0.0)
- hsv->h = hsv->h + 360;
+ FLOAT_T r, g, b;
+ FLOAT_T max, min, delta;
+
+ r = ((rgb>>16)&0xFF)/255.0;
+ g = ((rgb>>8)&0xFF)/255.0;
+ b = ((rgb)&0xFF)/255.0;
+
+ max = r;
+ if (g > max) {
+ max = g;
+ }
+ if (b > max) {
+ max = b;
+ }
+
+ min = r;
+ if (g < min) {
+ min = g;
+ }
+ if (b < min) {
+ min = b;
+ }
+
+ hsv->v = max;
+
+ if (max != 0.0) {
+ hsv->s = (max - min) / max;
+ } else {
+ hsv->s = 0.0;
+ }
+
+ if (hsv->s == 0.0) {
+ hsv->h = -1.0;
+ } else {
+ delta = max - min;
+
+ if (r == max) {
+ hsv->h = (g - b) / delta;
+ } else if (g == max) {
+ hsv->h = 2.0 + (b - r) / delta;
+ } else if (b == max) {
+ hsv->h = 4.0 + (r - g) / delta;
+ }
+
+ hsv->h = hsv->h * 60.0;
+
+ if (hsv->h < 0.0) {
+ hsv->h = hsv->h + 360;
+ }
}
}
static void Fill_hsv(
- wIndex_t segCnt,
- trkSeg_p segPtr,
- hsv_t * hsvP )
+ wIndex_t segCnt,
+ trkSeg_p segPtr,
+ hsv_t * hsvP )
{
int inx;
@@ -1061,18 +1112,20 @@ static void Fill_hsv(
for ( inx=0; inx<segCnt; inx++ ) {
Rgb2hsv( wDrawGetRGB(segPtr[inx].color), &hsvP[inx] );
if ( hsvP[inx].h >= 0 ) {
- if ( max_s < hsvP[inx].s )
+ if ( max_s < hsvP[inx].s ) {
max_s = hsvP[inx].s;
- if ( max_v < hsvP[inx].v )
+ }
+ if ( max_v < hsvP[inx].v ) {
max_v = hsvP[inx].v;
+ }
}
}
}
EXPORT void RecolorSegs(
- wIndex_t cnt,
- trkSeg_p segs,
- wDrawColor color )
+ wIndex_t cnt,
+ trkSeg_p segs,
+ wDrawColor color )
{
long rgb;
wIndex_t inx;
@@ -1084,18 +1137,21 @@ EXPORT void RecolorSegs(
rgb = wDrawGetRGB( color );
Rgb2hsv( rgb, &hsv0 );
h = hsv0.h;
- if ( max_s > 0.25 )
+ if ( max_s > 0.25 ) {
s = hsv0.s/max_s;
- else
+ } else {
s = 1.0;
- if ( max_v > 0.25 )
+ }
+ if ( max_v > 0.25 ) {
v = hsv0.v/max_v;
- else
+ } else {
v = 1.0;
+ }
for ( inx=0; inx<cnt; inx++,segs++ ) {
hsv0 = hsv(inx);
- if ( hsv0.h < 0 ) /* ignore black */
+ if ( hsv0.h < 0 ) { /* ignore black */
continue;
+ }
hsv0.h = h;
hsv0.s *= s;
hsv0.v *= v;
@@ -1131,28 +1187,26 @@ EXPORT BOOL_T ReadSegs( void )
char *cp, *cpp;
BOOL_T rc=TRUE;
trkSeg_p s;
- trkEndPt_p e;
long rgb;
int i;
DIST_T elev0, elev1;
BOOL_T hasElev;
BOOL_T isPolyV1, isPolyV2;
BOOL_T improvedEnds;
- FLOAT_T ignoreFloat;
char type;
char * plain_text;
- long option, option2;
+ long option;
BOOL_T subsegs = FALSE;
descriptionOff = zero;
tempSpecial[0] = '\0';
tempCustom[0] = '\0';
DYNARR_RESET( trkSeg_t, tempSegs_da );
- DYNARR_RESET( trkEndPt_t, tempEndPts_da );
+ TempEndPtsReset();
pathCnt = 0;
AppendPath(0); // End of all paths
while ( rc && ((cp = GetNextLine()) != NULL) ) {
- while (isspace(*cp)) cp++;
+ while (isspace(*cp)) { cp++; }
hasElev = FALSE;
improvedEnds = FALSE;
if ( IsEND( END_SEGS ) ) {
@@ -1169,15 +1223,17 @@ EXPORT BOOL_T ReadSegs( void )
if ( *cp == '\0' || *cp == '\n' || *cp == '#' ) {
continue;
}
- if (subsegs) continue;
+ if (subsegs) { continue; }
type = *cp++;
improvedEnds = isPolyV2 = hasElev = isPolyV1 = FALSE;
if ( isdigit( *cp ) ) {
long iVersion = strtol( cp, &cp, 10 );
- if ( iVersion >= 3 )
+ if ( iVersion >= 3 ) {
hasElev = isPolyV1 = TRUE;
- if ( iVersion >= 4 )
+ }
+ if ( iVersion >= 4 ) {
improvedEnds = isPolyV2 = TRUE;
+ }
if ( iVersion > 4 ) {
InputError( "Invalid segment version number, maximum is %d", TRUE, 4 );
break;
@@ -1190,7 +1246,7 @@ EXPORT BOOL_T ReadSegs( void )
s = &tempSegs(tempSegs_da.cnt-1);
s->type = type;
if ( !GetArgs( cp, hasElev?"lwpfpf":"lwpYpY",
- &rgb, &s->width, &s->u.l.pos[0], &elev0, &s->u.l.pos[1], &elev1 ) ) {
+ &rgb, &s->lineWidth, &s->u.l.pos[0], &elev0, &s->u.l.pos[1], &elev1 ) ) {
rc = FALSE;
break;
}
@@ -1203,14 +1259,16 @@ EXPORT BOOL_T ReadSegs( void )
s = &tempSegs(tempSegs_da.cnt-1);
s->type = type;
if ( !GetArgs( cp, hasElev?"lwpfpfl":"lwpYpYZ",
- &rgb, &s->width, &s->u.l.pos[0], &elev0, &s->u.l.pos[1], &elev1, &option ) ) {
+ &rgb, &s->lineWidth, &s->u.l.pos[0], &elev0, &s->u.l.pos[1], &elev1,
+ &option ) ) {
rc = FALSE;
break;
}
- if ( type == SEG_DIMLIN )
+ if ( type == SEG_DIMLIN ) {
s->u.l.option = option;
- else
+ } else {
s->u.l.option = BenchInputOption(option);
+ }
s->color = wDrawFindColor( rgb );
break;
case SEG_CRVLIN:
@@ -1218,11 +1276,11 @@ EXPORT BOOL_T ReadSegs( void )
s = &tempSegs(tempSegs_da.cnt-1);
s->type = SEG_CRVLIN;
if ( !GetArgs( cp, hasElev?"lwfpfff":"lwfpYff",
- &rgb, &s->width,
- &s->u.c.radius,
- &s->u.c.center,
- &elev0,
- &s->u.c.a0, &s->u.c.a1 ) ) {
+ &rgb, &s->lineWidth,
+ &s->u.c.radius,
+ &s->u.c.center,
+ &elev0,
+ &s->u.c.a0, &s->u.c.a1 ) ) {
rc = FALSE;
break;
}
@@ -1232,13 +1290,11 @@ EXPORT BOOL_T ReadSegs( void )
DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 );
s = &tempSegs(tempSegs_da.cnt-1);
s->type = SEG_STRTRK;
- s->bezSegs.max = 0;
- s->bezSegs.cnt = 0;
- s->bezSegs.ptr = NULL;
+ DYNARR_INIT( trkSeg_t, s->bezSegs );
if ( !GetArgs( cp, hasElev?"lwpfpf":"lwpYpY",
- &rgb, &s->width,
- &s->u.l.pos[0], &elev0,
- &s->u.l.pos[1], &elev1 ) ) {
+ &rgb, &s->lineWidth,
+ &s->u.l.pos[0], &elev0,
+ &s->u.l.pos[1], &elev1 ) ) {
rc = FALSE;
break;
}
@@ -1248,15 +1304,13 @@ EXPORT BOOL_T ReadSegs( void )
DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 );
s = &tempSegs(tempSegs_da.cnt-1);
s->type = SEG_CRVTRK;
- s->bezSegs.max = 0;
- s->bezSegs.cnt = 0;
- s->bezSegs.ptr = NULL;
+ DYNARR_INIT( trkSeg_t, s->bezSegs );
if ( !GetArgs( cp, hasElev?"lwfpfff":"lwfpYff",
- &rgb, &s->width,
- &s->u.c.radius,
- &s->u.c.center,
- &elev0,
- &s->u.c.a0, &s->u.c.a1 ) ) {
+ &rgb, &s->lineWidth,
+ &s->u.c.radius,
+ &s->u.c.center,
+ &elev0,
+ &s->u.c.a0, &s->u.c.a1 ) ) {
rc = FALSE;
break;
}
@@ -1267,15 +1321,15 @@ EXPORT BOOL_T ReadSegs( void )
s = &tempSegs(tempSegs_da.cnt-1);
s->type = SEG_JNTTRK;
if ( !GetArgs( cp, hasElev?"lwpffffffl":"lwpYfffffl",
- &rgb, &s->width,
- &s->u.j.pos,
- &elev0,
- &s->u.j.angle,
- &s->u.j.l0,
- &s->u.j.l1,
- &s->u.j.R,
- &s->u.j.L,
- &option ) ) {
+ &rgb, &s->lineWidth,
+ &s->u.j.pos,
+ &elev0,
+ &s->u.j.angle,
+ &s->u.j.l0,
+ &s->u.j.l1,
+ &s->u.j.R,
+ &s->u.j.L,
+ &option ) ) {
rc = FALSE;
break;
}
@@ -1284,51 +1338,47 @@ EXPORT BOOL_T ReadSegs( void )
s->u.j.Scurve = ( option&4 )!=0;
s->color = wDrawFindColor( rgb );
break;
- case SEG_BEZTRK:
- DYNARR_APPEND( trkSeg_t, tempSegs_da, 10);
- s = &tempSegs(tempSegs_da.cnt-1);
- s->type=SEG_BEZTRK;
- s->bezSegs.max=0;
- s->bezSegs.ptr= NULL;
- s->bezSegs.cnt=0;
- if ( !GetArgs( cp, "lwpppp",
- &rgb, &s->width,
- &s->u.b.pos[0],
- &s->u.b.pos[1],
- &s->u.b.pos[2],
- &s->u.b.pos[3])) {
- rc = FALSE;
- break;
- }
- s->color = wDrawFindColor( rgb );
- break;
- case SEG_BEZLIN:
- DYNARR_APPEND( trkSeg_t, tempSegs_da, 10);
- s = &tempSegs(tempSegs_da.cnt-1);
- s->type=SEG_BEZLIN;
- s->bezSegs.max=0;
- s->bezSegs.ptr= NULL;
- s->bezSegs.cnt=0;
- if ( !GetArgs( cp, "lwpppp",
- &rgb, &s->width,
- &s->u.b.pos[0],
- &s->u.b.pos[1],
- &s->u.b.pos[2],
- &s->u.b.pos[3])) {
- rc = FALSE;
- break;
- }
- s->color = wDrawFindColor( rgb );
- break;
+ case SEG_BEZTRK:
+ DYNARR_APPEND( trkSeg_t, tempSegs_da, 10);
+ s = &tempSegs(tempSegs_da.cnt-1);
+ s->type=SEG_BEZTRK;
+ DYNARR_INIT( trkSet_t, s->bezSegs );
+ if ( !GetArgs( cp, "lwpppp",
+ &rgb, &s->lineWidth,
+ &s->u.b.pos[0],
+ &s->u.b.pos[1],
+ &s->u.b.pos[2],
+ &s->u.b.pos[3])) {
+ rc = FALSE;
+ break;
+ }
+ s->color = wDrawFindColor( rgb );
+ break;
+ case SEG_BEZLIN:
+ DYNARR_APPEND( trkSeg_t, tempSegs_da, 10);
+ s = &tempSegs(tempSegs_da.cnt-1);
+ s->type=SEG_BEZLIN;
+ DYNARR_INIT( trkSet_t, s->bezSegs );
+ if ( !GetArgs( cp, "lwpppp",
+ &rgb, &s->lineWidth,
+ &s->u.b.pos[0],
+ &s->u.b.pos[1],
+ &s->u.b.pos[2],
+ &s->u.b.pos[3])) {
+ rc = FALSE;
+ break;
+ }
+ s->color = wDrawFindColor( rgb );
+ break;
case SEG_FILCRCL:
DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 );
s = &tempSegs(tempSegs_da.cnt-1);
s->type = SEG_FILCRCL;
if ( !GetArgs( cp, hasElev?"lwfpf":"lwfpY",
- &rgb, &s->width,
- &s->u.c.radius,
- &s->u.c.center,
- &elev0 ) ) {
+ &rgb, &s->lineWidth,
+ &s->u.c.radius,
+ &s->u.c.center,
+ &elev0 ) ) {
rc = FALSE;
/*??*/break;
}
@@ -1343,15 +1393,14 @@ EXPORT BOOL_T ReadSegs( void )
s->type = type;
s->u.p.polyType = FREEFORM;
if ( !GetArgs( cp,
- isPolyV2?"lwdd":"lwdX",
- &rgb,
- &s->width,
- &s->u.p.cnt,
- &s->u.p.polyType) ) {
+ isPolyV2?"lwdd":"lwdX",
+ &rgb,
+ &s->lineWidth,
+ &s->u.p.cnt,
+ &s->u.p.polyType) ) {
rc = FALSE;
/*??*/break;
}
- if (s->type == SEG_FILPOLY) s->u.p.polyType = FREEFORM; //Ensure closed if filled
s->color = wDrawFindColor( rgb );
s->u.p.pts = (pts_t*)MyMalloc( s->u.p.cnt * sizeof (pts_t) );
for ( i=0; i<s->u.p.cnt; i++ ) {
@@ -1359,10 +1408,10 @@ EXPORT BOOL_T ReadSegs( void )
if (cp == NULL ||
!GetArgs( cp,
// TODO: does elev belong here instead of the seg header?
- isPolyV2?"pdY":isPolyV1?"pXf":"pXY",
- &s->u.p.pts[i].pt,
- &s->u.p.pts[i].pt_type,
- &elev0 )) {
+ isPolyV2?"pdY":isPolyV1?"pXf":"pXY",
+ &s->u.p.pts[i].pt,
+ &s->u.p.pts[i].pt_type,
+ &elev0 )) {
rc = FALSE;
}
}
@@ -1374,7 +1423,8 @@ EXPORT BOOL_T ReadSegs( void )
s = &tempSegs(tempSegs_da.cnt-1);
s->type = type;
s->u.t.fontP = NULL;
- if ( !GetArgs( cp, "lpfdfq", &rgb, &s->u.t.pos, &s->u.t.angle, &s->u.t.boxed, &s->u.t.fontSize, &plain_text ) ) {
+ if ( !GetArgs( cp, "lpfdfq", &rgb, &s->u.t.pos, &s->u.t.angle, &s->u.t.boxed,
+ &s->u.t.fontSize, &plain_text ) ) {
rc = FALSE;
/*??*/break;
}
@@ -1383,79 +1433,19 @@ EXPORT BOOL_T ReadSegs( void )
break;
case SEG_UNCEP:
case SEG_CONEP:
- DYNARR_APPEND( trkEndPt_t, tempEndPts_da, 10 );
- e = &tempEndPts(tempEndPts_da.cnt-1);
- if (type == SEG_CONEP) {
- if ( !GetArgs( cp, "dc", &e->index, &cp ) ) {
- rc = FALSE;
- /*??*/break;
- }
- } else {
- e->index = -1;
- }
- if ( !GetArgs( cp, "pfc",
- &e->pos, &e->angle, &cp) ) {
- rc = FALSE;
- /*??*/break;
- }
- e->elev.option = 0;
- e->elev.u.height = 0.0;
- e->elev.doff = zero;
- e->option = 0;
- if (improvedEnds) { //E4 and T4
- if (!GetArgs( cp, "lpc", &option, &e->elev.doff, &cp )) {
- rc = FALSE;
- /*??*/break;
- }
- switch (option&ELEV_MASK) {
- case ELEV_STATION:
- GetArgs( cp, "qc", &e->elev.u.name, &cp);
- break;
- default:
- GetArgs( cp, "fc", &e->elev.u.height, &cp); //First height
- }
- DIST_T height2;
- if (!GetArgs( cp, "flLlc", &height2, &option2, &e->elev.option, &e->option, &cp ) ) {
- rc = FALSE;
- break;
- }
- if (option2) e->elev.option |= ELEV_VISIBLE;
- GetArgs(cp, "fc", &ignoreFloat, &cp);
- break;
- }
- if ( cp != NULL ) {
- if (paramVersion < 7) {
- GetArgs( cp, "dfp", &e->elev.option, &e->elev.u.height, &e->elev.doff, &cp );
- /*??*/break;
- }
- GetArgs( cp, "lpc", &option, &e->elev.doff, &cp );
- e->option = option >> 8;
- e->elev.option = (int)(option&0xFF);
- if ( (e->elev.option&ELEV_MASK) != ELEV_NONE ) {
- switch (e->elev.option&ELEV_MASK) {
- case ELEV_DEF:
- GetArgs( cp, "fc", &e->elev.u.height, &cp );
- break;
- case ELEV_STATION:
- GetArgs( cp, "qc", &e->elev.u.name, &cp );
- /*??*/break;
- default:
- ;
- }
- }
- }
+ rc = GetEndPtArg( cp, type, improvedEnds );
break;
case SEG_PATH:
- while (isspace(*cp)) cp++;
- if (*cp == '\"') cp++;
+ while (isspace(*cp)) { cp++; }
+ if (*cp == '\"') { cp++; }
pathCnt--; // Overwrite previous terminator
- while ( *cp != '\"') AppendPath((signed char)*cp++); // Name of path
+ while ( *cp != '\"') { AppendPath((signed char)*cp++); } // Name of path
AppendPath(0); // End of name
cp++;
while (1) {
i = (int)strtol(cp, &cpp, 10);
if (cp == cpp)
- /*??*/break;
+ /*??*/{ break; }
cp = cpp;
AppendPath( (signed char)i ); // Segment # of path component
}
@@ -1491,130 +1481,152 @@ EXPORT BOOL_T ReadSegs( void )
}
EXPORT BOOL_T WriteSegs(
- FILE * f,
- wIndex_t segCnt,
- trkSeg_p segs )
+ FILE * f,
+ wIndex_t segCnt,
+ trkSeg_p segs )
{
- return WriteSegsEnd(f,segCnt,segs,TRUE);
+ return WriteSegsEnd(f,segCnt,segs,TRUE);
}
EXPORT BOOL_T WriteSegsEnd(
- FILE * f,
- wIndex_t segCnt,
- trkSeg_p segs, BOOL_T writeEnd)
+ FILE * f,
+ wIndex_t segCnt,
+ trkSeg_p segs, BOOL_T writeEnd)
{
int i, j;
BOOL_T rc = TRUE;
long option;
char * escaped_text;
+ char* trackText;
+#ifdef UTFCONVERT
+ char* out = NULL;
+#endif
for ( i=0; i<segCnt; i++ ) {
switch ( segs[i].type ) {
case SEG_STRTRK:
rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f\n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
- segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
+ segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0;
break;
case SEG_STRLIN:
case SEG_TBLEDGE:
rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f 0 %0.6f %0.6f 0\n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
- segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
+ segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y ) > 0;
break;
case SEG_DIMLIN:
rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f 0 %0.6f %0.6f 0 %ld\n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
- segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y,
- segs[i].u.l.option ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
+ segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y,
+ segs[i].u.l.option ) > 0;
break;
case SEG_BENCH:
rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f 0 %0.6f %0.6f 0 %ld\n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
- segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y,
- BenchOutputOption(segs[i].u.l.option) ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
+ segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y,
+ BenchOutputOption(segs[i].u.l.option) ) > 0;
break;
case SEG_CRVTRK:
rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.c.radius,
- segs[i].u.c.center.x, segs[i].u.c.center.y,
- segs[i].u.c.a0, segs[i].u.c.a1 ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.c.radius,
+ segs[i].u.c.center.x, segs[i].u.c.center.y,
+ segs[i].u.c.a0, segs[i].u.c.a1 ) > 0;
break;
case SEG_JNTTRK:
- option = (segs[i].u.j.negate?1:0) + (segs[i].u.j.flip?2:0) + (segs[i].u.j.Scurve?4:0);
- rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %ld\n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.j.pos.x, segs[i].u.j.pos.y,
- segs[i].u.j.angle,
- segs[i].u.j.l0,
- segs[i].u.j.l1,
- segs[i].u.j.R,
- segs[i].u.j.L,
- option )>0;
- break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n",
- segs[i].type, wDrawGetRGB(segs[i].color),
- segs[i].width,
- segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
- segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y,
- segs[i].u.l.pos[2].x, segs[i].u.l.pos[2].y,
- segs[i].u.l.pos[3].x, segs[i].u.l.pos[3].y ) > 0;
- rc &= fprintf(f,"\tSUBSEGS\n");
- rc &= WriteSegsEnd(f,segs[i].bezSegs.cnt,segs[i].bezSegs.ptr,FALSE);
- rc &= fprintf(f,"\tSUBSEND\n");
- break;
+ option = (segs[i].u.j.negate?1:0) + (segs[i].u.j.flip?2:0) +
+ (segs[i].u.j.Scurve?4:0);
+ rc &= fprintf( f,
+ "\t%c %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %ld\n",
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.j.pos.x, segs[i].u.j.pos.y,
+ segs[i].u.j.angle,
+ segs[i].u.j.l0,
+ segs[i].u.j.l1,
+ segs[i].u.j.R,
+ segs[i].u.j.L,
+ option )>0;
+ break;
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ rc &= fprintf( f,
+ "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n",
+ segs[i].type, wDrawGetRGB(segs[i].color),
+ segs[i].lineWidth,
+ segs[i].u.l.pos[0].x, segs[i].u.l.pos[0].y,
+ segs[i].u.l.pos[1].x, segs[i].u.l.pos[1].y,
+ segs[i].u.l.pos[2].x, segs[i].u.l.pos[2].y,
+ segs[i].u.l.pos[3].x, segs[i].u.l.pos[3].y ) > 0;
+ rc &= fprintf(f,"\tSUBSEGS\n");
+ rc &= WriteSegsEnd(f,segs[i].bezSegs.cnt,
+ &DYNARR_N(trkSeg_t,segs[i].bezSegs,0), FALSE);
+ rc &= fprintf(f,"\tSUBSEND\n");
+ break;
case SEG_CRVLIN:
rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f 0 %0.6f %0.6f\n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.c.radius,
- segs[i].u.c.center.x, segs[i].u.c.center.y,
- segs[i].u.c.a0, segs[i].u.c.a1 ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.c.radius,
+ segs[i].u.c.center.x, segs[i].u.c.center.y,
+ segs[i].u.c.a0, segs[i].u.c.a1 ) > 0;
break;
case SEG_FILCRCL:
rc &= fprintf( f, "\t%c3 %ld %0.6f %0.6f %0.6f %0.6f 0\n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.c.radius,
- segs[i].u.c.center.x, segs[i].u.c.center.y ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.c.radius,
+ segs[i].u.c.center.x, segs[i].u.c.center.y ) > 0;
break;
case SEG_POLY:
case SEG_FILPOLY:
// TODO: to be consistent, we should add a dummy 0 for elev. See ReadSegs/SEG_POLY
rc &= fprintf( f, "\t%c4 %ld %0.6f %d %d \n",
- segs[i].type, wDrawGetRGB(segs[i].color), segs[i].width,
- segs[i].u.p.cnt, segs[i].u.p.polyType ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color), segs[i].lineWidth,
+ segs[i].u.p.cnt, segs[i].u.p.polyType ) > 0;
for ( j=0; j<segs[i].u.p.cnt; j++ )
rc &= fprintf( f, "\t\t%0.6f %0.6f %d\n",
- segs[i].u.p.pts[j].pt.x, segs[i].u.p.pts[j].pt.y, segs[i].u.p.pts[j].pt_type ) > 0;
+ segs[i].u.p.pts[j].pt.x, segs[i].u.p.pts[j].pt.y,
+ segs[i].u.p.pts[j].pt_type ) > 0;
break;
case SEG_TEXT: /* 0pf0fq */
- escaped_text = ConvertToEscapedText(segs[i].u.t.string);
+#ifdef UTFCONVERT
+ if (RequiresConvToUTF8(segs[i].u.t.string)) {
+ size_t cnt = strlen(segs[i].u.t.string) * 2 + 1;
+ out = MyMalloc(cnt);
+ wSystemToUTF8(segs[i].u.t.string, out, (unsigned int)cnt);
+ trackText = out;
+ }
+#else
+ trackText = segs[i].u.t.string;
+#endif // UTFCONVERT
+ escaped_text = ConvertToEscapedText(trackText);
rc &= fprintf( f, "\t%c %ld %0.6f %0.6f %0.6f %d %0.6f \"%s\"\n",
- segs[i].type, wDrawGetRGB(segs[i].color),
- segs[i].u.t.pos.x, segs[i].u.t.pos.y, segs[i].u.t.angle,
- segs[i].u.t.boxed,
- segs[i].u.t.fontSize, escaped_text ) > 0;
+ segs[i].type, wDrawGetRGB(segs[i].color),
+ segs[i].u.t.pos.x, segs[i].u.t.pos.y, segs[i].u.t.angle,
+ segs[i].u.t.boxed,
+ segs[i].u.t.fontSize, escaped_text ) > 0;
MyFree(escaped_text);
+#ifdef UTFCONVERT
+ MyFree(out);
+#endif
break;
}
}
- if (writeEnd) rc &= fprintf( f, "\t%s\n", END_SEGS )>0;
+ if (writeEnd) { rc &= fprintf( f, "\t%s\n", END_SEGS )>0; }
return rc;
}
EXPORT void SegProc(
- segProc_e cmd,
- trkSeg_p segPtr,
- segProcData_p data )
+ segProc_e cmd,
+ trkSeg_p segPtr,
+ segProcData_p data )
{
switch (segPtr->type) {
case SEG_STRTRK:
@@ -1628,12 +1640,12 @@ EXPORT void SegProc(
case SEG_JNTTRK:
JointSegProc( cmd, segPtr, data );
break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- BezierSegProc( cmd, segPtr, data);
- break;
- default:
- AbortProg( "SegProg( %d )", segPtr->type );
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ BezierSegProc( cmd, segPtr, data);
+ break;
+ default:
+ CHECKMSG( FALSE, ( "SegProg( %d )", segPtr->type ) );
break;
}
}
@@ -1645,15 +1657,15 @@ EXPORT void SegProc(
*/
EXPORT void DrawDimLine(
- drawCmd_p d,
- coOrd p0,
- coOrd p1,
- char * dimP,
- wFontSize_t fs,
- FLOAT_T middle,
- wDrawWidth width,
- wDrawColor color,
- long option )
+ drawCmd_p d,
+ coOrd p0,
+ coOrd p1,
+ char * dimP,
+ wFontSize_t fs,
+ FLOAT_T middle,
+ wDrawWidth width,
+ wDrawColor color,
+ long option )
{
ANGLE_T a0, a1;
wFont_p fp;
@@ -1662,8 +1674,8 @@ EXPORT void DrawDimLine(
POS_T x, y;
coOrd textsize;
- if ( middle < 0.0 ) middle = 0.0;
- if ( middle > 1.0 ) middle = 1.0;
+ if ( middle < 0.0 ) { middle = 0.0; }
+ if ( middle > 1.0 ) { middle = 1.0; }
a0 = FindAngle( p0, p1 );
dist = fs/144.0;
@@ -1700,37 +1712,37 @@ EXPORT void DrawDimLine(
DrawString( d, s_pos, 0.0, dimP, fp, fs, color );
return;
}
- a1 = FindAngle( zero, size );
- p.x = p0.x+(p1.x-p0.x)*middle;
- p.y = p0.y+(p1.y-p0.y)*middle;
- pc = p;
- p.x -= size.x;
- p.y -= size.y;
- fx = fy = 1;
- if (a0>180) {
- a0 = a0-180;
- fx = fy = -1;
- }
- if (a0>90) {
- a0 = 180-a0;
- fy *= -1;
- }
- if (a0>a1) {
- x = size.x;
- y = x * tan(D2R(90-a0));
- } else {
- y = size.y;
- x = y * tan(D2R(a0));
- }
- DrawString( d, p, 0.0, dimP, fp, fs, color );
- p = pc;
- p.x -= fx*x;
- p.y -= fy*y;
- DrawLine( d, p0, p, width, color );
- p = pc;
- p.x += fx*x;
- p.y += fy*y;
- DrawLine( d, p, p1, width, color );
+ a1 = FindAngle( zero, size );
+ p.x = p0.x+(p1.x-p0.x)*middle;
+ p.y = p0.y+(p1.y-p0.y)*middle;
+ pc = p;
+ p.x -= size.x;
+ p.y -= size.y;
+ fx = fy = 1;
+ if (a0>180) {
+ a0 = a0-180;
+ fx = fy = -1;
+ }
+ if (a0>90) {
+ a0 = 180-a0;
+ fy *= -1;
+ }
+ if (a0>a1) {
+ x = size.x;
+ y = x * tan(D2R(90-a0));
+ } else {
+ y = size.y;
+ x = y * tan(D2R(a0));
+ }
+ DrawString( d, p, 0.0, dimP, fp, fs, color );
+ p = pc;
+ p.x -= fx*x;
+ p.y -= fy*y;
+ DrawLine( d, p0, p, width, color );
+ p = pc;
+ p.x += fx*x;
+ p.y += fy*y;
+ DrawLine( d, p, p1, width, color );
}
/*
@@ -1738,15 +1750,15 @@ EXPORT void DrawDimLine(
* Note that Bezier segments in particular contain sub-arrays of Curve and Straight segments.
*/
EXPORT void DrawSegsO(
- drawCmd_p d,
- track_p trk,
- coOrd orig,
- ANGLE_T angle,
- trkSeg_p segPtr,
- wIndex_t segCnt,
- DIST_T trackGauge,
- wDrawColor color,
- long options )
+ drawCmd_p d,
+ track_p trk,
+ coOrd orig,
+ ANGLE_T angle,
+ trkSeg_p segPtr,
+ wIndex_t segCnt,
+ DIST_T trackGauge,
+ wDrawColor color,
+ long options )
{
wIndex_t i, j;
coOrd p0, p1, p2, p3, c;
@@ -1755,7 +1767,7 @@ EXPORT void DrawSegsO(
DIST_T factor = d->dpi/d->scale;
trkSeg_p tempPtr;
- long option;
+ long option;
wFontSize_t fs;
wBool_t bFill,bThick;
@@ -1768,9 +1780,9 @@ EXPORT void DrawSegsO(
color1 = color2 = color;
}
wDrawWidth thick = 3;
-#ifdef WINDOWS
- thick *= (wDrawWidth)(d->dpi/75.0);
-#endif
+//#ifdef WINDOWS
+// thick *= (LWIDTH_T)(d->dpi/BASE_DPI);
+//#endif
switch (segPtr->type) {
case SEG_STRLIN:
case SEG_DIMLIN:
@@ -1781,25 +1793,26 @@ EXPORT void DrawSegsO(
REORIGIN( p1, segPtr->u.l.pos[1], angle, orig )
switch (segPtr->type) {
case SEG_STRTRK:
- if (color1 == wDrawColorBlack)
+ if (color1 == wDrawColorBlack) {
color1 = normalColor;
- if ( segPtr->color == wDrawColorWhite )
- break;
+ }
if (options&DTS_CENTERONLY) {
DrawLine( d, p0, p1, thick, color1 );
break;
}
+ if ( segPtr->color == wDrawColorWhite ) { break; }
DrawStraightTrack( d,
- p0, p1,
- FindAngle(p1, p0 ),
- trk, color1, options );
+ p0, p1,
+ FindAngle(p1, p0 ),
+ trk, color1, options );
break;
case SEG_STRLIN:;
wDrawWidth w;
- if (segPtr->width <0)
- w = (int)floor(fabs(segPtr->width)+0.5);
- else
- w = (int)floor(fabs(segPtr->width*factor)+0.5);
+ if (segPtr->lineWidth < 0) {
+ w = (int)floor(-segPtr->lineWidth + 0.5);
+ } else {
+ w = (int)floor(segPtr->lineWidth * factor + 0.5);
+ }
DrawLine( d, p0, p1, (d->options&DC_THICK)?thick:w, color1 );
break;
case SEG_DIMLIN:
@@ -1817,15 +1830,18 @@ EXPORT void DrawSegsO(
fs = descriptionFontSize*4;
option = segPtr->u.l.option;
fs /= (option==0?8:option==1?4:option==2?2:1);
- if ( fs < 2 )
+ if ( fs < 2 ) {
fs = 2;
- DrawDimLine( d, p0, p1, FormatDistance(FindDistance(p0,p1)), fs, 0.5, (d->options&DC_THICK)?thick:0, color, option & 0x00 );
+ }
+ DrawDimLine( d, p0, p1, FormatDistance(FindDistance(p0,p1)), fs, 0.5,
+ (d->options&DC_THICK)?thick:0, color, option & 0x00 );
break;
case SEG_BENCH:
DrawBench( d, p0, p1, color1, color2, options, segPtr->u.l.option );
break;
case SEG_TBLEDGE:
- DrawLine( d, p0, p1, (wDrawWidth)floor(3.0/BASE_DPI*d->dpi+0.5) , color );
+ // DrawLine( d, p0, p1, (wDrawWidth)floor(3.0/BASE_DPI*d->dpi+0.5), color );
+ DrawLine(d, p0, p1, 3, color);
break;
}
}
@@ -1837,110 +1853,120 @@ EXPORT void DrawSegsO(
a0 = NormalizeAngle(segPtr->u.c.a0 + angle);
REORIGIN( c, segPtr->u.c.center, angle, orig );
if (segPtr->type == SEG_CRVTRK) {
- if (color1 == wDrawColorBlack)
+ if (color1 == wDrawColorBlack) {
color1 = normalColor;
- if ( segPtr->color == wDrawColorWhite )
- break;
+ }
p0.x = p0.y = p1.x = p1.y = 0;
if (options&DTS_CENTERONLY) {
DrawArc( d, c, fabs(segPtr->u.c.radius), a0, segPtr->u.c.a1,
- FALSE, thick, color1 );
+ FALSE, thick, color1 );
break;
}
+ if ( segPtr->color == wDrawColorWhite ) { break; }
DrawCurvedTrack( d,
- c,
- fabs(segPtr->u.c.radius),
- a0, segPtr->u.c.a1,
- trk, color1, options );
+ c,
+ fabs(segPtr->u.c.radius),
+ a0, segPtr->u.c.a1,
+ trk, color1, options );
} else {
wDrawWidth w;
- if (segPtr->width <0)
- w = (int)floor(fabs(segPtr->width)+0.5);
- else
- w = (int)floor(segPtr->width*factor+0.5);
+ if (segPtr->lineWidth < 0) {
+ w = (int)floor(-segPtr->lineWidth + 0.5);
+ } else {
+ w = (int)floor(segPtr->lineWidth * factor + 0.5);
+ }
DrawArc( d, c, fabs(segPtr->u.c.radius), a0, segPtr->u.c.a1,
- FALSE, (d->options&DC_THICK)?thick:w, color1 );
+ FALSE, (d->options&DC_THICK)?thick:w, color1 );
}
break;
- case SEG_BEZTRK:
- case SEG_BEZLIN:
- if (segPtr->type == SEG_BEZTRK) {
- if (color1 == wDrawColorBlack)
- color1 = normalColor;
- if ( segPtr->color == wDrawColorWhite )
- break;
- }
+ case SEG_BEZTRK:
+ case SEG_BEZLIN:
+ if (segPtr->type == SEG_BEZTRK) {
+ if (color1 == wDrawColorBlack) {
+ color1 = normalColor;
+ }
+ if ( segPtr->color == wDrawColorWhite ) {
+ break;
+ }
+ }
//else {
- REORIGIN(p0,segPtr->u.b.pos[0],angle,orig);
- REORIGIN(p1,segPtr->u.b.pos[1],angle,orig);
- REORIGIN(p2,segPtr->u.b.pos[2],angle,orig);
- REORIGIN(p3,segPtr->u.b.pos[3],angle,orig);
+ REORIGIN(p0,segPtr->u.b.pos[0],angle,orig);
+ REORIGIN(p1,segPtr->u.b.pos[1],angle,orig);
+ REORIGIN(p2,segPtr->u.b.pos[2],angle,orig);
+ REORIGIN(p3,segPtr->u.b.pos[3],angle,orig);
//}
- for(int j=0;j<segPtr->bezSegs.cnt;j++) { //Loop through sub Segs
- tempPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,j);
- switch (tempPtr->type) {
- case SEG_CRVTRK:
- case SEG_CRVLIN:
- a0 = NormalizeAngle(tempPtr->u.c.a0 + angle);
- REORIGIN( c, tempPtr->u.c.center, angle, orig );
- if (tempPtr->type == SEG_CRVTRK) {
- if (color1 == wDrawColorBlack) color1 = normalColor;
- if ( tempPtr->color == wDrawColorWhite ) break;
- p0.x = p0.y = p1.x = p1.y = 0;
- if (options&DTS_CENTERONLY) {
- DrawArc( d, c, fabs(segPtr->u.c.radius), a0, segPtr->u.c.a1,
- FALSE, thick, color1 );
- break;
- }
- DrawCurvedTrack( d,
- c,
- fabs(tempPtr->u.c.radius),
- a0, tempPtr->u.c.a1,
- trk, color1, options );
- } else if (tempPtr->type == SEG_CRVLIN) {
- wDrawWidth w;
- if (tempPtr->width <0)
- w = (int)floor(fabs(tempPtr->width)+0.5);
- else
- w = (int)floor(tempPtr->width*factor+0.5);
- DrawArc( d, c, fabs(tempPtr->u.c.radius), a0, tempPtr->u.c.a1,
- FALSE, (d->options&DC_THICK)?thick:w, color1 );
- }
- break;
- case SEG_STRTRK:
- if (color1 == wDrawColorBlack) color1 = normalColor;
- if ( tempPtr->color == wDrawColorWhite ) break;
- REORIGIN(p0,tempPtr->u.l.pos[0], angle, orig);
- REORIGIN(p1,tempPtr->u.l.pos[1], angle, orig);
- if (options&DTS_CENTERONLY) {
- DrawLine( d, p0, p1, thick, color1 );
+ for(int j=0; j<segPtr->bezSegs.cnt; j++) { //Loop through sub Segs
+ tempPtr = &DYNARR_N(trkSeg_t,segPtr->bezSegs,j);
+ switch (tempPtr->type) {
+ case SEG_CRVTRK:
+ case SEG_CRVLIN:
+ a0 = NormalizeAngle(tempPtr->u.c.a0 + angle);
+ REORIGIN( c, tempPtr->u.c.center, angle, orig );
+ if (tempPtr->type == SEG_CRVTRK) {
+ if (color1 == wDrawColorBlack) { color1 = normalColor; }
+ p0.x = p0.y = p1.x = p1.y = 0;
+ if (options&DTS_CENTERONLY) {
+ DrawArc( d, c, fabs(segPtr->u.c.radius), a0, segPtr->u.c.a1,
+ FALSE, thick, color1 );
break;
}
- DrawStraightTrack( d, p0, p1,
- FindAngle(p1,p0),
- trk,color1,options);
- break;
- case SEG_STRLIN:
- REORIGIN(p0,tempPtr->u.l.pos[0], angle, orig);
- REORIGIN(p1,tempPtr->u.l.pos[1], angle, orig);
- wDrawWidth w;
- if (tempPtr->width <0)
- w = (int)floor(fabs(tempPtr->width)+0.5);
- else
- w = (int)floor(tempPtr->width*factor+0.5);
- DrawLine( d, p0, p1, (d->options&DC_THICK)?thick:w, color1 );
- break;
- }
- }
- break;
+ if ( tempPtr->color == wDrawColorWhite ) { break; }
+ DrawCurvedTrack( d,
+ c,
+ fabs(tempPtr->u.c.radius),
+ a0, tempPtr->u.c.a1,
+ trk, color1, options );
+ } else if (tempPtr->type == SEG_CRVLIN) {
+ wDrawWidth w;
+ if (tempPtr->lineWidth < 0) {
+ w = (int)floor(-tempPtr->lineWidth + 0.5);
+ } else {
+ w = (int)floor(tempPtr->lineWidth*factor+0.5);
+ }
+ DrawArc( d, c, fabs(tempPtr->u.c.radius), a0, tempPtr->u.c.a1,
+ FALSE, (d->options&DC_THICK)?thick:w, color1 );
+ }
+ break;
+ case SEG_STRTRK:
+ if (color1 == wDrawColorBlack) { color1 = normalColor; }
+ REORIGIN(p0,tempPtr->u.l.pos[0], angle, orig);
+ REORIGIN(p1,tempPtr->u.l.pos[1], angle, orig);
+ if (options&DTS_CENTERONLY) {
+ DrawLine( d, p0, p1, thick, color1 );
+ break;
+ }
+ if ( tempPtr->color == wDrawColorWhite ) { break; }
+ DrawStraightTrack( d, p0, p1,
+ FindAngle(p1,p0),
+ trk,color1,options);
+ break;
+ case SEG_STRLIN:
+ REORIGIN(p0,tempPtr->u.l.pos[0], angle, orig);
+ REORIGIN(p1,tempPtr->u.l.pos[1], angle, orig);
+ wDrawWidth w;
+ if (tempPtr->lineWidth < 0) {
+ w = (int)floor(-tempPtr->lineWidth+0.5);
+ } else {
+ w = (int)floor(tempPtr->lineWidth*factor+0.5);
+ }
+ DrawLine( d, p0, p1, (d->options&DC_THICK)?thick:w, color1 );
+ break;
+ }
+ }
+ break;
case SEG_JNTTRK:
REORIGIN( p0, segPtr->u.j.pos, angle, orig );
- DrawJointTrack( d, p0, NormalizeAngle(segPtr->u.j.angle+angle), segPtr->u.j.l0, segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate, segPtr->u.j.flip, segPtr->u.j.Scurve, NULL, -1, -1, trackGauge, color1, options );
+ DrawJointTrack( d, p0, NormalizeAngle(segPtr->u.j.angle+angle), segPtr->u.j.l0,
+ segPtr->u.j.l1, segPtr->u.j.R, segPtr->u.j.L, segPtr->u.j.negate,
+ segPtr->u.j.flip, segPtr->u.j.Scurve, NULL, -1, -1, trackGauge, color1,
+ options );
break;
case SEG_TEXT:
REORIGIN( p0, segPtr->u.t.pos, angle, orig )
- DrawMultiString( d, p0, segPtr->u.t.string, segPtr->u.t.fontP, segPtr->u.t.fontSize, color1, NormalizeAngle(angle + segPtr->u.t.angle), NULL, NULL, segPtr->u.t.boxed );
+ DrawMultiString( d, p0, segPtr->u.t.string, segPtr->u.t.fontP,
+ segPtr->u.t.fontSize, color1, NormalizeAngle(angle + segPtr->u.t.angle), NULL,
+ NULL, segPtr->u.t.boxed );
break;
case SEG_FILPOLY:
case SEG_POLY:
@@ -1950,34 +1976,39 @@ EXPORT void DrawSegsO(
coOrd *tempPts = malloc(sizeof(coOrd)*segPtr->u.p.cnt);
int *tempTypes = malloc(sizeof(int)*segPtr->u.p.cnt);
// coOrd tempPts[segPtr->u.p.cnt];
- for (j=0;j<segPtr->u.p.cnt;j++) {
+ for (j=0; j<segPtr->u.p.cnt; j++) {
REORIGIN( tempPts[j], segPtr->u.p.pts[j].pt, angle, orig );
tempTypes[j] = segPtr->u.p.pts[j].pt_type;
}
bFill = (segPtr->type == SEG_FILPOLY);
- if ( (d->options&DC_SIMPLE) && programMode != MODE_TRAIN )
+ if ( (d->options&DC_SIMPLE) && programMode != MODE_TRAIN ) {
bFill = FALSE;
+ }
// If we are drawing highlights for Select, don't fill just edges
bThick = d->options&DC_THICK;
- if (&tempD == d && ( color == wDrawColorPreviewSelected || color == wDrawColorPreviewUnselected || color == selectedColor)) {
+ if (&tempD == d && ( color == wDrawColorPreviewSelected
+ || color == wDrawColorPreviewUnselected || color == selectedColor)) {
bFill = FALSE;
bThick = TRUE;
}
wDrawWidth w;
- if (segPtr->width <0)
- w = (int)floor(fabs(segPtr->width)+0.5);
- else
- w = (int)floor(segPtr->width*factor+0.5);
+ if (segPtr->lineWidth < 0) {
+ w = (int)floor(-segPtr->lineWidth + 0.5);
+ } else {
+ w = (int)floor(segPtr->lineWidth * factor + 0.5);
+ }
drawFill_e eOptFill;
- if ( bFill )
+ if ( bFill ) {
eOptFill = DRAW_FILL;
- else if ( segPtr->u.p.polyType == POLYLINE )
+ } else if ( segPtr->u.p.polyType == POLYLINE ) {
eOptFill = DRAW_OPEN;
- else
+ } else {
eOptFill = DRAW_CLOSED;
- DrawPoly( d, segPtr->u.p.cnt, tempPts, tempTypes, color1, bThick?thick:w, eOptFill );
+ }
+ DrawPoly( d, segPtr->u.p.cnt, tempPts, tempTypes, color1, bThick?thick:w,
+ eOptFill );
free(tempPts);
free(tempTypes);
@@ -1985,12 +2016,14 @@ EXPORT void DrawSegsO(
case SEG_FILCRCL:
REORIGIN( c, segPtr->u.c.center, angle, orig )
bFill = TRUE;
- if ( (d->options&DC_SIMPLE) && programMode != MODE_TRAIN )
+ if ( (d->options&DC_SIMPLE) && programMode != MODE_TRAIN ) {
bFill = FALSE;
+ }
// If we are drawing highlights for Select, don't fill just edges
bThick = d->options&DC_THICK;
- if (&tempD == d && (color == wDrawColorPreviewSelected || color == wDrawColorPreviewUnselected || color == selectedColor)) {
+ if (&tempD == d && (color == wDrawColorPreviewSelected
+ || color == wDrawColorPreviewUnselected || color == selectedColor)) {
bFill = FALSE;
bThick = TRUE;
}
@@ -1998,7 +2031,7 @@ EXPORT void DrawSegsO(
DrawFillCircle( d, c, fabs(segPtr->u.c.radius), color1 );
} else {
DrawArc( d, c, fabs(segPtr->u.c.radius), 0, 360,
- FALSE, bThick?thick:(wDrawWidth)0, color1 );
+ FALSE, bThick?thick:(wDrawWidth)0, color1 );
}
break;
}
@@ -2011,96 +2044,70 @@ EXPORT void DrawSegsO(
*/
EXPORT void DrawSegs(
- drawCmd_p d,
- coOrd orig,
- ANGLE_T angle,
- trkSeg_p segPtr,
- wIndex_t segCnt,
- DIST_T trackGauge,
- wDrawColor color )
+ drawCmd_p d,
+ coOrd orig,
+ ANGLE_T angle,
+ trkSeg_p segPtr,
+ wIndex_t segCnt,
+ DIST_T trackGauge,
+ wDrawColor color )
+{
+
+ DrawSegsO( d, NULL, orig, angle, segPtr, segCnt, trackGauge, color,
+ DTS_LEFT|DTS_RIGHT );
+}
+
+/*
+ * Draw Segments from a DynArr
+ */
+
+EXPORT void DrawSegsDA(
+ drawCmd_p d,
+ track_p trk,
+ coOrd orig,
+ ANGLE_T angle,
+ dynArr_t *da,
+ DIST_T trackGauge,
+ wDrawColor color,
+ long options )
{
- DrawSegsO( d, NULL, orig, angle, segPtr, segCnt, trackGauge, color, DTS_LEFT|DTS_RIGHT );
+ if ( da->cnt > 0 ) {
+ DrawSegsO( d, trk, orig, angle, &DYNARR_N(trkSeg_t,*da,0), da->cnt,
+ trackGauge, color, options );
+ }
}
/*
* Free dynamic storage added to each of an array of Track Segments.
*/
-EXPORT void CleanSegs(dynArr_t * seg_p) {
- if (seg_p->cnt ==0) return;
- for (int i=0;i<seg_p->cnt;i++) {
+EXPORT void CleanSegs(dynArr_t * seg_p)
+{
+ if (seg_p->cnt ==0) { return; }
+ for (int i=0; i<seg_p->cnt; i++) {
trkSeg_t t = DYNARR_N(trkSeg_t,* seg_p,i);
if (t.type == SEG_BEZLIN || t.type == SEG_BEZTRK) {
- if (t.bezSegs.ptr) MyFree(t.bezSegs.ptr);
- t.bezSegs.cnt = 0;
- t.bezSegs.max = 0;
- t.bezSegs.ptr = NULL;
+ DYNARR_FREE( trkSeg_t, t.bezSegs );
}
if (t.type == SEG_POLY || t.type == SEG_FILPOLY) {
- if (t.u.p.pts) MyFree(t.u.p.pts);
+ if (t.u.p.pts) { MyFree(t.u.p.pts); }
t.u.p.cnt = 0;
t.u.p.pts = NULL;
}
}
- seg_p->cnt = 0;
- if (seg_p->ptr) MyFree(seg_p->ptr);
- seg_p->ptr = NULL;
- seg_p->max = 0;
-}
-/*
- * Copy Segs from one array to another
- */
-EXPORT void AppendSegsToArray(dynArr_t * seg_to, dynArr_t * seg_from) {
- if (seg_from->cnt ==0) return;
- int j = 0;
- DYNARR_APPEND(trkSeg_t, * seg_to, seg_from->cnt);
- for (int i=0; i<seg_from->cnt;i++,j++) {
- trkSeg_p from_p = &DYNARR_N(trkSeg_t, * seg_from,j);
- trkSeg_p to_p = &DYNARR_N(trkSeg_t, * seg_to,i);
- memcpy(to_p,from_p,sizeof( trkSeg_t));
- if (from_p->type == SEG_BEZLIN || from_p->type == SEG_BEZTRK) {
- if (from_p->bezSegs.ptr) {
- to_p->bezSegs.ptr = memdup(from_p->bezSegs.ptr,from_p->bezSegs.cnt*sizeof(trkSeg_t));
- }
- }
- if (from_p->type == SEG_POLY || from_p->type == SEG_FILPOLY) {
- if (from_p->u.p.pts) {
- to_p->u.p.pts = memdup(from_p->u.p.pts,from_p->u.p.cnt*sizeof(pts_t));
- }
- }
+ if ( seg_p == &tempSegs_da ) {
+ DYNARR_RESET( trkSeg_t, *seg_p );
+ } else {
+ DYNARR_FREE( trkSeg_t, *seg_p );
}
}
-EXPORT void AppendTransformedSegs(dynArr_t * seg_to, dynArr_t * seg_from, coOrd orig, coOrd rotateOrig, ANGLE_T angle) {
- if (seg_from->cnt ==0) return;
- int j = 0;
- DYNARR_APPEND(trkSeg_t, * seg_to, seg_from->cnt);
- for (int i=0; i<seg_from->cnt;i++,j++) {
- trkSeg_p from_p = &DYNARR_N(trkSeg_t, * seg_from,j);
- trkSeg_p to_p = &DYNARR_N(trkSeg_t, * seg_to,i);
- memcpy(to_p,from_p,sizeof( trkSeg_t));
- if (from_p->type == SEG_BEZLIN || from_p->type == SEG_BEZTRK) {
- if (from_p->bezSegs.ptr) {
- to_p->bezSegs.ptr = memdup(from_p->bezSegs.ptr,from_p->bezSegs.cnt*sizeof(trkSeg_t));
- }
- }
- if (from_p->type == SEG_POLY || from_p->type == SEG_FILPOLY) {
- if (from_p->u.p.pts) {
- to_p->u.p.pts = memdup(from_p->u.p.pts,from_p->u.p.cnt*sizeof(pts_t));
- }
- }
- RotateSegs(1,to_p,rotateOrig,angle);
- coOrd move;
- move.x = orig.x - rotateOrig.x;
- move.y = orig.y - rotateOrig.y;
- MoveSegs(1,to_p,move);
- }
-}
-EXPORT void CopyPoly(trkSeg_p p, wIndex_t segCnt) {
+EXPORT void CopyPoly(trkSeg_p p, wIndex_t segCnt)
+{
pts_t * newPts;
- for (int i=0;i<segCnt;i++,p++) {
+ for (int i=0; i<segCnt; i++,p++) {
if ((p->type == SEG_POLY) || (p->type == SEG_FILPOLY)) {
newPts = memdup( p->u.p.pts, p->u.p.cnt*sizeof (pts_t) );
p->u.p.pts = newPts;
@@ -2113,10 +2120,10 @@ EXPORT void CopyPoly(trkSeg_p p, wIndex_t segCnt) {
EXPORT wBool_t CompareSegs(
- trkSeg_p segPtr1,
- int segCnt1,
- trkSeg_p segPtr2,
- int segCnt2 )
+ trkSeg_p segPtr1,
+ int segCnt1,
+ trkSeg_p segPtr2,
+ int segCnt2 )
{
char * cp = message+strlen(message);
if ( segCnt1 != segCnt2 ) {
@@ -2139,7 +2146,7 @@ EXPORT wBool_t CompareSegs(
// These don't have widths
break;
default:
- REGRESS_CHECK_WIDTH( "Width", segP1, segP2, width );
+ REGRESS_CHECK_WIDTH( "Width", segP1, segP2, lineWidth );
}
switch( segP1->type ) {
case SEG_DIMLIN: