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