~ojwb/survex/master

« back to all changes in this revision

Viewing changes to src/printwx.cc

  • Committer: Olly Betts
  • Date: 2010-06-18 07:16:42 UTC
  • mfrom: (2003.1.853)
  • Revision ID: git-v1:75fe355c16c77b1090c4426a3dc0b8dabca31904
Rename branches/survex-1_1 to trunk.

git-svn-id: file:///home/survex-svn/survex/trunk@3454 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* printwx.c */
2
 
/* Device dependent part of Survex wxWindows driver */
3
 
/* Copyright (C) 1993-2003,2004,2005 Olly Betts
 
1
/* printwx.cc */
 
2
/* wxWidgets specific parts of Survex wxWidgets printing code */
 
3
/* Copyright (C) 1993-2003,2004,2005,2006 Olly Betts
4
4
 * Copyright (C) 2001,2004 Philip Underwood
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
15
15
 *
16
16
 * You should have received a copy of the GNU General Public License
17
17
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
19
19
 */
20
20
 
21
21
#ifdef HAVE_CONFIG_H
22
22
# include <config.h>
23
23
#endif
24
24
 
 
25
#include <vector>
 
26
 
 
27
using namespace std;
 
28
 
25
29
#include <stdio.h>
26
30
#include <stdlib.h>
27
31
#include <math.h>
30
34
#include <ctype.h>
31
35
#include <float.h>
32
36
#include <limits.h>
 
37
#include <wx/filename.h>
33
38
#include <wx/print.h>
34
39
#include <wx/printdlg.h>
35
40
#include <wx/spinctrl.h>
37
42
#include <wx/statbox.h>
38
43
 
39
44
#include "debug.h" /* for BUG and SVX_ASSERT */
 
45
#include "export.h"
40
46
#include "filelist.h"
41
47
#include "filename.h"
42
48
#include "ini.h"
48
54
#include "mainfrm.h"
49
55
#include "printwx.h"
50
56
 
 
57
enum {
 
58
        svx_PRINT = 1200,
 
59
        svx_EXPORT,
 
60
        svx_PREVIEW,
 
61
        svx_SCALE,
 
62
        svx_BEARING,
 
63
        svx_TILT,
 
64
        svx_LEGS,
 
65
        svx_STATIONS,
 
66
        svx_NAMES,
 
67
        svx_BORDERS,
 
68
        svx_BLANKS,
 
69
        svx_INFOBOX,
 
70
        svx_SURFACE,
 
71
        svx_PLAN,
 
72
        svx_ELEV
 
73
};
 
74
 
51
75
class svxPrintout : public wxPrintout {
52
76
    MainFrm *mainfrm;
53
77
    layout *m_layout;
81
105
    void DrawCross(long x, long y);
82
106
    void SetFont(int fontcode);
83
107
    void SetColour(int colourcode);
84
 
    void WriteString(const char *s);
 
108
    void WriteString(const wxString & s);
85
109
    void DrawEllipse(long x, long y, long r, long R);
86
110
    void SolidRectangle(long x, long y, long w, long h);
87
111
    int Charset(void);
88
112
    int Pre();
89
113
    void NewPage(int pg, int pagesX, int pagesY);
90
114
    void ShowPage(const char *szPageDetails);
 
115
    void PlotLR(const vector<XSect> & centreline);
 
116
    void PlotUD(const vector<XSect> & centreline);
91
117
    char * Init(FILE **fh_list, bool fCalibrate);
92
118
  public:
93
119
    svxPrintout(MainFrm *mainfrm, layout *l, wxPageSetupDialogData *data, const wxString & title);
106
132
    EVT_SPINCTRL(svx_BEARING, svxPrintDlg::OnChangeSpin)
107
133
    EVT_SPINCTRL(svx_TILT, svxPrintDlg::OnChangeSpin)
108
134
    EVT_BUTTON(svx_PRINT, svxPrintDlg::OnPrint)
 
135
    EVT_BUTTON(svx_EXPORT, svxPrintDlg::OnExport)
109
136
    EVT_BUTTON(svx_PREVIEW, svxPrintDlg::OnPreview)
110
137
    EVT_BUTTON(svx_PLAN, svxPrintDlg::OnPlan)
111
138
    EVT_BUTTON(svx_ELEV, svxPrintDlg::OnElevation)
 
139
    EVT_CHECKBOX(svx_LEGS, svxPrintDlg::OnChange)
 
140
    EVT_CHECKBOX(svx_STATIONS, svxPrintDlg::OnChange)
 
141
    EVT_CHECKBOX(svx_NAMES, svxPrintDlg::OnChange)
 
142
    EVT_CHECKBOX(svx_SURFACE, svxPrintDlg::OnChange)
112
143
END_EVENT_TABLE()
113
144
 
114
145
static wxString scales[] = {
115
 
    "",
116
 
    "25",
117
 
    "50",
118
 
    "100",
119
 
    "250",
120
 
    "500",
121
 
    "1000",
122
 
    "2500",
123
 
    "5000",
124
 
    "10000",
125
 
    "25000",
126
 
    "50000",
127
 
    "100000"
 
146
    wxT(""),
 
147
    wxT("25"),
 
148
    wxT("50"),
 
149
    wxT("100"),
 
150
    wxT("250"),
 
151
    wxT("500"),
 
152
    wxT("1000"),
 
153
    wxT("2500"),
 
154
    wxT("5000"),
 
155
    wxT("10000"),
 
156
    wxT("25000"),
 
157
    wxT("50000"),
 
158
    wxT("100000")
128
159
};
129
160
 
130
161
// there are three jobs to do here...
132
163
svxPrintDlg::svxPrintDlg(MainFrm* mainfrm_, const wxString & filename,
133
164
                         const wxString & title, const wxString & datestamp,
134
165
                         double angle, double tilt_angle,
135
 
                         bool labels, bool crosses, bool legs, bool surf)
136
 
        : wxDialog(mainfrm_, -1, wxString(msg(/*Print*/399))),
 
166
                         bool labels, bool crosses, bool legs, bool surf,
 
167
                         bool printing)
 
168
        : wxDialog(mainfrm_, -1, wxString(printing ? wmsg(/*Print*/399) : wmsg(/*Export*/383))),
137
169
          m_layout(wxGetApp().GetPageSetupDialogData()),
138
170
          m_File(filename), mainfrm(mainfrm_)
