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