Changeset 4a66219 in git


Ignore:
Timestamp:
05/03/15 03:23:05 (5 years ago)
Author:
Olly Betts <olly@…>
Branches:
line_contents, master, stereo, travis-osx
Children:
0edddb4
Parents:
31f1db0
Message:

src/avenprcore.h,src/printwx.cc,src/printwx.h: Don't round bearing
and tilt angles to integers when printing and exporting.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r31f1db0 r4a66219  
     1Thu Mar 05 03:21:45 GMT 2015  Olly Betts <olly@survex.com>
     2
     3        * src/avenprcore.h,src/printwx.cc,src/printwx.h: Don't round bearing
     4          and tilt angles to integers when printing and exporting.
     5
    16Thu Mar 05 02:19:25 GMT 2015  Olly Betts <olly@survex.com>
    27
  • src/avenprcore.h

    r31f1db0 r4a66219  
    11/* avenprcore.h
    22 * Header file for printer independent parts of Survex printer drivers
    3  * Copyright (C) 1994-2002,2004,2005,2012,2013,2014 Olly Betts
     3 * Copyright (C) 1994-2002,2004,2005,2012,2013,2014,2015 Olly Betts
    44 * Copyright (C) 2004 Philip Underwood
    55 *
     
    6262    time_t datestamp_numeric;
    6363    double Scale;
    64     int rot, tilt;
     64    double rot, tilt;
    6565    enum {PLAN, ELEV, TILT, EXTELEV} view;
    6666
  • src/printwx.cc

    r31f1db0 r4a66219  
    5656
    5757using namespace std;
     58
     59// How many decimal points to show on angles:
     60#define ANGLE_DP 1
     61
     62#if ANGLE_DP == 0
     63# define ANGLE_FMT wxT("%03.f")
     64# define ANGLE2_FMT wxT("%.f")
     65#elif ANGLE_DP == 1
     66# define ANGLE_FMT wxT("%05.1f")
     67# define ANGLE2_FMT wxT("%.1f")
     68#elif ANGLE_DP == 2
     69# define ANGLE_FMT wxT("%06.2f")
     70# define ANGLE2_FMT wxT("%.2f")
     71#else
     72# error Need to add ANGLE_FMT and ANGLE2_FMT for the currently set ANGLE_DP
     73#endif
     74
     75static wxString
     76format_angle(const wxChar * fmt, double angle)
     77{
     78    wxString s;
     79    s.Printf(fmt, angle);
     80    size_t dot = s.find('.');
     81    size_t i = s.size();
     82    while (i > dot) {
     83        --i;
     84        if (s[i] != '0') {
     85            if (i != dot) ++i;
     86            s.resize(i);
     87            break;
     88        }
     89    }
     90    s += wmsg(/*°*/344);
     91    return s;
     92}
    5893
    5994enum {
     
    339374    m_layout.datestamp = datestamp;
    340375    m_layout.datestamp_numeric = datestamp_numeric;
    341     m_layout.rot = int(angle);
     376    m_layout.rot = angle;
    342377    m_layout.title = title;
    343378    m_layout.cs_proj = cs_proj;
    344379    if (mainfrm->IsExtendedElevation()) {
    345380        m_layout.view = layout::EXTELEV;
    346         if (m_layout.rot != 0 && m_layout.rot != 180) m_layout.rot = 0;
     381        if (m_layout.rot != 0.0 && m_layout.rot != 180.0) m_layout.rot = 0;
    347382        m_layout.tilt = 0;
    348383    } else {
    349         // FIXME rot and tilt shouldn't be integers.
    350         m_layout.tilt = int(tilt_angle);
    351         if (m_layout.tilt == -90) {
     384        m_layout.tilt = tilt_angle;
     385        if (m_layout.tilt == -90.0) {
    352386            m_layout.view = layout::PLAN;
    353         } else if (m_layout.tilt == 0) {
     387        } else if (m_layout.tilt == 0.0) {
    354388            m_layout.view = layout::ELEV;
    355389        } else {
     
    439473        brg_label = new wxStaticText(this, -1, wmsg(/*Bearing*/259));
    440474        anglebox->Add(brg_label, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5);
    441         m_bearing = new wxSpinCtrl(this, svx_BEARING);
    442         m_bearing->SetRange(0, 359);
     475        m_bearing = new wxSpinCtrlDouble(this, svx_BEARING);
     476        m_bearing->SetRange(0.0, 360.0);
     477        m_bearing->SetDigits(ANGLE_DP);
    443478        anglebox->Add(m_bearing, 0, wxALIGN_CENTER|wxALL, 5);
    444479        /* TRANSLATORS: Used in the print dialog: */
    445480        tilt_label = new wxStaticText(this, -1, wmsg(/*Tilt angle*/263));
    446481        anglebox->Add(tilt_label, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5);
    447         m_tilt = new wxSpinCtrl(this, svx_TILT);
    448         m_tilt->SetRange(-90, 90);
     482        m_tilt = new wxSpinCtrlDouble(this, svx_TILT);
     483        m_tilt->SetRange(-90.0, 90.0);
     484        m_tilt->SetDigits(ANGLE_DP);
    449485        anglebox->Add(m_tilt, 0, wxALIGN_CENTER|wxALL, 5);
    450486
     
    708744void
    709745svxPrintDlg::OnPlan(wxCommandEvent&) {
    710     m_tilt->SetValue(-90);
     746    m_tilt->SetValue(-90.0);
    711747    SomethingChanged(svx_TILT);
    712748}
     
    714750void
    715751svxPrintDlg::OnElevation(wxCommandEvent&) {
    716     m_tilt->SetValue(0);
     752    m_tilt->SetValue(0.0);
    717753    SomethingChanged(svx_TILT);
    718754}
     
    720756void
    721757svxPrintDlg::OnPlanUpdate(wxUpdateUIEvent& e) {
    722     e.Enable(m_tilt->GetValue() != -90);
     758    e.Enable(m_tilt->GetValue() != -90.0);
    723759}
    724760
    725761void
    726762svxPrintDlg::OnElevationUpdate(wxUpdateUIEvent& e) {
    727     e.Enable(m_tilt->GetValue() != 0);
     763    e.Enable(m_tilt->GetValue() != 0.0);
    728764}
    729765
     
    830866    if (m_layout.view != layout::EXTELEV && m_tilt) {
    831867        m_layout.tilt = m_tilt->GetValue();
    832         if (m_layout.tilt == -90) {
     868        if (m_layout.tilt == -90.0) {
    833869            m_layout.view = layout::PLAN;
    834         } else if (m_layout.tilt == 0) {
     870        } else if (m_layout.tilt == 0.0) {
    835871            m_layout.view = layout::ELEV;
    836872        } else {
     
    9971033      WriteString(wmsg(/*North*/115));
    9981034
    999       wxString angle;
    1000       angle.Printf(wxT("%03d"), l->rot);
    1001       angle += wmsg(/*°*/344);
     1035      wxString angle = format_angle(ANGLE_FMT, l->rot);
    10021036      wxString s;
    10031037      /* TRANSLATORS: This is used on printouts of plans, with %s replaced by
     
    10251059     
    10261060      MOVEMM(L, 2);
    1027       WriteString(wxString::Format(wxT("%03d%s"),
    1028                                    (l->rot + 270) % 360,
    1029                                    wmsg(/*°*/344).c_str()));
     1061      WriteString(format_angle(ANGLE_FMT, fmod(l->rot + 270.0, 360.0)));
    10301062      MOVEMM(R - 10, 2);
    1031       WriteString(wxString::Format(wxT("%03d%s"),
    1032                                    (l->rot + 90) % 360,
    1033                                    wmsg(/*°*/344).c_str()));
    1034 
    1035       wxString angle;
    1036       angle.Printf(wxT("%03d"), l->rot);
    1037       angle += wmsg(/*°*/344);
     1063      WriteString(format_angle(ANGLE_FMT, fmod(l->rot + 90.0, 360.0)));
     1064
     1065      wxString angle = format_angle(ANGLE_FMT, l->rot);
    10381066      wxString s;
    10391067      if (l->view == layout::ELEV) {
     
    10431071          s.Printf(wmsg(/*Elevation facing %s*/169), angle.c_str());
    10441072      } else {
    1045           wxString a2;
    1046           a2.Printf(wxT("%d"), l->tilt);
    1047           a2 += wmsg(/*°*/344);
     1073          wxString a2 = format_angle(ANGLE2_FMT, l->tilt);
    10481074          /* TRANSLATORS: This is used on printouts of tilted elevations, with
    10491075           * the first %s replaced by something like "123°", and the second by
  • src/printwx.h

    r31f1db0 r4a66219  
    22/* Device dependent part of Survex wxWidgets driver */
    33/* Copyright (C) 2004 Philip Underwood
    4  * Copyright (C) 2004,2005,2006,2011,2012,2013,2014 Olly Betts
     4 * Copyright (C) 2004,2005,2006,2011,2012,2013,2014,2015 Olly Betts
    55 *
    66 * This program is free software; you can redistribute it and/or modify
     
    3737class wxComboBox;
    3838class wxStaticText;
    39 class wxSpinCtrl;
     39class wxSpinCtrlDouble;
    4040class wxSpinEvent;
    4141
     
    4848        wxChoice* m_format;
    4949        wxStaticText* m_printSize;
    50         wxSpinCtrl* m_bearing;
    51         wxSpinCtrl* m_tilt;
     50        wxSpinCtrlDouble* m_bearing;
     51        wxSpinCtrlDouble* m_tilt;
    5252//      wxCheckBox* m_blanks;
    5353        wxString m_File;
Note: See TracChangeset for help on using the changeset viewer.