[a80e6f3] | 1 | /* printwx.cc */ |
---|
[1324d6c] | 2 | /* wxWidgets specific parts of Survex wxWidgets printing code */ |
---|
[70462c8] | 3 | /* Copyright (C) 1993-2003,2004,2005,2006,2010,2011,2012,2013,2014 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(), |
---|
| 635 | grid, text_height, marker_size)) { |
---|
| 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(); |
---|
[5940815] | 773 | if (!m_printSize) return; |
---|
[79c239e] | 774 | // Update the bounding box. |
---|
| 775 | RecalcBounds(); |
---|
[6ca9f08] | 776 | |
---|
| 777 | if (m_scale) { |
---|
| 778 | (m_scale->GetValue()).ToDouble(&(m_layout.Scale)); |
---|
| 779 | if (m_layout.Scale == 0.0) { |
---|
| 780 | m_layout.pick_scale(1, 1); |
---|
| 781 | } |
---|
| 782 | } |
---|
| 783 | |
---|
[ee05463] | 784 | if (m_layout.xMax >= m_layout.xMin) { |
---|
[79c239e] | 785 | m_layout.pages_required(); |
---|
[5627cbb] | 786 | m_printSize->SetLabel(wxString::Format(wmsg(/*%d pages (%dx%d)*/257), m_layout.pages, m_layout.pagesX, m_layout.pagesY)); |
---|
[79c239e] | 787 | } |
---|
| 788 | } |
---|
| 789 | |
---|
[ee05463] | 790 | void |
---|
[79c239e] | 791 | svxPrintDlg::LayoutToUI(){ |
---|
| 792 | // m_blanks->SetValue(m_layout.SkipBlank); |
---|
[eef68f9] | 793 | if (m_layout.view != layout::EXTELEV) { |
---|
| 794 | m_tilt->SetValue(m_layout.tilt); |
---|
| 795 | m_bearing->SetValue(m_layout.rot); |
---|
[79c239e] | 796 | } |
---|
| 797 | |
---|
| 798 | // Do this last as it causes an OnChange message which calls UIToLayout |
---|
[5940815] | 799 | if (m_scale) { |
---|
| 800 | if (m_layout.Scale != 0) { |
---|
| 801 | wxString temp; |
---|
| 802 | temp << m_layout.Scale; |
---|
| 803 | m_scale->SetValue(temp); |
---|
| 804 | } else { |
---|
[5627cbb] | 805 | if (scales[0].empty()) scales[0].assign(wmsg(/*One page*/258)); |
---|
[5940815] | 806 | m_scale->SetValue(scales[0]); |
---|
| 807 | } |
---|
[79c239e] | 808 | } |
---|
| 809 | } |
---|
| 810 | |
---|
[ee05463] | 811 | void |
---|
[79c239e] | 812 | svxPrintDlg::UIToLayout(){ |
---|
| 813 | // m_layout.SkipBlank = m_blanks->IsChecked(); |
---|
| 814 | |
---|
[de9aa88] | 815 | if (m_layout.view != layout::EXTELEV && m_tilt) { |
---|
[79c239e] | 816 | m_layout.tilt = m_tilt->GetValue(); |
---|
[7a57dc7] | 817 | if (m_layout.tilt == -90) { |
---|
[79c239e] | 818 | m_layout.view = layout::PLAN; |
---|
| 819 | } else if (m_layout.tilt == 0) { |
---|
| 820 | m_layout.view = layout::ELEV; |
---|
| 821 | } else { |
---|
| 822 | m_layout.view = layout::TILT; |
---|
| 823 | } |
---|
[256c4c8] | 824 | |
---|
| 825 | bool enable_passage_opts = (m_layout.view != layout::TILT); |
---|
| 826 | wxWindow * win; |
---|
| 827 | win = FindWindow(svx_XSECT); |
---|
| 828 | if (win) win->Enable(enable_passage_opts); |
---|
| 829 | win = FindWindow(svx_WALLS); |
---|
| 830 | if (win) win->Enable(enable_passage_opts); |
---|
| 831 | win = FindWindow(svx_PASSAGES); |
---|
| 832 | if (win) win->Enable(enable_passage_opts); |
---|
| 833 | |
---|
[79c239e] | 834 | m_layout.rot = m_bearing->GetValue(); |
---|
| 835 | } |
---|
| 836 | } |
---|
| 837 | |
---|
| 838 | void |
---|
| 839 | svxPrintDlg::RecalcBounds() |
---|
| 840 | { |
---|
| 841 | m_layout.yMax = m_layout.xMax = -DBL_MAX; |
---|
| 842 | m_layout.yMin = m_layout.xMin = DBL_MAX; |
---|
| 843 | |
---|
[5940815] | 844 | double SIN = sin(rad(m_layout.rot)); |
---|
| 845 | double COS = cos(rad(m_layout.rot)); |
---|
| 846 | double SINT = sin(rad(m_layout.tilt)); |
---|
| 847 | double COST = cos(rad(m_layout.tilt)); |
---|
[79c239e] | 848 | |
---|
[d713e5d] | 849 | if (m_layout.show_mask & LEGS) { |
---|
[c61aa79] | 850 | list<traverse>::const_iterator trav = mainfrm->traverses_begin(); |
---|
| 851 | list<traverse>::const_iterator tend = mainfrm->traverses_end(); |
---|
[ce403f1] | 852 | for ( ; trav != tend; ++trav) { |
---|
[d4650b3] | 853 | vector<PointInfo>::const_iterator pos = trav->begin(); |
---|
| 854 | vector<PointInfo>::const_iterator end = trav->end(); |
---|
[ce403f1] | 855 | for ( ; pos != end; ++pos) { |
---|
| 856 | double x = pos->GetX(); |
---|
| 857 | double y = pos->GetY(); |
---|
| 858 | double z = pos->GetZ(); |
---|
| 859 | double X = x * COS - y * SIN; |
---|
| 860 | if (X > m_layout.xMax) m_layout.xMax = X; |
---|
| 861 | if (X < m_layout.xMin) m_layout.xMin = X; |
---|
[7a57dc7] | 862 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
---|
[ce403f1] | 863 | if (Y > m_layout.yMax) m_layout.yMax = Y; |
---|
| 864 | if (Y < m_layout.yMin) m_layout.yMin = Y; |
---|
| 865 | } |
---|
| 866 | } |
---|
| 867 | } |
---|
[d713e5d] | 868 | if (m_layout.show_mask & SURF) { |
---|
[c61aa79] | 869 | list<traverse>::const_iterator trav = mainfrm->surface_traverses_begin(); |
---|
| 870 | list<traverse>::const_iterator tend = mainfrm->surface_traverses_end(); |
---|
[ce403f1] | 871 | for ( ; trav != tend; ++trav) { |
---|
[d4650b3] | 872 | vector<PointInfo>::const_iterator pos = trav->begin(); |
---|
| 873 | vector<PointInfo>::const_iterator end = trav->end(); |
---|
[ce403f1] | 874 | for ( ; pos != end; ++pos) { |
---|
| 875 | double x = pos->GetX(); |
---|
| 876 | double y = pos->GetY(); |
---|
| 877 | double z = pos->GetZ(); |
---|
| 878 | double X = x * COS - y * SIN; |
---|
| 879 | if (X > m_layout.xMax) m_layout.xMax = X; |
---|
| 880 | if (X < m_layout.xMin) m_layout.xMin = X; |
---|
[7a57dc7] | 881 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
---|
[ce403f1] | 882 | if (Y > m_layout.yMax) m_layout.yMax = Y; |
---|
| 883 | if (Y < m_layout.yMin) m_layout.yMin = Y; |
---|
[79c239e] | 884 | } |
---|
| 885 | } |
---|
| 886 | } |
---|
[d713e5d] | 887 | if (m_layout.show_mask & (LABELS|STNS)) { |
---|
[ce403f1] | 888 | list<LabelInfo*>::const_iterator label = mainfrm->GetLabels(); |
---|
| 889 | while (label != mainfrm->GetLabelsEnd()) { |
---|
[79c239e] | 890 | double x = (*label)->GetX(); |
---|
| 891 | double y = (*label)->GetY(); |
---|
| 892 | double z = (*label)->GetZ(); |
---|
[d713e5d] | 893 | if ((m_layout.show_mask & SURF) || (*label)->IsUnderground()) { |
---|
[79c239e] | 894 | double X = x * COS - y * SIN; |
---|
| 895 | if (X > m_layout.xMax) m_layout.xMax = X; |
---|
| 896 | if (X < m_layout.xMin) m_layout.xMin = X; |
---|
[7a57dc7] | 897 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
---|
[79c239e] | 898 | if (Y > m_layout.yMax) m_layout.yMax = Y; |
---|
| 899 | if (Y < m_layout.yMin) m_layout.yMin = Y; |
---|
| 900 | } |
---|
| 901 | ++label; |
---|
| 902 | } |
---|
| 903 | } |
---|
| 904 | } |
---|
| 905 | |
---|
| 906 | static int xpPageWidth, ypPageDepth; |
---|
| 907 | static long MarginLeft, MarginRight, MarginTop, MarginBottom; |
---|
| 908 | static long x_offset, y_offset; |
---|
| 909 | static wxFont *font_labels, *font_default; |
---|
| 910 | static int fontsize, fontsize_labels; |
---|
| 911 | |
---|
| 912 | /* FIXME: allow the font to be set */ |
---|
| 913 | |
---|
| 914 | static const char *fontname = "Arial", *fontname_labels = "Arial"; |
---|
| 915 | |
---|
| 916 | // wx <-> prcore (calls to print_page etc...) |
---|
[5627cbb] | 917 | svxPrintout::svxPrintout(MainFrm *mainfrm_, layout *l, |
---|
| 918 | wxPageSetupDialogData *data, const wxString & title) |
---|
[79c239e] | 919 | : wxPrintout(title) |
---|
| 920 | { |
---|
[ce403f1] | 921 | mainfrm = mainfrm_; |
---|
[79c239e] | 922 | m_layout = l; |
---|
| 923 | m_data = data; |
---|
| 924 | } |
---|
| 925 | |
---|
| 926 | void |
---|
| 927 | svxPrintout::draw_info_box() |
---|
| 928 | { |
---|
| 929 | layout *l = m_layout; |
---|
[995cf6a] | 930 | int boxwidth = 70; |
---|
[79c239e] | 931 | int boxheight = 30; |
---|
| 932 | |
---|
| 933 | SetColour(PR_COLOUR_FRAME); |
---|
| 934 | |
---|
[995cf6a] | 935 | int div = boxwidth; |
---|
[79c239e] | 936 | if (l->view != layout::EXTELEV) { |
---|
[995cf6a] | 937 | boxwidth += boxheight; |
---|
| 938 | MOVEMM(div, boxheight); |
---|
| 939 | DRAWMM(div, 0); |
---|
| 940 | MOVEMM(0, 30); DRAWMM(div, 30); |
---|
[79c239e] | 941 | } |
---|
| 942 | |
---|
| 943 | MOVEMM(0, boxheight); |
---|
| 944 | DRAWMM(boxwidth, boxheight); |
---|
| 945 | DRAWMM(boxwidth, 0); |
---|
| 946 | if (!l->Border) { |
---|
| 947 | DRAWMM(0, 0); |
---|
| 948 | DRAWMM(0, boxheight); |
---|
| 949 | } |
---|
| 950 | |
---|
[995cf6a] | 951 | MOVEMM(0, 20); DRAWMM(div, 20); |
---|
| 952 | MOVEMM(0, 10); DRAWMM(div, 10); |
---|
[79c239e] | 953 | |
---|
| 954 | switch (l->view) { |
---|
| 955 | case layout::PLAN: { |
---|
| 956 | long ax, ay, bx, by, cx, cy, dx, dy; |
---|
| 957 | |
---|
[995cf6a] | 958 | long xc = boxwidth - boxheight / 2; |
---|
| 959 | long yc = boxheight / 2; |
---|
[725cd74d] | 960 | const double RADIUS = boxheight / 3; |
---|
[995cf6a] | 961 | DrawEllipse(long(xc * l->scX), long(yc * l->scY), |
---|
| 962 | long(RADIUS * l->scX), long(RADIUS * l->scY)); |
---|
| 963 | |
---|
| 964 | ax = (long)((xc - (RADIUS - 1) * sin(rad(000.0 + l->rot))) * l->scX); |
---|
| 965 | ay = (long)((yc + (RADIUS - 1) * cos(rad(000.0 + l->rot))) * l->scY); |
---|
| 966 | bx = (long)((xc - RADIUS * 0.5 * sin(rad(180.0 + l->rot))) * l->scX); |
---|
| 967 | by = (long)((yc + RADIUS * 0.5 * cos(rad(180.0 + l->rot))) * l->scY); |
---|
| 968 | cx = (long)((xc - (RADIUS - 1) * sin(rad(160.0 + l->rot))) * l->scX); |
---|
| 969 | cy = (long)((yc + (RADIUS - 1) * cos(rad(160.0 + l->rot))) * l->scY); |
---|
| 970 | dx = (long)((xc - (RADIUS - 1) * sin(rad(200.0 + l->rot))) * l->scX); |
---|
| 971 | dy = (long)((yc + (RADIUS - 1) * cos(rad(200.0 + l->rot))) * l->scY); |
---|
[79c239e] | 972 | |
---|
| 973 | MoveTo(ax, ay); |
---|
| 974 | DrawTo(bx, by); |
---|
| 975 | DrawTo(cx, cy); |
---|
| 976 | DrawTo(ax, ay); |
---|
| 977 | DrawTo(dx, dy); |
---|
| 978 | DrawTo(bx, by); |
---|
| 979 | |
---|
| 980 | SetColour(PR_COLOUR_TEXT); |
---|
[725cd74d] | 981 | MOVEMM(div + 0.5, boxheight - 5.5); |
---|
[5627cbb] | 982 | WriteString(wmsg(/*North*/115)); |
---|
[79c239e] | 983 | |
---|
[995cf6a] | 984 | wxString angle; |
---|
| 985 | angle.Printf(wxT("%03d"), l->rot); |
---|
[05ccca5] | 986 | angle += wmsg(/*°*/344); |
---|
[995cf6a] | 987 | wxString s; |
---|
[736f7df] | 988 | /* TRANSLATORS: This is used on printouts of plans, with %s replaced by |
---|
| 989 | * something like "123°". The bearing is up the page. */ |
---|
[995cf6a] | 990 | s.Printf(wmsg(/*Plan view, %s up page*/168), angle.c_str()); |
---|
| 991 | MOVEMM(2, 12); WriteString(s); |
---|
[79c239e] | 992 | break; |
---|
| 993 | } |
---|
[995cf6a] | 994 | case layout::ELEV: case layout::TILT: { |
---|
| 995 | const int L = div + 2; |
---|
| 996 | const int R = boxwidth - 2; |
---|
[725cd74d] | 997 | const int H = boxheight / 2; |
---|
[995cf6a] | 998 | MOVEMM(L, H); DRAWMM(L + 5, H - 3); DRAWMM(L + 3, H); DRAWMM(L + 5, H + 3); |
---|
[79c239e] | 999 | |
---|
[995cf6a] | 1000 | DRAWMM(L, H); DRAWMM(R, H); |
---|
[79c239e] | 1001 | |
---|
[995cf6a] | 1002 | DRAWMM(R - 5, H + 3); DRAWMM(R - 3, H); DRAWMM(R - 5, H - 3); DRAWMM(R, H); |
---|
[79c239e] | 1003 | |
---|
[995cf6a] | 1004 | MOVEMM((L + R) / 2, H - 2); DRAWMM((L + R) / 2, H + 2); |
---|
[79c239e] | 1005 | |
---|
| 1006 | SetColour(PR_COLOUR_TEXT); |
---|
[725cd74d] | 1007 | MOVEMM(div + 2, boxheight - 8); |
---|
[736f7df] | 1008 | /* TRANSLATORS: "Elevation on" 020 <-> 200 degrees */ |
---|
[5627cbb] | 1009 | WriteString(wmsg(/*Elevation on*/116)); |
---|
| 1010 | |
---|
[725cd74d] | 1011 | MOVEMM(L, 2); |
---|
[05ccca5] | 1012 | WriteString(wxString::Format(wxT("%03d%s"), |
---|
[5b427c0] | 1013 | (l->rot + 270) % 360, |
---|
| 1014 | wmsg(/*°*/344).c_str())); |
---|
[725cd74d] | 1015 | MOVEMM(R - 10, 2); |
---|
[05ccca5] | 1016 | WriteString(wxString::Format(wxT("%03d%s"), |
---|
[5b427c0] | 1017 | (l->rot + 90) % 360, |
---|
| 1018 | wmsg(/*°*/344).c_str())); |
---|
[995cf6a] | 1019 | |
---|
| 1020 | wxString angle; |
---|
| 1021 | angle.Printf(wxT("%03d"), l->rot); |
---|
[05ccca5] | 1022 | angle += wmsg(/*°*/344); |
---|
[995cf6a] | 1023 | wxString s; |
---|
| 1024 | if (l->view == layout::ELEV) { |
---|
[736f7df] | 1025 | /* TRANSLATORS: This is used on printouts of elevations, with %s |
---|
| 1026 | * replaced by something like "123°". The bearing is the direction |
---|
| 1027 | * we’re looking. */ |
---|
[995cf6a] | 1028 | s.Printf(wmsg(/*Elevation facing %s*/169), angle.c_str()); |
---|
| 1029 | } else { |
---|
| 1030 | wxString a2; |
---|
| 1031 | a2.Printf(wxT("%d"), l->tilt); |
---|
[05ccca5] | 1032 | a2 += wmsg(/*°*/344); |
---|
[736f7df] | 1033 | /* TRANSLATORS: This is used on printouts of tilted elevations, with |
---|
| 1034 | * the first %s replaced by something like "123°", and the second by |
---|
| 1035 | * something like "-45°". The bearing is the direction we’re |
---|
| 1036 | * looking. */ |
---|
[995cf6a] | 1037 | s.Printf(wmsg(/*Elevation facing %s, tilted %s*/284), angle.c_str(), a2.c_str()); |
---|
| 1038 | } |
---|
| 1039 | MOVEMM(2, 12); WriteString(s); |
---|
[79c239e] | 1040 | break; |
---|
[995cf6a] | 1041 | } |
---|
[79c239e] | 1042 | case layout::EXTELEV: |
---|
| 1043 | SetColour(PR_COLOUR_TEXT); |
---|
[f6dff8b] | 1044 | MOVEMM(2, 12); |
---|
[736f7df] | 1045 | /* TRANSLATORS: This is used on printouts of extended elevations. */ |
---|
[5627cbb] | 1046 | WriteString(wmsg(/*Extended elevation*/191)); |
---|
[79c239e] | 1047 | break; |
---|
| 1048 | } |
---|
| 1049 | |
---|
[f6dff8b] | 1050 | MOVEMM(2, boxheight - 8); WriteString(l->title); |
---|
[79c239e] | 1051 | |
---|
[995cf6a] | 1052 | MOVEMM(2, 2); |
---|
| 1053 | // FIXME: "Original Scale" better? |
---|
[5627cbb] | 1054 | WriteString(wxString::Format(wmsg(/*Scale*/154) + wxT(" 1:%.0f"), |
---|
| 1055 | l->Scale)); |
---|
[79c239e] | 1056 | |
---|
| 1057 | /* This used to be a copyright line, but it was occasionally |
---|
| 1058 | * mis-interpreted as us claiming copyright on the survey, so let's |
---|
| 1059 | * give the website URL instead */ |
---|
| 1060 | MOVEMM(boxwidth + 2, 2); |
---|
[1671258] | 1061 | WriteString(wxT("Survex "VERSION" - http://survex.com/")); |
---|
[79c239e] | 1062 | |
---|
| 1063 | draw_scale_bar(boxwidth + 10.0, 17.0, l->PaperWidth - boxwidth - 18.0); |
---|
| 1064 | } |
---|
| 1065 | |
---|
| 1066 | /* Draw fancy scale bar with bottom left at (x,y) (both in mm) and at most */ |
---|
| 1067 | /* MaxLength mm long. The scaling in use is 1:scale */ |
---|
| 1068 | void |
---|
| 1069 | svxPrintout::draw_scale_bar(double x, double y, double MaxLength) |
---|
| 1070 | { |
---|
| 1071 | double StepEst, d; |
---|
[5627cbb] | 1072 | int E, Step, n, c; |
---|
| 1073 | wxString buf; |
---|
[79c239e] | 1074 | /* Limit scalebar to 20cm to stop people with A0 plotters complaining */ |
---|
| 1075 | if (MaxLength > 200.0) MaxLength = 200.0; |
---|
| 1076 | |
---|
| 1077 | #define dmin 10.0 /* each division >= dmin mm long */ |
---|
| 1078 | #define StepMax 5 /* number in steps of at most StepMax (x 10^N) */ |
---|
| 1079 | #define epsilon (1e-4) /* fudge factor to prevent rounding problems */ |
---|
| 1080 | |
---|
| 1081 | E = (int)ceil(log10((dmin * 0.001 * m_layout->Scale) / StepMax)); |
---|
| 1082 | StepEst = pow(10.0, -(double)E) * (dmin * 0.001) * m_layout->Scale - epsilon; |
---|
| 1083 | |
---|
| 1084 | /* Force labelling to be in multiples of 1, 2, or 5 */ |
---|
| 1085 | Step = (StepEst <= 1.0 ? 1 : (StepEst <= 2.0 ? 2 : 5)); |
---|
| 1086 | |
---|
| 1087 | /* Work out actual length of each scale bar division */ |
---|
| 1088 | d = Step * pow(10.0, (double)E) / m_layout->Scale * 1000.0; |
---|
| 1089 | |
---|
[ccb83b7] | 1090 | /* FIXME: Non-metric units here... */ |
---|
[79c239e] | 1091 | /* Choose appropriate units, s.t. if possible E is >=0 and minimized */ |
---|
[ccb83b7] | 1092 | int units; |
---|
| 1093 | if (E >= 3) { |
---|
| 1094 | E -= 3; |
---|
| 1095 | units = /*km*/423; |
---|
| 1096 | } else if (E >= 0) { |
---|
| 1097 | units = /*m*/424; |
---|
| 1098 | } else { |
---|
| 1099 | E += 2; |
---|
| 1100 | units = /*cm*/425; |
---|
| 1101 | } |
---|
[79c239e] | 1102 | |
---|
[5627cbb] | 1103 | buf = wmsg(/*Scale*/154); |
---|
[79c239e] | 1104 | |
---|
| 1105 | /* Add units used - eg. "Scale (10m)" */ |
---|
[ccb83b7] | 1106 | double pow10_E = pow(10.0, (double)E); |
---|
| 1107 | if (E >= 0) { |
---|
| 1108 | buf += wxString::Format(wxT(" (%.f%s)"), pow10_E, wmsg(units).c_str()); |
---|
| 1109 | } else { |
---|
| 1110 | int sf = -(int)floor(E); |
---|
| 1111 | buf += wxString::Format(wxT(" (%.*f%s)"), sf, pow10_E, wmsg(units).c_str()); |
---|
| 1112 | } |
---|
[79c239e] | 1113 | SetColour(PR_COLOUR_TEXT); |
---|
| 1114 | MOVEMM(x, y + 4); WriteString(buf); |
---|
| 1115 | |
---|
| 1116 | /* Work out how many divisions there will be */ |
---|
| 1117 | n = (int)(MaxLength / d); |
---|
| 1118 | |
---|
| 1119 | SetColour(PR_COLOUR_FRAME); |
---|
| 1120 | |
---|
| 1121 | long Y = long(y * m_layout->scY); |
---|
| 1122 | long Y2 = long((y + 3) * m_layout->scY); |
---|
| 1123 | long X = long(x * m_layout->scX); |
---|
| 1124 | long X2 = long((x + n * d) * m_layout->scX); |
---|
| 1125 | |
---|
| 1126 | /* Draw top of scale bar */ |
---|
| 1127 | MoveTo(X2, Y2); |
---|
| 1128 | DrawTo(X, Y2); |
---|
| 1129 | #if 0 |
---|
| 1130 | DrawTo(X2, Y); |
---|
| 1131 | DrawTo(X, Y); |
---|
| 1132 | MOVEMM(x + n * d, y); DRAWMM(x, y); |
---|
| 1133 | #endif |
---|
| 1134 | /* Draw divisions and label them */ |
---|
| 1135 | for (c = 0; c <= n; c++) { |
---|
| 1136 | SetColour(PR_COLOUR_FRAME); |
---|
| 1137 | X = long((x + c * d) * m_layout->scX); |
---|
| 1138 | MoveTo(X, Y); |
---|
| 1139 | DrawTo(X, Y2); |
---|
| 1140 | #if 0 // Don't waste toner! |
---|
| 1141 | /* Draw a "zebra crossing" scale bar. */ |
---|
| 1142 | if (c < n && (c & 1) == 0) { |
---|
| 1143 | X2 = long((x + (c + 1) * d) * m_layout->scX); |
---|
| 1144 | SolidRectangle(X, Y, X2 - X, Y2 - Y); |
---|
| 1145 | } |
---|
| 1146 | #endif |
---|
[5627cbb] | 1147 | buf.Printf(wxT("%d"), c * Step); |
---|
[79c239e] | 1148 | SetColour(PR_COLOUR_TEXT); |
---|
[30f1caa] | 1149 | MOVEMM(x + c * d - buf.length(), y - 5); |
---|
[79c239e] | 1150 | WriteString(buf); |
---|
| 1151 | } |
---|
| 1152 | } |
---|
| 1153 | |
---|
| 1154 | #if 0 |
---|
[ee05463] | 1155 | void |
---|
[79c239e] | 1156 | make_calibration(layout *l) { |
---|
| 1157 | img_point pt = { 0.0, 0.0, 0.0 }; |
---|
| 1158 | l->xMax = l->yMax = 0.1; |
---|
| 1159 | l->xMin = l->yMin = 0; |
---|
| 1160 | |
---|
| 1161 | stack(l,img_MOVE, NULL, &pt); |
---|
| 1162 | pt.x = 0.1; |
---|
| 1163 | stack(l,img_LINE, NULL, &pt); |
---|
| 1164 | pt.y = 0.1; |
---|
| 1165 | stack(l,img_LINE, NULL, &pt); |
---|
| 1166 | pt.x = 0.0; |
---|
| 1167 | stack(l,img_LINE, NULL, &pt); |
---|
| 1168 | pt.y = 0.0; |
---|
| 1169 | stack(l,img_LINE, NULL, &pt); |
---|
| 1170 | pt.x = 0.05; |
---|
| 1171 | pt.y = 0.001; |
---|
| 1172 | stack(l,img_LABEL, "10cm", &pt); |
---|
| 1173 | pt.x = 0.001; |
---|
| 1174 | pt.y = 0.05; |
---|
| 1175 | stack(l,img_LABEL, "10cm", &pt); |
---|
| 1176 | l->Scale = 1.0; |
---|
| 1177 | } |
---|
| 1178 | #endif |
---|
| 1179 | |
---|
| 1180 | int |
---|
| 1181 | svxPrintout::next_page(int *pstate, char **q, int pageLim) |
---|
| 1182 | { |
---|
| 1183 | char *p; |
---|
| 1184 | int page; |
---|
| 1185 | int c; |
---|
| 1186 | p = *q; |
---|
| 1187 | if (*pstate > 0) { |
---|
| 1188 | /* doing a range */ |
---|
| 1189 | (*pstate)++; |
---|
| 1190 | SVX_ASSERT(*p == '-'); |
---|
| 1191 | p++; |
---|
| 1192 | while (isspace((unsigned char)*p)) p++; |
---|
| 1193 | if (sscanf(p, "%u%n", &page, &c) > 0) { |
---|
| 1194 | p += c; |
---|
| 1195 | } else { |
---|
| 1196 | page = pageLim; |
---|
| 1197 | } |
---|
| 1198 | if (*pstate > page) goto err; |
---|
| 1199 | if (*pstate < page) return *pstate; |
---|
| 1200 | *q = p; |
---|
| 1201 | *pstate = 0; |
---|
| 1202 | return page; |
---|
| 1203 | } |
---|
| 1204 | |
---|
| 1205 | while (isspace((unsigned char)*p) || *p == ',') p++; |
---|
| 1206 | |
---|
| 1207 | if (!*p) return 0; /* done */ |
---|
| 1208 | |
---|
| 1209 | if (*p == '-') { |
---|
| 1210 | *q = p; |
---|
| 1211 | *pstate = 1; |
---|
| 1212 | return 1; /* range with initial parameter omitted */ |
---|
| 1213 | } |
---|
| 1214 | if (sscanf(p, "%u%n", &page, &c) > 0) { |
---|
| 1215 | p += c; |
---|
| 1216 | while (isspace((unsigned char)*p)) p++; |
---|
| 1217 | *q = p; |
---|
| 1218 | if (0 < page && page <= pageLim) { |
---|
| 1219 | if (*p == '-') *pstate = page; /* range with start */ |
---|
| 1220 | return page; |
---|
| 1221 | } |
---|
| 1222 | } |
---|
| 1223 | err: |
---|
| 1224 | *pstate = -1; |
---|
| 1225 | return 0; |
---|
| 1226 | } |
---|
| 1227 | |
---|
| 1228 | /* Draws in alignment marks on each page or borders on edge pages */ |
---|
| 1229 | void |
---|
| 1230 | svxPrintout::drawticks(border clip, int tsize, int x, int y) |
---|
| 1231 | { |
---|
| 1232 | long i; |
---|
| 1233 | int s = tsize * 4; |
---|
| 1234 | int o = s / 8; |
---|
| 1235 | bool fAtCorner = fFalse; |
---|
| 1236 | SetColour(PR_COLOUR_FRAME); |
---|
| 1237 | if (x == 0 && m_layout->Border) { |
---|
| 1238 | /* solid left border */ |
---|
| 1239 | MoveTo(clip.x_min, clip.y_min); |
---|
| 1240 | DrawTo(clip.x_min, clip.y_max); |
---|
| 1241 | fAtCorner = fTrue; |
---|
| 1242 | } else { |
---|
| 1243 | if (x > 0 || y > 0) { |
---|
| 1244 | MoveTo(clip.x_min, clip.y_min); |
---|
| 1245 | DrawTo(clip.x_min, clip.y_min + tsize); |
---|
| 1246 | } |
---|
| 1247 | if (s && x > 0 && m_layout->Cutlines) { |
---|
| 1248 | /* dashed left border */ |
---|
| 1249 | i = (clip.y_max - clip.y_min) - |
---|
| 1250 | (tsize + ((clip.y_max - clip.y_min - tsize * 2L) % s) / 2); |
---|
| 1251 | for ( ; i > tsize; i -= s) { |
---|
| 1252 | MoveTo(clip.x_min, clip.y_max - (i + o)); |
---|
| 1253 | DrawTo(clip.x_min, clip.y_max - (i - o)); |
---|
| 1254 | } |
---|
| 1255 | } |
---|
| 1256 | if (x > 0 || y < m_layout->pagesY - 1) { |
---|
| 1257 | MoveTo(clip.x_min, clip.y_max - tsize); |
---|
| 1258 | DrawTo(clip.x_min, clip.y_max); |
---|
| 1259 | fAtCorner = fTrue; |
---|
| 1260 | } |
---|
| 1261 | } |
---|
| 1262 | |
---|
| 1263 | if (y == m_layout->pagesY - 1 && m_layout->Border) { |
---|
| 1264 | /* solid top border */ |
---|
| 1265 | if (!fAtCorner) MoveTo(clip.x_min, clip.y_max); |
---|
| 1266 | DrawTo(clip.x_max, clip.y_max); |
---|
| 1267 | fAtCorner = fTrue; |
---|
| 1268 | } else { |
---|
| 1269 | if (y < m_layout->pagesY - 1 || x > 0) { |
---|
| 1270 | if (!fAtCorner) MoveTo(clip.x_min, clip.y_max); |
---|
| 1271 | DrawTo(clip.x_min + tsize, clip.y_max); |
---|
| 1272 | } |
---|
| 1273 | if (s && y < m_layout->pagesY - 1 && m_layout->Cutlines) { |
---|
| 1274 | /* dashed top border */ |
---|
| 1275 | i = (clip.x_max - clip.x_min) - |
---|
| 1276 | (tsize + ((clip.x_max - clip.x_min - tsize * 2L) % s) / 2); |
---|
| 1277 | for ( ; i > tsize; i -= s) { |
---|
| 1278 | MoveTo(clip.x_max - (i + o), clip.y_max); |
---|
| 1279 | DrawTo(clip.x_max - (i - o), clip.y_max); |
---|
| 1280 | } |
---|
| 1281 | } |
---|
| 1282 | if (y < m_layout->pagesY - 1 || x < m_layout->pagesX - 1) { |
---|
| 1283 | MoveTo(clip.x_max - tsize, clip.y_max); |
---|
| 1284 | DrawTo(clip.x_max, clip.y_max); |
---|
| 1285 | fAtCorner = fTrue; |
---|
| 1286 | } else { |
---|
| 1287 | fAtCorner = fFalse; |
---|
| 1288 | } |
---|
| 1289 | } |
---|
| 1290 | |
---|
| 1291 | if (x == m_layout->pagesX - 1 && m_layout->Border) { |
---|
| 1292 | /* solid right border */ |
---|
| 1293 | if (!fAtCorner) MoveTo(clip.x_max, clip.y_max); |
---|
| 1294 | DrawTo(clip.x_max, clip.y_min); |
---|
| 1295 | fAtCorner = fTrue; |
---|
| 1296 | } else { |
---|
| 1297 | if (x < m_layout->pagesX - 1 || y < m_layout->pagesY - 1) { |
---|
| 1298 | if (!fAtCorner) MoveTo(clip.x_max, clip.y_max); |
---|
| 1299 | DrawTo(clip.x_max, clip.y_max - tsize); |
---|
| 1300 | } |
---|
| 1301 | if (s && x < m_layout->pagesX - 1 && m_layout->Cutlines) { |
---|
| 1302 | /* dashed right border */ |
---|
| 1303 | i = (clip.y_max - clip.y_min) - |
---|
| 1304 | (tsize + ((clip.y_max - clip.y_min - tsize * 2L) % s) / 2); |
---|
| 1305 | for ( ; i > tsize; i -= s) { |
---|
| 1306 | MoveTo(clip.x_max, clip.y_min + (i + o)); |
---|
| 1307 | DrawTo(clip.x_max, clip.y_min + (i - o)); |
---|
| 1308 | } |
---|
| 1309 | } |
---|
| 1310 | if (x < m_layout->pagesX - 1 || y > 0) { |
---|
| 1311 | MoveTo(clip.x_max, clip.y_min + tsize); |
---|
| 1312 | DrawTo(clip.x_max, clip.y_min); |
---|
| 1313 | fAtCorner = fTrue; |
---|
| 1314 | } else { |
---|
| 1315 | fAtCorner = fFalse; |
---|
| 1316 | } |
---|
| 1317 | } |
---|
| 1318 | |
---|
| 1319 | if (y == 0 && m_layout->Border) { |
---|
| 1320 | /* solid bottom border */ |
---|
| 1321 | if (!fAtCorner) MoveTo(clip.x_max, clip.y_min); |
---|
| 1322 | DrawTo(clip.x_min, clip.y_min); |
---|
| 1323 | } else { |
---|
| 1324 | if (y > 0 || x < m_layout->pagesX - 1) { |
---|
| 1325 | if (!fAtCorner) MoveTo(clip.x_max, clip.y_min); |
---|
| 1326 | DrawTo(clip.x_max - tsize, clip.y_min); |
---|
| 1327 | } |
---|
| 1328 | if (s && y > 0 && m_layout->Cutlines) { |
---|
| 1329 | /* dashed bottom border */ |
---|
| 1330 | i = (clip.x_max - clip.x_min) - |
---|
| 1331 | (tsize + ((clip.x_max - clip.x_min - tsize * 2L) % s) / 2); |
---|
| 1332 | for ( ; i > tsize; i -= s) { |
---|
| 1333 | MoveTo(clip.x_min + (i + o), clip.y_min); |
---|
| 1334 | DrawTo(clip.x_min + (i - o), clip.y_min); |
---|
| 1335 | } |
---|
| 1336 | } |
---|
| 1337 | if (y > 0 || x > 0) { |
---|
| 1338 | MoveTo(clip.x_min + tsize, clip.y_min); |
---|
| 1339 | DrawTo(clip.x_min, clip.y_min); |
---|
| 1340 | } |
---|
| 1341 | } |
---|
| 1342 | } |
---|
| 1343 | |
---|
[ee05463] | 1344 | bool |
---|
[79c239e] | 1345 | svxPrintout::OnPrintPage(int pageNum) { |
---|
| 1346 | GetPageSizePixels(&xpPageWidth, &ypPageDepth); |
---|
| 1347 | pdc = GetDC(); |
---|
[cca2ce1] | 1348 | #ifdef AVEN_PRINT_PREVIEW |
---|
[79c239e] | 1349 | if (IsPreview()) { |
---|
| 1350 | int dcx, dcy; |
---|
| 1351 | pdc->GetSize(&dcx, &dcy); |
---|
| 1352 | pdc->SetUserScale((double)dcx / xpPageWidth, (double)dcy / ypPageDepth); |
---|
| 1353 | } |
---|
[cca2ce1] | 1354 | #endif |
---|
[79c239e] | 1355 | |
---|
| 1356 | layout * l = m_layout; |
---|
| 1357 | { |
---|
| 1358 | int pwidth, pdepth; |
---|
| 1359 | GetPageSizeMM(&pwidth, &pdepth); |
---|
| 1360 | l->scX = (double)xpPageWidth / pwidth; |
---|
| 1361 | l->scY = (double)ypPageDepth / pdepth; |
---|
| 1362 | font_scaling_x = l->scX * (25.4 / 72.0); |
---|
| 1363 | font_scaling_y = l->scY * (25.4 / 72.0); |
---|
| 1364 | MarginLeft = m_data->GetMarginTopLeft().x; |
---|
| 1365 | MarginTop = m_data->GetMarginTopLeft().y; |
---|
| 1366 | MarginBottom = m_data->GetMarginBottomRight().y; |
---|
| 1367 | MarginRight = m_data->GetMarginBottomRight().x; |
---|
| 1368 | xpPageWidth -= (int)(l->scX * (MarginLeft + MarginRight)); |
---|
| 1369 | ypPageDepth -= (int)(l->scY * (10 + MarginBottom + MarginRight)); |
---|
| 1370 | // xpPageWidth -= 1; |
---|
| 1371 | pdepth -= 10; |
---|
| 1372 | x_offset = (long)(l->scX * MarginLeft); |
---|
| 1373 | y_offset = (long)(l->scY * MarginTop); |
---|
| 1374 | l->PaperWidth = pwidth -= MarginLeft + MarginRight; |
---|
| 1375 | l->PaperDepth = pdepth -= MarginTop + MarginBottom; |
---|
| 1376 | } |
---|
| 1377 | |
---|
[5940815] | 1378 | double SIN = sin(rad(l->rot)); |
---|
| 1379 | double COS = cos(rad(l->rot)); |
---|
| 1380 | double SINT = sin(rad(l->tilt)); |
---|
| 1381 | double COST = cos(rad(l->tilt)); |
---|
[79c239e] | 1382 | |
---|
| 1383 | NewPage(pageNum, l->pagesX, l->pagesY); |
---|
| 1384 | |
---|
[256c4c8] | 1385 | if (l->Legend && pageNum == (l->pagesY - 1) * l->pagesX + 1) { |
---|
[79c239e] | 1386 | SetFont(PR_FONT_DEFAULT); |
---|
| 1387 | draw_info_box(); |
---|
| 1388 | } |
---|
| 1389 | |
---|
[55918ca] | 1390 | pdc->SetClippingRegion(x_offset, y_offset,xpPageWidth+1, ypPageDepth+1); |
---|
| 1391 | |
---|
[741d94f] | 1392 | const double Sc = 1000 / l->Scale; |
---|
[79c239e] | 1393 | |
---|
[d713e5d] | 1394 | if (l->show_mask & LEGS) { |
---|
[ce403f1] | 1395 | SetColour(PR_COLOUR_LEG); |
---|
[c61aa79] | 1396 | list<traverse>::const_iterator trav = mainfrm->traverses_begin(); |
---|
| 1397 | list<traverse>::const_iterator tend = mainfrm->traverses_end(); |
---|
[ce403f1] | 1398 | for ( ; trav != tend; ++trav) { |
---|
[d4650b3] | 1399 | vector<PointInfo>::const_iterator pos = trav->begin(); |
---|
| 1400 | vector<PointInfo>::const_iterator end = trav->end(); |
---|
[ce403f1] | 1401 | for ( ; pos != end; ++pos) { |
---|
| 1402 | double x = pos->GetX(); |
---|
| 1403 | double y = pos->GetY(); |
---|
| 1404 | double z = pos->GetZ(); |
---|
| 1405 | double X = x * COS - y * SIN; |
---|
[7a57dc7] | 1406 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
---|
[ce403f1] | 1407 | long px = (long)((X * Sc + l->xOrg) * l->scX); |
---|
| 1408 | long py = (long)((Y * Sc + l->yOrg) * l->scY); |
---|
| 1409 | if (pos == trav->begin()) { |
---|
| 1410 | MoveTo(px, py); |
---|
| 1411 | } else { |
---|
| 1412 | DrawTo(px, py); |
---|
| 1413 | } |
---|
| 1414 | } |
---|
[ee05463] | 1415 | } |
---|
| 1416 | } |
---|
| 1417 | |
---|
[d713e5d] | 1418 | if ((l->show_mask & XSECT) && |
---|
| 1419 | (l->tilt == 0.0 || l->tilt == 90.0 || l->tilt == -90.0)) { |
---|
[ee05463] | 1420 | list<vector<XSect> >::const_iterator trav = mainfrm->tubes_begin(); |
---|
| 1421 | list<vector<XSect> >::const_iterator tend = mainfrm->tubes_end(); |
---|
| 1422 | for ( ; trav != tend; ++trav) { |
---|
| 1423 | if (l->tilt == 90.0 || l->tilt == -90.0) PlotLR(*trav); |
---|
[0fdd3aa] | 1424 | if (l->tilt == 0.0) PlotUD(*trav); |
---|
[ce403f1] | 1425 | } |
---|
| 1426 | } |
---|
| 1427 | |
---|
[d713e5d] | 1428 | if (l->show_mask & SURF) { |
---|
[ce403f1] | 1429 | SetColour(PR_COLOUR_SURFACE_LEG); |
---|
[c61aa79] | 1430 | list<traverse>::const_iterator trav = mainfrm->surface_traverses_begin(); |
---|
| 1431 | list<traverse>::const_iterator tend = mainfrm->surface_traverses_end(); |
---|
[ce403f1] | 1432 | for ( ; trav != tend; ++trav) { |
---|
[d4650b3] | 1433 | vector<PointInfo>::const_iterator pos = trav->begin(); |
---|
| 1434 | vector<PointInfo>::const_iterator end = trav->end(); |
---|
[ce403f1] | 1435 | for ( ; pos != end; ++pos) { |
---|
| 1436 | double x = pos->GetX(); |
---|
| 1437 | double y = pos->GetY(); |
---|
| 1438 | double z = pos->GetZ(); |
---|
| 1439 | double X = x * COS - y * SIN; |
---|
[1b2e819] | 1440 | double Y = z * COST - (x * SIN + y * COS) * SINT; |
---|
[ce403f1] | 1441 | long px = (long)((X * Sc + l->xOrg) * l->scX); |
---|
| 1442 | long py = (long)((Y * Sc + l->yOrg) * l->scY); |
---|
| 1443 | if (pos == trav->begin()) { |
---|
| 1444 | MoveTo(px, py); |
---|
[79c239e] | 1445 | } else { |
---|
[ce403f1] | 1446 | DrawTo(px, py); |
---|
[79c239e] | 1447 | } |
---|
| 1448 | } |
---|
| 1449 | } |
---|
| 1450 | } |
---|
| 1451 | |
---|
[d713e5d] | 1452 | if (l->show_mask & (LABELS|STNS)) { |
---|
| 1453 | if (l->show_mask & LABELS) SetFont(PR_FONT_LABELS); |
---|
[ce403f1] | 1454 | list<LabelInfo*>::const_iterator label = mainfrm->GetLabels(); |
---|
| 1455 | while (label != mainfrm->GetLabelsEnd()) { |
---|
[79c239e] | 1456 | double px = (*label)->GetX(); |
---|
| 1457 | double py = (*label)->GetY(); |
---|
| 1458 | double pz = (*label)->GetZ(); |
---|
[d713e5d] | 1459 | if ((l->show_mask & SURF) || (*label)->IsUnderground()) { |
---|
[79c239e] | 1460 | double X = px * COS - py * SIN; |
---|
[7a57dc7] | 1461 | double Y = pz * COST - (px * SIN + py * COS) * SINT; |
---|
[79c239e] | 1462 | long xnew, ynew; |
---|
| 1463 | xnew = (long)((X * Sc + l->xOrg) * l->scX); |
---|
| 1464 | ynew = (long)((Y * Sc + l->yOrg) * l->scY); |
---|
[d713e5d] | 1465 | if (l->show_mask & STNS) { |
---|
[79c239e] | 1466 | SetColour(PR_COLOUR_CROSS); |
---|
| 1467 | DrawCross(xnew, ynew); |
---|
| 1468 | } |
---|
[d713e5d] | 1469 | if (l->show_mask & LABELS) { |
---|
[79c239e] | 1470 | SetColour(PR_COLOUR_LABELS); |
---|
| 1471 | MoveTo(xnew, ynew); |
---|
| 1472 | WriteString((*label)->GetText()); |
---|
| 1473 | } |
---|
| 1474 | } |
---|
| 1475 | ++label; |
---|
| 1476 | } |
---|
| 1477 | } |
---|
| 1478 | |
---|
| 1479 | return true; |
---|
| 1480 | } |
---|
| 1481 | |
---|
[13da582] | 1482 | void |
---|
| 1483 | svxPrintout::GetPageInfo(int *minPage, int *maxPage, |
---|
| 1484 | int *pageFrom, int *pageTo) |
---|
| 1485 | { |
---|
| 1486 | *minPage = *pageFrom = 1; |
---|
| 1487 | *maxPage = *pageTo = m_layout->pages; |
---|
| 1488 | } |
---|
| 1489 | |
---|
| 1490 | bool |
---|
| 1491 | svxPrintout::HasPage(int pageNum) { |
---|
| 1492 | return (pageNum <= m_layout->pages); |
---|
| 1493 | } |
---|
| 1494 | |
---|
[ee05463] | 1495 | void |
---|
[79c239e] | 1496 | svxPrintout::OnBeginPrinting() { |
---|
[ee05463] | 1497 | FILE *fh_list[4]; |
---|
[79c239e] | 1498 | |
---|
| 1499 | FILE **pfh = fh_list; |
---|
| 1500 | FILE *fh; |
---|
| 1501 | const char *pth_cfg; |
---|
| 1502 | char *print_ini; |
---|
| 1503 | |
---|
| 1504 | /* ini files searched in this order: |
---|
| 1505 | * ~/.survex/print.ini [unix only] |
---|
| 1506 | * /etc/survex/print.ini [unix only] |
---|
| 1507 | * <support file directory>/myprint.ini [not unix] |
---|
| 1508 | * <support file directory>/print.ini [must exist] |
---|
| 1509 | */ |
---|
| 1510 | |
---|
[affaeee] | 1511 | #ifdef __UNIX__ |
---|
[79c239e] | 1512 | pth_cfg = getenv("HOME"); |
---|
| 1513 | if (pth_cfg) { |
---|
| 1514 | fh = fopenWithPthAndExt(pth_cfg, ".survex/print."EXT_INI, NULL, |
---|
| 1515 | "rb", NULL); |
---|
| 1516 | if (fh) *pfh++ = fh; |
---|
| 1517 | } |
---|
| 1518 | pth_cfg = msg_cfgpth(); |
---|
| 1519 | fh = fopenWithPthAndExt(NULL, "/etc/survex/print."EXT_INI, NULL, "rb", |
---|
| 1520 | NULL); |
---|
| 1521 | if (fh) *pfh++ = fh; |
---|
| 1522 | #else |
---|
| 1523 | pth_cfg = msg_cfgpth(); |
---|
| 1524 | print_ini = add_ext("myprint", EXT_INI); |
---|
| 1525 | fh = fopenWithPthAndExt(pth_cfg, print_ini, NULL, "rb", NULL); |
---|
| 1526 | if (fh) *pfh++ = fh; |
---|
| 1527 | #endif |
---|
| 1528 | print_ini = add_ext("print", EXT_INI); |
---|
| 1529 | fh = fopenWithPthAndExt(pth_cfg, print_ini, NULL, "rb", NULL); |
---|
[98cf5b5] | 1530 | if (!fh) fatalerror(/*Couldn’t open file “%s”*/24, print_ini); |
---|
[79c239e] | 1531 | *pfh++ = fh; |
---|
| 1532 | *pfh = NULL; |
---|
| 1533 | Init(pfh, false); |
---|
| 1534 | for (pfh = fh_list; *pfh; pfh++) (void)fclose(*pfh); |
---|
| 1535 | Pre(); |
---|
[0804fbe] | 1536 | m_layout->footer = wmsg(/*Survey “%s” Page %d (of %d) Processed on %s*/167); |
---|
[79c239e] | 1537 | } |
---|
| 1538 | |
---|
| 1539 | void |
---|
| 1540 | svxPrintout::OnEndPrinting() { |
---|
[03e2031] | 1541 | delete font_labels; |
---|
| 1542 | delete font_default; |
---|
| 1543 | delete pen_frame; |
---|
| 1544 | delete pen_leg; |
---|
| 1545 | delete pen_surface_leg; |
---|
| 1546 | delete pen_cross; |
---|
[79c239e] | 1547 | } |
---|
| 1548 | |
---|
| 1549 | |
---|
| 1550 | // prcore -> wx.grafx (calls to move pens around and stuff - low level) |
---|
| 1551 | // this seems to have been done... |
---|
| 1552 | |
---|
| 1553 | |
---|
| 1554 | |
---|
| 1555 | static border clip; |
---|
| 1556 | |
---|
| 1557 | |
---|
| 1558 | int |
---|
| 1559 | svxPrintout::check_intersection(long x_p, long y_p) |
---|
| 1560 | { |
---|
| 1561 | #define U 1 |
---|
| 1562 | #define D 2 |
---|
| 1563 | #define L 4 |
---|
| 1564 | #define R 8 |
---|
| 1565 | int mask_p = 0, mask_t = 0; |
---|
| 1566 | if (x_p < 0) |
---|
| 1567 | mask_p = L; |
---|
| 1568 | else if (x_p > xpPageWidth) |
---|
| 1569 | mask_p = R; |
---|
| 1570 | |
---|
| 1571 | if (y_p < 0) |
---|
| 1572 | mask_p |= D; |
---|
| 1573 | else if (y_p > ypPageDepth) |
---|
| 1574 | mask_p |= U; |
---|
| 1575 | |
---|
| 1576 | if (x_t < 0) |
---|
| 1577 | mask_t = L; |
---|
| 1578 | else if (x_t > xpPageWidth) |
---|
| 1579 | mask_t = R; |
---|
| 1580 | |
---|
| 1581 | if (y_t < 0) |
---|
| 1582 | mask_t |= D; |
---|
| 1583 | else if (y_t > ypPageDepth) |
---|
| 1584 | mask_t |= U; |
---|
| 1585 | |
---|
| 1586 | #if 0 |
---|
| 1587 | /* approximation to correct answer */ |
---|
| 1588 | return !(mask_t & mask_p); |
---|
| 1589 | #else |
---|
| 1590 | /* One end of the line is on the page */ |
---|
| 1591 | if (!mask_t || !mask_p) return 1; |
---|
| 1592 | |
---|
| 1593 | /* whole line is above, left, right, or below page */ |
---|
| 1594 | if (mask_t & mask_p) return 0; |
---|
| 1595 | |
---|
| 1596 | if (mask_t == 0) mask_t = mask_p; |
---|
| 1597 | if (mask_t & U) { |
---|
| 1598 | double v = (double)(y_p - ypPageDepth) / (y_p - y_t); |
---|
| 1599 | return v >= 0 && v <= 1; |
---|
| 1600 | } |
---|
| 1601 | if (mask_t & D) { |
---|
| 1602 | double v = (double)y_p / (y_p - y_t); |
---|
| 1603 | return v >= 0 && v <= 1; |
---|
| 1604 | } |
---|
| 1605 | if (mask_t & R) { |
---|
| 1606 | double v = (double)(x_p - xpPageWidth) / (x_p - x_t); |
---|
| 1607 | return v >= 0 && v <= 1; |
---|
| 1608 | } |
---|
| 1609 | SVX_ASSERT(mask_t & L); |
---|
| 1610 | { |
---|
| 1611 | double v = (double)x_p / (x_p - x_t); |
---|
| 1612 | return v >= 0 && v <= 1; |
---|
| 1613 | } |
---|
| 1614 | #endif |
---|
| 1615 | #undef U |
---|
| 1616 | #undef D |
---|
| 1617 | #undef L |
---|
| 1618 | #undef R |
---|
| 1619 | } |
---|
| 1620 | |
---|
| 1621 | void |
---|
| 1622 | svxPrintout::MoveTo(long x, long y) |
---|
| 1623 | { |
---|
| 1624 | x_t = x_offset + x - clip.x_min; |
---|
| 1625 | y_t = y_offset + clip.y_max - y; |
---|
| 1626 | } |
---|
| 1627 | |
---|
| 1628 | void |
---|
| 1629 | svxPrintout::DrawTo(long x, long y) |
---|
| 1630 | { |
---|
| 1631 | long x_p = x_t, y_p = y_t; |
---|
| 1632 | x_t = x_offset + x - clip.x_min; |
---|
| 1633 | y_t = y_offset + clip.y_max - y; |
---|
| 1634 | if (cur_pass != -1) { |
---|
[5940815] | 1635 | pdc->DrawLine(x_p, y_p, x_t, y_t); |
---|
[79c239e] | 1636 | } else { |
---|
| 1637 | if (check_intersection(x_p, y_p)) fBlankPage = fFalse; |
---|
| 1638 | } |
---|
| 1639 | } |
---|
| 1640 | |
---|
| 1641 | #define POINTS_PER_INCH 72.0 |
---|
| 1642 | #define POINTS_PER_MM (POINTS_PER_INCH / MM_PER_INCH) |
---|
| 1643 | #define PWX_CROSS_SIZE (int)(2 * m_layout->scX / POINTS_PER_MM) |
---|
| 1644 | |
---|
| 1645 | void |
---|
| 1646 | svxPrintout::DrawCross(long x, long y) |
---|
| 1647 | { |
---|
| 1648 | if (cur_pass != -1) { |
---|
| 1649 | MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
---|
| 1650 | DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
---|
| 1651 | MoveTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
---|
| 1652 | DrawTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
---|
| 1653 | MoveTo(x, y); |
---|
| 1654 | } else { |
---|
| 1655 | if ((x + PWX_CROSS_SIZE > clip.x_min && |
---|
| 1656 | x - PWX_CROSS_SIZE < clip.x_max) || |
---|
| 1657 | (y + PWX_CROSS_SIZE > clip.y_min && |
---|
| 1658 | y - PWX_CROSS_SIZE < clip.y_max)) { |
---|
| 1659 | fBlankPage = fFalse; |
---|
| 1660 | } |
---|
| 1661 | } |
---|
| 1662 | } |
---|
| 1663 | |
---|
| 1664 | void |
---|
| 1665 | svxPrintout::SetFont(int fontcode) |
---|
| 1666 | { |
---|
| 1667 | switch (fontcode) { |
---|
| 1668 | case PR_FONT_DEFAULT: |
---|
| 1669 | current_font = font_default; |
---|
| 1670 | break; |
---|
| 1671 | case PR_FONT_LABELS: |
---|
| 1672 | current_font = font_labels; |
---|
| 1673 | break; |
---|
| 1674 | default: |
---|
| 1675 | BUG("unknown font code"); |
---|
| 1676 | } |
---|
| 1677 | } |
---|
| 1678 | |
---|
| 1679 | void |
---|
| 1680 | svxPrintout::SetColour(int colourcode) |
---|
| 1681 | { |
---|
| 1682 | switch (colourcode) { |
---|
| 1683 | case PR_COLOUR_TEXT: |
---|
| 1684 | pdc->SetTextForeground(colour_text); |
---|
| 1685 | break; |
---|
| 1686 | case PR_COLOUR_LABELS: |
---|
| 1687 | pdc->SetTextForeground(colour_labels); |
---|
| 1688 | pdc->SetBackgroundMode(wxTRANSPARENT); |
---|
| 1689 | break; |
---|
| 1690 | case PR_COLOUR_FRAME: |
---|
| 1691 | pdc->SetPen(*pen_frame); |
---|
| 1692 | break; |
---|
| 1693 | case PR_COLOUR_LEG: |
---|
| 1694 | pdc->SetPen(*pen_leg); |
---|
| 1695 | break; |
---|
| 1696 | case PR_COLOUR_CROSS: |
---|
| 1697 | pdc->SetPen(*pen_cross); |
---|
| 1698 | break; |
---|
| 1699 | case PR_COLOUR_SURFACE_LEG: |
---|
| 1700 | pdc->SetPen(*pen_surface_leg); |
---|
| 1701 | break; |
---|
| 1702 | default: |
---|
| 1703 | BUG("unknown colour code"); |
---|
| 1704 | } |
---|
| 1705 | } |
---|
| 1706 | |
---|
| 1707 | void |
---|
[5627cbb] | 1708 | svxPrintout::WriteString(const wxString & s) |
---|
[79c239e] | 1709 | { |
---|
| 1710 | double xsc, ysc; |
---|
| 1711 | pdc->GetUserScale(&xsc, &ysc); |
---|
| 1712 | pdc->SetUserScale(xsc * font_scaling_x, ysc * font_scaling_y); |
---|
| 1713 | pdc->SetFont(*current_font); |
---|
| 1714 | int w, h; |
---|
| 1715 | if (cur_pass != -1) { |
---|
[5627cbb] | 1716 | pdc->GetTextExtent(wxT("My"), &w, &h); |
---|
[ee05463] | 1717 | pdc->DrawText(s, |
---|
[79c239e] | 1718 | long(x_t / font_scaling_x), |
---|
| 1719 | long(y_t / font_scaling_y) - h); |
---|
| 1720 | } else { |
---|
| 1721 | pdc->GetTextExtent(s, &w, &h); |
---|
| 1722 | if ((y_t + h > 0 && y_t - h < clip.y_max - clip.y_min) || |
---|
| 1723 | (x_t < clip.x_max - clip.x_min && x_t + w > 0)) { |
---|
| 1724 | fBlankPage = fFalse; |
---|
| 1725 | } |
---|
| 1726 | } |
---|
| 1727 | pdc->SetUserScale(xsc, ysc); |
---|
| 1728 | } |
---|
| 1729 | |
---|
| 1730 | void |
---|
| 1731 | svxPrintout::DrawEllipse(long x, long y, long r, long R) |
---|
| 1732 | { |
---|
| 1733 | /* Don't need to check in first-pass - circle is only used in title box */ |
---|
| 1734 | if (cur_pass != -1) { |
---|
| 1735 | x_t = x_offset + x - clip.x_min; |
---|
| 1736 | y_t = y_offset + clip.y_max - y; |
---|
[2bf75f3] | 1737 | const wxBrush & save_brush = pdc->GetBrush(); |
---|
[79c239e] | 1738 | pdc->SetBrush(*wxTRANSPARENT_BRUSH); |
---|
| 1739 | pdc->DrawEllipse(x_t - r, y_t - R, 2 * r, 2 * R); |
---|
[2bf75f3] | 1740 | pdc->SetBrush(save_brush); |
---|
[79c239e] | 1741 | } |
---|
| 1742 | } |
---|
| 1743 | |
---|
| 1744 | void |
---|
| 1745 | svxPrintout::SolidRectangle(long x, long y, long w, long h) |
---|
| 1746 | { |
---|
| 1747 | long X = x_offset + x - clip.x_min; |
---|
| 1748 | long Y = y_offset + clip.y_max - y; |
---|
| 1749 | pdc->SetBrush(*wxBLACK_BRUSH); |
---|
| 1750 | pdc->DrawRectangle(X, Y - h, w, h); |
---|
| 1751 | } |
---|
| 1752 | |
---|
| 1753 | int |
---|
| 1754 | svxPrintout::Pre() |
---|
| 1755 | { |
---|
[5627cbb] | 1756 | font_labels = new wxFont(fontsize_labels, wxDEFAULT, wxNORMAL, wxNORMAL, |
---|
| 1757 | false, wxString(fontname_labels, wxConvUTF8), |
---|
| 1758 | wxFONTENCODING_ISO8859_1); |
---|
| 1759 | font_default = new wxFont(fontsize, wxDEFAULT, wxNORMAL, wxNORMAL, |
---|
| 1760 | false, wxString(fontname, wxConvUTF8), |
---|
| 1761 | wxFONTENCODING_ISO8859_1); |
---|
[79c239e] | 1762 | current_font = font_default; |
---|
[2bf75f3] | 1763 | pen_leg = new wxPen(colour_leg); |
---|
| 1764 | pen_surface_leg = new wxPen(colour_surface_leg); |
---|
| 1765 | pen_cross = new wxPen(colour_cross); |
---|
| 1766 | pen_frame = new wxPen(colour_frame); |
---|
[79c239e] | 1767 | return 1; /* only need 1 pass */ |
---|
| 1768 | } |
---|
| 1769 | |
---|
| 1770 | void |
---|
| 1771 | svxPrintout::NewPage(int pg, int pagesX, int pagesY) |
---|
| 1772 | { |
---|
| 1773 | int x, y; |
---|
| 1774 | x = (pg - 1) % pagesX; |
---|
| 1775 | y = pagesY - 1 - ((pg - 1) / pagesX); |
---|
| 1776 | |
---|
| 1777 | clip.x_min = (long)x * xpPageWidth; |
---|
| 1778 | clip.y_min = (long)y * ypPageDepth; |
---|
| 1779 | clip.x_max = clip.x_min + xpPageWidth; /* dm/pcl/ps had -1; */ |
---|
| 1780 | clip.y_max = clip.y_min + ypPageDepth; /* dm/pcl/ps had -1; */ |
---|
| 1781 | |
---|
| 1782 | //we have to write the footer here. PostScript is being weird. Really weird. |
---|
| 1783 | pdc->SetFont(*font_labels); |
---|
[0f8ab4d] | 1784 | MoveTo(clip.x_min, clip.y_min - (long)(7 * m_layout->scY)); |
---|
| 1785 | wxString footer; |
---|
| 1786 | footer.Printf(m_layout->footer, |
---|
| 1787 | m_layout->title.c_str(), |
---|
| 1788 | pg, |
---|
| 1789 | m_layout->pagesX * m_layout->pagesY, |
---|
| 1790 | m_layout->datestamp.c_str()); |
---|
| 1791 | WriteString(footer); |
---|
[79c239e] | 1792 | pdc->DestroyClippingRegion(); |
---|
| 1793 | drawticks(clip, (int)(9 * m_layout->scX / POINTS_PER_MM), x, y); |
---|
| 1794 | } |
---|
| 1795 | |
---|
[741d94f] | 1796 | void |
---|
[ee05463] | 1797 | svxPrintout::PlotLR(const vector<XSect> & centreline) |
---|
[741d94f] | 1798 | { |
---|
| 1799 | assert(centreline.size() > 1); |
---|
[ee05463] | 1800 | XSect prev_pt_v; |
---|
[741d94f] | 1801 | Vector3 last_right(1.0, 0.0, 0.0); |
---|
| 1802 | |
---|
| 1803 | const double Sc = 1000 / m_layout->Scale; |
---|
[0fdd3aa] | 1804 | const double SIN = sin(rad(m_layout->rot)); |
---|
| 1805 | const double COS = cos(rad(m_layout->rot)); |
---|
[741d94f] | 1806 | |
---|
[ee05463] | 1807 | vector<XSect>::const_iterator i = centreline.begin(); |
---|
| 1808 | vector<XSect>::size_type segment = 0; |
---|
[741d94f] | 1809 | while (i != centreline.end()) { |
---|
| 1810 | // get the coordinates of this vertex |
---|
[ee05463] | 1811 | const XSect & pt_v = *i++; |
---|
[741d94f] | 1812 | |
---|
| 1813 | Vector3 right; |
---|
| 1814 | |
---|
| 1815 | const Vector3 up_v(0.0, 0.0, 1.0); |
---|
| 1816 | |
---|
| 1817 | if (segment == 0) { |
---|
| 1818 | assert(i != centreline.end()); |
---|
| 1819 | // first segment |
---|
| 1820 | |
---|
| 1821 | // get the coordinates of the next vertex |
---|
[ee05463] | 1822 | const XSect & next_pt_v = *i; |
---|
[741d94f] | 1823 | |
---|
| 1824 | // calculate vector from this pt to the next one |
---|
[d67450e] | 1825 | Vector3 leg_v = next_pt_v - pt_v; |
---|
[741d94f] | 1826 | |
---|
| 1827 | // obtain a vector in the LRUD plane |
---|
| 1828 | right = leg_v * up_v; |
---|
| 1829 | if (right.magnitude() == 0) { |
---|
| 1830 | right = last_right; |
---|
| 1831 | } else { |
---|
| 1832 | last_right = right; |
---|
| 1833 | } |
---|
| 1834 | } else if (segment + 1 == centreline.size()) { |
---|
| 1835 | // last segment |
---|
| 1836 | |
---|
| 1837 | // Calculate vector from the previous pt to this one. |
---|
[d67450e] | 1838 | Vector3 leg_v = pt_v - prev_pt_v; |
---|
[741d94f] | 1839 | |
---|
| 1840 | // Obtain a horizontal vector in the LRUD plane. |
---|
| 1841 | right = leg_v * up_v; |
---|
| 1842 | if (right.magnitude() == 0) { |
---|
[d67450e] | 1843 | right = Vector3(last_right.GetX(), last_right.GetY(), 0.0); |
---|
[741d94f] | 1844 | } else { |
---|
| 1845 | last_right = right; |
---|
| 1846 | } |
---|
| 1847 | } else { |
---|
| 1848 | assert(i != centreline.end()); |
---|
| 1849 | // Intermediate segment. |
---|
| 1850 | |
---|
| 1851 | // Get the coordinates of the next vertex. |
---|
[ee05463] | 1852 | const XSect & next_pt_v = *i; |
---|
[741d94f] | 1853 | |
---|
| 1854 | // Calculate vectors from this vertex to the |
---|
| 1855 | // next vertex, and from the previous vertex to |
---|
| 1856 | // this one. |
---|
[d67450e] | 1857 | Vector3 leg1_v = pt_v - prev_pt_v; |
---|
| 1858 | Vector3 leg2_v = next_pt_v - pt_v; |
---|
[741d94f] | 1859 | |
---|
| 1860 | // Obtain horizontal vectors perpendicular to |
---|
| 1861 | // both legs, then normalise and average to get |
---|
| 1862 | // a horizontal bisector. |
---|
| 1863 | Vector3 r1 = leg1_v * up_v; |
---|
| 1864 | Vector3 r2 = leg2_v * up_v; |
---|
| 1865 | r1.normalise(); |
---|
| 1866 | r2.normalise(); |
---|
| 1867 | right = r1 + r2; |
---|
| 1868 | if (right.magnitude() == 0) { |
---|
| 1869 | // This is the "mid-pitch" case... |
---|
| 1870 | right = last_right; |
---|
| 1871 | } |
---|
| 1872 | last_right = right; |
---|
| 1873 | } |
---|
| 1874 | |
---|
| 1875 | // Scale to unit vectors in the LRUD plane. |
---|
| 1876 | right.normalise(); |
---|
| 1877 | |
---|
| 1878 | Double l = pt_v.GetL(); |
---|
| 1879 | Double r = pt_v.GetR(); |
---|
| 1880 | |
---|
| 1881 | if (l >= 0) { |
---|
[d67450e] | 1882 | Vector3 p = pt_v - right * l; |
---|
| 1883 | double X = p.GetX() * COS - p.GetY() * SIN; |
---|
| 1884 | double Y = (p.GetX() * SIN + p.GetY() * COS); |
---|
[741d94f] | 1885 | long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX); |
---|
| 1886 | long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY); |
---|
| 1887 | MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
---|
| 1888 | DrawTo(x, y); |
---|
| 1889 | DrawTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
---|
| 1890 | } |
---|
| 1891 | if (r >= 0) { |
---|
[d67450e] | 1892 | Vector3 p = pt_v + right * r; |
---|
| 1893 | double X = p.GetX() * COS - p.GetY() * SIN; |
---|
| 1894 | double Y = (p.GetX() * SIN + p.GetY() * COS); |
---|
[741d94f] | 1895 | long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX); |
---|
| 1896 | long y = (long)((Y * Sc + m_layout->yOrg) * m_layout->scY); |
---|
| 1897 | MoveTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
---|
| 1898 | DrawTo(x, y); |
---|
| 1899 | DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
---|
| 1900 | } |
---|
| 1901 | |
---|
| 1902 | prev_pt_v = pt_v; |
---|
| 1903 | |
---|
| 1904 | ++segment; |
---|
| 1905 | } |
---|
| 1906 | } |
---|
| 1907 | |
---|
[0fdd3aa] | 1908 | void |
---|
[ee05463] | 1909 | svxPrintout::PlotUD(const vector<XSect> & centreline) |
---|
[0fdd3aa] | 1910 | { |
---|
| 1911 | assert(centreline.size() > 1); |
---|
| 1912 | const double Sc = 1000 / m_layout->Scale; |
---|
| 1913 | |
---|
[ee05463] | 1914 | vector<XSect>::const_iterator i = centreline.begin(); |
---|
[0fdd3aa] | 1915 | while (i != centreline.end()) { |
---|
| 1916 | // get the coordinates of this vertex |
---|
[ee05463] | 1917 | const XSect & pt_v = *i++; |
---|
[0fdd3aa] | 1918 | |
---|
[4f40e6c] | 1919 | Double u = pt_v.GetU(); |
---|
| 1920 | Double d = pt_v.GetD(); |
---|
[0fdd3aa] | 1921 | |
---|
| 1922 | if (u >= 0 || d >= 0) { |
---|
[d67450e] | 1923 | Vector3 p = pt_v; |
---|
[0fdd3aa] | 1924 | double SIN = sin(rad(m_layout->rot)); |
---|
| 1925 | double COS = cos(rad(m_layout->rot)); |
---|
[d67450e] | 1926 | double X = p.GetX() * COS - p.GetY() * SIN; |
---|
| 1927 | double Y = p.GetZ(); |
---|
[0fdd3aa] | 1928 | long x = (long)((X * Sc + m_layout->xOrg) * m_layout->scX); |
---|
| 1929 | if (u >= 0) { |
---|
| 1930 | long y = (long)(((Y + u) * Sc + m_layout->yOrg) * m_layout->scY); |
---|
| 1931 | MoveTo(x - PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
---|
| 1932 | DrawTo(x, y); |
---|
| 1933 | DrawTo(x + PWX_CROSS_SIZE, y + PWX_CROSS_SIZE); |
---|
| 1934 | } |
---|
| 1935 | if (d >= 0) { |
---|
| 1936 | long y = (long)(((Y - d) * Sc + m_layout->yOrg) * m_layout->scY); |
---|
| 1937 | MoveTo(x - PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
---|
| 1938 | DrawTo(x, y); |
---|
| 1939 | DrawTo(x + PWX_CROSS_SIZE, y - PWX_CROSS_SIZE); |
---|
| 1940 | } |
---|
| 1941 | } |
---|
| 1942 | } |
---|
| 1943 | } |
---|
| 1944 | |
---|
[79c239e] | 1945 | static wxColour |
---|
| 1946 | to_rgb(const char *var, char *val) |
---|
| 1947 | { |
---|
| 1948 | unsigned long rgb; |
---|
| 1949 | if (!val) return *wxBLACK; |
---|
| 1950 | rgb = as_colour(var, val); |
---|
| 1951 | return wxColour((rgb & 0xff0000) >> 16, (rgb & 0xff00) >> 8, rgb & 0xff); |
---|
| 1952 | } |
---|
| 1953 | |
---|
| 1954 | /* Initialise printer routines */ |
---|
| 1955 | char * |
---|
| 1956 | svxPrintout::Init(FILE **fh_list, bool fCalibrate) |
---|
| 1957 | { |
---|
| 1958 | static const char *vars[] = { |
---|
| 1959 | "font_size_labels", |
---|
| 1960 | "colour_text", |
---|
| 1961 | "colour_labels", |
---|
| 1962 | "colour_frame", |
---|
| 1963 | "colour_legs", |
---|
| 1964 | "colour_crosses", |
---|
| 1965 | "colour_surface_legs", |
---|
| 1966 | NULL |
---|
| 1967 | }; |
---|
| 1968 | char **vals; |
---|
| 1969 | |
---|
[9185847] | 1970 | (void)fCalibrate; /* suppress unused argument warning */ |
---|
[79c239e] | 1971 | |
---|
[9577fcc] | 1972 | vals = ini_read(fh_list, "aven", vars); |
---|
[79c239e] | 1973 | fontsize_labels = 10; |
---|
[9f6ea6c] | 1974 | if (vals[0]) fontsize_labels = as_int(vars[0], vals[0], 1, INT_MAX); |
---|
[79c239e] | 1975 | fontsize = 10; |
---|
| 1976 | |
---|
| 1977 | colour_text = colour_labels = colour_frame = colour_leg = colour_cross = colour_surface_leg = *wxBLACK; |
---|
[9f6ea6c] | 1978 | if (vals[1]) colour_text = to_rgb(vars[1], vals[1]); |
---|
| 1979 | if (vals[2]) colour_labels = to_rgb(vars[2], vals[2]); |
---|
| 1980 | if (vals[3]) colour_frame = to_rgb(vars[3], vals[3]); |
---|
| 1981 | if (vals[4]) colour_leg = to_rgb(vars[4], vals[4]); |
---|
| 1982 | if (vals[5]) colour_cross = to_rgb(vars[5], vals[5]); |
---|
| 1983 | if (vals[6]) colour_surface_leg = to_rgb(vars[6], vals[6]); |
---|
[79c239e] | 1984 | m_layout->scX = 1; |
---|
| 1985 | m_layout->scY = 1; |
---|
| 1986 | return NULL; |
---|
| 1987 | } |
---|