139
171
{
 
172
    m_scale = NULL;
 
173
    m_printSize = NULL;
 
174
    m_tilttext = NULL;
 
175
    m_bearing = NULL;
 
176
    m_tilt = NULL;
 
177
    m_legs = NULL;
 
178
    m_stations = NULL;
 
179
    m_names = NULL;
 
180
    m_borders = NULL;
 
181
    m_infoBox = NULL;
 
182
    m_surface = NULL;
140
183
    m_layout.Labels = labels;
141
184
    m_layout.Crosses = crosses;
142
185
    m_layout.Shots = legs;
143
186
    m_layout.Surface = surf;
144
 
    m_layout.datestamp = osstrdup(datestamp.c_str());
 
187
    m_layout.datestamp = datestamp;
145
188
    m_layout.rot = int(angle + .001);
146
 
    if (title.length() > 11 &&
147
 
        title.substr(title.length() - 11) == " (extended)") {
148
 
        m_layout.title = osstrdup(title.substr(0, title.length() - 11).c_str());
 
189
    m_layout.title = title;
 
190
    if (mainfrm->IsExtendedElevation()) {
149
191
        m_layout.view = layout::EXTELEV;
150
192
        if (m_layout.rot != 0 && m_layout.rot != 180) m_layout.rot = 0;
151
193
        m_layout.tilt = 0;
153
195
        // FIXME rot and tilt shouldn't be integers, but for now add a small
154
196
        // fraction before forcing to int as otherwise plan view ends up being
155
197
        // 89 degrees!
156
 
        m_layout.title = osstrdup(title.c_str());
157
198
        m_layout.tilt = int(tilt_angle + .001);
158
199
        if (m_layout.tilt == 90) {
159
200
            m_layout.view = layout::PLAN;
167
208
    /* setup our print dialog*/
168
209
    wxBoxSizer* v1 = new wxBoxSizer(wxVERTICAL);
169
210
    wxBoxSizer* h1 = new wxBoxSizer(wxHORIZONTAL); // holds controls
170
 
    wxBoxSizer* v2 = new wxStaticBoxSizer(new wxStaticBox(this, -1, msg(/*View*/255)), wxVERTICAL);
171
 
    wxBoxSizer* v3 = new wxStaticBoxSizer(new wxStaticBox(this, -1, msg(/*Elements*/256)), wxVERTICAL);
 
211
    wxBoxSizer* v2 = new wxStaticBoxSizer(new wxStaticBox(this, -1, wmsg(/*View*/255)), wxVERTICAL);
 
212
    wxBoxSizer* v3 = new wxStaticBoxSizer(new wxStaticBox(this, -1, wmsg(/*Elements*/256)), wxVERTICAL);
172
213
    wxBoxSizer* h2 = new wxBoxSizer(wxHORIZONTAL); // holds buttons
173
214
 
174
 
    { // this isn't the "too wide" bit...
175
 
    wxStaticText* label;
176
 
    label = new wxStaticText(this, -1, wxString(msg(/*Scale*/154)) + " 1:");
177
 
    if (scales[0].empty()) scales[0].assign(msg(/*One page*/258));
178
 
    m_scale = new wxComboBox(this, svx_SCALE, scales[0], wxDefaultPosition,
179
 
                             wxDefaultSize, sizeof(scales) / sizeof(scales[0]),
180
 
                             scales);
181
 
    wxBoxSizer* scalebox = new wxBoxSizer(wxHORIZONTAL);
182
 
    scalebox->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
183
 
    scalebox->Add(m_scale, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
184
 
 
185
 
    v2->Add(scalebox, 0, wxALIGN_LEFT|wxALL, 0);
 
215
    if (printing) {
 
216
        wxStaticText* label;
 
217
        label = new wxStaticText(this, -1, wxString(wmsg(/*Scale*/154)) + wxT(" 1:"));
 
218
        if (scales[0].empty()) scales[0].assign(wmsg(/*One page*/258));
 
219
        m_scale = new wxComboBox(this, svx_SCALE, scales[0], wxDefaultPosition,
 
220
                                 wxDefaultSize, sizeof(scales) / sizeof(scales[0]),
 
221
                                 scales);
 
222
        wxBoxSizer* scalebox = new wxBoxSizer(wxHORIZONTAL);
 
223
        scalebox->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
224
        scalebox->Add(m_scale, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
225
 
 
226
        v2->Add(scalebox, 0, wxALIGN_LEFT|wxALL, 0);
 
227
 
 
228
        // Make the dummy string wider than any sane value and use that to
 
229
        // fix the width of the control so the sizers allow space for bigger
 
230
        // page layouts.
 
231
        m_printSize = new wxStaticText(this, -1, wxString::Format(wmsg(/*%d pages (%dx%d)*/257), 9604, 98, 98));
 
232
        v2->Add(m_printSize, 0, wxALIGN_LEFT|wxALL, 5);
186
233
    }
187
234
 
188
 
    // Make the dummy string wider than any sane value and use that to
189
 
    // fix the width of the control so the sizers allow space for bigger
190
 
    // page layouts.
191
 
    m_printSize = new wxStaticText(this, -1, wxString::Format(msg(/*%d pages (%dx%d)*/257), 9604, 98, 98));
192
 
    v2->Add(m_printSize, 0, wxALIGN_LEFT|wxALL, 5);
193
 
 
194
235
    if (m_layout.view != layout::EXTELEV) {
195
236
        wxFlexGridSizer* anglebox = new wxFlexGridSizer(2);
196
237
        wxStaticText * brg_label, * tilt_label;
197
 
        brg_label = new wxStaticText(this, -1, msg(/*Bearing*/259));
 
238
        brg_label = new wxStaticText(this, -1, wmsg(/*Bearing*/259));
198
239
        anglebox->Add(brg_label, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5);
199
240
        m_bearing = new wxSpinCtrl(this, svx_BEARING);
200
241
        m_bearing->SetRange(0, 359);
201
242
        anglebox->Add(m_bearing, 0, wxALIGN_CENTER|wxALL, 5);
202
 
        tilt_label = new wxStaticText(this, -1, msg(/*Tilt angle*/263));
 
243
        tilt_label = new wxStaticText(this, -1, wmsg(/*Tilt angle*/263));
203
244
        anglebox->Add(tilt_label, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5);
204
 
        m_tilt = new wxSpinCtrl(this,svx_TILT);
 
245
        m_tilt = new wxSpinCtrl(this, svx_TILT);
205
246
        m_tilt->SetRange(-90, 90);
206
247
        anglebox->Add(m_tilt, 0, wxALIGN_CENTER|wxALL, 5);
207
248
 
208
249
        v2->Add(anglebox, 0, wxALIGN_LEFT|wxALL, 0);
209
250
 
210
251
        wxBoxSizer * planelevsizer = new wxBoxSizer(wxHORIZONTAL);
211
 
        planelevsizer->Add(new wxButton(this, svx_PLAN, "Plan"),
 
252
        planelevsizer->Add(new wxButton(this, svx_PLAN, wmsg(/*Plan*/117)),
212
253
                           0, wxALIGN_CENTRE_VERTICAL|wxALL, 5);
213
 
        planelevsizer->Add(new wxButton(this, svx_ELEV, "Elevation"),
 
254
        planelevsizer->Add(new wxButton(this, svx_ELEV, wmsg(/*Elevation*/118)),
214
255
                           0, wxALIGN_CENTRE_VERTICAL|wxALL, 5);
215
256
 
216
257
        v2->Add(planelevsizer, 0, wxALIGN_LEFT|wxALL, 5);
218
259
 
219
260
    h1->Add(v2, 0, wxALIGN_LEFT|wxALL, 5);
220
261
 
221
 
    m_legs = new wxCheckBox(this, svx_LEGS, msg(/*Underground Survey Legs*/262));
 
262
    m_legs = new wxCheckBox(this, svx_LEGS, wmsg(/*Underground Survey Legs*/262));
222
263
    v3->Add(m_legs, 0, wxALIGN_LEFT|wxALL, 2);
223
 
    m_surface = new wxCheckBox(this, svx_SCALEBAR, msg(/*Sur&amp;face Survey Legs*/403));
 
264
    m_surface = new wxCheckBox(this, svx_SURFACE, wmsg(/*Sur&amp;face Survey Legs*/403));
224
265
    v3->Add(m_surface, 0, wxALIGN_LEFT|wxALL, 2);
225
 
    m_stations = new wxCheckBox(this, svx_STATIONS, msg(/*Crosses*/261));
 
266
    m_stations = new wxCheckBox(this, svx_STATIONS, wmsg(/*Crosses*/261));
226
267
    v3->Add(m_stations, 0, wxALIGN_LEFT|wxALL, 2);
227
 
    m_names = new wxCheckBox(this, svx_NAMES, msg(/*Station Names*/260));
 
268
    m_names = new wxCheckBox(this, svx_NAMES, wmsg(/*Station Names*/260));
228
269
    v3->Add(m_names, 0, wxALIGN_LEFT|wxALL, 2);
229
 
    m_borders = new wxCheckBox(this, svx_BORDERS, msg(/*Page Borders*/264));
230
 
    v3->Add(m_borders, 0, wxALIGN_LEFT|wxALL, 2);
231
 
//    m_blanks = new wxCheckBox(this, svx_BLANKS, msg(/*Blank Pages*/266));
232
 
//    v3->Add(m_blanks, 0, wxALIGN_LEFT|wxALL, 2);
233
 
    m_infoBox = new wxCheckBox(this, svx_INFOBOX, msg(/*Info Box*/265));
234
 
    v3->Add(m_infoBox, 0, wxALIGN_LEFT|wxALL, 2);
 
270
    if (printing) {
 
271
        m_borders = new wxCheckBox(this, svx_BORDERS, wmsg(/*Page Borders*/264));
 
272
        v3->Add(m_borders, 0, wxALIGN_LEFT|wxALL, 2);
 
273
//      m_blanks = new wxCheckBox(this, svx_BLANKS, wmsg(/*Blank Pages*/266));
 
274
//      v3->Add(m_blanks, 0, wxALIGN_LEFT|wxALL, 2);
 
275
        m_infoBox = new wxCheckBox(this, svx_INFOBOX, wmsg(/*Info Box*/265));
 
276
        v3->Add(m_infoBox, 0, wxALIGN_LEFT|wxALL, 2);
 
277
    }
235
278
 
236
279
    h1->Add(v3, 0, wxALIGN_LEFT|wxALL, 5);
237
280
 
238
281
    v1->Add(h1, 0, wxALIGN_LEFT|wxALL, 5);
239
282
 
240
283
    wxButton * but;
241
 
    but = new wxButton(this, wxID_CANCEL, msg(/*&Cancel*/402));
242
 
    h2->Add(but, 0, wxALIGN_RIGHT|wxALL, 5);
243
 
    but = new wxButton(this, svx_PREVIEW, msg(/*Pre&view*/401));
244
 
    h2->Add(but, 0, wxALIGN_RIGHT|wxALL, 5);
245
 
    but = new wxButton(this, svx_PRINT, msg(/*&Print*/400));
 
284
    but = new wxButton(this, wxID_CANCEL, wmsg(/*&Cancel*/402));
 
285
    h2->Add(but, 0, wxALIGN_RIGHT|wxALL, 5);
 
286
    if (printing) {
 
287
#ifndef __WXMAC__
 
288
        but = new wxButton(this, svx_PREVIEW, wmsg(/*Pre&view*/401));
 
289
        h2->Add(but, 0, wxALIGN_RIGHT|wxALL, 5);
 
290
        but = new wxButton(this, svx_PRINT, wmsg(/*&Print*/400));
 
291
#else
 
292
        but = new wxButton(this, svx_PRINT, wmsg(/*&Print*/400) + wxT("..."));
 
293
#endif
 
294
    } else {
 
295
        but = new wxButton(this, svx_EXPORT, wmsg(/*&Export...*/230));
 
296
    }
246
297
    but->SetDefault();
247
298
    h2->Add(but, 0, wxALIGN_RIGHT|wxALL, 5);
248
299
    v1->Add(h2, 0, wxALIGN_RIGHT|wxALL, 5);
256
307
    SomethingChanged();
257
308
}
258
309
 
259
 
svxPrintDlg::~svxPrintDlg() {
260
 
    osfree(m_layout.title);
261
 
    osfree(m_layout.datestamp);
262
 
}
263
 
 
264
310
void
265
311
svxPrintDlg::OnPrint(wxCommandEvent&) {
266
312
    SomethingChanged();
275
321
}
276
322
 
277
323
void
 
324
svxPrintDlg::OnExport(wxCommandEvent&) {
 
325
    UIToLayout();
 
326
    wxString baseleaf;
 
327
    wxFileName::SplitPath(m_File, NULL, NULL, &baseleaf, NULL, wxPATH_NATIVE);
 
328
    wxFileDialog dlg(this, wxT("Export as:"), wxString(), baseleaf,
 
329
                     wxT("DXF files|*.dxf|SVG files|*.svg|Sketch files|*.sk|EPS files|*.eps|Compass PLT for use with Carto|*.plt|HPGL for plotters|*.hpgl"),
 
330
                     wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
 
331
    if (dlg.ShowModal() == wxID_OK) {
 
332
        if (!Export(dlg.GetPath(), m_layout.title, mainfrm,
 
333
                    m_layout.rot, m_layout.tilt,
 
334
                    m_layout.Labels, m_layout.Crosses,
 
335
                    m_layout.Shots, m_layout.Surface)) {
 
336
            wxGetApp().ReportError(wxString::Format(wxT("Couldn't write file `%s'"), m_File.c_str()));
 
337
        }
 
338
    }
 
339
    Destroy();
 
340
}
 
341
 
 
342
void
278
343
svxPrintDlg::OnPreview(wxCommandEvent&) {
279
344
    SomethingChanged();
280
345
    wxPageSetupDialogData * psdd = wxGetApp().GetPageSetupDialogData();
283
348
    pv = new wxPrintPreview(new svxPrintout(mainfrm, &m_layout, psdd, m_File),
284
349
                            new svxPrintout(mainfrm, &m_layout, psdd, m_File),
285
350
                            &pd);
286
 
    wxPreviewFrame *frame = new wxPreviewFrame(pv, mainfrm, msg(/*Print Preview*/398));
 
351
    wxPreviewFrame *frame = new wxPreviewFrame(pv, mainfrm, wmsg(/*Print Preview*/398));
287
352
    frame->Initialize();
288
353
 
289
354
    // Size preview frame so that all of the controlbar and canvas can be seen
343
408
void
344
409
svxPrintDlg::SomethingChanged() {
345
410
    UIToLayout();
 
411
    if (!m_printSize) return;
346
412
    // Update the bounding box.
347
413
    RecalcBounds();
348
414
    if (m_layout.xMax >= m_layout.xMin) {
349
415
        m_layout.pages_required();
350
 
        m_printSize->SetLabel(wxString::Format(msg(/*%d pages (%dx%d)*/257), m_layout.pages, m_layout.pagesX, m_layout.pagesY));
 
416
        m_printSize->SetLabel(wxString::Format(wmsg(/*%d pages (%dx%d)*/257), m_layout.pages, m_layout.pagesX, m_layout.pagesY));
351
417
    }
352
418
}
353
419
 
356
422
    m_names->SetValue(m_layout.Labels);
357
423
    m_legs->SetValue(m_layout.Shots);
358
424
    m_stations->SetValue(m_layout.Crosses);
359
 
    m_borders->SetValue(m_layout.Border);
 
425
    if (m_borders) m_borders->SetValue(m_layout.Border);
360
426
//    m_blanks->SetValue(m_layout.SkipBlank);
361
 
    m_infoBox->SetValue(!m_layout.Raw);
 
427
    if (m_infoBox) m_infoBox->SetValue(!m_layout.Raw);
362
428
    m_surface->SetValue(m_layout.Surface);
363
429
    if (m_layout.view != layout::EXTELEV) {
364
430
        m_tilt->SetValue(m_layout.tilt);
373
439
    }
374
440
 
375
441
    // Do this last as it causes an OnChange message which calls UIToLayout
376
 
    if (m_layout.Scale != 0) {
377
 
        wxString temp;
378
 
        temp << m_layout.Scale;
379
 
        m_scale->SetValue(temp);
380
 
    } else {
381
 
        if (scales[0].empty()) scales[0].assign(msg(/*One page*/258));
382
 
        m_scale->SetValue(scales[0]);
 
442
    if (m_scale) {
 
443
        if (m_layout.Scale != 0) {
 
444
            wxString temp;
 
445
            temp << m_layout.Scale;
 
446
            m_scale->SetValue(temp);
 
447
        } else {
 
448
            if (scales[0].empty()) scales[0].assign(wmsg(/*One page*/258));
 
449
            m_scale->SetValue(scales[0]);
 
450
        }
383
451
    }
384
452
}
385
453
 
388
456
    m_layout.Labels = m_names->IsChecked();
389
457
    m_layout.Shots = m_legs->IsChecked();
390
458
    m_layout.Crosses = m_stations->IsChecked();
391
 
    m_layout.Border = m_borders->IsChecked();
 
459
    if (m_borders) m_layout.Border = m_borders->IsChecked();
392
460
//    m_layout.SkipBlank = m_blanks->IsChecked();
393
 
    m_layout.Raw = !m_infoBox->IsChecked();
 
461
    if (m_infoBox) m_layout.Raw = !m_infoBox->IsChecked();
394
462
    m_layout.Surface = m_surface->IsChecked();
395
463
 
396
464
    if (m_layout.view != layout::EXTELEV) {
405
473
        m_layout.rot = m_bearing->GetValue();
406
474
    }
407
475
 
408
 
    (m_scale->GetValue()).ToDouble(&(m_layout.Scale));
409
 
    if (m_layout.Scale == 0.0) {
410
 
        m_layout.pick_scale(1, 1);
 
476
    if (m_scale) {
 
477
        (m_scale->GetValue()).ToDouble(&(m_layout.Scale));
 
478
        if (m_layout.Scale == 0.0) {
 
479
            m_layout.pick_scale(1, 1);
 
480
        }
411
481
    }
412
482
}
413
483
 
417
487
    m_layout.yMax = m_layout.xMax = -DBL_MAX;
418
488
    m_layout.yMin = m_layout.xMin = DBL_MAX;
419
489
 
420
 
    double SIN,COS,SINT,COST;
421
 
    SIN = sin(rad(m_layout.rot));
422
 
    COS = cos(rad(m_layout.rot));
423
 
    SINT = sin(rad(m_layout.tilt));
424
 
    COST = cos(rad(m_layout.tilt));
 
490
    double SIN = sin(rad(m_layout.rot));
 
491
    double COS = cos(rad(m_layout.rot));
 
492
    double SINT = sin(rad(m_layout.tilt));
 
493
    double COST = cos(rad(m_layout.tilt));
425
494
 
426
 
    if (m_layout.Surface || m_layout.Shots) {
427
 
        for (int i=0; i < NUM_DEPTH_COLOURS; ++i) {
428
 
            list<PointInfo*>::const_iterator p = mainfrm->GetPoints(i);
429
 
            while (p != mainfrm->GetPointsEnd(i)) {
430
 
                double x = (*p)->GetX();
431
 
                double y = (*p)->GetY();
432
 
                double z = (*p)->GetZ();
433
 
                if ((*p)->IsSurface() ? m_layout.Surface : m_layout.Shots) {
434
 
                    double X = x * COS - y * SIN;
435
 
                    if (X > m_layout.xMax) m_layout.xMax = X;
436
 
                    if (X < m_layout.xMin) m_layout.xMin = X;
437
 
                    double Y = (x * SIN + y * COS) * SINT + z * COST;
438
 
                    if (Y > m_layout.yMax) m_layout.yMax = Y;
439
 
                    if (Y < m_layout.yMin) m_layout.yMin = Y;
440
 
                }
441
 
                ++p;
 
495
    if (m_layout.Shots) {
 
496
        list<traverse>::const_iterator trav = mainfrm->traverses_begin();
 
497
        list<traverse>::const_iterator tend = mainfrm->traverses_end();
 
498
        for ( ; trav != tend; ++trav) {
 
499
            vector<PointInfo>::const_iterator pos = trav->begin();
 
500
            vector<PointInfo>::const_iterator end = trav->end();
 
501
            for ( ; pos != end; ++pos) {
 
502
                double x = pos->GetX();
 
503
                double y = pos->GetY();
 
504
                double z = pos->GetZ();
 
505
                double X = x * COS - y * SIN;
 
506
                if (X > m_layout.xMax) m_layout.xMax = X;
 
507
                if (X < m_layout.xMin) m_layout.xMin = X;
 
508
                double Y = (x * SIN + y * COS) * SINT + z * COST;
 
509
                if (Y > m_layout.yMax) m_layout.yMax = Y;
 
510
                if (Y < m_layout.yMin) m_layout.yMin = Y;
 
511
            }
 
512
        }
 
513
    }
 
514
    if (m_layout.Surface) {
 
515
        list<traverse>::const_iterator trav = mainfrm->surface_traverses_begin();
 
516
        list<traverse>::const_iterator tend = mainfrm->surface_traverses_end();
 
517
        for ( ; trav != tend; ++trav) {
 
518
            vector<PointInfo>::const_iterator pos = trav->begin();
 
519
            vector<PointInfo>::const_iterator end = trav->end();
 
520
            for ( ; pos != end; ++pos) {
 
521
                double x = pos->GetX();
 
522
                double y = pos->GetY();
 
523
                double z = pos->GetZ();
 
524
                double X = x * COS - y * SIN;
 
525
                if (X > m_layout.xMax) m_layout.xMax = X;
 
526
                if (X < m_layout.xMin) m_layout.xMin = X;
 
527
                double Y = (x * SIN + y * COS) * SINT + z * COST;
 
528
                if (Y > m_layout.yMax) m_layout.yMax = Y;
 
529
                if (Y < m_layout.yMin) m_layout.yMin = Y;
442
530
            }
443
531
        }
444
532
    }
474
562
static const char *fontname = "Arial", *fontname_labels = "Arial";
475
563
 
476
564
// wx <-> prcore (calls to print_page etc...)
477
 
svxPrintout::svxPrintout(MainFrm *mainfrm_, layout *l, wxPageSetupDialogData *data,
478
 
                         const wxString & title)
 
565
svxPrintout::svxPrintout(MainFrm *mainfrm_, layout *l,
 
566
                         wxPageSetupDialogData *data, const wxString & title)
479
567
    : wxPrintout(title)
480
568
{
481
569
    mainfrm = mainfrm_;
488
576
svxPrintout::draw_info_box()
489
577
{
490
578
   layout *l = m_layout;
491
 
   char szTmp[256];
492
 
   char *p;
493
579
   int boxwidth = 60;
494
580
   int boxheight = 30;
495
581
 
540
626
 
541
627
      SetColour(PR_COLOUR_TEXT);
542
628
      MOVEMM(62, 36);
543
 
      WriteString(msg(/*North*/115));
 
629
      WriteString(wmsg(/*North*/115));
544
630
 
545
631
      MOVEMM(5, 23);
546
 
      WriteString(msg(/*Plan view*/117));
 
632
      WriteString(wmsg(/*Plan view*/117));
547
633
      break;
548
634
    }
549
635
    case layout::ELEV: case layout::TILT:
557
643
 
558
644
      SetColour(PR_COLOUR_TEXT);
559
645
      MOVEMM(62, 33);
560
 
      WriteString(msg(/*Elevation on*/116));
561
 
 
562
 
      sprintf(szTmp, "%03d"DEG, (l->rot + 270) % 360);
563
 
      MOVEMM(65, 20); WriteString(szTmp);
564
 
      sprintf(szTmp, "%03d"DEG, (l->rot + 90) % 360);
565
 
      MOVEMM(85, 20); WriteString(szTmp);
566
 
 
 
646
      WriteString(wmsg(/*Elevation on*/116));
 
647
      
 
648
      MOVEMM(65, 20); 
 
649
      WriteString(wxString::Format(wxT("%03d"DEG),
 
650
                                   (l->rot + 270) % 360 ));
 
651
      MOVEMM(85, 20);
 
652
      WriteString(wxString::Format(wxT("%03d"DEG),
 
653
                                   (l->rot + 90) % 360 ));
567
654
      MOVEMM(5, 23);
568
 
      WriteString(msg(/*Elevation*/118));
 
655
      WriteString(wmsg(/*Elevation*/118));
569
656
      break;
570
657
    case layout::EXTELEV:
571
658
      SetColour(PR_COLOUR_TEXT);
572
659
      MOVEMM(5, 13);
573
 
      WriteString(msg(/*Extended elevation*/191));
 
660
      WriteString(wmsg(/*Extended elevation*/191));
574
661
      break;
575
662
   }
576
663
 
577
664
   MOVEMM(5, boxheight - 7); WriteString(l->title);
578
665
 
579
 
   strcpy(szTmp, msg(/*Scale*/154));
580
 
   p = szTmp + strlen(szTmp);
581
 
   sprintf(p, " 1:%.0f", l->Scale);
582
 
   MOVEMM(5, boxheight - 27); WriteString(szTmp);
 
666
   MOVEMM(5, boxheight - 27); 
 
667
   WriteString(wxString::Format(wmsg(/*Scale*/154) + wxT(" 1:%.0f"),
 
668
                                l->Scale));
583
669
 
584
670
   if (l->view != layout::EXTELEV) {
585
 
      strcpy(szTmp,
586
 
             msg(l->view == layout::PLAN ? /*Up page*/168 : /*View*/169));
587
 
      p = szTmp + strlen(szTmp);
588
 
      sprintf(p, " %03d"DEG, l->rot);
589
 
      MOVEMM(5, 3); WriteString(szTmp);
 
671
      wxString s;
 
672
      s = wmsg(l->view == layout::PLAN ? /*Up page*/168 : /*View*/169);
 
673
      s.Append(wxString::Format(wxT(" %03d"DEG), l->rot));
 
674
      MOVEMM(5, 3); WriteString(s);
590
675
   }
591
676
 
592
677
   /* This used to be a copyright line, but it was occasionally
593
678
    * mis-interpreted as us claiming copyright on the survey, so let's
594
679
    * give the website URL instead */
595
680
   MOVEMM(boxwidth + 2, 2);
596
 
   WriteString("Survex "VERSION" - http://www.survex.com/");
 
681
   WriteString(wxT("Survex "VERSION" - http://www.survex.com/"));
597
682
 
598
683
   draw_scale_bar(boxwidth + 10.0, 17.0, l->PaperWidth - boxwidth - 18.0);
599
684
}
604
689
svxPrintout::draw_scale_bar(double x, double y, double MaxLength)
605
690
{
606
691
   double StepEst, d;
607
 
   int E, Step, n, le, c;
608
 
   char u_buf[3], buf[256];
609
 
   char *p;
 
692
   int E, Step, n, c;
 
693
   char u_buf[3];
 
694
   wxString buf;
610
695
   static const signed char powers[] = {
611
696
      12, 9, 9, 9, 6, 6, 6, 3, 2, 2, 0, 0, 0, -3, -3, -3, -6, -6, -6, -9,
612
697
   };
640
725
   u_buf[1] = '\0';
641
726
   strcat(u_buf, "m");
642
727
 
643
 
   strcpy(buf, msg(/*Scale*/154));
 
728
   buf = wmsg(/*Scale*/154);
644
729
 
645
730
   /* Add units used - eg. "Scale (10m)" */
646
 
   p = buf + strlen(buf);
647
 
   sprintf(p, " (%.0f%s)", (double)pow(10.0, (double)E), u_buf);
648
 
 
 
731
   buf.Append(wxString::Format(wxT(" (%.0f%s)"), (double)pow(10.0, (double)E), wxString::FromAscii(u_buf).c_str()));
649
732
   SetColour(PR_COLOUR_TEXT);
650
733
   MOVEMM(x, y + 4); WriteString(buf);
651
734
 
680
763
          SolidRectangle(X, Y, X2 - X, Y2 - Y);
681
764
      }
682
765
#endif
683
 
      /* ANSI sprintf returns length of formatted string, but some pre-ANSI Unix
684
 
       * implementations return char* (ptr to end of written string I think) */
685
 
      sprintf(buf, "%d", c * Step);
686
 
      le = strlen(buf);
 
766
      buf.Printf(wxT("%d"), c * Step);
687
767
      SetColour(PR_COLOUR_TEXT);
688
 
      MOVEMM(x + c * d - le, y - 4);
 
768
      MOVEMM(x + c * d - buf.length(), y - 4);
689
769
      WriteString(buf);
690
770
   }
691
771
}
912
992
        l->PaperDepth = pdepth -= MarginTop + MarginBottom;
913
993
    }
914
994
 
915
 
    double SIN,COS,SINT,COST;
916
 
    SIN = sin(rad(l->rot));
917
 
    COS = cos(rad(l->rot));
918
 
    SINT = sin(rad(l->tilt));
919
 
    COST = cos(rad(l->tilt));
920
 
 
921
 
    long x = 0, y = 0;
922
 
    bool pending_move = false;
923
 
    bool last_leg_surface = false;
 
995
    double SIN = sin(rad(l->rot));
 
996
    double COS = cos(rad(l->rot));
 
997
    double SINT = sin(rad(l->tilt));
 
998
    double COST = cos(rad(l->tilt));
924
999
 
925
1000
    NewPage(pageNum, l->pagesX, l->pagesY);
926
1001
 
931
1006
 
932
1007
    const double Sc = 1000 / l->Scale;
933
1008
 
934
 
    if (l->Surface || l->Shots) {
935
 
        for (int i=0; i < mainfrm->GetNumDepthBands(); ++i) {
936
 
            list<PointInfo*>::const_iterator p = mainfrm->GetPoints(i);
937
 
            while (p != mainfrm->GetPointsEnd(i)) {
938
 
                double px = (*p)->GetX();
939
 
                double py = (*p)->GetY();
940
 
                double pz = (*p)->GetZ();
941
 
                double X = px * COS - py * SIN;
942
 
                double Y = (px * SIN + py * COS) * SINT + pz * COST;
943
 
                long xnew = (long)((X * Sc + l->xOrg) * l->scX);
944
 
                long ynew = (long)((Y * Sc + l->yOrg) * l->scY);
945
 
 
946
 
                if ((*p)->IsLine()) {
947
 
                    bool draw = ((*p)->IsSurface() ? l->Surface : l->Shots);
948
 
                    if (draw) {
949
 
                        SetColour((*p)->IsSurface() ?
950
 
                                  PR_COLOUR_SURFACE_LEG : PR_COLOUR_LEG);
951
 
                    }
952
 
 
953
 
                    if ((*p)->IsSurface() != last_leg_surface)
954
 
                        pending_move = true;
955
 
 
956
 
                    /* avoid drawing superfluous lines */
957
 
                    if (pending_move || xnew != x || ynew != y) {
958
 
                        if (draw) {
959
 
                            if (pending_move) MoveTo(x, y);
960
 
                            pending_move = false;
961
 
                            DrawTo(xnew, ynew);
962
 
                        } else {
963
 
                            pending_move = true;
964
 
                        }
965
 
                        last_leg_surface = (*p)->IsSurface();
966
 
                        x = xnew;
967
 
                        y = ynew;
968
 
                    }
969
 
                } else {
970
 
                    /* avoid superfluous moves */
971
 
                    if (xnew != x || ynew != y) {
972
 
                        x = xnew;
973
 
                        y = ynew;
974
 
                        pending_move = true;
975
 
                    }
976
 
                }
977
 
                p++;
 
1009
    if (l->Shots) {
 
1010
        SetColour(PR_COLOUR_LEG);
 
1011
        list<traverse>::const_iterator trav = mainfrm->traverses_begin();
 
1012
        list<traverse>::const_iterator tend = mainfrm->traverses_end();
 
1013
        for ( ; trav != tend; ++trav) {
 
1014
            vector<PointInfo>::const_iterator pos = trav->begin();
 
1015
            vector<PointInfo>::const_iterator end = trav->end();
 
1016
            for ( ; pos != end; ++pos) {
 
1017
                double x = pos->GetX();
 
1018
                double y = pos->GetY();
 
1019
                double z = pos->GetZ();
 
1020
                double X = x * COS - y * SIN;
 
1021
                double Y = (x * SIN + y * COS) * SINT + z * COST;
 
1022
                long px = (long)((X * Sc + l->xOrg) * l->scX);
 
1023
                long py = (long)((Y * Sc + l->yOrg) * l->scY);
 
1024
                if (pos == trav->begin()) {
 
1025
                    MoveTo(px, py);
 
1026
                } else {
 
1027
                    DrawTo(px, py);
 
1028
                }
 
1029
            }
 
1030
        }
 
1031
    }
 
1032
 
 
1033
    if (l->Shots && (l->tilt == 0.0 || l->tilt == 90.0 || l->tilt == -90.0)) {
 
1034
        list<vector<XSect> >::const_iterator trav = mainfrm->tubes_begin();
 
1035
        list<vector<XSect> >::const_iterator tend = mainfrm->tubes_end();
 
1036
        for ( ; trav != tend; ++trav) {
 
1037
            if (l->tilt == 90.0 || l->tilt == -90.0) PlotLR(*trav);
 
1038
            if (l->tilt == 0.0) PlotUD(*trav);
 
1039
        }
 
1040
    }
 
1041
 
 
1042
    if (l->Surface) {
 
1043
        SetColour(PR_COLOUR_SURFACE_LEG);
 
1044
        list<traverse>::const_iterator trav = mainfrm->surface_traverses_begin();
 
1045
        list<traverse>::const_iterator tend = mainfrm->surface_traverses_end();
 
1046
        for ( ; trav != tend; ++trav) {
 
1047
            vector<PointInfo>::const_iterator pos = trav->begin();
 
1048
            vector<PointInfo>::const_iterator end = trav->end();
 
1049
            for ( ; pos != end; ++pos) {
 
1050
                double x = pos->GetX();
 
1051
                double y = pos->GetY();
 
1052
                double z = pos->GetZ();
 
1053
                double X = x * COS - y * SIN;
 
1054
                double Y = (x * SIN + y * COS) * SINT + z * COST;
 
1055
                long px = (long)((X * Sc + l->xOrg) * l->scX);
 
1056
                long py = (long)((Y * Sc + l->yOrg) * l->scY);
 
1057
                if (pos == trav->begin()) {
 
1058
                    MoveTo(px, py);
 
1059
                } else {
 
1060
                    DrawTo(px, py);
 
1061
                }
978
1062
            }
979
1063
        }
980
1064
    }
1009
1093
    if (!l->Raw) {
1010
1094
        char szTmp[256];
1011
1095
        SetColour(PR_COLOUR_TEXT);
1012
 
        sprintf(szTmp, l->footer, l->title, pageNum, l->pagesX * l->pagesY,
1013
 
                l->datestamp);
 
1096
        sprintf(szTmp,(const char*) l->footer.mb_str(), (const char*)l->title.mb_str(), pageNum, l->pagesX * l->pagesY,
 
1097
                (const char*)l->datestamp.mb_str());
1014
1098
        ShowPage(szTmp);
1015
1099
    } else {
1016
1100
        ShowPage("");
1053
1137
     * <support file directory>/print.ini [must exist]
1054
1138
     */
1055
1139
 
1056
 
#if (OS==UNIX)
 
1140
#ifdef __UNIX__
1057
1141
    pth_cfg = getenv("HOME");
1058
1142
    if (pth_cfg) {
1059
1143
        fh = fopenWithPthAndExt(pth_cfg, ".survex/print."EXT_INI, NULL,
1078
1162
    Init(pfh, false);
1079
1163
    for (pfh = fh_list; *pfh; pfh++) (void)fclose(*pfh);
1080
1164
    Pre();
1081
 
    m_layout->footer = msgPerm(/*Survey `%s'   Page %d (of %d)   Processed on %s*/167);
 
1165
    m_layout->footer = wmsg(/*Survey `%s'   Page %d (of %d)   Processed on %s*/167);
1082
1166
}
1083
1167
 
1084
1168
void
1177
1261
    x_t = x_offset + x - clip.x_min;
1178
1262
    y_t = y_offset + clip.y_max - y;
1179
1263
    if (cur_pass != -1) {
1180
 
        pdc->DrawLine(x_p,y_p,x_t,y_t);
 
1264
        pdc->DrawLine(x_p, y_p, x_t, y_t);
1181
1265
    } else {
1182
1266
        if (check_intersection(x_p, y_p)) fBlankPage = fFalse;
1183
1267
    }
1250
1334
}
1251
1335
 
1252
1336
void
1253
 
svxPrintout::WriteString(const char *s)
 
1337
svxPrintout::WriteString(const wxString & s)
1254
1338
{
1255
1339
    double xsc, ysc;
1256
1340
    pdc->GetUserScale(&xsc, &ysc);
1258
1342
    pdc->SetFont(*current_font);
1259
1343
    int w, h;
1260
1344
    if (cur_pass != -1) {
1261
 
        pdc->GetTextExtent("My", &w, &h);
 
1345
        pdc->GetTextExtent(wxT("My"), &w, &h);
1262
1346
        pdc->DrawText(s,
1263
1347
                      long(x_t / font_scaling_x),
1264
1348
                      long(y_t / font_scaling_y) - h);
1302
1386
int
1303
1387
svxPrintout::Pre()
1304
1388
{
1305
 
    font_labels = new wxFont(fontsize_labels,wxDEFAULT,wxNORMAL,wxNORMAL,false,fontname_labels,wxFONTENCODING_ISO8859_1);
1306
 
    font_default = new wxFont(fontsize,wxDEFAULT,wxNORMAL,wxNORMAL,false,fontname,wxFONTENCODING_ISO8859_1);
 
1389
    font_labels = new wxFont(fontsize_labels, wxDEFAULT, wxNORMAL, wxNORMAL,
 
1390
                             false, wxString(fontname_labels, wxConvUTF8),
 
1391
                             wxFONTENCODING_ISO8859_1);
 
1392
    font_default = new wxFont(fontsize, wxDEFAULT, wxNORMAL, wxNORMAL,
 
1393
                              false, wxString(fontname, wxConvUTF8),
 
1394
                              wxFONTENCODING_ISO8859_1);
1307
1395
    current_font = font_default;
1308
1396
    pen_leg = new wxPen(colour_leg,0,wxSOLID);
1309
1397
    pen_surface_leg = new wxPen(colour_surface_leg,0,wxSOLID);
1328
1416
    pdc->SetFont(*font_labels);
1329
1417
    MoveTo((long)(6 * m_layout->scX) + clip.x_min,
1330
1418
           clip.y_min - (long)(7 * m_layout->scY));
1331
 
    char szFooter[256];
1332
 
    sprintf(szFooter, m_layout->footer, m_layout->title, pg,
1333
 
            m_layout->pagesX * m_layout->pagesY,m_layout->datestamp);
 
1419
    wxString szFooter;
 
1420
    szFooter.Printf(m_layout->footer, 
 
1421
                    m_layout->title.c_str(), 
 
1422
                    pg,
 
1423
                    m_layout->pagesX * m_layout->pagesY,
 
1424
                    m_layout->datestamp.c_str());
1334
1425
    WriteString(szFooter);
1335
1426
    pdc->DestroyClippingRegion();
1336
1427
    pdc->SetClippingRegion(x_offset, y_offset,xpPageWidth+1, ypPageDepth+1);
1342
1433
{
1343
1434
}
1344
1435
 
 
1436
void
 
1437
svxPrintout::PlotLR(const vector<XSect> & centreline)
 
1438
{
 
1439
    assert(centreline.size() > 1);
 
1440
    XSect prev_pt_v;
 
1441
    Vector3 last_right(1.0, 0.0, 0.0);
 
1442
 
 
1443
    const double Sc = 1000 / m_layout->Scale;
 
1444
    const double SIN = sin(rad(m_layout->rot));
 
1445
    const double COS = cos(rad(m_layout->rot));
 
1446
 
 
1447
    vector<XSect>::const_iterator i = centreline.begin();
 
1448
    vector<XSect>::size_type segment = 0;
 
1449
    while (i != centreline.end()) {
 
1450
        // get the coordinates of this vertex
 
1451
        const XSect & pt_v = *i++;
 
1452
 
 
1453
        Vector3 right;
 
1454
 
 
1455
        const Vector3 up_v(0.0, 0.0, 1.0);
 
1456
 
 
1457
        if (segment == 0) {
 
1458
            assert(i != centreline.end());
 
1459
            // first segment
 
1460
 
 
1461
            // get the coordinates of the next vertex
 
1462
            const XSect & next_pt_v = *i;
 
1463
 
 
1464
            // calculate vector from this pt to the next one
 
1465
            Vector3 leg_v = next_pt_v - pt_v;
 
1466
 
 
1467
            // obtain a vector in the LRUD plane
 
1468
            right = leg_v * up_v;
 
1469
            if (right.magnitude() == 0) {
 
1470
                right = last_right;
 
1471
            } else {
 
1472
                last_right = right;
 
1473
            }
 
1474
        } else if (segment + 1 == centreline.size()) {
 
1475
            // last segment
 
1476
 
 
1477
            // Calculate vector from the previous pt to this one.
 
1478
            Vector3 leg_v = pt_v - prev_pt_v;
 
1479
 
 
1480
            // Obtain a horizontal vector in the LRUD plane.
 
1481
            right = leg_v * up_v;
 
1482
            if (right.magnitude() == 0) {
 
1483
                right = Vector3(last_right.GetX(), last_right.GetY(), 0.0);
 
1484
            } else {
 
1485
                last_right = right;
 
1486
            }
 
1487
        } else {
 
1488
            assert(i != centreline.end());
 
1489
            // Intermediate segment.
 
1490
 
 
1491
            // Get the coordinates of the next vertex.
 
1492
            const XSect & next_pt_v = *i;
 
1493
 
 
1494
            // Calculate vectors from this vertex to the
 
1495
            // next vertex, and from the previous vertex to
 
1496
            // this one.
 
1497
            Vector3 leg1_v = pt_v - prev_pt_v;
 
1498
            Vector3 leg2_v = next_pt_v - pt_v;
 
1499
 
 
1500
            // Obtain horizontal vectors perpendicular to
 
1501
            // both legs, then normalise and average to get
 
1502
            // a horizontal bisector.
 
1503
            Vector3 r1 = leg1_v * up_v;
 
1504
            Vector3 r2 = leg2_v * up_v;
 
1505
            r1.normalise();
 
1506
            r2.normalise();
 
1507
            right = r1 + r2;
 
1508
            if (right.magnitude() == 0) {
 
1509
                // This is the "mid-pitch" case...
 
1510
                right = last_right;
 
1511
            }
 
1512
            last_right = right;
 
1513
        }
 
1514
 
 
1515
        // Scale to unit vectors in the LRUD plane.
 
1516
        right.normalise();
 
1517
 
 
1518
        Double l = pt_v.GetL();
 
1519
        Double r = pt_v.GetR();
 
1520
 
 
1521
        if (l >= 0) {
 
1522
            Vector3 p = pt_v - right * l;
 
1523
            double X = p.GetX() * COS - p.GetY() * SIN;
 
1524
            double Y = (p.GetX() * SIN + p.GetY() * COS);
 
1525
            long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX);
 
1526
            long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY);
 
1527
            MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
 
1528
            DrawTo(x, y);
 
1529
            DrawTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
 
1530
        }
 
1531
        if (r >= 0) {
 
1532
            Vector3 p = pt_v + right * r;
 
1533
            double X = p.GetX() * COS - p.GetY() * SIN;
 
1534
            double Y = (p.GetX() * SIN + p.GetY() * COS);
 
1535
            long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX);
 
1536
            long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY);
 
1537
            MoveTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
 
1538
            DrawTo(x, y);
 
1539
            DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
 
1540
        }
 
1541
 
 
1542
        prev_pt_v = pt_v;
 
1543
 
 
1544
        ++segment;
 
1545
    }
 
1546
}
 
1547
 
 
1548
void
 
1549
svxPrintout::PlotUD(const vector<XSect> & centreline)
 
1550
{
 
1551
    assert(centreline.size() > 1);
 
1552
    const double Sc = 1000 / m_layout->Scale;
 
1553
 
 
1554
    vector<XSect>::const_iterator i = centreline.begin();
 
1555
    while (i != centreline.end()) {
 
1556
        // get the coordinates of this vertex
 
1557
        const XSect & pt_v = *i++;
 
1558
 
 
1559
        Double u = pt_v.GetU();
 
1560
        Double d = pt_v.GetD();
 
1561
 
 
1562
        if (u >= 0 || d >= 0) {
 
1563
            Vector3 p = pt_v;
 
1564
            double SIN = sin(rad(m_layout->rot));
 
1565
            double COS = cos(rad(m_layout->rot));
 
1566
            double X = p.GetX() * COS - p.GetY() * SIN;
 
1567
            double Y = p.GetZ();
 
1568
            long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX);
 
1569
            if (u >= 0) {
 
1570
                long y = (long)(((Y + u) * Sc + m_layout->yOrg) * m_layout->scY);
 
1571
                MoveTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
 
1572
                DrawTo(x, y);
 
1573
                DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE);
 
1574
            }
 
1575
            if (d >= 0) {
 
1576
                long y = (long)(((Y - d) * Sc + m_layout->yOrg) * m_layout->scY);
 
1577
                MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
 
1578
                DrawTo(x, y);
 
1579
                DrawTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE);
 
1580
            }
 
1581
        }
 
1582
    }
 
1583
}
 
1584
 
1345
1585
static wxColour
1346
1586
to_rgb(const char *var, char *val)
1347
1587
{
1356
1596
svxPrintout::Init(FILE **fh_list, bool fCalibrate)
1357
1597
{
1358
1598
   static const char *vars[] = {
1359
 
      "like",
1360
1599
      "font_size_labels",
1361
1600
      "colour_text",
1362
1601
      "colour_labels",
1370
1609
 
1371
1610
   fCalibrate = fCalibrate; /* suppress unused argument warning */
1372
1611
 
1373
 
   vals = ini_read_hier(fh_list, "win", vars);
 
1612
   vals = ini_read(fh_list, "aven", vars);
1374
1613
   fontsize_labels = 10;
1375
 
   if (vals[1]) fontsize_labels = as_int(vars[1], vals[1], 1, INT_MAX);
 
1614
   if (vals[0]) fontsize_labels = as_int(vars[0], vals[0], 1, INT_MAX);
1376
1615
   fontsize = 10;
1377
1616
 
1378
1617
   colour_text = colour_labels = colour_frame = colour_leg = colour_cross = colour_surface_leg = *wxBLACK;
1379
 
   if (vals[2]) colour_text = to_rgb(vars[2], vals[2]);
1380
 
   if (vals[3]) colour_labels = to_rgb(vars[3], vals[3]);
1381
 
   if (vals[4]) colour_frame = to_rgb(vars[4], vals[4]);
1382
 
   if (vals[5]) colour_leg = to_rgb(vars[5], vals[5]);
1383
 
   if (vals[6]) colour_cross = to_rgb(vars[6], vals[6]);
1384
 
   if (vals[7]) colour_surface_leg = to_rgb(vars[7], vals[7]);
 
1618
   if (vals[1]) colour_text = to_rgb(vars[1], vals[1]);
 
1619
   if (vals[2]) colour_labels = to_rgb(vars[2], vals[2]);
 
1620
   if (vals[3]) colour_frame = to_rgb(vars[3], vals[3]);
 
1621
   if (vals[4]) colour_leg = to_rgb(vars[4], vals[4]);
 
1622
   if (vals[5]) colour_cross = to_rgb(vars[5], vals[5]);
 
1623
   if (vals[6]) colour_surface_leg = to_rgb(vars[6], vals[6]);
1385
1624
   m_layout->scX = 1;
1386
1625
   m_layout->scY = 1;
1387
1626
   return NULL;