| 1 | /* printwx.cc */ |
|---|
| 2 | /* wxWidgets specific parts of Survex wxWidgets printing code */ |
|---|
| 3 | /* Copyright (C) 1993-2003,2004,2005,2006,2010,2011,2012,2013,2014 Olly Betts |
|---|
| 4 | * Copyright (C) 2001,2004 Philip Underwood |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #ifdef HAVE_CONFIG_H |
|---|
| 22 | # include <config.h> |
|---|
| 23 | #endif |
|---|
| 24 | |
|---|
| 25 | #include <wx/confbase.h> |
|---|
| 26 | #include <wx/filename.h> |
|---|
| 27 | #include <wx/print.h> |
|---|
| 28 | #include <wx/printdlg.h> |
|---|
| 29 | #include <wx/spinctrl.h> |
|---|
| 30 | #include <wx/radiobox.h> |
|---|
| 31 | #include <wx/statbox.h> |
|---|
| 32 | #include <wx/valgen.h> |
|---|
| 33 | |
|---|
| 34 | #include <vector> |
|---|
| 35 | |
|---|
| 36 | #include <stdio.h> |
|---|
| 37 | #include <stdlib.h> |
|---|
| 38 | #include <math.h> |
|---|
| 39 | #include <string.h> |
|---|
| 40 | #include <ctype.h> |
|---|
| 41 | #include <float.h> |
|---|
| 42 | #include <limits.h> |
|---|
| 43 | |
|---|
| 44 | #include "debug.h" /* for BUG and SVX_ASSERT */ |
|---|
| 45 | #include "export.h" |
|---|
| 46 | #include "filelist.h" |
|---|
| 47 | #include "filename.h" |
|---|
| 48 | #include "ini.h" |
|---|
| 49 | #include "message.h" |
|---|
| 50 | #include "useful.h" |
|---|
| 51 | |
|---|
| 52 | #include "aven.h" |
|---|
| 53 | #include "avenprcore.h" |
|---|
| 54 | #include "mainfrm.h" |
|---|
| 55 | #include "printwx.h" |
|---|
| 56 | |
|---|
| 57 | using namespace std; |
|---|
| 58 | |
|---|
| 59 | enum { |
|---|
| 60 | svx_EXPORT = 1200, |
|---|
| 61 | svx_FORMAT, |
|---|
| 62 | svx_SCALE, |
|---|
| 63 | svx_BEARING, |
|---|
| 64 | svx_TILT, |
|---|
| 65 | svx_LEGS, |
|---|
| 66 | svx_STATIONS, |
|---|
| 67 | svx_NAMES, |
|---|
| 68 | svx_XSECT, |
|---|
| 69 | svx_WALLS, |
|---|
| 70 | svx_PASSAGES, |
|---|
| 71 | svx_BORDERS, |
|---|
| 72 | svx_BLANKS, |
|---|
| 73 | svx_LEGEND, |
|---|
| 74 | svx_SURFACE, |
|---|
| 75 | svx_PLAN, |
|---|
| 76 | svx_ELEV, |
|---|
| 77 | svx_ENTS, |
|---|
| 78 | svx_FIXES, |
|---|
| 79 | svx_EXPORTS, |
|---|
| 80 | svx_PROJ_LABEL, |
|---|
| 81 | svx_PROJ, |
|---|
| 82 | svx_GRID, |
|---|
| 83 | svx_TEXT_HEIGHT, |
|---|
| 84 | svx_MARKER_SIZE, |
|---|
| 85 | svx_CENTRED, |
|---|
| 86 | svx_FULLCOORDS |
|---|
| 87 | }; |
|---|
| 88 | |
|---|
| 89 | class BitValidator : public wxValidator { |
|---|
| 90 | // Disallow assignment. |
|---|
| 91 | BitValidator & operator=(const BitValidator&); |
|---|
| 92 | |
|---|
| 93 | protected: |
|---|
| 94 | int * val; |
|---|
| 95 | |
|---|
| 96 | int mask; |
|---|
| 97 | |
|---|
| 98 | public: |
|---|
| 99 | BitValidator(int * val_, int mask_) |
|---|
| 100 | : val(val_), mask(mask_) { } |
|---|
| 101 | |
|---|
| 102 | BitValidator(const BitValidator &o) : wxValidator() { |
|---|
| 103 | Copy(o); |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | ~BitValidator() { } |
|---|
| 107 | |
|---|
| 108 | wxObject *Clone() const { return new BitValidator(val, mask); } |
|---|
| 109 | |
|---|
| 110 | bool Copy(const BitValidator& o) { |
|---|
| 111 | wxValidator::Copy(o); |
|---|
| 112 | val = o.val; |
|---|
| 113 | mask = o.mask; |
|---|
| 114 | return true; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | bool Validate(wxWindow *) { return true; } |
|---|
| 118 | |
|---|
| 119 | bool TransferToWindow() { |
|---|
| 120 | if (!m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox))) |
|---|
| 121 | return false; |
|---|
| 122 | ((wxCheckBox*)m_validatorWindow)->SetValue(*val & mask); |
|---|
| 123 | return true; |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | bool TransferFromWindow() { |
|---|
| 127 | if (!m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox))) |
|---|
| 128 | return false; |
|---|
| 129 | if (((wxCheckBox*)m_validatorWindow)->IsChecked()) |
|---|
| 130 | *val |= mask; |
|---|
| 131 | else |
|---|
| 132 | *val &= ~mask; |
|---|
| 133 | return true; |
|---|
| 134 | } |
|---|
| 135 | }; |
|---|
| 136 | |
|---|
| 137 | class svxPrintout : public wxPrintout { |
|---|
| 138 | MainFrm *mainfrm; |
|---|
| 139 | layout *m_layout; |
|---|
| 140 | wxPageSetupDialogData* m_data; |
|---|
| 141 | wxDC* pdc; |
|---|
| 142 | // Currently unused, but "skip blank pages" would use it. |
|---|
| 143 | static const int cur_pass = 0; |
|---|
| 144 | |
|---|
| 145 | wxPen *pen_frame, *pen_cross, *pen_surface_leg, *pen_leg; |
|---|
| 146 | wxColour colour_text, colour_labels, colour_frame, colour_leg; |
|---|
| 147 | wxColour colour_cross,colour_surface_leg; |
|---|
| 148 | |
|---|
| 149 | long x_t, y_t; |
|---|
| 150 | double font_scaling_x, font_scaling_y; |
|---|
| 151 | wxFont * current_font; |
|---|
| 152 | |
|---|
| 153 | int check_intersection(long x_p, long y_p); |
|---|
| 154 | void draw_info_box(); |
|---|
| 155 | void draw_scale_bar(double x, double y, double MaxLength); |
|---|
| 156 | int next_page(int *pstate, char **q, int pageLim); |
|---|
| 157 | void drawticks(border clip, int tsize, int x, int y); |
|---|
| 158 | |
|---|
| 159 | void MOVEMM(double X, double Y) { |
|---|
| 160 | MoveTo((long)(X * m_layout->scX), (long)(Y * m_layout->scY)); |
|---|
| 161 | } |
|---|
| 162 | void DRAWMM(double X, double Y) { |
|---|
| 163 | DrawTo((long)(X * m_layout->scX), (long)(Y * m_layout->scY)); |
|---|
| 164 | } |
|---|
| 165 | void MoveTo(long x, long y); |
|---|
| 166 | void DrawTo(long x, long y); |
|---|
| 167 | void DrawCross(long x, long y); |
|---|
| 168 | void SetFont(int fontcode); |
|---|
| 169 | void SetColour(int colourcode); |
|---|
| 170 | void WriteString(const wxString & s); |
|---|
| 171 | void DrawEllipse(long x, long y, long r, long R); |
|---|
| 172 | void SolidRectangle(long x, long y, long w, long h); |
|---|
| 173 | int Pre(); |
|---|
| 174 | void NewPage(int pg, int pagesX, int pagesY); |
|---|
| 175 | void PlotLR(const vector<XSect> & centreline); |
|---|
| 176 | void PlotUD(const vector<XSect> & centreline); |
|---|
| 177 | char * Init(FILE **fh_list, bool fCalibrate); |
|---|
| 178 | public: |
|---|
| 179 | svxPrintout(MainFrm *mainfrm, layout *l, wxPageSetupDialogData *data, const wxString & title); |
|---|
| 180 | bool OnPrintPage(int pageNum); |
|---|
| 181 | void GetPageInfo(int *minPage, int *maxPage, |
|---|
| 182 | int *pageFrom, int *pageTo); |
|---|
| 183 | bool HasPage(int pageNum); |
|---|
| 184 | void OnBeginPrinting(); |
|---|
| 185 | void OnEndPrinting(); |
|---|
| 186 | }; |
|---|
| 187 | |
|---|
| 188 | BEGIN_EVENT_TABLE(svxPrintDlg, wxDialog) |
|---|
| 189 | EVT_CHOICE(svx_FORMAT, svxPrintDlg::OnChange) |
|---|
| 190 | EVT_TEXT(svx_SCALE, svxPrintDlg::OnChange) |
|---|
| 191 | EVT_COMBOBOX(svx_SCALE, svxPrintDlg::OnChange) |
|---|
| 192 | EVT_SPINCTRL(svx_BEARING, svxPrintDlg::OnChangeSpin) |
|---|
| 193 | EVT_SPINCTRL(svx_TILT, svxPrintDlg::OnChangeSpin) |
|---|
| 194 | EVT_BUTTON(wxID_PRINT, svxPrintDlg::OnPrint) |
|---|
| 195 | EVT_BUTTON(svx_EXPORT, svxPrintDlg::OnExport) |
|---|
| 196 | EVT_BUTTON(wxID_CANCEL, svxPrintDlg::OnCancel) |
|---|
| 197 | #ifdef AVEN_PRINT_PREVIEW |
|---|
| 198 | EVT_BUTTON(wxID_PREVIEW, svxPrintDlg::OnPreview) |
|---|
| 199 | #endif |
|---|
| 200 | EVT_BUTTON(svx_PLAN, svxPrintDlg::OnPlan) |
|---|
| 201 | EVT_BUTTON(svx_ELEV, svxPrintDlg::OnElevation) |
|---|
| 202 | EVT_UPDATE_UI(svx_PLAN, svxPrintDlg::OnPlanUpdate) |
|---|
| 203 | EVT_UPDATE_UI(svx_ELEV, svxPrintDlg::OnElevationUpdate) |
|---|
| 204 | EVT_CHECKBOX(svx_LEGS, svxPrintDlg::OnChange) |
|---|
| 205 | EVT_CHECKBOX(svx_STATIONS, svxPrintDlg::OnChange) |
|---|
| 206 | EVT_CHECKBOX(svx_NAMES, svxPrintDlg::OnChange) |
|---|
| 207 | EVT_CHECKBOX(svx_SURFACE, svxPrintDlg::OnChange) |
|---|
| 208 | EVT_CHECKBOX(svx_ENTS, svxPrintDlg::OnChange) |
|---|
| 209 | EVT_CHECKBOX(svx_FIXES, svxPrintDlg::OnChange) |
|---|
| 210 | EVT_CHECKBOX(svx_EXPORTS, svxPrintDlg::OnChange) |
|---|
| 211 | END_EVENT_TABLE() |
|---|
| 212 | |
|---|
| 213 | static wxString scales[] = { |
|---|
| 214 | wxT(""), |
|---|
| 215 | wxT("25"), |
|---|
| 216 | wxT("50"), |
|---|
| 217 | wxT("100"), |
|---|
| 218 | wxT("250"), |
|---|
| 219 | wxT("500"), |
|---|
| 220 | wxT("1000"), |
|---|
| 221 | wxT("2500"), |
|---|
| 222 | wxT("5000"), |
|---|
| 223 | wxT("10000"), |
|---|
| 224 | wxT("25000"), |
|---|
| 225 | wxT("50000"), |
|---|
| 226 | wxT("100000") |
|---|
| 227 | }; |
|---|
| 228 | |
|---|
| 229 | static wxString formats[] = { |
|---|
| 230 | wxT("DXF"), |
|---|
| 231 | wxT("EPS"), |
|---|
| 232 | wxT("GPX"), |
|---|
| 233 | wxT("HPGL"), |
|---|
| 234 | wxT("KML"), |
|---|
| 235 | wxT("Plot"), |
|---|
| 236 | wxT("Skencil"), |
|---|
| 237 | wxT("SVG") |
|---|
| 238 | }; |
|---|
| 239 | |
|---|
| 240 | #if 0 |
|---|
| 241 | static wxString projs[] = { |
|---|
| 242 | /* CUCC Austria: */ |
|---|
| 243 | wxT("+proj=tmerc +lat_0=0 +lon_0=13d20 +k=1 +x_0=0 +y_0=-5200000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232"), |
|---|
| 244 | /* British grid SD (Yorkshire): */ |
|---|
| 245 | wxT("+proj=tmerc +lat_0=49d +lon_0=-2d +k=0.999601 +x_0=100000 +y_0=-500000 +ellps=airy +towgs84=375,-111,431,0,0,0,0"), |
|---|
| 246 | /* British full grid reference: */ |
|---|
| 247 | wxT("+proj=tmerc +lat_0=49d +lon_0=-2d +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=375,-111,431,0,0,0,0") |
|---|
| 248 | }; |
|---|
| 249 | #endif |
|---|
| 250 | |
|---|
| 251 | static unsigned format_info[] = { |
|---|
| 252 | LABELS|LEGS|SURF|STNS|PASG|XSECT|WALLS|MARKER_SIZE|TEXT_HEIGHT|GRID|FULL_COORDS, |
|---|
| 253 | LABELS|LEGS|SURF|STNS, |
|---|
| 254 | LABELS|LEGS|SURF|ENTS|FIXES|EXPORTS|PROJ|EXPORT_3D, |
|---|
| 255 | LABELS|LEGS|SURF|STNS|CENTRED, |
|---|
| 256 | LABELS|ENTS|FIXES|EXPORTS|PROJ|EXPORT_3D, |
|---|
| 257 | LABELS|LEGS|SURF, |
|---|
| 258 | LABELS|LEGS|SURF|STNS|MARKER_SIZE|GRID|SCALE, |
|---|
| 259 | LABELS|LEGS|SURF|STNS|PASG|XSECT|WALLS|MARKER_SIZE|TEXT_HEIGHT|SCALE |
|---|
| 260 | }; |
|---|
| 261 | |
|---|
| 262 | static const char * extension[] = { |
|---|
| 263 | ".dxf", |
|---|
| 264 | ".eps", |
|---|
| 265 | ".gpx", |
|---|
| 266 | ".hpgl", |
|---|
| 267 | ".kml", |
|---|
| 268 | ".plt", |
|---|
| 269 | ".sk", |
|---|
| 270 | ".svg" |
|---|
| 271 | }; |
|---|
| 272 | |
|---|
| 273 | static int msg_filetype[] = { |
|---|
| 274 | /*DXF files*/411, |
|---|
| 275 | /*EPS files*/412, |
|---|
| 276 | /*GPX files*/413, |
|---|
| 277 | /*HPGL for plotters*/414, |
|---|
| 278 | /*KML files*/444, |
|---|
| 279 | /*Compass PLT for use with Carto*/415, |
|---|
| 280 | /*Skencil files*/416, |
|---|
| 281 | /*SVG files*/417 |
|---|
| 282 | }; |
|---|
| 283 | |
|---|
| 284 | // there are three jobs to do here... |
|---|
| 285 | // User <-> wx - this should possibly be done in a separate file |
|---|
| 286 | svxPrintDlg::svxPrintDlg(MainFrm* mainfrm_, const wxString & filename, |
|---|
| 287 | const wxString & title, const wxString & cs_proj, |
|---|
| 288 | const wxString & datestamp, time_t datestamp_numeric, |
|---|
| 289 | double angle, double tilt_angle, |
|---|
| 290 | bool labels, bool crosses, bool legs, bool surf, |
|---|
| 291 | bool tubes, bool ents, bool fixes, bool exports, |
|---|
| 292 | bool printing, bool close_after_) |
|---|
| 293 | : wxDialog(mainfrm_, -1, wxString(printing ? |
|---|
| 294 | /* TRANSLATORS: Title of the print |
|---|
| 295 | * dialog */ |
|---|
| 296 | wmsg(/*Print*/399) : |
|---|
| 297 | /* TRANSLATORS: Title of the export |
|---|
| 298 | * dialog */ |
|---|
| 299 | wmsg(/*Export*/383))), |
|---|
| 300 | m_layout(printing ? wxGetApp().GetPageSetupDialogData() : NULL), |
|---|
| 301 | m_File(filename), mainfrm(mainfrm_), close_after(close_after_) |
|---|
| 302 | { |
|---|
| 303 | m_scale = NULL; |
|---|
| 304 | m_printSize = NULL; |
|---|
| 305 | m_bearing = NULL; |
|---|
| 306 | m_tilt = NULL; |
|---|
| 307 | m_format = NULL; |
|---|
| 308 | int show_mask = 0; |
|---|
| 309 | if (labels) |
|---|
| 310 | show_mask |= LABELS; |
|---|
| 311 | if (crosses) |
|---|
| 312 | show_mask |= STNS; |
|---|
| 313 | if (legs) |
|---|
| 314 | show_mask |= LEGS; |
|---|
| 315 | if (surf) |
|---|
| 316 | show_mask |= SURF; |
|---|
| 317 | if (tubes) |
|---|
| 318 | show_mask |= XSECT|WALLS|PASG; |
|---|
| 319 | if (ents) |
|---|
| 320 | show_mask |= ENTS; |
|---|
| 321 | if (fixes) |
|---|
| 322 | show_mask |= FIXES; |
|---|
| 323 | if (exports) |
|---|
| 324 | show_mask |= EXPORTS; |
|---|
| 325 | m_layout.show_mask = show_mask; |
|---|
| 326 | m_layout.datestamp = datestamp; |
|---|
| 327 | m_layout.datestamp_numeric = datestamp_numeric; |
|---|
| 328 | m_layout.rot = int(angle); |
|---|
| 329 | m_layout.title = title; |
|---|
| 330 | m_layout.cs_proj = cs_proj; |
|---|
| 331 | if (mainfrm->IsExtendedElevation()) { |
|---|
| 332 | m_layout.view = layout::EXTELEV; |
|---|
| 333 | if (m_layout.rot != 0 && m_layout.rot != 180) m_layout.rot = 0; |
|---|
| 334 | m_layout.tilt = 0; |
|---|
| 335 | } else { |
|---|
| 336 | // FIXME rot and tilt shouldn't be integers. |
|---|
| 337 | m_layout.tilt = int(tilt_angle); |
|---|
| 338 | if (m_layout.tilt == -90) { |
|---|
| 339 | m_layout.view = layout::PLAN; |
|---|
| 340 | } else if (m_layout.tilt == 0) { |
|---|
| 341 | m_layout.view = layout::ELEV; |
|---|
| 342 | } else { |
|---|
| 343 | m_layout.view = layout::TILT; |
|---|
| 344 | } |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | /* setup our print dialog*/ |
|---|
| 348 | wxBoxSizer* v1 = new wxBoxSizer(wxVERTICAL); |
|---|
| 349 | wxBoxSizer* h1 = new wxBoxSizer(wxHORIZONTAL); // holds controls |
|---|
| 350 | /* TRANSLATORS: Used as a label for the surrounding box for the "Bearing" |
|---|
| 351 | * and "Tilt angle" fields, and the "Plan view" and "Elevation" buttons in |
|---|
| 352 | * the "what to print/export" dialog. */ |
|---|
| 353 | m_viewbox = new wxStaticBoxSizer(new wxStaticBox(this, -1, wmsg(/*View*/283)), wxVERTICAL); |
|---|
| 354 | /* TRANSLATORS: Used as a label for the surrounding box for the "survey |
|---|
| 355 | * legs" "stations" "names" etc checkboxes in the "what to print" dialog. |
|---|
| 356 | * "Elements" isn’t a good name for this but nothing better has yet come to |
|---|
| 357 | * mind! */ |
|---|
| 358 | wxBoxSizer* v3 = new wxStaticBoxSizer(new wxStaticBox(this, -1, wmsg(/*Elements*/256)), wxVERTICAL); |
|---|
| 359 | wxBoxSizer* h2 = new wxBoxSizer(wxHORIZONTAL); |
|---|
| 360 | wxBoxSizer* h3 = new wxBoxSizer(wxHORIZONTAL); // holds buttons |
|---|
| 361 | |
|---|
| 362 | if (!printing) { |
|---|
| 363 | wxStaticText* label; |
|---|
| 364 | label = new wxStaticText(this, -1, wxString(wmsg(/*Export format*/410))); |
|---|
| 365 | const size_t n_formats = sizeof(formats) / sizeof(formats[0]); |
|---|
| 366 | m_format = new wxChoice(this, svx_FORMAT, |
|---|
| 367 | wxDefaultPosition, wxDefaultSize, |
|---|
| 368 | n_formats, formats); |
|---|
| 369 | unsigned current_format = 0; |
|---|
| 370 | wxConfigBase * cfg = wxConfigBase::Get(); |
|---|
| 371 | wxString s; |
|---|
| 372 | if (cfg->Read(wxT("export_format"), &s, wxString())) { |
|---|
| 373 | for (unsigned i = 0; i != n_formats; ++i) { |
|---|
| 374 | if (s == formats[i]) { |
|---|
| 375 | current_format = i; |
|---|
| 376 | break; |
|---|
| 377 | } |
|---|
| 378 | } |
|---|
| 379 | } |
|---|
| 380 | m_format->SetSelection(current_format); |
|---|
| 381 | wxBoxSizer* formatbox = new wxBoxSizer(wxHORIZONTAL); |
|---|
| 382 | formatbox->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
|---|
| 383 | formatbox->Add(m_format, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
|---|
| 384 | |
|---|
| 385 | v1->Add(formatbox, 0, wxALIGN_LEFT|wxALL, 0); |
|---|
| 386 | } |
|---|
| 387 | |
|---|
| 388 | wxStaticText* label; |
|---|
| 389 | label = new wxStaticText(this, -1, wxString(wmsg(/*Scale*/154)) + wxT(" 1:")); |
|---|
| 390 | if (scales[0].empty()) { |
|---|
| 391 | if (printing) { |
|---|
| 392 | /* TRANSLATORS: used in the scale drop down selector in the print |
|---|
| 393 | * dialog the implicit meaning is "choose a suitable scale to fit |
|---|
| 394 | * the plot on a single page", but we need something shorter */ |
|---|
| 395 | scales[0].assign(wmsg(/*One page*/258)); |
|---|
| 396 | } else { |
|---|
| 397 | scales[0].assign(wxT("1000")); |
|---|
| 398 | } |
|---|
| 399 | } |
|---|
| 400 | m_scale = new wxComboBox(this, svx_SCALE, scales[0], wxDefaultPosition, |
|---|
| 401 | wxDefaultSize, sizeof(scales) / sizeof(scales[0]), |
|---|
| 402 | scales); |
|---|
| 403 | m_scalebox = new wxBoxSizer(wxHORIZONTAL); |
|---|
| 404 | m_scalebox->Add(label, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
|---|
| 405 | m_scalebox->Add(m_scale, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); |
|---|
| 406 | |
|---|
| 407 | m_viewbox->Add(m_scalebox, 0, wxALIGN_LEFT|wxALL, 0); |
|---|
| 408 | |
|---|
| 409 | if (printing) { |
|---|
| 410 | // Make the dummy string wider than any sane value and use that to |
|---|
| 411 | // fix the width of the control so the sizers allow space for bigger |
|---|
| 412 | // page layouts. |
|---|
| 413 | m_printSize = new wxStaticText(this, -1, wxString::Format(wmsg(/*%d pages (%dx%d)*/257), 9604, 98, 98)); |
|---|
| 414 | m_viewbox->Add(m_printSize, 0, wxALIGN_LEFT|wxALL, 5); |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | /* FIXME: |
|---|
| 418 | * svx_GRID, // double - spacing, default: 100m |
|---|
| 419 | * svx_TEXT_HEIGHT, // default 0.6 |
|---|
| 420 | * svx_MARKER_SIZE // default 0.8 |
|---|
| 421 | */ |
|---|
| 422 | |
|---|
| 423 | if (m_layout.view != layout::EXTELEV) { |
|---|
| 424 | wxFlexGridSizer* anglebox = new wxFlexGridSizer(2); |
|---|
| 425 | wxStaticText * brg_label, * tilt_label; |
|---|
| 426 | brg_label = new wxStaticText(this, -1, wmsg(/*Bearing*/259)); |
|---|
| 427 | anglebox->Add(brg_label, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5); |
|---|
| 428 | m_bearing = new wxSpinCtrl(this, svx_BEARING); |
|---|
| 429 | m_bearing->SetRange(0, 359); |
|---|
| 430 | anglebox->Add(m_bearing, 0, wxALIGN_CENTER|wxALL, 5); |
|---|
| 431 | /* TRANSLATORS: Used in the print dialog: */ |
|---|
| 432 | tilt_label = new wxStaticText(this, -1, wmsg(/*Tilt angle*/263)); |
|---|
| 433 | anglebox->Add(tilt_label, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5); |
|---|
| 434 | m_tilt = new wxSpinCtrl(this, svx_TILT); |
|---|
| 435 | m_tilt->SetRange(-90, 90); |
|---|
| 436 | anglebox->Add(m_tilt, 0, wxALIGN_CENTER|wxALL, 5); |
|---|
| 437 | |
|---|
| 438 | m_viewbox->Add(anglebox, 0, wxALIGN_LEFT|wxALL, 0); |
|---|
| 439 | |
|---|
| 440 | wxBoxSizer * planelevsizer = new wxBoxSizer(wxHORIZONTAL); |
|---|
| 441 | planelevsizer->Add(new wxButton(this, svx_PLAN, wmsg(/*P&lan view*/117)), |
|---|
| 442 | 0, wxALIGN_CENTRE_VERTICAL|wxALL, 5); |
|---|
| 443 | planelevsizer->Add(new wxButton(this, svx_ELEV, wmsg(/*&Elevation*/285)), |
|---|
| 444 | 0, wxALIGN_CENTRE_VERTICAL|wxALL, 5); |
|---|
| 445 | |
|---|
| 446 | m_viewbox->Add(planelevsizer, 0, wxALIGN_LEFT|wxALL, 5); |
|---|
| 447 | } |
|---|
| 448 | |
|---|
| 449 | /* TRANSLATORS: Here a "survey leg" is a set of measurements between two |
|---|
| 450 | * "survey stations". */ |
|---|
| 451 | v3->Add(new wxCheckBox(this, svx_LEGS, wmsg(/*Underground Survey Legs*/262), |
|---|
| 452 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 453 | BitValidator(&m_layout.show_mask, LEGS)), |
|---|
| 454 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 455 | /* TRANSLATORS: Here a "survey leg" is a set of measurements between two |
|---|
| 456 | * "survey stations". */ |
|---|
| 457 | v3->Add(new wxCheckBox(this, svx_SURFACE, wmsg(/*Sur&face Survey Legs*/403), |
|---|
| 458 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 459 | BitValidator(&m_layout.show_mask, SURF)), |
|---|
| 460 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 461 | v3->Add(new wxCheckBox(this, svx_STATIONS, wmsg(/*Crosses*/261), |
|---|
| 462 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 463 | BitValidator(&m_layout.show_mask, STNS)), |
|---|
| 464 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 465 | v3->Add(new wxCheckBox(this, svx_NAMES, wmsg(/*Station Names*/260), |
|---|
| 466 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 467 | BitValidator(&m_layout.show_mask, LABELS)), |
|---|
| 468 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 469 | v3->Add(new wxCheckBox(this, svx_ENTS, wmsg(/*Entrances*/418), |
|---|
| 470 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 471 | BitValidator(&m_layout.show_mask, ENTS)), |
|---|
| 472 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 473 | v3->Add(new wxCheckBox(this, svx_FIXES, wmsg(/*Fixed Points*/419), |
|---|
| 474 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 475 | BitValidator(&m_layout.show_mask, FIXES)), |
|---|
| 476 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 477 | v3->Add(new wxCheckBox(this, svx_EXPORTS, wmsg(/*Exported Stations*/420), |
|---|
| 478 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 479 | BitValidator(&m_layout.show_mask, EXPORTS)), |
|---|
| 480 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 481 | v3->Add(new wxCheckBox(this, svx_XSECT, wmsg(/*Cross-sections*/393), |
|---|
| 482 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 483 | BitValidator(&m_layout.show_mask, XSECT)), |
|---|
| 484 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 485 | if (!printing) { |
|---|
| 486 | v3->Add(new wxCheckBox(this, svx_WALLS, wmsg(/*Walls*/394), |
|---|
| 487 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 488 | BitValidator(&m_layout.show_mask, WALLS)), |
|---|
| 489 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 490 | v3->Add(new wxCheckBox(this, svx_PASSAGES, wmsg(/*Passages*/395), |
|---|
| 491 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 492 | BitValidator(&m_layout.show_mask, PASG)), |
|---|
| 493 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 494 | v3->Add(new wxCheckBox(this, svx_CENTRED, wmsg(/*Origin in centre*/421), |
|---|
| 495 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 496 | BitValidator(&m_layout.show_mask, CENTRED)), |
|---|
| 497 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 498 | v3->Add(new wxCheckBox(this, svx_FULLCOORDS, wmsg(/*Full coordinates*/422), |
|---|
| 499 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 500 | BitValidator(&m_layout.show_mask, FULL_COORDS)), |
|---|
| 501 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 502 | } |
|---|
| 503 | if (printing) { |
|---|
| 504 | /* TRANSLATORS: used in the print dialog - controls drawing lines |
|---|
| 505 | * around each page */ |
|---|
| 506 | v3->Add(new wxCheckBox(this, svx_BORDERS, wmsg(/*Page Borders*/264), |
|---|
| 507 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 508 | wxGenericValidator(&m_layout.Border)), |
|---|
| 509 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 510 | /* TRANSLATORS: will be used in the print dialog - check this to print |
|---|
| 511 | * blank pages (otherwise they’ll be skipped to save paper) */ |
|---|
| 512 | // m_blanks = new wxCheckBox(this, svx_BLANKS, wmsg(/*Blank Pages*/266)); |
|---|
| 513 | // v3->Add(m_blanks, 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 514 | /* TRANSLATORS: As in the legend on a map. Used in the print dialog - |
|---|
| 515 | * controls drawing the box at the lower left with survey name, view |
|---|
| 516 | * angles, etc */ |
|---|
| 517 | v3->Add(new wxCheckBox(this, svx_LEGEND, wmsg(/*Legend*/265), |
|---|
| 518 | wxDefaultPosition, wxDefaultSize, 0, |
|---|
| 519 | wxGenericValidator(&m_layout.Legend)), |
|---|
| 520 | 0, wxALIGN_LEFT|wxALL, 2); |
|---|
| 521 | } |
|---|
| 522 | |
|---|
| 523 | h1->Add(v3, 0, wxALIGN_LEFT|wxALL, 5); |
|---|
| 524 | h1->Add(m_viewbox, 0, wxALIGN_LEFT|wxLEFT, 5); |
|---|
| 525 | |
|---|
| 526 | /* TRANSLATORS: The PROJ library is used to do coordinate transformations |
|---|
| 527 | * (https://trac.osgeo.org/proj/) - if the .3d file doesn't contain details |
|---|
| 528 | * of the coordinate projection in use, the user must specify it here for |
|---|
| 529 | * export formats which need to know it (e.g. GPX). |
|---|
| 530 | */ |
|---|
| 531 | h2->Add(new wxStaticText(this, svx_PROJ_LABEL, wmsg(/*Coordinate projection*/440)), |
|---|
| 532 | 0, wxLEFT|wxALIGN_CENTRE_VERTICAL, 5); |
|---|
| 533 | long style = 0; |
|---|
| 534 | if (!m_layout.cs_proj.empty()) { |
|---|
| 535 | // If the input file specified the coordinate system, don't let the |
|---|
| 536 | // user mess with it. |
|---|
| 537 | style = wxTE_READONLY; |
|---|
| 538 | } else { |
|---|
| 539 | #if 0 // FIXME: Is it a good idea to save this? |
|---|
| 540 | wxConfigBase * cfg = wxConfigBase::Get(); |
|---|
| 541 | wxString input_projection; |
|---|
| 542 | cfg->Read(wxT("input_projection"), &input_projection); |
|---|
| 543 | if (!input_projection.empty()) |
|---|
| 544 | proj_edit.SetValue(input_projection); |
|---|
| 545 | #endif |
|---|
| 546 | } |
|---|
| 547 | wxTextCtrl * proj_edit = new wxTextCtrl(this, svx_PROJ, m_layout.cs_proj, |
|---|
| 548 | wxDefaultPosition, wxDefaultSize, |
|---|
| 549 | style); |
|---|
| 550 | h2->Add(proj_edit, 1, wxALL|wxEXPAND|wxALIGN_CENTRE_VERTICAL, 5); |
|---|
| 551 | v1->Add(h2, 0, wxALIGN_LEFT|wxEXPAND, 5); |
|---|
| 552 | |
|---|
| 553 | v1->Add(h1, 0, wxALIGN_LEFT|wxALL, 5); |
|---|
| 554 | |
|---|
| 555 | // When we enable/disable checkboxes in the export dialog, ideally we'd |
|---|
| 556 | // like the dialog to resize, but not sure how to achieve that, so we |
|---|
| 557 | // add a stretchable spacer here so at least the buttons stay in the |
|---|
| 558 | // lower right corner. |
|---|
| 559 | v1->AddStretchSpacer(); |
|---|
| 560 | |
|---|
| 561 | wxButton * but; |
|---|
| 562 | but = new wxButton(this, wxID_CANCEL); |
|---|
| 563 | h3->Add(but, 0, wxALIGN_RIGHT|wxALL, 5); |
|---|
| 564 | if (printing) { |
|---|
| 565 | #ifdef AVEN_PRINT_PREVIEW |
|---|
| 566 | but = new wxButton(this, wxID_PREVIEW); |
|---|
| 567 | h3->Add(but, 0, wxALIGN_RIGHT|wxALL, 5); |
|---|
| 568 | but = new wxButton(this, wxID_PRINT); |
|---|
| 569 | #else |
|---|
| 570 | but = new wxButton(this, wxID_PRINT, wmsg(/*&Print…*/400)); |
|---|
| 571 | #endif |
|---|
| 572 | } else { |
|---|
| 573 | /* TRANSLATORS: The text on the action button in the "Export" settings |
|---|
| 574 | * dialog */ |
|---|
| 575 | but = new wxButton(this, svx_EXPORT, wmsg(/*&Export…*/230)); |
|---|
| 576 | } |
|---|
| 577 | but->SetDefault(); |
|---|
| 578 | h3->Add(but, 0, wxALIGN_RIGHT|wxALL, 5); |
|---|
| 579 | v1->Add(h3, 0, wxALIGN_RIGHT|wxALL, 5); |
|---|
| 580 | |
|---|
| 581 | SetAutoLayout(true); |
|---|
| 582 | SetSizer(v1); |
|---|
| 583 | v1->Fit(this); |
|---|
| 584 | v1->SetSizeHints(this); |
|---|
| 585 | |
|---|
| 586 | LayoutToUI(); |
|---|
| 587 | SomethingChanged(0); |
|---|
| 588 | } |
|---|
| 589 | |
|---|
| 590 | void |
|---|
| 591 | svxPrintDlg::OnPrint(wxCommandEvent&) { |
|---|
| 592 | SomethingChanged(0); |
|---|
| 593 | TransferDataFromWindow(); |
|---|
| 594 | wxPageSetupDialogData * psdd = wxGetApp().GetPageSetupDialogData(); |
|---|
| 595 | wxPrintDialogData pd(psdd->GetPrintData()); |
|---|
| 596 | wxPrinter pr(&pd); |
|---|
| 597 | svxPrintout po(mainfrm, &m_layout, psdd, m_File); |
|---|
| 598 | if (pr.Print(this, &po, true)) { |
|---|
| 599 | // Close the print dialog if printing succeeded. |
|---|
| 600 | Destroy(); |
|---|
| 601 | } |
|---|
| 602 | } |
|---|
| 603 | |
|---|
| 604 | void |
|---|
| 605 | svxPrintDlg::OnExport(wxCommandEvent&) { |
|---|
| 606 | UIToLayout(); |
|---|
| 607 | TransferDataFromWindow(); |
|---|
| 608 | wxString leaf; |
|---|
| 609 | wxFileName::SplitPath(m_File, NULL, NULL, &leaf, NULL, wxPATH_NATIVE); |
|---|
| 610 | unsigned format_idx = ((wxChoice*)FindWindow(svx_FORMAT))->GetSelection(); |
|---|
| 611 | leaf += wxString::FromUTF8(extension[format_idx]); |
|---|
| 612 | |
|---|
| 613 | wxString filespec = wmsg(msg_filetype[format_idx]); |
|---|
| 614 | filespec += wxT("|*"); |
|---|
| 615 | filespec += wxString::FromUTF8(extension[format_idx]); |
|---|
| 616 | filespec += wxT("|"); |
|---|
| 617 | filespec += wmsg(/*All files*/208); |
|---|
| 618 | filespec += wxT("|"); |
|---|
| 619 | filespec += wxFileSelectorDefaultWildcardStr; |
|---|
| 620 | |
|---|
| 621 | /* TRANSLATORS: Title of file dialog to choose name and type of exported |
|---|
| 622 | * file. */ |
|---|
| 623 | wxFileDialog dlg(this, wmsg(/*Export as:*/401), wxString(), leaf, |
|---|
| 624 | filespec, wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
|---|
| 625 | if (dlg.ShowModal() == wxID_OK) { |
|---|
| 626 | wxString input_projection = ((wxTextCtrl*)FindWindow(svx_PROJ))->GetValue(); |
|---|
| 627 | double grid = 100; // metres |
|---|
| 628 | double text_height = 0.6; |
|---|
| 629 | double marker_size = 0.8; |
|---|
| 630 | |
|---|
| 631 | try { |
|---|
| 632 | if (!Export(dlg.GetPath(), m_layout.title, |
|---|
| 633 | m_layout.datestamp, m_layout.datestamp_numeric, mainfrm, |
|---|
| 634 | m_layout.rot, m_layout.tilt, m_layout.show_mask, |
|---|
| 635 | export_format(format_idx), input_projection.mb_str(), |
|---|
| 636 | grid, text_height, marker_size)) { |
|---|
| 637 | wxString m = wxString::Format(wmsg(/*Couldn’t write file “%s”*/402).c_str(), |
|---|
| 638 | m_File.c_str()); |
|---|
| 639 | wxGetApp().ReportError(m); |
|---|
| 640 | } |
|---|
| 641 | } catch (const wxString & m) { |
|---|
| 642 | wxGetApp().ReportError(m); |
|---|
| 643 | } |
|---|
| 644 | } |
|---|
| 645 | Destroy(); |
|---|
| 646 | } |
|---|
| 647 | |
|---|
| 648 | #ifdef AVEN_PRINT_PREVIEW |
|---|
| 649 | void |
|---|
| 650 | svxPrintDlg::OnPreview(wxCommandEvent&) { |
|---|
| 651 | SomethingChanged(0); |
|---|
| 652 | TransferDataFromWindow(); |
|---|
| 653 | wxPageSetupDialogData * psdd = wxGetApp().GetPageSetupDialogData(); |
|---|
| 654 | wxPrintDialogData pd(psdd->GetPrintData()); |
|---|
| 655 | wxPrintPreview* pv; |
|---|
| 656 | pv = new wxPrintPreview(new svxPrintout(mainfrm, &m_layout, psdd, m_File), |
|---|
| 657 | new svxPrintout(mainfrm, &m_layout, psdd, m_File), |
|---|
| 658 | &pd); |
|---|
| 659 | // TRANSLATORS: Title of the print preview dialog |
|---|
| 660 | wxPreviewFrame *frame = new wxPreviewFrame(pv, mainfrm, wmsg(/*Print Preview*/398)); |
|---|
| 661 | frame->Initialize(); |
|---|
| 662 | |
|---|
| 663 | // Size preview frame so that all of the controlbar and canvas can be seen |
|---|
| 664 | // if possible. |
|---|
| 665 | int w, h; |
|---|
| 666 | // GetBestSize gives us the width needed to show the whole controlbar. |
|---|
| 667 | frame->GetBestSize(&w, &h); |
|---|
| 668 | #ifdef __WXMAC__ |
|---|
| 669 | // wxMac opens the preview window at minimum size by default. |
|---|
| 670 | // 360x480 is apparently enough to show A4 portrait. |
|---|
| 671 | if (h < 480 || w < 360) { |
|---|
| 672 | if (h < 480) h = 480; |
|---|
| 673 | if (w < 360) w = 360; |
|---|
| 674 | } |
|---|
| 675 | #else |
|---|
| 676 | if (h < w) { |
|---|
| 677 | // On wxGTK at least, GetBestSize() returns much too small a height. |
|---|
| 678 | h = w * 6 / 5; |
|---|
| 679 | } |
|---|
| 680 | #endif |
|---|
| 681 | // Ensure that we don't make the window bigger than the screen. |
|---|
| 682 | // Use wxGetClientDisplayRect() so we don't cover the MS Windows |
|---|
| 683 | // task bar either. |
|---|
| 684 | wxRect disp = wxGetClientDisplayRect(); |
|---|
| 685 | if (w > disp.GetWidth()) w = disp.GetWidth(); |
|---|
| 686 | if (h > disp.GetHeight()) h = disp.GetHeight(); |
|---|
| 687 | // Centre the window within the "ClientDisplayRect". |
|---|
| 688 | int x = disp.GetLeft() + (disp.GetWidth() - w) / 2; |
|---|
| 689 | int y = disp.GetTop() + (disp.GetHeight() - h) / 2; |
|---|
| 690 | frame->SetSize(x, y, w, h); |
|---|
| 691 | |
|---|
| 692 | frame->Show(); |
|---|
| 693 | } |
|---|
| 694 | #endif |
|---|
| 695 | |
|---|
| 696 | void |
|---|
| 697 | svxPrintDlg::OnPlan(wxCommandEvent&) { |
|---|
| 698 | m_tilt->SetValue(-90); |
|---|
| 699 | SomethingChanged(svx_TILT); |
|---|
| 700 | } |
|---|
| 701 | |
|---|
| 702 | void |
|---|
| 703 | svxPrintDlg::OnElevation(wxCommandEvent&) { |
|---|
| 704 | m_tilt->SetValue(0); |
|---|
| 705 | SomethingChanged(svx_TILT); |
|---|
| 706 | } |
|---|
| 707 | |
|---|
| 708 | void |
|---|
| 709 | svxPrintDlg::OnPlanUpdate(wxUpdateUIEvent& e) { |
|---|
| 710 | e.Enable(m_tilt->GetValue() != -90); |
|---|
| 711 | } |
|---|
| 712 | |
|---|
| 713 | void |
|---|
| 714 | svxPrintDlg::OnElevationUpdate(wxUpdateUIEvent& e) { |
|---|
| 715 | e.Enable(m_tilt->GetValue() != 0); |
|---|
| 716 | } |
|---|
| 717 | |
|---|
| 718 | void |
|---|
| 719 | svxPrintDlg::OnChangeSpin(wxSpinEvent& e) { |
|---|
| 720 | SomethingChanged(e.GetId()); |
|---|
| 721 | } |
|---|
| 722 | |
|---|
| 723 | void |
|---|
| 724 | svxPrintDlg::OnChange(wxCommandEvent& e) { |
|---|
| 725 | SomethingChanged(e.GetId()); |
|---|
| 726 | } |
|---|
| 727 | |
|---|
| 728 | void |
|---|
| 729 | svxPrintDlg::OnCancel(wxCommandEvent&) { |
|---|
| 730 | if (close_after) |
|---|
| 731 | mainfrm->Close(); |
|---|
| 732 | Destroy(); |
|---|
| 733 | } |
|---|
| 734 | |
|---|
| 735 | void |
|---|
| 736 | svxPrintDlg::SomethingChanged(int control_id) { |
|---|
| 737 | if ((control_id == 0 || control_id == svx_FORMAT) && m_format) { |
|---|
| 738 | // Update the shown/hidden fields for the newly selected export filter. |
|---|
| 739 | int new_filter_idx = m_format->GetSelection(); |
|---|
| 740 | if (new_filter_idx != wxNOT_FOUND) { |
|---|
| 741 | unsigned mask = format_info[new_filter_idx]; |
|---|
| 742 | static const struct { int id; unsigned mask; } controls[] = { |
|---|
| 743 | { svx_LEGS, LEGS }, |
|---|
| 744 | { svx_SURFACE, SURF }, |
|---|
| 745 | { svx_STATIONS, STNS }, |
|---|
| 746 | { svx_NAMES, LABELS }, |
|---|
| 747 | { svx_XSECT, XSECT }, |
|---|
| 748 | { svx_WALLS, WALLS }, |
|---|
| 749 | { svx_PASSAGES, PASG }, |
|---|
| 750 | { svx_ENTS, ENTS }, |
|---|
| 751 | { svx_FIXES, FIXES }, |
|---|
| 752 | { svx_EXPORTS, EXPORTS }, |
|---|
| 753 | { svx_CENTRED, CENTRED }, |
|---|
| 754 | { svx_FULLCOORDS, FULL_COORDS }, |
|---|
| 755 | { svx_PROJ_LABEL, PROJ }, |
|---|
| 756 | { svx_PROJ, PROJ }, |
|---|
| 757 | }; |
|---|
| 758 | static unsigned n_controls = sizeof(controls) / sizeof(controls[0]); |
|---|
| 759 | for (unsigned i = 0; i != n_controls; ++i) { |
|---|
| 760 | wxWindow * control = FindWindow(controls[i].id); |
|---|
| 761 | if (control) control->Show(mask & controls[i].mask); |
|---|
| 762 | } |
|---|
| 763 | m_scalebox->Show(bool(mask & SCALE)); |
|---|
| 764 | m_viewbox->Show(!bool(mask & EXPORT_3D)); |
|---|
| 765 | GetSizer()->Layout(); |
|---|
| 766 | if (control_id == svx_FORMAT) { |
|---|
| 767 | wxConfigBase * cfg = wxConfigBase::Get(); |
|---|
| 768 | cfg->Write(wxT("export_format"), formats[new_filter_idx]); |
|---|
| 769 | } |
|---|
| 770 | } |
|---|
| 771 | } |
|---|
| 772 | |
|---|
| 773 | UIToLayout(); |
|---|
| 774 | if (!m_printSize) return; |
|---|
| 775 | // Update the bounding box. |
|---|
| 776 | RecalcBounds(); |
|---|
| 777 | |
|---|
| 778 | if (m_scale) { |
|---|
| 779 | (m_scale->GetValue()).ToDouble(&(m_layout.Scale)); |
|---|
| 780 | if (m_layout.Scale == 0.0) { |
|---|
| 781 | m_layout.pick_scale(1, 1); |
|---|
| 782 | } |
|---|
| 783 | } |
|---|
| 784 | |
|---|
| 785 | if (m_layout.xMax >= m_layout.xMin) { |
|---|
| 786 | m_layout.pages_required(); |
|---|
| 787 | m_printSize->SetLabel(wxString::Format(wmsg(/*%d pages (%dx%d)*/257), m_layout.pages, m_layout.pagesX, m_layout.pagesY)); |
|---|
| 788 | } |
|---|
| 789 | } |
|---|
| 790 | |
|---|
| 791 | void |
|---|
| 792 | svxPrintDlg::LayoutToUI(){ |
|---|
| 793 | // m_blanks->SetValue(m_layout.SkipBlank); |
|---|
| 794 | if (m_layout.view != layout::EXTELEV) { |
|---|
| 795 | m_tilt->SetValue(m_layout.tilt); |
|---|
| 796 | m_bearing->SetValue(m_layout.rot); |
|---|
| 797 | } |
|---|
| 798 | |
|---|
| 799 | // Do this last as it causes an OnChange message which calls UIToLayout |
|---|
| 800 | if (m_scale) { |
|---|
| 801 | if (m_layout.Scale != 0) { |
|---|
| 802 | wxString temp; |
|---|
| 803 | temp << m_layout.Scale; |
|---|
| 804 | m_scale->SetValue(temp); |
|---|
| 805 | } else { |
|---|
| 806 | if (scales[0].empty()) scales[0].assign(wmsg(/*One page*/258)); |
|---|
| 807 | m_scale->SetValue(scales[0]); |
|---|
| 808 | } |
|---|
| 809 | } |
|---|
| 810 | } |
|---|
| 811 | |
|---|
| 812 | void |
|---|
| 813 | svxPrintDlg::UIToLayout(){ |
|---|
| 814 | // m_layout.SkipBlank = m_blanks->IsChecked(); |
|---|
| 815 | |
|---|
| 816 | if (m_layout.view != layout::EXTELEV && m_tilt) { |
|---|
| 817 | m_layout.tilt = m_tilt->GetValue(); |
|---|
| 818 | if (m_layout.tilt == -90) { |
|---|
| 819 | m_layout.view = layout::PLAN; |
|---|
| 820 | } else if (m_layout.tilt == 0) { |
|---|
| 821 | m_layout.view = layout::ELEV; |
|---|
| 822 | } else { |
|---|
| 823 | m_layout.view = layout::TILT; |
|---|
| 824 | } |
|---|
| 825 | |
|---|
| 826 | bool enable_passage_opts = (m_layout.view != layout::TILT); |
|---|
| 827 | wxWindow * win; |
|---|
| 828 | win = FindWindow(svx_XSECT); |
|---|
| 829 | if (win) win->Enable(enable_passage_opts); |
|---|
| 830 | win = FindWindow(svx_WALLS); |
|---|
| 831 | if (win) win->Enable(enable_passage_opts); |
|---|
| 832 | win = FindWindow(svx_PASSAGES); |
|---|
| 833 | if (win) win->Enable(enable_passage_opts); |
|---|
| 834 | |
|---|
| 835 | m_layout.rot = m_bearing->GetValue(); |
|---|
| 836 | } |
|---|
| 837 | } |
|---|
| 838 | |
|---|
| 839 | void |
|---|
| 840 | svxPrintDlg::RecalcBounds() |
|---|
| 841 | { |
|---|
| 842 | m_layout.yMax = m_layout.xMax = -DBL_MAX; |
|---|
| 843 | m_layout.yMin = m_layout.xMin = DBL_MAX; |
|---|
| 844 | |
|---|
| 845 | double SIN = sin(rad(m_layout.rot)); |
|---|
| 846 | double COS = cos(rad(m_layout.rot)); |
|---|
| 847 | double SINT = sin(rad(m_layout.tilt)); |
|---|
| 848 | double COST = cos(rad(m_layout.tilt)); |
|---|
| 849 | |
|---|
| 850 | if (m_layout.show_mask & LEGS) { |
|---|
| 851 | list<traverse>::const_iterator trav = mainfrm->traverses_begin(); |
|---|
| 852 | list<traverse>::const_iterator tend = mainfrm->traverses_end(); |
|---|
| 853 | for ( ; trav != tend; ++trav) { |
|---|
| 854 | vector<PointInfo>::const_iterator pos = trav->begin(); |
|---|
| 855 | vector<PointInfo>::const_iterator end = trav->end(); |
|---|
| 856 | for ( ; pos != end; ++pos) { |
|---|
| 857 | double x = pos->GetX(); |
|---|
| 858 | double y = pos->GetY(); |
|---|
| 859 | double z = pos->GetZ(); |
|---|
| 860 | double X = x * COS - y * SIN; |
|---|
| 861 | if (X > m_layout.xMax) m_layout.xMax = X; |
|---|
| 862 | if (X < m_layout.xMin) m_layout.xMin = X; |
|---|
| 863 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
|---|
| 864 | if (Y > m_layout.yMax) m_layout.yMax = Y; |
|---|
| 865 | if (Y < m_layout.yMin) m_layout.yMin = Y; |
|---|
| 866 | } |
|---|
| 867 | } |
|---|
| 868 | } |
|---|
| 869 | if (m_layout.show_mask & SURF) { |
|---|
| 870 | list<traverse>::const_iterator trav = mainfrm->surface_traverses_begin(); |
|---|
| 871 | list<traverse>::const_iterator tend = mainfrm->surface_traverses_end(); |
|---|
| 872 | for ( ; trav != tend; ++trav) { |
|---|
| 873 | vector<PointInfo>::const_iterator pos = trav->begin(); |
|---|
| 874 | vector<PointInfo>::const_iterator end = trav->end(); |
|---|
| 875 | for ( ; pos != end; ++pos) { |
|---|
| 876 | double x = pos->GetX(); |
|---|
| 877 | double y = pos->GetY(); |
|---|
| 878 | double z = pos->GetZ(); |
|---|
| 879 | double X = x * COS - y * SIN; |
|---|
| 880 | if (X > m_layout.xMax) m_layout.xMax = X; |
|---|
| 881 | if (X < m_layout.xMin) m_layout.xMin = X; |
|---|
| 882 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
|---|
| 883 | if (Y > m_layout.yMax) m_layout.yMax = Y; |
|---|
| 884 | if (Y < m_layout.yMin) m_layout.yMin = Y; |
|---|
| 885 | } |
|---|
| 886 | } |
|---|
| 887 | } |
|---|
| 888 | if (m_layout.show_mask & (LABELS|STNS)) { |
|---|
| 889 | list<LabelInfo*>::const_iterator label = mainfrm->GetLabels(); |
|---|
| 890 | while (label != mainfrm->GetLabelsEnd()) { |
|---|
| 891 | double x = (*label)->GetX(); |
|---|
| 892 | double y = (*label)->GetY(); |
|---|
| 893 | double z = (*label)->GetZ(); |
|---|
| 894 | if ((m_layout.show_mask & SURF) || (*label)->IsUnderground()) { |
|---|
| 895 | double X = x * COS - y * SIN; |
|---|
| 896 | if (X > m_layout.xMax) m_layout.xMax = X; |
|---|
| 897 | if (X < m_layout.xMin) m_layout.xMin = X; |
|---|
| 898 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
|---|
| 899 | if (Y > m_layout.yMax) m_layout.yMax = Y; |
|---|
| 900 | if (Y < m_layout.yMin) m_layout.yMin = Y; |
|---|
| 901 | } |
|---|
| 902 | ++label; |
|---|
| 903 | } |
|---|
| 904 | } |
|---|
| 905 | } |
|---|
| 906 | |
|---|
| 907 | static int xpPageWidth, ypPageDepth; |
|---|
| 908 | static long MarginLeft, MarginRight, MarginTop, MarginBottom; |
|---|
| 909 | static long x_offset, y_offset; |
|---|
| 910 | static wxFont *font_labels, *font_default; |
|---|
| 911 | static int fontsize, fontsize_labels; |
|---|
| 912 | |
|---|
| 913 | /* FIXME: allow the font to be set */ |
|---|
| 914 | |
|---|
| 915 | static const char *fontname = "Arial", *fontname_labels = "Arial"; |
|---|
| 916 | |
|---|
| 917 | // wx <-> prcore (calls to print_page etc...) |
|---|
| 918 | svxPrintout::svxPrintout(MainFrm *mainfrm_, layout *l, |
|---|
| 919 | wxPageSetupDialogData *data, const wxString & title) |
|---|
| 920 | : wxPrintout(title) |
|---|
| 921 | { |
|---|
| 922 | mainfrm = mainfrm_; |
|---|
| 923 | m_layout = l; |
|---|
| 924 | m_data = data; |
|---|
| 925 | } |
|---|
| 926 | |
|---|
| 927 | void |
|---|
| 928 | svxPrintout::draw_info_box() |
|---|
| 929 | { |
|---|
| 930 | layout *l = m_layout; |
|---|
| 931 | int boxwidth = 70; |
|---|
| 932 | int boxheight = 30; |
|---|
| 933 | |
|---|
| 934 | SetColour(PR_COLOUR_FRAME); |
|---|
| 935 | |
|---|
| 936 | int div = boxwidth; |
|---|
| 937 | if (l->view != layout::EXTELEV) { |
|---|
| 938 | boxwidth += boxheight; |
|---|
| 939 | MOVEMM(div, boxheight); |
|---|
| 940 | DRAWMM(div, 0); |
|---|
| 941 | MOVEMM(0, 30); DRAWMM(div, 30); |
|---|
| 942 | } |
|---|
| 943 | |
|---|
| 944 | MOVEMM(0, boxheight); |
|---|
| 945 | DRAWMM(boxwidth, boxheight); |
|---|
| 946 | DRAWMM(boxwidth, 0); |
|---|
| 947 | if (!l->Border) { |
|---|
| 948 | DRAWMM(0, 0); |
|---|
| 949 | DRAWMM(0, boxheight); |
|---|
| 950 | } |
|---|
| 951 | |
|---|
| 952 | MOVEMM(0, 20); DRAWMM(div, 20); |
|---|
| 953 | MOVEMM(0, 10); DRAWMM(div, 10); |
|---|
| 954 | |
|---|
| 955 | switch (l->view) { |
|---|
| 956 | case layout::PLAN: { |
|---|
| 957 | long ax, ay, bx, by, cx, cy, dx, dy; |
|---|
| 958 | |
|---|
| 959 | long xc = boxwidth - boxheight / 2; |
|---|
| 960 | long yc = boxheight / 2; |
|---|
| 961 | const double RADIUS = boxheight / 3; |
|---|
| 962 | DrawEllipse(long(xc * l->scX), long(yc * l->scY), |
|---|
| 963 | long(RADIUS * l->scX), long(RADIUS * l->scY)); |
|---|
| 964 | |
|---|
| 965 | ax = (long)((xc - (RADIUS - 1) * sin(rad(000.0 + l->rot))) * l->scX); |
|---|
| 966 | ay = (long)((yc + (RADIUS - 1) * cos(rad(000.0 + l->rot))) * l->scY); |
|---|
| 967 | bx = (long)((xc - RADIUS * 0.5 * sin(rad(180.0 + l->rot))) * l->scX); |
|---|
| 968 | by = (long)((yc + RADIUS * 0.5 * cos(rad(180.0 + l->rot))) * l->scY); |
|---|
| 969 | cx = (long)((xc - (RADIUS - 1) * sin(rad(160.0 + l->rot))) * l->scX); |
|---|
| 970 | cy = (long)((yc + (RADIUS - 1) * cos(rad(160.0 + l->rot))) * l->scY); |
|---|
| 971 | dx = (long)((xc - (RADIUS - 1) * sin(rad(200.0 + l->rot))) * l->scX); |
|---|
| 972 | dy = (long)((yc + (RADIUS - 1) * cos(rad(200.0 + l->rot))) * l->scY); |
|---|
| 973 | |
|---|
| 974 | MoveTo(ax, ay); |
|---|
| 975 | DrawTo(bx, by); |
|---|
| 976 | DrawTo(cx, cy); |
|---|
| 977 | DrawTo(ax, ay); |
|---|
| 978 | DrawTo(dx, dy); |
|---|
| 979 | DrawTo(bx, by); |
|---|
| 980 | |
|---|
| 981 | SetColour(PR_COLOUR_TEXT); |
|---|
| 982 | MOVEMM(div + 0.5, boxheight - 5.5); |
|---|
| 983 | WriteString(wmsg(/*North*/115)); |
|---|
| 984 | |
|---|
| 985 | wxString angle; |
|---|
| 986 | angle.Printf(wxT("%03d"), l->rot); |
|---|
| 987 | angle += wmsg(/*°*/344); |
|---|
| 988 | wxString s; |
|---|
| 989 | /* TRANSLATORS: This is used on printouts of plans, with %s replaced by |
|---|
| 990 | * something like "123°". The bearing is up the page. */ |
|---|
| 991 | s.Printf(wmsg(/*Plan view, %s up page*/168), angle.c_str()); |
|---|
| 992 | MOVEMM(2, 12); WriteString(s); |
|---|
| 993 | break; |
|---|
| 994 | } |
|---|
| 995 | case layout::ELEV: case layout::TILT: { |
|---|
| 996 | const int L = div + 2; |
|---|
| 997 | const int R = boxwidth - 2; |
|---|
| 998 | const int H = boxheight / 2; |
|---|
| 999 | MOVEMM(L, H); DRAWMM(L + 5, H - 3); DRAWMM(L + 3, H); DRAWMM(L + 5, H + 3); |
|---|
| 1000 | |
|---|
| 1001 | DRAWMM(L, H); DRAWMM(R, H); |
|---|
| 1002 | |
|---|
| 1003 | DRAWMM(R - 5, H + 3); DRAWMM(R - 3, H); DRAWMM(R - 5, H - 3); DRAWMM(R, H); |
|---|
| 1004 | |
|---|
| 1005 | MOVEMM((L + R) / 2, H - 2); DRAWMM((L + R) / 2, H + 2); |
|---|
| 1006 | |
|---|
| 1007 | SetColour(PR_COLOUR_TEXT); |
|---|
| 1008 | MOVEMM(div + 2, boxheight - 8); |
|---|
| 1009 | /* TRANSLATORS: "Elevation on" 020 <-> 200 degrees */ |
|---|
| 1010 | WriteString(wmsg(/*Elevation on*/116)); |
|---|
| 1011 | |
|---|
| 1012 | MOVEMM(L, 2); |
|---|
| 1013 | WriteString(wxString::Format(wxT("%03d%s"), |
|---|
| 1014 | (l->rot + 270) % 360, |
|---|
| 1015 | wmsg(/*°*/344).c_str())); |
|---|
| 1016 | MOVEMM(R - 10, 2); |
|---|
| 1017 | WriteString(wxString::Format(wxT("%03d%s"), |
|---|
| 1018 | (l->rot + 90) % 360, |
|---|
| 1019 | wmsg(/*°*/344).c_str())); |
|---|
| 1020 | |
|---|
| 1021 | wxString angle; |
|---|
| 1022 | angle.Printf(wxT("%03d"), l->rot); |
|---|
| 1023 | angle += wmsg(/*°*/344); |
|---|
| 1024 | wxString s; |
|---|
| 1025 | if (l->view == layout::ELEV) { |
|---|
| 1026 | /* TRANSLATORS: This is used on printouts of elevations, with %s |
|---|
| 1027 | * replaced by something like "123°". The bearing is the direction |
|---|
| 1028 | * we’re looking. */ |
|---|
| 1029 | s.Printf(wmsg(/*Elevation facing %s*/169), angle.c_str()); |
|---|
| 1030 | } else { |
|---|
| 1031 | wxString a2; |
|---|
| 1032 | a2.Printf(wxT("%d"), l->tilt); |
|---|
| 1033 | a2 += wmsg(/*°*/344); |
|---|
| 1034 | /* TRANSLATORS: This is used on printouts of tilted elevations, with |
|---|
| 1035 | * the first %s replaced by something like "123°", and the second by |
|---|
| 1036 | * something like "-45°". The bearing is the direction we’re |
|---|
| 1037 | * looking. */ |
|---|
| 1038 | s.Printf(wmsg(/*Elevation facing %s, tilted %s*/284), angle.c_str(), a2.c_str()); |
|---|
| 1039 | } |
|---|
| 1040 | MOVEMM(2, 12); WriteString(s); |
|---|
| 1041 | break; |
|---|
| 1042 | } |
|---|
| 1043 | case layout::EXTELEV: |
|---|
| 1044 | SetColour(PR_COLOUR_TEXT); |
|---|
| 1045 | MOVEMM(2, 12); |
|---|
| 1046 | /* TRANSLATORS: This is used on printouts of extended elevations. */ |
|---|
| 1047 | WriteString(wmsg(/*Extended elevation*/191)); |
|---|
| 1048 | break; |
|---|
| 1049 | } |
|---|
| 1050 | |
|---|
| 1051 | MOVEMM(2, boxheight - 8); WriteString(l->title); |
|---|
| 1052 | |
|---|
| 1053 | MOVEMM(2, 2); |
|---|
| 1054 | // FIXME: "Original Scale" better? |
|---|
| 1055 | WriteString(wxString::Format(wmsg(/*Scale*/154) + wxT(" 1:%.0f"), |
|---|
| 1056 | l->Scale)); |
|---|
| 1057 | |
|---|
| 1058 | /* This used to be a copyright line, but it was occasionally |
|---|
| 1059 | * mis-interpreted as us claiming copyright on the survey, so let's |
|---|
| 1060 | * give the website URL instead */ |
|---|
| 1061 | MOVEMM(boxwidth + 2, 2); |
|---|
| 1062 | WriteString(wxT("Survex "VERSION" - http://survex.com/")); |
|---|
| 1063 | |
|---|
| 1064 | draw_scale_bar(boxwidth + 10.0, 17.0, l->PaperWidth - boxwidth - 18.0); |
|---|
| 1065 | } |
|---|
| 1066 | |
|---|
| 1067 | /* Draw fancy scale bar with bottom left at (x,y) (both in mm) and at most */ |
|---|
| 1068 | /* MaxLength mm long. The scaling in use is 1:scale */ |
|---|
| 1069 | void |
|---|
| 1070 | svxPrintout::draw_scale_bar(double x, double y, double MaxLength) |
|---|
| 1071 | { |
|---|
| 1072 | double StepEst, d; |
|---|
| 1073 | int E, Step, n, c; |
|---|
| 1074 | wxString buf; |
|---|
| 1075 | /* Limit scalebar to 20cm to stop people with A0 plotters complaining */ |
|---|
| 1076 | if (MaxLength > 200.0) MaxLength = 200.0; |
|---|
| 1077 | |
|---|
| 1078 | #define dmin 10.0 /* each division >= dmin mm long */ |
|---|
| 1079 | #define StepMax 5 /* number in steps of at most StepMax (x 10^N) */ |
|---|
| 1080 | #define epsilon (1e-4) /* fudge factor to prevent rounding problems */ |
|---|
| 1081 | |
|---|
| 1082 | E = (int)ceil(log10((dmin * 0.001 * m_layout->Scale) / StepMax)); |
|---|
| 1083 | StepEst = pow(10.0, -(double)E) * (dmin * 0.001) * m_layout->Scale - epsilon; |
|---|
| 1084 | |
|---|
| 1085 | /* Force labelling to be in multiples of 1, 2, or 5 */ |
|---|
| 1086 | Step = (StepEst <= 1.0 ? 1 : (StepEst <= 2.0 ? 2 : 5)); |
|---|
| 1087 | |
|---|
| 1088 | /* Work out actual length of each scale bar division */ |
|---|
| 1089 | d = Step * pow(10.0, (double)E) / m_layout->Scale * 1000.0; |
|---|
| 1090 | |
|---|
| 1091 | /* FIXME: Non-metric units here... */ |
|---|
| 1092 | /* Choose appropriate units, s.t. if possible E is >=0 and minimized */ |
|---|
| 1093 | int units; |
|---|
| 1094 | if (E >= 3) { |
|---|
| 1095 | E -= 3; |
|---|
| 1096 | units = /*km*/423; |
|---|
| 1097 | } else if (E >= 0) { |
|---|
| 1098 | units = /*m*/424; |
|---|
| 1099 | } else { |
|---|
| 1100 | E += 2; |
|---|
| 1101 | units = /*cm*/425; |
|---|
| 1102 | } |
|---|
| 1103 | |
|---|
| 1104 | buf = wmsg(/*Scale*/154); |
|---|
| 1105 | |
|---|
| 1106 | /* Add units used - eg. "Scale (10m)" */ |
|---|
| 1107 | double pow10_E = pow(10.0, (double)E); |
|---|
| 1108 | if (E >= 0) { |
|---|
| 1109 | buf += wxString::Format(wxT(" (%.f%s)"), pow10_E, wmsg(units).c_str()); |
|---|
| 1110 | } else { |
|---|
| 1111 | int sf = -(int)floor(E); |
|---|
| 1112 | buf += wxString::Format(wxT(" (%.*f%s)"), sf, pow10_E, wmsg(units).c_str()); |
|---|
| 1113 | } |
|---|
| 1114 | SetColour(PR_COLOUR_TEXT); |
|---|
| 1115 | MOVEMM(x, y + 4); WriteString(buf); |
|---|
| 1116 | |
|---|
| 1117 | /* Work out how many divisions there will be */ |
|---|
| 1118 | n = (int)(MaxLength / d); |
|---|
| 1119 | |
|---|
| 1120 | SetColour(PR_COLOUR_FRAME); |
|---|
| 1121 | |
|---|
| 1122 | long Y = long(y * m_layout->scY); |
|---|
| 1123 | long Y2 = long((y + 3) * m_layout->scY); |
|---|
| 1124 | long X = long(x * m_layout->scX); |
|---|
| 1125 | long X2 = long((x + n * d) * m_layout->scX); |
|---|
| 1126 | |
|---|
| 1127 | /* Draw top of scale bar */ |
|---|
| 1128 | MoveTo(X2, Y2); |
|---|
| 1129 | DrawTo(X, Y2); |
|---|
| 1130 | #if 0 |
|---|
| 1131 | DrawTo(X2, Y); |
|---|
| 1132 | DrawTo(X, Y); |
|---|
| 1133 | MOVEMM(x + n * d, y); DRAWMM(x, y); |
|---|
| 1134 | #endif |
|---|
| 1135 | /* Draw divisions and label them */ |
|---|
| 1136 | for (c = 0; c <= n; c++) { |
|---|
| 1137 | SetColour(PR_COLOUR_FRAME); |
|---|
| 1138 | X = long((x + c * d) * m_layout->scX); |
|---|
| 1139 | MoveTo(X, Y); |
|---|
| 1140 | DrawTo(X, Y2); |
|---|
| 1141 | #if 0 // Don't waste toner! |
|---|
| 1142 | /* Draw a "zebra crossing" scale bar. */ |
|---|
| 1143 | if (c < n && (c & 1) == 0) { |
|---|
| 1144 | X2 = long((x + (c + 1) * d) * m_layout->scX); |
|---|
| 1145 | SolidRectangle(X, Y, X2 - X, Y2 - Y); |
|---|
| 1146 | } |
|---|
| 1147 | #endif |
|---|
| 1148 | buf.Printf(wxT("%d"), c * Step); |
|---|
| 1149 | SetColour(PR_COLOUR_TEXT); |
|---|
| 1150 | MOVEMM(x + c * d - buf.length(), y - 5); |
|---|
| 1151 | WriteString(buf); |
|---|
| 1152 | } |
|---|
| 1153 | } |
|---|
| 1154 | |
|---|
| 1155 | #if 0 |
|---|
| 1156 | void |
|---|
| 1157 | make_calibration(layout *l) { |
|---|
| 1158 | img_point pt = { 0.0, 0.0, 0.0 }; |
|---|
| 1159 | l->xMax = l->yMax = 0.1; |
|---|
| 1160 | l->xMin = l->yMin = 0; |
|---|
| 1161 | |
|---|
| 1162 | stack(l,img_MOVE, NULL, &pt); |
|---|
| 1163 | pt.x = 0.1; |
|---|
| 1164 | stack(l,img_LINE, NULL, &pt); |
|---|
| 1165 | pt.y = 0.1; |
|---|
| 1166 | stack(l,img_LINE, NULL, &pt); |
|---|
| 1167 | pt.x = 0.0; |
|---|
| 1168 | stack(l,img_LINE, NULL, &pt); |
|---|
| 1169 | pt.y = 0.0; |
|---|
| 1170 | stack(l,img_LINE, NULL, &pt); |
|---|
| 1171 | pt.x = 0.05; |
|---|
| 1172 | pt.y = 0.001; |
|---|
| 1173 | stack(l,img_LABEL, "10cm", &pt); |
|---|
| 1174 | pt.x = 0.001; |
|---|
| 1175 | pt.y = 0.05; |
|---|
| 1176 | stack(l,img_LABEL, "10cm", &pt); |
|---|
| 1177 | l->Scale = 1.0; |
|---|
| 1178 | } |
|---|
| 1179 | #endif |
|---|
| 1180 | |
|---|
| 1181 | int |
|---|
| 1182 | svxPrintout::next_page(int *pstate, char **q, int pageLim) |
|---|
| 1183 | { |
|---|
| 1184 | char *p; |
|---|
| 1185 | int page; |
|---|
| 1186 | int c; |
|---|
| 1187 | p = *q; |
|---|
| 1188 | if (*pstate > 0) { |
|---|
| 1189 | /* doing a range */ |
|---|
| 1190 | (*pstate)++; |
|---|
| 1191 | SVX_ASSERT(*p == '-'); |
|---|
| 1192 | p++; |
|---|
| 1193 | while (isspace((unsigned char)*p)) p++; |
|---|
| 1194 | if (sscanf(p, "%u%n", &page, &c) > 0) { |
|---|
| 1195 | p += c; |
|---|
| 1196 | } else { |
|---|
| 1197 | page = pageLim; |
|---|
| 1198 | } |
|---|
| 1199 | if (*pstate > page) goto err; |
|---|
| 1200 | if (*pstate < page) return *pstate; |
|---|
| 1201 | *q = p; |
|---|
| 1202 | *pstate = 0; |
|---|
| 1203 | return page; |
|---|
| 1204 | } |
|---|
| 1205 | |
|---|
| 1206 | while (isspace((unsigned char)*p) || *p == ',') p++; |
|---|
| 1207 | |
|---|
| 1208 | if (!*p) return 0; /* done */ |
|---|
| 1209 | |
|---|
| 1210 | if (*p == '-') { |
|---|
| 1211 | *q = p; |
|---|
| 1212 | *pstate = 1; |
|---|
| 1213 | return 1; /* range with initial parameter omitted */ |
|---|
| 1214 | } |
|---|
| 1215 | if (sscanf(p, "%u%n", &page, &c) > 0) { |
|---|
| 1216 | p += c; |
|---|
| 1217 | while (isspace((unsigned char)*p)) p++; |
|---|
| 1218 | *q = p; |
|---|
| 1219 | if (0 < page && page <= pageLim) { |
|---|
| 1220 | if (*p == '-') *pstate = page; /* range with start */ |
|---|
| 1221 | return page; |
|---|
| 1222 | } |
|---|
| 1223 | } |
|---|
| 1224 | err: |
|---|
| 1225 | *pstate = -1; |
|---|
| 1226 | return 0; |
|---|
| 1227 | } |
|---|
| 1228 | |
|---|
| 1229 | /* Draws in alignment marks on each page or borders on edge pages */ |
|---|
| 1230 | void |
|---|
| 1231 | svxPrintout::drawticks(border clip, int tsize, int x, int y) |
|---|
| 1232 | { |
|---|
| 1233 | long i; |
|---|
| 1234 | int s = tsize * 4; |
|---|
| 1235 | int o = s / 8; |
|---|
| 1236 | bool fAtCorner = fFalse; |
|---|
| 1237 | SetColour(PR_COLOUR_FRAME); |
|---|
| 1238 | if (x == 0 && m_layout->Border) { |
|---|
| 1239 | /* solid left border */ |
|---|
| 1240 | MoveTo(clip.x_min, clip.y_min); |
|---|
| 1241 | DrawTo(clip.x_min, clip.y_max); |
|---|
| 1242 | fAtCorner = fTrue; |
|---|
| 1243 | } else { |
|---|
| 1244 | if (x > 0 || y > 0) { |
|---|
| 1245 | MoveTo(clip.x_min, clip.y_min); |
|---|
| 1246 | DrawTo(clip.x_min, clip.y_min + tsize); |
|---|
| 1247 | } |
|---|
| 1248 | if (s && x > 0 && m_layout->Cutlines) { |
|---|
| 1249 | /* dashed left border */ |
|---|
| 1250 | i = (clip.y_max - clip.y_min) - |
|---|
| 1251 | (tsize + ((clip.y_max - clip.y_min - tsize * 2L) % s) / 2); |
|---|
| 1252 | for ( ; i > tsize; i -= s) { |
|---|
| 1253 | MoveTo(clip.x_min, clip.y_max - (i + o)); |
|---|
| 1254 | DrawTo(clip.x_min, clip.y_max - (i - o)); |
|---|
| 1255 | } |
|---|
| 1256 | } |
|---|
| 1257 | if (x > 0 || y < m_layout->pagesY - 1) { |
|---|
| 1258 | MoveTo(clip.x_min, clip.y_max - tsize); |
|---|
| 1259 | DrawTo(clip.x_min, clip.y_max); |
|---|
| 1260 | fAtCorner = fTrue; |
|---|
| 1261 | } |
|---|
| 1262 | } |
|---|
| 1263 | |
|---|
| 1264 | if (y == m_layout->pagesY - 1 && m_layout->Border) { |
|---|
| 1265 | /* solid top border */ |
|---|
| 1266 | if (!fAtCorner) MoveTo(clip.x_min, clip.y_max); |
|---|
| 1267 | DrawTo(clip.x_max, clip.y_max); |
|---|
| 1268 | fAtCorner = fTrue; |
|---|
| 1269 | } else { |
|---|
| 1270 | if (y < m_layout->pagesY - 1 || x > 0) { |
|---|
| 1271 | if (!fAtCorner) MoveTo(clip.x_min, clip.y_max); |
|---|
| 1272 | DrawTo(clip.x_min + tsize, clip.y_max); |
|---|
| 1273 | } |
|---|
| 1274 | if (s && y < m_layout->pagesY - 1 && m_layout->Cutlines) { |
|---|
| 1275 | /* dashed top border */ |
|---|
| 1276 | i = (clip.x_max - clip.x_min) - |
|---|
| 1277 | (tsize + ((clip.x_max - clip.x_min - tsize * 2L) % s) / 2); |
|---|
| 1278 | for ( ; i > tsize; i -= s) { |
|---|
| 1279 | MoveTo(clip.x_max - (i + o), clip.y_max); |
|---|
| 1280 | DrawTo(clip.x_max - (i - o), clip.y_max); |
|---|
| 1281 | } |
|---|
| 1282 | } |
|---|
| 1283 | if (y < m_layout->pagesY - 1 || x < m_layout->pagesX - 1) { |
|---|
| 1284 | MoveTo(clip.x_max - tsize, clip.y_max); |
|---|
| 1285 | DrawTo(clip.x_max, clip.y_max); |
|---|
| 1286 | fAtCorner = fTrue; |
|---|
| 1287 | } else { |
|---|
| 1288 | fAtCorner = fFalse; |
|---|
| 1289 | } |
|---|
| 1290 | } |
|---|
| 1291 | |
|---|
| 1292 | if (x == m_layout->pagesX - 1 && m_layout->Border) { |
|---|
| 1293 | /* solid right border */ |
|---|
| 1294 | if (!fAtCorner) MoveTo(clip.x_max, clip.y_max); |
|---|
| 1295 | DrawTo(clip.x_max, clip.y_min); |
|---|
| 1296 | fAtCorner = fTrue; |
|---|
| 1297 | } else { |
|---|
| 1298 | if (x < m_layout->pagesX - 1 || y < m_layout->pagesY - 1) { |
|---|
| 1299 | if (!fAtCorner) MoveTo(clip.x_max, clip.y_max); |
|---|
| 1300 | DrawTo(clip.x_max, clip.y_max - tsize); |
|---|
| 1301 | } |
|---|
| 1302 | if (s && x < m_layout->pagesX - 1 && m_layout->Cutlines) { |
|---|
| 1303 | /* dashed right border */ |
|---|
| 1304 | i = (clip.y_max - clip.y_min) - |
|---|
| 1305 | (tsize + ((clip.y_max - clip.y_min - tsize * 2L) % s) / 2); |
|---|
| 1306 | for ( ; i > tsize; i -= s) { |
|---|
| 1307 | MoveTo(clip.x_max, clip.y_min + (i + o)); |
|---|
| 1308 | DrawTo(clip.x_max, clip.y_min + (i - o)); |
|---|
| 1309 | } |
|---|
| 1310 | } |
|---|
| 1311 | if (x < m_layout->pagesX - 1 || y > 0) { |
|---|
| 1312 | MoveTo(clip.x_max, clip.y_min + tsize); |
|---|
| 1313 | DrawTo(clip.x_max, clip.y_min); |
|---|
| 1314 | fAtCorner = fTrue; |
|---|
| 1315 | } else { |
|---|
| 1316 | fAtCorner = fFalse; |
|---|
| 1317 | } |
|---|
| 1318 | } |
|---|
| 1319 | |
|---|
| 1320 | if (y == 0 && m_layout->Border) { |
|---|
| 1321 | /* solid bottom border */ |
|---|
| 1322 | if (!fAtCorner) MoveTo(clip.x_max, clip.y_min); |
|---|
| 1323 | DrawTo(clip.x_min, clip.y_min); |
|---|
| 1324 | } else { |
|---|
| 1325 | if (y > 0 || x < m_layout->pagesX - 1) { |
|---|
| 1326 | if (!fAtCorner) MoveTo(clip.x_max, clip.y_min); |
|---|
| 1327 | DrawTo(clip.x_max - tsize, clip.y_min); |
|---|
| 1328 | } |
|---|
| 1329 | if (s && y > 0 && m_layout->Cutlines) { |
|---|
| 1330 | /* dashed bottom border */ |
|---|
| 1331 | i = (clip.x_max - clip.x_min) - |
|---|
| 1332 | (tsize + ((clip.x_max - clip.x_min - tsize * 2L) % s) / 2); |
|---|
| 1333 | for ( ; i > tsize; i -= s) { |
|---|
| 1334 | MoveTo(clip.x_min + (i + o), clip.y_min); |
|---|
| 1335 | DrawTo(clip.x_min + (i - o), clip.y_min); |
|---|
| 1336 | } |
|---|
| 1337 | } |
|---|
| 1338 | if (y > 0 || x > 0) { |
|---|
| 1339 | MoveTo(clip.x_min + tsize, clip.y_min); |
|---|
| 1340 | DrawTo(clip.x_min, clip.y_min); |
|---|
| 1341 | } |
|---|
| 1342 | } |
|---|
| 1343 | } |
|---|
| 1344 | |
|---|
| 1345 | bool |
|---|
| 1346 | svxPrintout::OnPrintPage(int pageNum) { |
|---|
| 1347 | GetPageSizePixels(&xpPageWidth, &ypPageDepth); |
|---|
| 1348 | pdc = GetDC(); |
|---|
| 1349 | #ifdef AVEN_PRINT_PREVIEW |
|---|
| 1350 | if (IsPreview()) { |
|---|
| 1351 | int dcx, dcy; |
|---|
| 1352 | pdc->GetSize(&dcx, &dcy); |
|---|
| 1353 | pdc->SetUserScale((double)dcx / xpPageWidth, (double)dcy / ypPageDepth); |
|---|
| 1354 | } |
|---|
| 1355 | #endif |
|---|
| 1356 | |
|---|
| 1357 | layout * l = m_layout; |
|---|
| 1358 | { |
|---|
| 1359 | int pwidth, pdepth; |
|---|
| 1360 | GetPageSizeMM(&pwidth, &pdepth); |
|---|
| 1361 | l->scX = (double)xpPageWidth / pwidth; |
|---|
| 1362 | l->scY = (double)ypPageDepth / pdepth; |
|---|
| 1363 | font_scaling_x = l->scX * (25.4 / 72.0); |
|---|
| 1364 | font_scaling_y = l->scY * (25.4 / 72.0); |
|---|
| 1365 | MarginLeft = m_data->GetMarginTopLeft().x; |
|---|
| 1366 | MarginTop = m_data->GetMarginTopLeft().y; |
|---|
| 1367 | MarginBottom = m_data->GetMarginBottomRight().y; |
|---|
| 1368 | MarginRight = m_data->GetMarginBottomRight().x; |
|---|
| 1369 | xpPageWidth -= (int)(l->scX * (MarginLeft + MarginRight)); |
|---|
| 1370 | ypPageDepth -= (int)(l->scY * (10 + MarginBottom + MarginRight)); |
|---|
| 1371 | // xpPageWidth -= 1; |
|---|
| 1372 | pdepth -= 10; |
|---|
| 1373 | x_offset = (long)(l->scX * MarginLeft); |
|---|
| 1374 | y_offset = (long)(l->scY * MarginTop); |
|---|
| 1375 | l->PaperWidth = pwidth -= MarginLeft + MarginRight; |
|---|
| 1376 | l->PaperDepth = pdepth -= MarginTop + MarginBottom; |
|---|
| 1377 | } |
|---|
| 1378 | |
|---|
| 1379 | double SIN = sin(rad(l->rot)); |
|---|
| 1380 | double COS = cos(rad(l->rot)); |
|---|
| 1381 | double SINT = sin(rad(l->tilt)); |
|---|
| 1382 | double COST = cos(rad(l->tilt)); |
|---|
| 1383 | |
|---|
| 1384 | NewPage(pageNum, l->pagesX, l->pagesY); |
|---|
| 1385 | |
|---|
| 1386 | if (l->Legend && pageNum == (l->pagesY - 1) * l->pagesX + 1) { |
|---|
| 1387 | SetFont(PR_FONT_DEFAULT); |
|---|
| 1388 | draw_info_box(); |
|---|
| 1389 | } |
|---|
| 1390 | |
|---|
| 1391 | pdc->SetClippingRegion(x_offset, y_offset,xpPageWidth+1, ypPageDepth+1); |
|---|
| 1392 | |
|---|
| 1393 | const double Sc = 1000 / l->Scale; |
|---|
| 1394 | |
|---|
| 1395 | if (l->show_mask & LEGS) { |
|---|
| 1396 | SetColour(PR_COLOUR_LEG); |
|---|
| 1397 | list<traverse>::const_iterator trav = mainfrm->traverses_begin(); |
|---|
| 1398 | list<traverse>::const_iterator tend = mainfrm->traverses_end(); |
|---|
| 1399 | for ( ; trav != tend; ++trav) { |
|---|
| 1400 | vector<PointInfo>::const_iterator pos = trav->begin(); |
|---|
| 1401 | vector<PointInfo>::const_iterator end = trav->end(); |
|---|
| 1402 | for ( ; pos != end; ++pos) { |
|---|
| 1403 | double x = pos->GetX(); |
|---|
| 1404 | double y = pos->GetY(); |
|---|
| 1405 | double z = pos->GetZ(); |
|---|
| 1406 | double X = x * COS - y * SIN; |
|---|
| 1407 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
|---|
| 1408 | long px = (long)((X * Sc + l->xOrg) * l->scX); |
|---|
| 1409 | long py = (long)((Y * Sc + l->yOrg) * l->scY); |
|---|
| 1410 | if (pos == trav->begin()) { |
|---|
| 1411 | MoveTo(px, py); |
|---|
| 1412 | } else { |
|---|
| 1413 | DrawTo(px, py); |
|---|
| 1414 | } |
|---|
| 1415 | } |
|---|
| 1416 | } |
|---|
| 1417 | } |
|---|
| 1418 | |
|---|
| 1419 | if ((l->show_mask & XSECT) && |
|---|
| 1420 | (l->tilt == 0.0 || l->tilt == 90.0 || l->tilt == -90.0)) { |
|---|
| 1421 | list<vector<XSect> >::const_iterator trav = mainfrm->tubes_begin(); |
|---|
| 1422 | list<vector<XSect> >::const_iterator tend = mainfrm->tubes_end(); |
|---|
| 1423 | for ( ; trav != tend; ++trav) { |
|---|
| 1424 | if (l->tilt == 90.0 || l->tilt == -90.0) PlotLR(*trav); |
|---|
| 1425 | if (l->tilt == 0.0) PlotUD(*trav); |
|---|
| 1426 | } |
|---|
| 1427 | } |
|---|
| 1428 | |
|---|
| 1429 | if (l->show_mask & SURF) { |
|---|
| 1430 | SetColour(PR_COLOUR_SURFACE_LEG); |
|---|
| 1431 | list<traverse>::const_iterator trav = mainfrm->surface_traverses_begin(); |
|---|
| 1432 | list<traverse>::const_iterator tend = mainfrm->surface_traverses_end(); |
|---|
| 1433 | for ( ; trav != tend; ++trav) { |
|---|
| 1434 | vector<PointInfo>::const_iterator pos = trav->begin(); |
|---|
| 1435 | vector<PointInfo>::const_iterator end = trav->end(); |
|---|
| 1436 | for ( ; pos != end; ++pos) { |
|---|
| 1437 | double x = pos->GetX(); |
|---|
| 1438 | double y = pos->GetY(); |
|---|
| 1439 | double z = pos->GetZ(); |
|---|
| 1440 | double X = x * COS - y * SIN; |
|---|
| 1441 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
|---|
| 1442 | long px = (long)((X * Sc + l->xOrg) * l->scX); |
|---|
| 1443 | long py = (long)((Y * Sc + l->yOrg) * l->scY); |
|---|
| 1444 | if (pos == trav->begin()) { |
|---|
| 1445 | MoveTo(px, py); |
|---|
| 1446 | } else { |
|---|
| 1447 | DrawTo(px, py); |
|---|
| 1448 | } |
|---|
| 1449 | } |
|---|
| 1450 | } |
|---|
| 1451 | } |
|---|
| 1452 | |
|---|
| 1453 | if (l->show_mask & (LABELS|STNS)) { |
|---|
| 1454 | if (l->show_mask & LABELS) SetFont(PR_FONT_LABELS); |
|---|
| 1455 | list<LabelInfo*>::const_iterator label = mainfrm->GetLabels(); |
|---|
| 1456 | while (label != mainfrm->GetLabelsEnd()) { |
|---|
| 1457 | double px = (*label)->GetX(); |
|---|
| 1458 | double py = (*label)->GetY(); |
|---|
| 1459 | double pz = (*label)->GetZ(); |
|---|
| 1460 | if ((l->show_mask & SURF) || (*label)->IsUnderground()) { |
|---|
| 1461 | double X = px * COS - py * SIN; |
|---|
| 1462 | double Y = pz * COST - (px * SIN + py * COS) * SINT; |
|---|
| 1463 | long xnew, ynew; |
|---|
| 1464 | xnew = (long)((X * Sc + l->xOrg) * l->scX); |
|---|
| 1465 | ynew = (long)((Y * Sc + l->yOrg) * l->scY); |
|---|
| 1466 | if (l->show_mask & STNS) { |
|---|
| 1467 | SetColour(PR_COLOUR_CROSS); |
|---|
| 1468 | DrawCross(xnew, ynew); |
|---|
| 1469 | } |
|---|
| 1470 | if (l->show_mask & LABELS) { |
|---|
| 1471 | SetColour(PR_COLOUR_LABELS); |
|---|
| 1472 | MoveTo(xnew, ynew); |
|---|
| 1473 | WriteString((*label)->GetText()); |
|---|
| 1474 | } |
|---|
| 1475 | } |
|---|
| 1476 | ++label; |
|---|
| 1477 | } |
|---|
| 1478 | } |
|---|
| 1479 | |
|---|
| 1480 | return true; |
|---|
| 1481 | } |
|---|
| 1482 | |
|---|
| 1483 | void |
|---|
| 1484 | svxPrintout::GetPageInfo(int *minPage, int *maxPage, |
|---|
| 1485 | int *pageFrom, int *pageTo) |
|---|
| 1486 | { |
|---|
| 1487 | *minPage = *pageFrom = 1; |
|---|
| 1488 | *maxPage = *pageTo = m_layout->pages; |
|---|
| 1489 | } |
|---|
| 1490 | |
|---|
| 1491 | bool |
|---|
| 1492 | svxPrintout::HasPage(int pageNum) { |
|---|
| 1493 | return (pageNum <= m_layout->pages); |
|---|
| 1494 | } |
|---|
| 1495 | |
|---|
| 1496 | void |
|---|
| 1497 | svxPrintout::OnBeginPrinting() { |
|---|
| 1498 | FILE *fh_list[4]; |
|---|
| 1499 | |
|---|
| 1500 | FILE **pfh = fh_list; |
|---|
| 1501 | FILE *fh; |
|---|
| 1502 | const char *pth_cfg; |
|---|
| 1503 | char *print_ini; |
|---|
| 1504 | |
|---|
| 1505 | /* ini files searched in this order: |
|---|
| 1506 | * ~/.survex/print.ini [unix only] |
|---|
| 1507 | * /etc/survex/print.ini [unix only] |
|---|
| 1508 | * <support file directory>/myprint.ini [not unix] |
|---|
| 1509 | * <support file directory>/print.ini [must exist] |
|---|
| 1510 | */ |
|---|
| 1511 | |
|---|
| 1512 | #ifdef __UNIX__ |
|---|
| 1513 | pth_cfg = getenv("HOME"); |
|---|
| 1514 | if (pth_cfg) { |
|---|
| 1515 | fh = fopenWithPthAndExt(pth_cfg, ".survex/print."EXT_INI, NULL, |
|---|
| 1516 | "rb", NULL); |
|---|
| 1517 | if (fh) *pfh++ = fh; |
|---|
| 1518 | } |
|---|
| 1519 | pth_cfg = msg_cfgpth(); |
|---|
| 1520 | fh = fopenWithPthAndExt(NULL, "/etc/survex/print."EXT_INI, NULL, "rb", |
|---|
| 1521 | NULL); |
|---|
| 1522 | if (fh) *pfh++ = fh; |
|---|
| 1523 | #else |
|---|
| 1524 | pth_cfg = msg_cfgpth(); |
|---|
| 1525 | print_ini = add_ext("myprint", EXT_INI); |
|---|
| 1526 | fh = fopenWithPthAndExt(pth_cfg, print_ini, NULL, "rb", NULL); |
|---|
| 1527 | if (fh) *pfh++ = fh; |
|---|
| 1528 | #endif |
|---|
| 1529 | print_ini = add_ext("print", EXT_INI); |
|---|
| 1530 | fh = fopenWithPthAndExt(pth_cfg, print_ini, NULL, "rb", NULL); |
|---|
| 1531 | if (!fh) fatalerror(/*Couldn’t open file “%s”*/24, print_ini); |
|---|
| 1532 | *pfh++ = fh; |
|---|
| 1533 | *pfh = NULL; |
|---|
| 1534 | Init(pfh, false); |
|---|
| 1535 | for (pfh = fh_list; *pfh; pfh++) (void)fclose(*pfh); |
|---|
| 1536 | Pre(); |
|---|
| 1537 | m_layout->footer = wmsg(/*Survey “%s” Page %d (of %d) Processed on %s*/167); |
|---|
| 1538 | } |
|---|
| 1539 | |
|---|
| 1540 | void |
|---|
| 1541 | svxPrintout::OnEndPrinting() { |
|---|
| 1542 | delete font_labels; |
|---|
| 1543 | delete font_default; |
|---|
| 1544 | delete pen_frame; |
|---|
| 1545 | delete pen_leg; |
|---|
| 1546 | delete pen_surface_leg; |
|---|
| 1547 | delete pen_cross; |
|---|
| 1548 | } |
|---|
| 1549 | |
|---|
| 1550 | |
|---|
| 1551 | // prcore -> wx.grafx (calls to move pens around and stuff - low level) |
|---|
| 1552 | // this seems to have been done... |
|---|
| 1553 | |
|---|
| 1554 | |
|---|
| 1555 | |
|---|
| 1556 | static border clip; |
|---|
| 1557 | |
|---|
| 1558 | |
|---|
| 1559 | int |
|---|
| 1560 | svxPrintout::check_intersection(long x_p, long y_p) |
|---|
| 1561 | { |
|---|
| 1562 | #define U 1 |
|---|
| 1563 | #define D 2 |
|---|
| 1564 | #define L 4 |
|---|
| 1565 | #define R 8 |
|---|
| 1566 | int mask_p = 0, mask_t = 0; |
|---|
| 1567 | if (x_p < 0) |
|---|
| 1568 | mask_p = L; |
|---|
| 1569 | else if (x_p > xpPageWidth) |
|---|
| 1570 | mask_p = R; |
|---|
| 1571 | |
|---|
| 1572 | if (y_p < 0) |
|---|
| 1573 | mask_p |= D; |
|---|
| 1574 | else if (y_p > ypPageDepth) |
|---|
| 1575 | mask_p |= U; |
|---|
| 1576 | |
|---|
| 1577 | if (x_t < 0) |
|---|
| 1578 | mask_t = L; |
|---|
| 1579 | else if (x_t > xpPageWidth) |
|---|
| 1580 | mask_t = R; |
|---|
| 1581 | |
|---|
| 1582 | if (y_t < 0) |
|---|
| 1583 | mask_t |= D; |
|---|
| 1584 | else if (y_t > ypPageDepth) |
|---|
| 1585 | mask_t |= U; |
|---|
| 1586 | |
|---|
| 1587 | #if 0 |
|---|
| 1588 | /* approximation to correct answer */ |
|---|
| 1589 | return !(mask_t & mask_p); |
|---|
| 1590 | #else |
|---|
| 1591 | /* One end of the line is on the page */ |
|---|
| 1592 | if (!mask_t || !mask_p) return 1; |
|---|
| 1593 | |
|---|
| 1594 | /* whole line is above, left, right, or below page */ |
|---|
| 1595 | if (mask_t & mask_p) return 0; |
|---|
| 1596 | |
|---|
| 1597 | if (mask_t == 0) mask_t = mask_p; |
|---|
| 1598 | if (mask_t & U) { |
|---|
| 1599 | double v = (double)(y_p - ypPageDepth) / (y_p - y_t); |
|---|
| 1600 | return v >= 0 && v <= 1; |
|---|
| 1601 | } |
|---|
| 1602 | if (mask_t & D) { |
|---|
| 1603 | double v = (double)y_p / (y_p - y_t); |
|---|
| 1604 | return v >= 0 && v <= 1; |
|---|
| 1605 | } |
|---|
| 1606 | if (mask_t & R) { |
|---|
| 1607 | double v = (double)(x_p - xpPageWidth) / (x_p - x_t); |
|---|
| 1608 | return v >= 0 && v <= 1; |
|---|
| 1609 | } |
|---|
| 1610 | SVX_ASSERT(mask_t & L); |
|---|
| 1611 | { |
|---|
| 1612 | double v = (double)x_p / (x_p - x_t); |
|---|
| 1613 | return v >= 0 && v <= 1; |
|---|
| 1614 | } |
|---|
| 1615 | #endif |
|---|
| 1616 | #undef U |
|---|
| 1617 | #undef D |
|---|
| 1618 | #undef L |
|---|
| 1619 | #undef R |
|---|
| 1620 | } |
|---|
| 1621 | |
|---|
| 1622 | void |
|---|
| 1623 | svxPrintout::MoveTo(long x, long y) |
|---|
| 1624 | { |
|---|
| 1625 | x_t = x_offset + x - clip.x_min; |
|---|
| 1626 | y_t = y_offset + clip.y_max - y; |
|---|
| 1627 | } |
|---|
| 1628 | |
|---|
| 1629 | void |
|---|
| 1630 | svxPrintout::DrawTo(long x, long y) |
|---|
| 1631 | { |
|---|
| 1632 | long x_p = x_t, y_p = y_t; |
|---|
| 1633 | x_t = x_offset + x - clip.x_min; |
|---|
| 1634 | y_t = y_offset + clip.y_max - y; |
|---|
| 1635 | if (cur_pass != -1) { |
|---|
| 1636 | pdc->DrawLine(x_p, y_p, x_t, y_t); |
|---|
| 1637 | } else { |
|---|
| 1638 | if (check_intersection(x_p, y_p)) fBlankPage = fFalse; |
|---|
| 1639 | } |
|---|
| 1640 | } |
|---|
| 1641 | |
|---|
| 1642 | #define POINTS_PER_INCH 72.0 |
|---|
| 1643 | #define POINTS_PER_MM (POINTS_PER_INCH / MM_PER_INCH) |
|---|
| 1644 | #define PWX_CROSS_SIZE (int)(2 * m_layout->scX / POINTS_PER_MM) |
|---|
| 1645 | |
|---|
| 1646 | void |
|---|
| 1647 | svxPrintout::DrawCross(long x, long y) |
|---|
| 1648 | { |
|---|
| 1649 | if (cur_pass != -1) { |
|---|
| 1650 | MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
|---|
| 1651 | DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
|---|
| 1652 | MoveTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
|---|
| 1653 | DrawTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
|---|
| 1654 | MoveTo(x, y); |
|---|
| 1655 | } else { |
|---|
| 1656 | if ((x + PWX_CROSS_SIZE > clip.x_min && |
|---|
| 1657 | x - PWX_CROSS_SIZE < clip.x_max) || |
|---|
| 1658 | (y + PWX_CROSS_SIZE > clip.y_min && |
|---|
| 1659 | y - PWX_CROSS_SIZE < clip.y_max)) { |
|---|
| 1660 | fBlankPage = fFalse; |
|---|
| 1661 | } |
|---|
| 1662 | } |
|---|
| 1663 | } |
|---|
| 1664 | |
|---|
| 1665 | void |
|---|
| 1666 | svxPrintout::SetFont(int fontcode) |
|---|
| 1667 | { |
|---|
| 1668 | switch (fontcode) { |
|---|
| 1669 | case PR_FONT_DEFAULT: |
|---|
| 1670 | current_font = font_default; |
|---|
| 1671 | break; |
|---|
| 1672 | case PR_FONT_LABELS: |
|---|
| 1673 | current_font = font_labels; |
|---|
| 1674 | break; |
|---|
| 1675 | default: |
|---|
| 1676 | BUG("unknown font code"); |
|---|
| 1677 | } |
|---|
| 1678 | } |
|---|
| 1679 | |
|---|
| 1680 | void |
|---|
| 1681 | svxPrintout::SetColour(int colourcode) |
|---|
| 1682 | { |
|---|
| 1683 | switch (colourcode) { |
|---|
| 1684 | case PR_COLOUR_TEXT: |
|---|
| 1685 | pdc->SetTextForeground(colour_text); |
|---|
| 1686 | break; |
|---|
| 1687 | case PR_COLOUR_LABELS: |
|---|
| 1688 | pdc->SetTextForeground(colour_labels); |
|---|
| 1689 | pdc->SetBackgroundMode(wxTRANSPARENT); |
|---|
| 1690 | break; |
|---|
| 1691 | case PR_COLOUR_FRAME: |
|---|
| 1692 | pdc->SetPen(*pen_frame); |
|---|
| 1693 | break; |
|---|
| 1694 | case PR_COLOUR_LEG: |
|---|
| 1695 | pdc->SetPen(*pen_leg); |
|---|
| 1696 | break; |
|---|
| 1697 | case PR_COLOUR_CROSS: |
|---|
| 1698 | pdc->SetPen(*pen_cross); |
|---|
| 1699 | break; |
|---|
| 1700 | case PR_COLOUR_SURFACE_LEG: |
|---|
| 1701 | pdc->SetPen(*pen_surface_leg); |
|---|
| 1702 | break; |
|---|
| 1703 | default: |
|---|
| 1704 | BUG("unknown colour code"); |
|---|
| 1705 | } |
|---|
| 1706 | } |
|---|
| 1707 | |
|---|
| 1708 | void |
|---|
| 1709 | svxPrintout::WriteString(const wxString & s) |
|---|
| 1710 | { |
|---|
| 1711 | double xsc, ysc; |
|---|
| 1712 | pdc->GetUserScale(&xsc, &ysc); |
|---|
| 1713 | pdc->SetUserScale(xsc * font_scaling_x, ysc * font_scaling_y); |
|---|
| 1714 | pdc->SetFont(*current_font); |
|---|
| 1715 | int w, h; |
|---|
| 1716 | if (cur_pass != -1) { |
|---|
| 1717 | pdc->GetTextExtent(wxT("My"), &w, &h); |
|---|
| 1718 | pdc->DrawText(s, |
|---|
| 1719 | long(x_t / font_scaling_x), |
|---|
| 1720 | long(y_t / font_scaling_y) - h); |
|---|
| 1721 | } else { |
|---|
| 1722 | pdc->GetTextExtent(s, &w, &h); |
|---|
| 1723 | if ((y_t + h > 0 && y_t - h < clip.y_max - clip.y_min) || |
|---|
| 1724 | (x_t < clip.x_max - clip.x_min && x_t + w > 0)) { |
|---|
| 1725 | fBlankPage = fFalse; |
|---|
| 1726 | } |
|---|
| 1727 | } |
|---|
| 1728 | pdc->SetUserScale(xsc, ysc); |
|---|
| 1729 | } |
|---|
| 1730 | |
|---|
| 1731 | void |
|---|
| 1732 | svxPrintout::DrawEllipse(long x, long y, long r, long R) |
|---|
| 1733 | { |
|---|
| 1734 | /* Don't need to check in first-pass - circle is only used in title box */ |
|---|
| 1735 | if (cur_pass != -1) { |
|---|
| 1736 | x_t = x_offset + x - clip.x_min; |
|---|
| 1737 | y_t = y_offset + clip.y_max - y; |
|---|
| 1738 | const wxBrush & save_brush = pdc->GetBrush(); |
|---|
| 1739 | pdc->SetBrush(*wxTRANSPARENT_BRUSH); |
|---|
| 1740 | pdc->DrawEllipse(x_t - r, y_t - R, 2 * r, 2 * R); |
|---|
| 1741 | pdc->SetBrush(save_brush); |
|---|
| 1742 | } |
|---|
| 1743 | } |
|---|
| 1744 | |
|---|
| 1745 | void |
|---|
| 1746 | svxPrintout::SolidRectangle(long x, long y, long w, long h) |
|---|
| 1747 | { |
|---|
| 1748 | long X = x_offset + x - clip.x_min; |
|---|
| 1749 | long Y = y_offset + clip.y_max - y; |
|---|
| 1750 | pdc->SetBrush(*wxBLACK_BRUSH); |
|---|
| 1751 | pdc->DrawRectangle(X, Y - h, w, h); |
|---|
| 1752 | } |
|---|
| 1753 | |
|---|
| 1754 | int |
|---|
| 1755 | svxPrintout::Pre() |
|---|
| 1756 | { |
|---|
| 1757 | font_labels = new wxFont(fontsize_labels, wxDEFAULT, wxNORMAL, wxNORMAL, |
|---|
| 1758 | false, wxString(fontname_labels, wxConvUTF8), |
|---|
| 1759 | wxFONTENCODING_ISO8859_1); |
|---|
| 1760 | font_default = new wxFont(fontsize, wxDEFAULT, wxNORMAL, wxNORMAL, |
|---|
| 1761 | false, wxString(fontname, wxConvUTF8), |
|---|
| 1762 | wxFONTENCODING_ISO8859_1); |
|---|
| 1763 | current_font = font_default; |
|---|
| 1764 | pen_leg = new wxPen(colour_leg); |
|---|
| 1765 | pen_surface_leg = new wxPen(colour_surface_leg); |
|---|
| 1766 | pen_cross = new wxPen(colour_cross); |
|---|
| 1767 | pen_frame = new wxPen(colour_frame); |
|---|
| 1768 | return 1; /* only need 1 pass */ |
|---|
| 1769 | } |
|---|
| 1770 | |
|---|
| 1771 | void |
|---|
| 1772 | svxPrintout::NewPage(int pg, int pagesX, int pagesY) |
|---|
| 1773 | { |
|---|
| 1774 | int x, y; |
|---|
| 1775 | x = (pg - 1) % pagesX; |
|---|
| 1776 | y = pagesY - 1 - ((pg - 1) / pagesX); |
|---|
| 1777 | |
|---|
| 1778 | clip.x_min = (long)x * xpPageWidth; |
|---|
| 1779 | clip.y_min = (long)y * ypPageDepth; |
|---|
| 1780 | clip.x_max = clip.x_min + xpPageWidth; /* dm/pcl/ps had -1; */ |
|---|
| 1781 | clip.y_max = clip.y_min + ypPageDepth; /* dm/pcl/ps had -1; */ |
|---|
| 1782 | |
|---|
| 1783 | //we have to write the footer here. PostScript is being weird. Really weird. |
|---|
| 1784 | pdc->SetFont(*font_labels); |
|---|
| 1785 | MoveTo(clip.x_min, clip.y_min - (long)(7 * m_layout->scY)); |
|---|
| 1786 | wxString footer; |
|---|
| 1787 | footer.Printf(m_layout->footer, |
|---|
| 1788 | m_layout->title.c_str(), |
|---|
| 1789 | pg, |
|---|
| 1790 | m_layout->pagesX * m_layout->pagesY, |
|---|
| 1791 | m_layout->datestamp.c_str()); |
|---|
| 1792 | WriteString(footer); |
|---|
| 1793 | pdc->DestroyClippingRegion(); |
|---|
| 1794 | drawticks(clip, (int)(9 * m_layout->scX / POINTS_PER_MM), x, y); |
|---|
| 1795 | } |
|---|
| 1796 | |
|---|
| 1797 | void |
|---|
| 1798 | svxPrintout::PlotLR(const vector<XSect> & centreline) |
|---|
| 1799 | { |
|---|
| 1800 | assert(centreline.size() > 1); |
|---|
| 1801 | XSect prev_pt_v; |
|---|
| 1802 | Vector3 last_right(1.0, 0.0, 0.0); |
|---|
| 1803 | |
|---|
| 1804 | const double Sc = 1000 / m_layout->Scale; |
|---|
| 1805 | const double SIN = sin(rad(m_layout->rot)); |
|---|
| 1806 | const double COS = cos(rad(m_layout->rot)); |
|---|
| 1807 | |
|---|
| 1808 | vector<XSect>::const_iterator i = centreline.begin(); |
|---|
| 1809 | vector<XSect>::size_type segment = 0; |
|---|
| 1810 | while (i != centreline.end()) { |
|---|
| 1811 | // get the coordinates of this vertex |
|---|
| 1812 | const XSect & pt_v = *i++; |
|---|
| 1813 | |
|---|
| 1814 | Vector3 right; |
|---|
| 1815 | |
|---|
| 1816 | const Vector3 up_v(0.0, 0.0, 1.0); |
|---|
| 1817 | |
|---|
| 1818 | if (segment == 0) { |
|---|
| 1819 | assert(i != centreline.end()); |
|---|
| 1820 | // first segment |
|---|
| 1821 | |
|---|
| 1822 | // get the coordinates of the next vertex |
|---|
| 1823 | const XSect & next_pt_v = *i; |
|---|
| 1824 | |
|---|
| 1825 | // calculate vector from this pt to the next one |
|---|
| 1826 | Vector3 leg_v = next_pt_v - pt_v; |
|---|
| 1827 | |
|---|
| 1828 | // obtain a vector in the LRUD plane |
|---|
| 1829 | right = leg_v * up_v; |
|---|
| 1830 | if (right.magnitude() == 0) { |
|---|
| 1831 | right = last_right; |
|---|
| 1832 | } else { |
|---|
| 1833 | last_right = right; |
|---|
| 1834 | } |
|---|
| 1835 | } else if (segment + 1 == centreline.size()) { |
|---|
| 1836 | // last segment |
|---|
| 1837 | |
|---|
| 1838 | // Calculate vector from the previous pt to this one. |
|---|
| 1839 | Vector3 leg_v = pt_v - prev_pt_v; |
|---|
| 1840 | |
|---|
| 1841 | // Obtain a horizontal vector in the LRUD plane. |
|---|
| 1842 | right = leg_v * up_v; |
|---|
| 1843 | if (right.magnitude() == 0) { |
|---|
| 1844 | right = Vector3(last_right.GetX(), last_right.GetY(), 0.0); |
|---|
| 1845 | } else { |
|---|
| 1846 | last_right = right; |
|---|
| 1847 | } |
|---|
| 1848 | } else { |
|---|
| 1849 | assert(i != centreline.end()); |
|---|
| 1850 | // Intermediate segment. |
|---|
| 1851 | |
|---|
| 1852 | // Get the coordinates of the next vertex. |
|---|
| 1853 | const XSect & next_pt_v = *i; |
|---|
| 1854 | |
|---|
| 1855 | // Calculate vectors from this vertex to the |
|---|
| 1856 | // next vertex, and from the previous vertex to |
|---|
| 1857 | // this one. |
|---|
| 1858 | Vector3 leg1_v = pt_v - prev_pt_v; |
|---|
| 1859 | Vector3 leg2_v = next_pt_v - pt_v; |
|---|
| 1860 | |
|---|
| 1861 | // Obtain horizontal vectors perpendicular to |
|---|
| 1862 | // both legs, then normalise and average to get |
|---|
| 1863 | // a horizontal bisector. |
|---|
| 1864 | Vector3 r1 = leg1_v * up_v; |
|---|
| 1865 | Vector3 r2 = leg2_v * up_v; |
|---|
| 1866 | r1.normalise(); |
|---|
| 1867 | r2.normalise(); |
|---|
| 1868 | right = r1 + r2; |
|---|
| 1869 | if (right.magnitude() == 0) { |
|---|
| 1870 | // This is the "mid-pitch" case... |
|---|
| 1871 | right = last_right; |
|---|
| 1872 | } |
|---|
| 1873 | last_right = right; |
|---|
| 1874 | } |
|---|
| 1875 | |
|---|
| 1876 | // Scale to unit vectors in the LRUD plane. |
|---|
| 1877 | right.normalise(); |
|---|
| 1878 | |
|---|
| 1879 | Double l = pt_v.GetL(); |
|---|
| 1880 | Double r = pt_v.GetR(); |
|---|
| 1881 | |
|---|
| 1882 | if (l >= 0) { |
|---|
| 1883 | Vector3 p = pt_v - right * l; |
|---|
| 1884 | double X = p.GetX() * COS - p.GetY() * SIN; |
|---|
| 1885 | double Y = (p.GetX() * SIN + p.GetY() * COS); |
|---|
| 1886 | long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX); |
|---|
| 1887 | long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY); |
|---|
| 1888 | MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
|---|
| 1889 | DrawTo(x, y); |
|---|
| 1890 | DrawTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
|---|
| 1891 | } |
|---|
| 1892 | if (r >= 0) { |
|---|
| 1893 | Vector3 p = pt_v + right * r; |
|---|
| 1894 | double X = p.GetX() * COS - p.GetY() * SIN; |
|---|
| 1895 | double Y = (p.GetX() * SIN + p.GetY() * COS); |
|---|
| 1896 | long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX); |
|---|
| 1897 | long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY); |
|---|
| 1898 | MoveTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
|---|
| 1899 | DrawTo(x, y); |
|---|
| 1900 | DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
|---|
| 1901 | } |
|---|
| 1902 | |
|---|
| 1903 | prev_pt_v = pt_v; |
|---|
| 1904 | |
|---|
| 1905 | ++segment; |
|---|
| 1906 | } |
|---|
| 1907 | } |
|---|
| 1908 | |
|---|
| 1909 | void |
|---|
| 1910 | svxPrintout::PlotUD(const vector<XSect> & centreline) |
|---|
| 1911 | { |
|---|
| 1912 | assert(centreline.size() > 1); |
|---|
| 1913 | const double Sc = 1000 / m_layout->Scale; |
|---|
| 1914 | |
|---|
| 1915 | vector<XSect>::const_iterator i = centreline.begin(); |
|---|
| 1916 | while (i != centreline.end()) { |
|---|
| 1917 | // get the coordinates of this vertex |
|---|
| 1918 | const XSect & pt_v = *i++; |
|---|
| 1919 | |
|---|
| 1920 | Double u = pt_v.GetU(); |
|---|
| 1921 | Double d = pt_v.GetD(); |
|---|
| 1922 | |
|---|
| 1923 | if (u >= 0 || d >= 0) { |
|---|
| 1924 | Vector3 p = pt_v; |
|---|
| 1925 | double SIN = sin(rad(m_layout->rot)); |
|---|
| 1926 | double COS = cos(rad(m_layout->rot)); |
|---|
| 1927 | double X = p.GetX() * COS - p.GetY() * SIN; |
|---|
| 1928 | double Y = p.GetZ(); |
|---|
| 1929 | long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX); |
|---|
| 1930 | if (u >= 0) { |
|---|
| 1931 | long y = (long)(((Y + u) * Sc + m_layout->yOrg) * m_layout->scY); |
|---|
| 1932 | MoveTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
|---|
| 1933 | DrawTo(x, y); |
|---|
| 1934 | DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
|---|
| 1935 | } |
|---|
| 1936 | if (d >= 0) { |
|---|
| 1937 | long y = (long)(((Y - d) * Sc + m_layout->yOrg) * m_layout->scY); |
|---|
| 1938 | MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
|---|
| 1939 | DrawTo(x, y); |
|---|
| 1940 | DrawTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
|---|
| 1941 | } |
|---|
| 1942 | } |
|---|
| 1943 | } |
|---|
| 1944 | } |
|---|
| 1945 | |
|---|
| 1946 | static wxColour |
|---|
| 1947 | to_rgb(const char *var, char *val) |
|---|
| 1948 | { |
|---|
| 1949 | unsigned long rgb; |
|---|
| 1950 | if (!val) return *wxBLACK; |
|---|
| 1951 | rgb = as_colour(var, val); |
|---|
| 1952 | return wxColour((rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff); |
|---|
| 1953 | } |
|---|
| 1954 | |
|---|
| 1955 | /* Initialise printer routines */ |
|---|
| 1956 | char * |
|---|
| 1957 | svxPrintout::Init(FILE **fh_list, bool fCalibrate) |
|---|
| 1958 | { |
|---|
| 1959 | static const char *vars[] = { |
|---|
| 1960 | "font_size_labels", |
|---|
| 1961 | "colour_text", |
|---|
| 1962 | "colour_labels", |
|---|
| 1963 | "colour_frame", |
|---|
| 1964 | "colour_legs", |
|---|
| 1965 | "colour_crosses", |
|---|
| 1966 | "colour_surface_legs", |
|---|
| 1967 | NULL |
|---|
| 1968 | }; |
|---|
| 1969 | char **vals; |
|---|
| 1970 | |
|---|
| 1971 | (void)fCalibrate; /* suppress unused argument warning */ |
|---|
| 1972 | |
|---|
| 1973 | vals = ini_read(fh_list, "aven", vars); |
|---|
| 1974 | fontsize_labels = 10; |
|---|
| 1975 | if (vals[0]) fontsize_labels = as_int(vars[0], vals[0], 1, INT_MAX); |
|---|
| 1976 | fontsize = 10; |
|---|
| 1977 | |
|---|
| 1978 | colour_text = colour_labels = colour_frame = colour_leg = colour_cross = colour_surface_leg = *wxBLACK; |
|---|
| 1979 | if (vals[1]) colour_text = to_rgb(vars[1], vals[1]); |
|---|
| 1980 | if (vals[2]) colour_labels = to_rgb(vars[2], vals[2]); |
|---|
| 1981 | if (vals[3]) colour_frame = to_rgb(vars[3], vals[3]); |
|---|
| 1982 | if (vals[4]) colour_leg = to_rgb(vars[4], vals[4]); |
|---|
| 1983 | if (vals[5]) colour_cross = to_rgb(vars[5], vals[5]); |
|---|
| 1984 | if (vals[6]) colour_surface_leg = to_rgb(vars[6], vals[6]); |
|---|
| 1985 | m_layout->scX = 1; |
|---|
| 1986 | m_layout->scY = 1; |
|---|
| 1987 | return NULL; |
|---|
| 1988 | } |
|---|