Ticket #65: printLRUD.patch

File printLRUD.patch, 5.1 KB (added by Olly Betts, 8 years ago)

patch

  • src/printing.cc

    diff -ur survex-1.2.21/src/printing.cc survex-1.2.21-printLRUD/src/printing.cc
    old new  
    19921992        Double l = pt_v.GetL();
    19931993        Double r = pt_v.GetR();
    19941994
    1995         if (l >= 0) {
    1996             Vector3 p = pt_v - right * l;
    1997             double X = p.GetX() * COS - p.GetY() * SIN;
    1998             double Y = (p.GetX() * SIN + p.GetY() * COS);
    1999             long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX);
    2000             long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY);
    2001             MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
    2002             DrawTo(x, y);
    2003             DrawTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
    2004         }
    2005         if (r >= 0) {
    2006             Vector3 p = pt_v + right * r;
    2007             double X = p.GetX() * COS - p.GetY() * SIN;
    2008             double Y = (p.GetX() * SIN + p.GetY() * COS);
    2009             long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX);
    2010             long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY);
    2011             MoveTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
    2012             DrawTo(x, y);
    2013             DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
     1995        if (l >= 0 || r >= 0) {
     1996
     1997                // Get the x and y coordinates of the survey station
     1998                double pt_X = pt_v.GetX() * COS - pt_v.GetY() * SIN;
     1999                double pt_Y = pt_v.GetX() * SIN + pt_v.GetY() * COS;
     2000                long pt_x = (long)((pt_X * Sc + m_layout->xOrg) * m_layout->scX);
     2001                long pt_y = (long)((pt_Y * Sc + m_layout->yOrg) * m_layout->scY);
     2002
     2003                // Calculate dimensions for the right arrow
     2004                double COSR = right.GetX();
     2005                double SINR = right.GetY();
     2006                long CROSS_MAJOR = (COSR + SINR) * PWX_CROSS_SIZE;
     2007                long CROSS_MINOR = (COSR - SINR) * PWX_CROSS_SIZE;
     2008
     2009                // Set fraction for arrow stem
     2010                double frac = 0.5;
     2011
     2012                if (l >= 0) {
     2013
     2014                        // Get the x and y coordinates of the end of the left arrow
     2015                    Vector3 p = pt_v - right * l;
     2016                    double X = p.GetX() * COS - p.GetY() * SIN;
     2017                    double Y = (p.GetX() * SIN + p.GetY() * COS);
     2018                    long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX);
     2019                    long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY);
     2020       
     2021                        // Draw the arrow stem from partway
     2022                        MoveTo(frac*x + (1-frac)*pt_x, frac*y + (1-frac)*pt_y);
     2023                        DrawTo(x, y);
     2024       
     2025                        // Rotate the arrow by the page rotation
     2026                        long dx1 = (+CROSS_MINOR) * COS - (+CROSS_MAJOR) * SIN;
     2027                        long dy1 = (+CROSS_MINOR) * SIN + (+CROSS_MAJOR) * COS;
     2028                        long dx2 = (+CROSS_MAJOR) * COS - (-CROSS_MINOR) * SIN;
     2029                        long dy2 = (+CROSS_MAJOR) * SIN + (-CROSS_MINOR) * COS;
     2030
     2031                        // Draw the arrow
     2032                        MoveTo(x + dx1, y + dy1);
     2033                        DrawTo(x , y);
     2034                        DrawTo(x + dx2, y + dy2);
     2035                }
     2036
     2037                if (r >= 0) {
     2038
     2039                        // Get the x and y coordinates of the end of the right arrow
     2040                    Vector3 p = pt_v + right * r;
     2041                    double X = p.GetX() * COS - p.GetY() * SIN;
     2042                    double Y = (p.GetX() * SIN + p.GetY() * COS);
     2043                    long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX);
     2044                    long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY);
     2045       
     2046                        // Draw the arrow stem from partway
     2047                        MoveTo(frac*x + (1-frac)*pt_x, frac*y + (1-frac)*pt_y);
     2048                        DrawTo(x, y);
     2049       
     2050                        // Rotate the arrow by the page rotation
     2051                        long dx1 = (-CROSS_MINOR) * COS - (-CROSS_MAJOR) * SIN;
     2052                        long dy1 = (-CROSS_MINOR) * SIN + (-CROSS_MAJOR) * COS;
     2053                        long dx2 = (-CROSS_MAJOR) * COS - (+CROSS_MINOR) * SIN;
     2054                        long dy2 = (-CROSS_MAJOR) * SIN + (+CROSS_MINOR) * COS;
     2055       
     2056                        // Draw the arrow
     2057                        MoveTo(x + dx1, y + dy1);
     2058                        DrawTo(x , y);
     2059                        DrawTo(x + dx2, y + dy2);
     2060                }
     2061
    20142062        }
    20152063
    20162064        prev_pt_v = pt_v;
     
    20342082        Double d = pt_v.GetD();
    20352083
    20362084        if (u >= 0 || d >= 0) {
     2085               
     2086                // Get the coordinates of the survey point
    20372087            Vector3 p = pt_v;
    20382088            double SIN = sin(rad(m_layout->rot));
    20392089            double COS = cos(rad(m_layout->rot));
    20402090            double X = p.GetX() * COS - p.GetY() * SIN;
    20412091            double Y = p.GetZ();
    20422092            long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX);
     2093                long pt_y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scX);
     2094
     2095                // Set fraction for arrow stem
     2096                double frac = 0.5;
     2097
    20432098            if (u >= 0) {
    2044                 long y = (long)(((Y + u) * Sc + m_layout->yOrg) * m_layout->scY);
    2045                 MoveTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
    2046                 DrawTo(x, y);
    2047                 DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
     2099
     2100                        // Get the y coordinate of the up arrow
     2101                        long y = (long)(((Y + u) * Sc + m_layout->yOrg) * m_layout->scY);
     2102
     2103                        // Draw the arrow stem from partway
     2104                        MoveTo(x, frac*y + (1-frac)*pt_y);
     2105                        DrawTo(x, y);
     2106
     2107                        // Draw the up arrow
     2108                        MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
     2109                        DrawTo(x, y);
     2110                        DrawTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
    20482111            }
     2112
    20492113            if (d >= 0) {
    2050                 long y = (long)(((Y - d) * Sc + m_layout->yOrg) * m_layout->scY);
    2051                 MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
    2052                 DrawTo(x, y);
    2053                 DrawTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
     2114
     2115                        // Get the y coordinate of the down arrow
     2116                        long y = (long)(((Y - d) * Sc + m_layout->yOrg) * m_layout->scY);
     2117
     2118                        // Draw the arrow stem from partway
     2119                        MoveTo(x, frac*y + (1-frac)*pt_y);
     2120                        DrawTo(x, y);
     2121
     2122                        // Draw the down arrow
     2123                        MoveTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
     2124                        DrawTo(x, y);
     2125                        DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
    20542126            }
     2127
    20552128        }
     2129
    20562130    }
    20572131}