diff options
Diffstat (limited to 'app/bin/draw.c')
-rw-r--r-- | app/bin/draw.c | 2498 |
1 files changed, 1423 insertions, 1075 deletions
diff --git a/app/bin/draw.c b/app/bin/draw.c index d7ec0c0..d833a7b 100644 --- a/app/bin/draw.c +++ b/app/bin/draw.c @@ -17,7 +17,7 @@ * * 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 "cselect.h" @@ -38,13 +38,13 @@ static void DrawMarkers( void ); static void ConstraintOrig( coOrd *, coOrd, int, int ); static void DoMouse( wAction_t action, coOrd pos ); static void DDrawPoly( - drawCmd_p d, - int cnt, - coOrd * pts, - int * types, - wDrawColor color, - wDrawWidth width, - drawFill_e eFillOpt ); + drawCmd_p d, + int cnt, + coOrd * pts, + int * types, + wDrawColor color, + wDrawWidth width, + drawFill_e eFillOpt ); static void DrawMapBoundingBox( BOOL_T set ); static void DrawTicks( drawCmd_p d, coOrd size ); static void DoZoom( void * pScaleVP ); @@ -54,6 +54,7 @@ static int log_zoom = 0; static int log_mouse = 0; static int log_redraw = 0; static int log_timemainredraw = 0; +static int log_mapsize = 0; static wFontSize_t drawMaxTextFontSize = 100; @@ -65,11 +66,14 @@ static wFontSize_t drawMaxTextFontSize = 100; // static char FAR message[STR_LONG_SIZE]; -EXPORT wDrawPix_t closePixels = 10; EXPORT long maxArcSegStraightLen = 100; EXPORT long drawCount; EXPORT BOOL_T drawEnable = TRUE; EXPORT long currRedraw = 0; +EXPORT long constrainMain = 0; +//EXPORT long mapScale = 64; +EXPORT long liveMap = 0; +EXPORT long descriptionFontSize = 72; EXPORT coOrd panCenter; EXPORT coOrd menuPos; @@ -80,10 +84,15 @@ EXPORT wDrawColor drawColorRed; EXPORT wDrawColor drawColorBlue; EXPORT wDrawColor drawColorGreen; EXPORT wDrawColor drawColorAqua; +EXPORT wDrawColor drawColorDkRed; +EXPORT wDrawColor drawColorDkBlue; +EXPORT wDrawColor drawColorDkGreen; +EXPORT wDrawColor drawColorDkAqua; EXPORT wDrawColor drawColorPreviewSelected; EXPORT wDrawColor drawColorPreviewUnselected; EXPORT wDrawColor drawColorPowderedBlue; EXPORT wDrawColor drawColorPurple; +EXPORT wDrawColor drawColorMagenta; EXPORT wDrawColor drawColorGold; EXPORT wDrawColor drawColorGrey10; EXPORT wDrawColor drawColorGrey20; @@ -122,24 +131,26 @@ EXPORT wDrawColor elevColorDefined; EXPORT wDrawColor profilePathColor; EXPORT wDrawColor exceptionColor; +DIST_T closeDist = 0.100; + static wFont_p rulerFp; static struct { - wStatus_p scale_m; - wStatus_p count_m; - wStatus_p posX_m; - wStatus_p posY_m; - wStatus_p info_m; - wWinPix_t scale_w; - wWinPix_t count_w; - wWinPix_t pos_w; - wWinPix_t info_w; - wBox_p scale_b; - wBox_p count_b; - wBox_p posX_b; - wBox_p posY_b; - wBox_p info_b; - } infoD; + wStatus_p scale_m; + wStatus_p count_m; + wStatus_p posX_m; + wStatus_p posY_m; + wStatus_p info_m; + wWinPix_t scale_w; + wWinPix_t count_w; + wWinPix_t pos_w; + wWinPix_t info_w; + wBox_p scale_b; + wBox_p count_b; + wBox_p posX_b; + wBox_p posY_b; + wBox_p info_b; +} infoD; EXPORT coOrd oldMarker = { 0.0, 0.0 }; @@ -150,7 +161,8 @@ EXPORT BOOL_T inError = FALSE; typedef enum { mouseNone, mouseLeft, mouseRight, mouseLeftPending } mouseState_e; static mouseState_e mouseState; -static wDrawPix_t mousePositionx, mousePositiony; /**< position of mouse pointer */ +static wDrawPix_t mousePositionx, + mousePositiony; /**< position of mouse pointer */ static int delayUpdate = 1; @@ -159,62 +171,72 @@ static char yLabel[] = "Y: "; static char zoomLabel[] = "Zoom: "; static struct { - char * name; - double value; - wMenuRadio_p pdRadio; - wMenuRadio_p btRadio; - wMenuRadio_p ctxRadio1; - wMenuRadio_p panRadio; - } zoomList[] = { - { "1:10", 1.0 / 10.0 }, - { "1:9", 1.0 / 9.0 }, - { "1:8", 1.0 / 8.0 }, - { "1:7", 1.0 / 7.0 }, - { "1:6", 1.0 / 6.0 }, - { "1:5", 1.0 / 5.0 }, - { "1:4", 1.0 / 4.0 }, - { "1:3", 1.0 / 3.0 }, - { "1:2", 1.0 / 2.0 }, - { "1:1", 1.0 }, - { "2:1", 2.0 }, - { "3:1", 3.0 }, - { "4:1", 4.0 }, - { "5:1", 5.0 }, - { "6:1", 6.0 }, - { "7:1", 7.0 }, - { "8:1", 8.0 }, - { "9:1", 9.0 }, - { "10:1", 10.0 }, - { "12:1", 12.0 }, - { "14:1", 14.0 }, - { "16:1", 16.0 }, - { "18:1", 18.0 }, - { "20:1", 20.0 }, - { "24:1", 24.0 }, - { "28:1", 28.0 }, - { "32:1", 32.0 }, - { "36:1", 36.0 }, - { "40:1", 40.0 }, - { "48:1", 48.0 }, - { "56:1", 56.0 }, - { "64:1", 64.0 }, - { "80:1", 80.0 }, - { "96:1", 96.0 }, - { "112:1", 112.0 }, - { "128:1", 128.0 }, - { "160:1", 160.0 }, - { "192:1", 192.0 }, - { "224:1", 224.0 }, - { "256:1", 256.0 }, - { "320:1", 320.0 }, - { "384:1", 384.0 }, - { "448:1", 448.0 }, - { "512:1", 512.0 }, - { "640:1", 640.0 }, - { "768:1", 768.0 }, - { "896:1", 896.0 }, - { "1024:1", 1024.0 }, - }; + char * name; + DIST_T value; + wMenuRadio_p pdRadio; + wMenuRadio_p btRadio; + wMenuRadio_p ctxRadio1; + wMenuRadio_p panRadio; +} zoomList[] = { + { "1:10", 1.0 / 10.0 }, + { "1:9", 1.0 / 9.0 }, + { "1:8", 1.0 / 8.0 }, + { "1:7", 1.0 / 7.0 }, + { "1:6", 1.0 / 6.0 }, + { "1:5", 1.0 / 5.0 }, + { "1:4", 1.0 / 4.0 }, + { "1:3.5", 1.0 / 3.5 }, + { "1:3", 1.0 / 3.0 }, + { "1:2.5", 1.0 / 2.5 }, + { "1:2", 1.0 / 2.0 }, + { "1:1.75", 1.0 / 1.75 }, + { "1:1.5", 1.0 / 1.5 }, + { "1:1.25", 1.0 / 1.25 }, + { "1:1", 1.0 }, + { "1.25:1", 1.25 }, + { "1.5:1", 1.5 }, + { "1.75:1", 1.75 }, + { "2:1", 2.0 }, + { "2.5:1", 2.5 }, + { "3:1", 3.0 }, + { "3.5:1", 3.5 }, + { "4:1", 4.0 }, + { "5:1", 5.0 }, + { "6:1", 6.0 }, + { "7:1", 7.0 }, + { "8:1", 8.0 }, + { "9:1", 9.0 }, + { "10:1", 10.0 }, + { "12:1", 12.0 }, + { "14:1", 14.0 }, + { "16:1", 16.0 }, + { "18:1", 18.0 }, + { "20:1", 20.0 }, + { "24:1", 24.0 }, + { "28:1", 28.0 }, + { "32:1", 32.0 }, + { "36:1", 36.0 }, + { "40:1", 40.0 }, + { "48:1", 48.0 }, + { "56:1", 56.0 }, + { "64:1", 64.0 }, + { "80:1", 80.0 }, + { "96:1", 96.0 }, + { "112:1", 112.0 }, + { "128:1", 128.0 }, + { "160:1", 160.0 }, + { "192:1", 192.0 }, + { "224:1", 224.0 }, + { "256:1", 256.0 }, + { "320:1", 320.0 }, + { "384:1", 384.0 }, + { "448:1", 448.0 }, + { "512:1", 512.0 }, + { "640:1", 640.0 }, + { "768:1", 768.0 }, + { "896:1", 896.0 }, + { "1024:1", 1024.0 }, +}; @@ -224,24 +246,28 @@ static struct { * */ -static void MainCoOrd2Pix( drawCmd_p d, coOrd p, wDrawPix_t * x, wDrawPix_t * y ) +static void MainCoOrd2Pix( drawCmd_p d, coOrd p, wDrawPix_t * x, + wDrawPix_t * y ) { DIST_T t; - if (d->angle != 0.0) + if (d->angle != 0.0) { Rotate( &p, d->orig, -d->angle ); + } p.x = (p.x - d->orig.x) / d->scale; p.y = (p.y - d->orig.y) / d->scale; t = p.x*d->dpi; - if ( t > 0.0 ) + if ( t > 0.0 ) { t += 0.5; - else + } else { t -= 0.5; + } *x = ((wDrawPix_t)t) + ((d->options&DC_TICKS)?LBORDER:0); t = p.y*d->dpi; - if ( t > 0.0 ) + if ( t > 0.0 ) { t += 0.5; - else + } else { t -= 0.5; + } *y = ((wDrawPix_t)t) + ((d->options&DC_TICKS)?BBORDER:0); } @@ -249,10 +275,10 @@ static void MainCoOrd2Pix( drawCmd_p d, coOrd p, wDrawPix_t * x, wDrawPix_t * y static int Pix2CoOrd_interpolate = 0; static void MainPix2CoOrd( - drawCmd_p d, - wDrawPix_t px, - wDrawPix_t py, - coOrd * posR ) + drawCmd_p d, + wDrawPix_t px, + wDrawPix_t py, + coOrd * posR ) { DIST_T x, y; DIST_T bins = pixelBins; @@ -260,19 +286,20 @@ static void MainPix2CoOrd( y = ((((POS_T)((py)-BBORDER))/d->dpi)) * d->scale; x = (long)(x*bins)/bins; y = (long)(y*bins)/bins; -if (Pix2CoOrd_interpolate) { - DIST_T x1, y1; - x1 = ((((POS_T)((px-1)-LBORDER))/d->dpi)) * d->scale; - y1 = ((((POS_T)((py-1)-BBORDER))/d->dpi)) * d->scale; - x1 = (long)(x1*bins)/bins; - y1 = (long)(y1*bins)/bins; - if (x == x1) { - x += 1/bins/2; - printf ("px=%0.1f x1=%0.6f x=%0.6f\n", px, x1, x ); - } - if (y == y1) - y += 1/bins/2; -} + if (Pix2CoOrd_interpolate) { + DIST_T x1, y1; + x1 = ((((POS_T)((px-1)-LBORDER))/d->dpi)) * d->scale; + y1 = ((((POS_T)((py-1)-BBORDER))/d->dpi)) * d->scale; + x1 = (long)(x1*bins)/bins; + y1 = (long)(y1*bins)/bins; + if (x == x1) { + x += 1/bins/2; + printf ("px=%0.1f x1=%0.6f x=%0.6f\n", px, x1, x ); + } + if (y == y1) { + y += 1/bins/2; + } + } x += d->orig.x; y += d->orig.y; posR->x = x; @@ -283,36 +310,38 @@ if (Pix2CoOrd_interpolate) { #define DRAWOPTS( D ) (((D->options&DC_TEMP)?wDrawOptTemp:0)|((D->options&DC_OUTLINE)?wDrawOutlineFont:0)) static void DDrawLine( - drawCmd_p d, - coOrd p0, - coOrd p1, - wDrawWidth width, - wDrawColor color ) + drawCmd_p d, + coOrd p0, + coOrd p1, + wDrawWidth width, + wDrawColor color ) { wDrawPix_t x0, y0, x1, y1; BOOL_T in0 = FALSE, in1 = FALSE; coOrd orig, size; - if (d == &mapD && !mapVisible) + if (d == &mapD && !mapVisible) { return; - if ( (d->options&DC_NOCLIP) == 0 ) { - if (d->angle == 0.0) { - in0 = (p0.x >= d->orig.x && p0.x <= d->orig.x+d->size.x && - p0.y >= d->orig.y && p0.y <= d->orig.y+d->size.y); - in1 = (p1.x >= d->orig.x && p1.x <= d->orig.x+d->size.x && - p1.y >= d->orig.y && p1.y <= d->orig.y+d->size.y); - } - if ( (!in0) || (!in1) ) { - orig = d->orig; - size = d->size; - if (d->options&DC_TICKS) { - orig.x -= LBORDER/d->dpi*d->scale; - orig.y -= BBORDER/d->dpi*d->scale; - size.x += (LBORDER+RBORDER)/d->dpi*d->scale; - size.y += (BBORDER+TBORDER)/d->dpi*d->scale; - } - if (!ClipLine( &p0, &p1, orig, d->angle, size )) - return; } + if ( (d->options&DC_NOCLIP) == 0 ) { + if (d->angle == 0.0) { + in0 = (p0.x >= d->orig.x && p0.x <= d->orig.x+d->size.x && + p0.y >= d->orig.y && p0.y <= d->orig.y+d->size.y); + in1 = (p1.x >= d->orig.x && p1.x <= d->orig.x+d->size.x && + p1.y >= d->orig.y && p1.y <= d->orig.y+d->size.y); + } + if ( (!in0) || (!in1) ) { + orig = d->orig; + size = d->size; + if (d->options&DC_TICKS) { + orig.x -= LBORDER/d->dpi*d->scale; + orig.y -= BBORDER/d->dpi*d->scale; + size.x += (LBORDER+RBORDER)/d->dpi*d->scale; + size.y += (BBORDER+TBORDER)/d->dpi*d->scale; + } + if (!ClipLine( &p0, &p1, orig, d->angle, size )) { + return; + } + } } d->CoOrd2Pix(d,p0,&x0,&y0); d->CoOrd2Pix(d,p1,&x1,&y1); @@ -320,126 +349,126 @@ static void DDrawLine( wDrawLineType_e lineOpt = wDrawLineSolid; unsigned long NotSolid = DC_NOTSOLIDLINE; unsigned long opt = d->options&NotSolid; - if (opt == DC_DASH) - lineOpt = wDrawLineDash; - else if(opt == DC_DOT) - lineOpt = wDrawLineDot; - else if(opt == DC_DASHDOT) - lineOpt = wDrawLineDashDot; - else if (opt == DC_DASHDOTDOT) - lineOpt = wDrawLineDashDotDot; - else if(opt == DC_CENTER) - lineOpt = wDrawLineCenter; - else if (opt == DC_PHANTOM) - lineOpt = wDrawLinePhantom; + if (opt == DC_DASH) { + lineOpt = wDrawLineDash; + } else if(opt == DC_DOT) { + lineOpt = wDrawLineDot; + } else if(opt == DC_DASHDOT) { + lineOpt = wDrawLineDashDot; + } else if (opt == DC_DASHDOTDOT) { + lineOpt = wDrawLineDashDotDot; + } else if(opt == DC_CENTER) { + lineOpt = wDrawLineCenter; + } else if (opt == DC_PHANTOM) { + lineOpt = wDrawLinePhantom; + } if (drawEnable) { wDrawLine( d->d, x0, y0, x1, y1, - width, - lineOpt, - color, DRAWOPTS(d) ); + width, + lineOpt, + color, DRAWOPTS(d) ); } } static void DDrawArc( - drawCmd_p d, - coOrd p, - DIST_T r, - ANGLE_T angle0, - ANGLE_T angle1, - BOOL_T drawCenter, - wDrawWidth width, - wDrawColor color ) -{ - wDrawPix_t x, y; - ANGLE_T da; - coOrd p0, p1; - DIST_T rr; - int i, cnt; - - if (d == &mapD && !mapVisible) - { - return; - } - rr = (r / d->scale) * d->dpi + 0.5; - if (rr > wDrawGetMaxRadius(d->d)) - { - da = (maxArcSegStraightLen * 180) / (M_PI * rr); - cnt = (int)(angle1/da) + 1; - da = angle1 / cnt; - coOrd min,max; - min = d->orig; - max.x = min.x + d->size.x; - max.y = min.y + d->size.y; - PointOnCircle(&p0, p, r, angle0); - for (i=1; i<=cnt; i++) { - angle0 += da; - PointOnCircle(&p1, p, r, angle0); - if (d->angle == 0.0 && - ((p0.x >= min.x && - p0.x <= max.x && - p0.y >= min.y && - p0.y <= max.y) || - (p1.x >= min.x && - p1.x <= max.x && - p1.y >= min.y && - p1.y <= max.y))) { - DrawLine(d, p0, p1, width, color); - } else { - coOrd clip0 = p0, clip1 = p1; - if (ClipLine(&clip0, &clip1, d->orig, d->angle, d->size)) { - DrawLine(d, clip0, clip1, width, color); - } - } - - p0 = p1; - } - return; - } - if (d->angle!=0.0 && angle1 < 360.0) - { - angle0 = NormalizeAngle(angle0-d->angle); - } - d->CoOrd2Pix(d,p,&x,&y); - drawCount++; - wDrawLineType_e lineOpt = wDrawLineSolid; - unsigned long NotSolid = DC_NOTSOLIDLINE; - unsigned long opt = d->options&NotSolid; - if (opt == DC_DASH) + drawCmd_p d, + coOrd p, + DIST_T r, + ANGLE_T angle0, + ANGLE_T angle1, + BOOL_T drawCenter, + wDrawWidth width, + wDrawColor color ) +{ + wDrawPix_t x, y; + ANGLE_T da; + coOrd p0, p1; + DIST_T rr; + int i, cnt; + + if (d == &mapD && !mapVisible) { + return; + } + rr = (r / d->scale) * d->dpi + 0.5; + if (rr > wDrawGetMaxRadius(d->d)) { + da = (maxArcSegStraightLen * 180) / (M_PI * rr); + cnt = (int)(angle1/da) + 1; + da = angle1 / cnt; + coOrd min,max; + min = d->orig; + max.x = min.x + d->size.x; + max.y = min.y + d->size.y; + PointOnCircle(&p0, p, r, angle0); + for (i=1; i<=cnt; i++) { + angle0 += da; + PointOnCircle(&p1, p, r, angle0); + if (d->angle == 0.0 && + ((p0.x >= min.x && + p0.x <= max.x && + p0.y >= min.y && + p0.y <= max.y) || + (p1.x >= min.x && + p1.x <= max.x && + p1.y >= min.y && + p1.y <= max.y))) { + DrawLine(d, p0, p1, width, color); + } else { + coOrd clip0 = p0, clip1 = p1; + if (ClipLine(&clip0, &clip1, d->orig, d->angle, d->size)) { + DrawLine(d, clip0, clip1, width, color); + } + } + + p0 = p1; + } + return; + } + if (d->angle!=0.0 && angle1 < 360.0) { + angle0 = NormalizeAngle(angle0-d->angle); + } + d->CoOrd2Pix(d,p,&x,&y); + drawCount++; + wDrawLineType_e lineOpt = wDrawLineSolid; + unsigned long NotSolid = DC_NOTSOLIDLINE; + unsigned long opt = d->options&NotSolid; + if (opt == DC_DASH) { lineOpt = wDrawLineDash; - else if(opt == DC_DOT) + } else if(opt == DC_DOT) { lineOpt = wDrawLineDot; - else if(opt == DC_DASHDOT) + } else if(opt == DC_DASHDOT) { lineOpt = wDrawLineDashDot; - else if (opt == DC_DASHDOTDOT) + } else if (opt == DC_DASHDOTDOT) { lineOpt = wDrawLineDashDotDot; - else if(opt == DC_CENTER) + } else if(opt == DC_CENTER) { lineOpt = wDrawLineCenter; - else if (opt == DC_PHANTOM) + } else if (opt == DC_PHANTOM) { lineOpt = wDrawLinePhantom; - if (drawEnable) - { - int sizeCenter = (int)(drawCenter ? ((d->options & DC_PRINT) ? (d->dpi / BASE_DPI) : 1) : 0); - wDrawArc(d->d, x, y, (wDrawPix_t)(rr), angle0, angle1, sizeCenter, - width, lineOpt, - color, DRAWOPTS(d) ); - } + } + if (drawEnable) { + int sizeCenter = (int)(drawCenter ? ((d->options & DC_PRINT) ? + (d->dpi / BASE_DPI) : 1) : 0); + wDrawArc(d->d, x, y, (wDrawPix_t)(rr), angle0, angle1, sizeCenter, + width, lineOpt, + color, DRAWOPTS(d) ); + } } static void DDrawString( - drawCmd_p d, - coOrd p, - ANGLE_T a, - char * s, - wFont_p fp, - FONTSIZE_T fontSize, - wDrawColor color ) + drawCmd_p d, + coOrd p, + ANGLE_T a, + char * s, + wFont_p fp, + FONTSIZE_T fontSize, + wDrawColor color ) { wDrawPix_t x, y; - if (d == &mapD && !mapVisible) + if (d == &mapD && !mapVisible) { return; + } d->CoOrd2Pix(d,p,&x,&y); if ( color == wDrawColorWhite ) { wDrawPix_t width, height, descent, ascent; @@ -467,13 +496,13 @@ static void DDrawString( static void DDrawPoly( - drawCmd_p d, - int cnt, - coOrd * pts, - int * types, - wDrawColor color, - wDrawWidth width, - drawFill_e eFillOpt ) + drawCmd_p d, + int cnt, + coOrd * pts, + int * types, + wDrawColor color, + wDrawWidth width, + drawFill_e eFillOpt ) { typedef wDrawPix_t wPos2[2]; static dynArr_t wpts_da; @@ -490,26 +519,28 @@ static void DDrawPoly( d->CoOrd2Pix( d, pts[inx], &x, &y ); wpts(inx)[0] = x; wpts(inx)[1] = y; - if (!types) + if (!types) { wtype(inx) = 0; - else + } else { wtype(inx) = (wPolyLine_e)types[inx]; + } } wDrawLineType_e lineOpt = wDrawLineSolid; unsigned long NotSolid = DC_NOTSOLIDLINE; unsigned long opt = d->options&NotSolid; - if (opt == DC_DASH) + if (opt == DC_DASH) { lineOpt = wDrawLineDash; - else if(opt == DC_DOT) + } else if(opt == DC_DOT) { lineOpt = wDrawLineDot; - else if(opt == DC_DASHDOT) + } else if(opt == DC_DASHDOT) { lineOpt = wDrawLineDashDot; - else if (opt == DC_DASHDOTDOT) + } else if (opt == DC_DASHDOTDOT) { lineOpt = wDrawLineDashDotDot; - else if(opt == DC_CENTER) + } else if(opt == DC_CENTER) { lineOpt = wDrawLineCenter; - else if (opt == DC_PHANTOM) + } else if (opt == DC_PHANTOM) { lineOpt = wDrawLinePhantom; + } wDrawOpts drawOpts = DRAWOPTS(d); switch ( eFillOpt ) { @@ -526,23 +557,25 @@ static void DDrawPoly( drawOpts |= wDrawOptTransparent; break; default: - abort(); + CHECK(FALSE); } - wDrawPolygon( d->d, &wpts(0), &wtype(0), cnt, color, width, lineOpt, drawOpts, fill, open ); + wDrawPolygon( d->d, &wpts(0), &wtype(0), cnt, color, width, lineOpt, drawOpts, + fill, open ); } static void DDrawFillCircle( - drawCmd_p d, - coOrd p, - DIST_T r, - wDrawColor color ) + drawCmd_p d, + coOrd p, + DIST_T r, + wDrawColor color ) { wDrawPix_t x, y; DIST_T rr; - if (d == &mapD && !mapVisible) + if (d == &mapD && !mapVisible) { return; + } rr = (r / d->scale) * d->dpi + 0.5; if (rr > wDrawGetMaxRadius(d->d)) { // Circle too big @@ -553,32 +586,35 @@ static void DDrawFillCircle( wDrawGetSize( d->d, &w, &h ); if ( d->options & DC_TICKS ) { if ( x+rr < LBORDER || x-rr > w-RBORDER || - y+rr < BBORDER || y-rr > h-TBORDER ) + y+rr < BBORDER || y-rr > h-TBORDER ) { return; + } } else { if ( x+rr < 0 || x-rr > w || - y+rr < 0 || y-rr > h ) + y+rr < 0 || y-rr > h ) { return; + } } drawCount++; if (drawEnable) { wDrawFilledCircle( d->d, x, y, (wDrawPix_t)(rr), - color, DRAWOPTS(d) ); + color, DRAWOPTS(d) ); } } static void DDrawRectangle( - drawCmd_p d, - coOrd orig, - coOrd size, - wDrawColor color, - drawFill_e eFillOpt ) + drawCmd_p d, + coOrd orig, + coOrd size, + wDrawColor color, + drawFill_e eFillOpt ) { wDrawPix_t x, y, w, h; - if (d == &mapD && !mapVisible) - return; + if (d == &mapD && !mapVisible) { + return; + } d->CoOrd2Pix(d,orig,&x,&y); w = (wDrawPix_t)((size.x/d->scale)*d->dpi+0.5); h = (wDrawPix_t)((size.y/d->scale)*d->dpi+0.5); @@ -603,12 +639,16 @@ static void DDrawRectangle( break; case DRAW_TRANSPARENT: opts |= wDrawOptTransparent; - // Fallthru + // Fallthru case DRAW_FILL: + if ( d->options & DC_ROUND ) { + x = round(x); + y = round(y); + } wDrawFilledRectangle( d->d, x, y, w, h, color, opts ); break; default: - abort(); + CHECK(FALSE); } } } @@ -619,32 +659,34 @@ EXPORT void DrawHilight( drawCmd_p d, coOrd p, coOrd s, BOOL_T add ) unsigned long options = d->options; d->options |= DC_TEMP; wBool_t bTemp = wDrawSetTempMode( d->d, TRUE ); - DrawRectangle( d, p, s, add?drawColorPowderedBlue:selectedColor, DRAW_TRANSPARENT ); + DrawRectangle( d, p, s, add?drawColorPowderedBlue:selectedColor, + DRAW_TRANSPARENT ); wDrawSetTempMode( d->d, bTemp ); d->options = options; } EXPORT void DrawHilightPolygon( drawCmd_p d, coOrd *p, int cnt ) { - ASSERT( cnt <= 4 ); + CHECK( cnt <= 4 ); static wDrawColor color = 0; - if ( color == 0 ) + if ( color == 0 ) { color = wDrawColorGray( 70 ); + } DrawPoly( d, cnt, p, NULL, color, 0, DRAW_TRANSPARENT ); } EXPORT void DrawMultiString( - drawCmd_p d, - coOrd pos, - char * text, - wFont_p fp, - wFontSize_t fs, - wDrawColor color, - ANGLE_T a, - coOrd * lo, - coOrd * hi, - BOOL_T boxed) + drawCmd_p d, + coOrd pos, + char * text, + wFont_p fp, + wFontSize_t fs, + wDrawColor color, + ANGLE_T a, + coOrd * lo, + coOrd * hi, + BOOL_T boxed) { char * cp; char * cp1; @@ -668,21 +710,24 @@ EXPORT void DrawMultiString( cp = line; // Build up message to hold all of the strings separated by nulls while (*text) { cp1 = cp; - while (*text != '\0' && *text != '\n') + while (*text != '\0' && *text != '\n') { *cp++ = *text++; + } *cp = '\0'; DrawTextSize2( &mainD, cp1, fp, fs, TRUE, &textsize, &descent, &ascent); lineW = textsize.x; - if (lineW>size.x) + if (lineW>size.x) { size.x = lineW; + } posl.x = pos.x; posl.y = pos.y; Rotate( &posl, orig, a); DrawString( d, posl, a, cp1, fp, fs, color ); pos.y -= lineH; size.y += lineH; - if (*text == '\0') + if (*text == '\0') { break; + } text++; cp++; } @@ -700,11 +745,12 @@ EXPORT void DrawMultiString( size.y = fabs(orig.y-posl.y)+bh*d->scale/d->dpi; size.y += descent+ascent; coOrd p[4]; - p[0] = orig; p[0].x -= (bw-br)*d->scale/d->dpi; p[0].y += (bh-bb)*d->scale/d->dpi+ascent; + p[0] = orig; p[0].x -= (bw-br)*d->scale/d->dpi; + p[0].y += (bh-bb)*d->scale/d->dpi+ascent; p[1] = p[0]; p[1].x += size.x; p[2] = p[1]; p[2].y -= size.y; p[3] = p[2]; p[3].x = p[0].x; - for (int i=0;i<4;i++) { + for (int i=0; i<4; i++) { Rotate( &p[i], orig, a); } DrawPoly( d, 4, p, NULL, color, 0, DRAW_CLOSED ); @@ -713,52 +759,64 @@ EXPORT void DrawMultiString( free(line); } +/** + * Draw some text inside a box. The layout of the box can be defined using the style + * parameter. Possibilities are complete frame, underline only, omit background or + * draw inversed. + * The background is drawn in white if not disabled + * + * \param style style of box framed, underlined, no background, inverse + * \param d drawing command + * \param pos position + * \param text text to draw + * \param fp font + * \param fs font size + * \param color text color + * \param a angle + */ EXPORT void DrawBoxedString( - int style, - drawCmd_p d, - coOrd pos, - char * text, - wFont_p fp, wFontSize_t fs, - wDrawColor color, - ANGLE_T a ) -{ - coOrd size, p[4], p0=pos, p1, p2; - static int bw=2, bh=2, br=1, bb=1; + int style, + drawCmd_p d, + coOrd pos, + char* text, + wFont_p fp, wFontSize_t fs, + wDrawColor color, + ANGLE_T a) +{ + coOrd size, p[4], p0 = pos, p1, p2; + static int bw = 2, bh = 2, br = 1, bb = 1; static double arrowScale = 0.5; - unsigned long options = d->options; POS_T descent, ascent; - /*DrawMultiString( d, pos, text, fp, fs, color, a, &lo, &hi );*/ - if ( fs < 2*d->scale ) + if (fs < 2 * d->scale) { return; + } #ifndef WINDOWS - if ( ( d->options & DC_PRINT) != 0 ) { - double scale = ((FLOAT_T)fs)/((FLOAT_T)drawMaxTextFontSize)/mainD.dpi; + if ((d->options & DC_PRINT) != 0) { + double scale = ((FLOAT_T)fs) / ((FLOAT_T)drawMaxTextFontSize) / mainD.dpi; wDrawPix_t w, h, d, a; - wDrawGetTextSize( &w, &h, &d, &a, mainD.d, text, fp, drawMaxTextFontSize ); - size.x = w*scale; - size.y = h*scale; - descent = d*scale; - ascent = a*scale; + wDrawGetTextSize(&w, &h, &d, &a, mainD.d, text, fp, drawMaxTextFontSize); + size.x = w * scale; + size.y = h * scale; + descent = d * scale; + ascent = a * scale; } else #endif - DrawTextSize2( &mainD, text, fp, fs, TRUE, &size, &descent, &ascent ); -#ifdef WINDOWS - /*h -= 15;*/ -#endif - p0.x -= size.x/2.0; - p0.y -= size.y/2.0; + DrawTextSize2(&mainD, text, fp, fs, TRUE, &size, &descent, &ascent); + + p0.x -= size.x / 2.0; + p0.y -= size.y / 2.0; if (style == BOX_NONE || d == &mapD) { - DrawString( d, p0, 0.0, text, fp, fs, color ); + DrawString(d, p0, 0.0, text, fp, fs, color); return; } - size.x += bw*d->scale/d->dpi; - size.y += bh*d->scale/d->dpi; + size.x += bw * d->scale / d->dpi; + size.y += bh * d->scale / d->dpi; p[0] = p0; - p[0].x -= br*d->scale/d->dpi; //Top of box - p[0].y += (bb*d->scale/d->dpi+ascent); + p[0].x -= br * d->scale / d->dpi; //Top of box + p[0].y += (bb * d->scale / d->dpi + ascent); p[1].y = p[0].y; - p[2].y = p[3].y = p[0].y-size.y-descent; //Bottom of box + p[2].y = p[3].y = p[0].y - size.y - descent; //Bottom of box p[1].x = p[2].x = p[0].x + size.x; p[3].x = p[0].x; d->options &= ~DC_DASH; @@ -766,61 +824,64 @@ EXPORT void DrawBoxedString( case BOX_ARROW: case BOX_ARROW_BACKGROUND: // Reset size to actual size of the box - size.x = p[2].x-p[0].x; - size.y = p[0].y-p[2].y; + size.x = p[2].x - p[0].x; + size.y = p[0].y - p[2].y; // Pick a point (p1) outside of Box in arrow direction - Translate( &p1, pos, a, size.x+size.y ); + Translate(&p1, pos, a, size.x + size.y); // Find point on edge of Box (p1) - ClipLine( &pos, &p1, p[3], 0.0, size ); + ClipLine(&pos, &p1, p[3], 0.0, size); // Draw line from edge (p1) to Arrow head (p2) - Translate( &p2, p1, a, size.y*arrowScale ); - DrawLine( d, p1, p2, 0, color ); + Translate(&p2, p1, a, size.y * arrowScale); + DrawLine(d, p1, p2, 0, color); // Draw Arrow edges - Translate( &p1, p2, a+150, size.y*0.7*arrowScale ); - DrawLine( d, p1, p2, 0, color ); - Translate( &p1, p2, a-150, size.y*0.7*arrowScale ); - DrawLine( d, p1, p2, 0, color ); - /* no break */ + Translate(&p1, p2, a + 150, size.y * 0.7 * arrowScale); + DrawLine(d, p1, p2, 0, color); + Translate(&p1, p2, a - 150, size.y * 0.7 * arrowScale); + DrawLine(d, p1, p2, 0, color); + /* no break */ case BOX_BOX: case BOX_BOX_BACKGROUND: - if (style == BOX_ARROW_BACKGROUND || style == BOX_BOX_BACKGROUND) - DrawPoly( d, 4, p, NULL, wDrawColorWhite, 0, DRAW_FILL ); //Clear background for box and box-arrow - DrawLine( d, p[1], p[2], 0, color ); - DrawLine( d, p[2], p[3], 0, color ); - DrawLine( d, p[3], p[0], 0, color ); - /* no break */ + if (style == BOX_ARROW_BACKGROUND || style == BOX_BOX_BACKGROUND) { + DrawPoly(d, 4, p, NULL, wDrawColorWhite, 0, + DRAW_FILL); //Clear background for box and box-arrow + } + DrawLine(d, p[1], p[2], 0, color); + DrawLine(d, p[2], p[3], 0, color); + DrawLine(d, p[3], p[0], 0, color); + /* no break */ case BOX_UNDERLINE: - DrawLine( d, p[0], p[1], 0, color ); - DrawString( d, p0, 0.0, text, fp, fs, color ); + DrawLine(d, p[0], p[1], 0, color); + DrawString(d, p0, 0.0, text, fp, fs, color); break; case BOX_INVERT: - DrawPoly( d, 4, p, NULL, color, 0, DRAW_FILL ); - if ( color != wDrawColorWhite ) - DrawString( d, p0, 0.0, text, fp, fs, wDrawColorGray( 94 ) ); + DrawPoly(d, 4, p, NULL, color, 0, DRAW_FILL); + if (color != wDrawColorWhite) { + DrawString(d, p0, 0.0, text, fp, fs, wDrawColorGray(94)); + } break; case BOX_BACKGROUND: - DrawPoly( d, 4, p, NULL, wDrawColorWhite, 0, DRAW_FILL ); - DrawString( d, p0, 0.0, text, fp, fs, color ); + DrawPoly(d, 4, p, NULL, wDrawColorWhite, 0, DRAW_FILL); + DrawString(d, p0, 0.0, text, fp, fs, color); break; } - d->options = options; } EXPORT void DrawTextSize2( - drawCmd_p dp, - char * text, - wFont_p fp, - wFontSize_t fs, - BOOL_T relative, - coOrd * size, - POS_T * descent, - POS_T * ascent) + drawCmd_p dp, + char * text, + wFont_p fp, + wFontSize_t fs, + BOOL_T relative, + coOrd * size, + POS_T * descent, + POS_T * ascent) { wDrawPix_t w, h, d, a; FLOAT_T scale = 1.0; - if ( relative ) + if ( relative ) { fs /= dp->scale; + } if ( fs > drawMaxTextFontSize ) { scale = ((FLOAT_T)fs)/((FLOAT_T)drawMaxTextFontSize); fs = drawMaxTextFontSize; @@ -836,29 +897,29 @@ EXPORT void DrawTextSize2( *descent *= dp->scale; *ascent *=dp->scale; } -/* printf( "DTS2(\"%s\",%0.3f,%d) = (w%d,h%d,d%d) *%0.3f x%0.3f y%0.3f %0.3f\n", text, fs, relative, w, h, d, scale, size->x, size->y, *descent );*/ + /* printf( "DTS2(\"%s\",%0.3f,%d) = (w%d,h%d,d%d) *%0.3f x%0.3f y%0.3f %0.3f\n", text, fs, relative, w, h, d, scale, size->x, size->y, *descent );*/ } EXPORT void DrawTextSize( - drawCmd_p dp, - char * text, - wFont_p fp, - wFontSize_t fs, - BOOL_T relative, - coOrd * size ) + drawCmd_p dp, + char * text, + wFont_p fp, + wFontSize_t fs, + BOOL_T relative, + coOrd * size ) { POS_T descent, ascent; DrawTextSize2( dp, text, fp, fs, relative, size, &descent, &ascent ); } EXPORT void DrawMultiLineTextSize( - drawCmd_p dp, - char * text, - wFont_p fp, - wFontSize_t fs, - BOOL_T relative, - coOrd * size, - coOrd * lastline ) + drawCmd_p dp, + char * text, + wFont_p fp, + wFontSize_t fs, + BOOL_T relative, + coOrd * size, + coOrd * lastline ) { POS_T descent, ascent, lineW, lineH; coOrd textsize, blocksize; @@ -874,14 +935,16 @@ EXPORT void DrawMultiLineTextSize( lastline->y = 0; while (text && *text != '\0' ) { cp = line; - while (*text != '\0' && *text != '\n') + while (*text != '\0' && *text != '\n') { *cp++ = *text++; + } *cp = '\0'; blocksize.y += lineH; DrawTextSize2( &mainD, line, fp, fs, TRUE, &textsize, &descent, &ascent); lineW = textsize.x; - if (lineW>blocksize.x) + if (lineW>blocksize.x) { blocksize.x = lineW; + } lastline->x = textsize.x; if (*text =='\n') { blocksize.y += lineH; @@ -900,7 +963,8 @@ EXPORT void DrawMultiLineTextSize( } -static void DDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, wDrawColor color) +static void DDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, + wDrawColor color) { wDrawPix_t x, y; d->CoOrd2Pix( d, p, &x, &y ); @@ -909,45 +973,47 @@ static void DDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, wDrawColor colo static void TempSegLine( - drawCmd_p d, - coOrd p0, - coOrd p1, - wDrawWidth width, - wDrawColor color ) + drawCmd_p d, + coOrd p0, + coOrd p1, + wDrawWidth width, + wDrawColor color ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1).type = SEG_STRLIN; tempSegs(tempSegs_da.cnt-1).color = color; - if (d->options&DC_SIMPLE) - tempSegs(tempSegs_da.cnt-1).width = 0; - else if (width<0) - tempSegs(tempSegs_da.cnt-1).width = width; - else - tempSegs(tempSegs_da.cnt-1).width = width*d->scale/d->dpi; + if (d->options&DC_SIMPLE) { + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; + } else if (width<0) { + tempSegs(tempSegs_da.cnt-1).lineWidth = width; + } else { + tempSegs(tempSegs_da.cnt-1).lineWidth = width*d->scale/d->dpi; + } tempSegs(tempSegs_da.cnt-1).u.l.pos[0] = p0; tempSegs(tempSegs_da.cnt-1).u.l.pos[1] = p1; } static void TempSegArc( - drawCmd_p d, - coOrd p, - DIST_T r, - ANGLE_T angle0, - ANGLE_T angle1, - BOOL_T drawCenter, - wDrawWidth width, - wDrawColor color ) + drawCmd_p d, + coOrd p, + DIST_T r, + ANGLE_T angle0, + ANGLE_T angle1, + BOOL_T drawCenter, + wDrawWidth width, + wDrawColor color ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1).type = SEG_CRVLIN; tempSegs(tempSegs_da.cnt-1).color = color; - if (d->options&DC_SIMPLE) - tempSegs(tempSegs_da.cnt-1).width = 0; - else if (width<0) - tempSegs(tempSegs_da.cnt-1).width = width; - else - tempSegs(tempSegs_da.cnt-1).width = width*d->scale/d->dpi; + if (d->options&DC_SIMPLE) { + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; + } else if (width<0) { + tempSegs(tempSegs_da.cnt-1).lineWidth = width; + } else { + tempSegs(tempSegs_da.cnt-1).lineWidth = width*d->scale/d->dpi; + } tempSegs(tempSegs_da.cnt-1).u.c.center = p; tempSegs(tempSegs_da.cnt-1).u.c.radius = r; tempSegs(tempSegs_da.cnt-1).u.c.a0 = angle0; @@ -956,19 +1022,19 @@ static void TempSegArc( static void TempSegString( - drawCmd_p d, - coOrd p, - ANGLE_T a, - char * s, - wFont_p fp, - FONTSIZE_T fontSize, - wDrawColor color ) + drawCmd_p d, + coOrd p, + ANGLE_T a, + char * s, + wFont_p fp, + FONTSIZE_T fontSize, + wDrawColor color ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1).type = SEG_TEXT; tempSegs(tempSegs_da.cnt-1).color = color; tempSegs(tempSegs_da.cnt-1).u.t.boxed = FALSE; - tempSegs(tempSegs_da.cnt-1).width = 0; + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; tempSegs(tempSegs_da.cnt-1).u.t.pos = p; tempSegs(tempSegs_da.cnt-1).u.t.angle = a; tempSegs(tempSegs_da.cnt-1).u.t.fontP = fp; @@ -978,13 +1044,13 @@ static void TempSegString( static void TempSegPoly( - drawCmd_p d, - int cnt, - coOrd * pts, - int * types, - wDrawColor color, - wDrawWidth width, - drawFill_e eFillOpt ) + drawCmd_p d, + int cnt, + coOrd * pts, + int * types, + wDrawColor color, + wDrawWidth width, + drawFill_e eFillOpt ) { int fill = 0; int open = 0; @@ -1001,39 +1067,41 @@ static void TempSegPoly( fill = 1; break; default: - abort(); + CHECK(FALSE); } DYNARR_APPEND( trkSeg_t, tempSegs_da, 1); tempSegs(tempSegs_da.cnt-1).type = fill?SEG_FILPOLY:SEG_POLY; tempSegs(tempSegs_da.cnt-1).color = color; - if (d->options&DC_SIMPLE) - tempSegs(tempSegs_da.cnt-1).width = 0; - else if (width<0) - tempSegs(tempSegs_da.cnt-1).width = width; - else - tempSegs(tempSegs_da.cnt-1).width = width*d->scale/d->dpi; + if (d->options&DC_SIMPLE) { + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; + } else if (width<0) { + tempSegs(tempSegs_da.cnt-1).lineWidth = width; + } else { + tempSegs(tempSegs_da.cnt-1).lineWidth = width*d->scale/d->dpi; + } tempSegs(tempSegs_da.cnt-1).u.p.polyType = open?POLYLINE:FREEFORM; tempSegs(tempSegs_da.cnt-1).u.p.cnt = cnt; tempSegs(tempSegs_da.cnt-1).u.p.orig = zero; tempSegs(tempSegs_da.cnt-1).u.p.angle = 0.0; tempSegs(tempSegs_da.cnt-1).u.p.pts = (pts_t *)MyMalloc(cnt*sizeof(pts_t)); - for (int i=0;i<=cnt-1;i++) { + for (int i=0; i<=cnt-1; i++) { tempSegs(tempSegs_da.cnt-1).u.p.pts[i].pt = pts[i]; - tempSegs(tempSegs_da.cnt-1).u.p.pts[i].pt_type = ((d->options&DC_SIMPLE)==0 && (types!=0))?types[i]:wPolyLineStraight; + tempSegs(tempSegs_da.cnt-1).u.p.pts[i].pt_type = ((d->options&DC_SIMPLE)==0 + && (types!=0))?types[i]:wPolyLineStraight; } } static void TempSegFillCircle( - drawCmd_p d, - coOrd p, - DIST_T r, - wDrawColor color ) + drawCmd_p d, + coOrd p, + DIST_T r, + wDrawColor color ) { DYNARR_APPEND( trkSeg_t, tempSegs_da, 10 ); tempSegs(tempSegs_da.cnt-1).type = SEG_FILCRCL; tempSegs(tempSegs_da.cnt-1).color = color; - tempSegs(tempSegs_da.cnt-1).width = 0; + tempSegs(tempSegs_da.cnt-1).lineWidth = 0; tempSegs(tempSegs_da.cnt-1).u.c.center = p; tempSegs(tempSegs_da.cnt-1).u.c.radius = r; tempSegs(tempSegs_da.cnt-1).u.c.a0 = 0.0; @@ -1042,11 +1110,11 @@ static void TempSegFillCircle( static void TempSegRectangle( - drawCmd_p d, - coOrd orig, - coOrd size, - wDrawColor color, - drawFill_e eOpts ) + drawCmd_p d, + coOrd orig, + coOrd size, + wDrawColor color, + drawFill_e eOpts ) { coOrd p[4]; // p1 p2 @@ -1059,48 +1127,55 @@ static void TempSegRectangle( } -static void NoDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, wDrawColor color ) +static void NoDrawBitMap( drawCmd_p d, coOrd p, wDrawBitMap_p bm, + wDrawColor color ) { } EXPORT drawFuncs_t screenDrawFuncs = { - DDrawLine, - DDrawArc, - DDrawString, - DDrawBitMap, - DDrawPoly, - DDrawFillCircle, - DDrawRectangle}; + DDrawLine, + DDrawArc, + DDrawString, + DDrawBitMap, + DDrawPoly, + DDrawFillCircle, + DDrawRectangle +}; EXPORT drawFuncs_t printDrawFuncs = { - DDrawLine, - DDrawArc, - DDrawString, - NoDrawBitMap, - DDrawPoly, - DDrawFillCircle, - DDrawRectangle}; + DDrawLine, + DDrawArc, + DDrawString, + NoDrawBitMap, + DDrawPoly, + DDrawFillCircle, + DDrawRectangle +}; EXPORT drawFuncs_t tempSegDrawFuncs = { - TempSegLine, - TempSegArc, - TempSegString, - NoDrawBitMap, - TempSegPoly, - TempSegFillCircle, - TempSegRectangle}; + TempSegLine, + TempSegArc, + TempSegString, + NoDrawBitMap, + TempSegPoly, + TempSegFillCircle, + TempSegRectangle +}; EXPORT drawCmd_t mainD = { - NULL, &screenDrawFuncs, DC_TICKS, INIT_MAIN_SCALE, 0.0, {0.0,0.0}, {0.0,0.0}, MainPix2CoOrd, MainCoOrd2Pix, 96.0}; + NULL, &screenDrawFuncs, DC_TICKS, INIT_MAIN_SCALE, 0.0, {0.0,0.0}, {0.0,0.0}, MainPix2CoOrd, MainCoOrd2Pix, 96.0 +}; EXPORT drawCmd_t tempD = { - NULL, &screenDrawFuncs, DC_TICKS|DC_TEMP, INIT_MAIN_SCALE, 0.0, {0.0,0.0}, {0.0,0.0}, MainPix2CoOrd, MainCoOrd2Pix, 96.0}; + NULL, &screenDrawFuncs, DC_TICKS|DC_TEMP, INIT_MAIN_SCALE, 0.0, {0.0,0.0}, {0.0,0.0}, MainPix2CoOrd, MainCoOrd2Pix, 96.0 +}; EXPORT drawCmd_t mapD = { - NULL, &screenDrawFuncs, DC_SIMPLE, INIT_MAP_SCALE, 0.0, {0.0,0.0}, {96.0,48.0}, Pix2CoOrd, CoOrd2Pix, 96.0}; + NULL, &screenDrawFuncs, DC_SIMPLE, INIT_MAP_SCALE, 0.0, {0.0,0.0}, {96.0,48.0}, Pix2CoOrd, CoOrd2Pix, 96.0 +}; /***************************************************************************** @@ -1127,37 +1202,41 @@ static wWinPix_t curInfoLabelWidth[NUM_INFOCTL]; static wWinPix_t GetInfoPosWidth( void ) { wWinPix_t labelWidth; - + DIST_T dist; - if ( mapD.size.x > mapD.size.y ) - dist = mapD.size.x; - else - dist = mapD.size.y; - if ( units == UNITS_METRIC ) { - dist *= 2.54; - if ( dist >= 1000 ) - dist = 9999.999*2.54; - else if ( dist >= 100 ) - dist = 999.999*2.54; - else if ( dist >= 10 ) - dist = 99.999*2.54; - } else { - if ( dist >= 100*12 ) - dist = 999.0*12.0+11.0+3.0/4.0-1.0/64.0; - else if ( dist >= 10*12 ) - dist = 99.0*12.0+11.0+3.0/4.0-1.0/64.0; - else if ( dist >= 1*12 ) - dist = 9.0*12.0+11.0+3.0/4.0-1.0/64.0; + if ( mapD.size.x > mapD.size.y ) { + dist = mapD.size.x; + } else { + dist = mapD.size.y; + } + if ( units == UNITS_METRIC ) { + dist *= 2.54; + if ( dist >= 1000 ) { + dist = 9999.999*2.54; + } else if ( dist >= 100 ) { + dist = 999.999*2.54; + } else if ( dist >= 10 ) { + dist = 99.999*2.54; + } + } else { + if ( dist >= 100*12 ) { + dist = 999.0*12.0+11.0+3.0/4.0-1.0/64.0; + } else if ( dist >= 10*12 ) { + dist = 99.0*12.0+11.0+3.0/4.0-1.0/64.0; + } else if ( dist >= 1*12 ) { + dist = 9.0*12.0+11.0+3.0/4.0-1.0/64.0; } - - labelWidth = (wStatusGetWidth( xLabel ) > wStatusGetWidth( yLabel ) ? wStatusGetWidth( xLabel ):wStatusGetWidth( yLabel )); - - return wStatusGetWidth( FormatDistance(dist) ) + labelWidth; + } + + labelWidth = (wStatusGetWidth( xLabel ) > wStatusGetWidth( + yLabel ) ? wStatusGetWidth( xLabel ):wStatusGetWidth( yLabel )); + + return wStatusGetWidth( FormatDistance(dist) ) + labelWidth; } /** * Initialize the status line at the bottom of the window. - * + * */ EXPORT void InitInfoBar( void ) @@ -1176,27 +1255,33 @@ EXPORT void InitInfoBar( void ) infoD.scale_w = wStatusGetWidth( "999:1" ) + wStatusGetWidth( zoomLabel ); /* we do not use the count label for the moment */ infoD.count_w = 0; - infoD.info_w = width - 20 - infoD.pos_w*2 - infoD.scale_w - infoD.count_w - 45; // Allow Window to resize down + infoD.info_w = width - 20 - infoD.pos_w*2 - infoD.scale_w - infoD.count_w - + 45; // Allow Window to resize down if (infoD.info_w <= 0) { infoD.info_w = 10; } yb = y+info_yb_offset; ym = y+(infoHeight-textHeight)/2; boxH = infoHeight; - x = 2; - infoD.scale_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.scale_w, boxH ); - infoD.scale_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarScale", infoD.scale_w-six, zoomLabel); - x += infoD.scale_w + 2; - infoD.posX_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.pos_w, boxH ); - infoD.posX_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarPosX", infoD.pos_w-six, xLabel ); - x += infoD.pos_w + 2; - infoD.posY_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.pos_w, boxH ); - infoD.posY_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarPosY", infoD.pos_w-six, yLabel ); - x += infoD.pos_w + 2; - messageOrControlX = x+info_xm_offset; //Remember Position - messageOrControlY = ym; - infoD.info_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.info_w, boxH ); - infoD.info_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarStatus", infoD.info_w-six, "" ); + x = 2; + infoD.scale_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.scale_w, + boxH ); + infoD.scale_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarScale", + infoD.scale_w-six, zoomLabel); + x += infoD.scale_w + 2; + infoD.posX_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.pos_w, boxH ); + infoD.posX_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarPosX", + infoD.pos_w-six, xLabel ); + x += infoD.pos_w + 2; + infoD.posY_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.pos_w, boxH ); + infoD.posY_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarPosY", + infoD.pos_w-six, yLabel ); + x += infoD.pos_w + 2; + messageOrControlX = x+info_xm_offset; //Remember Position + messageOrControlY = ym; + infoD.info_b = wBoxCreate( mainW, x, yb, NULL, wBoxBelow, infoD.info_w, boxH ); + infoD.info_m = wStatusCreate( mainW, x+info_xm_offset, ym, "infoBarStatus", + infoD.info_w-six, "" ); } @@ -1217,58 +1302,62 @@ static void SetInfoBar( void ) wBoxSetSize( infoD.posY_b, infoD.pos_w, infoHeight-3 ); wStatusSetWidth( infoD.posY_m, infoD.pos_w-six ); } - infoD.info_w = width - 20 - infoD.pos_w*2 - infoD.scale_w - infoD.count_w - 40 + 4; + infoD.info_w = width - 20 - infoD.pos_w*2 - infoD.scale_w - infoD.count_w - 40 + + 4; if (infoD.info_w <= 0) { infoD.info_w = 10; } yb = y+info_yb_offset; ym = y+(infoHeight-textHeight)/2; boxH = infoHeight; - wWinClear( mainW, 0, y, width-20, infoHeight ); - x = 0; - wControlSetPos( (wControl_p)infoD.scale_b, x, yb ); - wControlSetPos( (wControl_p)infoD.scale_m, x+info_xm_offset, ym ); - x += infoD.scale_w + 10; - wControlSetPos( (wControl_p)infoD.posX_b, x, yb ); - wControlSetPos( (wControl_p)infoD.posX_m, x+info_xm_offset, ym ); - x += infoD.pos_w + 5; - wControlSetPos( (wControl_p)infoD.posY_b, x, yb ); - wControlSetPos( (wControl_p)infoD.posY_m, x+info_xm_offset, ym ); - x += infoD.pos_w + 10; - wControlSetPos( (wControl_p)infoD.info_b, x, yb ); - wControlSetPos( (wControl_p)infoD.info_m, x+info_xm_offset, ym ); - wBoxSetSize( infoD.info_b, infoD.info_w, boxH ); - wStatusSetWidth( infoD.info_m, infoD.info_w-six ); - messageOrControlX = x+info_xm_offset; - messageOrControlY = ym; - if (curInfoControl[0]) { - for ( inx=0; curInfoControl[inx]; inx++ ) { - x += curInfoLabelWidth[inx]; - wWinPix_t y_this = ym + (textHeight/2) - (wControlGetHeight( curInfoControl[inx] )/2); - wControlSetPos( curInfoControl[inx], x, y_this ); - x += wControlGetWidth( curInfoControl[inx] )+3; - wControlShow( curInfoControl[inx], TRUE ); - } - wControlSetPos( (wControl_p)infoD.info_m, x+info_xm_offset, ym ); //Move to end + wWinClear( mainW, 0, y, width-20, infoHeight ); + x = 0; + wControlSetPos( (wControl_p)infoD.scale_b, x, yb ); + wControlSetPos( (wControl_p)infoD.scale_m, x+info_xm_offset, ym ); + x += infoD.scale_w + 10; + wControlSetPos( (wControl_p)infoD.posX_b, x, yb ); + wControlSetPos( (wControl_p)infoD.posX_m, x+info_xm_offset, ym ); + x += infoD.pos_w + 5; + wControlSetPos( (wControl_p)infoD.posY_b, x, yb ); + wControlSetPos( (wControl_p)infoD.posY_m, x+info_xm_offset, ym ); + x += infoD.pos_w + 10; + wControlSetPos( (wControl_p)infoD.info_b, x, yb ); + wControlSetPos( (wControl_p)infoD.info_m, x+info_xm_offset, ym ); + wBoxSetSize( infoD.info_b, infoD.info_w, boxH ); + wStatusSetWidth( infoD.info_m, infoD.info_w-six ); + messageOrControlX = x+info_xm_offset; + messageOrControlY = ym; + if (curInfoControl[0]) { + for ( inx=0; curInfoControl[inx]; inx++ ) { + x += curInfoLabelWidth[inx]; + wWinPix_t y_this = ym + (textHeight/2) - (wControlGetHeight( + curInfoControl[inx] )/2); + wControlSetPos( curInfoControl[inx], x, y_this ); + x += wControlGetWidth( curInfoControl[inx] )+3; + wControlShow( curInfoControl[inx], TRUE ); } + wControlSetPos( (wControl_p)infoD.info_m, x+info_xm_offset, ym ); //Move to end + } } static void InfoScale( void ) { - if (mainD.scale >= 1) - sprintf( message, "%s%0.0f:1", zoomLabel, mainD.scale ); - else - sprintf( message, "%s1:%0.0f", zoomLabel, floor(1/mainD.scale+0.5) ); + if (mainD.scale >= 1.0) { + sprintf( message, "%s%.4g:1", zoomLabel, lround(mainD.scale*4.0)/4.0 ); + } else { + sprintf( message, "%s1:%.4g", zoomLabel, lround((1.0/mainD.scale)*4.0)/4.0 ); + } + wStatusSetValue( infoD.scale_m, message ); } EXPORT void InfoCount( wIndex_t count ) { -/* - sprintf( message, "%d", count ); - wMessageSetValue( infoD.count_m, message ); -*/ + /* + sprintf( message, "%d", count ); + wMessageSetValue( infoD.count_m, message ); + */ } EXPORT void InfoPos( coOrd pos ) @@ -1277,7 +1366,7 @@ EXPORT void InfoPos( coOrd pos ) wStatusSetValue( infoD.posX_m, message ); sprintf( message, "%s%s", yLabel, FormatDistance(pos.y) ); wStatusSetValue( infoD.posY_m, message ); - + oldMarker = pos; } @@ -1285,8 +1374,8 @@ static wControl_p deferSubstituteControls[NUM_INFOCTL+1]; static char * deferSubstituteLabels[NUM_INFOCTL]; EXPORT void InfoSubstituteControls( - wControl_p * controls, - char ** labels ) + wControl_p * controls, + char ** labels ) { wWinPix_t x, y; int inx; @@ -1318,7 +1407,8 @@ EXPORT void InfoSubstituteControls( #ifdef WINDOWS wWinPix_t y_this = y + (infoHeight/2) - (textHeight / 2 ); #else - wWinPix_t y_this = y + (infoHeight / 2) - (wControlGetHeight(controls[inx]) / 2) - 2; + wWinPix_t y_this = y + (infoHeight / 2) - (wControlGetHeight( + controls[inx]) / 2) - 2; #endif wControlSetPos( controls[inx], x, y_this ); x += wControlGetWidth( controls[inx] ); @@ -1337,70 +1427,140 @@ EXPORT void SetMessage( char * msg ) wStatusSetValue( infoD.info_m, msg ); } +/** + * Map Handling + * + */ -static void ChangeMapScale( BOOL_T reset ) +/* + * Set mapW size to fit the rescaled map + * + * \param reset IN + */ +static int mapBorderH = 24; +static int mapBorderW = 24; +static void ChangeMapScale() { wWinPix_t w, h; - wWinPix_t dw, dh; FLOAT_T fw, fh; + // Restrict map size to 1/2 of screen + FLOAT_T fScaleW = mapD.size.x / ( displayWidth * 0.5 / mapD.dpi ); + FLOAT_T fScaleH = mapD.size.y / ( displayHeight * 0.5 / mapD.dpi ); + FLOAT_T fScale = ceil( max( fScaleW, fScaleH ) ); + if ( fScale > mapD.scale ) { + LOG( log_mapsize, 2, ( " ChangeMapScale incr scale from %0.3f to %0.3f\n", + mapD.scale, fScale ) ); + mapD.scale = fScale; + } - fw = (((mapD.size.x/mapD.scale)*mapD.dpi) + 0.5)+2; - fh = (((mapD.size.y/mapD.scale)*mapD.dpi) + 0.5)+2; + fw = (((mapD.size.x/mapD.scale)*mapD.dpi) + 0.5)+2; + fh = (((mapD.size.y/mapD.scale)*mapD.dpi) + 0.5)+2; w = (wWinPix_t)fw; h = (wWinPix_t)fh; - if (reset) { - wGetDisplaySize( &dw, &dh ); - wSetGeometry(mapW, 50, dw, 50, dh, -1, -1, mapD.size.x/mapD.size.y); - wWinSetSize( mapW, w+DlgSepLeft+DlgSepRight, h+DlgSepTop+DlgSepBottom); - } + LOG( log_mapsize, 2, ( " ChangeMapScale mapD.scale=%0.3f w=%ld h=%ld\n", + mapD.scale, w, h ) ); + wWinSetSize( mapW, w+mapBorderW, h+mapBorderH ); + // This should be done by wWinSetSize wDrawSetSize( mapD.d, w, h, NULL ); } EXPORT BOOL_T SetRoomSize( coOrd size ) { + LOG( log_mapsize, 2, ( "SetRoomSize NEW:%0.3fx%0.3f OLD:%0.3fx%0.3f\n", size.x, + size.y, mapD.size.x, mapD.size.y ) ); SetLayoutRoomSize(size); - if (size.x < 12.0) - size.x = 12.0; - if (size.y < 12.0) - size.y = 12.0; + if (size.x < 1.0) { + size.x = 1.0; + } + if (size.y < 1.0) { + size.y = 1.0; + } if ( mapD.size.x == size.x && - mapD.size.y == size.y ) + mapD.size.y == size.y ) { return TRUE; + } mapD.size = size; SetLayoutRoomSize(size); - if ( mapW == NULL) - return TRUE; - ChangeMapScale(TRUE); wPrefSetFloat( "draw", "roomsizeX", mapD.size.x ); wPrefSetFloat( "draw", "roomsizeY", mapD.size.y ); + if ( mapW == NULL) { + return TRUE; + } + ChangeMapScale(); return TRUE; } -EXPORT void GetRoomSize( coOrd * froomSize ) -{ - *froomSize = mapD.size; -} - +/** + * Redraw the Map window using the Scale derived from the Window size and Room size + * \param bd [inout] Map canvas - not used + * \param pContext [inout] Param context - not used + * \param px, py [in] canvas size + */ static void MapRedraw( - wDraw_p bd, void * pContex, wWinPix_t px, wWinPix_t py ) + wDraw_p bd, void * pContex, wWinPix_t px, wWinPix_t py ) { - if (inPlaybackQuit) + if (inPlaybackQuit) { return; + } static int cMR = 0; LOG( log_redraw, 2, ( "MapRedraw: %d\n", cMR++ ) ); - if (!mapVisible) + if (!mapVisible) { return; - if (delayUpdate) - wDrawDelayUpdate( mapD.d, TRUE ); + } + if (delayUpdate) { + wDrawDelayUpdate( mapD.d, TRUE ); + } //wSetCursor( mapD.d, wCursorWait ); wBool_t bTemp = wDrawSetTempMode( mapD.d, FALSE ); - if ( bTemp ) + if ( bTemp ) { printf( "MapRedraw TempMode\n" ); + } + + if ( log_mapsize >= 2 ) { + lprintf( " MapRedraw: parm=%ldx%ld", px, py ); + wWinPix_t tx, ty; + if ( mapW ) { + wWinGetSize( mapW, &tx, &ty ); + lprintf( " win=%ldx%ld", tx, ty ); + } + if ( mapD.d ) { + wDrawGetSize( mapD.d, &tx, &ty ); + lprintf( " draw=%ldx%ld", tx, ty ); + } + lprintf( "\n" ); + } + + // Find new mapD.scale + if ( ( px <= 0 || py <= 0 ) && mapD.d ) { + wDrawGetSize( mapD.d, &px, &py ); + px += 2; + py += 2; + } + if ( px > 0 && py > 0 ) { + FLOAT_T scaleX = mapD.size.x * mapD.dpi / px; + FLOAT_T scaleY = mapD.size.y * mapD.dpi / py; + FLOAT_T scale; + + // Find largest scale + if (scaleX>scaleY) { scale = scaleX; } + else { scale = scaleY; } + + if (scale > MAX_MAIN_SCALE) { scale = MAX_MAIN_SCALE; } + if (scale < MIN_MAIN_MACRO) { scale = MIN_MAIN_MACRO; } + + scale = ceil( scale ); // Round up + LOG( log_mapsize, 2, + ( " %ldx%ld mapD.scale=%0.3f, scaleX=%0.3f scaleY=%0.3f scale=%0.3f\n", + px, py, mapD.scale, scaleX, scaleY, scale ) ); + mapD.scale = scale; + } else { + LOG( log_mapsize, 2, ( " 0x0 mapD.scale=%0.3f\n", mapD.scale ) ); + } wDrawClear( mapD.d ); DrawTracks( &mapD, mapD.scale, mapD.orig, mapD.size ); DrawMapBoundingBox( TRUE ); @@ -1410,14 +1570,6 @@ static void MapRedraw( } -static void MapResize( void ) -{ - mapD.scale = mapScale; - ChangeMapScale(TRUE); - MapRedraw( mapD.d, NULL, 0, 0 ); -} - - EXPORT void SetMainSize( void ) { wWinPix_t ww, hh; @@ -1432,35 +1584,34 @@ EXPORT void SetMainSize( void ) tempD.size = mainD.size; } -// Hack to switch between TempRedraw and MainRedraw -extern wBool_t wDrawDoTempDraw; /* Update temp_surface after executing a command */ -EXPORT void TempRedraw( void ) { +EXPORT void TempRedraw( void ) +{ static int cTR = 0; LOG( log_redraw, 2, ( "TempRedraw: %d\n", cTR++ ) ); -if (wDrawDoTempDraw == FALSE) { - // Remove this after windows supports GTK - MainRedraw(); // TempRedraw - windows -} else { - wDrawDelayUpdate( tempD.d, TRUE ); - wDrawSetTempMode( tempD.d, TRUE ); - DrawMarkers(); - DoCurCommand( C_REDRAW, zero ); - RulerRedraw( FALSE ); - RedrawPlaybackCursor(); //If in playback - wDrawSetTempMode( tempD.d, FALSE ); - wDrawDelayUpdate( tempD.d, FALSE ); -} + if (wDrawDoTempDraw == FALSE) { + // Remove this after windows supports GTK + MainRedraw(); // TempRedraw - windows + } else { + wDrawDelayUpdate( tempD.d, TRUE ); + wDrawSetTempMode( tempD.d, TRUE ); + DrawMarkers(); + DoCurCommand( C_REDRAW, zero ); + RulerRedraw( FALSE ); + RedrawPlaybackCursor(); //If in playback + wDrawSetTempMode( tempD.d, FALSE ); + wDrawDelayUpdate( tempD.d, FALSE ); + } } /** * Calculate position and size of background bitmap * * \param [in] drawP destination drawing area - * \param [in] origX x origin of drawing area + * \param [in] origX x origin of drawing area * \param [in] origY y origin of drawing area * \param [out] posX x position of bitmap * \param [out] posY y position of bitmap @@ -1473,15 +1624,15 @@ void TranslateBackground(drawCmd_p drawP, POS_T origX, POS_T origY, wWinPix_t* posX, wWinPix_t* posY, wWinPix_t* pWidth) { - coOrd back_pos = GetLayoutBackGroundPos(); + coOrd back_pos = GetLayoutBackGroundPos(); - *pWidth = (wWinPix_t)(GetLayoutBackGroundSize() / drawP->scale * - drawP->dpi); + *pWidth = (wWinPix_t)(GetLayoutBackGroundSize() / drawP->scale * + drawP->dpi); - *posX = (wWinPix_t)((back_pos.x - origX) / drawP->scale * - drawP->dpi); - *posY = (wWinPix_t)((back_pos.y - origY) / drawP->scale * - drawP->dpi); + *posX = (wWinPix_t)((back_pos.x - origX) / drawP->scale * + drawP->dpi); + *posY = (wWinPix_t)((back_pos.y - origY) / drawP->scale * + drawP->dpi); } /* @@ -1492,10 +1643,12 @@ EXPORT void MainRedraw( void ) coOrd orig, size; static int cMR = 0; - LOG( log_redraw, 1, ( "MainRedraw: %d\n", cMR++ ) ); + LOG( log_redraw, 1, ( "MainRedraw: %d %0.1fx%0.1f\n", cMR++, mainD.size.x, + mainD.size.y ) ); unsigned long time0 = wGetTimer(); - if (delayUpdate) - wDrawDelayUpdate( mainD.d, TRUE ); + if (delayUpdate) { + wDrawDelayUpdate( mainD.d, TRUE ); + } wDrawSetTempMode( mainD.d, FALSE ); wDrawClear( mainD.d ); @@ -1537,7 +1690,8 @@ EXPORT void MainRedraw( void ) //wSetCursor( mainD.d, defaultCursor ); InfoScale(); - LOG( log_timemainredraw, 1, ( "MainRedraw time = %lu mS\n", wGetTimer()-time0 ) ); + LOG( log_timemainredraw, 1, ( "MainRedraw time = %lu mS\n", + wGetTimer()-time0 ) ); // The remainder is from TempRedraw wDrawSetTempMode( tempD.d, TRUE ); DrawMarkers(); @@ -1555,14 +1709,16 @@ EXPORT void MainRedraw( void ) * \param bNoBorder Don't allow mainD.orig to go negative */ EXPORT void MainLayout( - wBool_t bRedraw, - wBool_t bNoBorder ) + wBool_t bRedraw, + wBool_t bNoBorder ) { DIST_T t1; - if (inPlaybackQuit) + if (inPlaybackQuit) { return; + } static int cML = 0; - LOG( log_redraw, 1, ( "MainLayout: %d\n", cML++ ) ); + LOG( log_redraw, 1, ( "MainLayout: %d %s %s\n", cML++, bRedraw?"RDW":"---", + bNoBorder?"NBR":"---" ) ); SetMainSize(); t1 = mainD.dpi/mainD.scale; @@ -1574,14 +1730,17 @@ EXPORT void MainLayout( pixelBins = 0.127; while (1) { pixelBins *= 2.0; - if ( pixelBins >= t1 ) + if ( pixelBins >= t1 ) { break; + } pixelBins *= 2.0; - if ( pixelBins >= t1 ) + if ( pixelBins >= t1 ) { break; + } pixelBins *= 2.5; - if ( pixelBins >= t1 ) + if ( pixelBins >= t1 ) { break; + } } } LOG( log_pan, 2, ( "PixelBins=%0.6f\n", pixelBins ) ); @@ -1592,30 +1751,34 @@ EXPORT void MainLayout( mainCenter.y = mainD.orig.y + mainD.size.y/2.0; DrawMapBoundingBox( TRUE ); - if ( bRedraw ) + if ( bRedraw ) { MainRedraw(); + } if ( bRedraw && wDrawDoTempDraw ) { // Temporary until mswlib supports TempDraw wAction_t action = wActionMove; coOrd pos; - if ( mouseState == mouseLeft ) + if ( mouseState == mouseLeft ) { action = wActionLDrag; - if ( mouseState == mouseRight ) + } + if ( mouseState == mouseRight ) { action = wActionRDrag; + } mainD.Pix2CoOrd( &mainD, mousePositionx, mousePositiony, &pos ); // Prevent recursion if curCommand calls MainLayout when action if a Move or Drag // ie CmdPan static int iRecursion = 0; iRecursion++; - if ( iRecursion == 1 ) + if ( iRecursion == 1 ) { DoMouse( action, pos ); + } iRecursion--; } } /** * The wlib event handler for the main window. - * + * * \param win wlib window information * \param e the wlib event * \param data additional data (unused) @@ -1623,30 +1786,36 @@ EXPORT void MainLayout( void MainProc( wWin_p win, winProcEvent e, void * refresh, void * data ) { + static int cMP = 0; wWinPix_t width, height; switch( e ) { case wResize_e: - if (mainD.d == NULL) + if (mainD.d == NULL) { return; + } wWinGetSize( mainW, &width, &height ); + LOG( log_redraw, 1, ( "MainProc/Resize: %d %s %ld %ld\n", cMP++, + refresh==NULL?"RDW":"---", width, height ) ); LayoutToolBar(refresh); height -= (toolbarHeight+max(infoHeight,textHeight)+10); if (height >= 0) { wBool_t bTemp = wDrawSetTempMode(mainD.d, FALSE ); -if ( bTemp ) - printf( "MainProc TempMode\n" ); + if ( bTemp ) { + printf( "MainProc TempMode\n" ); + } wDrawSetSize( mainD.d, width-20, height, refresh ); wControlSetPos( (wControl_p)mainD.d, 0, toolbarHeight ); SetMainSize(); SetInfoBar(); panCenter.x = mainD.orig.x + mainD.size.x/2.0; panCenter.y = mainD.orig.y + mainD.size.y/2.0; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); MainLayout( !refresh, TRUE ); // MainProc: wResize_e event wPrefSetInteger( "draw", "mainwidth", (int)width ); wPrefSetInteger( "draw", "mainheight", (int)height ); wDrawSetTempMode( mainD.d, bTemp ); - } else DrawMapBoundingBox( TRUE ); + } else { DrawMapBoundingBox( TRUE ); } break; case wState_e: wPrefSetInteger( "draw", "maximized", wWinIsMaximized(win) ); @@ -1666,6 +1835,8 @@ if ( bTemp ) EXPORT void DoRedraw( void ) { + LOG( log_mapsize, 2, ( "DoRedraw\n" ) ); + ChangeMapScale(); MapRedraw( mapD.d, NULL, 0, 0 ); MainRedraw(); // DoRedraw } @@ -1679,8 +1850,9 @@ EXPORT void DoRedraw( void ) static void DrawRoomWalls( wBool_t drawBackground ) { - if (mainD.d == NULL) + if (mainD.d == NULL) { return; + } if (drawBackground) { DrawRectangle( &mainD, mainD.orig, mainD.size, drawColorGrey80, DRAW_FILL ); @@ -1714,13 +1886,13 @@ static DIST_T rulerFontSize = 12.0; EXPORT void DrawRuler( - drawCmd_p d, - coOrd pos0, - coOrd pos1, - DIST_T offset, - int number, - int tickSide, - wDrawColor color ) + drawCmd_p d, + coOrd pos0, + coOrd pos1, + DIST_T offset, + int number, + int tickSide, + wDrawColor color ) { coOrd orig = pos0; wAngle_t a, aa; @@ -1733,9 +1905,10 @@ EXPORT void DrawRuler( coOrd d_orig, d_size; wFontSize_t fs; long mm, mm0, mm1, power, skip; - + static double lengths[] = { - 0, 2.0, 4.0, 2.0, 6.0, 2.0, 4.0, 2.0, 8.0, 2.0, 4.0, 2.0, 6.0, 2.0, 4.0, 2.0, 0.0 }; + 0, 2.0, 4.0, 2.0, 6.0, 2.0, 4.0, 2.0, 8.0, 2.0, 4.0, 2.0, 6.0, 2.0, 4.0, 2.0, 0.0 + }; int fraction, incr, firstFraction, lastFraction; int majorLength; coOrd p0, p1; @@ -1746,18 +1919,21 @@ EXPORT void DrawRuler( aa = NormalizeAngle(a+(tickSide==0?+90:-90)); end = FindDistance( pos0, pos1 ); - if (end < 0.1) + if (end < 0.1) { return; + } d_orig.x = d->orig.x - 0.1; d_orig.y = d->orig.y - 0.1; d_size.x = d->size.x + 0.2; d_size.y = d->size.y + 0.2; - if (!ClipLine( &pos0, &pos1, d_orig, d->angle, d_size )) + if (!ClipLine( &pos0, &pos1, d_orig, d->angle, d_size )) { return; + } start = FindDistance( orig, pos0 ); - if (offset < 0) + if (offset < 0) { start = -start; + } end = FindDistance( orig, pos1 ); DrawLine( d, pos0, pos1, 0, color ); @@ -1779,39 +1955,39 @@ EXPORT void DrawRuler( // Label interval for scale > 40 if (d->scale <= 200) { skip = 2000; - } - else if (d->scale <= 400) { + } else if (d->scale <= 400) { skip = 5000; - } - else { + } else { skip = 10000; } for ( ; power<=1000; power*=10,len+=3 ) { - if (power == 1000) + if (power == 1000) { len = 10; + } for (mm=((mm0+(mm0>0?power-1:0))/power)*power; mm<=mm1; mm+=power) { if (power==1000 || mm%(power*10) != 0) { Translate( &p0, orig, a, mm/25.4 ); Translate( &p1, p0, aa, len*d->scale/mainD.dpi ); DrawLine( d, p0, p1, 0, color ); - if (!number || (d->scale > 40 && mm % skip != 0.0)) + if (!number || (d->scale > 40 && mm % skip != 0.0)) { continue; + } if ( (power>=1000) || - (d->scale<=8 && power>=100) || - (d->scale<=1 && power>=10) ) { + (d->scale<=8 && power>=100) || + (d->scale<=1 && power>=10) ) { if (mm%100 != 0) { sprintf(message, "%ld", mm/10%10 ); fs = rulerFontSize*2/3; Translate( &p0, p0, aa, (fs/2.0+len)*d->scale/mainD.dpi ); - Translate( &p0, p0, 225, fs*d->scale/mainD.dpi ); + Translate( &p0, p0, 225, fs*d->scale/mainD.dpi ); //p0.x = p1.x+4*dxn/10*d->scale/mainD.dpi; //p0.y = p1.y+dyn*d->scale/mainD.dpi; } else { sprintf(message, "%0.1f", mm/1000.0 ); fs = rulerFontSize; Translate( &p0, p0, aa, (fs/2.0+len)*d->scale/mainD.dpi ); - Translate( &p0, p0, 225, 1.5*fs*d->scale/mainD.dpi ); + Translate( &p0, p0, 225, 1.5*fs*d->scale/mainD.dpi ); //p0.x = p0.x+((-(LBORDER-2)/2)+((LBORDER-2)/2+2)*sin_aa)*d->scale/mainD.dpi; //p0.y = p1.y+dyn*d->scale/mainD.dpi; } @@ -1821,18 +1997,19 @@ EXPORT void DrawRuler( } } } else { - if (d->scale <= 1) - incr = 1; //16ths - else if (d->scale <= 3) - incr = 2; //8ths - else if (d->scale <= 5) - incr = 4; //4ths - else if (d->scale <= 7) - incr = 8; //1/2ths - else if (d->scale <= 48) + if (d->scale <= 1) { + incr = 1; //16ths + } else if (d->scale <= 3) { + incr = 2; //8ths + } else if (d->scale <= 5) { + incr = 4; //4ths + } else if (d->scale <= 7) { + incr = 8; //1/2ths + } else if (d->scale <= 48) { incr = 32; - else - incr = 16; //Inches + } else { + incr = 16; //Inches + } lastInch = (int)floor(end); lastFraction = 16; @@ -1842,7 +2019,7 @@ EXPORT void DrawRuler( inch--; firstFraction = 16 - firstFraction; } - for ( ; inch<=lastInch; inch++){ + for ( ; inch<=lastInch; inch++) { if(inch % 12 == 0) { lengths[0] = 12; majorLength = 16; @@ -1855,7 +2032,7 @@ EXPORT void DrawRuler( digit = (int)(inch%12); fs = rulerFontSize*(2.0/3.0); quote = '"'; - } else if (d->scale <= 24){ // 16 + } else if (d->scale <= 24) { // 16 lengths[0] = 10; majorLength = 12; digit = (int)(inch%12); @@ -1863,24 +2040,22 @@ EXPORT void DrawRuler( } else { continue; } - if (inch == lastInch) + if (inch == lastInch) { lastFraction = (((int)((end - lastInch)*16)) / incr) * incr; + } for ( fraction = firstFraction; fraction <= lastFraction; fraction += incr ) { // Tick interval for scale > 128 skip = 0; if(d->scale > 512) { skip = (inch % 120 != 0); - } - else if(d->scale > 256) { + } else if(d->scale > 256) { skip = (inch % 60 != 0); - } - else if(d->scale > 128) { + } else if(d->scale > 128) { skip = (inch % 24 != 0); - } - else if(d->scale > 64) { + } else if(d->scale > 64) { skip = (inch % 12 != 0); } - if(!skip){ + if(!skip) { Translate( &p0, orig, a, inch+fraction/16.0 ); Translate( &p1, p0, aa, lengths[fraction]*d->scale/mainD.dpi ); DrawLine( d, p0, p1, 0, color ); @@ -1889,20 +2064,16 @@ EXPORT void DrawRuler( // Label interval for scale > 40 if (d->scale <= 80) { skip = 2; - } - else if (d->scale <= 120) { + } else if (d->scale <= 120) { skip = 5; - } - else if (d->scale <= 240) { + } else if (d->scale <= 240) { skip = 10; - } - else if (d->scale <= 480) { + } else if (d->scale <= 480) { skip = 20; - } - else { + } else { skip = 50; } - if ( (number == TRUE && d->scale <= 40) || (digit % skip == 0)) { + if ( number == TRUE && ((d->scale <= 40) || (digit % skip == 0.0)) ) { if (inch % 12 == 0 || d->scale <= 2) { Translate( &p0, p0, aa, majorLength*d->scale/mainD.dpi ); Translate( &p0, p0, 225, fs*d->scale/mainD.dpi ); @@ -1911,7 +2082,7 @@ EXPORT void DrawRuler( } } } - firstFraction = 0; + firstFraction = 0; } } } @@ -1928,14 +2099,14 @@ static void DrawTicks( drawCmd_p d, coOrd size ) double blank_zone = 40*d->scale/mainD.dpi; if ( d->orig.x<0.0-blank_zone ) { - p0.y = 0.0; p1.y = mapD.size.y; - p0.x = p1.x = 0.0; - DrawRuler( d, p0, p1, offset, FALSE, TRUE, borderColor ); + p0.y = 0.0; p1.y = mapD.size.y; + p0.x = p1.x = 0.0; + DrawRuler( d, p0, p1, offset, FALSE, TRUE, borderColor ); } if (d->orig.x+d->size.x>mapD.size.x+blank_zone) { - p0.y = 0.0; p1.y = mapD.size.y; - p0.x = p1.x = mapD.size.x; - DrawRuler( d, p0, p1, offset, FALSE, FALSE, borderColor ); + p0.y = 0.0; p1.y = mapD.size.y; + p0.x = p1.x = mapD.size.x; + DrawRuler( d, p0, p1, offset, FALSE, FALSE, borderColor ); } p0.x = 0.0; p1.x = d->size.x; offset = d->orig.x; @@ -1952,9 +2123,9 @@ static void DrawTicks( drawCmd_p d, coOrd size ) DrawRuler( d, p0, p1, offset, FALSE, FALSE, borderColor ); } if (d->orig.y+d->size.y>mapD.size.y+blank_zone) { - p0.x = 0.0; p1.x = mapD.size.x; - p0.y = p1.y = mapD.size.y; - DrawRuler( d, p0, p1, offset, FALSE, TRUE, borderColor ); + p0.x = 0.0; p1.x = mapD.size.x; + p0.y = p1.y = mapD.size.y; + DrawRuler( d, p0, p1, offset, FALSE, TRUE, borderColor ); } p0.y = 0.0; p1.y = d->size.y; offset = d->orig.y; @@ -1974,23 +2145,26 @@ EXPORT coOrd mainCenter; static void DrawMapBoundingBox( BOOL_T set ) { - if (mainD.d == NULL || mapD.d == NULL) - abort(); - if (!mapVisible) + CHECK( mainD.d ); + CHECK( mapD.d ); + if (!mapVisible) { return; + } DrawHilight( &mapD, mainD.orig, mainD.size, TRUE ); } -static void ConstraintOrig( coOrd * orig, coOrd size, wBool_t bNoBorder, wBool_t bRound ) +static void ConstraintOrig( coOrd * orig, coOrd size, wBool_t bNoBorder, + wBool_t bRound ) { -LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=%0.3fx%0.3f", - orig->x, orig->y, mapD.size.x, mapD.size.y, - size.x, size.y ) ) + LOG( log_pan, 2, + ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=%0.3fx%0.3f", + orig->x, orig->y, mapD.size.x, mapD.size.y, + size.x, size.y ) ) coOrd bound = zero; - if ( !bNoBorder ) { + if ( !bNoBorder ) { bound.x = size.x/2; bound.y = size.y/2; } @@ -2004,8 +2178,9 @@ LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=% } } - if (orig->x < (0-bound.x)) - orig->x = 0-bound.x; + if (orig->x < (0-bound.x)) { + orig->x = 0-bound.x; + } if (orig->y > 0.0) { if ((orig->y+size.y) > (mapD.size.y+bound.y) ) { @@ -2015,8 +2190,9 @@ LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=% } } - if (orig->y < (0-bound.y)) - orig->y = 0-bound.y; + if (orig->y < (0-bound.y)) { + orig->y = 0-bound.y; + } if (bRound) { orig->x = round(orig->x*pixelBins)/pixelBins; @@ -2026,8 +2202,8 @@ LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=% } /** - * Initialize the menu for setting zoom factors. - * + * Initialize the menu for setting zoom factors. + * * \param IN zoomM Menu to which radio button is added * \param IN zoomSubM Second menu to which radio button is added, ignored if NULL * \param IN ctxMenu1 @@ -2035,31 +2211,34 @@ LOG( log_pan, 2, ( "ConstraintOrig [ %0.6f, %0.6f ] RoomSize(%0.3f %0.3f), WxH=% * */ -EXPORT void InitCmdZoom( wMenu_p zoomM, wMenu_p zoomSubM, wMenu_p ctxMenu1, wMenu_p panMenu ) +EXPORT void InitCmdZoom( wMenu_p zoomM, wMenu_p zoomSubM, wMenu_p ctxMenu1, + wMenu_p panMenu ) { int inx; - + for ( inx=0; inx<COUNT( zoomList ); inx++ ) { - if( (zoomList[ inx ].value >= 1.0 && zoomList[ inx ].value<=10 ) || - (ceil(log2(zoomList[ inx ].value)) == floor(log2(zoomList[ inx ].value)))) - { - if (zoomM) - zoomList[inx].btRadio = wMenuRadioCreate( zoomM, "cmdZoom", zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); - if( zoomSubM ) - zoomList[inx].pdRadio = wMenuRadioCreate( zoomSubM, "cmdZoom", zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); - if (panMenu) - zoomList[inx].panRadio = wMenuRadioCreate( panMenu, "cmdZoom", zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); + if (zoomM) { + zoomList[inx].btRadio = wMenuRadioCreate( zoomM, "cmdZoom", zoomList[inx].name, + 0, DoZoom, (&(zoomList[inx].value))); } - if ((zoomList[inx].value >=1.0 && zoomList[inx].value <= 10.0) || (ceil(log2(zoomList[ inx ].value)) == floor(log2(zoomList[ inx ].value)))) { - if (ctxMenu1) - zoomList[inx].ctxRadio1 = wMenuRadioCreate( ctxMenu1, "cmdZoom", zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); + if( zoomSubM ) { + zoomList[inx].pdRadio = wMenuRadioCreate( zoomSubM, "cmdZoom", + zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); + } + if (panMenu) { + zoomList[inx].panRadio = wMenuRadioCreate( panMenu, "cmdZoom", + zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); + } + if (ctxMenu1) { + zoomList[inx].ctxRadio1 = wMenuRadioCreate( ctxMenu1, "cmdZoom", + zoomList[inx].name, 0, DoZoom, (&(zoomList[inx].value))); } } } /** * Set radio button(s) corresponding to current scale. - * + * * \param IN scale current scale * */ @@ -2067,93 +2246,126 @@ EXPORT void InitCmdZoom( wMenu_p zoomM, wMenu_p zoomSubM, wMenu_p ctxMenu1, wMen static void SetZoomRadio( DIST_T scale ) { int inx; - long curScale = (long)scale; - + for ( inx=0; inx<COUNT( zoomList ); inx++ ) { - if( curScale == zoomList[inx].value ) { - if (zoomList[inx].btRadio) + if( scale == zoomList[inx].value ) { + if (zoomList[inx].btRadio) { wMenuRadioSetActive( zoomList[inx].btRadio ); - if( zoomList[inx].pdRadio ) + } + if( zoomList[inx].pdRadio ) { wMenuRadioSetActive( zoomList[inx].pdRadio ); - if (zoomList[inx].ctxRadio1) + } + if (zoomList[inx].ctxRadio1) { wMenuRadioSetActive( zoomList[inx].ctxRadio1 ); - if (zoomList[inx].panRadio) + } + if (zoomList[inx].panRadio) { wMenuRadioSetActive( zoomList[inx].panRadio ); - /* activate / deactivate zoom buttons when appropriate */ + } + /* activate / deactivate zoom buttons when appropriate */ wControlLinkedActive( (wControl_p)zoomUpB, ( inx != 0 ) ); - wControlLinkedActive( (wControl_p)zoomDownB, ( inx < (COUNT( zoomList ) - 1))); + wControlLinkedActive( (wControl_p)zoomDownB, ( inx < (COUNT( zoomList ) - 1))); } } -} +} /** - * Find current scale + * Find current scale * * \param IN scale current scale * \return index in scale table or -1 if error * */ - + static int ScaleInx( DIST_T scale ) { int inx; - + for ( inx=0; inx<COUNT( zoomList); inx++ ) { if( scale == zoomList[inx].value ) { return inx; } } - return -1; + return -1; } /* * Find Nearest Scale */ -static int NearestScaleInx ( DIST_T scale, BOOL_T larger ) { +static int NearestScaleInx ( DIST_T scale, BOOL_T larger ) +{ int inx; - for ( inx=0; inx<COUNT( zoomList ); inx++ ) { + //scale = rintf(scale*4.0)/4.0; + + if (larger) { + for ( inx=0; inx<COUNT( zoomList )-1; inx++ ) { if( scale == zoomList[inx].value ) { return inx; } - if (scale < zoomList[inx].value) return inx; + if (scale < zoomList[inx].value) { + return inx; + } } return inx-1; + } else { + for ( inx=COUNT( zoomList)-1; inx>=0; inx-- ) { + if( scale == zoomList[inx].value ) { + return inx; + } + if (scale > zoomList[inx].value ) { + return inx; + } + } + } + return 0; } /** - * Set up for new drawing scale. After the scale was changed, eg. via zoom button, everything - * is set up for the new scale. + * Set up for new drawing scale. After the scale was changed, eg. via zoom button, everything + * is set up for the new scale. * * \param scale IN new scale */ - + static void DoNewScale( DIST_T scale ) { char tmp[20]; - if (scale > MAX_MAIN_SCALE) + static BOOL_T in_use = 0; //lock for recursion to avoid additional setting. + + if (in_use) { return; } + + in_use = 1; //set lock + + if (scale > MAX_MAIN_SCALE) { scale = MAX_MAIN_SCALE; + } + + if (scale < zoomList[0].value) { + scale = zoomList[0].value; + } tempD.scale = mainD.scale = scale; mainD.dpi = wDrawGetDPI( mainD.d ); - if ( scale > 1.0 && scale <= 12.0 ) { - mainD.dpi = floor( (mainD.dpi + scale/2)/scale) * scale; - } + //if ( scale > 1.0 && scale <= 12.0 ) { + // mainD.dpi = floor( (mainD.dpi + scale/2)/scale) * scale; + //} tempD.dpi = mainD.dpi; - SetZoomRadio( scale ); + SetZoomRadio( scale ); //This routine causes a re-drive of the DoNewScale. + InfoScale(); - SetMainSize(); + SetMainSize(); PanHere( I2VP(1) ); -LOG( log_zoom, 1, ( "center = [%0.3f %0.3f]\n", mainCenter.x, mainCenter.y ) ) + LOG( log_zoom, 1, ( "center = [%0.3f %0.3f]\n", mainCenter.x, mainCenter.y ) ) sprintf( tmp, "%0.3f", mainD.scale ); wPrefSetString( "draw", "zoom", tmp ); if (recordF) { fprintf( recordF, "ORIG %0.3f %0.3f %0.3f\n", - mainD.scale, mainD.orig.x, mainD.orig.y ); + mainD.scale, mainD.orig.x, mainD.orig.y ); } + in_use=0; //release lock } @@ -2167,34 +2379,37 @@ EXPORT void DoZoomUp( void * mode ) { long newScale; int i; - + LOG( log_zoom, 2, ( "DoZoomUp KS:%x\n", MyGetKeyState() ) ); if ( mode != NULL || (MyGetKeyState()&WKEY_SHIFT) == 0) { i = ScaleInx( mainD.scale ); - if (i < 0) i = NearestScaleInx(mainD.scale, TRUE); - /* - * Zooming into macro mode happens when we are at scale 1:1. + if (i < 0) { i = NearestScaleInx(mainD.scale, FALSE); } + /* + * Zooming into macro mode happens when we are at scale 1:1. * To jump into macro mode, the CTRL-key has to be pressed and held. */ if( mainD.scale != 1.0 || (mainD.scale == 1.0 && (MyGetKeyState()&WKEY_CTRL))) { if( i ) { - if (mainD.scale <=1.0) + if (mainD.scale <=1.0) { InfoMessage(_("Macro Zoom Mode")); - else + } else { InfoMessage(""); - DoNewScale( zoomList[ i - 1 ].value ); - - } else InfoMessage("Minimum Macro Zoom"); + } + DoNewScale( zoomList[ i - 1 ].value ); + + } else { InfoMessage("Minimum Macro Zoom"); } } else { InfoMessage(_("Scale 1:1 - Use Ctrl+ to go to Macro Zoom Mode")); } } else if ( (MyGetKeyState()&WKEY_CTRL) == 0 ) { wPrefGetInteger( "misc", "zoomin", &newScale, 4 ); - InfoMessage(_("Preset Zoom In Value selected. Shift+Ctrl+PageDwn to reset value")); + InfoMessage( + _("Preset Zoom In Value selected. Shift+Ctrl+PageDwn to reset value")); DoNewScale( newScale ); } else { wPrefSetInteger( "misc", "zoomin", (long)mainD.scale ); - InfoMessage( _("Zoom In Program Value %ld:1, Shift+PageDwn to use"), (long)mainD.scale ); + InfoMessage( _("Zoom In Program Value %ld:1, Shift+PageDwn to use"), + (long)mainD.scale ); } } @@ -2202,31 +2417,33 @@ EXPORT void DoZoomUp( void * mode ) * Mode - 0 = Extents are Map size * Mode - 1 = Extents are Selected size */ -EXPORT void DoZoomExtents( void * mode) { +EXPORT void DoZoomExtents( void * mode) +{ DIST_T scale_x, scale_y; if ( 1 == VP2L(mode) ) { - if ( selectedTrackCount == 0 ) - return; - track_p trk = NULL; - coOrd bot, top; - BOOL_T first = TRUE; - while ( TrackIterate( &trk ) ) { - if(GetTrkSelected(trk)) { - coOrd hi, lo; - GetBoundingBox(trk,&hi,&lo); - if (first) { - first = FALSE; - bot = lo; - top = hi; - } else { - if (lo.x < bot.x) bot.x = lo.x; - if (lo.y < bot.y) bot.y = lo.y; - if (hi.x > top.x) top.x = hi.x; - if (hi.y > top.y) top.y = hi.y; - } - } + if ( selectedTrackCount == 0 ) { + return; + } + track_p trk = NULL; + coOrd bot, top; + BOOL_T first = TRUE; + while ( TrackIterate( &trk ) ) { + if(GetTrkSelected(trk)) { + coOrd hi, lo; + GetBoundingBox(trk,&hi,&lo); + if (first) { + first = FALSE; + bot = lo; + top = hi; + } else { + if (lo.x < bot.x) { bot.x = lo.x; } + if (lo.y < bot.y) { bot.y = lo.y; } + if (hi.x > top.x) { top.x = hi.x; } + if (hi.y > top.y) { top.y = hi.y; } + } } + } panCenter.x = (top.x/2)+(bot.x)/2; panCenter.y = (top.y/2)+(bot.y)/2; PanHere(I2VP(1)); @@ -2238,13 +2455,15 @@ EXPORT void DoZoomExtents( void * mode) { } - if (scale_x<scale_y) + if (scale_x<scale_y) { scale_x = scale_y; + } scale_x = ceil(scale_x); - if (scale_x < 1) scale_x = 1; - if (scale_x > MAX_MAIN_SCALE) scale_x = MAX_MAIN_SCALE; - if (1 != (intptr_t)1) + if (scale_x < 1) { scale_x = 1; } + if (scale_x > MAX_MAIN_SCALE) { scale_x = MAX_MAIN_SCALE; } + if (1 != (intptr_t)1) { mainD.orig = zero; + } DoNewScale(scale_x); MainLayout(TRUE,TRUE); @@ -2261,31 +2480,34 @@ EXPORT void DoZoomDown( void * mode) { long newScale; int i; - + LOG( log_zoom, 2, ( "DoZoomDown KS:%x\n", MyGetKeyState() ) ); if ( mode != NULL || (MyGetKeyState()&WKEY_SHIFT) == 0 ) { i = ScaleInx( mainD.scale ); - if (i < 0) i = NearestScaleInx(mainD.scale, TRUE); - if( i>= 0 && i < ( COUNT( zoomList ) - 1 )) { + if (i < 0) { i = NearestScaleInx(mainD.scale, TRUE); } + if( i >= 0 && i < ( COUNT( zoomList ) - 1 )) { InfoMessage(""); DoNewScale( zoomList[ i + 1 ].value ); - } else + } else { InfoMessage(_("At Maximum Zoom Out")); - - + } + + } else if ( (MyGetKeyState()&WKEY_CTRL) == 0 ) { wPrefGetInteger( "misc", "zoomout", &newScale, 16 ); - InfoMessage(_("Preset Zoom Out Value selected. Shift+Ctrl+PageUp to reset value")); + InfoMessage( + _("Preset Zoom Out Value selected. Shift+Ctrl+PageUp to reset value")); DoNewScale( newScale ); } else { wPrefSetInteger( "misc", "zoomout", (long)mainD.scale ); - InfoMessage( _("Zoom Out Program Value %ld:1 set, Shift+PageUp to use"), (long)mainD.scale ); + InfoMessage( _("Zoom Out Program Value %ld:1 set, Shift+PageUp to use"), + (long)mainD.scale ); } } /** - * Zoom to user selected value. This is the callback function for the - * user-selectable preset zoom values. + * Zoom to user selected value. This is the callback function for the + * user-selectable preset zoom values. * * \param IN scale current pScale * @@ -2295,26 +2517,27 @@ static void DoZoom( void * pScaleVP ) DIST_T *pScale = pScaleVP; DIST_T scale = *pScale; - if( scale != mainD.scale ) + if( scale != mainD.scale ) { DoNewScale( scale ); + } } EXPORT void Pix2CoOrd( - drawCmd_p d, - wDrawPix_t x, - wDrawPix_t y, - coOrd * pos ) + drawCmd_p d, + wDrawPix_t x, + wDrawPix_t y, + coOrd * pos ) { pos->x = (((DIST_T)x)/d->dpi)*d->scale+d->orig.x; pos->y = (((DIST_T)y)/d->dpi)*d->scale+d->orig.y; } EXPORT void CoOrd2Pix( - drawCmd_p d, - coOrd pos, - wDrawPix_t * x, - wDrawPix_t * y ) + drawCmd_p d, + coOrd pos, + wDrawPix_t * x, + wDrawPix_t * y ) { *x = (wDrawPix_t)((pos.x-d->orig.x)/d->scale*d->dpi); *y = (wDrawPix_t)((pos.y-d->orig.y)/d->scale*d->dpi); @@ -2330,20 +2553,24 @@ EXPORT void CoOrd2Pix( * - 2: same as 0, plus liveMap * - 3: Take position from menuPos */ -EXPORT void PanHere(void * mode) { +EXPORT void PanHere(void * mode) +{ if ( 3 == VP2L(mode ) ) { panCenter = menuPos; - LOG( log_pan, 2, ( "MCenter:Mod-%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "MCenter:Mod-%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + } + wBool_t bLiveMap = TRUE; + if ( 2 == VP2L(mode) ) { + bLiveMap = liveMap; } mainD.orig.x = panCenter.x - mainD.size.x/2.0; mainD.orig.y = panCenter.y - mainD.size.y/2.0; wBool_t bNoBorder = (constrainMain != 0); if ( 1 != VP2L(mode) ) - if ( (MyGetKeyState()&WKEY_CTRL)!= 0 ) + if ( (MyGetKeyState()&WKEY_CTRL)!= 0 ) { bNoBorder = !bNoBorder; - wBool_t bLiveMap = TRUE; - if ( 2 == VP2L(mode) ) - bLiveMap = liveMap; + } MainLayout( bLiveMap, bNoBorder ); // PanHere } @@ -2365,44 +2592,52 @@ static int DoPanKeyAction( wAction_t action ) case wAccelKey_Right: panCenter.x = mainD.orig.x + mainD.size.x/2; panCenter.y = mainD.orig.y + mainD.size.y/2; - if ((MyGetKeyState() & WKEY_SHIFT) != 0) - panCenter.x += 0.25*mainD.scale; //~1cm in 1::1, 1ft in 30:1, 1mm in 10:1 - else + if ((MyGetKeyState() & WKEY_SHIFT) != 0) { + panCenter.x += 0.25*mainD.scale; //~1cm in 1::1, 1ft in 30:1, 1mm in 10:1 + } else { panCenter.x += mainD.size.x/2; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + } + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); break; case wAccelKey_Left: panCenter.x = mainD.orig.x + mainD.size.x/2; panCenter.y = mainD.orig.y + mainD.size.y/2; - if ((MyGetKeyState() & WKEY_SHIFT) != 0) + if ((MyGetKeyState() & WKEY_SHIFT) != 0) { panCenter.x -= 0.25*mainD.scale; - else + } else { panCenter.x -= mainD.size.x/2; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + } + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); break; case wAccelKey_Up: panCenter.x = mainD.orig.x + mainD.size.x/2; panCenter.y = mainD.orig.y + mainD.size.y/2; - if ((MyGetKeyState() & WKEY_SHIFT) != 0) + if ((MyGetKeyState() & WKEY_SHIFT) != 0) { panCenter.y += 0.25*mainD.scale; - else + } else { panCenter.y += mainD.size.y/2; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + } + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); break; case wAccelKey_Down: panCenter.x = mainD.orig.x + mainD.size.x/2; panCenter.y = mainD.orig.y + mainD.size.y/2; - if ((MyGetKeyState() & WKEY_SHIFT) != 0) + if ((MyGetKeyState() & WKEY_SHIFT) != 0) { panCenter.y -= 0.25*mainD.scale; - else + } else { panCenter.y -= mainD.size.y/2; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + } + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere(I2VP(0)); break; @@ -2424,63 +2659,77 @@ static void DoMapPan( wAction_t action, coOrd pos ) switch (action & 0xFF) { case C_DOWN: - if ( mode == noPan ) + if ( mode == noPan ) { mode = movePan; - else + } else { break; + } case C_MOVE: - if ( mode != movePan ) + if ( mode != movePan ) { break; + } // mainD.orig.x = pos.x - mainD.size.x/2.0; // mainD.orig.y = pos.y - mainD.size.y/2.0; panCenter = pos; -LOG( log_pan, 1, ( "%s = [ %0.3f, %0.3f ]\n", action == C_DOWN? "START":"MOVE", mainD.orig.x, mainD.orig.y ) ) + LOG( log_pan, 1, ( "%s = [ %0.3f, %0.3f ]\n", action == C_DOWN? "START":"MOVE", + mainD.orig.x, mainD.orig.y ) ) PanHere( I2VP(2)); break; case C_UP: - if ( mode != movePan ) + if ( mode != movePan ) { break; + } panCenter = pos; PanHere( I2VP(0)); -LOG( log_pan, 1, ( "FINAL = [ %0.3f, %0.3f ]\n", mainD.orig.x, mainD.orig.y ) ) + LOG( log_pan, 1, ( "FINAL = [ %0.3f, %0.3f ]\n", mainD.orig.x, mainD.orig.y ) ) mode = noPan; break; case C_RDOWN: - if ( mode == noPan ) + if ( mode == noPan ) { mode = resizePan; - else + } else { break; + } mapOrig = pos; size.x = mainD.size.x/mainD.scale; //How big screen? size.y = mainD.size.y/mainD.scale; xscale = mainD.scale; //start at current panCenter = pos; -LOG( log_pan, 1, ( "START %0.3fx%0.3f %0.3f+%0.3f\n", mapOrig.x, mapOrig.y, size.x, size.y ) ) + LOG( log_pan, 1, ( "START %0.3fx%0.3f %0.3f+%0.3f\n", mapOrig.x, mapOrig.y, + size.x, size.y ) ) break; case C_RMOVE: - if ( mode != resizePan ) + if ( mode != resizePan ) { break; - if (pos.x < 0) + } + if (pos.x < 0) { pos.x = 0; - if (pos.x > mapD.size.x) + } + if (pos.x > mapD.size.x) { pos.x = mapD.size.x; - if (pos.y < 0) + } + if (pos.y < 0) { pos.y = 0; - if (pos.y > mapD.size.y) + } + if (pos.y > mapD.size.y) { pos.y = mapD.size.y; + } xscale = fabs((pos.x-mapOrig.x)*2.0/size.x); yscale = fabs((pos.y-mapOrig.y)*2.0/size.y); - if (xscale < yscale) + if (xscale < yscale) { xscale = yscale; + } xscale = ceil( xscale ); - if (xscale < 0.01) + if (xscale < 0.01) { xscale = 0.01; - if (xscale > 64) + } + if (xscale > 64) { xscale = 64; + } mainD.size.x = size.x * xscale; mainD.size.y = size.y * xscale; @@ -2488,13 +2737,15 @@ LOG( log_pan, 1, ( "START %0.3fx%0.3f %0.3f+%0.3f\n", mapOrig.x, mapOrig.y, size mainD.orig.y = mapOrig.y - mainD.size.y / 2.0; tempD.scale = mainD.scale = xscale; PanHere( I2VP(2)); -LOG( log_pan, 1, ( "MOVE SCL:%0.3f %0.3fx%0.3f %0.3f+%0.3f\n", xscale, mainD.orig.x, mainD.orig.y, mainD.size.x, mainD.size.y ) ) + LOG( log_pan, 1, ( "MOVE SCL:%0.3f %0.3fx%0.3f %0.3f+%0.3f\n", xscale, + mainD.orig.x, mainD.orig.y, mainD.size.x, mainD.size.y ) ) InfoScale(); - break; + break; case C_RUP: - if ( mode != resizePan ) + if ( mode != resizePan ) { break; + } DoNewScale( xscale ); mode = noPan; break; @@ -2515,13 +2766,12 @@ LOG( log_pan, 1, ( "MOVE SCL:%0.3f %0.3fx%0.3f %0.3f+%0.3f\n", xscale, mainD.ori /* * IsClose * is distance smaller than 10 pixels at 72 DPI? +* is distance smaller than 0.1" at 1:1? */ EXPORT BOOL_T IsClose( - DIST_T d ) + DIST_T d ) { - wDrawPix_t pd; - pd = (wDrawPix_t)(d/mainD.scale * mainD.dpi); - return pd <= closePixels; + return d <= closeDist*mainD.scale; } /***************************************************************************** @@ -2548,7 +2798,7 @@ EXPORT void FakeDownMouseState( void ) * * \param x OUT pointer x position * \param y OUT pointer y position - * \return + * \return */ void @@ -2560,7 +2810,8 @@ GetMousePosition( wDrawPix_t *x, wDrawPix_t *y ) } } -coOrd minIncrementSizes() { +coOrd minIncrementSizes() +{ double x,y; if (mainD.scale >= 1.0) { if (units == UNITS_ENGLISH) { @@ -2572,11 +2823,11 @@ coOrd minIncrementSizes() { } } else { if (units == UNITS_ENGLISH) { - x = 1/64; //<1:1 = 1/64 inch - y = 1/64; + x = 1.0/64.0; //<1:1 = 1/64 inch + y = 1.0/64.0; } else { - x = 1/(25.4*2); //>1:1 = 0.5 mm - y = 1/(25.4*2); + x = 1.0/(25.4*2); //>1:1 = 0.5 mm + y = 1.0/(25.4*2); } } coOrd ret; @@ -2591,8 +2842,12 @@ static void DoMouse( wAction_t action, coOrd pos ) BOOL_T rc; wDrawPix_t x, y; static BOOL_T ignoreCommands; + // Middle button pan state + static BOOL_T panActive = FALSE; + static coOrd panOrigin, panStart; - LOG( log_mouse, 2, ( "DoMouse( %d, %0.3f, %0.3f )\n", action, pos.x, pos.y ) ) + LOG( log_mouse, (action == wActionMove)?2:1, + ( "DoMouse( %d, %0.3f, %0.3f )\n", action, pos.x, pos.y ) ) if (recordF) { RecordMouse( "MOUSE", action, pos.x, pos.y ); @@ -2602,8 +2857,9 @@ static void DoMouse( wAction_t action, coOrd pos ) switch (action&0xFF) { case C_UP: - if (mouseState != mouseLeft) + if (mouseState != mouseLeft) { return; + } if (ignoreCommands) { ignoreCommands = FALSE; return; @@ -2611,29 +2867,43 @@ static void DoMouse( wAction_t action, coOrd pos ) mouseState = mouseNone; break; case C_RUP: - if (mouseState != mouseRight) + if (mouseState != mouseRight) { return; + } if (ignoreCommands) { ignoreCommands = FALSE; return; } mouseState = mouseNone; break; + case C_MUP: + if ( !panActive ) { + return; + } + if (ignoreCommands) { + ignoreCommands = FALSE; + return; + } + break; case C_MOVE: if (mouseState == mouseLeftPending ) { action = C_DOWN; mouseState = mouseLeft; } - if (mouseState != mouseLeft) + if (mouseState != mouseLeft) { + return; + } + if (ignoreCommands) { return; - if (ignoreCommands) - return; + } break; case C_RMOVE: - if (mouseState != mouseRight) + if (mouseState != mouseRight) { + return; + } + if (ignoreCommands) { return; - if (ignoreCommands) - return; + } break; case C_DOWN: mouseState = mouseLeft; @@ -2641,11 +2911,19 @@ static void DoMouse( wAction_t action, coOrd pos ) case C_RDOWN: mouseState = mouseRight; break; + case C_MDOWN: + // Set up state for Middle button pan + panActive = TRUE; + panOrigin = panCenter; + panStart.x = pos.x-mainD.orig.x; + panStart.y = pos.y-mainD.orig.y; + break; } inError = FALSE; - if ( deferSubstituteControls[0] ) + if ( deferSubstituteControls[0] ) { InfoSubstituteControls( deferSubstituteControls, deferSubstituteLabels ); + } // panCenter.y = mainD.orig.y + mainD.size.y/2; // panCenter.x = mainD.orig.x + mainD.size.x/2; @@ -2654,105 +2932,131 @@ static void DoMouse( wAction_t action, coOrd pos ) coOrd min = minIncrementSizes(); switch ( action&0xFF ) { - case C_DOWN: - case C_RDOWN: - tempSegs_da.cnt = 0; - break; - case wActionMove: - InfoPos( pos ); - if ( ignoreMoves ) - return; - break; - case wActionExtKey: - mainD.CoOrd2Pix(&mainD,pos,&x,&y); - if ((MyGetKeyState() & - (WKEY_SHIFT | WKEY_CTRL)) == (WKEY_SHIFT | WKEY_CTRL) && - ( action>>8 == wAccelKey_Up || - action>>8 == wAccelKey_Down || - action>>8 == wAccelKey_Left || - action>>8 == wAccelKey_Right )) - break; //Allow SHIFT+CTRL for Move - if (((action>>8)&0xFF) == wAccelKey_LineFeed) { - action = C_TEXT+((int)(0x0A<<8)); - break; - } - int rc = DoPanKeyAction(action); - if (rc!=1) return; - break; - case C_TEXT: - if ((action>>8) == 0x0D) { - action = C_OK; - } else if ((action>>8) == 0x1B) { - ConfirmReset( TRUE ); - return; - } - /*no break */ - case C_MODKEY: - case C_MOVE: - case C_UP: - case C_RMOVE: - case C_RUP: - case C_LDOUBLE: - InfoPos( pos ); - /*DrawTempTrack();*/ - break; - case C_WUP: - DoZoomUp(I2VP(1L)); - break; - case C_WDOWN: - DoZoomDown(I2VP(1L)); - break; - case C_SCROLLUP: - panCenter.y = panCenter.y + ((mainD.size.y/20>min.y)?mainD.size.y/20:min.y); - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(1)); - break; - case C_SCROLLDOWN: - panCenter.y = panCenter.y - ((mainD.size.y/20>min.y)?mainD.size.y/20:min.y); - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(1)); - break; - case C_SCROLLLEFT: - panCenter.x = panCenter.x - ((mainD.size.x/20>min.x)?mainD.size.x/20:min.x); - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(1)); - break; - case C_SCROLLRIGHT: - panCenter.x = panCenter.x + ((mainD.size.x/20>min.x)?mainD.size.x/20:min.x); - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); - PanHere(I2VP(1)); - break; - default: - NoticeMessage( MSG_DOMOUSE_BAD_OP, _("Ok"), NULL, action&0xFF ); - break; + case C_DOWN: + case C_RDOWN: + DYNARR_RESET( trkSeg_t, tempSegs_da ); + break; + case C_MDOWN: + break; + case wActionMove: + InfoPos( pos ); + if ( ignoreMoves ) { + return; } - if (delayUpdate) - wDrawDelayUpdate( mainD.d, TRUE ); - rc = DoCurCommand( action, pos ); - wDrawDelayUpdate( mainD.d, FALSE ); - switch( rc ) { - case C_CONTINUE: - /*DrawTempTrack();*/ - break; - case C_ERROR: - ignoreCommands = TRUE; - inError = TRUE; - Reset(); - LOG( log_mouse, 1, ( "Mouse returns Error\n" ) ) - break; - case C_TERMINATE: - Reset(); - DoCurCommand( C_START, zero ); + break; + case wActionExtKey: + mainD.CoOrd2Pix(&mainD,pos,&x,&y); + if ((MyGetKeyState() & + (WKEY_SHIFT | WKEY_CTRL)) == (WKEY_SHIFT | WKEY_CTRL) && + ( action>>8 == wAccelKey_Up || + action>>8 == wAccelKey_Down || + action>>8 == wAccelKey_Left || + action>>8 == wAccelKey_Right )) { + break; //Allow SHIFT+CTRL for Move + } + if (((action>>8)&0xFF) == wAccelKey_LineFeed) { + action = C_TEXT+((int)(0x0A<<8)); break; - case C_INFO: - Reset(); + } + int rc = DoPanKeyAction(action); + if (rc!=1) { return; } + break; + case C_TEXT: + if ((action>>8) == 0x0D) { + action = C_OK; + } else if ((action>>8) == 0x1B) { + ConfirmReset( TRUE ); + return; + } + /*no break */ + case C_MODKEY: + case C_MOVE: + case C_UP: + case C_RMOVE: + case C_RUP: + case C_LDOUBLE: + case C_MUP: + InfoPos( pos ); + /*DrawTempTrack();*/ + break; + case C_WUP: + DoZoomUp(I2VP(1L)); + break; + case C_WDOWN: + DoZoomDown(I2VP(1L)); + break; + case C_SCROLLUP: + panCenter.y = panCenter.y + ((mainD.size.y/20>min.y)?mainD.size.y/20:min.y); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(1)); + break; + case C_SCROLLDOWN: + panCenter.y = panCenter.y - ((mainD.size.y/20>min.y)?mainD.size.y/20:min.y); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(1)); + break; + case C_SCROLLLEFT: + panCenter.x = panCenter.x - ((mainD.size.x/20>min.x)?mainD.size.x/20:min.x); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(1)); + break; + case C_SCROLLRIGHT: + panCenter.x = panCenter.x + ((mainD.size.x/20>min.x)?mainD.size.x/20:min.x); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); + PanHere(I2VP(1)); + break; + case C_MMOVE: + // Middle button pan + if ( !panActive ) { break; } + panCenter.x = panOrigin.x + (panStart.x - ( pos.x - mainD.orig.x ) ); + panCenter.y = panOrigin.y + (panStart.y - ( pos.y - mainD.orig.y ) ); + if ( panCenter.x < 0 ) { panCenter.x = 0; } + if ( panCenter.x > mapD.size.x ) { panCenter.x = mapD.size.x; } + if ( panCenter.y < 0 ) { panCenter.y = 0; } + if ( panCenter.y > mapD.size.y ) { panCenter.y = mapD.size.y; } + LOG( log_pan, 1, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, + panCenter.x, panCenter.y ) ); + PanHere(I2VP(1)); + break; + default: + NoticeMessage( MSG_DOMOUSE_BAD_OP, _("Ok"), NULL, action&0xFF ); + break; + } + if (delayUpdate) { + wDrawDelayUpdate( mainD.d, TRUE ); + } + rc = DoCurCommand( action, pos ); + wDrawDelayUpdate( mainD.d, FALSE ); + switch( rc ) { + case C_CONTINUE: + /*DrawTempTrack();*/ + break; + case C_ERROR: + ignoreCommands = TRUE; + inError = TRUE; + Reset(); + LOG( log_mouse, 1, ( "Mouse returns Error\n" ) ) + break; + case C_TERMINATE: + Reset(); + DoCurCommand( C_START, zero ); + break; + case C_INFO: + Reset(); + break; + } } wDrawPix_t autoPanFactor = 10; -static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, wDrawPix_t y ) +static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, + wDrawPix_t y ) { coOrd pos; coOrd orig; @@ -2761,8 +3065,9 @@ static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, DIST_T minDist; wDrawGetSize( mainD.d, &w, &h ); if ( autoPan && !inPlayback ) { - if ( action == wActionLDown || action == wActionRDown || - (action == wActionLDrag && mouseState == mouseLeftPending ) /*|| + if ( action == wActionLDown || action == wActionRDown + || action == wActionScrollDown || + (action == wActionLDrag && mouseState == mouseLeftPending ) /*|| (action == wActionRDrag && mouseState == mouseRightPending ) */ ) { lastX = x; lastY = y; @@ -2770,39 +3075,45 @@ static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, if ( action == wActionLDrag || action == wActionRDrag ) { orig = mainD.orig; if ( ( x < 10 && x < lastX ) || - ( x > w-10 && x > lastX ) || - ( y < 10 && y < lastY ) || - ( y > h-10 && y > lastY ) ) { + ( x > w-10 && x > lastX ) || + ( y < 10 && y < lastY ) || + ( y > h-10 && y > lastY ) ) { mainD.Pix2CoOrd( &mainD, x, y, &pos ); - orig.x = mainD.orig.x + (pos.x - (mainD.orig.x + mainD.size.x/2.0) )/autoPanFactor; - orig.y = mainD.orig.y + (pos.y - (mainD.orig.y + mainD.size.y/2.0) )/autoPanFactor; + orig.x = mainD.orig.x + (pos.x - (mainD.orig.x + + mainD.size.x/2.0) )/autoPanFactor; + orig.y = mainD.orig.y + (pos.y - (mainD.orig.y + + mainD.size.y/2.0) )/autoPanFactor; if ( orig.x != mainD.orig.x || orig.y != mainD.orig.y ) { if ( mainD.scale >= 1 ) { - if ( units == UNITS_ENGLISH ) + if ( units == UNITS_ENGLISH ) { minDist = 1.0; - else + } else { minDist = 1.0/2.54; + } if ( orig.x != mainD.orig.x ) { if ( fabs( orig.x-mainD.orig.x ) < minDist ) { - if ( orig.x < mainD.orig.x ) + if ( orig.x < mainD.orig.x ) { orig.x -= minDist; - else + } else { orig.x += minDist; + } } } if ( orig.y != mainD.orig.y ) { if ( fabs( orig.y-mainD.orig.y ) < minDist ) { - if ( orig.y < mainD.orig.y ) + if ( orig.y < mainD.orig.y ) { orig.y -= minDist; - else + } else { orig.y += minDist; + } } } } mainD.orig = orig; panCenter.x = mainD.orig.x + mainD.size.x/2.0; panCenter.y = mainD.orig.y + mainD.size.y/2.0; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); MainLayout( TRUE, TRUE ); // DoMouseW: autopan tempD.orig = mainD.orig; wFlush(); @@ -2822,6 +3133,7 @@ static void DoMousew( wDraw_p d, void * context, wAction_t action, wDrawPix_t x, case wActionRDrag: case wActionRUp: case wActionLDownDouble: + case wActionMDrag: mousePositionx = x; mousePositiony = y; break; @@ -2844,7 +3156,8 @@ static wBool_t PlaybackMain( char * line ) SetCLocale(); - rc=sscanf( line, "%d " SCANF_FLOAT_FORMAT SCANF_FLOAT_FORMAT, &action, &pos.x, &pos.y); + rc=sscanf( line, "%d " SCANF_FLOAT_FORMAT SCANF_FLOAT_FORMAT, &action, &pos.x, + &pos.y); SetUserLocale(); if (rc != 3) { @@ -2863,7 +3176,8 @@ static wBool_t PlaybackKey( char * line ) int c; SetCLocale(); - rc=sscanf( line, "%d " SCANF_FLOAT_FORMAT SCANF_FLOAT_FORMAT, &c, &pos.x, &pos.y ); + rc=sscanf( line, "%d " SCANF_FLOAT_FORMAT SCANF_FLOAT_FORMAT, &c, &pos.x, + &pos.y ); SetUserLocale(); if (rc != 3) { @@ -2881,92 +3195,108 @@ static wBool_t PlaybackKey( char * line ) * */ -static paramDrawData_t mapDrawData = { 100, 100, MapRedraw, DoMapPan, &mapD }; +static paramDrawData_t mapDrawData = { 50, 50, MapRedraw, DoMapPan, &mapD }; static paramData_t mapPLs[] = { - { PD_DRAW, NULL, "canvas", 0, &mapDrawData } }; + { PD_DRAW, NULL, "canvas", PDO_DLGRESIZE, &mapDrawData } +}; static paramGroup_t mapPG = { "map", PGO_NODEFAULTPROC, mapPLs, COUNT( mapPLs ) }; -static void MapDlgUpdate( - paramGroup_p pg, - int inx, - void * valueP ) -{ - wWinPix_t width,height; - switch(inx) { - case wResize_e: - if (mapD.d == NULL) - return; - wWinGetSize( mapW, &width, &height ); - if (height >= 100) { - wControlSetPos( (wControl_p)mapD.d, 0, 0 ); - double scaleX = (mapD.size.x/((width-DlgSepLeft-DlgSepRight-10)/mapD.dpi)); - double scaleY = (mapD.size.y/((height-DlgSepTop-DlgSepBottom-10)/mapD.dpi)); - double scale; - - if (scaleX<scaleY) scale = scaleX; - else scale = scaleY; - - if (scale > MAX_MAIN_SCALE) scale = MAX_MAIN_SCALE; - if (scale < MIN_MAIN_MACRO) scale = MIN_MAIN_MACRO; - - mapScale = (long)scale; - - mapD.scale = mapScale; - ChangeMapScale(FALSE); - - if (mapVisible) { - MapRedraw( mapD.d, NULL, 0, 0 ); - } - wPrefSetInteger( "draw", "mapscale", (long)mapD.scale ); - } - break; - case -1: - MapWindowShow( FALSE ); - break; - default: - break; - } -} - static void DrawChange( long changes ) { if (changes & CHANGE_MAIN) { MainLayout( TRUE, FALSE ); // DrawChange: CHANGE_MAIN } - if (changes &CHANGE_UNITS) + if (changes &CHANGE_UNITS) { SetInfoBar(); - if (changes & CHANGE_MAP) - MapResize(); + } + if (changes & CHANGE_MAP) { + LOG( log_mapsize, 2, ( "CHANGE_MAP: mapD.scale=%0.3f\n", mapD.scale ) ); + ChangeMapScale(); + } } static void MainLayoutCB( - wDraw_p bd, void * pContex, wWinPix_t px, wWinPix_t py ) + wDraw_p bd, void * pContex, wWinPix_t px, wWinPix_t py ) { MainLayout( TRUE, FALSE ); } +EXPORT void InitColor( void ) +{ + drawColorBlack = wDrawFindColor( wRGB( 0, 0, 0) ); + drawColorWhite = wDrawFindColor( wRGB(255,255,255) ); + drawColorRed = wDrawFindColor( wRGB(255, 0, 0) ); + drawColorBlue = wDrawFindColor( wRGB( 0, 0,255) ); + drawColorGreen = wDrawFindColor( wRGB( 0,255, 0) ); + drawColorAqua = wDrawFindColor( wRGB( 0,255,255) ); + drawColorDkRed = wDrawFindColor( wRGB(128, 0, 0) ); + drawColorDkBlue = wDrawFindColor( wRGB( 0, 0,128) ); + drawColorDkGreen= wDrawFindColor( wRGB( 0,128, 0) ); + drawColorDkAqua = wDrawFindColor( wRGB( 0,128,128) ); + + // Last component of spectial color must be > 3 + drawColorPreviewSelected = wDrawFindColor( wRGB ( 6, 6, 255) ); //Special Blue + drawColorPreviewUnselected = wDrawFindColor( wRGB( 255, 215, + 6)); //Special Yellow + + drawColorPowderedBlue = wDrawFindColor( wRGB(129, 212, 250) ); + drawColorPurple = wDrawFindColor( wRGB(128, 0,128) ); + drawColorMagenta = wDrawFindColor( wRGB(255, 0, 255) ); + drawColorGold = wDrawFindColor( wRGB(255,215, 0) ); + drawColorGrey10 = wDrawFindColor( wRGB(26,26,26) ); + drawColorGrey20 = wDrawFindColor( wRGB(51,51,51) ); + drawColorGrey30 = wDrawFindColor( wRGB(72,72,72) ); + drawColorGrey40 = wDrawFindColor( wRGB(102,102,102) ); + drawColorGrey50 = wDrawFindColor( wRGB(128,128,128) ); + drawColorGrey60 = wDrawFindColor( wRGB(153,153,153) ); + drawColorGrey70 = wDrawFindColor( wRGB(179,179,179) ); + drawColorGrey80 = wDrawFindColor( wRGB(204,204,204) ); + drawColorGrey90 = wDrawFindColor( wRGB(230,230,230) ); + snapGridColor = drawColorGreen; + markerColor = drawColorRed; + borderColor = drawColorBlack; + crossMajorColor = drawColorRed; + crossMinorColor = drawColorBlue; + selectedColor = drawColorRed; + normalColor = drawColorBlack; + elevColorIgnore = drawColorBlue; + elevColorDefined = drawColorGold; + profilePathColor = drawColorPurple; + exceptionColor = wDrawFindColor(wRGB(255, 89, 0 )); + tieColor = wDrawFindColor(wRGB(153, 89, 68)); +} + + EXPORT void DrawInit( int initialZoom ) { wWinPix_t w, h; + log_pan = LogFindIndex( "pan" ); + log_zoom = LogFindIndex( "zoom" ); + log_mouse = LogFindIndex( "mouse" ); + log_redraw = LogFindIndex( "redraw" ); + log_timemainredraw = LogFindIndex( "timemainredraw" ); + log_mapsize = LogFindIndex( "mapsize" ); +// InitColor(); wWinGetSize( mainW, &w, &h ); /*LayoutToolBar();*/ h = h - (toolbarHeight+max(textHeight,infoHeight)+10); - if ( w <= 0 ) w = 1; - if ( h <= 0 ) h = 1; - tempD.d = mainD.d = wDrawCreate( mainW, 0, toolbarHeight, "", BD_TICKS|BD_MODKEYS, - w, h, &mainD, - MainLayoutCB, DoMousew ); + if ( w <= 0 ) { w = 1; } + if ( h <= 0 ) { h = 1; } + tempD.d = mainD.d = wDrawCreate( mainW, 0, toolbarHeight, "", + BD_TICKS|BD_MODKEYS, + w, h, &mainD, + MainLayoutCB, DoMousew ); if (initialZoom == 0) { WDOUBLE_T tmpR; wPrefGetFloat( "draw", "zoom", &tmpR, mainD.scale ); mainD.scale = tmpR; - } else { + } else { while (initialZoom > 0 && mainD.scale < MAX_MAIN_SCALE) { mainD.scale *= 2; initialZoom--; @@ -2986,38 +3316,33 @@ EXPORT void DrawInit( int initialZoom ) SetMainSize(); panCenter.x = mainD.size.x/2 +mainD.orig.x; panCenter.y = mainD.size.y/2 +mainD.orig.y; - mapD.scale = mapScale; /*w = (wWinPix_t)((mapD.size.x/mapD.scale)*mainD.dpi + 0.5)+2;*/ /*h = (wWinPix_t)((mapD.size.y/mapD.scale)*mainD.dpi + 0.5)+2;*/ ParamRegister( &mapPG ); - mapW = ParamCreateDialog( &mapPG, MakeWindowTitle(_("Map")), NULL, NULL, NULL, FALSE, NULL, F_RESIZE, MapDlgUpdate ); - ChangeMapScale(TRUE); - - log_pan = LogFindIndex( "pan" ); - log_zoom = LogFindIndex( "zoom" ); - log_mouse = LogFindIndex( "mouse" ); - log_redraw = LogFindIndex( "redraw" ); - log_timemainredraw = LogFindIndex( "timemainredraw" ); + LOG( log_mapsize, 2, ( "DrawInit/ParamCreateDialog(&mapPG\n" ) ); + mapW = ParamCreateDialog( &mapPG, MakeWindowTitle(_("Map")), NULL, NULL, NULL, + FALSE, NULL, F_RESIZE, NULL ); + ChangeMapScale(); AddPlaybackProc( "MOUSE ", (playbackProc_p)PlaybackMain, NULL ); AddPlaybackProc( "KEY ", (playbackProc_p)PlaybackKey, NULL ); rulerFp = wStandardFont( F_HELV, FALSE, FALSE ); - SetZoomRadio( mainD.scale ); + SetZoomRadio( mainD.scale ); InfoScale(); SetInfoBar(); InfoPos( zero ); RegisterChangeNotification( DrawChange ); } -#include "bitmaps/pan-zoom.xpm" +#include "bitmaps/pan-zoom.xpm3" -EXPORT static wMenu_p panPopupM; +static wMenu_p panPopupM; static STATUS_T CmdPan( - wAction_t action, - coOrd pos ) + wAction_t action, + coOrd pos ) { static enum { PAN, ZOOM, NONE } panmode; @@ -3035,10 +3360,11 @@ static STATUS_T CmdPan( switch (action&0xFF) { case C_START: start_pos = zero; - panmode = NONE; - InfoMessage(_("Left-Drag to pan, Ctrl+Left-Drag to zoom, 0 to set origin to zero, 1-9 to zoom#, e to set to extents")); - wSetCursor(mainD.d,wCursorSizeAll); - break; + panmode = NONE; + InfoMessage( + _("Left-Drag to pan, Ctrl+Left-Drag to zoom, 0 to set origin to zero, 1-9 to zoom#, e to set to extents")); + wSetCursor(mainD.d,wCursorSizeAll); + break; case C_DOWN: if ((MyGetKeyState()&WKEY_CTRL) == 0) { panmode = PAN; @@ -3055,33 +3381,36 @@ static STATUS_T CmdPan( break; case C_MOVE: if (panmode == PAN) { - double min_inc; - if (mainD.scale >= 1.0) { - if (units == UNITS_ENGLISH) { - min_inc = 1/4; //>1:1 = 1/4 inch - } else { - min_inc = 1/(2.54*2); //>1:1 = 0.5 cm - } + double min_inc; + if (mainD.scale >= 1.0) { + if (units == UNITS_ENGLISH) { + min_inc = 1.0/4.0; //>1:1 = 1/4 inch } else { - if (units == UNITS_ENGLISH) { - min_inc = 1/64; //<1:1 = 1/64 inch - } else { - min_inc = 1/(25.4*2); //>1:1 = 0.5 mm - } + min_inc = 1.0/(2.54*2); //>1:1 = 0.5 cm } - if ((fabs(pos.x-start_pos.x) > min_inc) || (fabs(pos.y-start_pos.y) > min_inc)) { - coOrd oldOrig = mainD.orig; - mainD.orig.x -= (pos.x - start_pos.x); - mainD.orig.y -= (pos.y - start_pos.y); - if ((MyGetKeyState()&WKEY_SHIFT) != 0) - ConstraintOrig(&mainD.orig,mainD.size,TRUE,TRUE); - if ((oldOrig.x == mainD.orig.x) && (oldOrig.y == mainD.orig.y)) - InfoMessage(_("Can't move any further in that direction")); - else - InfoMessage(_("Left click to pan, right click to zoom, 'o' for origin, 'e' for extents")); + } else { + if (units == UNITS_ENGLISH) { + min_inc = 1.0/64.0; //<1:1 = 1/64 inch + } else { + min_inc = 1.0/(25.4*2); //>1:1 = 0.5 mm } } - else if (panmode == ZOOM) { + if ((fabs(pos.x-start_pos.x) > min_inc) + || (fabs(pos.y-start_pos.y) > min_inc)) { + coOrd oldOrig = mainD.orig; + mainD.orig.x -= (pos.x - start_pos.x); + mainD.orig.y -= (pos.y - start_pos.y); + if ((MyGetKeyState()&WKEY_SHIFT) != 0) { + ConstraintOrig(&mainD.orig,mainD.size,TRUE,TRUE); + } + if ((oldOrig.x == mainD.orig.x) && (oldOrig.y == mainD.orig.y)) { + InfoMessage(_("Can't move any further in that direction")); + } else { + InfoMessage( + _("Left click to pan, right click to zoom, 'o' for origin, 'e' for extents")); + } + } + } else if (panmode == ZOOM) { base = start_pos; size.x = pos.x - base.x; if (size.x < 0) { @@ -3103,32 +3432,36 @@ static STATUS_T CmdPan( scale_x = size.x/mainD.size.x*mainD.scale; scale_y = size.y/mainD.size.y*mainD.scale; - if (scale_x<scale_y) - scale_x = scale_y; - if (scale_x>1) scale_x = ceil( scale_x ); - else scale_x = 1/(ceil(1/scale_x)); + if (scale_x<scale_y) { + scale_x = scale_y; + } + if (scale_x>1) { scale_x = ceil( scale_x ); } + else { scale_x = 1/(ceil(1/scale_x)); } - if (scale_x > MAX_MAIN_SCALE) scale_x = MAX_MAIN_SCALE; - if (scale_x < MIN_MAIN_MACRO) scale_x = MIN_MAIN_MACRO; + if (scale_x > MAX_MAIN_SCALE) { scale_x = MAX_MAIN_SCALE; } + if (scale_x < MIN_MAIN_MACRO) { scale_x = MIN_MAIN_MACRO; } mainD.orig.x = base.x; mainD.orig.y = base.y; panmode = NONE; - InfoMessage(_("Left Drag to Pan, +CTRL to Zoom, 0 to set Origin to 0,0, 1-9 to Zoom#, e to set to Extent")); + InfoMessage( + _("Left Drag to Pan, +CTRL to Zoom, 0 to set Origin to 0,0, 1-9 to Zoom#, e to set to Extent")); DoNewScale(scale_x); break; } else if (panmode == PAN) { panCenter.x = mainD.orig.x + mainD.size.x/2.0; panCenter.y = mainD.orig.y + mainD.size.y/2.0; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); panmode = NONE; } break; case C_REDRAW: if (panmode == ZOOM) { - if (base.x && base.y && size.x && size.y) + if (base.x && base.y && size.x && size.y) { DrawHilight( &tempD, base, size, TRUE ); + } } break; case C_CANCEL: @@ -3146,14 +3479,16 @@ static STATUS_T CmdPan( mainD.orig = zero; panCenter.x = mainD.size.x/2.0; panCenter.y = mainD.size.y/2.0; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); MainLayout( TRUE, TRUE ); // CmdPan C_TEXT '0' 'o' } else if ((action>>8) >= '1' && (action>>8) <= '9') { //"1" to "9" scale_x = (action>>8)&0x0F; DoNewScale(scale_x); } else if ((action>>8) == 'c') { // "c" panCenter = pos; - LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, panCenter.y ) ); + LOG( log_pan, 2, ( "PanCenter:%d %0.3f %0.3f\n", __LINE__, panCenter.x, + panCenter.y ) ); PanHere( I2VP(0)); // CmdPan C_TEXT 'c' } @@ -3175,7 +3510,8 @@ static STATUS_T CmdPan( return C_CONTINUE; } static wMenuPush_p zoomExtents,panOrig,panHere; -static wMenuPush_p zoomLvl1,zoomLvl2,zoomLvl3,zoomLvl4,zoomLvl5,zoomLvl6,zoomLvl7,zoomLvl8,zoomLvl9; +static wMenuPush_p zoomLvl1,zoomLvl2,zoomLvl3,zoomLvl4,zoomLvl5,zoomLvl6, + zoomLvl7,zoomLvl8,zoomLvl9; EXPORT void PanMenuEnter( void * keyVP ) { @@ -3186,35 +3522,47 @@ EXPORT void PanMenuEnter( void * keyVP ) CmdPan(action,zero); } -extern wIndex_t selectCmdInx; -extern wIndex_t describeCmdInx; -extern wIndex_t joinCmdInx; -extern wIndex_t modifyCmdInx; EXPORT void InitCmdPan( wMenu_p menu ) { - panCmdInx = AddMenuButton( menu, CmdPan, "cmdPan", _("Pan/Zoom"), wIconCreatePixMap(pan_zoom_xpm[iconSize]), - LEVEL0, IC_CANCEL|IC_POPUP|IC_LCLICK|IC_CMDMENU, ACCL_PAN, NULL ); + panCmdInx = AddMenuButton( menu, CmdPan, "cmdPan", _("Pan/Zoom"), + wIconCreatePixMap(pan_zoom_xpm3[iconSize]), + LEVEL0, IC_CANCEL|IC_POPUP|IC_LCLICK|IC_CMDMENU, ACCL_PAN, NULL ); } EXPORT void InitCmdPan2( wMenu_p menu ) { panPopupM = MenuRegister( "Pan Options" ); - wMenuPushCreate(panPopupM, "cmdSelectMode", GetBalloonHelpStr("cmdSelectMode"), 0, DoCommandB, I2VP(selectCmdInx)); - wMenuPushCreate(panPopupM, "cmdDescribeMode", GetBalloonHelpStr("cmdDescribeMode"), 0, DoCommandB, I2VP(describeCmdInx)); - wMenuPushCreate(panPopupM, "cmdModifyMode", GetBalloonHelpStr("cmdModifyMode"), 0, DoCommandB, I2VP(modifyCmdInx)); + wMenuPushCreate(panPopupM, "cmdSelectMode", GetBalloonHelpStr("cmdSelectMode"), + 0, DoCommandB, I2VP(selectCmdInx)); + wMenuPushCreate(panPopupM, "cmdDescribeMode", + GetBalloonHelpStr("cmdDescribeMode"), 0, DoCommandB, I2VP(describeCmdInx)); + wMenuPushCreate(panPopupM, "cmdModifyMode", GetBalloonHelpStr("cmdModifyMode"), + 0, DoCommandB, I2VP(modifyCmdInx)); wMenuSeparatorCreate(panPopupM); - zoomExtents = wMenuPushCreate( panPopupM, "", _("Zoom to extents - 'e'"), 0, PanMenuEnter, I2VP( 'e')); - zoomLvl1 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:1 - '1'"), 0, PanMenuEnter, I2VP( '1')); - zoomLvl2 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:2 - '2'"), 0, PanMenuEnter, I2VP( '2')); - zoomLvl3 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:3 - '3'"), 0, PanMenuEnter, I2VP( '3')); - zoomLvl4 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:4 - '4'"), 0, PanMenuEnter, I2VP( '4')); - zoomLvl5 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:5 - '5'"), 0, PanMenuEnter, I2VP( '5')); - zoomLvl6 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:6 - '6'"), 0, PanMenuEnter, I2VP( '6')); - zoomLvl7 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:7 - '7'"), 0, PanMenuEnter, I2VP( '7')); - zoomLvl8 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:8 - '8'"), 0, PanMenuEnter, I2VP( '8')); - zoomLvl9 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:9 - '9'"), 0, PanMenuEnter, I2VP( '9')); - panOrig = wMenuPushCreate( panPopupM, "", _("Pan to Origin - 'o'/'0'"), 0, PanMenuEnter, I2VP( 'o')); + zoomExtents = wMenuPushCreate( panPopupM, "", _("Zoom to extents - 'e'"), 0, + PanMenuEnter, I2VP( 'e')); + zoomLvl1 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:1 - '1'"), 0, + PanMenuEnter, I2VP( '1')); + zoomLvl2 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:2 - '2'"), 0, + PanMenuEnter, I2VP( '2')); + zoomLvl3 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:3 - '3'"), 0, + PanMenuEnter, I2VP( '3')); + zoomLvl4 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:4 - '4'"), 0, + PanMenuEnter, I2VP( '4')); + zoomLvl5 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:5 - '5'"), 0, + PanMenuEnter, I2VP( '5')); + zoomLvl6 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:6 - '6'"), 0, + PanMenuEnter, I2VP( '6')); + zoomLvl7 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:7 - '7'"), 0, + PanMenuEnter, I2VP( '7')); + zoomLvl8 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:8 - '8'"), 0, + PanMenuEnter, I2VP( '8')); + zoomLvl9 = wMenuPushCreate( panPopupM, "", _("Zoom to 1:9 - '9'"), 0, + PanMenuEnter, I2VP( '9')); + panOrig = wMenuPushCreate( panPopupM, "", _("Pan to Origin - 'o'/'0'"), 0, + PanMenuEnter, I2VP( 'o')); wMenu_p zoomPanM = wMenuMenuCreate(panPopupM, "", _("&Zoom")); InitCmdZoom(NULL, NULL, NULL, zoomPanM); - panHere = wMenuPushCreate( panPopupM, "", _("Pan center here - 'c'"), 0, PanHere, I2VP( 3)); + panHere = wMenuPushCreate( panPopupM, "", _("Pan center here - 'c'"), 0, + PanHere, I2VP( 3)); } |