[5809313] | 1 | // |
---|
[156dc16] | 2 | // mainfrm.cc |
---|
[5809313] | 3 | // |
---|
| 4 | // Main frame handling for Aven. |
---|
| 5 | // |
---|
[b72f4b5] | 6 | // Copyright (C) 2000-2002,2005,2006 Mark R. Shinwell |
---|
[8be4d09] | 7 | // Copyright (C) 2001-2003,2004,2005,2006,2010,2011,2012,2013,2014,2015,2016,2018 Olly Betts |
---|
[887c26e] | 8 | // Copyright (C) 2005 Martin Green |
---|
[5809313] | 9 | // |
---|
| 10 | // This program is free software; you can redistribute it and/or modify |
---|
| 11 | // it under the terms of the GNU General Public License as published by |
---|
| 12 | // the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | // (at your option) any later version. |
---|
| 14 | // |
---|
| 15 | // This program is distributed in the hope that it will be useful, |
---|
| 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | // GNU General Public License for more details. |
---|
| 19 | // |
---|
| 20 | // You should have received a copy of the GNU General Public License |
---|
| 21 | // along with this program; if not, write to the Free Software |
---|
[5940815] | 22 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[5809313] | 23 | // |
---|
| 24 | |
---|
[cbfa50d] | 25 | #ifdef HAVE_CONFIG_H |
---|
| 26 | #include <config.h> |
---|
| 27 | #endif |
---|
| 28 | |
---|
[6bec10c] | 29 | #include "cavernlog.h" |
---|
[5809313] | 30 | #include "mainfrm.h" |
---|
| 31 | #include "aven.h" |
---|
[6e65d9e] | 32 | #include "aboutdlg.h" |
---|
[706b033] | 33 | |
---|
[93c3f97] | 34 | #include "message.h" |
---|
[a405bc1] | 35 | #include "img_hosted.h" |
---|
[41adebb] | 36 | #include "namecompare.h" |
---|
[4283d6f] | 37 | #include "printing.h" |
---|
[045e2af] | 38 | #include "filename.h" |
---|
[e577f89] | 39 | #include "useful.h" |
---|
[706b033] | 40 | |
---|
[2d9ed8ad] | 41 | #include <wx/confbase.h> |
---|
[8991d7f] | 42 | //#include <wx/filefn.h> |
---|
[f302cbaa] | 43 | #include <wx/filename.h> |
---|
[ee41e88] | 44 | #include <wx/image.h> |
---|
[0580c6a] | 45 | #include <wx/imaglist.h> |
---|
[b88b171] | 46 | #include <wx/process.h> |
---|
[0580c6a] | 47 | #include <wx/regex.h> |
---|
[562ca6a] | 48 | #ifdef USING_GENERIC_TOOLBAR |
---|
[2737db5] | 49 | # include <wx/sysopt.h> |
---|
| 50 | #endif |
---|
[203d2a7] | 51 | |
---|
[549eb37] | 52 | #include <cerrno> |
---|
[42bd3576] | 53 | #include <cstdlib> |
---|
[5809313] | 54 | #include <float.h> |
---|
[63dc4eb] | 55 | #include <functional> |
---|
[7a2e1ed] | 56 | #include <vector> |
---|
[0c76ad9] | 57 | |
---|
[63c2fe8] | 58 | // XPM files declare the array as static, but we also want it to be const too. |
---|
| 59 | // This avoids a compiler warning, and also means the data can go in a |
---|
| 60 | // read-only page and be shared between processes. |
---|
| 61 | #define static static const |
---|
[63a2dba] | 62 | #ifndef __WXMSW__ |
---|
[ea1ea51] | 63 | #include "../lib/icons/aven.xpm" |
---|
[63a2dba] | 64 | #endif |
---|
[d7b53e3] | 65 | #include "../lib/icons/log.xpm" |
---|
[63c2fe8] | 66 | #include "../lib/icons/open.xpm" |
---|
| 67 | #include "../lib/icons/open_pres.xpm" |
---|
| 68 | #include "../lib/icons/rotation.xpm" |
---|
| 69 | #include "../lib/icons/plan.xpm" |
---|
| 70 | #include "../lib/icons/elevation.xpm" |
---|
| 71 | #include "../lib/icons/defaults.xpm" |
---|
| 72 | #include "../lib/icons/names.xpm" |
---|
| 73 | #include "../lib/icons/crosses.xpm" |
---|
| 74 | #include "../lib/icons/entrances.xpm" |
---|
| 75 | #include "../lib/icons/fixed_pts.xpm" |
---|
| 76 | #include "../lib/icons/exported_pts.xpm" |
---|
| 77 | #include "../lib/icons/ug_legs.xpm" |
---|
| 78 | #include "../lib/icons/surface_legs.xpm" |
---|
| 79 | #include "../lib/icons/tubes.xpm" |
---|
[4938bcd] | 80 | #include "../lib/icons/solid_surface.xpm" |
---|
[63c2fe8] | 81 | #include "../lib/icons/pres_frew.xpm" |
---|
| 82 | #include "../lib/icons/pres_rew.xpm" |
---|
| 83 | #include "../lib/icons/pres_go_back.xpm" |
---|
| 84 | #include "../lib/icons/pres_pause.xpm" |
---|
| 85 | #include "../lib/icons/pres_go.xpm" |
---|
| 86 | #include "../lib/icons/pres_ff.xpm" |
---|
| 87 | #include "../lib/icons/pres_fff.xpm" |
---|
| 88 | #include "../lib/icons/pres_stop.xpm" |
---|
| 89 | #include "../lib/icons/find.xpm" |
---|
| 90 | #include "../lib/icons/hideresults.xpm" |
---|
| 91 | #include "../lib/icons/survey_tree.xpm" |
---|
| 92 | #include "../lib/icons/pres_tree.xpm" |
---|
| 93 | #undef static |
---|
[63a2dba] | 94 | #ifdef __WXMSW__ |
---|
| 95 | # define TOOL(x) wxBitmap(x##_xpm) |
---|
| 96 | #else |
---|
| 97 | # define TOOL(x) wxBITMAP(x) |
---|
[63c2fe8] | 98 | #endif |
---|
| 99 | |
---|
[0580c6a] | 100 | using namespace std; |
---|
[5809313] | 101 | |
---|
[b1de3e0] | 102 | class AvenSplitterWindow : public wxSplitterWindow { |
---|
| 103 | MainFrm *parent; |
---|
| 104 | |
---|
| 105 | public: |
---|
[fd4f6ff] | 106 | explicit AvenSplitterWindow(MainFrm *parent_) |
---|
[b4fe9fb] | 107 | : wxSplitterWindow(parent_, -1, wxDefaultPosition, wxDefaultSize, |
---|
[5ed907b0] | 108 | wxSP_3DSASH), |
---|
[b4fe9fb] | 109 | parent(parent_) |
---|
| 110 | { |
---|
[b1de3e0] | 111 | } |
---|
| 112 | |
---|
[41f7a27] | 113 | void OnSplitterDClick(wxSplitterEvent &) { |
---|
[b1de3e0] | 114 | parent->ToggleSidePanel(); |
---|
| 115 | } |
---|
[f433fda] | 116 | |
---|
[b1de3e0] | 117 | private: |
---|
| 118 | DECLARE_EVENT_TABLE() |
---|
| 119 | }; |
---|
| 120 | |
---|
| 121 | BEGIN_EVENT_TABLE(AvenSplitterWindow, wxSplitterWindow) |
---|
| 122 | EVT_SPLITTER_DCLICK(-1, AvenSplitterWindow::OnSplitterDClick) |
---|
| 123 | END_EVENT_TABLE() |
---|
| 124 | |
---|
[9521a42] | 125 | class EditMarkDlg : public wxDialog { |
---|
| 126 | wxTextCtrl * easting, * northing, * altitude; |
---|
[49ce5b0] | 127 | wxTextCtrl * angle, * tilt_angle, * scale, * time; |
---|
[9521a42] | 128 | public: |
---|
[736f7df] | 129 | // TRANSLATORS: Title of dialog to edit a waypoint in a presentation. |
---|
[9521a42] | 130 | EditMarkDlg(wxWindow* parent, const PresentationMark & p) |
---|
[fbc1d32] | 131 | : wxDialog(parent, 500, wmsg(/*Edit Waypoint*/404)) |
---|
[9521a42] | 132 | { |
---|
[5627cbb] | 133 | easting = new wxTextCtrl(this, 601, wxString::Format(wxT("%.3f"), p.GetX())); |
---|
| 134 | northing = new wxTextCtrl(this, 602, wxString::Format(wxT("%.3f"), p.GetY())); |
---|
| 135 | altitude = new wxTextCtrl(this, 603, wxString::Format(wxT("%.3f"), p.GetZ())); |
---|
| 136 | angle = new wxTextCtrl(this, 604, wxString::Format(wxT("%.3f"), p.angle)); |
---|
| 137 | tilt_angle = new wxTextCtrl(this, 605, wxString::Format(wxT("%.3f"), p.tilt_angle)); |
---|
| 138 | scale = new wxTextCtrl(this, 606, wxString::Format(wxT("%.3f"), p.scale)); |
---|
[49ce5b0] | 139 | if (p.time > 0.0) { |
---|
[5627cbb] | 140 | time = new wxTextCtrl(this, 607, wxString::Format(wxT("%.3f"), p.time)); |
---|
[49ce5b0] | 141 | } else if (p.time < 0.0) { |
---|
[5627cbb] | 142 | time = new wxTextCtrl(this, 607, wxString::Format(wxT("*%.3f"), -p.time)); |
---|
[49ce5b0] | 143 | } else { |
---|
[5627cbb] | 144 | time = new wxTextCtrl(this, 607, wxT("0")); |
---|
[49ce5b0] | 145 | } |
---|
| 146 | |
---|
[9521a42] | 147 | wxBoxSizer * coords = new wxBoxSizer(wxHORIZONTAL); |
---|
[5627cbb] | 148 | coords->Add(new wxStaticText(this, 610, wxT("(")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 149 | coords->Add(easting, 1); |
---|
[5627cbb] | 150 | coords->Add(new wxStaticText(this, 611, wxT(",")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 151 | coords->Add(northing, 1); |
---|
[5627cbb] | 152 | coords->Add(new wxStaticText(this, 612, wxT(",")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 153 | coords->Add(altitude, 1); |
---|
[5627cbb] | 154 | coords->Add(new wxStaticText(this, 613, wxT(")")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 155 | wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL); |
---|
| 156 | vert->Add(coords, 0, wxALL, 8); |
---|
| 157 | wxBoxSizer * r2 = new wxBoxSizer(wxHORIZONTAL); |
---|
[fbc1d32] | 158 | r2->Add(new wxStaticText(this, 614, wmsg(/*Bearing*/259) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 159 | r2->Add(angle); |
---|
| 160 | vert->Add(r2, 0, wxALL, 8); |
---|
| 161 | wxBoxSizer * r3 = new wxBoxSizer(wxHORIZONTAL); |
---|
[fbc1d32] | 162 | r3->Add(new wxStaticText(this, 615, wmsg(/*Elevation*/118) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 163 | r3->Add(tilt_angle); |
---|
| 164 | vert->Add(r3, 0, wxALL, 8); |
---|
| 165 | wxBoxSizer * r4 = new wxBoxSizer(wxHORIZONTAL); |
---|
[fbc1d32] | 166 | r4->Add(new wxStaticText(this, 616, wmsg(/*Scale*/154) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 167 | r4->Add(scale); |
---|
[736f7df] | 168 | /* TRANSLATORS: Note after "Scale" field in dialog to edit a waypoint |
---|
| 169 | * in a presentation. */ |
---|
[857408e] | 170 | r4->Add(new wxStaticText(this, 617, wmsg(/* (unused in perspective view)*/278)), |
---|
[9521a42] | 171 | 0, wxALIGN_CENTRE_VERTICAL); |
---|
| 172 | vert->Add(r4, 0, wxALL, 8); |
---|
| 173 | |
---|
| 174 | wxBoxSizer * r5 = new wxBoxSizer(wxHORIZONTAL); |
---|
[736f7df] | 175 | /* TRANSLATORS: Field label in dialog to edit a waypoint in a |
---|
| 176 | * presentation. */ |
---|
[857408e] | 177 | r5->Add(new wxStaticText(this, 616, wmsg(/*Time: */279)), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[49ce5b0] | 178 | r5->Add(time); |
---|
[736f7df] | 179 | /* TRANSLATORS: units+info after time field in dialog to edit a |
---|
| 180 | * waypoint in a presentation. */ |
---|
[857408e] | 181 | r5->Add(new wxStaticText(this, 617, wmsg(/* secs (0 = auto; *6 = 6 times auto)*/282)), |
---|
[49ce5b0] | 182 | 0, wxALIGN_CENTRE_VERTICAL); |
---|
| 183 | vert->Add(r5, 0, wxALL, 8); |
---|
| 184 | |
---|
| 185 | wxBoxSizer * buttons = new wxBoxSizer(wxHORIZONTAL); |
---|
[73b3388] | 186 | wxButton* cancel = new wxButton(this, wxID_CANCEL); |
---|
[49ce5b0] | 187 | buttons->Add(cancel, 0, wxALL, 8); |
---|
[73b3388] | 188 | wxButton* ok = new wxButton(this, wxID_OK); |
---|
[9521a42] | 189 | ok->SetDefault(); |
---|
[49ce5b0] | 190 | buttons->Add(ok, 0, wxALL, 8); |
---|
| 191 | vert->Add(buttons, 0, wxALL|wxALIGN_RIGHT); |
---|
[9521a42] | 192 | |
---|
| 193 | SetAutoLayout(true); |
---|
| 194 | SetSizer(vert); |
---|
| 195 | |
---|
| 196 | vert->SetSizeHints(this); |
---|
[128fac4] | 197 | } |
---|
[9521a42] | 198 | PresentationMark GetMark() const { |
---|
[d67450e] | 199 | double a, t, s, T; |
---|
[430f5e0] | 200 | Vector3 v(wxAtof(easting->GetValue()), |
---|
| 201 | wxAtof(northing->GetValue()), |
---|
| 202 | wxAtof(altitude->GetValue())); |
---|
| 203 | a = wxAtof(angle->GetValue()); |
---|
| 204 | t = wxAtof(tilt_angle->GetValue()); |
---|
| 205 | s = wxAtof(scale->GetValue()); |
---|
[49ce5b0] | 206 | wxString str = time->GetValue(); |
---|
[e60254e] | 207 | if (!str.empty() && str[0u] == '*') str[0u] = '-'; |
---|
[430f5e0] | 208 | T = wxAtof(str); |
---|
[d67450e] | 209 | return PresentationMark(v, a, t, s, T); |
---|
[9521a42] | 210 | } |
---|
| 211 | |
---|
| 212 | private: |
---|
| 213 | DECLARE_EVENT_TABLE() |
---|
| 214 | }; |
---|
| 215 | |
---|
[3fdeb44d] | 216 | // Write a value without trailing zeros after the decimal point. |
---|
| 217 | static void write_double(double d, FILE * fh) { |
---|
| 218 | char buf[64]; |
---|
| 219 | sprintf(buf, "%.21f", d); |
---|
[c988ae4] | 220 | char * p = strchr(buf, ','); |
---|
| 221 | if (p) *p = '.'; |
---|
[3fdeb44d] | 222 | size_t l = strlen(buf); |
---|
| 223 | while (l > 1 && buf[l - 1] == '0') --l; |
---|
| 224 | if (l > 1 && buf[l - 1] == '.') --l; |
---|
| 225 | fwrite(buf, l, 1, fh); |
---|
| 226 | } |
---|
| 227 | |
---|
[1c6b20d7] | 228 | class AvenPresList : public wxListCtrl { |
---|
| 229 | MainFrm * mainfrm; |
---|
[1690fa9] | 230 | GfxCore * gfx; |
---|
[9521a42] | 231 | vector<PresentationMark> entries; |
---|
[1690fa9] | 232 | long current_item; |
---|
| 233 | bool modified; |
---|
[bd7607c] | 234 | bool force_save_as; |
---|
[1690fa9] | 235 | wxString filename; |
---|
[f433fda] | 236 | |
---|
[1690fa9] | 237 | public: |
---|
[1c6b20d7] | 238 | AvenPresList(MainFrm * mainfrm_, wxWindow * parent, GfxCore * gfx_) |
---|
[1690fa9] | 239 | : wxListCtrl(parent, listctrl_PRES, wxDefaultPosition, wxDefaultSize, |
---|
[9521a42] | 240 | wxLC_REPORT|wxLC_VIRTUAL), |
---|
[bd7607c] | 241 | mainfrm(mainfrm_), gfx(gfx_), current_item(-1), modified(false), |
---|
| 242 | force_save_as(true) |
---|
[1690fa9] | 243 | { |
---|
[5627cbb] | 244 | InsertColumn(0, wmsg(/*Easting*/378)); |
---|
| 245 | InsertColumn(1, wmsg(/*Northing*/379)); |
---|
| 246 | InsertColumn(2, wmsg(/*Altitude*/335)); |
---|
[1690fa9] | 247 | } |
---|
| 248 | |
---|
| 249 | void OnBeginLabelEdit(wxListEvent& event) { |
---|
| 250 | event.Veto(); // No editting allowed |
---|
| 251 | } |
---|
| 252 | void OnDeleteItem(wxListEvent& event) { |
---|
| 253 | long item = event.GetIndex(); |
---|
| 254 | if (current_item == item) { |
---|
| 255 | current_item = -1; |
---|
| 256 | } else if (current_item > item) { |
---|
| 257 | --current_item; |
---|
| 258 | } |
---|
[9521a42] | 259 | entries.erase(entries.begin() + item); |
---|
| 260 | SetItemCount(entries.size()); |
---|
[1690fa9] | 261 | modified = true; |
---|
| 262 | } |
---|
[41f7a27] | 263 | void OnDeleteAllItems(wxListEvent&) { |
---|
[1690fa9] | 264 | entries.clear(); |
---|
[9521a42] | 265 | SetItemCount(entries.size()); |
---|
[5627cbb] | 266 | filename = wxString(); |
---|
[1690fa9] | 267 | modified = false; |
---|
[bd7607c] | 268 | force_save_as = true; |
---|
[1690fa9] | 269 | } |
---|
| 270 | void OnListKeyDown(wxListEvent& event) { |
---|
| 271 | switch (event.GetKeyCode()) { |
---|
| 272 | case WXK_DELETE: { |
---|
| 273 | long item = GetNextItem(-1, wxLIST_NEXT_ALL, |
---|
| 274 | wxLIST_STATE_SELECTED); |
---|
| 275 | while (item != -1) { |
---|
| 276 | DeleteItem(item); |
---|
| 277 | // - 1 because the indices were shifted by DeleteItem() |
---|
| 278 | item = GetNextItem(item - 1, wxLIST_NEXT_ALL, |
---|
| 279 | wxLIST_STATE_SELECTED); |
---|
| 280 | } |
---|
| 281 | break; |
---|
| 282 | } |
---|
| 283 | default: |
---|
[c8f929b] | 284 | //printf("event.GetIndex() = %ld %d\n", event.GetIndex(), event.GetKeyCode()); |
---|
[1690fa9] | 285 | event.Skip(); |
---|
| 286 | } |
---|
| 287 | } |
---|
| 288 | void OnActivated(wxListEvent& event) { |
---|
| 289 | // Jump to this view. |
---|
| 290 | long item = event.GetIndex(); |
---|
[9521a42] | 291 | gfx->SetView(entries[item]); |
---|
[1690fa9] | 292 | } |
---|
| 293 | void OnFocused(wxListEvent& event) { |
---|
| 294 | current_item = event.GetIndex(); |
---|
| 295 | } |
---|
[9521a42] | 296 | void OnRightClick(wxListEvent& event) { |
---|
| 297 | long item = event.GetIndex(); |
---|
[f7d52a1] | 298 | if (item < 0) { |
---|
| 299 | AddMark(item, gfx->GetView()); |
---|
| 300 | item = 0; |
---|
| 301 | } |
---|
[9521a42] | 302 | EditMarkDlg edit(mainfrm, entries[item]); |
---|
| 303 | if (edit.ShowModal() == wxID_OK) { |
---|
| 304 | entries[item] = edit.GetMark(); |
---|
| 305 | } |
---|
| 306 | } |
---|
[1690fa9] | 307 | void OnChar(wxKeyEvent& event) { |
---|
[c8f929b] | 308 | switch (event.GetKeyCode()) { |
---|
| 309 | case WXK_INSERT: |
---|
[a6e8d45] | 310 | if (event.GetModifiers() == wxMOD_CONTROL) { |
---|
[c8f929b] | 311 | if (current_item != -1 && |
---|
| 312 | size_t(current_item) < entries.size()) { |
---|
| 313 | AddMark(current_item, entries[current_item]); |
---|
| 314 | } |
---|
| 315 | } else { |
---|
| 316 | AddMark(current_item); |
---|
| 317 | } |
---|
| 318 | break; |
---|
| 319 | case WXK_DELETE: |
---|
| 320 | // Already handled in OnListKeyDown. |
---|
| 321 | break; |
---|
| 322 | case WXK_UP: case WXK_DOWN: |
---|
| 323 | event.Skip(); |
---|
| 324 | break; |
---|
| 325 | default: |
---|
| 326 | gfx->OnKeyPress(event); |
---|
[5e31bd2] | 327 | } |
---|
[1690fa9] | 328 | } |
---|
| 329 | void AddMark(long item = -1) { |
---|
| 330 | AddMark(item, gfx->GetView()); |
---|
| 331 | } |
---|
| 332 | void AddMark(long item, const PresentationMark & mark) { |
---|
[9521a42] | 333 | if (item == -1) item = entries.size(); |
---|
| 334 | entries.insert(entries.begin() + item, mark); |
---|
| 335 | SetItemCount(entries.size()); |
---|
[1690fa9] | 336 | modified = true; |
---|
| 337 | } |
---|
[9521a42] | 338 | virtual wxString OnGetItemText(long item, long column) const { |
---|
[5627cbb] | 339 | if (item < 0 || item >= (long)entries.size()) return wxString(); |
---|
[9521a42] | 340 | const PresentationMark & p = entries[item]; |
---|
| 341 | double v; |
---|
| 342 | switch (column) { |
---|
[d67450e] | 343 | case 0: v = p.GetX(); break; |
---|
| 344 | case 1: v = p.GetY(); break; |
---|
| 345 | case 2: v = p.GetZ(); break; |
---|
[9521a42] | 346 | #if 0 |
---|
| 347 | case 3: v = p.angle; break; |
---|
| 348 | case 4: v = p.tilt_angle; break; |
---|
| 349 | case 5: v = p.scale; break; |
---|
[49ce5b0] | 350 | case 6: v = p.time; break; |
---|
[9521a42] | 351 | #endif |
---|
[5627cbb] | 352 | default: return wxString(); |
---|
[9521a42] | 353 | } |
---|
[5627cbb] | 354 | return wxString::Format(wxT("%ld"), (long)v); |
---|
[9521a42] | 355 | } |
---|
[1690fa9] | 356 | void Save(bool use_default_name) { |
---|
| 357 | wxString fnm = filename; |
---|
[bd7607c] | 358 | if (!use_default_name || force_save_as) { |
---|
[1690fa9] | 359 | #ifdef __WXMOTIF__ |
---|
[5627cbb] | 360 | wxString ext(wxT("*.fly")); |
---|
[1690fa9] | 361 | #else |
---|
[5627cbb] | 362 | wxString ext = wmsg(/*Aven presentations*/320); |
---|
[52f67931] | 363 | ext += wxT("|*.fly"); |
---|
[1690fa9] | 364 | #endif |
---|
[5627cbb] | 365 | wxFileDialog dlg(this, wmsg(/*Select an output filename*/319), |
---|
| 366 | wxString(), fnm, ext, |
---|
| 367 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
---|
[1690fa9] | 368 | if (dlg.ShowModal() != wxID_OK) return; |
---|
| 369 | fnm = dlg.GetPath(); |
---|
| 370 | } |
---|
| 371 | |
---|
[3206c12] | 372 | FILE * fh_pres = wxFopen(fnm, wxT("w")); |
---|
[1690fa9] | 373 | if (!fh_pres) { |
---|
[0804fbe] | 374 | wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), fnm.c_str())); |
---|
[1690fa9] | 375 | return; |
---|
| 376 | } |
---|
[9521a42] | 377 | vector<PresentationMark>::const_iterator i; |
---|
[1690fa9] | 378 | for (i = entries.begin(); i != entries.end(); ++i) { |
---|
| 379 | const PresentationMark &p = *i; |
---|
[d67450e] | 380 | write_double(p.GetX(), fh_pres); |
---|
[e02a6a6] | 381 | PUTC(' ', fh_pres); |
---|
[d67450e] | 382 | write_double(p.GetY(), fh_pres); |
---|
[e02a6a6] | 383 | PUTC(' ', fh_pres); |
---|
[d67450e] | 384 | write_double(p.GetZ(), fh_pres); |
---|
[e02a6a6] | 385 | PUTC(' ', fh_pres); |
---|
[3fdeb44d] | 386 | write_double(p.angle, fh_pres); |
---|
[e02a6a6] | 387 | PUTC(' ', fh_pres); |
---|
[3fdeb44d] | 388 | write_double(p.tilt_angle, fh_pres); |
---|
[e02a6a6] | 389 | PUTC(' ', fh_pres); |
---|
[3fdeb44d] | 390 | write_double(p.scale, fh_pres); |
---|
[49ce5b0] | 391 | if (p.time != 0.0) { |
---|
[e02a6a6] | 392 | PUTC(' ', fh_pres); |
---|
[49ce5b0] | 393 | write_double(p.time, fh_pres); |
---|
| 394 | } |
---|
[e02a6a6] | 395 | PUTC('\n', fh_pres); |
---|
[1690fa9] | 396 | } |
---|
| 397 | fclose(fh_pres); |
---|
| 398 | filename = fnm; |
---|
| 399 | modified = false; |
---|
[bd7607c] | 400 | force_save_as = false; |
---|
| 401 | } |
---|
| 402 | void New(const wxString &fnm) { |
---|
| 403 | DeleteAllItems(); |
---|
[d3172cc] | 404 | wxFileName::SplitPath(fnm, NULL, NULL, &filename, NULL, wxPATH_NATIVE); |
---|
[5627cbb] | 405 | filename += wxT(".fly"); |
---|
[bd7607c] | 406 | force_save_as = true; |
---|
[1690fa9] | 407 | } |
---|
| 408 | bool Load(const wxString &fnm) { |
---|
[3206c12] | 409 | FILE * fh_pres = wxFopen(fnm, wxT("r")); |
---|
[9b540e6] | 410 | if (!fh_pres) { |
---|
| 411 | wxString m; |
---|
[ffee37e] | 412 | m.Printf(wmsg(/*Couldn’t open file “%s”*/24), fnm.c_str()); |
---|
[9b540e6] | 413 | wxGetApp().ReportError(m); |
---|
| 414 | return false; |
---|
| 415 | } |
---|
[1690fa9] | 416 | DeleteAllItems(); |
---|
| 417 | long item = 0; |
---|
| 418 | while (!feof(fh_pres)) { |
---|
| 419 | char buf[4096]; |
---|
| 420 | size_t i = 0; |
---|
| 421 | while (i < sizeof(buf) - 1) { |
---|
[e02a6a6] | 422 | int ch = GETC(fh_pres); |
---|
[1690fa9] | 423 | if (ch == EOF || ch == '\n' || ch == '\r') break; |
---|
| 424 | buf[i++] = ch; |
---|
| 425 | } |
---|
| 426 | if (i) { |
---|
| 427 | buf[i] = 0; |
---|
[49ce5b0] | 428 | double x, y, z, a, t, s, T; |
---|
| 429 | int c = sscanf(buf, "%lf %lf %lf %lf %lf %lf %lf", &x, &y, &z, &a, &t, &s, &T); |
---|
| 430 | if (c < 6) { |
---|
[c988ae4] | 431 | char *p = buf; |
---|
| 432 | while ((p = strchr(p, '.'))) *p++ = ','; |
---|
| 433 | c = sscanf(buf, "%lf %lf %lf %lf %lf %lf %lf", &x, &y, &z, &a, &t, &s, &T); |
---|
| 434 | if (c < 6) { |
---|
| 435 | DeleteAllItems(); |
---|
[0804fbe] | 436 | wxGetApp().ReportError(wxString::Format(wmsg(/*Error in format of presentation file “%s”*/323), fnm.c_str())); |
---|
[c988ae4] | 437 | return false; |
---|
| 438 | } |
---|
[1690fa9] | 439 | } |
---|
[49ce5b0] | 440 | if (c == 6) T = 0; |
---|
[d67450e] | 441 | AddMark(item, PresentationMark(Vector3(x, y, z), a, t, s, T)); |
---|
[9b540e6] | 442 | ++item; |
---|
[1690fa9] | 443 | } |
---|
| 444 | } |
---|
| 445 | fclose(fh_pres); |
---|
| 446 | filename = fnm; |
---|
| 447 | modified = false; |
---|
[bd7607c] | 448 | force_save_as = false; |
---|
[1690fa9] | 449 | return true; |
---|
| 450 | } |
---|
| 451 | bool Modified() const { return modified; } |
---|
| 452 | bool Empty() const { return entries.empty(); } |
---|
| 453 | PresentationMark GetPresMark(int which) { |
---|
| 454 | long item = current_item; |
---|
| 455 | if (which == MARK_FIRST) { |
---|
| 456 | item = 0; |
---|
| 457 | } else if (which == MARK_NEXT) { |
---|
[9521a42] | 458 | ++item; |
---|
[128fac4] | 459 | } else if (which == MARK_PREV) { |
---|
| 460 | --item; |
---|
[1690fa9] | 461 | } |
---|
[128fac4] | 462 | if (item == -1 || item == (long)entries.size()) |
---|
| 463 | return PresentationMark(); |
---|
[1690fa9] | 464 | if (item != current_item) { |
---|
| 465 | // Move the focus |
---|
| 466 | if (current_item != -1) { |
---|
| 467 | wxListCtrl::SetItemState(current_item, wxLIST_STATE_FOCUSED, |
---|
| 468 | 0); |
---|
| 469 | } |
---|
| 470 | wxListCtrl::SetItemState(item, wxLIST_STATE_FOCUSED, |
---|
| 471 | wxLIST_STATE_FOCUSED); |
---|
| 472 | } |
---|
[9521a42] | 473 | return entries[item]; |
---|
[1690fa9] | 474 | } |
---|
| 475 | |
---|
| 476 | private: |
---|
| 477 | |
---|
[1c6b20d7] | 478 | DECLARE_NO_COPY_CLASS(AvenPresList) |
---|
[1690fa9] | 479 | DECLARE_EVENT_TABLE() |
---|
| 480 | }; |
---|
[f433fda] | 481 | |
---|
[9521a42] | 482 | BEGIN_EVENT_TABLE(EditMarkDlg, wxDialog) |
---|
| 483 | END_EVENT_TABLE() |
---|
| 484 | |
---|
[1c6b20d7] | 485 | BEGIN_EVENT_TABLE(AvenPresList, wxListCtrl) |
---|
| 486 | EVT_LIST_BEGIN_LABEL_EDIT(listctrl_PRES, AvenPresList::OnBeginLabelEdit) |
---|
| 487 | EVT_LIST_DELETE_ITEM(listctrl_PRES, AvenPresList::OnDeleteItem) |
---|
| 488 | EVT_LIST_DELETE_ALL_ITEMS(listctrl_PRES, AvenPresList::OnDeleteAllItems) |
---|
| 489 | EVT_LIST_KEY_DOWN(listctrl_PRES, AvenPresList::OnListKeyDown) |
---|
| 490 | EVT_LIST_ITEM_ACTIVATED(listctrl_PRES, AvenPresList::OnActivated) |
---|
| 491 | EVT_LIST_ITEM_FOCUSED(listctrl_PRES, AvenPresList::OnFocused) |
---|
[9521a42] | 492 | EVT_LIST_ITEM_RIGHT_CLICK(listctrl_PRES, AvenPresList::OnRightClick) |
---|
[1c6b20d7] | 493 | EVT_CHAR(AvenPresList::OnChar) |
---|
[1690fa9] | 494 | END_EVENT_TABLE() |
---|
| 495 | |
---|
[137bf99] | 496 | BEGIN_EVENT_TABLE(MainFrm, wxFrame) |
---|
[d1628e8e] | 497 | EVT_TEXT(textctrl_FIND, MainFrm::OnFind) |
---|
| 498 | EVT_TEXT_ENTER(textctrl_FIND, MainFrm::OnGotoFound) |
---|
[42c7efe] | 499 | EVT_MENU(wxID_FIND, MainFrm::OnGotoFound) |
---|
[8e1a10e] | 500 | EVT_MENU(button_HIDE, MainFrm::OnHide) |
---|
[429465a] | 501 | EVT_UPDATE_UI(button_HIDE, MainFrm::OnHideUpdate) |
---|
[bc60689] | 502 | EVT_IDLE(MainFrm::OnIdle) |
---|
[2a02de2] | 503 | |
---|
[42c7efe] | 504 | EVT_MENU(wxID_OPEN, MainFrm::OnOpen) |
---|
[622460e] | 505 | EVT_MENU(menu_FILE_OPEN_TERRAIN, MainFrm::OnOpenTerrain) |
---|
[d7b53e3] | 506 | EVT_MENU(menu_FILE_LOG, MainFrm::OnShowLog) |
---|
[42c7efe] | 507 | EVT_MENU(wxID_PRINT, MainFrm::OnPrint) |
---|
[ce403f1] | 508 | EVT_MENU(menu_FILE_PAGE_SETUP, MainFrm::OnPageSetup) |
---|
[045e2af] | 509 | EVT_MENU(menu_FILE_SCREENSHOT, MainFrm::OnScreenshot) |
---|
[42c7efe] | 510 | // EVT_MENU(wxID_PREFERENCES, MainFrm::OnFilePreferences) |
---|
[223f1ad] | 511 | EVT_MENU(menu_FILE_EXPORT, MainFrm::OnExport) |
---|
[549eb37] | 512 | EVT_MENU(menu_FILE_EXTEND, MainFrm::OnExtend) |
---|
[42c7efe] | 513 | EVT_MENU(wxID_EXIT, MainFrm::OnQuit) |
---|
[732b9b0] | 514 | EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, MainFrm::OnMRUFile) |
---|
[137bf99] | 515 | |
---|
[1690fa9] | 516 | EVT_MENU(menu_PRES_NEW, MainFrm::OnPresNew) |
---|
| 517 | EVT_MENU(menu_PRES_OPEN, MainFrm::OnPresOpen) |
---|
| 518 | EVT_MENU(menu_PRES_SAVE, MainFrm::OnPresSave) |
---|
| 519 | EVT_MENU(menu_PRES_SAVE_AS, MainFrm::OnPresSaveAs) |
---|
| 520 | EVT_MENU(menu_PRES_MARK, MainFrm::OnPresMark) |
---|
[128fac4] | 521 | EVT_MENU(menu_PRES_FREWIND, MainFrm::OnPresFRewind) |
---|
| 522 | EVT_MENU(menu_PRES_REWIND, MainFrm::OnPresRewind) |
---|
| 523 | EVT_MENU(menu_PRES_REVERSE, MainFrm::OnPresReverse) |
---|
| 524 | EVT_MENU(menu_PRES_PLAY, MainFrm::OnPresPlay) |
---|
| 525 | EVT_MENU(menu_PRES_FF, MainFrm::OnPresFF) |
---|
| 526 | EVT_MENU(menu_PRES_FFF, MainFrm::OnPresFFF) |
---|
| 527 | EVT_MENU(menu_PRES_PAUSE, MainFrm::OnPresPause) |
---|
[42c7efe] | 528 | EVT_MENU(wxID_STOP, MainFrm::OnPresStop) |
---|
[6a4cdcb6] | 529 | EVT_MENU(menu_PRES_EXPORT_MOVIE, MainFrm::OnPresExportMovie) |
---|
[1690fa9] | 530 | |
---|
| 531 | EVT_UPDATE_UI(menu_PRES_NEW, MainFrm::OnPresNewUpdate) |
---|
| 532 | EVT_UPDATE_UI(menu_PRES_OPEN, MainFrm::OnPresOpenUpdate) |
---|
| 533 | EVT_UPDATE_UI(menu_PRES_SAVE, MainFrm::OnPresSaveUpdate) |
---|
| 534 | EVT_UPDATE_UI(menu_PRES_SAVE_AS, MainFrm::OnPresSaveAsUpdate) |
---|
| 535 | EVT_UPDATE_UI(menu_PRES_MARK, MainFrm::OnPresMarkUpdate) |
---|
[128fac4] | 536 | EVT_UPDATE_UI(menu_PRES_FREWIND, MainFrm::OnPresFRewindUpdate) |
---|
| 537 | EVT_UPDATE_UI(menu_PRES_REWIND, MainFrm::OnPresRewindUpdate) |
---|
| 538 | EVT_UPDATE_UI(menu_PRES_REVERSE, MainFrm::OnPresReverseUpdate) |
---|
| 539 | EVT_UPDATE_UI(menu_PRES_PLAY, MainFrm::OnPresPlayUpdate) |
---|
| 540 | EVT_UPDATE_UI(menu_PRES_FF, MainFrm::OnPresFFUpdate) |
---|
| 541 | EVT_UPDATE_UI(menu_PRES_FFF, MainFrm::OnPresFFFUpdate) |
---|
| 542 | EVT_UPDATE_UI(menu_PRES_PAUSE, MainFrm::OnPresPauseUpdate) |
---|
[42c7efe] | 543 | EVT_UPDATE_UI(wxID_STOP, MainFrm::OnPresStopUpdate) |
---|
[6a4cdcb6] | 544 | EVT_UPDATE_UI(menu_PRES_EXPORT_MOVIE, MainFrm::OnPresExportMovieUpdate) |
---|
[5ffa439] | 545 | |
---|
[137bf99] | 546 | EVT_CLOSE(MainFrm::OnClose) |
---|
[4b1fc48] | 547 | EVT_SET_FOCUS(MainFrm::OnSetFocus) |
---|
[137bf99] | 548 | |
---|
[7ebc3d1] | 549 | EVT_MENU(menu_ROTATION_TOGGLE, MainFrm::OnToggleRotation) |
---|
[137bf99] | 550 | EVT_MENU(menu_ROTATION_REVERSE, MainFrm::OnReverseDirectionOfRotation) |
---|
| 551 | EVT_MENU(menu_ORIENT_MOVE_NORTH, MainFrm::OnMoveNorth) |
---|
| 552 | EVT_MENU(menu_ORIENT_MOVE_EAST, MainFrm::OnMoveEast) |
---|
| 553 | EVT_MENU(menu_ORIENT_MOVE_SOUTH, MainFrm::OnMoveSouth) |
---|
| 554 | EVT_MENU(menu_ORIENT_MOVE_WEST, MainFrm::OnMoveWest) |
---|
| 555 | EVT_MENU(menu_ORIENT_PLAN, MainFrm::OnPlan) |
---|
| 556 | EVT_MENU(menu_ORIENT_ELEVATION, MainFrm::OnElevation) |
---|
| 557 | EVT_MENU(menu_ORIENT_DEFAULTS, MainFrm::OnDefaults) |
---|
| 558 | EVT_MENU(menu_VIEW_SHOW_LEGS, MainFrm::OnShowSurveyLegs) |
---|
[8666fc7] | 559 | EVT_MENU(menu_SPLAYS_HIDE, MainFrm::OnHideSplays) |
---|
[b96edeb] | 560 | EVT_MENU(menu_SPLAYS_SHOW_DASHED, MainFrm::OnShowSplaysDashed) |
---|
[8666fc7] | 561 | EVT_MENU(menu_SPLAYS_SHOW_FADED, MainFrm::OnShowSplaysFaded) |
---|
[b96edeb] | 562 | EVT_MENU(menu_SPLAYS_SHOW_NORMAL, MainFrm::OnShowSplaysNormal) |
---|
[e5c5f3c] | 563 | EVT_MENU(menu_DUPES_HIDE, MainFrm::OnHideDupes) |
---|
| 564 | EVT_MENU(menu_DUPES_SHOW_DASHED, MainFrm::OnShowDupesDashed) |
---|
[b96edeb] | 565 | EVT_MENU(menu_DUPES_SHOW_FADED, MainFrm::OnShowDupesFaded) |
---|
| 566 | EVT_MENU(menu_DUPES_SHOW_NORMAL, MainFrm::OnShowDupesNormal) |
---|
[137bf99] | 567 | EVT_MENU(menu_VIEW_SHOW_CROSSES, MainFrm::OnShowCrosses) |
---|
[fe444b8] | 568 | EVT_MENU(menu_VIEW_SHOW_ENTRANCES, MainFrm::OnShowEntrances) |
---|
| 569 | EVT_MENU(menu_VIEW_SHOW_FIXED_PTS, MainFrm::OnShowFixedPts) |
---|
| 570 | EVT_MENU(menu_VIEW_SHOW_EXPORTED_PTS, MainFrm::OnShowExportedPts) |
---|
[137bf99] | 571 | EVT_MENU(menu_VIEW_SHOW_NAMES, MainFrm::OnShowStationNames) |
---|
| 572 | EVT_MENU(menu_VIEW_SHOW_OVERLAPPING_NAMES, MainFrm::OnDisplayOverlappingNames) |
---|
[46beda0] | 573 | EVT_MENU(menu_COLOUR_BY_DEPTH, MainFrm::OnColourByDepth) |
---|
| 574 | EVT_MENU(menu_COLOUR_BY_DATE, MainFrm::OnColourByDate) |
---|
| 575 | EVT_MENU(menu_COLOUR_BY_ERROR, MainFrm::OnColourByError) |
---|
[fc43dda] | 576 | EVT_MENU(menu_COLOUR_BY_H_ERROR, MainFrm::OnColourByHError) |
---|
| 577 | EVT_MENU(menu_COLOUR_BY_V_ERROR, MainFrm::OnColourByVError) |
---|
[46beda0] | 578 | EVT_MENU(menu_COLOUR_BY_GRADIENT, MainFrm::OnColourByGradient) |
---|
| 579 | EVT_MENU(menu_COLOUR_BY_LENGTH, MainFrm::OnColourByLength) |
---|
[68fb07a] | 580 | EVT_MENU(menu_COLOUR_BY_SURVEY, MainFrm::OnColourBySurvey) |
---|
[137bf99] | 581 | EVT_MENU(menu_VIEW_SHOW_SURFACE, MainFrm::OnShowSurface) |
---|
[c1cf79d] | 582 | EVT_MENU(menu_VIEW_GRID, MainFrm::OnViewGrid) |
---|
[f4c5932] | 583 | EVT_MENU(menu_VIEW_BOUNDING_BOX, MainFrm::OnViewBoundingBox) |
---|
[6abab84] | 584 | EVT_MENU(menu_VIEW_PERSPECTIVE, MainFrm::OnViewPerspective) |
---|
[d67450e] | 585 | EVT_MENU(menu_VIEW_SMOOTH_SHADING, MainFrm::OnViewSmoothShading) |
---|
[a517825] | 586 | EVT_MENU(menu_VIEW_TEXTURED, MainFrm::OnViewTextured) |
---|
[c60062d] | 587 | EVT_MENU(menu_VIEW_FOG, MainFrm::OnViewFog) |
---|
[db452ae] | 588 | EVT_MENU(menu_VIEW_SMOOTH_LINES, MainFrm::OnViewSmoothLines) |
---|
[b13aee4] | 589 | EVT_MENU(menu_VIEW_FULLSCREEN, MainFrm::OnViewFullScreen) |
---|
[33b2094] | 590 | EVT_MENU(menu_VIEW_SHOW_TUBES, MainFrm::OnToggleTubes) |
---|
[4938bcd] | 591 | EVT_MENU(menu_VIEW_TERRAIN, MainFrm::OnViewTerrain) |
---|
[7a36b67] | 592 | EVT_MENU(menu_IND_COMPASS, MainFrm::OnViewCompass) |
---|
| 593 | EVT_MENU(menu_IND_CLINO, MainFrm::OnViewClino) |
---|
[97ea48d] | 594 | EVT_MENU(menu_IND_COLOUR_KEY, MainFrm::OnToggleColourKey) |
---|
[7a36b67] | 595 | EVT_MENU(menu_IND_SCALE_BAR, MainFrm::OnToggleScalebar) |
---|
| 596 | EVT_MENU(menu_CTL_SIDE_PANEL, MainFrm::OnViewSidePanel) |
---|
| 597 | EVT_MENU(menu_CTL_METRIC, MainFrm::OnToggleMetric) |
---|
| 598 | EVT_MENU(menu_CTL_DEGREES, MainFrm::OnToggleDegrees) |
---|
[d171c0c] | 599 | EVT_MENU(menu_CTL_PERCENT, MainFrm::OnTogglePercent) |
---|
[137bf99] | 600 | EVT_MENU(menu_CTL_REVERSE, MainFrm::OnReverseControls) |
---|
[1fd2edb] | 601 | EVT_MENU(menu_CTL_CANCEL_DIST_LINE, MainFrm::OnCancelDistLine) |
---|
[42c7efe] | 602 | EVT_MENU(wxID_ABOUT, MainFrm::OnAbout) |
---|
[137bf99] | 603 | |
---|
[622460e] | 604 | EVT_UPDATE_UI(menu_FILE_OPEN_TERRAIN, MainFrm::OnOpenTerrainUpdate) |
---|
[d7b53e3] | 605 | EVT_UPDATE_UI(menu_FILE_LOG, MainFrm::OnShowLogUpdate) |
---|
[42c7efe] | 606 | EVT_UPDATE_UI(wxID_PRINT, MainFrm::OnPrintUpdate) |
---|
[045e2af] | 607 | EVT_UPDATE_UI(menu_FILE_SCREENSHOT, MainFrm::OnScreenshotUpdate) |
---|
[223f1ad] | 608 | EVT_UPDATE_UI(menu_FILE_EXPORT, MainFrm::OnExportUpdate) |
---|
[549eb37] | 609 | EVT_UPDATE_UI(menu_FILE_EXTEND, MainFrm::OnExtendUpdate) |
---|
[546a6f3] | 610 | EVT_UPDATE_UI(menu_ROTATION_TOGGLE, MainFrm::OnToggleRotationUpdate) |
---|
[137bf99] | 611 | EVT_UPDATE_UI(menu_ROTATION_REVERSE, MainFrm::OnReverseDirectionOfRotationUpdate) |
---|
| 612 | EVT_UPDATE_UI(menu_ORIENT_MOVE_NORTH, MainFrm::OnMoveNorthUpdate) |
---|
| 613 | EVT_UPDATE_UI(menu_ORIENT_MOVE_EAST, MainFrm::OnMoveEastUpdate) |
---|
| 614 | EVT_UPDATE_UI(menu_ORIENT_MOVE_SOUTH, MainFrm::OnMoveSouthUpdate) |
---|
| 615 | EVT_UPDATE_UI(menu_ORIENT_MOVE_WEST, MainFrm::OnMoveWestUpdate) |
---|
| 616 | EVT_UPDATE_UI(menu_ORIENT_PLAN, MainFrm::OnPlanUpdate) |
---|
| 617 | EVT_UPDATE_UI(menu_ORIENT_ELEVATION, MainFrm::OnElevationUpdate) |
---|
| 618 | EVT_UPDATE_UI(menu_ORIENT_DEFAULTS, MainFrm::OnDefaultsUpdate) |
---|
| 619 | EVT_UPDATE_UI(menu_VIEW_SHOW_LEGS, MainFrm::OnShowSurveyLegsUpdate) |
---|
[9cb97b7] | 620 | EVT_UPDATE_UI(menu_VIEW_SPLAYS, MainFrm::OnSplaysUpdate) |
---|
[8666fc7] | 621 | EVT_UPDATE_UI(menu_SPLAYS_HIDE, MainFrm::OnHideSplaysUpdate) |
---|
[b96edeb] | 622 | EVT_UPDATE_UI(menu_SPLAYS_SHOW_DASHED, MainFrm::OnShowSplaysDashedUpdate) |
---|
[8666fc7] | 623 | EVT_UPDATE_UI(menu_SPLAYS_SHOW_FADED, MainFrm::OnShowSplaysFadedUpdate) |
---|
[b96edeb] | 624 | EVT_UPDATE_UI(menu_SPLAYS_SHOW_NORMAL, MainFrm::OnShowSplaysNormalUpdate) |
---|
[e5c5f3c] | 625 | EVT_UPDATE_UI(menu_VIEW_DUPES, MainFrm::OnDupesUpdate) |
---|
| 626 | EVT_UPDATE_UI(menu_DUPES_HIDE, MainFrm::OnHideDupesUpdate) |
---|
| 627 | EVT_UPDATE_UI(menu_DUPES_SHOW_DASHED, MainFrm::OnShowDupesDashedUpdate) |
---|
[b96edeb] | 628 | EVT_UPDATE_UI(menu_DUPES_SHOW_FADED, MainFrm::OnShowDupesFadedUpdate) |
---|
| 629 | EVT_UPDATE_UI(menu_DUPES_SHOW_NORMAL, MainFrm::OnShowDupesNormalUpdate) |
---|
[137bf99] | 630 | EVT_UPDATE_UI(menu_VIEW_SHOW_CROSSES, MainFrm::OnShowCrossesUpdate) |
---|
[fe444b8] | 631 | EVT_UPDATE_UI(menu_VIEW_SHOW_ENTRANCES, MainFrm::OnShowEntrancesUpdate) |
---|
| 632 | EVT_UPDATE_UI(menu_VIEW_SHOW_FIXED_PTS, MainFrm::OnShowFixedPtsUpdate) |
---|
| 633 | EVT_UPDATE_UI(menu_VIEW_SHOW_EXPORTED_PTS, MainFrm::OnShowExportedPtsUpdate) |
---|
[137bf99] | 634 | EVT_UPDATE_UI(menu_VIEW_SHOW_NAMES, MainFrm::OnShowStationNamesUpdate) |
---|
| 635 | EVT_UPDATE_UI(menu_VIEW_SHOW_SURFACE, MainFrm::OnShowSurfaceUpdate) |
---|
| 636 | EVT_UPDATE_UI(menu_VIEW_SHOW_OVERLAPPING_NAMES, MainFrm::OnDisplayOverlappingNamesUpdate) |
---|
[46beda0] | 637 | EVT_UPDATE_UI(menu_VIEW_COLOUR_BY, MainFrm::OnColourByUpdate) |
---|
| 638 | EVT_UPDATE_UI(menu_COLOUR_BY_DEPTH, MainFrm::OnColourByDepthUpdate) |
---|
| 639 | EVT_UPDATE_UI(menu_COLOUR_BY_DATE, MainFrm::OnColourByDateUpdate) |
---|
| 640 | EVT_UPDATE_UI(menu_COLOUR_BY_ERROR, MainFrm::OnColourByErrorUpdate) |
---|
[fc43dda] | 641 | EVT_UPDATE_UI(menu_COLOUR_BY_H_ERROR, MainFrm::OnColourByHErrorUpdate) |
---|
| 642 | EVT_UPDATE_UI(menu_COLOUR_BY_V_ERROR, MainFrm::OnColourByVErrorUpdate) |
---|
[46beda0] | 643 | EVT_UPDATE_UI(menu_COLOUR_BY_GRADIENT, MainFrm::OnColourByGradientUpdate) |
---|
| 644 | EVT_UPDATE_UI(menu_COLOUR_BY_LENGTH, MainFrm::OnColourByLengthUpdate) |
---|
[68fb07a] | 645 | EVT_UPDATE_UI(menu_COLOUR_BY_SURVEY, MainFrm::OnColourBySurveyUpdate) |
---|
[c1cf79d] | 646 | EVT_UPDATE_UI(menu_VIEW_GRID, MainFrm::OnViewGridUpdate) |
---|
[f4c5932] | 647 | EVT_UPDATE_UI(menu_VIEW_BOUNDING_BOX, MainFrm::OnViewBoundingBoxUpdate) |
---|
[6abab84] | 648 | EVT_UPDATE_UI(menu_VIEW_PERSPECTIVE, MainFrm::OnViewPerspectiveUpdate) |
---|
[d67450e] | 649 | EVT_UPDATE_UI(menu_VIEW_SMOOTH_SHADING, MainFrm::OnViewSmoothShadingUpdate) |
---|
[a517825] | 650 | EVT_UPDATE_UI(menu_VIEW_TEXTURED, MainFrm::OnViewTexturedUpdate) |
---|
[c60062d] | 651 | EVT_UPDATE_UI(menu_VIEW_FOG, MainFrm::OnViewFogUpdate) |
---|
[db452ae] | 652 | EVT_UPDATE_UI(menu_VIEW_SMOOTH_LINES, MainFrm::OnViewSmoothLinesUpdate) |
---|
[b13aee4] | 653 | EVT_UPDATE_UI(menu_VIEW_FULLSCREEN, MainFrm::OnViewFullScreenUpdate) |
---|
[33b2094] | 654 | EVT_UPDATE_UI(menu_VIEW_SHOW_TUBES, MainFrm::OnToggleTubesUpdate) |
---|
[4938bcd] | 655 | EVT_UPDATE_UI(menu_VIEW_TERRAIN, MainFrm::OnViewTerrainUpdate) |
---|
[7a36b67] | 656 | EVT_UPDATE_UI(menu_IND_COMPASS, MainFrm::OnViewCompassUpdate) |
---|
| 657 | EVT_UPDATE_UI(menu_IND_CLINO, MainFrm::OnViewClinoUpdate) |
---|
[97ea48d] | 658 | EVT_UPDATE_UI(menu_IND_COLOUR_KEY, MainFrm::OnToggleColourKeyUpdate) |
---|
[7a36b67] | 659 | EVT_UPDATE_UI(menu_IND_SCALE_BAR, MainFrm::OnToggleScalebarUpdate) |
---|
| 660 | EVT_UPDATE_UI(menu_CTL_INDICATORS, MainFrm::OnIndicatorsUpdate) |
---|
| 661 | EVT_UPDATE_UI(menu_CTL_SIDE_PANEL, MainFrm::OnViewSidePanelUpdate) |
---|
| 662 | EVT_UPDATE_UI(menu_CTL_REVERSE, MainFrm::OnReverseControlsUpdate) |
---|
| 663 | EVT_UPDATE_UI(menu_CTL_CANCEL_DIST_LINE, MainFrm::OnCancelDistLineUpdate) |
---|
| 664 | EVT_UPDATE_UI(menu_CTL_METRIC, MainFrm::OnToggleMetricUpdate) |
---|
| 665 | EVT_UPDATE_UI(menu_CTL_DEGREES, MainFrm::OnToggleDegreesUpdate) |
---|
[d171c0c] | 666 | EVT_UPDATE_UI(menu_CTL_PERCENT, MainFrm::OnTogglePercentUpdate) |
---|
[5809313] | 667 | END_EVENT_TABLE() |
---|
| 668 | |
---|
[63dc4eb] | 669 | class LabelCmp : public greater<const LabelInfo*> { |
---|
[ff9f695] | 670 | wxChar separator; |
---|
[156dc16] | 671 | public: |
---|
[fd4f6ff] | 672 | explicit LabelCmp(wxChar separator_) : separator(separator_) {} |
---|
[156dc16] | 673 | bool operator()(const LabelInfo* pt1, const LabelInfo* pt2) { |
---|
[2f36993] | 674 | return name_cmp(pt1->GetText(), pt2->GetText(), separator) < 0; |
---|
[156dc16] | 675 | } |
---|
| 676 | }; |
---|
| 677 | |
---|
[63dc4eb] | 678 | class LabelPlotCmp : public greater<const LabelInfo*> { |
---|
[ff9f695] | 679 | wxChar separator; |
---|
[291ca5d] | 680 | public: |
---|
[fd4f6ff] | 681 | explicit LabelPlotCmp(wxChar separator_) : separator(separator_) {} |
---|
[291ca5d] | 682 | bool operator()(const LabelInfo* pt1, const LabelInfo* pt2) { |
---|
[5a24583] | 683 | int n = pt1->get_flags() - pt2->get_flags(); |
---|
[291ca5d] | 684 | if (n) return n > 0; |
---|
[5a24583] | 685 | wxString l1 = pt1->GetText().AfterLast(separator); |
---|
| 686 | wxString l2 = pt2->GetText().AfterLast(separator); |
---|
[f11f2af] | 687 | n = name_cmp(l1, l2, separator); |
---|
| 688 | if (n) return n < 0; |
---|
[2a94924] | 689 | // Prefer non-2-nodes... |
---|
| 690 | // FIXME; implement |
---|
[f11f2af] | 691 | // if leaf names are the same, prefer shorter labels as we can |
---|
| 692 | // display more of them |
---|
[5a24583] | 693 | n = pt1->GetText().length() - pt2->GetText().length(); |
---|
[f11f2af] | 694 | if (n) return n < 0; |
---|
[2a94924] | 695 | // make sure that we don't ever compare different labels as equal |
---|
[5a24583] | 696 | return name_cmp(pt1->GetText(), pt2->GetText(), separator) < 0; |
---|
[291ca5d] | 697 | } |
---|
| 698 | }; |
---|
| 699 | |
---|
[f6fe808] | 700 | #if wxUSE_DRAG_AND_DROP |
---|
[5901b62] | 701 | class DnDFile : public wxFileDropTarget { |
---|
| 702 | public: |
---|
[fd4f6ff] | 703 | explicit DnDFile(MainFrm *parent) : m_Parent(parent) { } |
---|
[5901b62] | 704 | virtual bool OnDropFiles(wxCoord, wxCoord, |
---|
| 705 | const wxArrayString &filenames); |
---|
| 706 | |
---|
| 707 | private: |
---|
| 708 | MainFrm * m_Parent; |
---|
| 709 | }; |
---|
| 710 | |
---|
| 711 | bool |
---|
| 712 | DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString &filenames) |
---|
| 713 | { |
---|
| 714 | // Load a survey file by drag-and-drop. |
---|
| 715 | assert(filenames.GetCount() > 0); |
---|
| 716 | |
---|
| 717 | if (filenames.GetCount() != 1) { |
---|
[736f7df] | 718 | /* TRANSLATORS: error if you try to drag multiple files to the aven |
---|
| 719 | * window */ |
---|
[5627cbb] | 720 | wxGetApp().ReportError(wmsg(/*You may only view one 3d file at a time.*/336)); |
---|
[6d1bc83] | 721 | return false; |
---|
[5901b62] | 722 | } |
---|
[421b7d2] | 723 | |
---|
[5901b62] | 724 | m_Parent->OpenFile(filenames[0]); |
---|
[6d1bc83] | 725 | return true; |
---|
[5901b62] | 726 | } |
---|
[f6fe808] | 727 | #endif |
---|
[5901b62] | 728 | |
---|
[137bf99] | 729 | MainFrm::MainFrm(const wxString& title, const wxPoint& pos, const wxSize& size) : |
---|
[ad3d0a2] | 730 | wxFrame(NULL, 101, title, pos, size, wxDEFAULT_FRAME_STYLE), |
---|
[486c619] | 731 | m_SashPosition(-1), |
---|
[d7b53e3] | 732 | m_Gfx(NULL), m_Log(NULL), |
---|
[b75a37d] | 733 | pending_find(false), fullscreen_showing_menus(false) |
---|
[9c3d91e] | 734 | #ifdef PREFDLG |
---|
| 735 | , m_PrefsDlg(NULL) |
---|
| 736 | #endif |
---|
[5809313] | 737 | { |
---|
[cfd6c44] | 738 | #ifdef _WIN32 |
---|
[003d953] | 739 | // The peculiar name is so that the icon is the first in the file |
---|
[b1de3e0] | 740 | // (required by Microsoft Windows for this type of icon) |
---|
[ea1ea51] | 741 | SetIcon(wxICON(AAA_aven)); |
---|
[95fa391] | 742 | #else |
---|
[ea1ea51] | 743 | SetIcon(wxICON(aven)); |
---|
[cfd6c44] | 744 | #endif |
---|
| 745 | |
---|
[83478f5] | 746 | #if wxCHECK_VERSION(3,1,0) |
---|
| 747 | // Add a full screen button to the right upper corner of title bar under OS |
---|
| 748 | // X 10.7 and later. |
---|
| 749 | EnableFullScreenView(); |
---|
| 750 | #endif |
---|
[9d3d8cc] | 751 | CreateMenuBar(); |
---|
[242cb07] | 752 | MakeToolBar(); |
---|
[7c29c976] | 753 | CreateStatusBar(2, wxST_SIZEGRIP); |
---|
[9d3d8cc] | 754 | CreateSidePanel(); |
---|
[f433fda] | 755 | |
---|
[7c29c976] | 756 | int widths[2] = { -1 /* variable width */, -1 }; |
---|
| 757 | GetStatusBar()->SetStatusWidths(2, widths); |
---|
[9d3d8cc] | 758 | |
---|
[0580c6a] | 759 | #ifdef __X__ // wxMotif or wxX11 |
---|
[9d3d8cc] | 760 | int x; |
---|
| 761 | int y; |
---|
| 762 | GetSize(&x, &y); |
---|
| 763 | // X seems to require a forced resize. |
---|
| 764 | SetSize(-1, -1, x, y); |
---|
| 765 | #endif |
---|
| 766 | |
---|
[0edb0d0] | 767 | #if wxUSE_DRAG_AND_DROP |
---|
[5901b62] | 768 | SetDropTarget(new DnDFile(this)); |
---|
[f6fe808] | 769 | #endif |
---|
[9d3d8cc] | 770 | } |
---|
| 771 | |
---|
| 772 | void MainFrm::CreateMenuBar() |
---|
| 773 | { |
---|
| 774 | // Create the menus and the menu bar. |
---|
[137bf99] | 775 | |
---|
| 776 | wxMenu* filemenu = new wxMenu; |
---|
[42c7efe] | 777 | // wxID_OPEN stock label lacks the ellipses |
---|
[736f7df] | 778 | /* TRANSLATORS: Aven menu items. An “&” goes before the letter of any |
---|
| 779 | * accelerator key. |
---|
| 780 | * |
---|
| 781 | * The string "\t" separates the menu text and any accelerator key. |
---|
| 782 | * |
---|
| 783 | * "File" menu. The accelerators must be different within this group. |
---|
| 784 | * c.f. 201, 380, 381. */ |
---|
[7f928d3] | 785 | filemenu->Append(wxID_OPEN, wmsg(/*&Open...\tCtrl+O*/220)); |
---|
[51755e1] | 786 | /* TRANSLATORS: Open a "Terrain file" - i.e. a digital model of the |
---|
| 787 | * terrain. */ |
---|
[7f928d3] | 788 | filemenu->Append(menu_FILE_OPEN_TERRAIN, wmsg(/*Open &Terrain...*/453)); |
---|
[4b2d207] | 789 | filemenu->AppendCheckItem(menu_FILE_LOG, wmsg(/*Show &Log*/144)); |
---|
[137bf99] | 790 | filemenu->AppendSeparator(); |
---|
[42c7efe] | 791 | // wxID_PRINT stock label lacks the ellipses |
---|
[7f928d3] | 792 | filemenu->Append(wxID_PRINT, wmsg(/*&Print...\tCtrl+P*/380)); |
---|
| 793 | filemenu->Append(menu_FILE_PAGE_SETUP, wmsg(/*P&age Setup...*/381)); |
---|
[ce403f1] | 794 | filemenu->AppendSeparator(); |
---|
[736f7df] | 795 | /* TRANSLATORS: In the "File" menu */ |
---|
[7f928d3] | 796 | filemenu->Append(menu_FILE_SCREENSHOT, wmsg(/*&Screenshot...*/201)); |
---|
| 797 | filemenu->Append(menu_FILE_EXPORT, wmsg(/*&Export as...*/382)); |
---|
[549eb37] | 798 | /* TRANSLATORS: In the "File" menu - c.f. n:191 */ |
---|
| 799 | filemenu->Append(menu_FILE_EXTEND, wmsg(/*E&xtended Elevation...*/247)); |
---|
[b72f4b5] | 800 | #ifndef __WXMAC__ |
---|
| 801 | // On wxMac the "Quit" menu item will be moved elsewhere, so we suppress |
---|
| 802 | // this separator. |
---|
[223f1ad] | 803 | filemenu->AppendSeparator(); |
---|
[f930738] | 804 | #else |
---|
[559cd60] | 805 | // We suppress the "Help" menu under macOS as it would otherwise end up as |
---|
[f930738] | 806 | // an empty menu, but we need to add the "About" menu item somewhere. It |
---|
| 807 | // really doesn't matter where as wxWidgets will move it to the "Apple" |
---|
| 808 | // menu. |
---|
| 809 | filemenu->Append(wxID_ABOUT); |
---|
[b72f4b5] | 810 | #endif |
---|
[42c7efe] | 811 | filemenu->Append(wxID_EXIT); |
---|
[137bf99] | 812 | |
---|
[cf8c84b] | 813 | m_history.UseMenu(filemenu); |
---|
| 814 | m_history.Load(*wxConfigBase::Get()); |
---|
| 815 | |
---|
[137bf99] | 816 | wxMenu* rotmenu = new wxMenu; |
---|
[736f7df] | 817 | /* TRANSLATORS: "Rotation" menu. The accelerators must be different within |
---|
[de6d5e3] | 818 | * this group. Tickable menu item which toggles auto rotation. |
---|
| 819 | * Please don't translate "Space" - that's the shortcut key to use which |
---|
| 820 | * wxWidgets needs to parse and it should then handle translating. |
---|
| 821 | */ |
---|
[ee7511a] | 822 | rotmenu->AppendCheckItem(menu_ROTATION_TOGGLE, wmsg(/*Au&to-Rotate\tSpace*/231)); |
---|
[137bf99] | 823 | rotmenu->AppendSeparator(); |
---|
[d86459c] | 824 | rotmenu->Append(menu_ROTATION_REVERSE, wmsg(/*&Reverse Direction*/234)); |
---|
[137bf99] | 825 | |
---|
| 826 | wxMenu* orientmenu = new wxMenu; |
---|
[d86459c] | 827 | orientmenu->Append(menu_ORIENT_MOVE_NORTH, wmsg(/*View &North*/240)); |
---|
| 828 | orientmenu->Append(menu_ORIENT_MOVE_EAST, wmsg(/*View &East*/241)); |
---|
| 829 | orientmenu->Append(menu_ORIENT_MOVE_SOUTH, wmsg(/*View &South*/242)); |
---|
| 830 | orientmenu->Append(menu_ORIENT_MOVE_WEST, wmsg(/*View &West*/243)); |
---|
[137bf99] | 831 | orientmenu->AppendSeparator(); |
---|
[d86459c] | 832 | orientmenu->Append(menu_ORIENT_PLAN, wmsg(/*&Plan View*/248)); |
---|
| 833 | orientmenu->Append(menu_ORIENT_ELEVATION, wmsg(/*Ele&vation*/249)); |
---|
[137bf99] | 834 | orientmenu->AppendSeparator(); |
---|
[d86459c] | 835 | orientmenu->Append(menu_ORIENT_DEFAULTS, wmsg(/*Restore De&fault View*/254)); |
---|
[1690fa9] | 836 | |
---|
[203d2a7] | 837 | wxMenu* presmenu = new wxMenu; |
---|
[d86459c] | 838 | presmenu->Append(menu_PRES_NEW, wmsg(/*&New Presentation*/311)); |
---|
[7f928d3] | 839 | presmenu->Append(menu_PRES_OPEN, wmsg(/*&Open Presentation...*/312)); |
---|
[d86459c] | 840 | presmenu->Append(menu_PRES_SAVE, wmsg(/*&Save Presentation*/313)); |
---|
[7f928d3] | 841 | presmenu->Append(menu_PRES_SAVE_AS, wmsg(/*Sa&ve Presentation As...*/314)); |
---|
[203d2a7] | 842 | presmenu->AppendSeparator(); |
---|
[736f7df] | 843 | /* TRANSLATORS: "Mark" as in "Mark this position" */ |
---|
[d86459c] | 844 | presmenu->Append(menu_PRES_MARK, wmsg(/*&Mark*/315)); |
---|
[736f7df] | 845 | /* TRANSLATORS: "Play" as in "Play back a recording" */ |
---|
[a2a8d23] | 846 | presmenu->AppendCheckItem(menu_PRES_PLAY, wmsg(/*Pla&y*/316)); |
---|
[7f928d3] | 847 | presmenu->Append(menu_PRES_EXPORT_MOVIE, wmsg(/*&Export as Movie...*/317)); |
---|
[1690fa9] | 848 | |
---|
[203d2a7] | 849 | wxMenu* viewmenu = new wxMenu; |
---|
[edb6576] | 850 | #ifndef PREFDLG |
---|
[736f7df] | 851 | /* TRANSLATORS: Items in the "View" menu: */ |
---|
[d86459c] | 852 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_NAMES, wmsg(/*Station &Names\tCtrl+N*/270)); |
---|
[736f7df] | 853 | /* TRANSLATORS: Toggles drawing of 3D passages */ |
---|
[ee7511a] | 854 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_TUBES, wmsg(/*Passage &Tubes\tCtrl+T*/346)); |
---|
[4938bcd] | 855 | /* TRANSLATORS: Toggles drawing the surface of the Earth */ |
---|
[90c628d] | 856 | viewmenu->AppendCheckItem(menu_VIEW_TERRAIN, wmsg(/*Terr&ain*/449)); |
---|
[d86459c] | 857 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_CROSSES, wmsg(/*&Crosses\tCtrl+X*/271)); |
---|
| 858 | viewmenu->AppendCheckItem(menu_VIEW_GRID, wmsg(/*&Grid\tCtrl+G*/297)); |
---|
| 859 | viewmenu->AppendCheckItem(menu_VIEW_BOUNDING_BOX, wmsg(/*&Bounding Box\tCtrl+B*/318)); |
---|
[edb6576] | 860 | viewmenu->AppendSeparator(); |
---|
[736f7df] | 861 | /* TRANSLATORS: Here a "survey leg" is a set of measurements between two |
---|
| 862 | * "survey stations". */ |
---|
[d86459c] | 863 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_LEGS, wmsg(/*&Underground Survey Legs\tCtrl+L*/272)); |
---|
[736f7df] | 864 | /* TRANSLATORS: Here a "survey leg" is a set of measurements between two |
---|
| 865 | * "survey stations". */ |
---|
[d86459c] | 866 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_SURFACE, wmsg(/*&Surface Survey Legs\tCtrl+F*/291)); |
---|
[8666fc7] | 867 | |
---|
| 868 | wxMenu* splaymenu = new wxMenu; |
---|
[b96edeb] | 869 | /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if |
---|
| 870 | * this is selected, such legs are not shown. */ |
---|
[82ae44a] | 871 | splaymenu->AppendCheckItem(menu_SPLAYS_HIDE, wmsg(/*&Hide*/407)); |
---|
[b96edeb] | 872 | /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if |
---|
| 873 | * this is selected, aven will show such legs with dashed lines. */ |
---|
| 874 | splaymenu->AppendCheckItem(menu_SPLAYS_SHOW_DASHED, wmsg(/*&Dashed*/250)); |
---|
| 875 | /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if |
---|
| 876 | * this is selected, aven will show such legs with less bright colours. */ |
---|
[82ae44a] | 877 | splaymenu->AppendCheckItem(menu_SPLAYS_SHOW_FADED, wmsg(/*&Fade*/408)); |
---|
[b96edeb] | 878 | /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if |
---|
| 879 | * this is selected, such legs are shown the same as other legs. */ |
---|
[82ae44a] | 880 | splaymenu->AppendCheckItem(menu_SPLAYS_SHOW_NORMAL, wmsg(/*&Show*/409)); |
---|
[9cb97b7] | 881 | viewmenu->Append(menu_VIEW_SPLAYS, wmsg(/*Spla&y Legs*/406), splaymenu); |
---|
[8666fc7] | 882 | |
---|
[e5c5f3c] | 883 | wxMenu* dupemenu = new wxMenu; |
---|
[2299161] | 884 | dupemenu->AppendCheckItem(menu_DUPES_HIDE, wmsg(/*&Hide*/407)); |
---|
| 885 | dupemenu->AppendCheckItem(menu_DUPES_SHOW_DASHED, wmsg(/*&Dashed*/250)); |
---|
[b96edeb] | 886 | dupemenu->AppendCheckItem(menu_DUPES_SHOW_FADED, wmsg(/*&Fade*/408)); |
---|
[2299161] | 887 | dupemenu->AppendCheckItem(menu_DUPES_SHOW_NORMAL, wmsg(/*&Show*/409)); |
---|
| 888 | viewmenu->Append(menu_VIEW_DUPES, wmsg(/*&Duplicate Legs*/251), dupemenu); |
---|
[e5c5f3c] | 889 | |
---|
[edb6576] | 890 | viewmenu->AppendSeparator(); |
---|
[d86459c] | 891 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_OVERLAPPING_NAMES, wmsg(/*&Overlapping Names*/273)); |
---|
[46beda0] | 892 | |
---|
| 893 | wxMenu* colourbymenu = new wxMenu; |
---|
| 894 | colourbymenu->AppendCheckItem(menu_COLOUR_BY_DEPTH, wmsg(/*Colour by &Depth*/292)); |
---|
| 895 | colourbymenu->AppendCheckItem(menu_COLOUR_BY_DATE, wmsg(/*Colour by D&ate*/293)); |
---|
| 896 | colourbymenu->AppendCheckItem(menu_COLOUR_BY_ERROR, wmsg(/*Colour by &Error*/289)); |
---|
[fc43dda] | 897 | colourbymenu->AppendCheckItem(menu_COLOUR_BY_H_ERROR, wmsg(/*Colour by &Horizontal Error*/480)); |
---|
| 898 | colourbymenu->AppendCheckItem(menu_COLOUR_BY_V_ERROR, wmsg(/*Colour by &Vertical Error*/481)); |
---|
[46beda0] | 899 | colourbymenu->AppendCheckItem(menu_COLOUR_BY_GRADIENT, wmsg(/*Colour by &Gradient*/85)); |
---|
| 900 | colourbymenu->AppendCheckItem(menu_COLOUR_BY_LENGTH, wmsg(/*Colour by &Length*/82)); |
---|
[68fb07a] | 901 | colourbymenu->AppendCheckItem(menu_COLOUR_BY_SURVEY, wmsg(/*Colour by &Survey*/448)); |
---|
[46beda0] | 902 | |
---|
[90c628d] | 903 | viewmenu->Append(menu_VIEW_COLOUR_BY, wmsg(/*Co&lour by*/450), colourbymenu); |
---|
[46beda0] | 904 | |
---|
[edb6576] | 905 | viewmenu->AppendSeparator(); |
---|
[d86459c] | 906 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_ENTRANCES, wmsg(/*Highlight &Entrances*/294)); |
---|
| 907 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_FIXED_PTS, wmsg(/*Highlight &Fixed Points*/295)); |
---|
| 908 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_EXPORTED_PTS, wmsg(/*Highlight E&xported Points*/296)); |
---|
[edb6576] | 909 | viewmenu->AppendSeparator(); |
---|
| 910 | #else |
---|
[de6d5e3] | 911 | /* TRANSLATORS: Please don't translate "Escape" - that's the shortcut key |
---|
| 912 | * to use which wxWidgets needs to parse and it should then handle |
---|
| 913 | * translating. |
---|
| 914 | */ |
---|
[d86459c] | 915 | viewmenu-> Append(menu_VIEW_CANCEL_DIST_LINE, wmsg(/*&Cancel Measuring Line\tEscape*/281)); |
---|
[edb6576] | 916 | #endif |
---|
[d86459c] | 917 | viewmenu->AppendCheckItem(menu_VIEW_PERSPECTIVE, wmsg(/*&Perspective*/237)); |
---|
| 918 | // FIXME: enable this viewmenu->AppendCheckItem(menu_VIEW_SMOOTH_SHADING, wmsg(/*&Smooth Shading*/?!?); |
---|
| 919 | viewmenu->AppendCheckItem(menu_VIEW_TEXTURED, wmsg(/*Textured &Walls*/238)); |
---|
[736f7df] | 920 | /* TRANSLATORS: Toggles OpenGL "Depth Fogging" - feel free to translate |
---|
| 921 | * using that term instead if it gives a better translation which most |
---|
| 922 | * users will understand. */ |
---|
[ee7511a] | 923 | viewmenu->AppendCheckItem(menu_VIEW_FOG, wmsg(/*Fade Distant Ob&jects*/239)); |
---|
[736f7df] | 924 | /* TRANSLATORS: Here a "survey leg" is a set of measurements between two |
---|
| 925 | * "survey stations". */ |
---|
[5c2bff7] | 926 | viewmenu->AppendCheckItem(menu_VIEW_SMOOTH_LINES, wmsg(/*Smoot&hed Survey Legs*/298)); |
---|
[6abab84] | 927 | viewmenu->AppendSeparator(); |
---|
[85c83ac5] | 928 | #ifdef __WXMAC__ |
---|
[559cd60] | 929 | // F11 on macOS is used by the desktop (for speaker volume and/or window |
---|
| 930 | // navigation). The standard macOS shortcut for full screen mode is |
---|
[8962fc9] | 931 | // Ctrl-Command-F which in wxWidgets terms is RawCtrl+Ctrl+F. |
---|
[85c83ac5] | 932 | wxString wxmac_fullscreen = wmsg(/*Full Screen &Mode\tF11*/356); |
---|
[8962fc9] | 933 | wxmac_fullscreen.Replace(wxT("\tF11"), wxT("\tRawCtrl+Ctrl+F"), false); |
---|
[85c83ac5] | 934 | viewmenu->AppendCheckItem(menu_VIEW_FULLSCREEN, wxmac_fullscreen); |
---|
[559cd60] | 935 | // FIXME: On macOS, the standard wording here is "Enter Full Screen" and |
---|
[98bd0a0] | 936 | // "Exit Full Screen", depending whether we are in full screen mode or not, |
---|
| 937 | // and this isn't a checked menu item. |
---|
[85c83ac5] | 938 | #else |
---|
[ee7511a] | 939 | viewmenu->AppendCheckItem(menu_VIEW_FULLSCREEN, wmsg(/*Full Screen &Mode\tF11*/356)); |
---|
[85c83ac5] | 940 | #endif |
---|
[edb6576] | 941 | #ifdef PREFDLG |
---|
[203d2a7] | 942 | viewmenu->AppendSeparator(); |
---|
[7f928d3] | 943 | viewmenu-> Append(wxID_PREFERENCES, wmsg(/*&Preferences...*/347)); |
---|
[edb6576] | 944 | #endif |
---|
| 945 | |
---|
| 946 | #ifndef PREFDLG |
---|
| 947 | wxMenu* ctlmenu = new wxMenu; |
---|
[d86459c] | 948 | ctlmenu->AppendCheckItem(menu_CTL_REVERSE, wmsg(/*&Reverse Sense\tCtrl+R*/280)); |
---|
[edb6576] | 949 | ctlmenu->AppendSeparator(); |
---|
[bf2d0ba] | 950 | #ifdef __WXGTK__ |
---|
| 951 | // wxGTK (at least with GTK+ v2.24), if we specify a short-cut here then |
---|
| 952 | // the key handler isn't called, so we can't exit full screen mode on |
---|
| 953 | // Escape. wxGTK doesn't actually show the "Escape" shortcut text in the |
---|
| 954 | // menu item, so removing it doesn't make any visual difference, and doing |
---|
| 955 | // so allows Escape to still cancel the measuring line, but also serve to |
---|
| 956 | // exit full screen mode if no measuring line is shown. |
---|
| 957 | wxString wxgtk_cancelline = wmsg(/*&Cancel Measuring Line\tEscape*/281); |
---|
| 958 | wxgtk_cancelline.Replace(wxT("\tEscape"), wxT(""), false); |
---|
| 959 | ctlmenu->Append(menu_CTL_CANCEL_DIST_LINE, wxgtk_cancelline); |
---|
| 960 | #else |
---|
| 961 | // With wxMac and wxMSW, we can have the short-cut on the menu and still |
---|
| 962 | // have Escape handled by the key handler to exit full screen mode. |
---|
[d86459c] | 963 | ctlmenu->Append(menu_CTL_CANCEL_DIST_LINE, wmsg(/*&Cancel Measuring Line\tEscape*/281)); |
---|
[bf2d0ba] | 964 | #endif |
---|
[edb6576] | 965 | ctlmenu->AppendSeparator(); |
---|
| 966 | wxMenu* indmenu = new wxMenu; |
---|
[d86459c] | 967 | indmenu->AppendCheckItem(menu_IND_COMPASS, wmsg(/*&Compass*/274)); |
---|
| 968 | indmenu->AppendCheckItem(menu_IND_CLINO, wmsg(/*C&linometer*/275)); |
---|
[736f7df] | 969 | /* TRANSLATORS: The "Colour Key" is the thing in aven showing which colour |
---|
| 970 | * corresponds to which depth, date, survey closure error, etc. */ |
---|
[97ea48d] | 971 | indmenu->AppendCheckItem(menu_IND_COLOUR_KEY, wmsg(/*Colour &Key*/276)); |
---|
[d86459c] | 972 | indmenu->AppendCheckItem(menu_IND_SCALE_BAR, wmsg(/*&Scale Bar*/277)); |
---|
| 973 | ctlmenu->Append(menu_CTL_INDICATORS, wmsg(/*&Indicators*/299), indmenu); |
---|
| 974 | ctlmenu->AppendCheckItem(menu_CTL_SIDE_PANEL, wmsg(/*&Side Panel*/337)); |
---|
[edb6576] | 975 | ctlmenu->AppendSeparator(); |
---|
[d86459c] | 976 | ctlmenu->AppendCheckItem(menu_CTL_METRIC, wmsg(/*&Metric*/342)); |
---|
| 977 | ctlmenu->AppendCheckItem(menu_CTL_DEGREES, wmsg(/*&Degrees*/343)); |
---|
[d171c0c] | 978 | ctlmenu->AppendCheckItem(menu_CTL_PERCENT, wmsg(/*&Percent*/430)); |
---|
[edb6576] | 979 | #endif |
---|
[137bf99] | 980 | |
---|
[c988ae4] | 981 | wxMenuBar* menubar = new wxMenuBar(); |
---|
[736f7df] | 982 | /* TRANSLATORS: Aven menu titles. An “&” goes before the letter of any |
---|
| 983 | * accelerator key. The accelerators must be different within this group |
---|
| 984 | */ |
---|
[d86459c] | 985 | menubar->Append(filemenu, wmsg(/*&File*/210)); |
---|
| 986 | menubar->Append(rotmenu, wmsg(/*&Rotation*/211)); |
---|
| 987 | menubar->Append(orientmenu, wmsg(/*&Orientation*/212)); |
---|
| 988 | menubar->Append(viewmenu, wmsg(/*&View*/213)); |
---|
[5de0cac] | 989 | #ifndef PREFDLG |
---|
[d86459c] | 990 | menubar->Append(ctlmenu, wmsg(/*&Controls*/214)); |
---|
[5de0cac] | 991 | #endif |
---|
[adc7f92] | 992 | // TRANSLATORS: "Presentation" in the sense of a talk with a slideshow - |
---|
| 993 | // the items in this menu allow the user to animate between preset |
---|
| 994 | // views. |
---|
[d86459c] | 995 | menubar->Append(presmenu, wmsg(/*&Presentation*/216)); |
---|
[b72f4b5] | 996 | #ifndef __WXMAC__ |
---|
| 997 | // On wxMac the "About" menu item will be moved elsewhere, so we suppress |
---|
| 998 | // this menu since it will then be empty. |
---|
[c5dd692] | 999 | wxMenu* helpmenu = new wxMenu; |
---|
| 1000 | helpmenu->Append(wxID_ABOUT); |
---|
| 1001 | |
---|
[d86459c] | 1002 | menubar->Append(helpmenu, wmsg(/*&Help*/215)); |
---|
[b72f4b5] | 1003 | #endif |
---|
[137bf99] | 1004 | SetMenuBar(menubar); |
---|
[9d3d8cc] | 1005 | } |
---|
[137bf99] | 1006 | |
---|
[242cb07] | 1007 | void MainFrm::MakeToolBar() |
---|
[9d3d8cc] | 1008 | { |
---|
[242cb07] | 1009 | // Make the toolbar. |
---|
[137bf99] | 1010 | |
---|
[562ca6a] | 1011 | #ifdef USING_GENERIC_TOOLBAR |
---|
[2737db5] | 1012 | // This OS-X-specific code is only needed to stop the toolbar icons getting |
---|
| 1013 | // scaled up, which just makes them look nasty and fuzzy. Once we have |
---|
| 1014 | // larger versions of the icons, we can drop this code. |
---|
| 1015 | wxSystemOptions::SetOption(wxT("mac.toolbar.no-native"), 1); |
---|
| 1016 | wxToolBar* toolbar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, |
---|
| 1017 | wxDefaultSize, wxNO_BORDER|wxTB_FLAT|wxTB_NODIVIDER|wxTB_NOALIGN); |
---|
[562ca6a] | 1018 | wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL); |
---|
[2737db5] | 1019 | sizer->Add(toolbar, 0, wxEXPAND); |
---|
[562ca6a] | 1020 | SetSizer(sizer); |
---|
[2737db5] | 1021 | #else |
---|
[9d3d8cc] | 1022 | wxToolBar* toolbar = wxFrame::CreateToolBar(); |
---|
[2737db5] | 1023 | #endif |
---|
[137bf99] | 1024 | |
---|
[b65c13f] | 1025 | #ifndef __WXGTK20__ |
---|
[d94f5db] | 1026 | toolbar->SetMargins(5, 5); |
---|
| 1027 | #endif |
---|
| 1028 | |
---|
[9b540e6] | 1029 | // FIXME: TRANSLATE tooltips |
---|
[b4f28e0] | 1030 | toolbar->AddTool(wxID_OPEN, wxT("Open"), TOOL(open), wxT("Open a survey file for viewing")); |
---|
| 1031 | toolbar->AddTool(menu_PRES_OPEN, wxT("Open presentation"), TOOL(open_pres), wxT("Open a presentation")); |
---|
[4b2d207] | 1032 | toolbar->AddCheckTool(menu_FILE_LOG, wxT("View log"), TOOL(log), wxNullBitmap, wxT("View log from processing survey data")); |
---|
[2d9ed8ad] | 1033 | toolbar->AddSeparator(); |
---|
[b4f28e0] | 1034 | toolbar->AddCheckTool(menu_ROTATION_TOGGLE, wxT("Toggle rotation"), TOOL(rotation), wxNullBitmap, wxT("Toggle rotation")); |
---|
| 1035 | toolbar->AddTool(menu_ORIENT_PLAN, wxT("Plan"), TOOL(plan), wxT("Switch to plan view")); |
---|
| 1036 | toolbar->AddTool(menu_ORIENT_ELEVATION, wxT("Elevation"), TOOL(elevation), wxT("Switch to elevation view")); |
---|
| 1037 | toolbar->AddTool(menu_ORIENT_DEFAULTS, wxT("Default view"), TOOL(defaults), wxT("Restore default view")); |
---|
[2d9ed8ad] | 1038 | toolbar->AddSeparator(); |
---|
[b4f28e0] | 1039 | toolbar->AddCheckTool(menu_VIEW_SHOW_NAMES, wxT("Names"), TOOL(names), wxNullBitmap, wxT("Show station names")); |
---|
| 1040 | toolbar->AddCheckTool(menu_VIEW_SHOW_CROSSES, wxT("Crosses"), TOOL(crosses), wxNullBitmap, wxT("Show crosses on stations")); |
---|
| 1041 | toolbar->AddCheckTool(menu_VIEW_SHOW_ENTRANCES, wxT("Entrances"), TOOL(entrances), wxNullBitmap, wxT("Highlight entrances")); |
---|
| 1042 | toolbar->AddCheckTool(menu_VIEW_SHOW_FIXED_PTS, wxT("Fixed points"), TOOL(fixed_pts), wxNullBitmap, wxT("Highlight fixed points")); |
---|
| 1043 | toolbar->AddCheckTool(menu_VIEW_SHOW_EXPORTED_PTS, wxT("Exported points"), TOOL(exported_pts), wxNullBitmap, wxT("Highlight exported stations")); |
---|
[2d9ed8ad] | 1044 | toolbar->AddSeparator(); |
---|
[b4f28e0] | 1045 | toolbar->AddCheckTool(menu_VIEW_SHOW_LEGS, wxT("Underground legs"), TOOL(ug_legs), wxNullBitmap, wxT("Show underground surveys")); |
---|
| 1046 | toolbar->AddCheckTool(menu_VIEW_SHOW_SURFACE, wxT("Surface legs"), TOOL(surface_legs), wxNullBitmap, wxT("Show surface surveys")); |
---|
| 1047 | toolbar->AddCheckTool(menu_VIEW_SHOW_TUBES, wxT("Tubes"), TOOL(tubes), wxNullBitmap, wxT("Show passage tubes")); |
---|
[4938bcd] | 1048 | toolbar->AddCheckTool(menu_VIEW_TERRAIN, wxT("Terrain"), TOOL(solid_surface), wxNullBitmap, wxT("Show terrain")); |
---|
[128fac4] | 1049 | toolbar->AddSeparator(); |
---|
[b4f28e0] | 1050 | toolbar->AddCheckTool(menu_PRES_FREWIND, wxT("Fast Rewind"), TOOL(pres_frew), wxNullBitmap, wxT("Very Fast Rewind")); |
---|
| 1051 | toolbar->AddCheckTool(menu_PRES_REWIND, wxT("Rewind"), TOOL(pres_rew), wxNullBitmap, wxT("Fast Rewind")); |
---|
| 1052 | toolbar->AddCheckTool(menu_PRES_REVERSE, wxT("Backwards"), TOOL(pres_go_back), wxNullBitmap, wxT("Play Backwards")); |
---|
| 1053 | toolbar->AddCheckTool(menu_PRES_PAUSE, wxT("Pause"), TOOL(pres_pause), wxNullBitmap, wxT("Pause")); |
---|
| 1054 | toolbar->AddCheckTool(menu_PRES_PLAY, wxT("Go"), TOOL(pres_go), wxNullBitmap, wxT("Play")); |
---|
| 1055 | toolbar->AddCheckTool(menu_PRES_FF, wxT("FF"), TOOL(pres_ff), wxNullBitmap, wxT("Fast Forward")); |
---|
| 1056 | toolbar->AddCheckTool(menu_PRES_FFF, wxT("Very FF"), TOOL(pres_fff), wxNullBitmap, wxT("Very Fast Forward")); |
---|
| 1057 | toolbar->AddTool(wxID_STOP, wxT("Stop"), TOOL(pres_stop), wxT("Stop")); |
---|
[fd6e0d5] | 1058 | |
---|
[203d2a7] | 1059 | toolbar->AddSeparator(); |
---|
[5627cbb] | 1060 | m_FindBox = new wxTextCtrl(toolbar, textctrl_FIND, wxString(), wxDefaultPosition, |
---|
[429465a] | 1061 | wxDefaultSize, wxTE_PROCESS_ENTER); |
---|
[fd6e0d5] | 1062 | toolbar->AddControl(m_FindBox); |
---|
[736f7df] | 1063 | /* TRANSLATORS: "Find stations" button tooltip */ |
---|
[b4f28e0] | 1064 | toolbar->AddTool(wxID_FIND, wmsg(/*Find*/332), TOOL(find)/*, "Search for station name"*/); |
---|
[736f7df] | 1065 | /* TRANSLATORS: "Hide stations" button default tooltip */ |
---|
[b4f28e0] | 1066 | toolbar->AddTool(button_HIDE, wmsg(/*Hide*/333), TOOL(hideresults)/*, "Hide search results"*/); |
---|
[fd6e0d5] | 1067 | |
---|
[2d9ed8ad] | 1068 | toolbar->Realize(); |
---|
[9d3d8cc] | 1069 | } |
---|
[2d9ed8ad] | 1070 | |
---|
[9d3d8cc] | 1071 | void MainFrm::CreateSidePanel() |
---|
| 1072 | { |
---|
[b1de3e0] | 1073 | m_Splitter = new AvenSplitterWindow(this); |
---|
[562ca6a] | 1074 | #ifdef USING_GENERIC_TOOLBAR |
---|
[2737db5] | 1075 | // This OS-X-specific code is only needed to stop the toolbar icons getting |
---|
| 1076 | // scaled up, which just makes them look nasty and fuzzy. Once we have |
---|
| 1077 | // larger versions of the icons, we can drop this code. |
---|
| 1078 | GetSizer()->Add(m_Splitter, 1, wxEXPAND); |
---|
| 1079 | Layout(); |
---|
| 1080 | #endif |
---|
[421b7d2] | 1081 | |
---|
[203d2a7] | 1082 | m_Notebook = new wxNotebook(m_Splitter, 400, wxDefaultPosition, |
---|
[b63cf6cc] | 1083 | wxDefaultSize, |
---|
[e83fa9fc] | 1084 | wxBK_BOTTOM); |
---|
[203d2a7] | 1085 | m_Notebook->Show(false); |
---|
[f433fda] | 1086 | |
---|
[1be3a88] | 1087 | wxPanel * panel = new wxPanel(m_Notebook); |
---|
| 1088 | m_Tree = new AvenTreeCtrl(this, panel); |
---|
[156dc16] | 1089 | |
---|
[429465a] | 1090 | // m_RegexpCheckBox = new wxCheckBox(find_panel, -1, |
---|
[ee7511a] | 1091 | // msg(/*Regular expression*/)); |
---|
[2c30188] | 1092 | |
---|
| 1093 | wxBoxSizer *panel_sizer = new wxBoxSizer(wxVERTICAL); |
---|
| 1094 | panel_sizer->Add(m_Tree, 1, wxALL | wxEXPAND, 2); |
---|
[1be3a88] | 1095 | panel->SetAutoLayout(true); |
---|
| 1096 | panel->SetSizer(panel_sizer); |
---|
| 1097 | // panel_sizer->SetSizeHints(panel); |
---|
[156dc16] | 1098 | |
---|
[5876fcb] | 1099 | m_Control = new GUIControl(); |
---|
| 1100 | m_Gfx = new GfxCore(this, m_Splitter, m_Control); |
---|
| 1101 | m_Control->SetView(m_Gfx); |
---|
[156dc16] | 1102 | |
---|
[203d2a7] | 1103 | // Presentation panel: |
---|
[1be3a88] | 1104 | wxPanel * prespanel = new wxPanel(m_Notebook); |
---|
[203d2a7] | 1105 | |
---|
[1be3a88] | 1106 | m_PresList = new AvenPresList(this, prespanel, m_Gfx); |
---|
[f433fda] | 1107 | |
---|
[203d2a7] | 1108 | wxBoxSizer *pres_panel_sizer = new wxBoxSizer(wxVERTICAL); |
---|
| 1109 | pres_panel_sizer->Add(m_PresList, 1, wxALL | wxEXPAND, 2); |
---|
[1be3a88] | 1110 | prespanel->SetAutoLayout(true); |
---|
| 1111 | prespanel->SetSizer(pres_panel_sizer); |
---|
[1690fa9] | 1112 | |
---|
[203d2a7] | 1113 | // Overall tabbed structure: |
---|
[c5032bb0] | 1114 | // FIXME: this assumes images are 15x15 |
---|
| 1115 | wxImageList* image_list = new wxImageList(15, 15); |
---|
[b4f28e0] | 1116 | image_list->Add(TOOL(survey_tree)); |
---|
| 1117 | image_list->Add(TOOL(pres_tree)); |
---|
[203d2a7] | 1118 | m_Notebook->SetImageList(image_list); |
---|
[736f7df] | 1119 | /* TRANSLATORS: labels for tabbed side panel this is for the tab with the |
---|
| 1120 | * tree hierarchy of survey station names */ |
---|
[5627cbb] | 1121 | m_Notebook->AddPage(panel, wmsg(/*Surveys*/376), true, 0); |
---|
| 1122 | m_Notebook->AddPage(prespanel, wmsg(/*Presentation*/377), false, 1); |
---|
[203d2a7] | 1123 | |
---|
[e9b97eb] | 1124 | m_Splitter->Initialize(m_Gfx); |
---|
[068b4f2] | 1125 | } |
---|
[137bf99] | 1126 | |
---|
[373b738] | 1127 | bool MainFrm::LoadData(const wxString& file, const wxString& prefix) |
---|
[b88b171] | 1128 | { |
---|
[137bf99] | 1129 | // Load survey data from file, centre the dataset around the origin, |
---|
[f4fae12] | 1130 | // and prepare the data for drawing. |
---|
[137bf99] | 1131 | |
---|
[c9427d2] | 1132 | #if 0 |
---|
| 1133 | wxStopWatch timer; |
---|
| 1134 | timer.Start(); |
---|
| 1135 | #endif |
---|
[b88b171] | 1136 | |
---|
[373b738] | 1137 | int err_msg_code = Model::Load(file, prefix); |
---|
| 1138 | if (err_msg_code) { |
---|
| 1139 | wxString m = wxString::Format(wmsg(err_msg_code), file.c_str()); |
---|
| 1140 | wxGetApp().ReportError(m); |
---|
| 1141 | return false; |
---|
| 1142 | } |
---|
| 1143 | |
---|
| 1144 | // Update window title. |
---|
| 1145 | SetTitle(GetSurveyTitle() + " - " APP_NAME); |
---|
| 1146 | |
---|
| 1147 | // Sort the labels ready for filling the tree. |
---|
| 1148 | m_Labels.sort(LabelCmp(GetSeparator())); |
---|
| 1149 | |
---|
| 1150 | // Fill the tree of stations and prefixes. |
---|
| 1151 | wxString root_name = wxFileNameFromPath(file); |
---|
| 1152 | if (!prefix.empty()) { |
---|
| 1153 | root_name += " ("; |
---|
| 1154 | root_name += prefix; |
---|
| 1155 | root_name += ")"; |
---|
| 1156 | } |
---|
[17a38ded] | 1157 | m_Tree->FillTree(root_name); |
---|
[373b738] | 1158 | |
---|
| 1159 | // Sort labels so that entrances are displayed in preference, |
---|
| 1160 | // then fixed points, then exported points, then other points. |
---|
| 1161 | // |
---|
| 1162 | // Also sort by leaf name so that we'll tend to choose labels |
---|
| 1163 | // from different surveys, rather than labels from surveys which |
---|
| 1164 | // are earlier in the list. |
---|
| 1165 | m_Labels.sort(LabelPlotCmp(GetSeparator())); |
---|
| 1166 | |
---|
| 1167 | if (!m_FindBox->GetValue().empty()) { |
---|
| 1168 | // Highlight any stations matching the current search. |
---|
| 1169 | DoFind(); |
---|
| 1170 | } |
---|
| 1171 | |
---|
| 1172 | m_FileProcessed = file; |
---|
| 1173 | |
---|
| 1174 | return true; |
---|
| 1175 | } |
---|
| 1176 | |
---|
[d4650b3] | 1177 | #if 0 |
---|
[57a3cd4] | 1178 | // Run along a newly read in traverse and make up plausible LRUD where |
---|
| 1179 | // it is missing. |
---|
| 1180 | void |
---|
[c61aa79] | 1181 | MainFrm::FixLRUD(traverse & centreline) |
---|
[57a3cd4] | 1182 | { |
---|
| 1183 | assert(centreline.size() > 1); |
---|
| 1184 | |
---|
| 1185 | Double last_size = 0; |
---|
[d4650b3] | 1186 | vector<PointInfo>::iterator i = centreline.begin(); |
---|
[57a3cd4] | 1187 | while (i != centreline.end()) { |
---|
[4c9e87b] | 1188 | // Get the coordinates of this vertex. |
---|
[db36155] | 1189 | Point & pt_v = *i++; |
---|
[57a3cd4] | 1190 | Double size; |
---|
| 1191 | |
---|
| 1192 | if (i != centreline.end()) { |
---|
| 1193 | Double h = sqrd(i->GetX() - pt_v.GetX()) + |
---|
| 1194 | sqrd(i->GetY() - pt_v.GetY()); |
---|
| 1195 | Double v = sqrd(i->GetZ() - pt_v.GetZ()); |
---|
| 1196 | if (h + v > 30.0 * 30.0) { |
---|
| 1197 | Double scale = 30.0 / sqrt(h + v); |
---|
| 1198 | h *= scale; |
---|
| 1199 | v *= scale; |
---|
| 1200 | } |
---|
| 1201 | size = sqrt(h + v / 9); |
---|
| 1202 | size /= 4; |
---|
| 1203 | if (i == centreline.begin() + 1) { |
---|
| 1204 | // First segment. |
---|
| 1205 | last_size = size; |
---|
| 1206 | } else { |
---|
| 1207 | // Intermediate segment. |
---|
| 1208 | swap(size, last_size); |
---|
| 1209 | size += last_size; |
---|
| 1210 | size /= 2; |
---|
| 1211 | } |
---|
| 1212 | } else { |
---|
| 1213 | // Last segment. |
---|
| 1214 | size = last_size; |
---|
| 1215 | } |
---|
| 1216 | |
---|
| 1217 | Double & l = pt_v.l; |
---|
| 1218 | Double & r = pt_v.r; |
---|
| 1219 | Double & u = pt_v.u; |
---|
| 1220 | Double & d = pt_v.d; |
---|
| 1221 | |
---|
| 1222 | if (l == 0 && r == 0 && u == 0 && d == 0) { |
---|
| 1223 | l = r = u = d = -size; |
---|
| 1224 | } else { |
---|
| 1225 | if (l < 0 && r < 0) { |
---|
| 1226 | l = r = -size; |
---|
| 1227 | } else if (l < 0) { |
---|
| 1228 | l = -(2 * size - r); |
---|
| 1229 | if (l >= 0) l = -0.01; |
---|
| 1230 | } else if (r < 0) { |
---|
| 1231 | r = -(2 * size - l); |
---|
| 1232 | if (r >= 0) r = -0.01; |
---|
| 1233 | } |
---|
| 1234 | if (u < 0 && d < 0) { |
---|
| 1235 | u = d = -size; |
---|
| 1236 | } else if (u < 0) { |
---|
| 1237 | u = -(2 * size - d); |
---|
| 1238 | if (u >= 0) u = -0.01; |
---|
| 1239 | } else if (d < 0) { |
---|
| 1240 | d = -(2 * size - u); |
---|
| 1241 | if (d >= 0) d = -0.01; |
---|
| 1242 | } |
---|
| 1243 | } |
---|
| 1244 | } |
---|
| 1245 | } |
---|
[d4650b3] | 1246 | #endif |
---|
[57a3cd4] | 1247 | |
---|
[732b9b0] | 1248 | void MainFrm::OnMRUFile(wxCommandEvent& event) |
---|
| 1249 | { |
---|
| 1250 | wxString f(m_history.GetHistoryFile(event.GetId() - wxID_FILE1)); |
---|
| 1251 | if (!f.empty()) OpenFile(f); |
---|
| 1252 | } |
---|
| 1253 | |
---|
[bc73093] | 1254 | void MainFrm::AddToFileHistory(const wxString & file) |
---|
| 1255 | { |
---|
| 1256 | if (wxIsAbsolutePath(file)) { |
---|
| 1257 | m_history.AddFileToHistory(file); |
---|
| 1258 | } else { |
---|
| 1259 | wxString abs = wxGetCwd(); |
---|
| 1260 | abs += wxCONFIG_PATH_SEPARATOR; |
---|
| 1261 | abs += file; |
---|
| 1262 | m_history.AddFileToHistory(abs); |
---|
| 1263 | } |
---|
| 1264 | wxConfigBase *b = wxConfigBase::Get(); |
---|
| 1265 | m_history.Save(*b); |
---|
| 1266 | b->Flush(); |
---|
| 1267 | } |
---|
| 1268 | |
---|
[5f06d2c] | 1269 | void MainFrm::OpenFile(const wxString& file, const wxString& survey) |
---|
[137bf99] | 1270 | { |
---|
[4b1fc48] | 1271 | wxBusyCursor hourglass; |
---|
[bc73093] | 1272 | |
---|
| 1273 | // Check if this is an unprocessed survey data file. |
---|
| 1274 | if (file.length() > 4 && file[file.length() - 4] == '.') { |
---|
| 1275 | wxString ext(file, file.length() - 3, 3); |
---|
| 1276 | ext.MakeLower(); |
---|
| 1277 | if (ext == wxT("svx") || ext == wxT("dat") || ext == wxT("mak")) { |
---|
[d7b53e3] | 1278 | CavernLogWindow * log = new CavernLogWindow(this, survey, m_Splitter); |
---|
[fb5887c] | 1279 | wxWindow * win = m_Splitter->GetWindow1(); |
---|
| 1280 | m_Splitter->ReplaceWindow(win, log); |
---|
[fd96020] | 1281 | win->Show(false); |
---|
[fb5887c] | 1282 | if (m_Splitter->GetWindow2() == NULL) { |
---|
| 1283 | if (win != m_Gfx) win->Destroy(); |
---|
| 1284 | } else { |
---|
| 1285 | if (m_Splitter->IsSplit()) m_Splitter->Unsplit(); |
---|
| 1286 | } |
---|
| 1287 | |
---|
[8991d7f] | 1288 | if (wxFileExists(file)) AddToFileHistory(file); |
---|
| 1289 | log->process(file); |
---|
| 1290 | // Log window will tell us to load file if it successfully completes. |
---|
[bc73093] | 1291 | return; |
---|
[eb5b48df] | 1292 | } |
---|
[137bf99] | 1293 | } |
---|
[bc73093] | 1294 | |
---|
| 1295 | if (!LoadData(file, survey)) |
---|
| 1296 | return; |
---|
| 1297 | AddToFileHistory(file); |
---|
[5e0b9f9d] | 1298 | InitialiseAfterLoad(file, survey); |
---|
[d7b53e3] | 1299 | |
---|
| 1300 | // If aven is showing the log for a .svx file and you load a .3d file, then |
---|
| 1301 | // at this point m_Log will be the log window for the .svx file, so destroy |
---|
| 1302 | // it - it should never legitimately be set if we get here. |
---|
| 1303 | if (m_Log) { |
---|
| 1304 | m_Log->Destroy(); |
---|
| 1305 | m_Log = NULL; |
---|
| 1306 | } |
---|
[bc73093] | 1307 | } |
---|
| 1308 | |
---|
[5e0b9f9d] | 1309 | void MainFrm::InitialiseAfterLoad(const wxString & file, const wxString & prefix) |
---|
[bc73093] | 1310 | { |
---|
[486c619] | 1311 | if (m_SashPosition < 0) { |
---|
| 1312 | // Calculate sane default width for side panel. |
---|
| 1313 | int x; |
---|
| 1314 | int y; |
---|
| 1315 | GetClientSize(&x, &y); |
---|
| 1316 | if (x < 600) |
---|
| 1317 | x /= 3; |
---|
| 1318 | else if (x < 1000) |
---|
| 1319 | x = 200; |
---|
| 1320 | else |
---|
| 1321 | x /= 5; |
---|
| 1322 | m_SashPosition = x; |
---|
| 1323 | } |
---|
[bc73093] | 1324 | |
---|
[fb5887c] | 1325 | // Do this before we potentially delete the log window which may own the |
---|
| 1326 | // wxString which parameter file refers to! |
---|
[bc73093] | 1327 | bool same_file = (file == m_File); |
---|
| 1328 | if (!same_file) |
---|
| 1329 | m_File = file; |
---|
[5e0b9f9d] | 1330 | m_Survey = prefix; |
---|
[bc73093] | 1331 | |
---|
[fb5887c] | 1332 | wxWindow * win = NULL; |
---|
| 1333 | if (m_Splitter->GetWindow2() == NULL) { |
---|
| 1334 | win = m_Splitter->GetWindow1(); |
---|
| 1335 | if (win == m_Gfx) win = NULL; |
---|
| 1336 | } |
---|
| 1337 | |
---|
[486c619] | 1338 | if (!IsFullScreen()) { |
---|
| 1339 | m_Splitter->SplitVertically(m_Notebook, m_Gfx, m_SashPosition); |
---|
| 1340 | } else { |
---|
| 1341 | was_showing_sidepanel_before_fullscreen = true; |
---|
| 1342 | } |
---|
[fb5887c] | 1343 | |
---|
[bc73093] | 1344 | m_Gfx->Initialise(same_file); |
---|
[d7b53e3] | 1345 | |
---|
| 1346 | if (win) { |
---|
| 1347 | // FIXME: check it actually is the log window! |
---|
| 1348 | if (m_Log && m_Log != win) |
---|
| 1349 | m_Log->Destroy(); |
---|
| 1350 | m_Log = win; |
---|
| 1351 | m_Log->Show(false); |
---|
| 1352 | } |
---|
| 1353 | |
---|
[486c619] | 1354 | if (!IsFullScreen()) { |
---|
| 1355 | m_Notebook->Show(true); |
---|
| 1356 | } |
---|
[bc73093] | 1357 | |
---|
| 1358 | m_Gfx->Show(true); |
---|
| 1359 | m_Gfx->SetFocus(); |
---|
[d7b53e3] | 1360 | } |
---|
[fb5887c] | 1361 | |
---|
[d7b53e3] | 1362 | void MainFrm::HideLog(wxWindow * log_window) |
---|
| 1363 | { |
---|
| 1364 | if (!IsFullScreen()) { |
---|
| 1365 | m_Splitter->SplitVertically(m_Notebook, m_Gfx, m_SashPosition); |
---|
| 1366 | } |
---|
| 1367 | |
---|
| 1368 | m_Log = log_window; |
---|
| 1369 | m_Log->Show(false); |
---|
| 1370 | |
---|
| 1371 | if (!IsFullScreen()) { |
---|
| 1372 | m_Notebook->Show(true); |
---|
| 1373 | } |
---|
| 1374 | |
---|
| 1375 | m_Gfx->Show(true); |
---|
| 1376 | m_Gfx->SetFocus(); |
---|
[137bf99] | 1377 | } |
---|
| 1378 | |
---|
| 1379 | // |
---|
| 1380 | // UI event handlers |
---|
| 1381 | // |
---|
| 1382 | |
---|
[c988ae4] | 1383 | // For Unix we want "*.svx;*.SVX" while for Windows we only want "*.svx". |
---|
| 1384 | #ifdef _WIN32 |
---|
| 1385 | # define CASE(X) |
---|
| 1386 | #else |
---|
[1c55fb5] | 1387 | # define CASE(X) ";" X |
---|
[496a208] | 1388 | #endif |
---|
| 1389 | |
---|
[137bf99] | 1390 | void MainFrm::OnOpen(wxCommandEvent&) |
---|
| 1391 | { |
---|
| 1392 | #ifdef __WXMOTIF__ |
---|
[5627cbb] | 1393 | wxString filetypes = wxT("*.3d"); |
---|
[137bf99] | 1394 | #else |
---|
[c988ae4] | 1395 | wxString filetypes; |
---|
[d9cd8ae] | 1396 | filetypes.Printf(wxT("%s|*.3d;*.svx;*.plt;*.plf;*.dat;*.mak;*.adj;*.sht;*.una;*.xyz" |
---|
| 1397 | CASE("*.3D;*.SVX;*.PLT;*.PLF;*.DAT;*.MAK;*.ADJ;*.SHT;*.UNA;*.XYZ") |
---|
[1c55fb5] | 1398 | "|%s|*.3d" CASE("*.3D") |
---|
| 1399 | "|%s|*.svx" CASE("*.SVX") |
---|
| 1400 | "|%s|*.plt;*.plf" CASE("*.PLT;*.PLF") |
---|
| 1401 | "|%s|*.dat;*.mak" CASE("*.DAT;*.MAK") |
---|
| 1402 | "|%s|*.adj;*.sht;*.una;*.xyz" CASE("*.ADJ;*.SHT;*.UNA;*.XYZ") |
---|
[5627cbb] | 1403 | "|%s|%s"), |
---|
[736f7df] | 1404 | /* TRANSLATORS: Here "survey" is a "cave map" rather than |
---|
| 1405 | * list of questions - it should be translated to the |
---|
| 1406 | * terminology that cavers using the language would use. |
---|
| 1407 | */ |
---|
[6e63fd3] | 1408 | wmsg(/*All survey files*/229).c_str(), |
---|
[0b8c321] | 1409 | /* TRANSLATORS: Survex is the name of the software, and "3d" refers to a |
---|
| 1410 | * file extension, so neither should be translated. */ |
---|
[5627cbb] | 1411 | wmsg(/*Survex 3d files*/207).c_str(), |
---|
[0b8c321] | 1412 | /* TRANSLATORS: Survex is the name of the software, and "svx" refers to a |
---|
| 1413 | * file extension, so neither should be translated. */ |
---|
[6e63fd3] | 1414 | wmsg(/*Survex svx files*/329).c_str(), |
---|
[736f7df] | 1415 | /* TRANSLATORS: "Compass" as in Larry Fish’s cave |
---|
| 1416 | * surveying package, so probably shouldn’t be translated |
---|
| 1417 | */ |
---|
[5627cbb] | 1418 | wmsg(/*Compass PLT files*/324).c_str(), |
---|
[736f7df] | 1419 | /* TRANSLATORS: "Compass" as in Larry Fish’s cave |
---|
[0b8c321] | 1420 | * surveying package, so should not be translated |
---|
[736f7df] | 1421 | */ |
---|
[6e63fd3] | 1422 | wmsg(/*Compass DAT and MAK files*/330).c_str(), |
---|
[736f7df] | 1423 | /* TRANSLATORS: "CMAP" is Bob Thrun’s cave surveying |
---|
| 1424 | * package, so don’t translate it. */ |
---|
[5627cbb] | 1425 | wmsg(/*CMAP XYZ files*/325).c_str(), |
---|
| 1426 | wmsg(/*All files*/208).c_str(), |
---|
[c988ae4] | 1427 | wxFileSelectorDefaultWildcardStr); |
---|
[5627cbb] | 1428 | #endif |
---|
[736f7df] | 1429 | /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions |
---|
| 1430 | * - it should be translated to the terminology that cavers using the |
---|
| 1431 | * language would use. |
---|
[b49ac56] | 1432 | * |
---|
[736f7df] | 1433 | * File->Open dialog: */ |
---|
[6e63fd3] | 1434 | wxFileDialog dlg(this, wmsg(/*Select a survey file to view*/206), |
---|
[5627cbb] | 1435 | wxString(), wxString(), |
---|
[c988ae4] | 1436 | filetypes, wxFD_OPEN|wxFD_FILE_MUST_EXIST); |
---|
[137bf99] | 1437 | if (dlg.ShowModal() == wxID_OK) { |
---|
[421b7d2] | 1438 | OpenFile(dlg.GetPath()); |
---|
[137bf99] | 1439 | } |
---|
| 1440 | } |
---|
| 1441 | |
---|
[622460e] | 1442 | void MainFrm::OnOpenTerrain(wxCommandEvent&) |
---|
| 1443 | { |
---|
| 1444 | if (!m_Gfx) return; |
---|
| 1445 | |
---|
[373b738] | 1446 | if (GetCSProj().empty()) { |
---|
[ceb2edb] | 1447 | wxMessageBox(wxT("No coordinate system specified in survey data")); |
---|
| 1448 | return; |
---|
| 1449 | } |
---|
| 1450 | |
---|
[622460e] | 1451 | #ifdef __WXMOTIF__ |
---|
[112f80c] | 1452 | wxString filetypes = wxT("*.*"); |
---|
[622460e] | 1453 | #else |
---|
| 1454 | wxString filetypes; |
---|
[112f80c] | 1455 | filetypes.Printf(wxT("%s|*.bil;*.hgt;*.zip" CASE("*.BIL;*.HGT;*.ZIP") |
---|
[622460e] | 1456 | "|%s|%s"), |
---|
| 1457 | wmsg(/*Terrain files*/452).c_str(), |
---|
| 1458 | wmsg(/*All files*/208).c_str(), |
---|
| 1459 | wxFileSelectorDefaultWildcardStr); |
---|
| 1460 | #endif |
---|
[51755e1] | 1461 | /* TRANSLATORS: "Terrain file" being a digital model of the terrain (e.g. a |
---|
| 1462 | * grid of height values). */ |
---|
[622460e] | 1463 | wxFileDialog dlg(this, wmsg(/*Select a terrain file to view*/451), |
---|
| 1464 | wxString(), wxString(), |
---|
| 1465 | filetypes, wxFD_OPEN|wxFD_FILE_MUST_EXIST); |
---|
| 1466 | if (dlg.ShowModal() == wxID_OK && m_Gfx->LoadDEM(dlg.GetPath())) { |
---|
| 1467 | if (!m_Gfx->DisplayingTerrain()) m_Gfx->ToggleTerrain(); |
---|
| 1468 | } |
---|
| 1469 | } |
---|
| 1470 | |
---|
[d7b53e3] | 1471 | void MainFrm::OnShowLog(wxCommandEvent&) |
---|
| 1472 | { |
---|
[4b2d207] | 1473 | if (!m_Log) { |
---|
| 1474 | HideLog(m_Splitter->GetWindow1()); |
---|
| 1475 | return; |
---|
| 1476 | } |
---|
[d7b53e3] | 1477 | wxWindow * win = m_Splitter->GetWindow1(); |
---|
| 1478 | m_Splitter->ReplaceWindow(win, m_Log); |
---|
[fd96020] | 1479 | win->Show(false); |
---|
[d7b53e3] | 1480 | if (m_Splitter->IsSplit()) { |
---|
| 1481 | m_SashPosition = m_Splitter->GetSashPosition(); // save width of panel |
---|
| 1482 | m_Splitter->Unsplit(); |
---|
| 1483 | } |
---|
| 1484 | m_Log->Show(true); |
---|
| 1485 | m_Log->SetFocus(); |
---|
| 1486 | m_Log = NULL; |
---|
| 1487 | } |
---|
| 1488 | |
---|
[045e2af] | 1489 | void MainFrm::OnScreenshot(wxCommandEvent&) |
---|
| 1490 | { |
---|
[f302cbaa] | 1491 | wxString baseleaf; |
---|
| 1492 | wxFileName::SplitPath(m_File, NULL, NULL, &baseleaf, NULL, wxPATH_NATIVE); |
---|
[736f7df] | 1493 | /* TRANSLATORS: title of the save screenshot dialog */ |
---|
[5627cbb] | 1494 | wxFileDialog dlg(this, wmsg(/*Save Screenshot*/321), wxString(), |
---|
[f302cbaa] | 1495 | baseleaf + wxT(".png"), |
---|
[5627cbb] | 1496 | wxT("*.png"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
---|
[045e2af] | 1497 | if (dlg.ShowModal() == wxID_OK) { |
---|
| 1498 | static bool png_handled = false; |
---|
| 1499 | if (!png_handled) { |
---|
[4a0e6b35] | 1500 | #if 0 // FIXME : enable this to allow other export formats... |
---|
[ee41e88] | 1501 | ::wxInitAllImageHandlers(); |
---|
| 1502 | #else |
---|
[045e2af] | 1503 | wxImage::AddHandler(new wxPNGHandler); |
---|
[ee41e88] | 1504 | #endif |
---|
[045e2af] | 1505 | png_handled = true; |
---|
| 1506 | } |
---|
| 1507 | if (!m_Gfx->SaveScreenshot(dlg.GetPath(), wxBITMAP_TYPE_PNG)) { |
---|
[0804fbe] | 1508 | wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), dlg.GetPath().c_str())); |
---|
[045e2af] | 1509 | } |
---|
| 1510 | } |
---|
| 1511 | } |
---|
| 1512 | |
---|
| 1513 | void MainFrm::OnScreenshotUpdate(wxUpdateUIEvent& event) |
---|
| 1514 | { |
---|
| 1515 | event.Enable(!m_File.empty()); |
---|
| 1516 | } |
---|
| 1517 | |
---|
[02c7c1a] | 1518 | void MainFrm::OnFilePreferences(wxCommandEvent&) |
---|
| 1519 | { |
---|
[edb6576] | 1520 | #ifdef PREFDLG |
---|
[203d2a7] | 1521 | m_PrefsDlg = new PrefsDlg(m_Gfx, this); |
---|
[02c7c1a] | 1522 | m_PrefsDlg->Show(true); |
---|
[edb6576] | 1523 | #endif |
---|
[02c7c1a] | 1524 | } |
---|
[8000d8f] | 1525 | |
---|
[ce403f1] | 1526 | void MainFrm::OnPrint(wxCommandEvent&) |
---|
| 1527 | { |
---|
[60d7755] | 1528 | m_Gfx->OnPrint(m_File, GetSurveyTitle(), GetDateString()); |
---|
[ce403f1] | 1529 | } |
---|
| 1530 | |
---|
[4ed8154] | 1531 | void MainFrm::PrintAndExit() |
---|
| 1532 | { |
---|
[60d7755] | 1533 | m_Gfx->OnPrint(m_File, GetSurveyTitle(), GetDateString(), true); |
---|
[4ed8154] | 1534 | } |
---|
| 1535 | |
---|
[ce403f1] | 1536 | void MainFrm::OnPageSetup(wxCommandEvent&) |
---|
| 1537 | { |
---|
[e0ffc2c] | 1538 | wxPageSetupDialog dlg(this, wxGetApp().GetPageSetupDialogData()); |
---|
| 1539 | if (dlg.ShowModal() == wxID_OK) { |
---|
| 1540 | wxGetApp().SetPageSetupDialogData(dlg.GetPageSetupData()); |
---|
| 1541 | } |
---|
[ce403f1] | 1542 | } |
---|
| 1543 | |
---|
[223f1ad] | 1544 | void MainFrm::OnExport(wxCommandEvent&) |
---|
| 1545 | { |
---|
[60d7755] | 1546 | m_Gfx->OnExport(m_File, GetSurveyTitle(), GetDateString()); |
---|
[223f1ad] | 1547 | } |
---|
| 1548 | |
---|
[549eb37] | 1549 | void MainFrm::OnExtend(wxCommandEvent&) |
---|
| 1550 | { |
---|
| 1551 | wxString output = m_Survey; |
---|
| 1552 | if (output.empty()) { |
---|
| 1553 | wxFileName::SplitPath(m_File, NULL, NULL, &output, NULL, wxPATH_NATIVE); |
---|
| 1554 | } |
---|
| 1555 | output += wxT("_extend.3d"); |
---|
| 1556 | { |
---|
| 1557 | #ifdef __WXMOTIF__ |
---|
| 1558 | wxString ext(wxT("*.3d")); |
---|
| 1559 | #else |
---|
| 1560 | /* TRANSLATORS: Survex is the name of the software, and "3d" refers to a |
---|
| 1561 | * file extension, so neither should be translated. */ |
---|
| 1562 | wxString ext = wmsg(/*Survex 3d files*/207); |
---|
| 1563 | ext += wxT("|*.3d"); |
---|
| 1564 | #endif |
---|
| 1565 | wxFileDialog dlg(this, wmsg(/*Select an output filename*/319), |
---|
| 1566 | wxString(), output, ext, |
---|
| 1567 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
---|
| 1568 | if (dlg.ShowModal() != wxID_OK) return; |
---|
| 1569 | output = dlg.GetPath(); |
---|
| 1570 | } |
---|
| 1571 | wxString cmd = get_command_path(L"extend"); |
---|
| 1572 | cmd = escape_for_shell(cmd, false); |
---|
| 1573 | if (!m_Survey.empty()) { |
---|
| 1574 | cmd += wxT(" --survey="); |
---|
| 1575 | cmd += escape_for_shell(m_Survey, false); |
---|
| 1576 | } |
---|
| 1577 | cmd += wxT(" --show-breaks "); |
---|
| 1578 | cmd += escape_for_shell(m_FileProcessed, true); |
---|
| 1579 | cmd += wxT(" "); |
---|
| 1580 | cmd += escape_for_shell(output, true); |
---|
| 1581 | if (wxExecute(cmd, wxEXEC_SYNC) < 0) { |
---|
| 1582 | wxString m; |
---|
| 1583 | m.Printf(wmsg(/*Couldn’t run external command: “%s”*/17), cmd.c_str()); |
---|
| 1584 | m += wxT(" ("); |
---|
| 1585 | m += wxString(strerror(errno), wxConvUTF8); |
---|
| 1586 | m += wxT(')'); |
---|
| 1587 | wxGetApp().ReportError(m); |
---|
| 1588 | return; |
---|
| 1589 | } |
---|
| 1590 | if (LoadData(output, wxString())) |
---|
| 1591 | InitialiseAfterLoad(output, wxString()); |
---|
| 1592 | } |
---|
| 1593 | |
---|
[137bf99] | 1594 | void MainFrm::OnQuit(wxCommandEvent&) |
---|
| 1595 | { |
---|
[1690fa9] | 1596 | if (m_PresList->Modified()) { |
---|
| 1597 | // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel] |
---|
[736f7df] | 1598 | /* TRANSLATORS: and the question in that box */ |
---|
[5627cbb] | 1599 | if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327), |
---|
[736f7df] | 1600 | /* TRANSLATORS: title of message box */ |
---|
[5627cbb] | 1601 | wmsg(/*Modified Presentation*/326), |
---|
[1690fa9] | 1602 | wxOK|wxCANCEL|wxICON_QUESTION) == wxCANCEL) { |
---|
| 1603 | return; |
---|
| 1604 | } |
---|
| 1605 | } |
---|
[3db0798] | 1606 | wxConfigBase *b = wxConfigBase::Get(); |
---|
| 1607 | if (IsFullScreen()) { |
---|
[5627cbb] | 1608 | b->Write(wxT("width"), -2); |
---|
| 1609 | b->DeleteEntry(wxT("height")); |
---|
[3db0798] | 1610 | } else if (IsMaximized()) { |
---|
[5627cbb] | 1611 | b->Write(wxT("width"), -1); |
---|
| 1612 | b->DeleteEntry(wxT("height")); |
---|
[3db0798] | 1613 | } else { |
---|
| 1614 | int width, height; |
---|
| 1615 | GetSize(&width, &height); |
---|
[5627cbb] | 1616 | b->Write(wxT("width"), width); |
---|
| 1617 | b->Write(wxT("height"), height); |
---|
[3db0798] | 1618 | } |
---|
| 1619 | b->Flush(); |
---|
[137bf99] | 1620 | exit(0); |
---|
| 1621 | } |
---|
| 1622 | |
---|
| 1623 | void MainFrm::OnClose(wxCloseEvent&) |
---|
| 1624 | { |
---|
[3db0798] | 1625 | wxCommandEvent dummy; |
---|
| 1626 | OnQuit(dummy); |
---|
[137bf99] | 1627 | } |
---|
| 1628 | |
---|
| 1629 | void MainFrm::OnAbout(wxCommandEvent&) |
---|
| 1630 | { |
---|
[261ab22] | 1631 | #ifdef __WXMAC__ |
---|
[559cd60] | 1632 | // GetIcon() returns an invalid wxIcon under macOS. |
---|
[261ab22] | 1633 | AboutDlg dlg(this, wxICON(aven)); |
---|
| 1634 | #else |
---|
[ea1ea51] | 1635 | AboutDlg dlg(this, GetIcon()); |
---|
[261ab22] | 1636 | #endif |
---|
[796aee3] | 1637 | dlg.Centre(); |
---|
| 1638 | dlg.ShowModal(); |
---|
[137bf99] | 1639 | } |
---|
[c6d95d8] | 1640 | |
---|
[7c29c976] | 1641 | void MainFrm::UpdateStatusBar() |
---|
| 1642 | { |
---|
| 1643 | if (!here_text.empty()) { |
---|
| 1644 | GetStatusBar()->SetStatusText(here_text); |
---|
| 1645 | GetStatusBar()->SetStatusText(dist_text, 1); |
---|
| 1646 | } else if (!coords_text.empty()) { |
---|
| 1647 | GetStatusBar()->SetStatusText(coords_text); |
---|
[0633bcc] | 1648 | GetStatusBar()->SetStatusText(distfree_text, 1); |
---|
[7c29c976] | 1649 | } else { |
---|
[5627cbb] | 1650 | GetStatusBar()->SetStatusText(wxString()); |
---|
| 1651 | GetStatusBar()->SetStatusText(wxString(), 1); |
---|
[7c29c976] | 1652 | } |
---|
| 1653 | } |
---|
| 1654 | |
---|
[1fd2edb] | 1655 | void MainFrm::ClearTreeSelection() |
---|
| 1656 | { |
---|
| 1657 | m_Tree->UnselectAll(); |
---|
[19026f3] | 1658 | m_Gfx->SetThere(); |
---|
[381ae6e] | 1659 | ShowInfo(); |
---|
[1fd2edb] | 1660 | } |
---|
| 1661 | |
---|
[156dc16] | 1662 | void MainFrm::ClearCoords() |
---|
| 1663 | { |
---|
[4b031c0] | 1664 | if (!coords_text.empty()) { |
---|
[5627cbb] | 1665 | coords_text = wxString(); |
---|
[4b031c0] | 1666 | UpdateStatusBar(); |
---|
| 1667 | } |
---|
[156dc16] | 1668 | } |
---|
| 1669 | |
---|
[d67450e] | 1670 | void MainFrm::SetCoords(const Vector3 &v) |
---|
[d877aa2] | 1671 | { |
---|
[ccb83b7] | 1672 | Double x = v.GetX(); |
---|
| 1673 | Double y = v.GetY(); |
---|
| 1674 | Double z = v.GetZ(); |
---|
| 1675 | int units; |
---|
[d877aa2] | 1676 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 1677 | units = /*m*/424; |
---|
[d877aa2] | 1678 | } else { |
---|
[ccb83b7] | 1679 | x /= METRES_PER_FOOT; |
---|
| 1680 | y /= METRES_PER_FOOT; |
---|
| 1681 | z /= METRES_PER_FOOT; |
---|
| 1682 | units = /*ft*/428; |
---|
[d877aa2] | 1683 | } |
---|
[736f7df] | 1684 | /* TRANSLATORS: show coordinates (N = North or Northing, E = East or |
---|
| 1685 | * Easting) */ |
---|
[ccb83b7] | 1686 | coords_text.Printf(wmsg(/*%.2f E, %.2f N*/338), x, y); |
---|
| 1687 | coords_text += wxString::Format(wxT(", %s %.2f%s"), |
---|
| 1688 | wmsg(/*Altitude*/335).c_str(), |
---|
| 1689 | z, wmsg(units).c_str()); |
---|
[5627cbb] | 1690 | distfree_text = wxString(); |
---|
[7c29c976] | 1691 | UpdateStatusBar(); |
---|
[d877aa2] | 1692 | } |
---|
| 1693 | |
---|
[0633bcc] | 1694 | const LabelInfo * MainFrm::GetTreeSelection() const { |
---|
| 1695 | wxTreeItemData* sel_wx; |
---|
| 1696 | if (!m_Tree->GetSelectionData(&sel_wx)) return NULL; |
---|
| 1697 | |
---|
[44ed489] | 1698 | const TreeData* data = static_cast<const TreeData*>(sel_wx); |
---|
[0633bcc] | 1699 | if (!data->IsStation()) return NULL; |
---|
| 1700 | |
---|
| 1701 | return data->GetLabel(); |
---|
| 1702 | } |
---|
| 1703 | |
---|
[381ae6e] | 1704 | void MainFrm::SetCoords(Double x, Double y, const LabelInfo * there) |
---|
[156dc16] | 1705 | { |
---|
[7c29c976] | 1706 | wxString & s = coords_text; |
---|
[33b2094] | 1707 | if (m_Gfx->GetMetric()) { |
---|
[5627cbb] | 1708 | s.Printf(wmsg(/*%.2f E, %.2f N*/338), x, y); |
---|
[7a89dc2] | 1709 | } else { |
---|
[5627cbb] | 1710 | s.Printf(wmsg(/*%.2f E, %.2f N*/338), |
---|
[3d4bee1] | 1711 | x / METRES_PER_FOOT, y / METRES_PER_FOOT); |
---|
[7a89dc2] | 1712 | } |
---|
[0633bcc] | 1713 | |
---|
[c00c6713] | 1714 | wxString & t = distfree_text; |
---|
[5627cbb] | 1715 | t = wxString(); |
---|
[381ae6e] | 1716 | if (m_Gfx->ShowingMeasuringLine() && there) { |
---|
[373b738] | 1717 | auto offset = GetOffset(); |
---|
| 1718 | Vector3 delta(x - offset.GetX() - there->GetX(), |
---|
| 1719 | y - offset.GetY() - there->GetY(), 0); |
---|
[0633bcc] | 1720 | Double dh = sqrt(delta.GetX()*delta.GetX() + delta.GetY()*delta.GetY()); |
---|
| 1721 | Double brg = deg(atan2(delta.GetX(), delta.GetY())); |
---|
| 1722 | if (brg < 0) brg += 360; |
---|
| 1723 | |
---|
| 1724 | wxString from_str; |
---|
[736f7df] | 1725 | /* TRANSLATORS: Used in Aven: |
---|
[113731f] | 1726 | * From <stationname>: H 12.24m, Brg 234.5° |
---|
| 1727 | */ |
---|
[7b9b700] | 1728 | from_str.Printf(wmsg(/*From %s*/339), there->name_or_anon().c_str()); |
---|
[ccb83b7] | 1729 | int brg_unit; |
---|
[0633bcc] | 1730 | if (m_Gfx->GetDegrees()) { |
---|
[ccb83b7] | 1731 | brg_unit = /*°*/344; |
---|
[0633bcc] | 1732 | } else { |
---|
| 1733 | brg *= 400.0 / 360.0; |
---|
[85dcdcd] | 1734 | brg_unit = /*ᵍ*/345; |
---|
[0633bcc] | 1735 | } |
---|
| 1736 | |
---|
[ccb83b7] | 1737 | int units; |
---|
[0633bcc] | 1738 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 1739 | units = /*m*/424; |
---|
[0633bcc] | 1740 | } else { |
---|
[ccb83b7] | 1741 | dh /= METRES_PER_FOOT; |
---|
| 1742 | units = /*ft*/428; |
---|
[0633bcc] | 1743 | } |
---|
[736f7df] | 1744 | /* TRANSLATORS: "H" is short for "Horizontal", "Brg" for "Bearing" (as |
---|
| 1745 | * in Compass bearing) */ |
---|
[113731f] | 1746 | t.Printf(wmsg(/*%s: H %.2f%s, Brg %03.1f%s*/374), |
---|
[ccb83b7] | 1747 | from_str.c_str(), dh, wmsg(units).c_str(), |
---|
[113731f] | 1748 | brg, wmsg(brg_unit).c_str()); |
---|
[0633bcc] | 1749 | } |
---|
| 1750 | |
---|
[7c29c976] | 1751 | UpdateStatusBar(); |
---|
[156dc16] | 1752 | } |
---|
| 1753 | |
---|
[381ae6e] | 1754 | void MainFrm::SetAltitude(Double z, const LabelInfo * there) |
---|
[156dc16] | 1755 | { |
---|
[ccb83b7] | 1756 | double alt = z; |
---|
| 1757 | int units; |
---|
[33b2094] | 1758 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 1759 | units = /*m*/424; |
---|
[7a89dc2] | 1760 | } else { |
---|
[ccb83b7] | 1761 | alt /= METRES_PER_FOOT; |
---|
| 1762 | units = /*ft*/428; |
---|
[7a89dc2] | 1763 | } |
---|
[ccb83b7] | 1764 | coords_text.Printf(wxT("%s %.2f%s"), wmsg(/*Altitude*/335).c_str(), |
---|
| 1765 | alt, wmsg(units).c_str()); |
---|
[0633bcc] | 1766 | |
---|
[c00c6713] | 1767 | wxString & t = distfree_text; |
---|
[5627cbb] | 1768 | t = wxString(); |
---|
[381ae6e] | 1769 | if (m_Gfx->ShowingMeasuringLine() && there) { |
---|
[373b738] | 1770 | Double dz = z - GetOffset().GetZ() - there->GetZ(); |
---|
[0633bcc] | 1771 | |
---|
| 1772 | wxString from_str; |
---|
[7b9b700] | 1773 | from_str.Printf(wmsg(/*From %s*/339), there->name_or_anon().c_str()); |
---|
[0633bcc] | 1774 | |
---|
[ccb83b7] | 1775 | if (!m_Gfx->GetMetric()) { |
---|
| 1776 | dz /= METRES_PER_FOOT; |
---|
[0633bcc] | 1777 | } |
---|
[736f7df] | 1778 | // TRANSLATORS: "V" is short for "Vertical" |
---|
[ccb83b7] | 1779 | t.Printf(wmsg(/*%s: V %.2f%s*/375), from_str.c_str(), |
---|
| 1780 | dz, wmsg(units).c_str()); |
---|
[0633bcc] | 1781 | } |
---|
| 1782 | |
---|
[7c29c976] | 1783 | UpdateStatusBar(); |
---|
[2a3d328] | 1784 | } |
---|
| 1785 | |
---|
[381ae6e] | 1786 | void MainFrm::ShowInfo(const LabelInfo *here, const LabelInfo *there) |
---|
[7a89dc2] | 1787 | { |
---|
| 1788 | assert(m_Gfx); |
---|
[f433fda] | 1789 | |
---|
[0633bcc] | 1790 | if (!here) { |
---|
[7c29c976] | 1791 | m_Gfx->SetHere(); |
---|
[570d62c3] | 1792 | m_Tree->SetHere(wxTreeItemId()); |
---|
[1235f9b] | 1793 | // Don't clear "There" mark here. |
---|
[4b031c0] | 1794 | if (here_text.empty() && dist_text.empty()) return; |
---|
[5627cbb] | 1795 | here_text = wxString(); |
---|
| 1796 | dist_text = wxString(); |
---|
[7c29c976] | 1797 | UpdateStatusBar(); |
---|
| 1798 | return; |
---|
| 1799 | } |
---|
| 1800 | |
---|
[373b738] | 1801 | Vector3 v = *here + GetOffset(); |
---|
[7c29c976] | 1802 | wxString & s = here_text; |
---|
[ccb83b7] | 1803 | Double x = v.GetX(); |
---|
| 1804 | Double y = v.GetY(); |
---|
| 1805 | Double z = v.GetZ(); |
---|
| 1806 | int units; |
---|
[33b2094] | 1807 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 1808 | units = /*m*/424; |
---|
[7a89dc2] | 1809 | } else { |
---|
[ccb83b7] | 1810 | x /= METRES_PER_FOOT; |
---|
| 1811 | y /= METRES_PER_FOOT; |
---|
| 1812 | z /= METRES_PER_FOOT; |
---|
| 1813 | units = /*ft*/428; |
---|
[7a89dc2] | 1814 | } |
---|
[ccb83b7] | 1815 | s.Printf(wmsg(/*%.2f E, %.2f N*/338), x, y); |
---|
| 1816 | s += wxString::Format(wxT(", %s %.2f%s"), wmsg(/*Altitude*/335).c_str(), |
---|
| 1817 | z, wmsg(units).c_str()); |
---|
[5627cbb] | 1818 | s += wxT(": "); |
---|
[f153906] | 1819 | s += here->name_or_anon(); |
---|
[381ae6e] | 1820 | m_Gfx->SetHere(here); |
---|
[570d62c3] | 1821 | m_Tree->SetHere(here->tree_id); |
---|
[7a89dc2] | 1822 | |
---|
[381ae6e] | 1823 | if (m_Gfx->ShowingMeasuringLine() && there) { |
---|
| 1824 | Vector3 delta = *here - *there; |
---|
[d67450e] | 1825 | |
---|
[87d2ab6] | 1826 | Double d_horiz = sqrt(delta.GetX()*delta.GetX() + |
---|
| 1827 | delta.GetY()*delta.GetY()); |
---|
[0633bcc] | 1828 | Double dr = delta.magnitude(); |
---|
[87d2ab6] | 1829 | Double dz = delta.GetZ(); |
---|
[d67450e] | 1830 | |
---|
[0633bcc] | 1831 | Double brg = deg(atan2(delta.GetX(), delta.GetY())); |
---|
| 1832 | if (brg < 0) brg += 360; |
---|
[421b7d2] | 1833 | |
---|
[533d8e0] | 1834 | Double grd = deg(atan2(delta.GetZ(), d_horiz)); |
---|
| 1835 | |
---|
[0633bcc] | 1836 | wxString from_str; |
---|
[7b9b700] | 1837 | from_str.Printf(wmsg(/*From %s*/339), there->name_or_anon().c_str()); |
---|
[203d2a7] | 1838 | |
---|
[0633bcc] | 1839 | wxString hv_str; |
---|
| 1840 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 1841 | units = /*m*/424; |
---|
[0633bcc] | 1842 | } else { |
---|
[ccb83b7] | 1843 | d_horiz /= METRES_PER_FOOT; |
---|
| 1844 | dr /= METRES_PER_FOOT; |
---|
[87d2ab6] | 1845 | dz /= METRES_PER_FOOT; |
---|
[ccb83b7] | 1846 | units = /*ft*/428; |
---|
[0633bcc] | 1847 | } |
---|
[ccb83b7] | 1848 | wxString len_unit = wmsg(units); |
---|
[736f7df] | 1849 | /* TRANSLATORS: "H" is short for "Horizontal", "V" for "Vertical" */ |
---|
[ccb83b7] | 1850 | hv_str.Printf(wmsg(/*H %.2f%s, V %.2f%s*/340), |
---|
[87d2ab6] | 1851 | d_horiz, len_unit.c_str(), dz, len_unit.c_str()); |
---|
[ccb83b7] | 1852 | int brg_unit; |
---|
[0633bcc] | 1853 | if (m_Gfx->GetDegrees()) { |
---|
[ccb83b7] | 1854 | brg_unit = /*°*/344; |
---|
[7a89dc2] | 1855 | } else { |
---|
[0633bcc] | 1856 | brg *= 400.0 / 360.0; |
---|
[85dcdcd] | 1857 | brg_unit = /*ᵍ*/345; |
---|
[421b7d2] | 1858 | } |
---|
[533d8e0] | 1859 | int grd_unit; |
---|
| 1860 | wxString grd_str; |
---|
| 1861 | if (m_Gfx->GetPercent()) { |
---|
| 1862 | if (grd > 89.99) { |
---|
| 1863 | grd = 1000000; |
---|
| 1864 | } else if (grd < -89.99) { |
---|
| 1865 | grd = -1000000; |
---|
| 1866 | } else { |
---|
| 1867 | grd = int(100 * tan(rad(grd))); |
---|
| 1868 | } |
---|
| 1869 | if (grd > 99999 || grd < -99999) { |
---|
| 1870 | grd_str = grd > 0 ? wxT("+") : wxT("-"); |
---|
| 1871 | /* TRANSLATORS: infinity symbol - used for the percentage gradient on |
---|
| 1872 | * vertical angles. */ |
---|
| 1873 | grd_str += wmsg(/*∞*/431); |
---|
| 1874 | } |
---|
| 1875 | grd_unit = /*%*/96; |
---|
| 1876 | } else if (m_Gfx->GetDegrees()) { |
---|
| 1877 | grd_unit = /*°*/344; |
---|
| 1878 | } else { |
---|
| 1879 | grd *= 400.0 / 360.0; |
---|
| 1880 | grd_unit = /*ᵍ*/345; |
---|
| 1881 | } |
---|
| 1882 | if (grd_str.empty()) { |
---|
| 1883 | grd_str.Printf(wxT("%+02.1f%s"), grd, wmsg(grd_unit).c_str()); |
---|
| 1884 | } |
---|
| 1885 | |
---|
[0633bcc] | 1886 | wxString & d = dist_text; |
---|
[736f7df] | 1887 | /* TRANSLATORS: "Dist" is short for "Distance", "Brg" for "Bearing" (as |
---|
[533d8e0] | 1888 | * in Compass bearing) and "Grd" for "Gradient" (the slope angle |
---|
| 1889 | * measured by the clino) */ |
---|
| 1890 | d.Printf(wmsg(/*%s: %s, Dist %.2f%s, Brg %03.1f%s, Grd %s*/341), |
---|
[ccb83b7] | 1891 | from_str.c_str(), hv_str.c_str(), |
---|
[533d8e0] | 1892 | dr, len_unit.c_str(), |
---|
| 1893 | brg, wmsg(brg_unit).c_str(), |
---|
| 1894 | grd_str.c_str()); |
---|
[0633bcc] | 1895 | } else { |
---|
[5627cbb] | 1896 | dist_text = wxString(); |
---|
[0633bcc] | 1897 | m_Gfx->SetThere(); |
---|
[156dc16] | 1898 | } |
---|
[7c29c976] | 1899 | UpdateStatusBar(); |
---|
[7a89dc2] | 1900 | } |
---|
| 1901 | |
---|
[8734409] | 1902 | void MainFrm::DisplayTreeInfo(const wxTreeItemData* item) |
---|
[7a89dc2] | 1903 | { |
---|
[8734409] | 1904 | const TreeData* data = static_cast<const TreeData*>(item); |
---|
[0642381] | 1905 | if (data) { |
---|
| 1906 | if (data->IsStation()) { |
---|
| 1907 | m_Gfx->SetHereFromTree(data->GetLabel()); |
---|
| 1908 | } else { |
---|
| 1909 | m_Gfx->SetHereSurvey(data->GetSurvey()); |
---|
| 1910 | ShowInfo(); |
---|
| 1911 | } |
---|
| 1912 | return; |
---|
[156dc16] | 1913 | } |
---|
[0642381] | 1914 | m_Gfx->SetHereSurvey(wxString()); |
---|
| 1915 | ShowInfo(); |
---|
[156dc16] | 1916 | } |
---|
| 1917 | |
---|
[672459c] | 1918 | void MainFrm::TreeItemSelected(const wxTreeItemData* item) |
---|
[156dc16] | 1919 | { |
---|
[44ed489] | 1920 | const TreeData* data = static_cast<const TreeData*>(item); |
---|
[156dc16] | 1921 | if (data && data->IsStation()) { |
---|
[8734409] | 1922 | const LabelInfo* label = data->GetLabel(); |
---|
[672459c] | 1923 | if (m_Gfx->GetThere() == label) { |
---|
| 1924 | m_Gfx->CentreOn(*label); |
---|
| 1925 | } else { |
---|
| 1926 | m_Gfx->SetThere(label); |
---|
| 1927 | } |
---|
[5627cbb] | 1928 | dist_text = wxString(); |
---|
[7c29c976] | 1929 | // FIXME: Need to update dist_text (From ... etc) |
---|
[887c26e] | 1930 | // But we don't currently know where "here" is at this point in the |
---|
| 1931 | // code! |
---|
[0580c6a] | 1932 | } else { |
---|
[5627cbb] | 1933 | dist_text = wxString(); |
---|
[0580c6a] | 1934 | m_Gfx->SetThere(); |
---|
[672459c] | 1935 | if (!data) { |
---|
| 1936 | // Must be the root. |
---|
[0642381] | 1937 | wxCommandEvent dummy; |
---|
| 1938 | OnDefaults(dummy); |
---|
[672459c] | 1939 | } else { |
---|
[0642381] | 1940 | m_Gfx->ZoomToSurvey(data->GetSurvey()); |
---|
[44ed489] | 1941 | } |
---|
| 1942 | } |
---|
[7c29c976] | 1943 | UpdateStatusBar(); |
---|
[156dc16] | 1944 | } |
---|
| 1945 | |
---|
[97a414f] | 1946 | void MainFrm::OnPresNew(wxCommandEvent&) |
---|
[156dc16] | 1947 | { |
---|
[1690fa9] | 1948 | if (m_PresList->Modified()) { |
---|
| 1949 | // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel] |
---|
[5627cbb] | 1950 | if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327), |
---|
| 1951 | wmsg(/*Modified Presentation*/326), |
---|
[1690fa9] | 1952 | wxOK|wxCANCEL|wxICON_QUESTION) == wxCANCEL) { |
---|
| 1953 | return; |
---|
| 1954 | } |
---|
[156dc16] | 1955 | } |
---|
[bd7607c] | 1956 | m_PresList->New(m_File); |
---|
[24961e2] | 1957 | if (!ShowingSidePanel()) ToggleSidePanel(); |
---|
[c8f929b] | 1958 | // Select the presentation page in the notebook. |
---|
| 1959 | m_Notebook->SetSelection(1); |
---|
[156dc16] | 1960 | } |
---|
| 1961 | |
---|
[97a414f] | 1962 | void MainFrm::OnPresOpen(wxCommandEvent&) |
---|
[156dc16] | 1963 | { |
---|
[1690fa9] | 1964 | if (m_PresList->Modified()) { |
---|
| 1965 | // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel] |
---|
[5627cbb] | 1966 | if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327), |
---|
| 1967 | wmsg(/*Modified Presentation*/326), |
---|
[1690fa9] | 1968 | wxOK|wxCANCEL|wxICON_QUESTION) == wxCANCEL) { |
---|
| 1969 | return; |
---|
| 1970 | } |
---|
| 1971 | } |
---|
[156dc16] | 1972 | #ifdef __WXMOTIF__ |
---|
[5627cbb] | 1973 | wxFileDialog dlg(this, wmsg(/*Select a presentation to open*/322), wxString(), wxString(), |
---|
| 1974 | wxT("*.fly"), wxFD_OPEN); |
---|
[156dc16] | 1975 | #else |
---|
[5627cbb] | 1976 | wxFileDialog dlg(this, wmsg(/*Select a presentation to open*/322), wxString(), wxString(), |
---|
| 1977 | wxString::Format(wxT("%s|*.fly|%s|%s"), |
---|
[b49ac56] | 1978 | wmsg(/*Aven presentations*/320).c_str(), |
---|
| 1979 | wmsg(/*All files*/208).c_str(), |
---|
| 1980 | wxFileSelectorDefaultWildcardStr), |
---|
[5627cbb] | 1981 | wxFD_OPEN|wxFD_FILE_MUST_EXIST); |
---|
[156dc16] | 1982 | #endif |
---|
| 1983 | if (dlg.ShowModal() == wxID_OK) { |
---|
[1690fa9] | 1984 | if (!m_PresList->Load(dlg.GetPath())) { |
---|
| 1985 | return; |
---|
| 1986 | } |
---|
[97a414f] | 1987 | // FIXME : keep a history of loaded/saved presentations, like we do for |
---|
| 1988 | // loaded surveys... |
---|
[c8f929b] | 1989 | // Select the presentation page in the notebook. |
---|
| 1990 | m_Notebook->SetSelection(1); |
---|
[156dc16] | 1991 | } |
---|
| 1992 | } |
---|
[5ffa439] | 1993 | |
---|
[97a414f] | 1994 | void MainFrm::OnPresSave(wxCommandEvent&) |
---|
[8000d8f] | 1995 | { |
---|
[1690fa9] | 1996 | m_PresList->Save(true); |
---|
[8000d8f] | 1997 | } |
---|
| 1998 | |
---|
[97a414f] | 1999 | void MainFrm::OnPresSaveAs(wxCommandEvent&) |
---|
[5ffa439] | 2000 | { |
---|
[1690fa9] | 2001 | m_PresList->Save(false); |
---|
[5ffa439] | 2002 | } |
---|
| 2003 | |
---|
[97a414f] | 2004 | void MainFrm::OnPresMark(wxCommandEvent&) |
---|
[5ffa439] | 2005 | { |
---|
[1690fa9] | 2006 | m_PresList->AddMark(); |
---|
[5ffa439] | 2007 | } |
---|
| 2008 | |
---|
[128fac4] | 2009 | void MainFrm::OnPresFRewind(wxCommandEvent&) |
---|
| 2010 | { |
---|
| 2011 | m_Gfx->PlayPres(-100); |
---|
| 2012 | } |
---|
| 2013 | |
---|
| 2014 | void MainFrm::OnPresRewind(wxCommandEvent&) |
---|
| 2015 | { |
---|
| 2016 | m_Gfx->PlayPres(-10); |
---|
| 2017 | } |
---|
| 2018 | |
---|
| 2019 | void MainFrm::OnPresReverse(wxCommandEvent&) |
---|
| 2020 | { |
---|
| 2021 | m_Gfx->PlayPres(-1); |
---|
| 2022 | } |
---|
| 2023 | |
---|
| 2024 | void MainFrm::OnPresPlay(wxCommandEvent&) |
---|
[5ffa439] | 2025 | { |
---|
[128fac4] | 2026 | m_Gfx->PlayPres(1); |
---|
| 2027 | } |
---|
| 2028 | |
---|
| 2029 | void MainFrm::OnPresFF(wxCommandEvent&) |
---|
| 2030 | { |
---|
| 2031 | m_Gfx->PlayPres(10); |
---|
| 2032 | } |
---|
| 2033 | |
---|
| 2034 | void MainFrm::OnPresFFF(wxCommandEvent&) |
---|
| 2035 | { |
---|
| 2036 | m_Gfx->PlayPres(100); |
---|
| 2037 | } |
---|
| 2038 | |
---|
| 2039 | void MainFrm::OnPresPause(wxCommandEvent&) |
---|
| 2040 | { |
---|
| 2041 | m_Gfx->PlayPres(0); |
---|
| 2042 | } |
---|
| 2043 | |
---|
| 2044 | void MainFrm::OnPresStop(wxCommandEvent&) |
---|
| 2045 | { |
---|
| 2046 | m_Gfx->PlayPres(0, false); |
---|
[5ffa439] | 2047 | } |
---|
| 2048 | |
---|
[97a414f] | 2049 | void MainFrm::OnPresExportMovie(wxCommandEvent&) |
---|
[6a4cdcb6] | 2050 | { |
---|
[f4e4b56] | 2051 | #ifdef WITH_LIBAV |
---|
[97a414f] | 2052 | // FIXME : Taking the leaf of the currently loaded presentation as the |
---|
| 2053 | // default might make more sense? |
---|
[f302cbaa] | 2054 | wxString baseleaf; |
---|
| 2055 | wxFileName::SplitPath(m_File, NULL, NULL, &baseleaf, NULL, wxPATH_NATIVE); |
---|
[6e63fd3] | 2056 | wxFileDialog dlg(this, wmsg(/*Export Movie*/331), wxString(), |
---|
[709dd14] | 2057 | baseleaf + wxT(".mp4"), |
---|
[65f6d8e] | 2058 | wxT("MPEG|*.mp4|OGG|*.ogv|AVI|*.avi|QuickTime|*.mov|WMV|*.wmv;*.asf"), |
---|
[4e98397] | 2059 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
---|
[97a414f] | 2060 | if (dlg.ShowModal() == wxID_OK) { |
---|
[091069f] | 2061 | // Error is reported by GfxCore. |
---|
| 2062 | (void)m_Gfx->ExportMovie(dlg.GetPath()); |
---|
[6a4cdcb6] | 2063 | } |
---|
[f4e4b56] | 2064 | #else |
---|
| 2065 | wxGetApp().ReportError(wxT("Movie generation support code not present")); |
---|
| 2066 | #endif |
---|
[6a4cdcb6] | 2067 | } |
---|
| 2068 | |
---|
[1690fa9] | 2069 | PresentationMark MainFrm::GetPresMark(int which) |
---|
[5ffa439] | 2070 | { |
---|
[1690fa9] | 2071 | return m_PresList->GetPresMark(which); |
---|
[5ffa439] | 2072 | } |
---|
| 2073 | |
---|
[86895ec] | 2074 | void MainFrm::RestrictTo(const wxString & survey) |
---|
| 2075 | { |
---|
| 2076 | // The station names will change, so clear the current search. |
---|
| 2077 | wxCommandEvent dummy; |
---|
| 2078 | OnHide(dummy); |
---|
| 2079 | |
---|
| 2080 | wxString new_prefix; |
---|
| 2081 | if (!survey.empty()) { |
---|
| 2082 | if (!m_Survey.empty()) { |
---|
| 2083 | new_prefix = m_Survey; |
---|
[373b738] | 2084 | new_prefix += GetSeparator(); |
---|
[86895ec] | 2085 | } |
---|
| 2086 | new_prefix += survey; |
---|
| 2087 | } |
---|
[c0aabea] | 2088 | // Reload the processed data rather rather than potentially reprocessing. |
---|
| 2089 | if (!LoadData(m_FileProcessed, new_prefix)) |
---|
[86895ec] | 2090 | return; |
---|
| 2091 | InitialiseAfterLoad(m_File, new_prefix); |
---|
| 2092 | } |
---|
| 2093 | |
---|
[622460e] | 2094 | void MainFrm::OnOpenTerrainUpdate(wxUpdateUIEvent& event) |
---|
| 2095 | { |
---|
| 2096 | event.Enable(!m_File.empty()); |
---|
| 2097 | } |
---|
[1690fa9] | 2098 | |
---|
| 2099 | void MainFrm::OnPresNewUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2100 | { |
---|
[1366db2] | 2101 | event.Enable(!m_File.empty()); |
---|
[5ffa439] | 2102 | } |
---|
| 2103 | |
---|
[1690fa9] | 2104 | void MainFrm::OnPresOpenUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2105 | { |
---|
[1690fa9] | 2106 | event.Enable(!m_File.empty()); |
---|
[5ffa439] | 2107 | } |
---|
| 2108 | |
---|
[1690fa9] | 2109 | void MainFrm::OnPresSaveUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2110 | { |
---|
[1690fa9] | 2111 | event.Enable(!m_PresList->Empty()); |
---|
[5ffa439] | 2112 | } |
---|
| 2113 | |
---|
[1690fa9] | 2114 | void MainFrm::OnPresSaveAsUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2115 | { |
---|
[1690fa9] | 2116 | event.Enable(!m_PresList->Empty()); |
---|
[5ffa439] | 2117 | } |
---|
| 2118 | |
---|
[1690fa9] | 2119 | void MainFrm::OnPresMarkUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2120 | { |
---|
[1690fa9] | 2121 | event.Enable(!m_File.empty()); |
---|
| 2122 | } |
---|
| 2123 | |
---|
[128fac4] | 2124 | void MainFrm::OnPresFRewindUpdate(wxUpdateUIEvent& event) |
---|
| 2125 | { |
---|
| 2126 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2127 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() < -10); |
---|
| 2128 | } |
---|
| 2129 | |
---|
| 2130 | void MainFrm::OnPresRewindUpdate(wxUpdateUIEvent& event) |
---|
| 2131 | { |
---|
| 2132 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2133 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() == -10); |
---|
| 2134 | } |
---|
| 2135 | |
---|
| 2136 | void MainFrm::OnPresReverseUpdate(wxUpdateUIEvent& event) |
---|
| 2137 | { |
---|
| 2138 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2139 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() == -1); |
---|
| 2140 | } |
---|
| 2141 | |
---|
| 2142 | void MainFrm::OnPresPlayUpdate(wxUpdateUIEvent& event) |
---|
[1690fa9] | 2143 | { |
---|
| 2144 | event.Enable(!m_PresList->Empty()); |
---|
[128fac4] | 2145 | event.Check(m_Gfx && m_Gfx->GetPresentationMode() && |
---|
| 2146 | m_Gfx->GetPresentationSpeed() == 1); |
---|
| 2147 | } |
---|
| 2148 | |
---|
| 2149 | void MainFrm::OnPresFFUpdate(wxUpdateUIEvent& event) |
---|
| 2150 | { |
---|
| 2151 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2152 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() == 10); |
---|
| 2153 | } |
---|
| 2154 | |
---|
| 2155 | void MainFrm::OnPresFFFUpdate(wxUpdateUIEvent& event) |
---|
| 2156 | { |
---|
| 2157 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2158 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() > 10); |
---|
| 2159 | } |
---|
| 2160 | |
---|
| 2161 | void MainFrm::OnPresPauseUpdate(wxUpdateUIEvent& event) |
---|
| 2162 | { |
---|
| 2163 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2164 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() == 0); |
---|
| 2165 | } |
---|
| 2166 | |
---|
| 2167 | void MainFrm::OnPresStopUpdate(wxUpdateUIEvent& event) |
---|
| 2168 | { |
---|
| 2169 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
[5ffa439] | 2170 | } |
---|
[2a02de2] | 2171 | |
---|
[6a4cdcb6] | 2172 | void MainFrm::OnPresExportMovieUpdate(wxUpdateUIEvent& event) |
---|
| 2173 | { |
---|
| 2174 | event.Enable(!m_PresList->Empty()); |
---|
| 2175 | } |
---|
| 2176 | |
---|
[b4fe9fb] | 2177 | void MainFrm::OnFind(wxCommandEvent&) |
---|
[2a02de2] | 2178 | { |
---|
[bc60689] | 2179 | pending_find = true; |
---|
| 2180 | } |
---|
| 2181 | |
---|
| 2182 | void MainFrm::OnIdle(wxIdleEvent&) |
---|
| 2183 | { |
---|
| 2184 | if (pending_find) { |
---|
| 2185 | DoFind(); |
---|
| 2186 | } |
---|
| 2187 | } |
---|
| 2188 | |
---|
| 2189 | void MainFrm::DoFind() |
---|
| 2190 | { |
---|
| 2191 | pending_find = false; |
---|
[e98af57] | 2192 | wxBusyCursor hourglass; |
---|
[44ed489] | 2193 | // Find stations specified by a string or regular expression pattern. |
---|
[9d3d8cc] | 2194 | |
---|
[0580c6a] | 2195 | wxString pattern = m_FindBox->GetValue(); |
---|
[d1628e8e] | 2196 | if (pattern.empty()) { |
---|
| 2197 | // Hide any search result highlights. |
---|
| 2198 | list<LabelInfo*>::iterator pos = m_Labels.begin(); |
---|
| 2199 | while (pos != m_Labels.end()) { |
---|
| 2200 | LabelInfo* label = *pos++; |
---|
[5a24583] | 2201 | label->clear_flags(LFLAG_HIGHLIGHTED); |
---|
[c8aff97] | 2202 | } |
---|
[d1628e8e] | 2203 | m_NumHighlighted = 0; |
---|
[0c76ad9] | 2204 | } else { |
---|
[d1628e8e] | 2205 | int re_flags = wxRE_NOSUB; |
---|
| 2206 | |
---|
| 2207 | if (true /* case insensitive */) { |
---|
| 2208 | re_flags |= wxRE_ICASE; |
---|
[0c76ad9] | 2209 | } |
---|
| 2210 | |
---|
[d1628e8e] | 2211 | bool substring = true; |
---|
| 2212 | if (false /*m_RegexpCheckBox->GetValue()*/) { |
---|
| 2213 | re_flags |= wxRE_EXTENDED; |
---|
| 2214 | } else if (true /* simple glob-style */) { |
---|
| 2215 | wxString pat; |
---|
| 2216 | for (size_t i = 0; i < pattern.size(); i++) { |
---|
[5627cbb] | 2217 | wxChar ch = pattern[i]; |
---|
[d1628e8e] | 2218 | // ^ only special at start; $ at end. But this is simpler... |
---|
| 2219 | switch (ch) { |
---|
| 2220 | case '^': case '$': case '.': case '[': case '\\': |
---|
[5627cbb] | 2221 | pat += wxT('\\'); |
---|
[d1628e8e] | 2222 | pat += ch; |
---|
| 2223 | break; |
---|
| 2224 | case '*': |
---|
[5627cbb] | 2225 | pat += wxT(".*"); |
---|
[d1628e8e] | 2226 | substring = false; |
---|
| 2227 | break; |
---|
| 2228 | case '?': |
---|
[5627cbb] | 2229 | pat += wxT('.'); |
---|
[d1628e8e] | 2230 | substring = false; |
---|
| 2231 | break; |
---|
| 2232 | default: |
---|
| 2233 | pat += ch; |
---|
| 2234 | } |
---|
| 2235 | } |
---|
| 2236 | pattern = pat; |
---|
| 2237 | re_flags |= wxRE_BASIC; |
---|
| 2238 | } else { |
---|
| 2239 | wxString pat; |
---|
| 2240 | for (size_t i = 0; i < pattern.size(); i++) { |
---|
[5627cbb] | 2241 | wxChar ch = pattern[i]; |
---|
[d1628e8e] | 2242 | // ^ only special at start; $ at end. But this is simpler... |
---|
| 2243 | switch (ch) { |
---|
| 2244 | case '^': case '$': case '*': case '.': case '[': case '\\': |
---|
[5627cbb] | 2245 | pat += wxT('\\'); |
---|
[d1628e8e] | 2246 | } |
---|
| 2247 | pat += ch; |
---|
| 2248 | } |
---|
| 2249 | pattern = pat; |
---|
| 2250 | re_flags |= wxRE_BASIC; |
---|
| 2251 | } |
---|
[421b7d2] | 2252 | |
---|
[d1628e8e] | 2253 | if (!substring) { |
---|
| 2254 | // FIXME "0u" required to avoid compilation error with g++-3.0 |
---|
[5627cbb] | 2255 | if (pattern.empty() || pattern[0u] != '^') pattern = wxT('^') + pattern; |
---|
[d1628e8e] | 2256 | // FIXME: this fails to cope with "\$" at the end of pattern... |
---|
[5627cbb] | 2257 | if (pattern[pattern.size() - 1] != '$') pattern += wxT('$'); |
---|
[d1628e8e] | 2258 | } |
---|
[2a02de2] | 2259 | |
---|
[d1628e8e] | 2260 | wxRegEx regex; |
---|
| 2261 | if (!regex.Compile(pattern, re_flags)) { |
---|
| 2262 | wxBell(); |
---|
| 2263 | return; |
---|
| 2264 | } |
---|
[2a02de2] | 2265 | |
---|
[d1628e8e] | 2266 | int found = 0; |
---|
[1be3a88] | 2267 | |
---|
[d1628e8e] | 2268 | list<LabelInfo*>::iterator pos = m_Labels.begin(); |
---|
| 2269 | while (pos != m_Labels.end()) { |
---|
| 2270 | LabelInfo* label = *pos++; |
---|
| 2271 | |
---|
[5a24583] | 2272 | if (regex.Matches(label->GetText())) { |
---|
| 2273 | label->set_flags(LFLAG_HIGHLIGHTED); |
---|
[d1628e8e] | 2274 | ++found; |
---|
| 2275 | } else { |
---|
[5a24583] | 2276 | label->clear_flags(LFLAG_HIGHLIGHTED); |
---|
[d1628e8e] | 2277 | } |
---|
[1be3a88] | 2278 | } |
---|
| 2279 | |
---|
[d1628e8e] | 2280 | m_NumHighlighted = found; |
---|
| 2281 | |
---|
| 2282 | // Re-sort so highlighted points get names in preference |
---|
[373b738] | 2283 | if (found) m_Labels.sort(LabelPlotCmp(GetSeparator())); |
---|
[d1628e8e] | 2284 | } |
---|
[421b7d2] | 2285 | |
---|
[429465a] | 2286 | m_Gfx->UpdateBlobs(); |
---|
[fa42426] | 2287 | m_Gfx->ForceRefresh(); |
---|
[9d3d8cc] | 2288 | |
---|
[d1628e8e] | 2289 | if (!m_NumHighlighted) { |
---|
[857408e] | 2290 | GetToolBar()->SetToolShortHelp(button_HIDE, wmsg(/*No matches were found.*/328)); |
---|
[a2f4720] | 2291 | } else { |
---|
[736f7df] | 2292 | /* TRANSLATORS: "Hide stations" button tooltip when stations are found |
---|
| 2293 | */ |
---|
[857408e] | 2294 | GetToolBar()->SetToolShortHelp(button_HIDE, wxString::Format(wmsg(/*Hide %d found stations*/334).c_str(), m_NumHighlighted)); |
---|
[9d3d8cc] | 2295 | } |
---|
[2a02de2] | 2296 | } |
---|
| 2297 | |
---|
[d1628e8e] | 2298 | void MainFrm::OnGotoFound(wxCommandEvent&) |
---|
[2a02de2] | 2299 | { |
---|
[d1628e8e] | 2300 | if (!m_NumHighlighted) { |
---|
[5627cbb] | 2301 | wxGetApp().ReportError(wmsg(/*No matches were found.*/328)); |
---|
[d1628e8e] | 2302 | return; |
---|
| 2303 | } |
---|
| 2304 | |
---|
| 2305 | Double xmin = DBL_MAX; |
---|
| 2306 | Double xmax = -DBL_MAX; |
---|
| 2307 | Double ymin = DBL_MAX; |
---|
| 2308 | Double ymax = -DBL_MAX; |
---|
| 2309 | Double zmin = DBL_MAX; |
---|
| 2310 | Double zmax = -DBL_MAX; |
---|
| 2311 | |
---|
[fa42426] | 2312 | list<LabelInfo*>::iterator pos = m_Labels.begin(); |
---|
| 2313 | while (pos != m_Labels.end()) { |
---|
| 2314 | LabelInfo* label = *pos++; |
---|
[d1628e8e] | 2315 | |
---|
[5a24583] | 2316 | if (label->get_flags() & LFLAG_HIGHLIGHTED) { |
---|
| 2317 | if (label->GetX() < xmin) xmin = label->GetX(); |
---|
| 2318 | if (label->GetX() > xmax) xmax = label->GetX(); |
---|
| 2319 | if (label->GetY() < ymin) ymin = label->GetY(); |
---|
| 2320 | if (label->GetY() > ymax) ymax = label->GetY(); |
---|
| 2321 | if (label->GetZ() < zmin) zmin = label->GetZ(); |
---|
| 2322 | if (label->GetZ() > zmax) zmax = label->GetZ(); |
---|
[d1628e8e] | 2323 | } |
---|
[fa42426] | 2324 | } |
---|
[d1628e8e] | 2325 | |
---|
| 2326 | m_Gfx->SetViewTo(xmin, xmax, ymin, ymax, zmin, zmax); |
---|
| 2327 | m_Gfx->SetFocus(); |
---|
| 2328 | } |
---|
| 2329 | |
---|
| 2330 | void MainFrm::OnHide(wxCommandEvent&) |
---|
| 2331 | { |
---|
[5627cbb] | 2332 | m_FindBox->SetValue(wxString()); |
---|
[857408e] | 2333 | GetToolBar()->SetToolShortHelp(button_HIDE, wmsg(/*Hide*/333)); |
---|
[2a02de2] | 2334 | } |
---|
[39e460c9] | 2335 | |
---|
[429465a] | 2336 | void MainFrm::OnHideUpdate(wxUpdateUIEvent& ui) |
---|
| 2337 | { |
---|
| 2338 | ui.Enable(m_NumHighlighted != 0); |
---|
| 2339 | } |
---|
| 2340 | |
---|
[9059368] | 2341 | void MainFrm::OnViewSidePanel(wxCommandEvent&) |
---|
[b1de3e0] | 2342 | { |
---|
| 2343 | ToggleSidePanel(); |
---|
| 2344 | } |
---|
| 2345 | |
---|
| 2346 | void MainFrm::ToggleSidePanel() |
---|
[9059368] | 2347 | { |
---|
| 2348 | // Toggle display of the side panel. |
---|
| 2349 | |
---|
| 2350 | assert(m_Gfx); |
---|
| 2351 | |
---|
| 2352 | if (m_Splitter->IsSplit()) { |
---|
[421b7d2] | 2353 | m_SashPosition = m_Splitter->GetSashPosition(); // save width of panel |
---|
[1690fa9] | 2354 | m_Splitter->Unsplit(m_Notebook); |
---|
[b63cf6cc] | 2355 | } else { |
---|
[203d2a7] | 2356 | m_Notebook->Show(true); |
---|
[b1de3e0] | 2357 | m_Gfx->Show(true); |
---|
[203d2a7] | 2358 | m_Splitter->SplitVertically(m_Notebook, m_Gfx, m_SashPosition); |
---|
[9059368] | 2359 | } |
---|
| 2360 | } |
---|
| 2361 | |
---|
| 2362 | void MainFrm::OnViewSidePanelUpdate(wxUpdateUIEvent& ui) |
---|
| 2363 | { |
---|
[f48d6949] | 2364 | ui.Enable(!m_File.empty()); |
---|
[203d2a7] | 2365 | ui.Check(ShowingSidePanel()); |
---|
[9059368] | 2366 | } |
---|
[203d2a7] | 2367 | |
---|
| 2368 | bool MainFrm::ShowingSidePanel() |
---|
| 2369 | { |
---|
| 2370 | return m_Splitter->IsSplit(); |
---|
| 2371 | } |
---|
[fdfa926] | 2372 | |
---|
| 2373 | void MainFrm::ViewFullScreen() { |
---|
[e4b87e5] | 2374 | #ifdef __WXMAC__ |
---|
[559cd60] | 2375 | // On macOS, wxWidgets doesn't currently hide the toolbar or statusbar in |
---|
[e4b87e5] | 2376 | // full screen mode (last checked with 3.0.2), but it is easy to do |
---|
| 2377 | // ourselves. |
---|
| 2378 | if (!IsFullScreen()) { |
---|
| 2379 | GetToolBar()->Hide(); |
---|
| 2380 | GetStatusBar()->Hide(); |
---|
| 2381 | } |
---|
| 2382 | #endif |
---|
| 2383 | |
---|
[fdfa926] | 2384 | ShowFullScreen(!IsFullScreen()); |
---|
[b75a37d] | 2385 | fullscreen_showing_menus = false; |
---|
[486c619] | 2386 | if (IsFullScreen()) |
---|
| 2387 | was_showing_sidepanel_before_fullscreen = ShowingSidePanel(); |
---|
| 2388 | if (was_showing_sidepanel_before_fullscreen) |
---|
| 2389 | ToggleSidePanel(); |
---|
[e4b87e5] | 2390 | |
---|
| 2391 | #ifdef __WXMAC__ |
---|
| 2392 | if (!IsFullScreen()) { |
---|
| 2393 | GetStatusBar()->Show(); |
---|
| 2394 | GetToolBar()->Show(); |
---|
[3465803] | 2395 | #ifdef USING_GENERIC_TOOLBAR |
---|
| 2396 | Layout(); |
---|
| 2397 | #endif |
---|
[e4b87e5] | 2398 | } |
---|
| 2399 | #endif |
---|
[fdfa926] | 2400 | } |
---|
[b75a37d] | 2401 | |
---|
| 2402 | bool MainFrm::FullScreenModeShowingMenus() const |
---|
| 2403 | { |
---|
| 2404 | return fullscreen_showing_menus; |
---|
| 2405 | } |
---|
| 2406 | |
---|
| 2407 | void MainFrm::FullScreenModeShowMenus(bool show) |
---|
| 2408 | { |
---|
| 2409 | if (!IsFullScreen() || show == fullscreen_showing_menus) |
---|
| 2410 | return; |
---|
[7413829] | 2411 | #ifdef __WXMAC__ |
---|
[559cd60] | 2412 | // On macOS, enabling the menu bar while in full |
---|
[7413829] | 2413 | // screen mode doesn't have any effect, so instead |
---|
| 2414 | // make moving the mouse to the top of the screen |
---|
| 2415 | // drop us out of full screen mode for now. |
---|
| 2416 | ViewFullScreen(); |
---|
| 2417 | #else |
---|
[3c65a9f] | 2418 | GetMenuBar()->Show(show); |
---|
[b75a37d] | 2419 | fullscreen_showing_menus = show; |
---|
[7413829] | 2420 | #endif |
---|
[b75a37d] | 2421 | } |
---|