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