[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 |
---|
[e583283] | 7 | // Copyright (C) 2001-2003,2004,2005,2006,2010,2011,2012,2013,2014,2015 Olly Betts |
---|
[887c26e] | 8 | // Copyright (C) 2005 Martin Green |
---|
[5809313] | 9 | // |
---|
| 10 | // This program is free software; you can redistribute it and/or modify |
---|
| 11 | // it under the terms of the GNU General Public License as published by |
---|
| 12 | // the Free Software Foundation; either version 2 of the License, or |
---|
| 13 | // (at your option) any later version. |
---|
| 14 | // |
---|
| 15 | // This program is distributed in the hope that it will be useful, |
---|
| 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 18 | // GNU General Public License for more details. |
---|
| 19 | // |
---|
| 20 | // You should have received a copy of the GNU General Public License |
---|
| 21 | // along with this program; if not, write to the Free Software |
---|
[5940815] | 22 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
[5809313] | 23 | // |
---|
| 24 | |
---|
[cbfa50d] | 25 | #ifdef HAVE_CONFIG_H |
---|
| 26 | #include <config.h> |
---|
| 27 | #endif |
---|
| 28 | |
---|
[6bec10c] | 29 | #include "cavernlog.h" |
---|
[5809313] | 30 | #include "mainfrm.h" |
---|
| 31 | #include "aven.h" |
---|
[6e65d9e] | 32 | #include "aboutdlg.h" |
---|
[706b033] | 33 | |
---|
[93c3f97] | 34 | #include "message.h" |
---|
[a405bc1] | 35 | #include "img_hosted.h" |
---|
[41adebb] | 36 | #include "namecompare.h" |
---|
[ce403f1] | 37 | #include "printwx.h" |
---|
[045e2af] | 38 | #include "filename.h" |
---|
[e577f89] | 39 | #include "useful.h" |
---|
[706b033] | 40 | |
---|
[2d9ed8ad] | 41 | #include <wx/confbase.h> |
---|
[f302cbaa] | 42 | #include <wx/filename.h> |
---|
[ee41e88] | 43 | #include <wx/image.h> |
---|
[0580c6a] | 44 | #include <wx/imaglist.h> |
---|
[b88b171] | 45 | #include <wx/process.h> |
---|
[0580c6a] | 46 | #include <wx/regex.h> |
---|
[203d2a7] | 47 | |
---|
[42bd3576] | 48 | #include <cstdlib> |
---|
[5809313] | 49 | #include <float.h> |
---|
[63dc4eb] | 50 | #include <functional> |
---|
[576e5a9] | 51 | #include <map> |
---|
[156dc16] | 52 | #include <stack> |
---|
[7a2e1ed] | 53 | #include <vector> |
---|
[0c76ad9] | 54 | |
---|
[b4f28e0] | 55 | #ifdef __WXMSW__ |
---|
| 56 | #define TOOL(x) wxBitmap(wxT(#x), wxBITMAP_TYPE_PNG_RESOURCE) |
---|
| 57 | #else |
---|
[63c2fe8] | 58 | // XPM files declare the array as static, but we also want it to be const too. |
---|
| 59 | // This avoids a compiler warning, and also means the data can go in a |
---|
| 60 | // read-only page and be shared between processes. |
---|
| 61 | #define static static const |
---|
[ea1ea51] | 62 | #include "../lib/icons/aven.xpm" |
---|
[d7b53e3] | 63 | #include "../lib/icons/log.xpm" |
---|
[63c2fe8] | 64 | #include "../lib/icons/open.xpm" |
---|
| 65 | #include "../lib/icons/open_pres.xpm" |
---|
| 66 | #include "../lib/icons/rotation.xpm" |
---|
| 67 | #include "../lib/icons/plan.xpm" |
---|
| 68 | #include "../lib/icons/elevation.xpm" |
---|
| 69 | #include "../lib/icons/defaults.xpm" |
---|
| 70 | #include "../lib/icons/names.xpm" |
---|
| 71 | #include "../lib/icons/crosses.xpm" |
---|
| 72 | #include "../lib/icons/entrances.xpm" |
---|
| 73 | #include "../lib/icons/fixed_pts.xpm" |
---|
| 74 | #include "../lib/icons/exported_pts.xpm" |
---|
| 75 | #include "../lib/icons/ug_legs.xpm" |
---|
| 76 | #include "../lib/icons/surface_legs.xpm" |
---|
| 77 | #include "../lib/icons/tubes.xpm" |
---|
| 78 | #include "../lib/icons/pres_frew.xpm" |
---|
| 79 | #include "../lib/icons/pres_rew.xpm" |
---|
| 80 | #include "../lib/icons/pres_go_back.xpm" |
---|
| 81 | #include "../lib/icons/pres_pause.xpm" |
---|
| 82 | #include "../lib/icons/pres_go.xpm" |
---|
| 83 | #include "../lib/icons/pres_ff.xpm" |
---|
| 84 | #include "../lib/icons/pres_fff.xpm" |
---|
| 85 | #include "../lib/icons/pres_stop.xpm" |
---|
| 86 | #include "../lib/icons/find.xpm" |
---|
| 87 | #include "../lib/icons/hideresults.xpm" |
---|
| 88 | #include "../lib/icons/survey_tree.xpm" |
---|
| 89 | #include "../lib/icons/pres_tree.xpm" |
---|
| 90 | #undef static |
---|
[b4f28e0] | 91 | #define TOOL(x) wxBITMAP(x) |
---|
[63c2fe8] | 92 | #endif |
---|
| 93 | |
---|
[0580c6a] | 94 | using namespace std; |
---|
[5809313] | 95 | |
---|
[dcbcae0] | 96 | const static int img2aven_tab[] = { |
---|
| 97 | #include "img2aven.h" |
---|
| 98 | }; |
---|
| 99 | |
---|
| 100 | inline int |
---|
| 101 | img2aven(int flags) |
---|
| 102 | { |
---|
[9140f41] | 103 | flags &= (sizeof(img2aven_tab) / sizeof(img2aven_tab[0]) - 1); |
---|
[dcbcae0] | 104 | return img2aven_tab[flags]; |
---|
| 105 | } |
---|
| 106 | |
---|
[b1de3e0] | 107 | class AvenSplitterWindow : public wxSplitterWindow { |
---|
| 108 | MainFrm *parent; |
---|
| 109 | |
---|
| 110 | public: |
---|
| 111 | AvenSplitterWindow(MainFrm *parent_) |
---|
[b4fe9fb] | 112 | : wxSplitterWindow(parent_, -1, wxDefaultPosition, wxDefaultSize, |
---|
[5ed907b0] | 113 | wxSP_3DSASH), |
---|
[b4fe9fb] | 114 | parent(parent_) |
---|
| 115 | { |
---|
[b1de3e0] | 116 | } |
---|
| 117 | |
---|
[41f7a27] | 118 | void OnSplitterDClick(wxSplitterEvent &) { |
---|
[b1de3e0] | 119 | parent->ToggleSidePanel(); |
---|
| 120 | } |
---|
[f433fda] | 121 | |
---|
[b1de3e0] | 122 | private: |
---|
| 123 | DECLARE_EVENT_TABLE() |
---|
| 124 | }; |
---|
| 125 | |
---|
| 126 | BEGIN_EVENT_TABLE(AvenSplitterWindow, wxSplitterWindow) |
---|
| 127 | EVT_SPLITTER_DCLICK(-1, AvenSplitterWindow::OnSplitterDClick) |
---|
| 128 | END_EVENT_TABLE() |
---|
| 129 | |
---|
[9521a42] | 130 | class EditMarkDlg : public wxDialog { |
---|
| 131 | wxTextCtrl * easting, * northing, * altitude; |
---|
[49ce5b0] | 132 | wxTextCtrl * angle, * tilt_angle, * scale, * time; |
---|
[9521a42] | 133 | public: |
---|
[736f7df] | 134 | // TRANSLATORS: Title of dialog to edit a waypoint in a presentation. |
---|
[9521a42] | 135 | EditMarkDlg(wxWindow* parent, const PresentationMark & p) |
---|
[fbc1d32] | 136 | : wxDialog(parent, 500, wmsg(/*Edit Waypoint*/404)) |
---|
[9521a42] | 137 | { |
---|
[5627cbb] | 138 | easting = new wxTextCtrl(this, 601, wxString::Format(wxT("%.3f"), p.GetX())); |
---|
| 139 | northing = new wxTextCtrl(this, 602, wxString::Format(wxT("%.3f"), p.GetY())); |
---|
| 140 | altitude = new wxTextCtrl(this, 603, wxString::Format(wxT("%.3f"), p.GetZ())); |
---|
| 141 | angle = new wxTextCtrl(this, 604, wxString::Format(wxT("%.3f"), p.angle)); |
---|
| 142 | tilt_angle = new wxTextCtrl(this, 605, wxString::Format(wxT("%.3f"), p.tilt_angle)); |
---|
| 143 | scale = new wxTextCtrl(this, 606, wxString::Format(wxT("%.3f"), p.scale)); |
---|
[49ce5b0] | 144 | if (p.time > 0.0) { |
---|
[5627cbb] | 145 | time = new wxTextCtrl(this, 607, wxString::Format(wxT("%.3f"), p.time)); |
---|
[49ce5b0] | 146 | } else if (p.time < 0.0) { |
---|
[5627cbb] | 147 | time = new wxTextCtrl(this, 607, wxString::Format(wxT("*%.3f"), -p.time)); |
---|
[49ce5b0] | 148 | } else { |
---|
[5627cbb] | 149 | time = new wxTextCtrl(this, 607, wxT("0")); |
---|
[49ce5b0] | 150 | } |
---|
| 151 | |
---|
[9521a42] | 152 | wxBoxSizer * coords = new wxBoxSizer(wxHORIZONTAL); |
---|
[5627cbb] | 153 | coords->Add(new wxStaticText(this, 610, wxT("(")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 154 | coords->Add(easting, 1); |
---|
[5627cbb] | 155 | coords->Add(new wxStaticText(this, 611, wxT(",")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 156 | coords->Add(northing, 1); |
---|
[5627cbb] | 157 | coords->Add(new wxStaticText(this, 612, wxT(",")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 158 | coords->Add(altitude, 1); |
---|
[5627cbb] | 159 | coords->Add(new wxStaticText(this, 613, wxT(")")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 160 | wxBoxSizer* vert = new wxBoxSizer(wxVERTICAL); |
---|
| 161 | vert->Add(coords, 0, wxALL, 8); |
---|
| 162 | wxBoxSizer * r2 = new wxBoxSizer(wxHORIZONTAL); |
---|
[fbc1d32] | 163 | r2->Add(new wxStaticText(this, 614, wmsg(/*Bearing*/259) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 164 | r2->Add(angle); |
---|
| 165 | vert->Add(r2, 0, wxALL, 8); |
---|
| 166 | wxBoxSizer * r3 = new wxBoxSizer(wxHORIZONTAL); |
---|
[fbc1d32] | 167 | r3->Add(new wxStaticText(this, 615, wmsg(/*Elevation*/118) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 168 | r3->Add(tilt_angle); |
---|
| 169 | vert->Add(r3, 0, wxALL, 8); |
---|
| 170 | wxBoxSizer * r4 = new wxBoxSizer(wxHORIZONTAL); |
---|
[fbc1d32] | 171 | r4->Add(new wxStaticText(this, 616, wmsg(/*Scale*/154) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[9521a42] | 172 | r4->Add(scale); |
---|
[736f7df] | 173 | /* TRANSLATORS: Note after "Scale" field in dialog to edit a waypoint |
---|
| 174 | * in a presentation. */ |
---|
[857408e] | 175 | r4->Add(new wxStaticText(this, 617, wmsg(/* (unused in perspective view)*/278)), |
---|
[9521a42] | 176 | 0, wxALIGN_CENTRE_VERTICAL); |
---|
| 177 | vert->Add(r4, 0, wxALL, 8); |
---|
| 178 | |
---|
| 179 | wxBoxSizer * r5 = new wxBoxSizer(wxHORIZONTAL); |
---|
[736f7df] | 180 | /* TRANSLATORS: Field label in dialog to edit a waypoint in a |
---|
| 181 | * presentation. */ |
---|
[857408e] | 182 | r5->Add(new wxStaticText(this, 616, wmsg(/*Time: */279)), 0, wxALIGN_CENTRE_VERTICAL); |
---|
[49ce5b0] | 183 | r5->Add(time); |
---|
[736f7df] | 184 | /* TRANSLATORS: units+info after time field in dialog to edit a |
---|
| 185 | * waypoint in a presentation. */ |
---|
[857408e] | 186 | r5->Add(new wxStaticText(this, 617, wmsg(/* secs (0 = auto; *6 = 6 times auto)*/282)), |
---|
[49ce5b0] | 187 | 0, wxALIGN_CENTRE_VERTICAL); |
---|
| 188 | vert->Add(r5, 0, wxALL, 8); |
---|
| 189 | |
---|
| 190 | wxBoxSizer * buttons = new wxBoxSizer(wxHORIZONTAL); |
---|
[73b3388] | 191 | wxButton* cancel = new wxButton(this, wxID_CANCEL); |
---|
[49ce5b0] | 192 | buttons->Add(cancel, 0, wxALL, 8); |
---|
[73b3388] | 193 | wxButton* ok = new wxButton(this, wxID_OK); |
---|
[9521a42] | 194 | ok->SetDefault(); |
---|
[49ce5b0] | 195 | buttons->Add(ok, 0, wxALL, 8); |
---|
| 196 | vert->Add(buttons, 0, wxALL|wxALIGN_RIGHT); |
---|
[9521a42] | 197 | |
---|
| 198 | SetAutoLayout(true); |
---|
| 199 | SetSizer(vert); |
---|
| 200 | |
---|
| 201 | vert->SetSizeHints(this); |
---|
[128fac4] | 202 | } |
---|
[9521a42] | 203 | PresentationMark GetMark() const { |
---|
[d67450e] | 204 | double a, t, s, T; |
---|
[318ac31] | 205 | Vector3 v(atof(easting->GetValue().mb_str()), |
---|
| 206 | atof(northing->GetValue().mb_str()), |
---|
| 207 | atof(altitude->GetValue().mb_str())); |
---|
| 208 | a = atof(angle->GetValue().mb_str()); |
---|
| 209 | t = atof(tilt_angle->GetValue().mb_str()); |
---|
| 210 | s = atof(scale->GetValue().mb_str()); |
---|
[49ce5b0] | 211 | wxString str = time->GetValue(); |
---|
[e60254e] | 212 | if (!str.empty() && str[0u] == '*') str[0u] = '-'; |
---|
[318ac31] | 213 | T = atof(str.mb_str()); |
---|
[d67450e] | 214 | return PresentationMark(v, a, t, s, T); |
---|
[9521a42] | 215 | } |
---|
| 216 | |
---|
| 217 | private: |
---|
| 218 | DECLARE_EVENT_TABLE() |
---|
| 219 | }; |
---|
| 220 | |
---|
[3fdeb44d] | 221 | // Write a value without trailing zeros after the decimal point. |
---|
| 222 | static void write_double(double d, FILE * fh) { |
---|
| 223 | char buf[64]; |
---|
| 224 | sprintf(buf, "%.21f", d); |
---|
[c988ae4] | 225 | char * p = strchr(buf, ','); |
---|
| 226 | if (p) *p = '.'; |
---|
[3fdeb44d] | 227 | size_t l = strlen(buf); |
---|
| 228 | while (l > 1 && buf[l - 1] == '0') --l; |
---|
| 229 | if (l > 1 && buf[l - 1] == '.') --l; |
---|
| 230 | fwrite(buf, l, 1, fh); |
---|
| 231 | } |
---|
| 232 | |
---|
[1c6b20d7] | 233 | class AvenPresList : public wxListCtrl { |
---|
| 234 | MainFrm * mainfrm; |
---|
[1690fa9] | 235 | GfxCore * gfx; |
---|
[9521a42] | 236 | vector<PresentationMark> entries; |
---|
[1690fa9] | 237 | long current_item; |
---|
| 238 | bool modified; |
---|
[bd7607c] | 239 | bool force_save_as; |
---|
[1690fa9] | 240 | wxString filename; |
---|
[f433fda] | 241 | |
---|
[1690fa9] | 242 | public: |
---|
[1c6b20d7] | 243 | AvenPresList(MainFrm * mainfrm_, wxWindow * parent, GfxCore * gfx_) |
---|
[1690fa9] | 244 | : wxListCtrl(parent, listctrl_PRES, wxDefaultPosition, wxDefaultSize, |
---|
[9521a42] | 245 | wxLC_REPORT|wxLC_VIRTUAL), |
---|
[bd7607c] | 246 | mainfrm(mainfrm_), gfx(gfx_), current_item(-1), modified(false), |
---|
| 247 | force_save_as(true) |
---|
[1690fa9] | 248 | { |
---|
[5627cbb] | 249 | InsertColumn(0, wmsg(/*Easting*/378)); |
---|
| 250 | InsertColumn(1, wmsg(/*Northing*/379)); |
---|
| 251 | InsertColumn(2, wmsg(/*Altitude*/335)); |
---|
[1690fa9] | 252 | } |
---|
| 253 | |
---|
| 254 | void OnBeginLabelEdit(wxListEvent& event) { |
---|
| 255 | event.Veto(); // No editting allowed |
---|
| 256 | } |
---|
| 257 | void OnDeleteItem(wxListEvent& event) { |
---|
| 258 | long item = event.GetIndex(); |
---|
| 259 | if (current_item == item) { |
---|
| 260 | current_item = -1; |
---|
| 261 | } else if (current_item > item) { |
---|
| 262 | --current_item; |
---|
| 263 | } |
---|
[9521a42] | 264 | entries.erase(entries.begin() + item); |
---|
| 265 | SetItemCount(entries.size()); |
---|
[1690fa9] | 266 | modified = true; |
---|
| 267 | } |
---|
[41f7a27] | 268 | void OnDeleteAllItems(wxListEvent&) { |
---|
[1690fa9] | 269 | entries.clear(); |
---|
[9521a42] | 270 | SetItemCount(entries.size()); |
---|
[5627cbb] | 271 | filename = wxString(); |
---|
[1690fa9] | 272 | modified = false; |
---|
[bd7607c] | 273 | force_save_as = true; |
---|
[1690fa9] | 274 | } |
---|
| 275 | void OnListKeyDown(wxListEvent& event) { |
---|
| 276 | switch (event.GetKeyCode()) { |
---|
| 277 | case WXK_DELETE: { |
---|
| 278 | long item = GetNextItem(-1, wxLIST_NEXT_ALL, |
---|
| 279 | wxLIST_STATE_SELECTED); |
---|
| 280 | while (item != -1) { |
---|
| 281 | DeleteItem(item); |
---|
| 282 | // - 1 because the indices were shifted by DeleteItem() |
---|
| 283 | item = GetNextItem(item - 1, wxLIST_NEXT_ALL, |
---|
| 284 | wxLIST_STATE_SELECTED); |
---|
| 285 | } |
---|
| 286 | break; |
---|
| 287 | } |
---|
| 288 | default: |
---|
[c8f929b] | 289 | //printf("event.GetIndex() = %ld %d\n", event.GetIndex(), event.GetKeyCode()); |
---|
[1690fa9] | 290 | event.Skip(); |
---|
| 291 | } |
---|
| 292 | } |
---|
| 293 | void OnActivated(wxListEvent& event) { |
---|
| 294 | // Jump to this view. |
---|
| 295 | long item = event.GetIndex(); |
---|
[9521a42] | 296 | gfx->SetView(entries[item]); |
---|
[1690fa9] | 297 | } |
---|
| 298 | void OnFocused(wxListEvent& event) { |
---|
| 299 | current_item = event.GetIndex(); |
---|
| 300 | } |
---|
[9521a42] | 301 | void OnRightClick(wxListEvent& event) { |
---|
| 302 | long item = event.GetIndex(); |
---|
[f7d52a1] | 303 | if (item < 0) { |
---|
| 304 | AddMark(item, gfx->GetView()); |
---|
| 305 | item = 0; |
---|
| 306 | } |
---|
[9521a42] | 307 | EditMarkDlg edit(mainfrm, entries[item]); |
---|
| 308 | if (edit.ShowModal() == wxID_OK) { |
---|
| 309 | entries[item] = edit.GetMark(); |
---|
| 310 | } |
---|
| 311 | } |
---|
[1690fa9] | 312 | void OnChar(wxKeyEvent& event) { |
---|
[c8f929b] | 313 | switch (event.GetKeyCode()) { |
---|
| 314 | case WXK_INSERT: |
---|
[a6e8d45] | 315 | if (event.GetModifiers() == wxMOD_CONTROL) { |
---|
[c8f929b] | 316 | if (current_item != -1 && |
---|
| 317 | size_t(current_item) < entries.size()) { |
---|
| 318 | AddMark(current_item, entries[current_item]); |
---|
| 319 | } |
---|
| 320 | } else { |
---|
| 321 | AddMark(current_item); |
---|
| 322 | } |
---|
| 323 | break; |
---|
| 324 | case WXK_DELETE: |
---|
| 325 | // Already handled in OnListKeyDown. |
---|
| 326 | break; |
---|
| 327 | case WXK_UP: case WXK_DOWN: |
---|
| 328 | event.Skip(); |
---|
| 329 | break; |
---|
| 330 | default: |
---|
| 331 | gfx->OnKeyPress(event); |
---|
[5e31bd2] | 332 | } |
---|
[1690fa9] | 333 | } |
---|
| 334 | void AddMark(long item = -1) { |
---|
| 335 | AddMark(item, gfx->GetView()); |
---|
| 336 | } |
---|
| 337 | void AddMark(long item, const PresentationMark & mark) { |
---|
[9521a42] | 338 | if (item == -1) item = entries.size(); |
---|
| 339 | entries.insert(entries.begin() + item, mark); |
---|
| 340 | SetItemCount(entries.size()); |
---|
[1690fa9] | 341 | modified = true; |
---|
| 342 | } |
---|
[9521a42] | 343 | virtual wxString OnGetItemText(long item, long column) const { |
---|
[5627cbb] | 344 | if (item < 0 || item >= (long)entries.size()) return wxString(); |
---|
[9521a42] | 345 | const PresentationMark & p = entries[item]; |
---|
| 346 | double v; |
---|
| 347 | switch (column) { |
---|
[d67450e] | 348 | case 0: v = p.GetX(); break; |
---|
| 349 | case 1: v = p.GetY(); break; |
---|
| 350 | case 2: v = p.GetZ(); break; |
---|
[9521a42] | 351 | #if 0 |
---|
| 352 | case 3: v = p.angle; break; |
---|
| 353 | case 4: v = p.tilt_angle; break; |
---|
| 354 | case 5: v = p.scale; break; |
---|
[49ce5b0] | 355 | case 6: v = p.time; break; |
---|
[9521a42] | 356 | #endif |
---|
[5627cbb] | 357 | default: return wxString(); |
---|
[9521a42] | 358 | } |
---|
[5627cbb] | 359 | return wxString::Format(wxT("%ld"), (long)v); |
---|
[9521a42] | 360 | } |
---|
[1690fa9] | 361 | void Save(bool use_default_name) { |
---|
| 362 | wxString fnm = filename; |
---|
[bd7607c] | 363 | if (!use_default_name || force_save_as) { |
---|
[1c6b20d7] | 364 | AvenAllowOnTop ontop(mainfrm); |
---|
[1690fa9] | 365 | #ifdef __WXMOTIF__ |
---|
[5627cbb] | 366 | wxString ext(wxT("*.fly")); |
---|
[1690fa9] | 367 | #else |
---|
[5627cbb] | 368 | wxString ext = wmsg(/*Aven presentations*/320); |
---|
[52f67931] | 369 | ext += wxT("|*.fly"); |
---|
[1690fa9] | 370 | #endif |
---|
[5627cbb] | 371 | wxFileDialog dlg(this, wmsg(/*Select an output filename*/319), |
---|
| 372 | wxString(), fnm, ext, |
---|
| 373 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
---|
[1690fa9] | 374 | if (dlg.ShowModal() != wxID_OK) return; |
---|
| 375 | fnm = dlg.GetPath(); |
---|
| 376 | } |
---|
| 377 | |
---|
[36c4cf1] | 378 | #ifdef __WXMSW__ |
---|
| 379 | FILE * fh_pres = _wfopen(fnm.fn_str(), L"w"); |
---|
| 380 | #else |
---|
[318ac31] | 381 | FILE * fh_pres = fopen(fnm.mb_str(), "w"); |
---|
[36c4cf1] | 382 | #endif |
---|
[1690fa9] | 383 | if (!fh_pres) { |
---|
[0804fbe] | 384 | wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), fnm.c_str())); |
---|
[1690fa9] | 385 | return; |
---|
| 386 | } |
---|
[9521a42] | 387 | vector<PresentationMark>::const_iterator i; |
---|
[1690fa9] | 388 | for (i = entries.begin(); i != entries.end(); ++i) { |
---|
| 389 | const PresentationMark &p = *i; |
---|
[d67450e] | 390 | write_double(p.GetX(), fh_pres); |
---|
[e02a6a6] | 391 | PUTC(' ', fh_pres); |
---|
[d67450e] | 392 | write_double(p.GetY(), fh_pres); |
---|
[e02a6a6] | 393 | PUTC(' ', fh_pres); |
---|
[d67450e] | 394 | write_double(p.GetZ(), fh_pres); |
---|
[e02a6a6] | 395 | PUTC(' ', fh_pres); |
---|
[3fdeb44d] | 396 | write_double(p.angle, fh_pres); |
---|
[e02a6a6] | 397 | PUTC(' ', fh_pres); |
---|
[3fdeb44d] | 398 | write_double(p.tilt_angle, fh_pres); |
---|
[e02a6a6] | 399 | PUTC(' ', fh_pres); |
---|
[3fdeb44d] | 400 | write_double(p.scale, fh_pres); |
---|
[49ce5b0] | 401 | if (p.time != 0.0) { |
---|
[e02a6a6] | 402 | PUTC(' ', fh_pres); |
---|
[49ce5b0] | 403 | write_double(p.time, fh_pres); |
---|
| 404 | } |
---|
[e02a6a6] | 405 | PUTC('\n', fh_pres); |
---|
[1690fa9] | 406 | } |
---|
| 407 | fclose(fh_pres); |
---|
| 408 | filename = fnm; |
---|
| 409 | modified = false; |
---|
[bd7607c] | 410 | force_save_as = false; |
---|
| 411 | } |
---|
| 412 | void New(const wxString &fnm) { |
---|
| 413 | DeleteAllItems(); |
---|
[d3172cc] | 414 | wxFileName::SplitPath(fnm, NULL, NULL, &filename, NULL, wxPATH_NATIVE); |
---|
[5627cbb] | 415 | filename += wxT(".fly"); |
---|
[bd7607c] | 416 | force_save_as = true; |
---|
[1690fa9] | 417 | } |
---|
| 418 | bool Load(const wxString &fnm) { |
---|
[36c4cf1] | 419 | #ifdef __WXMSW__ |
---|
| 420 | FILE * fh_pres = _wfopen(fnm.fn_str(), L"r"); |
---|
| 421 | #else |
---|
[318ac31] | 422 | FILE * fh_pres = fopen(fnm.mb_str(), "r"); |
---|
[36c4cf1] | 423 | #endif |
---|
[9b540e6] | 424 | if (!fh_pres) { |
---|
| 425 | wxString m; |
---|
[ffee37e] | 426 | m.Printf(wmsg(/*Couldn’t open file “%s”*/24), fnm.c_str()); |
---|
[9b540e6] | 427 | wxGetApp().ReportError(m); |
---|
| 428 | return false; |
---|
| 429 | } |
---|
[1690fa9] | 430 | DeleteAllItems(); |
---|
| 431 | long item = 0; |
---|
| 432 | while (!feof(fh_pres)) { |
---|
| 433 | char buf[4096]; |
---|
| 434 | size_t i = 0; |
---|
| 435 | while (i < sizeof(buf) - 1) { |
---|
[e02a6a6] | 436 | int ch = GETC(fh_pres); |
---|
[1690fa9] | 437 | if (ch == EOF || ch == '\n' || ch == '\r') break; |
---|
| 438 | buf[i++] = ch; |
---|
| 439 | } |
---|
| 440 | if (i) { |
---|
| 441 | buf[i] = 0; |
---|
[49ce5b0] | 442 | double x, y, z, a, t, s, T; |
---|
| 443 | int c = sscanf(buf, "%lf %lf %lf %lf %lf %lf %lf", &x, &y, &z, &a, &t, &s, &T); |
---|
| 444 | if (c < 6) { |
---|
[c988ae4] | 445 | char *p = buf; |
---|
| 446 | while ((p = strchr(p, '.'))) *p++ = ','; |
---|
| 447 | c = sscanf(buf, "%lf %lf %lf %lf %lf %lf %lf", &x, &y, &z, &a, &t, &s, &T); |
---|
| 448 | if (c < 6) { |
---|
| 449 | DeleteAllItems(); |
---|
[0804fbe] | 450 | wxGetApp().ReportError(wxString::Format(wmsg(/*Error in format of presentation file “%s”*/323), fnm.c_str())); |
---|
[c988ae4] | 451 | return false; |
---|
| 452 | } |
---|
[1690fa9] | 453 | } |
---|
[49ce5b0] | 454 | if (c == 6) T = 0; |
---|
[d67450e] | 455 | AddMark(item, PresentationMark(Vector3(x, y, z), a, t, s, T)); |
---|
[9b540e6] | 456 | ++item; |
---|
[1690fa9] | 457 | } |
---|
| 458 | } |
---|
| 459 | fclose(fh_pres); |
---|
| 460 | filename = fnm; |
---|
| 461 | modified = false; |
---|
[bd7607c] | 462 | force_save_as = false; |
---|
[1690fa9] | 463 | return true; |
---|
| 464 | } |
---|
| 465 | bool Modified() const { return modified; } |
---|
| 466 | bool Empty() const { return entries.empty(); } |
---|
| 467 | PresentationMark GetPresMark(int which) { |
---|
| 468 | long item = current_item; |
---|
| 469 | if (which == MARK_FIRST) { |
---|
| 470 | item = 0; |
---|
| 471 | } else if (which == MARK_NEXT) { |
---|
[9521a42] | 472 | ++item; |
---|
[128fac4] | 473 | } else if (which == MARK_PREV) { |
---|
| 474 | --item; |
---|
[1690fa9] | 475 | } |
---|
[128fac4] | 476 | if (item == -1 || item == (long)entries.size()) |
---|
| 477 | return PresentationMark(); |
---|
[1690fa9] | 478 | if (item != current_item) { |
---|
| 479 | // Move the focus |
---|
| 480 | if (current_item != -1) { |
---|
| 481 | wxListCtrl::SetItemState(current_item, wxLIST_STATE_FOCUSED, |
---|
| 482 | 0); |
---|
| 483 | } |
---|
| 484 | wxListCtrl::SetItemState(item, wxLIST_STATE_FOCUSED, |
---|
| 485 | wxLIST_STATE_FOCUSED); |
---|
| 486 | } |
---|
[9521a42] | 487 | return entries[item]; |
---|
[1690fa9] | 488 | } |
---|
| 489 | |
---|
| 490 | private: |
---|
| 491 | |
---|
[1c6b20d7] | 492 | DECLARE_NO_COPY_CLASS(AvenPresList) |
---|
[1690fa9] | 493 | DECLARE_EVENT_TABLE() |
---|
| 494 | }; |
---|
[f433fda] | 495 | |
---|
[9521a42] | 496 | BEGIN_EVENT_TABLE(EditMarkDlg, wxDialog) |
---|
| 497 | END_EVENT_TABLE() |
---|
| 498 | |
---|
[1c6b20d7] | 499 | BEGIN_EVENT_TABLE(AvenPresList, wxListCtrl) |
---|
| 500 | EVT_LIST_BEGIN_LABEL_EDIT(listctrl_PRES, AvenPresList::OnBeginLabelEdit) |
---|
| 501 | EVT_LIST_DELETE_ITEM(listctrl_PRES, AvenPresList::OnDeleteItem) |
---|
| 502 | EVT_LIST_DELETE_ALL_ITEMS(listctrl_PRES, AvenPresList::OnDeleteAllItems) |
---|
| 503 | EVT_LIST_KEY_DOWN(listctrl_PRES, AvenPresList::OnListKeyDown) |
---|
| 504 | EVT_LIST_ITEM_ACTIVATED(listctrl_PRES, AvenPresList::OnActivated) |
---|
| 505 | EVT_LIST_ITEM_FOCUSED(listctrl_PRES, AvenPresList::OnFocused) |
---|
[9521a42] | 506 | EVT_LIST_ITEM_RIGHT_CLICK(listctrl_PRES, AvenPresList::OnRightClick) |
---|
[1c6b20d7] | 507 | EVT_CHAR(AvenPresList::OnChar) |
---|
[1690fa9] | 508 | END_EVENT_TABLE() |
---|
| 509 | |
---|
[137bf99] | 510 | BEGIN_EVENT_TABLE(MainFrm, wxFrame) |
---|
[d1628e8e] | 511 | EVT_TEXT(textctrl_FIND, MainFrm::OnFind) |
---|
| 512 | EVT_TEXT_ENTER(textctrl_FIND, MainFrm::OnGotoFound) |
---|
[42c7efe] | 513 | EVT_MENU(wxID_FIND, MainFrm::OnGotoFound) |
---|
[8e1a10e] | 514 | EVT_MENU(button_HIDE, MainFrm::OnHide) |
---|
[429465a] | 515 | EVT_UPDATE_UI(button_HIDE, MainFrm::OnHideUpdate) |
---|
[bc60689] | 516 | EVT_IDLE(MainFrm::OnIdle) |
---|
[2a02de2] | 517 | |
---|
[42c7efe] | 518 | EVT_MENU(wxID_OPEN, MainFrm::OnOpen) |
---|
[d7b53e3] | 519 | EVT_MENU(menu_FILE_LOG, MainFrm::OnShowLog) |
---|
[42c7efe] | 520 | EVT_MENU(wxID_PRINT, MainFrm::OnPrint) |
---|
[ce403f1] | 521 | EVT_MENU(menu_FILE_PAGE_SETUP, MainFrm::OnPageSetup) |
---|
[045e2af] | 522 | EVT_MENU(menu_FILE_SCREENSHOT, MainFrm::OnScreenshot) |
---|
[42c7efe] | 523 | // EVT_MENU(wxID_PREFERENCES, MainFrm::OnFilePreferences) |
---|
[223f1ad] | 524 | EVT_MENU(menu_FILE_EXPORT, MainFrm::OnExport) |
---|
[42c7efe] | 525 | EVT_MENU(wxID_EXIT, MainFrm::OnQuit) |
---|
[732b9b0] | 526 | EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, MainFrm::OnMRUFile) |
---|
[137bf99] | 527 | |
---|
[1690fa9] | 528 | EVT_MENU(menu_PRES_NEW, MainFrm::OnPresNew) |
---|
| 529 | EVT_MENU(menu_PRES_OPEN, MainFrm::OnPresOpen) |
---|
| 530 | EVT_MENU(menu_PRES_SAVE, MainFrm::OnPresSave) |
---|
| 531 | EVT_MENU(menu_PRES_SAVE_AS, MainFrm::OnPresSaveAs) |
---|
| 532 | EVT_MENU(menu_PRES_MARK, MainFrm::OnPresMark) |
---|
[128fac4] | 533 | EVT_MENU(menu_PRES_FREWIND, MainFrm::OnPresFRewind) |
---|
| 534 | EVT_MENU(menu_PRES_REWIND, MainFrm::OnPresRewind) |
---|
| 535 | EVT_MENU(menu_PRES_REVERSE, MainFrm::OnPresReverse) |
---|
| 536 | EVT_MENU(menu_PRES_PLAY, MainFrm::OnPresPlay) |
---|
| 537 | EVT_MENU(menu_PRES_FF, MainFrm::OnPresFF) |
---|
| 538 | EVT_MENU(menu_PRES_FFF, MainFrm::OnPresFFF) |
---|
| 539 | EVT_MENU(menu_PRES_PAUSE, MainFrm::OnPresPause) |
---|
[42c7efe] | 540 | EVT_MENU(wxID_STOP, MainFrm::OnPresStop) |
---|
[6a4cdcb6] | 541 | EVT_MENU(menu_PRES_EXPORT_MOVIE, MainFrm::OnPresExportMovie) |
---|
[1690fa9] | 542 | |
---|
| 543 | EVT_UPDATE_UI(menu_PRES_NEW, MainFrm::OnPresNewUpdate) |
---|
| 544 | EVT_UPDATE_UI(menu_PRES_OPEN, MainFrm::OnPresOpenUpdate) |
---|
| 545 | EVT_UPDATE_UI(menu_PRES_SAVE, MainFrm::OnPresSaveUpdate) |
---|
| 546 | EVT_UPDATE_UI(menu_PRES_SAVE_AS, MainFrm::OnPresSaveAsUpdate) |
---|
| 547 | EVT_UPDATE_UI(menu_PRES_MARK, MainFrm::OnPresMarkUpdate) |
---|
[128fac4] | 548 | EVT_UPDATE_UI(menu_PRES_FREWIND, MainFrm::OnPresFRewindUpdate) |
---|
| 549 | EVT_UPDATE_UI(menu_PRES_REWIND, MainFrm::OnPresRewindUpdate) |
---|
| 550 | EVT_UPDATE_UI(menu_PRES_REVERSE, MainFrm::OnPresReverseUpdate) |
---|
| 551 | EVT_UPDATE_UI(menu_PRES_PLAY, MainFrm::OnPresPlayUpdate) |
---|
| 552 | EVT_UPDATE_UI(menu_PRES_FF, MainFrm::OnPresFFUpdate) |
---|
| 553 | EVT_UPDATE_UI(menu_PRES_FFF, MainFrm::OnPresFFFUpdate) |
---|
| 554 | EVT_UPDATE_UI(menu_PRES_PAUSE, MainFrm::OnPresPauseUpdate) |
---|
[42c7efe] | 555 | EVT_UPDATE_UI(wxID_STOP, MainFrm::OnPresStopUpdate) |
---|
[6a4cdcb6] | 556 | EVT_UPDATE_UI(menu_PRES_EXPORT_MOVIE, MainFrm::OnPresExportMovieUpdate) |
---|
[5ffa439] | 557 | |
---|
[137bf99] | 558 | EVT_CLOSE(MainFrm::OnClose) |
---|
[4b1fc48] | 559 | EVT_SET_FOCUS(MainFrm::OnSetFocus) |
---|
[137bf99] | 560 | |
---|
[7ebc3d1] | 561 | EVT_MENU(menu_ROTATION_TOGGLE, MainFrm::OnToggleRotation) |
---|
[137bf99] | 562 | EVT_MENU(menu_ROTATION_SPEED_UP, MainFrm::OnSpeedUp) |
---|
| 563 | EVT_MENU(menu_ROTATION_SLOW_DOWN, MainFrm::OnSlowDown) |
---|
| 564 | EVT_MENU(menu_ROTATION_REVERSE, MainFrm::OnReverseDirectionOfRotation) |
---|
| 565 | EVT_MENU(menu_ROTATION_STEP_CCW, MainFrm::OnStepOnceAnticlockwise) |
---|
| 566 | EVT_MENU(menu_ROTATION_STEP_CW, MainFrm::OnStepOnceClockwise) |
---|
| 567 | EVT_MENU(menu_ORIENT_MOVE_NORTH, MainFrm::OnMoveNorth) |
---|
| 568 | EVT_MENU(menu_ORIENT_MOVE_EAST, MainFrm::OnMoveEast) |
---|
| 569 | EVT_MENU(menu_ORIENT_MOVE_SOUTH, MainFrm::OnMoveSouth) |
---|
| 570 | EVT_MENU(menu_ORIENT_MOVE_WEST, MainFrm::OnMoveWest) |
---|
| 571 | EVT_MENU(menu_ORIENT_SHIFT_LEFT, MainFrm::OnShiftDisplayLeft) |
---|
| 572 | EVT_MENU(menu_ORIENT_SHIFT_RIGHT, MainFrm::OnShiftDisplayRight) |
---|
| 573 | EVT_MENU(menu_ORIENT_SHIFT_UP, MainFrm::OnShiftDisplayUp) |
---|
| 574 | EVT_MENU(menu_ORIENT_SHIFT_DOWN, MainFrm::OnShiftDisplayDown) |
---|
| 575 | EVT_MENU(menu_ORIENT_PLAN, MainFrm::OnPlan) |
---|
| 576 | EVT_MENU(menu_ORIENT_ELEVATION, MainFrm::OnElevation) |
---|
| 577 | EVT_MENU(menu_ORIENT_HIGHER_VP, MainFrm::OnHigherViewpoint) |
---|
| 578 | EVT_MENU(menu_ORIENT_LOWER_VP, MainFrm::OnLowerViewpoint) |
---|
[42c7efe] | 579 | EVT_MENU(wxID_ZOOM_IN, MainFrm::OnZoomIn) |
---|
| 580 | EVT_MENU(wxID_ZOOM_OUT, MainFrm::OnZoomOut) |
---|
[137bf99] | 581 | EVT_MENU(menu_ORIENT_DEFAULTS, MainFrm::OnDefaults) |
---|
| 582 | EVT_MENU(menu_VIEW_SHOW_LEGS, MainFrm::OnShowSurveyLegs) |
---|
[8666fc7] | 583 | EVT_MENU(menu_SPLAYS_HIDE, MainFrm::OnHideSplays) |
---|
| 584 | EVT_MENU(menu_SPLAYS_SHOW_NORMAL, MainFrm::OnShowSplaysNormal) |
---|
| 585 | EVT_MENU(menu_SPLAYS_SHOW_FADED, MainFrm::OnShowSplaysFaded) |
---|
[137bf99] | 586 | EVT_MENU(menu_VIEW_SHOW_CROSSES, MainFrm::OnShowCrosses) |
---|
[fe444b8] | 587 | EVT_MENU(menu_VIEW_SHOW_ENTRANCES, MainFrm::OnShowEntrances) |
---|
| 588 | EVT_MENU(menu_VIEW_SHOW_FIXED_PTS, MainFrm::OnShowFixedPts) |
---|
| 589 | EVT_MENU(menu_VIEW_SHOW_EXPORTED_PTS, MainFrm::OnShowExportedPts) |
---|
[137bf99] | 590 | EVT_MENU(menu_VIEW_SHOW_NAMES, MainFrm::OnShowStationNames) |
---|
| 591 | EVT_MENU(menu_VIEW_SHOW_OVERLAPPING_NAMES, MainFrm::OnDisplayOverlappingNames) |
---|
[da6c802] | 592 | EVT_MENU(menu_VIEW_COLOUR_BY_DEPTH, MainFrm::OnColourByDepth) |
---|
[d4650b3] | 593 | EVT_MENU(menu_VIEW_COLOUR_BY_DATE, MainFrm::OnColourByDate) |
---|
[c61aa79] | 594 | EVT_MENU(menu_VIEW_COLOUR_BY_ERROR, MainFrm::OnColourByError) |
---|
[cc9e2c65] | 595 | EVT_MENU(menu_VIEW_COLOUR_BY_GRADIENT, MainFrm::OnColourByGradient) |
---|
[af50685] | 596 | EVT_MENU(menu_VIEW_COLOUR_BY_LENGTH, MainFrm::OnColourByLength) |
---|
[137bf99] | 597 | EVT_MENU(menu_VIEW_SHOW_SURFACE, MainFrm::OnShowSurface) |
---|
[c1cf79d] | 598 | EVT_MENU(menu_VIEW_GRID, MainFrm::OnViewGrid) |
---|
[f4c5932] | 599 | EVT_MENU(menu_VIEW_BOUNDING_BOX, MainFrm::OnViewBoundingBox) |
---|
[6abab84] | 600 | EVT_MENU(menu_VIEW_PERSPECTIVE, MainFrm::OnViewPerspective) |
---|
[d67450e] | 601 | EVT_MENU(menu_VIEW_SMOOTH_SHADING, MainFrm::OnViewSmoothShading) |
---|
[a517825] | 602 | EVT_MENU(menu_VIEW_TEXTURED, MainFrm::OnViewTextured) |
---|
[c60062d] | 603 | EVT_MENU(menu_VIEW_FOG, MainFrm::OnViewFog) |
---|
[db452ae] | 604 | EVT_MENU(menu_VIEW_SMOOTH_LINES, MainFrm::OnViewSmoothLines) |
---|
[b13aee4] | 605 | EVT_MENU(menu_VIEW_FULLSCREEN, MainFrm::OnViewFullScreen) |
---|
[33b2094] | 606 | EVT_MENU(menu_VIEW_SHOW_TUBES, MainFrm::OnToggleTubes) |
---|
[7a36b67] | 607 | EVT_MENU(menu_IND_COMPASS, MainFrm::OnViewCompass) |
---|
| 608 | EVT_MENU(menu_IND_CLINO, MainFrm::OnViewClino) |
---|
[97ea48d] | 609 | EVT_MENU(menu_IND_COLOUR_KEY, MainFrm::OnToggleColourKey) |
---|
[7a36b67] | 610 | EVT_MENU(menu_IND_SCALE_BAR, MainFrm::OnToggleScalebar) |
---|
| 611 | EVT_MENU(menu_CTL_SIDE_PANEL, MainFrm::OnViewSidePanel) |
---|
| 612 | EVT_MENU(menu_CTL_METRIC, MainFrm::OnToggleMetric) |
---|
| 613 | EVT_MENU(menu_CTL_DEGREES, MainFrm::OnToggleDegrees) |
---|
[d171c0c] | 614 | EVT_MENU(menu_CTL_PERCENT, MainFrm::OnTogglePercent) |
---|
[137bf99] | 615 | EVT_MENU(menu_CTL_REVERSE, MainFrm::OnReverseControls) |
---|
[1fd2edb] | 616 | EVT_MENU(menu_CTL_CANCEL_DIST_LINE, MainFrm::OnCancelDistLine) |
---|
[42c7efe] | 617 | EVT_MENU(wxID_ABOUT, MainFrm::OnAbout) |
---|
[137bf99] | 618 | |
---|
[d7b53e3] | 619 | EVT_UPDATE_UI(menu_FILE_LOG, MainFrm::OnShowLogUpdate) |
---|
[42c7efe] | 620 | EVT_UPDATE_UI(wxID_PRINT, MainFrm::OnPrintUpdate) |
---|
[045e2af] | 621 | EVT_UPDATE_UI(menu_FILE_SCREENSHOT, MainFrm::OnScreenshotUpdate) |
---|
[223f1ad] | 622 | EVT_UPDATE_UI(menu_FILE_EXPORT, MainFrm::OnExportUpdate) |
---|
[546a6f3] | 623 | EVT_UPDATE_UI(menu_ROTATION_TOGGLE, MainFrm::OnToggleRotationUpdate) |
---|
[137bf99] | 624 | EVT_UPDATE_UI(menu_ROTATION_SPEED_UP, MainFrm::OnSpeedUpUpdate) |
---|
| 625 | EVT_UPDATE_UI(menu_ROTATION_SLOW_DOWN, MainFrm::OnSlowDownUpdate) |
---|
| 626 | EVT_UPDATE_UI(menu_ROTATION_REVERSE, MainFrm::OnReverseDirectionOfRotationUpdate) |
---|
[c3b20c5] | 627 | EVT_UPDATE_UI(menu_ROTATION_STEP_CCW, MainFrm::OnStepOnceUpdate) |
---|
| 628 | EVT_UPDATE_UI(menu_ROTATION_STEP_CW, MainFrm::OnStepOnceUpdate) |
---|
[137bf99] | 629 | EVT_UPDATE_UI(menu_ORIENT_MOVE_NORTH, MainFrm::OnMoveNorthUpdate) |
---|
| 630 | EVT_UPDATE_UI(menu_ORIENT_MOVE_EAST, MainFrm::OnMoveEastUpdate) |
---|
| 631 | EVT_UPDATE_UI(menu_ORIENT_MOVE_SOUTH, MainFrm::OnMoveSouthUpdate) |
---|
| 632 | EVT_UPDATE_UI(menu_ORIENT_MOVE_WEST, MainFrm::OnMoveWestUpdate) |
---|
| 633 | EVT_UPDATE_UI(menu_ORIENT_SHIFT_LEFT, MainFrm::OnShiftDisplayLeftUpdate) |
---|
| 634 | EVT_UPDATE_UI(menu_ORIENT_SHIFT_RIGHT, MainFrm::OnShiftDisplayRightUpdate) |
---|
| 635 | EVT_UPDATE_UI(menu_ORIENT_SHIFT_UP, MainFrm::OnShiftDisplayUpUpdate) |
---|
| 636 | EVT_UPDATE_UI(menu_ORIENT_SHIFT_DOWN, MainFrm::OnShiftDisplayDownUpdate) |
---|
| 637 | EVT_UPDATE_UI(menu_ORIENT_PLAN, MainFrm::OnPlanUpdate) |
---|
| 638 | EVT_UPDATE_UI(menu_ORIENT_ELEVATION, MainFrm::OnElevationUpdate) |
---|
| 639 | EVT_UPDATE_UI(menu_ORIENT_HIGHER_VP, MainFrm::OnHigherViewpointUpdate) |
---|
| 640 | EVT_UPDATE_UI(menu_ORIENT_LOWER_VP, MainFrm::OnLowerViewpointUpdate) |
---|
[42c7efe] | 641 | EVT_UPDATE_UI(wxID_ZOOM_IN, MainFrm::OnZoomInUpdate) |
---|
| 642 | EVT_UPDATE_UI(wxID_ZOOM_OUT, MainFrm::OnZoomOutUpdate) |
---|
[137bf99] | 643 | EVT_UPDATE_UI(menu_ORIENT_DEFAULTS, MainFrm::OnDefaultsUpdate) |
---|
| 644 | EVT_UPDATE_UI(menu_VIEW_SHOW_LEGS, MainFrm::OnShowSurveyLegsUpdate) |
---|
[9cb97b7] | 645 | EVT_UPDATE_UI(menu_VIEW_SPLAYS, MainFrm::OnSplaysUpdate) |
---|
[8666fc7] | 646 | EVT_UPDATE_UI(menu_SPLAYS_HIDE, MainFrm::OnHideSplaysUpdate) |
---|
| 647 | EVT_UPDATE_UI(menu_SPLAYS_SHOW_NORMAL, MainFrm::OnShowSplaysNormalUpdate) |
---|
| 648 | EVT_UPDATE_UI(menu_SPLAYS_SHOW_FADED, MainFrm::OnShowSplaysFadedUpdate) |
---|
[137bf99] | 649 | EVT_UPDATE_UI(menu_VIEW_SHOW_CROSSES, MainFrm::OnShowCrossesUpdate) |
---|
[fe444b8] | 650 | EVT_UPDATE_UI(menu_VIEW_SHOW_ENTRANCES, MainFrm::OnShowEntrancesUpdate) |
---|
| 651 | EVT_UPDATE_UI(menu_VIEW_SHOW_FIXED_PTS, MainFrm::OnShowFixedPtsUpdate) |
---|
| 652 | EVT_UPDATE_UI(menu_VIEW_SHOW_EXPORTED_PTS, MainFrm::OnShowExportedPtsUpdate) |
---|
[137bf99] | 653 | EVT_UPDATE_UI(menu_VIEW_SHOW_NAMES, MainFrm::OnShowStationNamesUpdate) |
---|
| 654 | EVT_UPDATE_UI(menu_VIEW_SHOW_SURFACE, MainFrm::OnShowSurfaceUpdate) |
---|
| 655 | EVT_UPDATE_UI(menu_VIEW_SHOW_OVERLAPPING_NAMES, MainFrm::OnDisplayOverlappingNamesUpdate) |
---|
[da6c802] | 656 | EVT_UPDATE_UI(menu_VIEW_COLOUR_BY_DEPTH, MainFrm::OnColourByDepthUpdate) |
---|
[d4650b3] | 657 | EVT_UPDATE_UI(menu_VIEW_COLOUR_BY_DATE, MainFrm::OnColourByDateUpdate) |
---|
[c61aa79] | 658 | EVT_UPDATE_UI(menu_VIEW_COLOUR_BY_ERROR, MainFrm::OnColourByErrorUpdate) |
---|
[cc9e2c65] | 659 | EVT_UPDATE_UI(menu_VIEW_COLOUR_BY_GRADIENT, MainFrm::OnColourByGradientUpdate) |
---|
[af50685] | 660 | EVT_UPDATE_UI(menu_VIEW_COLOUR_BY_LENGTH, MainFrm::OnColourByLengthUpdate) |
---|
[c1cf79d] | 661 | EVT_UPDATE_UI(menu_VIEW_GRID, MainFrm::OnViewGridUpdate) |
---|
[f4c5932] | 662 | EVT_UPDATE_UI(menu_VIEW_BOUNDING_BOX, MainFrm::OnViewBoundingBoxUpdate) |
---|
[6abab84] | 663 | EVT_UPDATE_UI(menu_VIEW_PERSPECTIVE, MainFrm::OnViewPerspectiveUpdate) |
---|
[d67450e] | 664 | EVT_UPDATE_UI(menu_VIEW_SMOOTH_SHADING, MainFrm::OnViewSmoothShadingUpdate) |
---|
[a517825] | 665 | EVT_UPDATE_UI(menu_VIEW_TEXTURED, MainFrm::OnViewTexturedUpdate) |
---|
[c60062d] | 666 | EVT_UPDATE_UI(menu_VIEW_FOG, MainFrm::OnViewFogUpdate) |
---|
[db452ae] | 667 | EVT_UPDATE_UI(menu_VIEW_SMOOTH_LINES, MainFrm::OnViewSmoothLinesUpdate) |
---|
[b13aee4] | 668 | EVT_UPDATE_UI(menu_VIEW_FULLSCREEN, MainFrm::OnViewFullScreenUpdate) |
---|
[33b2094] | 669 | EVT_UPDATE_UI(menu_VIEW_SHOW_TUBES, MainFrm::OnToggleTubesUpdate) |
---|
[7a36b67] | 670 | EVT_UPDATE_UI(menu_IND_COMPASS, MainFrm::OnViewCompassUpdate) |
---|
| 671 | EVT_UPDATE_UI(menu_IND_CLINO, MainFrm::OnViewClinoUpdate) |
---|
[97ea48d] | 672 | EVT_UPDATE_UI(menu_IND_COLOUR_KEY, MainFrm::OnToggleColourKeyUpdate) |
---|
[7a36b67] | 673 | EVT_UPDATE_UI(menu_IND_SCALE_BAR, MainFrm::OnToggleScalebarUpdate) |
---|
| 674 | EVT_UPDATE_UI(menu_CTL_INDICATORS, MainFrm::OnIndicatorsUpdate) |
---|
| 675 | EVT_UPDATE_UI(menu_CTL_SIDE_PANEL, MainFrm::OnViewSidePanelUpdate) |
---|
| 676 | EVT_UPDATE_UI(menu_CTL_REVERSE, MainFrm::OnReverseControlsUpdate) |
---|
| 677 | EVT_UPDATE_UI(menu_CTL_CANCEL_DIST_LINE, MainFrm::OnCancelDistLineUpdate) |
---|
| 678 | EVT_UPDATE_UI(menu_CTL_METRIC, MainFrm::OnToggleMetricUpdate) |
---|
| 679 | EVT_UPDATE_UI(menu_CTL_DEGREES, MainFrm::OnToggleDegreesUpdate) |
---|
[d171c0c] | 680 | EVT_UPDATE_UI(menu_CTL_PERCENT, MainFrm::OnTogglePercentUpdate) |
---|
[5809313] | 681 | END_EVENT_TABLE() |
---|
| 682 | |
---|
[63dc4eb] | 683 | class LabelCmp : public greater<const LabelInfo*> { |
---|
[ff9f695] | 684 | wxChar separator; |
---|
[156dc16] | 685 | public: |
---|
[ff9f695] | 686 | LabelCmp(wxChar separator_) : separator(separator_) {} |
---|
[156dc16] | 687 | bool operator()(const LabelInfo* pt1, const LabelInfo* pt2) { |
---|
[2f36993] | 688 | return name_cmp(pt1->GetText(), pt2->GetText(), separator) < 0; |
---|
[156dc16] | 689 | } |
---|
| 690 | }; |
---|
| 691 | |
---|
[63dc4eb] | 692 | class LabelPlotCmp : public greater<const LabelInfo*> { |
---|
[ff9f695] | 693 | wxChar separator; |
---|
[291ca5d] | 694 | public: |
---|
[ff9f695] | 695 | LabelPlotCmp(wxChar separator_) : separator(separator_) {} |
---|
[291ca5d] | 696 | bool operator()(const LabelInfo* pt1, const LabelInfo* pt2) { |
---|
[5a24583] | 697 | int n = pt1->get_flags() - pt2->get_flags(); |
---|
[291ca5d] | 698 | if (n) return n > 0; |
---|
[5a24583] | 699 | wxString l1 = pt1->GetText().AfterLast(separator); |
---|
| 700 | wxString l2 = pt2->GetText().AfterLast(separator); |
---|
[f11f2af] | 701 | n = name_cmp(l1, l2, separator); |
---|
| 702 | if (n) return n < 0; |
---|
[2a94924] | 703 | // Prefer non-2-nodes... |
---|
| 704 | // FIXME; implement |
---|
[f11f2af] | 705 | // if leaf names are the same, prefer shorter labels as we can |
---|
| 706 | // display more of them |
---|
[5a24583] | 707 | n = pt1->GetText().length() - pt2->GetText().length(); |
---|
[f11f2af] | 708 | if (n) return n < 0; |
---|
[2a94924] | 709 | // make sure that we don't ever compare different labels as equal |
---|
[5a24583] | 710 | return name_cmp(pt1->GetText(), pt2->GetText(), separator) < 0; |
---|
[291ca5d] | 711 | } |
---|
| 712 | }; |
---|
| 713 | |
---|
[f6fe808] | 714 | #if wxUSE_DRAG_AND_DROP |
---|
[5901b62] | 715 | class DnDFile : public wxFileDropTarget { |
---|
| 716 | public: |
---|
| 717 | DnDFile(MainFrm *parent) : m_Parent(parent) { } |
---|
| 718 | virtual bool OnDropFiles(wxCoord, wxCoord, |
---|
| 719 | const wxArrayString &filenames); |
---|
| 720 | |
---|
| 721 | private: |
---|
| 722 | MainFrm * m_Parent; |
---|
| 723 | }; |
---|
| 724 | |
---|
| 725 | bool |
---|
| 726 | DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString &filenames) |
---|
| 727 | { |
---|
| 728 | // Load a survey file by drag-and-drop. |
---|
| 729 | assert(filenames.GetCount() > 0); |
---|
| 730 | |
---|
| 731 | if (filenames.GetCount() != 1) { |
---|
[736f7df] | 732 | /* TRANSLATORS: error if you try to drag multiple files to the aven |
---|
| 733 | * window */ |
---|
[5627cbb] | 734 | wxGetApp().ReportError(wmsg(/*You may only view one 3d file at a time.*/336)); |
---|
[6d1bc83] | 735 | return false; |
---|
[5901b62] | 736 | } |
---|
[421b7d2] | 737 | |
---|
[5901b62] | 738 | m_Parent->OpenFile(filenames[0]); |
---|
[6d1bc83] | 739 | return true; |
---|
[5901b62] | 740 | } |
---|
[f6fe808] | 741 | #endif |
---|
[5901b62] | 742 | |
---|
[137bf99] | 743 | MainFrm::MainFrm(const wxString& title, const wxPoint& pos, const wxSize& size) : |
---|
[ad3d0a2] | 744 | wxFrame(NULL, 101, title, pos, size, wxDEFAULT_FRAME_STYLE), |
---|
[486c619] | 745 | m_SashPosition(-1), |
---|
[d7b53e3] | 746 | m_Gfx(NULL), m_Log(NULL), |
---|
| 747 | m_NumEntrances(0), m_NumFixedPts(0), m_NumExportedPts(0), |
---|
[5fe7292] | 748 | m_NumHighlighted(0), |
---|
| 749 | m_HasUndergroundLegs(false), m_HasSplays(false), m_HasSurfaceLegs(false), |
---|
[bc60689] | 750 | m_HasErrorInformation(false), m_IsExtendedElevation(false), |
---|
[b75a37d] | 751 | pending_find(false), fullscreen_showing_menus(false) |
---|
[9c3d91e] | 752 | #ifdef PREFDLG |
---|
| 753 | , m_PrefsDlg(NULL) |
---|
| 754 | #endif |
---|
[5809313] | 755 | { |
---|
[cfd6c44] | 756 | #ifdef _WIN32 |
---|
[003d953] | 757 | // The peculiar name is so that the icon is the first in the file |
---|
[b1de3e0] | 758 | // (required by Microsoft Windows for this type of icon) |
---|
[ea1ea51] | 759 | SetIcon(wxICON(AAA_aven)); |
---|
[95fa391] | 760 | #else |
---|
[ea1ea51] | 761 | SetIcon(wxICON(aven)); |
---|
[cfd6c44] | 762 | #endif |
---|
| 763 | |
---|
[83478f5] | 764 | #if wxCHECK_VERSION(3,1,0) |
---|
| 765 | // Add a full screen button to the right upper corner of title bar under OS |
---|
| 766 | // X 10.7 and later. |
---|
| 767 | EnableFullScreenView(); |
---|
| 768 | #endif |
---|
[9d3d8cc] | 769 | CreateMenuBar(); |
---|
[242cb07] | 770 | MakeToolBar(); |
---|
[7c29c976] | 771 | CreateStatusBar(2, wxST_SIZEGRIP); |
---|
[9d3d8cc] | 772 | CreateSidePanel(); |
---|
[f433fda] | 773 | |
---|
[7c29c976] | 774 | int widths[2] = { -1 /* variable width */, -1 }; |
---|
| 775 | GetStatusBar()->SetStatusWidths(2, widths); |
---|
[9d3d8cc] | 776 | |
---|
[0580c6a] | 777 | #ifdef __X__ // wxMotif or wxX11 |
---|
[9d3d8cc] | 778 | int x; |
---|
| 779 | int y; |
---|
| 780 | GetSize(&x, &y); |
---|
| 781 | // X seems to require a forced resize. |
---|
| 782 | SetSize(-1, -1, x, y); |
---|
| 783 | #endif |
---|
| 784 | |
---|
[0edb0d0] | 785 | #if wxUSE_DRAG_AND_DROP |
---|
[5901b62] | 786 | SetDropTarget(new DnDFile(this)); |
---|
[f6fe808] | 787 | #endif |
---|
[9d3d8cc] | 788 | } |
---|
| 789 | |
---|
| 790 | void MainFrm::CreateMenuBar() |
---|
| 791 | { |
---|
| 792 | // Create the menus and the menu bar. |
---|
[137bf99] | 793 | |
---|
| 794 | wxMenu* filemenu = new wxMenu; |
---|
[42c7efe] | 795 | // wxID_OPEN stock label lacks the ellipses |
---|
[736f7df] | 796 | /* TRANSLATORS: Aven menu items. An “&” goes before the letter of any |
---|
| 797 | * accelerator key. |
---|
| 798 | * |
---|
| 799 | * The string "\t" separates the menu text and any accelerator key. |
---|
| 800 | * |
---|
| 801 | * "File" menu. The accelerators must be different within this group. |
---|
| 802 | * c.f. 201, 380, 381. */ |
---|
[ee7511a] | 803 | filemenu->Append(wxID_OPEN, wmsg(/*&Open…\tCtrl+O*/220)); |
---|
[d7b53e3] | 804 | filemenu->Append(menu_FILE_LOG, wmsg(/*Show &Log*/144)); |
---|
[137bf99] | 805 | filemenu->AppendSeparator(); |
---|
[42c7efe] | 806 | // wxID_PRINT stock label lacks the ellipses |
---|
[ee7511a] | 807 | filemenu->Append(wxID_PRINT, wmsg(/*&Print…\tCtrl+P*/380)); |
---|
| 808 | filemenu->Append(menu_FILE_PAGE_SETUP, wmsg(/*P&age Setup…*/381)); |
---|
[ce403f1] | 809 | filemenu->AppendSeparator(); |
---|
[736f7df] | 810 | /* TRANSLATORS: In the "File" menu */ |
---|
[ee7511a] | 811 | filemenu->Append(menu_FILE_SCREENSHOT, wmsg(/*&Screenshot…*/201)); |
---|
| 812 | filemenu->Append(menu_FILE_EXPORT, wmsg(/*&Export as…*/382)); |
---|
[b72f4b5] | 813 | #ifndef __WXMAC__ |
---|
| 814 | // On wxMac the "Quit" menu item will be moved elsewhere, so we suppress |
---|
| 815 | // this separator. |
---|
[223f1ad] | 816 | filemenu->AppendSeparator(); |
---|
[f930738] | 817 | #else |
---|
| 818 | // We suppress the "Help" menu under OS X as it would otherwise end up as |
---|
| 819 | // an empty menu, but we need to add the "About" menu item somewhere. It |
---|
| 820 | // really doesn't matter where as wxWidgets will move it to the "Apple" |
---|
| 821 | // menu. |
---|
| 822 | filemenu->Append(wxID_ABOUT); |
---|
[b72f4b5] | 823 | #endif |
---|
[42c7efe] | 824 | filemenu->Append(wxID_EXIT); |
---|
[137bf99] | 825 | |
---|
[cf8c84b] | 826 | m_history.UseMenu(filemenu); |
---|
| 827 | m_history.Load(*wxConfigBase::Get()); |
---|
| 828 | |
---|
[137bf99] | 829 | wxMenu* rotmenu = new wxMenu; |
---|
[736f7df] | 830 | /* TRANSLATORS: "Rotation" menu. The accelerators must be different within |
---|
| 831 | * this group. Tickable menu item which toggles auto rotation */ |
---|
[ee7511a] | 832 | rotmenu->AppendCheckItem(menu_ROTATION_TOGGLE, wmsg(/*Au&to-Rotate\tSpace*/231)); |
---|
[137bf99] | 833 | rotmenu->AppendSeparator(); |
---|
[d86459c] | 834 | rotmenu->Append(menu_ROTATION_SPEED_UP, wmsg(/*Speed &Up*/232)); |
---|
| 835 | rotmenu->Append(menu_ROTATION_SLOW_DOWN, wmsg(/*Slow &Down*/233)); |
---|
[137bf99] | 836 | rotmenu->AppendSeparator(); |
---|
[d86459c] | 837 | rotmenu->Append(menu_ROTATION_REVERSE, wmsg(/*&Reverse Direction*/234)); |
---|
[137bf99] | 838 | rotmenu->AppendSeparator(); |
---|
[d86459c] | 839 | rotmenu->Append(menu_ROTATION_STEP_CCW, wmsg(/*Step Once &Anticlockwise*/235)); |
---|
| 840 | rotmenu->Append(menu_ROTATION_STEP_CW, wmsg(/*Step Once &Clockwise*/236)); |
---|
[137bf99] | 841 | |
---|
| 842 | wxMenu* orientmenu = new wxMenu; |
---|
[d86459c] | 843 | orientmenu->Append(menu_ORIENT_MOVE_NORTH, wmsg(/*View &North*/240)); |
---|
| 844 | orientmenu->Append(menu_ORIENT_MOVE_EAST, wmsg(/*View &East*/241)); |
---|
| 845 | orientmenu->Append(menu_ORIENT_MOVE_SOUTH, wmsg(/*View &South*/242)); |
---|
| 846 | orientmenu->Append(menu_ORIENT_MOVE_WEST, wmsg(/*View &West*/243)); |
---|
[137bf99] | 847 | orientmenu->AppendSeparator(); |
---|
[736f7df] | 848 | /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions |
---|
| 849 | * - it should be translated to the terminology that cavers using the |
---|
| 850 | * language would use. */ |
---|
[d86459c] | 851 | orientmenu->Append(menu_ORIENT_SHIFT_LEFT, wmsg(/*Shift Survey &Left*/244)); |
---|
[736f7df] | 852 | /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions |
---|
| 853 | * - it should be translated to the terminology that cavers using the |
---|
| 854 | * language would use. */ |
---|
[d86459c] | 855 | orientmenu->Append(menu_ORIENT_SHIFT_RIGHT, wmsg(/*Shift Survey &Right*/245)); |
---|
[736f7df] | 856 | /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions |
---|
| 857 | * - it should be translated to the terminology that cavers using the |
---|
| 858 | * language would use. */ |
---|
[d86459c] | 859 | orientmenu->Append(menu_ORIENT_SHIFT_UP, wmsg(/*Shift Survey &Up*/246)); |
---|
[736f7df] | 860 | /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions |
---|
| 861 | * - it should be translated to the terminology that cavers using the |
---|
| 862 | * language would use. */ |
---|
[d86459c] | 863 | orientmenu->Append(menu_ORIENT_SHIFT_DOWN, wmsg(/*Shift Survey &Down*/247)); |
---|
[137bf99] | 864 | orientmenu->AppendSeparator(); |
---|
[d86459c] | 865 | orientmenu->Append(menu_ORIENT_PLAN, wmsg(/*&Plan View*/248)); |
---|
| 866 | orientmenu->Append(menu_ORIENT_ELEVATION, wmsg(/*Ele&vation*/249)); |
---|
[137bf99] | 867 | orientmenu->AppendSeparator(); |
---|
[d86459c] | 868 | orientmenu->Append(menu_ORIENT_HIGHER_VP, wmsg(/*&Higher Viewpoint*/250)); |
---|
| 869 | orientmenu->Append(menu_ORIENT_LOWER_VP, wmsg(/*L&ower Viewpoint*/251)); |
---|
[137bf99] | 870 | orientmenu->AppendSeparator(); |
---|
[42c7efe] | 871 | // Default labels for wxID_ZOOM_IN and wxID_ZOOM_OUT don't have accels. |
---|
| 872 | orientmenu->Append(wxID_ZOOM_IN, wmsg(/*&Zoom In\t]*/252)); |
---|
| 873 | orientmenu->Append(wxID_ZOOM_OUT, wmsg(/*Zoo&m Out\t[*/253)); |
---|
[137bf99] | 874 | orientmenu->AppendSeparator(); |
---|
[d86459c] | 875 | orientmenu->Append(menu_ORIENT_DEFAULTS, wmsg(/*Restore De&fault View*/254)); |
---|
[1690fa9] | 876 | |
---|
[203d2a7] | 877 | wxMenu* presmenu = new wxMenu; |
---|
[d86459c] | 878 | presmenu->Append(menu_PRES_NEW, wmsg(/*&New Presentation*/311)); |
---|
[ee7511a] | 879 | presmenu->Append(menu_PRES_OPEN, wmsg(/*&Open Presentation…*/312)); |
---|
[d86459c] | 880 | presmenu->Append(menu_PRES_SAVE, wmsg(/*&Save Presentation*/313)); |
---|
[ee7511a] | 881 | presmenu->Append(menu_PRES_SAVE_AS, wmsg(/*Sa&ve Presentation As…*/314)); |
---|
[203d2a7] | 882 | presmenu->AppendSeparator(); |
---|
[736f7df] | 883 | /* TRANSLATORS: "Mark" as in "Mark this position" */ |
---|
[d86459c] | 884 | presmenu->Append(menu_PRES_MARK, wmsg(/*&Mark*/315)); |
---|
[736f7df] | 885 | /* TRANSLATORS: "Play" as in "Play back a recording" */ |
---|
[a2a8d23] | 886 | presmenu->AppendCheckItem(menu_PRES_PLAY, wmsg(/*Pla&y*/316)); |
---|
[ee7511a] | 887 | presmenu->Append(menu_PRES_EXPORT_MOVIE, wmsg(/*&Export as Movie…*/317)); |
---|
[1690fa9] | 888 | |
---|
[203d2a7] | 889 | wxMenu* viewmenu = new wxMenu; |
---|
[edb6576] | 890 | #ifndef PREFDLG |
---|
[736f7df] | 891 | /* TRANSLATORS: Items in the "View" menu: */ |
---|
[d86459c] | 892 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_NAMES, wmsg(/*Station &Names\tCtrl+N*/270)); |
---|
[736f7df] | 893 | /* TRANSLATORS: Toggles drawing of 3D passages */ |
---|
[ee7511a] | 894 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_TUBES, wmsg(/*Passage &Tubes\tCtrl+T*/346)); |
---|
[d86459c] | 895 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_CROSSES, wmsg(/*&Crosses\tCtrl+X*/271)); |
---|
| 896 | viewmenu->AppendCheckItem(menu_VIEW_GRID, wmsg(/*&Grid\tCtrl+G*/297)); |
---|
| 897 | viewmenu->AppendCheckItem(menu_VIEW_BOUNDING_BOX, wmsg(/*&Bounding Box\tCtrl+B*/318)); |
---|
[edb6576] | 898 | viewmenu->AppendSeparator(); |
---|
[736f7df] | 899 | /* TRANSLATORS: Here a "survey leg" is a set of measurements between two |
---|
| 900 | * "survey stations". */ |
---|
[d86459c] | 901 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_LEGS, wmsg(/*&Underground Survey Legs\tCtrl+L*/272)); |
---|
[736f7df] | 902 | /* TRANSLATORS: Here a "survey leg" is a set of measurements between two |
---|
| 903 | * "survey stations". */ |
---|
[d86459c] | 904 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_SURFACE, wmsg(/*&Surface Survey Legs\tCtrl+F*/291)); |
---|
[8666fc7] | 905 | |
---|
| 906 | wxMenu* splaymenu = new wxMenu; |
---|
[36efb03] | 907 | /* TRANSLATORS: Item in the "Splay Legs" submenu - if this is selected, |
---|
| 908 | * splay legs are not shown. */ |
---|
[82ae44a] | 909 | splaymenu->AppendCheckItem(menu_SPLAYS_HIDE, wmsg(/*&Hide*/407)); |
---|
[36efb03] | 910 | /* TRANSLATORS: Item in the "Splay Legs" submenu - if this is selected, |
---|
| 911 | * aven will show splay legs with less bright colours (rather than the |
---|
| 912 | * same as other legs "Show" or not shown "Hide"). */ |
---|
[82ae44a] | 913 | splaymenu->AppendCheckItem(menu_SPLAYS_SHOW_FADED, wmsg(/*&Fade*/408)); |
---|
[36efb03] | 914 | /* TRANSLATORS: Item in the "Splay Legs" submenu - if this is selected, |
---|
| 915 | * splay legs are shown the same as other legs. */ |
---|
[82ae44a] | 916 | splaymenu->AppendCheckItem(menu_SPLAYS_SHOW_NORMAL, wmsg(/*&Show*/409)); |
---|
[9cb97b7] | 917 | viewmenu->Append(menu_VIEW_SPLAYS, wmsg(/*Spla&y Legs*/406), splaymenu); |
---|
[8666fc7] | 918 | |
---|
[edb6576] | 919 | viewmenu->AppendSeparator(); |
---|
[d86459c] | 920 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_OVERLAPPING_NAMES, wmsg(/*&Overlapping Names*/273)); |
---|
| 921 | viewmenu->AppendCheckItem(menu_VIEW_COLOUR_BY_DEPTH, wmsg(/*Colour by &Depth*/292)); |
---|
| 922 | viewmenu->AppendCheckItem(menu_VIEW_COLOUR_BY_DATE, wmsg(/*Colour by D&ate*/293)); |
---|
| 923 | viewmenu->AppendCheckItem(menu_VIEW_COLOUR_BY_ERROR, wmsg(/*Colour by E&rror*/289)); |
---|
[cc9e2c65] | 924 | viewmenu->AppendCheckItem(menu_VIEW_COLOUR_BY_GRADIENT, wmsg(/*Colour by Grad&ient*/85)); |
---|
[af50685] | 925 | viewmenu->AppendCheckItem(menu_VIEW_COLOUR_BY_LENGTH, wmsg(/*Colour by &Length*/82)); |
---|
[edb6576] | 926 | viewmenu->AppendSeparator(); |
---|
[d86459c] | 927 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_ENTRANCES, wmsg(/*Highlight &Entrances*/294)); |
---|
| 928 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_FIXED_PTS, wmsg(/*Highlight &Fixed Points*/295)); |
---|
| 929 | viewmenu->AppendCheckItem(menu_VIEW_SHOW_EXPORTED_PTS, wmsg(/*Highlight E&xported Points*/296)); |
---|
[edb6576] | 930 | viewmenu->AppendSeparator(); |
---|
| 931 | #else |
---|
[d86459c] | 932 | viewmenu-> Append(menu_VIEW_CANCEL_DIST_LINE, wmsg(/*&Cancel Measuring Line\tEscape*/281)); |
---|
[edb6576] | 933 | #endif |
---|
[d86459c] | 934 | viewmenu->AppendCheckItem(menu_VIEW_PERSPECTIVE, wmsg(/*&Perspective*/237)); |
---|
| 935 | // FIXME: enable this viewmenu->AppendCheckItem(menu_VIEW_SMOOTH_SHADING, wmsg(/*&Smooth Shading*/?!?); |
---|
| 936 | viewmenu->AppendCheckItem(menu_VIEW_TEXTURED, wmsg(/*Textured &Walls*/238)); |
---|
[736f7df] | 937 | /* TRANSLATORS: Toggles OpenGL "Depth Fogging" - feel free to translate |
---|
| 938 | * using that term instead if it gives a better translation which most |
---|
| 939 | * users will understand. */ |
---|
[ee7511a] | 940 | viewmenu->AppendCheckItem(menu_VIEW_FOG, wmsg(/*Fade Distant Ob&jects*/239)); |
---|
[736f7df] | 941 | /* TRANSLATORS: Here a "survey leg" is a set of measurements between two |
---|
| 942 | * "survey stations". */ |
---|
[5c2bff7] | 943 | viewmenu->AppendCheckItem(menu_VIEW_SMOOTH_LINES, wmsg(/*Smoot&hed Survey Legs*/298)); |
---|
[6abab84] | 944 | viewmenu->AppendSeparator(); |
---|
[85c83ac5] | 945 | #ifdef __WXMAC__ |
---|
| 946 | // F11 on OS X is used by the desktop (for speaker volume and/or window |
---|
| 947 | // navigation). The standard OS X shortcut for full screen mode is |
---|
| 948 | // Shift-Command-F which in wxWidgets terms is Shift+Ctrl+F. |
---|
| 949 | wxString wxmac_fullscreen = wmsg(/*Full Screen &Mode\tF11*/356); |
---|
[e583283] | 950 | wxmac_fullscreen.Replace(wxT("\tF11"), wxT("\tShift+Ctrl+F"), false); |
---|
[85c83ac5] | 951 | viewmenu->AppendCheckItem(menu_VIEW_FULLSCREEN, wxmac_fullscreen); |
---|
| 952 | #else |
---|
[ee7511a] | 953 | viewmenu->AppendCheckItem(menu_VIEW_FULLSCREEN, wmsg(/*Full Screen &Mode\tF11*/356)); |
---|
[85c83ac5] | 954 | #endif |
---|
[edb6576] | 955 | #ifdef PREFDLG |
---|
[203d2a7] | 956 | viewmenu->AppendSeparator(); |
---|
[ee7511a] | 957 | viewmenu-> Append(wxID_PREFERENCES, wmsg(/*&Preferences…*/347)); |
---|
[edb6576] | 958 | #endif |
---|
| 959 | |
---|
| 960 | #ifndef PREFDLG |
---|
| 961 | wxMenu* ctlmenu = new wxMenu; |
---|
[d86459c] | 962 | ctlmenu->AppendCheckItem(menu_CTL_REVERSE, wmsg(/*&Reverse Sense\tCtrl+R*/280)); |
---|
[edb6576] | 963 | ctlmenu->AppendSeparator(); |
---|
[d86459c] | 964 | ctlmenu->Append(menu_CTL_CANCEL_DIST_LINE, wmsg(/*&Cancel Measuring Line\tEscape*/281)); |
---|
[edb6576] | 965 | ctlmenu->AppendSeparator(); |
---|
| 966 | wxMenu* indmenu = new wxMenu; |
---|
[d86459c] | 967 | indmenu->AppendCheckItem(menu_IND_COMPASS, wmsg(/*&Compass*/274)); |
---|
| 968 | indmenu->AppendCheckItem(menu_IND_CLINO, wmsg(/*C&linometer*/275)); |
---|
[736f7df] | 969 | /* TRANSLATORS: The "Colour Key" is the thing in aven showing which colour |
---|
| 970 | * corresponds to which depth, date, survey closure error, etc. */ |
---|
[97ea48d] | 971 | indmenu->AppendCheckItem(menu_IND_COLOUR_KEY, wmsg(/*Colour &Key*/276)); |
---|
[d86459c] | 972 | indmenu->AppendCheckItem(menu_IND_SCALE_BAR, wmsg(/*&Scale Bar*/277)); |
---|
| 973 | ctlmenu->Append(menu_CTL_INDICATORS, wmsg(/*&Indicators*/299), indmenu); |
---|
| 974 | ctlmenu->AppendCheckItem(menu_CTL_SIDE_PANEL, wmsg(/*&Side Panel*/337)); |
---|
[edb6576] | 975 | ctlmenu->AppendSeparator(); |
---|
[d86459c] | 976 | ctlmenu->AppendCheckItem(menu_CTL_METRIC, wmsg(/*&Metric*/342)); |
---|
| 977 | ctlmenu->AppendCheckItem(menu_CTL_DEGREES, wmsg(/*&Degrees*/343)); |
---|
[d171c0c] | 978 | ctlmenu->AppendCheckItem(menu_CTL_PERCENT, wmsg(/*&Percent*/430)); |
---|
[edb6576] | 979 | #endif |
---|
[137bf99] | 980 | |
---|
[c988ae4] | 981 | wxMenuBar* menubar = new wxMenuBar(); |
---|
[736f7df] | 982 | /* TRANSLATORS: Aven menu titles. An “&” goes before the letter of any |
---|
| 983 | * accelerator key. The accelerators must be different within this group |
---|
| 984 | */ |
---|
[d86459c] | 985 | menubar->Append(filemenu, wmsg(/*&File*/210)); |
---|
| 986 | menubar->Append(rotmenu, wmsg(/*&Rotation*/211)); |
---|
| 987 | menubar->Append(orientmenu, wmsg(/*&Orientation*/212)); |
---|
| 988 | menubar->Append(viewmenu, wmsg(/*&View*/213)); |
---|
[5de0cac] | 989 | #ifndef PREFDLG |
---|
[d86459c] | 990 | menubar->Append(ctlmenu, wmsg(/*&Controls*/214)); |
---|
[5de0cac] | 991 | #endif |
---|
[d86459c] | 992 | menubar->Append(presmenu, wmsg(/*&Presentation*/216)); |
---|
[b72f4b5] | 993 | #ifndef __WXMAC__ |
---|
| 994 | // On wxMac the "About" menu item will be moved elsewhere, so we suppress |
---|
| 995 | // this menu since it will then be empty. |
---|
[c5dd692] | 996 | wxMenu* helpmenu = new wxMenu; |
---|
| 997 | helpmenu->Append(wxID_ABOUT); |
---|
| 998 | |
---|
[d86459c] | 999 | menubar->Append(helpmenu, wmsg(/*&Help*/215)); |
---|
[b72f4b5] | 1000 | #endif |
---|
[137bf99] | 1001 | SetMenuBar(menubar); |
---|
[9d3d8cc] | 1002 | } |
---|
[137bf99] | 1003 | |
---|
[242cb07] | 1004 | void MainFrm::MakeToolBar() |
---|
[9d3d8cc] | 1005 | { |
---|
[242cb07] | 1006 | // Make the toolbar. |
---|
[137bf99] | 1007 | |
---|
[9d3d8cc] | 1008 | wxToolBar* toolbar = wxFrame::CreateToolBar(); |
---|
[137bf99] | 1009 | |
---|
[b65c13f] | 1010 | #ifndef __WXGTK20__ |
---|
[d94f5db] | 1011 | toolbar->SetMargins(5, 5); |
---|
| 1012 | #endif |
---|
| 1013 | |
---|
[9b540e6] | 1014 | // FIXME: TRANSLATE tooltips |
---|
[b4f28e0] | 1015 | toolbar->AddTool(wxID_OPEN, wxT("Open"), TOOL(open), wxT("Open a survey file for viewing")); |
---|
| 1016 | toolbar->AddTool(menu_PRES_OPEN, wxT("Open presentation"), TOOL(open_pres), wxT("Open a presentation")); |
---|
[d7b53e3] | 1017 | toolbar->AddTool(menu_FILE_LOG, wxT("View log"), TOOL(log), wxT("View log from processing survey data")); |
---|
[2d9ed8ad] | 1018 | toolbar->AddSeparator(); |
---|
[b4f28e0] | 1019 | toolbar->AddCheckTool(menu_ROTATION_TOGGLE, wxT("Toggle rotation"), TOOL(rotation), wxNullBitmap, wxT("Toggle rotation")); |
---|
| 1020 | toolbar->AddTool(menu_ORIENT_PLAN, wxT("Plan"), TOOL(plan), wxT("Switch to plan view")); |
---|
| 1021 | toolbar->AddTool(menu_ORIENT_ELEVATION, wxT("Elevation"), TOOL(elevation), wxT("Switch to elevation view")); |
---|
| 1022 | toolbar->AddTool(menu_ORIENT_DEFAULTS, wxT("Default view"), TOOL(defaults), wxT("Restore default view")); |
---|
[2d9ed8ad] | 1023 | toolbar->AddSeparator(); |
---|
[b4f28e0] | 1024 | toolbar->AddCheckTool(menu_VIEW_SHOW_NAMES, wxT("Names"), TOOL(names), wxNullBitmap, wxT("Show station names")); |
---|
| 1025 | toolbar->AddCheckTool(menu_VIEW_SHOW_CROSSES, wxT("Crosses"), TOOL(crosses), wxNullBitmap, wxT("Show crosses on stations")); |
---|
| 1026 | toolbar->AddCheckTool(menu_VIEW_SHOW_ENTRANCES, wxT("Entrances"), TOOL(entrances), wxNullBitmap, wxT("Highlight entrances")); |
---|
| 1027 | toolbar->AddCheckTool(menu_VIEW_SHOW_FIXED_PTS, wxT("Fixed points"), TOOL(fixed_pts), wxNullBitmap, wxT("Highlight fixed points")); |
---|
| 1028 | toolbar->AddCheckTool(menu_VIEW_SHOW_EXPORTED_PTS, wxT("Exported points"), TOOL(exported_pts), wxNullBitmap, wxT("Highlight exported stations")); |
---|
[2d9ed8ad] | 1029 | toolbar->AddSeparator(); |
---|
[b4f28e0] | 1030 | toolbar->AddCheckTool(menu_VIEW_SHOW_LEGS, wxT("Underground legs"), TOOL(ug_legs), wxNullBitmap, wxT("Show underground surveys")); |
---|
| 1031 | toolbar->AddCheckTool(menu_VIEW_SHOW_SURFACE, wxT("Surface legs"), TOOL(surface_legs), wxNullBitmap, wxT("Show surface surveys")); |
---|
| 1032 | toolbar->AddCheckTool(menu_VIEW_SHOW_TUBES, wxT("Tubes"), TOOL(tubes), wxNullBitmap, wxT("Show passage tubes")); |
---|
[128fac4] | 1033 | toolbar->AddSeparator(); |
---|
[b4f28e0] | 1034 | toolbar->AddCheckTool(menu_PRES_FREWIND, wxT("Fast Rewind"), TOOL(pres_frew), wxNullBitmap, wxT("Very Fast Rewind")); |
---|
| 1035 | toolbar->AddCheckTool(menu_PRES_REWIND, wxT("Rewind"), TOOL(pres_rew), wxNullBitmap, wxT("Fast Rewind")); |
---|
| 1036 | toolbar->AddCheckTool(menu_PRES_REVERSE, wxT("Backwards"), TOOL(pres_go_back), wxNullBitmap, wxT("Play Backwards")); |
---|
| 1037 | toolbar->AddCheckTool(menu_PRES_PAUSE, wxT("Pause"), TOOL(pres_pause), wxNullBitmap, wxT("Pause")); |
---|
| 1038 | toolbar->AddCheckTool(menu_PRES_PLAY, wxT("Go"), TOOL(pres_go), wxNullBitmap, wxT("Play")); |
---|
| 1039 | toolbar->AddCheckTool(menu_PRES_FF, wxT("FF"), TOOL(pres_ff), wxNullBitmap, wxT("Fast Forward")); |
---|
| 1040 | toolbar->AddCheckTool(menu_PRES_FFF, wxT("Very FF"), TOOL(pres_fff), wxNullBitmap, wxT("Very Fast Forward")); |
---|
| 1041 | toolbar->AddTool(wxID_STOP, wxT("Stop"), TOOL(pres_stop), wxT("Stop")); |
---|
[fd6e0d5] | 1042 | |
---|
[203d2a7] | 1043 | toolbar->AddSeparator(); |
---|
[5627cbb] | 1044 | m_FindBox = new wxTextCtrl(toolbar, textctrl_FIND, wxString(), wxDefaultPosition, |
---|
[429465a] | 1045 | wxDefaultSize, wxTE_PROCESS_ENTER); |
---|
[fd6e0d5] | 1046 | toolbar->AddControl(m_FindBox); |
---|
[736f7df] | 1047 | /* TRANSLATORS: "Find stations" button tooltip */ |
---|
[b4f28e0] | 1048 | toolbar->AddTool(wxID_FIND, wmsg(/*Find*/332), TOOL(find)/*, "Search for station name"*/); |
---|
[736f7df] | 1049 | /* TRANSLATORS: "Hide stations" button default tooltip */ |
---|
[b4f28e0] | 1050 | toolbar->AddTool(button_HIDE, wmsg(/*Hide*/333), TOOL(hideresults)/*, "Hide search results"*/); |
---|
[fd6e0d5] | 1051 | |
---|
[2d9ed8ad] | 1052 | toolbar->Realize(); |
---|
[9d3d8cc] | 1053 | } |
---|
[2d9ed8ad] | 1054 | |
---|
[9d3d8cc] | 1055 | void MainFrm::CreateSidePanel() |
---|
| 1056 | { |
---|
[b1de3e0] | 1057 | m_Splitter = new AvenSplitterWindow(this); |
---|
[421b7d2] | 1058 | |
---|
[203d2a7] | 1059 | m_Notebook = new wxNotebook(m_Splitter, 400, wxDefaultPosition, |
---|
[b63cf6cc] | 1060 | wxDefaultSize, |
---|
[4e98397] | 1061 | wxBK_BOTTOM | wxBK_LEFT); |
---|
[203d2a7] | 1062 | m_Notebook->Show(false); |
---|
[f433fda] | 1063 | |
---|
[1be3a88] | 1064 | wxPanel * panel = new wxPanel(m_Notebook); |
---|
| 1065 | m_Tree = new AvenTreeCtrl(this, panel); |
---|
[156dc16] | 1066 | |
---|
[429465a] | 1067 | // m_RegexpCheckBox = new wxCheckBox(find_panel, -1, |
---|
[ee7511a] | 1068 | // msg(/*Regular expression*/)); |
---|
[2c30188] | 1069 | |
---|
| 1070 | wxBoxSizer *panel_sizer = new wxBoxSizer(wxVERTICAL); |
---|
| 1071 | panel_sizer->Add(m_Tree, 1, wxALL | wxEXPAND, 2); |
---|
[1be3a88] | 1072 | panel->SetAutoLayout(true); |
---|
| 1073 | panel->SetSizer(panel_sizer); |
---|
| 1074 | // panel_sizer->SetSizeHints(panel); |
---|
[156dc16] | 1075 | |
---|
[5876fcb] | 1076 | m_Control = new GUIControl(); |
---|
| 1077 | m_Gfx = new GfxCore(this, m_Splitter, m_Control); |
---|
| 1078 | m_Control->SetView(m_Gfx); |
---|
[156dc16] | 1079 | |
---|
[203d2a7] | 1080 | // Presentation panel: |
---|
[1be3a88] | 1081 | wxPanel * prespanel = new wxPanel(m_Notebook); |
---|
[203d2a7] | 1082 | |
---|
[1be3a88] | 1083 | m_PresList = new AvenPresList(this, prespanel, m_Gfx); |
---|
[f433fda] | 1084 | |
---|
[203d2a7] | 1085 | wxBoxSizer *pres_panel_sizer = new wxBoxSizer(wxVERTICAL); |
---|
| 1086 | pres_panel_sizer->Add(m_PresList, 1, wxALL | wxEXPAND, 2); |
---|
[1be3a88] | 1087 | prespanel->SetAutoLayout(true); |
---|
| 1088 | prespanel->SetSizer(pres_panel_sizer); |
---|
[1690fa9] | 1089 | |
---|
[203d2a7] | 1090 | // Overall tabbed structure: |
---|
[c5032bb0] | 1091 | // FIXME: this assumes images are 15x15 |
---|
| 1092 | wxImageList* image_list = new wxImageList(15, 15); |
---|
[b4f28e0] | 1093 | image_list->Add(TOOL(survey_tree)); |
---|
| 1094 | image_list->Add(TOOL(pres_tree)); |
---|
[203d2a7] | 1095 | m_Notebook->SetImageList(image_list); |
---|
[736f7df] | 1096 | /* TRANSLATORS: labels for tabbed side panel this is for the tab with the |
---|
| 1097 | * tree hierarchy of survey station names */ |
---|
[5627cbb] | 1098 | m_Notebook->AddPage(panel, wmsg(/*Surveys*/376), true, 0); |
---|
| 1099 | m_Notebook->AddPage(prespanel, wmsg(/*Presentation*/377), false, 1); |
---|
[203d2a7] | 1100 | |
---|
[e9b97eb] | 1101 | m_Splitter->Initialize(m_Gfx); |
---|
[068b4f2] | 1102 | } |
---|
[137bf99] | 1103 | |
---|
[5f06d2c] | 1104 | bool MainFrm::LoadData(const wxString& file, const wxString & prefix) |
---|
[b88b171] | 1105 | { |
---|
[137bf99] | 1106 | // Load survey data from file, centre the dataset around the origin, |
---|
[f4fae12] | 1107 | // and prepare the data for drawing. |
---|
[137bf99] | 1108 | |
---|
[c9427d2] | 1109 | #if 0 |
---|
| 1110 | wxStopWatch timer; |
---|
| 1111 | timer.Start(); |
---|
| 1112 | #endif |
---|
[b88b171] | 1113 | |
---|
[bc73093] | 1114 | // Load the processed survey data. |
---|
[318ac31] | 1115 | img* survey = img_open_survey(file.mb_str(), prefix.mb_str()); |
---|
[137bf99] | 1116 | if (!survey) { |
---|
[4d7d209] | 1117 | wxString m = wxString::Format(wmsg(img_error2msg(img_error())), file.c_str()); |
---|
[421b7d2] | 1118 | wxGetApp().ReportError(m); |
---|
| 1119 | return false; |
---|
[137bf99] | 1120 | } |
---|
[1d0cd97] | 1121 | |
---|
[eef68f9] | 1122 | m_IsExtendedElevation = survey->is_extended_elevation; |
---|
[156dc16] | 1123 | |
---|
[9f176bd] | 1124 | m_Tree->DeleteAllItems(); |
---|
| 1125 | |
---|
[1d0cd97] | 1126 | // Create a list of all the leg vertices, counting them and finding the |
---|
| 1127 | // extent of the survey at the same time. |
---|
| 1128 | |
---|
| 1129 | m_NumFixedPts = 0; |
---|
| 1130 | m_NumExportedPts = 0; |
---|
| 1131 | m_NumEntrances = 0; |
---|
[f433fda] | 1132 | m_HasUndergroundLegs = false; |
---|
[5fe7292] | 1133 | m_HasSplays = false; |
---|
[f433fda] | 1134 | m_HasSurfaceLegs = false; |
---|
[c61aa79] | 1135 | m_HasErrorInformation = false; |
---|
[1d0cd97] | 1136 | |
---|
[1690fa9] | 1137 | // FIXME: discard existing presentation? ask user about saving if we do! |
---|
[156dc16] | 1138 | |
---|
[1d0cd97] | 1139 | // Delete any existing list entries. |
---|
[0e6ee74] | 1140 | m_Labels.clear(); |
---|
[1d0cd97] | 1141 | |
---|
[a6f081c] | 1142 | Double xmin = DBL_MAX; |
---|
[1d0cd97] | 1143 | Double xmax = -DBL_MAX; |
---|
[a6f081c] | 1144 | Double ymin = DBL_MAX; |
---|
[1d0cd97] | 1145 | Double ymax = -DBL_MAX; |
---|
[78c67a6] | 1146 | Double zmin = DBL_MAX; |
---|
[1d0cd97] | 1147 | Double zmax = -DBL_MAX; |
---|
[78c67a6] | 1148 | |
---|
| 1149 | m_DepthMin = DBL_MAX; |
---|
| 1150 | Double depthmax = -DBL_MAX; |
---|
| 1151 | |
---|
[1ee204e] | 1152 | m_DateMin = INT_MAX; |
---|
[2043961] | 1153 | int datemax = -1; |
---|
[a74b014] | 1154 | complete_dateinfo = true; |
---|
[1d0cd97] | 1155 | |
---|
[3ddcad8] | 1156 | traverses.clear(); |
---|
| 1157 | surface_traverses.clear(); |
---|
[ee05463] | 1158 | tubes.clear(); |
---|
[3ddcad8] | 1159 | |
---|
| 1160 | // Ultimately we probably want different types (subclasses perhaps?) for |
---|
| 1161 | // underground and surface data, so we don't need to store LRUD for surface |
---|
| 1162 | // stuff. |
---|
[c61aa79] | 1163 | traverse * current_traverse = NULL; |
---|
| 1164 | traverse * current_surface_traverse = NULL; |
---|
[ee05463] | 1165 | vector<XSect> * current_tube = NULL; |
---|
[1d0cd97] | 1166 | |
---|
[576e5a9] | 1167 | map<wxString, LabelInfo *> labelmap; |
---|
| 1168 | list<LabelInfo*>::const_iterator last_mapped_label = m_Labels.begin(); |
---|
| 1169 | |
---|
[1d0cd97] | 1170 | int result; |
---|
[3ddcad8] | 1171 | img_point prev_pt = {0,0,0}; |
---|
| 1172 | bool current_polyline_is_surface = false; |
---|
[8666fc7] | 1173 | bool current_polyline_is_splay = false; |
---|
[3ddcad8] | 1174 | bool pending_move = false; |
---|
[c61aa79] | 1175 | // When a traverse is split between surface and underground, we split it |
---|
| 1176 | // into contiguous traverses of each, but we need to track these so we can |
---|
| 1177 | // assign the error statistics to all of them. So we keep counts of how |
---|
| 1178 | // many surface_traverses and traverses we've generated for the current |
---|
| 1179 | // traverse. |
---|
| 1180 | size_t n_traverses = 0; |
---|
| 1181 | size_t n_surface_traverses = 0; |
---|
[1d0cd97] | 1182 | do { |
---|
[e9bd2800] | 1183 | #if 0 |
---|
[3ddcad8] | 1184 | if (++items % 200 == 0) { |
---|
[b63cf6cc] | 1185 | long pos = ftell(survey->fh); |
---|
| 1186 | int progress = int((double(pos) / double(file_size)) * 100.0); |
---|
[0580c6a] | 1187 | // SetProgress(progress); |
---|
[b63cf6cc] | 1188 | } |
---|
[e9bd2800] | 1189 | #endif |
---|
[203d2a7] | 1190 | |
---|
[421b7d2] | 1191 | img_point pt; |
---|
| 1192 | result = img_read_item(survey, &pt); |
---|
| 1193 | switch (result) { |
---|
| 1194 | case img_MOVE: |
---|
[c61aa79] | 1195 | n_traverses = n_surface_traverses = 0; |
---|
[3ddcad8] | 1196 | pending_move = true; |
---|
| 1197 | prev_pt = pt; |
---|
| 1198 | break; |
---|
[421b7d2] | 1199 | |
---|
[3ddcad8] | 1200 | case img_LINE: { |
---|
[421b7d2] | 1201 | // Update survey extents. |
---|
[a6f081c] | 1202 | if (pt.x < xmin) xmin = pt.x; |
---|
[421b7d2] | 1203 | if (pt.x > xmax) xmax = pt.x; |
---|
[a6f081c] | 1204 | if (pt.y < ymin) ymin = pt.y; |
---|
[421b7d2] | 1205 | if (pt.y > ymax) ymax = pt.y; |
---|
[78c67a6] | 1206 | if (pt.z < zmin) zmin = pt.z; |
---|
[421b7d2] | 1207 | if (pt.z > zmax) zmax = pt.z; |
---|
| 1208 | |
---|
[1ee204e] | 1209 | int date = survey->days1; |
---|
| 1210 | if (date != -1) { |
---|
| 1211 | date += (survey->days2 - date) / 2; |
---|
[d4650b3] | 1212 | if (date < m_DateMin) m_DateMin = date; |
---|
| 1213 | if (date > datemax) datemax = date; |
---|
[a74b014] | 1214 | } else { |
---|
| 1215 | complete_dateinfo = false; |
---|
[d4650b3] | 1216 | } |
---|
| 1217 | |
---|
[5fe7292] | 1218 | if (survey->flags & img_FLAG_SPLAY) |
---|
| 1219 | m_HasSplays = true; |
---|
[3ddcad8] | 1220 | bool is_surface = (survey->flags & img_FLAG_SURFACE); |
---|
[8666fc7] | 1221 | bool is_splay = (survey->flags & img_FLAG_SPLAY); |
---|
[78c67a6] | 1222 | if (!is_surface) { |
---|
| 1223 | if (pt.z < m_DepthMin) m_DepthMin = pt.z; |
---|
| 1224 | if (pt.z > depthmax) depthmax = pt.z; |
---|
| 1225 | } |
---|
[8666fc7] | 1226 | if (pending_move || current_polyline_is_surface != is_surface || current_polyline_is_splay != is_splay) { |
---|
[57a3cd4] | 1227 | if (!current_polyline_is_surface && current_traverse) { |
---|
[ee05463] | 1228 | //FixLRUD(*current_traverse); |
---|
[57a3cd4] | 1229 | } |
---|
[ad661cc] | 1230 | |
---|
[3ddcad8] | 1231 | // Start new traverse (surface or underground). |
---|
[f433fda] | 1232 | if (is_surface) { |
---|
| 1233 | m_HasSurfaceLegs = true; |
---|
[c61aa79] | 1234 | surface_traverses.push_back(traverse()); |
---|
[faae79c] | 1235 | current_surface_traverse = &surface_traverses.back(); |
---|
[c61aa79] | 1236 | ++n_surface_traverses; |
---|
[f433fda] | 1237 | } else { |
---|
| 1238 | m_HasUndergroundLegs = true; |
---|
[c61aa79] | 1239 | traverses.push_back(traverse()); |
---|
[3ddcad8] | 1240 | current_traverse = &traverses.back(); |
---|
[8666fc7] | 1241 | current_traverse->isSplay = is_splay; |
---|
[c61aa79] | 1242 | ++n_traverses; |
---|
[78c67a6] | 1243 | // The previous point was at a surface->ug transition. |
---|
[ad661cc] | 1244 | if (current_polyline_is_surface) { |
---|
[8666fc7] | 1245 | if (prev_pt.z < m_DepthMin) m_DepthMin = prev_pt.z; |
---|
| 1246 | if (prev_pt.z > depthmax) depthmax = prev_pt.z; |
---|
| 1247 | } |
---|
[3ddcad8] | 1248 | } |
---|
[8666fc7] | 1249 | |
---|
| 1250 | current_polyline_is_surface = is_surface; |
---|
| 1251 | current_polyline_is_splay = is_splay; |
---|
[ad661cc] | 1252 | |
---|
[3ddcad8] | 1253 | if (pending_move) { |
---|
[faae79c] | 1254 | // Update survey extents. We only need to do this if |
---|
| 1255 | // there's a pending move, since for a surface <-> |
---|
| 1256 | // underground transition, we'll already have handled |
---|
| 1257 | // this point. |
---|
[3ddcad8] | 1258 | if (prev_pt.x < xmin) xmin = prev_pt.x; |
---|
| 1259 | if (prev_pt.x > xmax) xmax = prev_pt.x; |
---|
| 1260 | if (prev_pt.y < ymin) ymin = prev_pt.y; |
---|
| 1261 | if (prev_pt.y > ymax) ymax = prev_pt.y; |
---|
[78c67a6] | 1262 | if (prev_pt.z < zmin) zmin = prev_pt.z; |
---|
[3ddcad8] | 1263 | if (prev_pt.z > zmax) zmax = prev_pt.z; |
---|
[faae79c] | 1264 | } |
---|
[3ddcad8] | 1265 | |
---|
[faae79c] | 1266 | if (is_surface) { |
---|
[d4650b3] | 1267 | current_surface_traverse->push_back(PointInfo(prev_pt)); |
---|
[faae79c] | 1268 | } else { |
---|
[d4650b3] | 1269 | current_traverse->push_back(PointInfo(prev_pt)); |
---|
[f433fda] | 1270 | } |
---|
[421b7d2] | 1271 | } |
---|
| 1272 | |
---|
[3ddcad8] | 1273 | if (is_surface) { |
---|
[d4650b3] | 1274 | current_surface_traverse->push_back(PointInfo(pt, date)); |
---|
[3ddcad8] | 1275 | } else { |
---|
[d4650b3] | 1276 | current_traverse->push_back(PointInfo(pt, date)); |
---|
[3ddcad8] | 1277 | } |
---|
| 1278 | |
---|
| 1279 | prev_pt = pt; |
---|
| 1280 | pending_move = false; |
---|
[421b7d2] | 1281 | break; |
---|
| 1282 | } |
---|
| 1283 | |
---|
[3ddcad8] | 1284 | case img_LABEL: { |
---|
[de402d4] | 1285 | wxString s(survey->label, wxConvUTF8); |
---|
| 1286 | if (s.empty()) { |
---|
| 1287 | // If label isn't valid UTF-8 then this conversion will |
---|
[457da16] | 1288 | // give an empty string. In this case, assume that the |
---|
| 1289 | // label is CP1252 (the Microsoft superset of ISO8859-1). |
---|
[de402d4] | 1290 | static wxCSConv ConvCP1252(wxFONTENCODING_CP1252); |
---|
| 1291 | s = wxString(survey->label, ConvCP1252); |
---|
[d43fa84] | 1292 | if (s.empty()) { |
---|
[457da16] | 1293 | // Or if that doesn't work (ConvCP1252 doesn't like |
---|
| 1294 | // strings with some bytes in) let's just go for |
---|
| 1295 | // ISO8859-1. |
---|
| 1296 | s = wxString(survey->label, wxConvISO8859_1); |
---|
[d43fa84] | 1297 | } |
---|
[de402d4] | 1298 | } |
---|
[dcbcae0] | 1299 | int flags = img2aven(survey->flags); |
---|
[de402d4] | 1300 | LabelInfo* label = new LabelInfo(pt, s, flags); |
---|
[421b7d2] | 1301 | if (label->IsEntrance()) { |
---|
| 1302 | m_NumEntrances++; |
---|
| 1303 | } |
---|
| 1304 | if (label->IsFixedPt()) { |
---|
| 1305 | m_NumFixedPts++; |
---|
| 1306 | } |
---|
| 1307 | if (label->IsExportedPt()) { |
---|
| 1308 | m_NumExportedPts++; |
---|
| 1309 | } |
---|
| 1310 | m_Labels.push_back(label); |
---|
| 1311 | break; |
---|
| 1312 | } |
---|
| 1313 | |
---|
[ee05463] | 1314 | case img_XSECT: { |
---|
| 1315 | if (!current_tube) { |
---|
| 1316 | // Start new current_tube. |
---|
| 1317 | tubes.push_back(vector<XSect>()); |
---|
| 1318 | current_tube = &tubes.back(); |
---|
| 1319 | } |
---|
| 1320 | |
---|
[576e5a9] | 1321 | LabelInfo * lab; |
---|
[5627cbb] | 1322 | wxString label(survey->label, wxConvUTF8); |
---|
[576e5a9] | 1323 | map<wxString, LabelInfo *>::const_iterator p; |
---|
| 1324 | p = labelmap.find(label); |
---|
| 1325 | if (p != labelmap.end()) { |
---|
| 1326 | lab = p->second; |
---|
| 1327 | } else { |
---|
| 1328 | // Initialise labelmap lazily - we may have no |
---|
| 1329 | // cross-sections. |
---|
| 1330 | list<LabelInfo*>::const_iterator i; |
---|
| 1331 | if (labelmap.empty()) { |
---|
| 1332 | i = m_Labels.begin(); |
---|
| 1333 | } else { |
---|
| 1334 | i = last_mapped_label; |
---|
| 1335 | ++i; |
---|
| 1336 | } |
---|
| 1337 | while (i != m_Labels.end() && (*i)->GetText() != label) { |
---|
| 1338 | labelmap[(*i)->GetText()] = *i; |
---|
| 1339 | ++i; |
---|
| 1340 | } |
---|
| 1341 | last_mapped_label = i; |
---|
| 1342 | if (i == m_Labels.end()) { |
---|
| 1343 | // Unattached cross-section - ignore for now. |
---|
| 1344 | printf("unattached cross-section\n"); |
---|
| 1345 | if (current_tube->size() <= 1) |
---|
| 1346 | tubes.resize(tubes.size() - 1); |
---|
| 1347 | current_tube = NULL; |
---|
| 1348 | if (!m_Labels.empty()) |
---|
| 1349 | --last_mapped_label; |
---|
| 1350 | break; |
---|
| 1351 | } |
---|
| 1352 | lab = *i; |
---|
| 1353 | labelmap[label] = lab; |
---|
[d7d7fa7] | 1354 | } |
---|
[ee05463] | 1355 | |
---|
[1ee204e] | 1356 | int date = survey->days1; |
---|
| 1357 | if (date != -1) { |
---|
| 1358 | date += (survey->days2 - date) / 2; |
---|
[d4650b3] | 1359 | if (date < m_DateMin) m_DateMin = date; |
---|
| 1360 | if (date > datemax) datemax = date; |
---|
| 1361 | } |
---|
| 1362 | |
---|
[576e5a9] | 1363 | current_tube->push_back(XSect(*lab, date, survey->l, survey->r, survey->u, survey->d)); |
---|
[ee05463] | 1364 | break; |
---|
| 1365 | } |
---|
| 1366 | |
---|
[d7d7fa7] | 1367 | case img_XSECT_END: |
---|
| 1368 | // Finish off current_tube. |
---|
| 1369 | // If there's only one cross-section in the tube, just |
---|
| 1370 | // discard it for now. FIXME: we should handle this |
---|
| 1371 | // when we come to skinning the tubes. |
---|
[ae2e3c0] | 1372 | if (current_tube && current_tube->size() <= 1) |
---|
[d7d7fa7] | 1373 | tubes.resize(tubes.size() - 1); |
---|
| 1374 | current_tube = NULL; |
---|
| 1375 | break; |
---|
| 1376 | |
---|
[c61aa79] | 1377 | case img_ERROR_INFO: { |
---|
[ed58edc] | 1378 | if (survey->E == 0.0) { |
---|
| 1379 | // Currently cavern doesn't spot all articulating traverses |
---|
| 1380 | // so we assume that any traverse with no error isn't part |
---|
| 1381 | // of a loop. FIXME: fix cavern! |
---|
| 1382 | break; |
---|
| 1383 | } |
---|
[c61aa79] | 1384 | m_HasErrorInformation = true; |
---|
| 1385 | list<traverse>::reverse_iterator t; |
---|
| 1386 | t = surface_traverses.rbegin(); |
---|
| 1387 | while (n_surface_traverses) { |
---|
| 1388 | assert(t != surface_traverses.rend()); |
---|
| 1389 | t->n_legs = survey->n_legs; |
---|
| 1390 | t->length = survey->length; |
---|
| 1391 | t->E = survey->E; |
---|
| 1392 | t->H = survey->H; |
---|
| 1393 | t->V = survey->V; |
---|
| 1394 | --n_surface_traverses; |
---|
| 1395 | ++t; |
---|
| 1396 | } |
---|
| 1397 | t = traverses.rbegin(); |
---|
| 1398 | while (n_traverses) { |
---|
| 1399 | assert(t != traverses.rend()); |
---|
| 1400 | t->n_legs = survey->n_legs; |
---|
| 1401 | t->length = survey->length; |
---|
| 1402 | t->E = survey->E; |
---|
| 1403 | t->H = survey->H; |
---|
| 1404 | t->V = survey->V; |
---|
| 1405 | --n_traverses; |
---|
| 1406 | ++t; |
---|
| 1407 | } |
---|
| 1408 | break; |
---|
| 1409 | } |
---|
| 1410 | |
---|
[3ddcad8] | 1411 | case img_BAD: { |
---|
[421b7d2] | 1412 | m_Labels.clear(); |
---|
| 1413 | |
---|
| 1414 | // FIXME: Do we need to reset all these? - Olly |
---|
| 1415 | m_NumFixedPts = 0; |
---|
| 1416 | m_NumExportedPts = 0; |
---|
| 1417 | m_NumEntrances = 0; |
---|
[f433fda] | 1418 | m_HasUndergroundLegs = false; |
---|
[5fe7292] | 1419 | m_HasSplays = false; |
---|
[f433fda] | 1420 | m_HasSurfaceLegs = false; |
---|
[421b7d2] | 1421 | |
---|
| 1422 | img_close(survey); |
---|
| 1423 | |
---|
[4d7d209] | 1424 | wxString m = wxString::Format(wmsg(img_error2msg(img_error())), file.c_str()); |
---|
[421b7d2] | 1425 | wxGetApp().ReportError(m); |
---|
[dc1a546] | 1426 | |
---|
[421b7d2] | 1427 | return false; |
---|
| 1428 | } |
---|
| 1429 | |
---|
| 1430 | default: |
---|
| 1431 | break; |
---|
| 1432 | } |
---|
[1d0cd97] | 1433 | } while (result != img_STOP); |
---|
[c1cf79d] | 1434 | |
---|
[57a3cd4] | 1435 | if (!current_polyline_is_surface && current_traverse) { |
---|
[ee05463] | 1436 | //FixLRUD(*current_traverse); |
---|
[57a3cd4] | 1437 | } |
---|
| 1438 | |
---|
[d7d7fa7] | 1439 | // Finish off current_tube. |
---|
| 1440 | // If there's only one cross-section in the tube, just |
---|
| 1441 | // discard it for now. FIXME: we should handle this |
---|
| 1442 | // when we come to skinning the tubes. |
---|
[ae2e3c0] | 1443 | if (current_tube && current_tube->size() <= 1) |
---|
[d7d7fa7] | 1444 | tubes.resize(tubes.size() - 1); |
---|
[ee05463] | 1445 | |
---|
[ee1ec59] | 1446 | separator = survey->separator; |
---|
[5627cbb] | 1447 | m_Title = wxString(survey->title, wxConvUTF8); |
---|
[f10cf8f] | 1448 | m_DateStamp_numeric = survey->datestamp_numeric; |
---|
[6d3938b] | 1449 | if (survey->cs) { |
---|
[7b9b700] | 1450 | m_cs_proj = wxString(survey->cs, wxConvUTF8); |
---|
[6d3938b] | 1451 | } else { |
---|
| 1452 | m_cs_proj = wxString(); |
---|
| 1453 | } |
---|
[42bd3576] | 1454 | if (strcmp(survey->datestamp, "?") == 0) { |
---|
[736f7df] | 1455 | /* TRANSLATORS: used a processed survey with no processing date/time info */ |
---|
[42bd3576] | 1456 | m_DateStamp = wmsg(/*Date and time not available.*/108); |
---|
| 1457 | } else if (survey->datestamp[0] == '@') { |
---|
[f10cf8f] | 1458 | const struct tm * tm = localtime(&m_DateStamp_numeric); |
---|
[4f70ebc] | 1459 | char buf[256]; |
---|
[736f7df] | 1460 | /* TRANSLATORS: This is the date format string used to timestamp .3d |
---|
| 1461 | * files internally. Probably best to keep it the same for all |
---|
| 1462 | * translations. */ |
---|
[4f70ebc] | 1463 | strftime(buf, 256, msg(/*%a,%Y.%m.%d %H:%M:%S %Z*/107), tm); |
---|
| 1464 | m_DateStamp = wxString(buf, wxConvUTF8); |
---|
[42bd3576] | 1465 | } |
---|
| 1466 | if (m_DateStamp.empty()) { |
---|
| 1467 | m_DateStamp = wxString(survey->datestamp, wxConvUTF8); |
---|
| 1468 | } |
---|
[1d0cd97] | 1469 | img_close(survey); |
---|
[137bf99] | 1470 | |
---|
[1d0cd97] | 1471 | // Check we've actually loaded some legs or stations! |
---|
[f433fda] | 1472 | if (!m_HasUndergroundLegs && !m_HasSurfaceLegs && m_Labels.empty()) { |
---|
[0804fbe] | 1473 | wxString m = wxString::Format(wmsg(/*No survey data in 3d file “%s”*/202), file.c_str()); |
---|
[421b7d2] | 1474 | wxGetApp().ReportError(m); |
---|
| 1475 | return false; |
---|
[1d0cd97] | 1476 | } |
---|
[137bf99] | 1477 | |
---|
[3ddcad8] | 1478 | if (traverses.empty() && surface_traverses.empty()) { |
---|
[421b7d2] | 1479 | // No legs, so get survey extents from stations |
---|
| 1480 | list<LabelInfo*>::const_iterator i; |
---|
| 1481 | for (i = m_Labels.begin(); i != m_Labels.end(); ++i) { |
---|
[5a24583] | 1482 | if ((*i)->GetX() < xmin) xmin = (*i)->GetX(); |
---|
| 1483 | if ((*i)->GetX() > xmax) xmax = (*i)->GetX(); |
---|
| 1484 | if ((*i)->GetY() < ymin) ymin = (*i)->GetY(); |
---|
| 1485 | if ((*i)->GetY() > ymax) ymax = (*i)->GetY(); |
---|
[78c67a6] | 1486 | if ((*i)->GetZ() < zmin) zmin = (*i)->GetZ(); |
---|
[5a24583] | 1487 | if ((*i)->GetZ() > zmax) zmax = (*i)->GetZ(); |
---|
[421b7d2] | 1488 | } |
---|
[137bf99] | 1489 | } |
---|
| 1490 | |
---|
[78c67a6] | 1491 | m_Ext.assign(xmax - xmin, ymax - ymin, zmax - zmin); |
---|
[1d0cd97] | 1492 | |
---|
[1ee204e] | 1493 | if (datemax < m_DateMin) m_DateMin = datemax; |
---|
[d4650b3] | 1494 | m_DateExt = datemax - m_DateMin; |
---|
| 1495 | |
---|
[a6f081c] | 1496 | // Centre the dataset around the origin. |
---|
[78c67a6] | 1497 | CentreDataset(Vector3(xmin, ymin, zmin)); |
---|
| 1498 | |
---|
| 1499 | if (depthmax < m_DepthMin) { |
---|
| 1500 | m_DepthMin = 0; |
---|
| 1501 | m_DepthExt = 0; |
---|
| 1502 | } else { |
---|
| 1503 | m_DepthExt = depthmax - m_DepthMin; |
---|
| 1504 | m_DepthMin -= m_Offsets.GetZ(); |
---|
| 1505 | } |
---|
[a6f081c] | 1506 | |
---|
[c9427d2] | 1507 | #if 0 |
---|
| 1508 | printf("time to load = %.3f\n", (double)timer.Time()); |
---|
| 1509 | #endif |
---|
| 1510 | |
---|
[1d0cd97] | 1511 | // Update window title. |
---|
[1d7f0fd] | 1512 | SetTitle(m_Title + " - "APP_NAME); |
---|
[1d0cd97] | 1513 | |
---|
[d7b53e3] | 1514 | // Sort the labels ready for filling the tree. |
---|
| 1515 | m_Labels.sort(LabelCmp(separator)); |
---|
| 1516 | |
---|
| 1517 | // Fill the tree of stations and prefixes. |
---|
| 1518 | FillTree(wxFileNameFromPath(file)); |
---|
| 1519 | |
---|
| 1520 | // Sort labels so that entrances are displayed in preference, |
---|
| 1521 | // then fixed points, then exported points, then other points. |
---|
| 1522 | // |
---|
| 1523 | // Also sort by leaf name so that we'll tend to choose labels |
---|
| 1524 | // from different surveys, rather than labels from surveys which |
---|
| 1525 | // are earlier in the list. |
---|
| 1526 | m_Labels.sort(LabelPlotCmp(separator)); |
---|
| 1527 | |
---|
| 1528 | if (!m_FindBox->GetValue().empty()) { |
---|
| 1529 | // Highlight any stations matching the current search. |
---|
| 1530 | DoFind(); |
---|
| 1531 | } |
---|
| 1532 | |
---|
[1d0cd97] | 1533 | return true; |
---|
[f626e1f] | 1534 | } |
---|
| 1535 | |
---|
[d4650b3] | 1536 | #if 0 |
---|
[57a3cd4] | 1537 | // Run along a newly read in traverse and make up plausible LRUD where |
---|
| 1538 | // it is missing. |
---|
| 1539 | void |
---|
[c61aa79] | 1540 | MainFrm::FixLRUD(traverse & centreline) |
---|
[57a3cd4] | 1541 | { |
---|
| 1542 | assert(centreline.size() > 1); |
---|
| 1543 | |
---|
| 1544 | Double last_size = 0; |
---|
[d4650b3] | 1545 | vector<PointInfo>::iterator i = centreline.begin(); |
---|
[57a3cd4] | 1546 | while (i != centreline.end()) { |
---|
[4c9e87b] | 1547 | // Get the coordinates of this vertex. |
---|
[db36155] | 1548 | Point & pt_v = *i++; |
---|
[57a3cd4] | 1549 | Double size; |
---|
| 1550 | |
---|
| 1551 | if (i != centreline.end()) { |
---|
| 1552 | Double h = sqrd(i->GetX() - pt_v.GetX()) + |
---|
| 1553 | sqrd(i->GetY() - pt_v.GetY()); |
---|
| 1554 | Double v = sqrd(i->GetZ() - pt_v.GetZ()); |
---|
| 1555 | if (h + v > 30.0 * 30.0) { |
---|
| 1556 | Double scale = 30.0 / sqrt(h + v); |
---|
| 1557 | h *= scale; |
---|
| 1558 | v *= scale; |
---|
| 1559 | } |
---|
| 1560 | size = sqrt(h + v / 9); |
---|
| 1561 | size /= 4; |
---|
| 1562 | if (i == centreline.begin() + 1) { |
---|
| 1563 | // First segment. |
---|
| 1564 | last_size = size; |
---|
| 1565 | } else { |
---|
| 1566 | // Intermediate segment. |
---|
| 1567 | swap(size, last_size); |
---|
| 1568 | size += last_size; |
---|
| 1569 | size /= 2; |
---|
| 1570 | } |
---|
| 1571 | } else { |
---|
| 1572 | // Last segment. |
---|
| 1573 | size = last_size; |
---|
| 1574 | } |
---|
| 1575 | |
---|
| 1576 | Double & l = pt_v.l; |
---|
| 1577 | Double & r = pt_v.r; |
---|
| 1578 | Double & u = pt_v.u; |
---|
| 1579 | Double & d = pt_v.d; |
---|
| 1580 | |
---|
| 1581 | if (l == 0 && r == 0 && u == 0 && d == 0) { |
---|
| 1582 | l = r = u = d = -size; |
---|
| 1583 | } else { |
---|
| 1584 | if (l < 0 && r < 0) { |
---|
| 1585 | l = r = -size; |
---|
| 1586 | } else if (l < 0) { |
---|
| 1587 | l = -(2 * size - r); |
---|
| 1588 | if (l >= 0) l = -0.01; |
---|
| 1589 | } else if (r < 0) { |
---|
| 1590 | r = -(2 * size - l); |
---|
| 1591 | if (r >= 0) r = -0.01; |
---|
| 1592 | } |
---|
| 1593 | if (u < 0 && d < 0) { |
---|
| 1594 | u = d = -size; |
---|
| 1595 | } else if (u < 0) { |
---|
| 1596 | u = -(2 * size - d); |
---|
| 1597 | if (u >= 0) u = -0.01; |
---|
| 1598 | } else if (d < 0) { |
---|
| 1599 | d = -(2 * size - u); |
---|
| 1600 | if (d >= 0) d = -0.01; |
---|
| 1601 | } |
---|
| 1602 | } |
---|
| 1603 | } |
---|
| 1604 | } |
---|
[d4650b3] | 1605 | #endif |
---|
[57a3cd4] | 1606 | |
---|
[d7b53e3] | 1607 | void MainFrm::FillTree(const wxString & root_name) |
---|
[156dc16] | 1608 | { |
---|
[91c9bea] | 1609 | // Create the root of the tree. |
---|
[d7b53e3] | 1610 | wxTreeItemId treeroot = m_Tree->AddRoot(root_name); |
---|
[156dc16] | 1611 | |
---|
[91c9bea] | 1612 | // Fill the tree of stations and prefixes. |
---|
[156dc16] | 1613 | stack<wxTreeItemId> previous_ids; |
---|
[5627cbb] | 1614 | wxString current_prefix; |
---|
[91c9bea] | 1615 | wxTreeItemId current_id = treeroot; |
---|
[156dc16] | 1616 | |
---|
[86cdcf2] | 1617 | list<LabelInfo*>::iterator pos = m_Labels.begin(); |
---|
[156dc16] | 1618 | while (pos != m_Labels.end()) { |
---|
[421b7d2] | 1619 | LabelInfo* label = *pos++; |
---|
[156dc16] | 1620 | |
---|
[d309e17] | 1621 | if (label->IsAnon()) continue; |
---|
| 1622 | |
---|
[421b7d2] | 1623 | // Determine the current prefix. |
---|
[ee1ec59] | 1624 | wxString prefix = label->GetText().BeforeLast(separator); |
---|
[9d3d8cc] | 1625 | |
---|
[421b7d2] | 1626 | // Determine if we're still on the same prefix. |
---|
| 1627 | if (prefix == current_prefix) { |
---|
| 1628 | // no need to fiddle with branches... |
---|
| 1629 | } |
---|
| 1630 | // If not, then see if we've descended to a new prefix. |
---|
[4252768] | 1631 | else if (prefix.length() > current_prefix.length() && |
---|
[003d953] | 1632 | prefix.StartsWith(current_prefix) && |
---|
[4252768] | 1633 | (prefix[current_prefix.length()] == separator || |
---|
[5627cbb] | 1634 | current_prefix.empty())) { |
---|
[421b7d2] | 1635 | // We have, so start as many new branches as required. |
---|
[4252768] | 1636 | int current_prefix_length = current_prefix.length(); |
---|
[421b7d2] | 1637 | current_prefix = prefix; |
---|
[05b5d5b] | 1638 | size_t next_dot = current_prefix_length; |
---|
| 1639 | if (!next_dot) --next_dot; |
---|
[421b7d2] | 1640 | do { |
---|
[44ed489] | 1641 | size_t prev_dot = next_dot + 1; |
---|
| 1642 | |
---|
[421b7d2] | 1643 | // Extract the next bit of prefix. |
---|
[44ed489] | 1644 | next_dot = prefix.find(separator, prev_dot + 1); |
---|
[421b7d2] | 1645 | |
---|
[44ed489] | 1646 | wxString bit = prefix.substr(prev_dot, next_dot - prev_dot); |
---|
[5627cbb] | 1647 | assert(!bit.empty()); |
---|
[421b7d2] | 1648 | |
---|
| 1649 | // Add the current tree ID to the stack. |
---|
| 1650 | previous_ids.push(current_id); |
---|
| 1651 | |
---|
| 1652 | // Append the new item to the tree and set this as the current branch. |
---|
| 1653 | current_id = m_Tree->AppendItem(current_id, bit); |
---|
[44ed489] | 1654 | m_Tree->SetItemData(current_id, new TreeData(prefix.substr(0, next_dot))); |
---|
| 1655 | } while (next_dot != wxString::npos); |
---|
[421b7d2] | 1656 | } |
---|
| 1657 | // Otherwise, we must have moved up, and possibly then down again. |
---|
| 1658 | else { |
---|
[dc8d2eb] | 1659 | size_t count = 0; |
---|
[4252768] | 1660 | bool ascent_only = (prefix.length() < current_prefix.length() && |
---|
[421b7d2] | 1661 | current_prefix.StartsWith(prefix) && |
---|
[4252768] | 1662 | (current_prefix[prefix.length()] == separator || |
---|
[5627cbb] | 1663 | prefix.empty())); |
---|
[421b7d2] | 1664 | if (!ascent_only) { |
---|
[7d9e02b] | 1665 | // Find out how much of the current prefix and the new prefix |
---|
| 1666 | // are the same. |
---|
| 1667 | // Note that we require a match of a whole number of parts |
---|
| 1668 | // between dots! |
---|
[17de0e2] | 1669 | size_t n = min(prefix.length(), current_prefix.length()); |
---|
| 1670 | size_t i; |
---|
| 1671 | for (i = 0; i < n && prefix[i] == current_prefix[i]; ++i) { |
---|
[b4fe9fb] | 1672 | if (prefix[i] == separator) count = i + 1; |
---|
[421b7d2] | 1673 | } |
---|
[b4fe9fb] | 1674 | } else { |
---|
[4252768] | 1675 | count = prefix.length() + 1; |
---|
[421b7d2] | 1676 | } |
---|
| 1677 | |
---|
[7d9e02b] | 1678 | // Extract the part of the current prefix after the bit (if any) |
---|
| 1679 | // which has matched. |
---|
[421b7d2] | 1680 | // This gives the prefixes to ascend over. |
---|
[4252768] | 1681 | wxString prefixes_ascended = current_prefix.substr(count); |
---|
[421b7d2] | 1682 | |
---|
| 1683 | // Count the number of prefixes to ascend over. |
---|
[ee1ec59] | 1684 | int num_prefixes = prefixes_ascended.Freq(separator); |
---|
[421b7d2] | 1685 | |
---|
| 1686 | // Reverse up over these prefixes. |
---|
| 1687 | for (int i = 1; i <= num_prefixes; i++) { |
---|
| 1688 | previous_ids.pop(); |
---|
| 1689 | } |
---|
[8734409] | 1690 | current_id = previous_ids.top(); |
---|
| 1691 | previous_ids.pop(); |
---|
[421b7d2] | 1692 | |
---|
| 1693 | if (!ascent_only) { |
---|
| 1694 | // Add branches for this new part. |
---|
[44ed489] | 1695 | size_t next_dot = count - 1; |
---|
| 1696 | do { |
---|
| 1697 | size_t prev_dot = next_dot + 1; |
---|
| 1698 | |
---|
[421b7d2] | 1699 | // Extract the next bit of prefix. |
---|
[44ed489] | 1700 | next_dot = prefix.find(separator, prev_dot + 1); |
---|
[421b7d2] | 1701 | |
---|
[44ed489] | 1702 | wxString bit = prefix.substr(prev_dot, next_dot - prev_dot); |
---|
[5627cbb] | 1703 | assert(!bit.empty()); |
---|
[421b7d2] | 1704 | |
---|
| 1705 | // Add the current tree ID to the stack. |
---|
| 1706 | previous_ids.push(current_id); |
---|
| 1707 | |
---|
[44ed489] | 1708 | // Append the new item to the tree and set this as the current branch. |
---|
[421b7d2] | 1709 | current_id = m_Tree->AppendItem(current_id, bit); |
---|
[44ed489] | 1710 | m_Tree->SetItemData(current_id, new TreeData(prefix.substr(0, next_dot))); |
---|
| 1711 | } while (next_dot != wxString::npos); |
---|
[421b7d2] | 1712 | } |
---|
| 1713 | |
---|
| 1714 | current_prefix = prefix; |
---|
| 1715 | } |
---|
| 1716 | |
---|
| 1717 | // Now add the leaf. |
---|
[ee1ec59] | 1718 | wxString bit = label->GetText().AfterLast(separator); |
---|
[5627cbb] | 1719 | assert(!bit.empty()); |
---|
[421b7d2] | 1720 | wxTreeItemId id = m_Tree->AppendItem(current_id, bit); |
---|
| 1721 | m_Tree->SetItemData(id, new TreeData(label)); |
---|
[91c9bea] | 1722 | label->tree_id = id; |
---|
| 1723 | // Set the colour for an item in the survey tree. |
---|
| 1724 | if (label->IsEntrance()) { |
---|
| 1725 | // Entrances are green (like entrance blobs). |
---|
[18886d7] | 1726 | m_Tree->SetItemTextColour(id, wxColour(0, 255, 40)); |
---|
[91c9bea] | 1727 | } else if (label->IsSurface()) { |
---|
| 1728 | // Surface stations are dark green. |
---|
| 1729 | m_Tree->SetItemTextColour(id, wxColour(49, 158, 79)); |
---|
| 1730 | } |
---|
[156dc16] | 1731 | } |
---|
[91c9bea] | 1732 | |
---|
| 1733 | m_Tree->Expand(treeroot); |
---|
| 1734 | m_Tree->SetEnabled(); |
---|
[156dc16] | 1735 | } |
---|
| 1736 | |
---|
[d67450e] | 1737 | void MainFrm::CentreDataset(const Vector3 & vmin) |
---|
[a6f081c] | 1738 | { |
---|
| 1739 | // Centre the dataset around the origin. |
---|
| 1740 | |
---|
[d67450e] | 1741 | m_Offsets = vmin + (m_Ext * 0.5); |
---|
[a6f081c] | 1742 | |
---|
[c61aa79] | 1743 | list<traverse>::iterator t = traverses.begin(); |
---|
[3ddcad8] | 1744 | while (t != traverses.end()) { |
---|
[faae79c] | 1745 | assert(t->size() > 1); |
---|
[d4650b3] | 1746 | vector<PointInfo>::iterator pos = t->begin(); |
---|
[3ddcad8] | 1747 | while (pos != t->end()) { |
---|
[db36155] | 1748 | Point & point = *pos++; |
---|
[d67450e] | 1749 | point -= m_Offsets; |
---|
[3ddcad8] | 1750 | } |
---|
| 1751 | ++t; |
---|
| 1752 | } |
---|
| 1753 | |
---|
| 1754 | t = surface_traverses.begin(); |
---|
| 1755 | while (t != surface_traverses.end()) { |
---|
[faae79c] | 1756 | assert(t->size() > 1); |
---|
[d4650b3] | 1757 | vector<PointInfo>::iterator pos = t->begin(); |
---|
[3ddcad8] | 1758 | while (pos != t->end()) { |
---|
[db36155] | 1759 | Point & point = *pos++; |
---|
[d67450e] | 1760 | point -= m_Offsets; |
---|
[3ddcad8] | 1761 | } |
---|
| 1762 | ++t; |
---|
[a6f081c] | 1763 | } |
---|
| 1764 | |
---|
[ee05463] | 1765 | list<vector<XSect> >::iterator i = tubes.begin(); |
---|
| 1766 | while (i != tubes.end()) { |
---|
| 1767 | assert(i->size() > 1); |
---|
| 1768 | vector<XSect>::iterator pos = i->begin(); |
---|
| 1769 | while (pos != i->end()) { |
---|
[d4650b3] | 1770 | Point & point = *pos++; |
---|
[d67450e] | 1771 | point -= m_Offsets; |
---|
[ee05463] | 1772 | } |
---|
| 1773 | ++i; |
---|
| 1774 | } |
---|
| 1775 | |
---|
[a6f081c] | 1776 | list<LabelInfo*>::iterator lpos = m_Labels.begin(); |
---|
| 1777 | while (lpos != m_Labels.end()) { |
---|
[d4650b3] | 1778 | Point & point = **lpos++; |
---|
[d67450e] | 1779 | point -= m_Offsets; |
---|
[a6f081c] | 1780 | } |
---|
| 1781 | } |
---|
| 1782 | |
---|
[732b9b0] | 1783 | void MainFrm::OnMRUFile(wxCommandEvent& event) |
---|
| 1784 | { |
---|
| 1785 | wxString f(m_history.GetHistoryFile(event.GetId() - wxID_FILE1)); |
---|
| 1786 | if (!f.empty()) OpenFile(f); |
---|
| 1787 | } |
---|
| 1788 | |
---|
[bc73093] | 1789 | void MainFrm::AddToFileHistory(const wxString & file) |
---|
| 1790 | { |
---|
| 1791 | if (wxIsAbsolutePath(file)) { |
---|
| 1792 | m_history.AddFileToHistory(file); |
---|
| 1793 | } else { |
---|
| 1794 | wxString abs = wxGetCwd(); |
---|
| 1795 | abs += wxCONFIG_PATH_SEPARATOR; |
---|
| 1796 | abs += file; |
---|
| 1797 | m_history.AddFileToHistory(abs); |
---|
| 1798 | } |
---|
| 1799 | wxConfigBase *b = wxConfigBase::Get(); |
---|
| 1800 | m_history.Save(*b); |
---|
| 1801 | b->Flush(); |
---|
| 1802 | } |
---|
| 1803 | |
---|
[5f06d2c] | 1804 | void MainFrm::OpenFile(const wxString& file, const wxString& survey) |
---|
[137bf99] | 1805 | { |
---|
[4b1fc48] | 1806 | wxBusyCursor hourglass; |
---|
[bc73093] | 1807 | |
---|
| 1808 | // Check if this is an unprocessed survey data file. |
---|
| 1809 | if (file.length() > 4 && file[file.length() - 4] == '.') { |
---|
| 1810 | wxString ext(file, file.length() - 3, 3); |
---|
| 1811 | ext.MakeLower(); |
---|
| 1812 | if (ext == wxT("svx") || ext == wxT("dat") || ext == wxT("mak")) { |
---|
[d7b53e3] | 1813 | CavernLogWindow * log = new CavernLogWindow(this, survey, m_Splitter); |
---|
[fb5887c] | 1814 | wxWindow * win = m_Splitter->GetWindow1(); |
---|
| 1815 | m_Splitter->ReplaceWindow(win, log); |
---|
| 1816 | if (m_Splitter->GetWindow2() == NULL) { |
---|
| 1817 | if (win != m_Gfx) win->Destroy(); |
---|
| 1818 | } else { |
---|
| 1819 | if (m_Splitter->IsSplit()) m_Splitter->Unsplit(); |
---|
| 1820 | } |
---|
| 1821 | |
---|
| 1822 | int result = log->process(file); |
---|
| 1823 | if (result < 0) { |
---|
| 1824 | // Error running cavern or processing data. |
---|
[bc73093] | 1825 | return; |
---|
| 1826 | } |
---|
[fb5887c] | 1827 | |
---|
[bc73093] | 1828 | AddToFileHistory(file); |
---|
| 1829 | wxString file3d(file, 0, file.length() - 3); |
---|
| 1830 | file3d.append(wxT("3d")); |
---|
| 1831 | if (!LoadData(file3d, survey)) |
---|
| 1832 | return; |
---|
[fb5887c] | 1833 | if (result == 0) { |
---|
| 1834 | InitialiseAfterLoad(file); |
---|
| 1835 | } |
---|
[bc73093] | 1836 | return; |
---|
[eb5b48df] | 1837 | } |
---|
[137bf99] | 1838 | } |
---|
[bc73093] | 1839 | |
---|
| 1840 | if (!LoadData(file, survey)) |
---|
| 1841 | return; |
---|
| 1842 | AddToFileHistory(file); |
---|
| 1843 | InitialiseAfterLoad(file); |
---|
[d7b53e3] | 1844 | |
---|
| 1845 | // If aven is showing the log for a .svx file and you load a .3d file, then |
---|
| 1846 | // at this point m_Log will be the log window for the .svx file, so destroy |
---|
| 1847 | // it - it should never legitimately be set if we get here. |
---|
| 1848 | if (m_Log) { |
---|
| 1849 | m_Log->Destroy(); |
---|
| 1850 | m_Log = NULL; |
---|
| 1851 | } |
---|
[bc73093] | 1852 | } |
---|
| 1853 | |
---|
| 1854 | void MainFrm::InitialiseAfterLoad(const wxString & file) |
---|
| 1855 | { |
---|
[486c619] | 1856 | if (m_SashPosition < 0) { |
---|
| 1857 | // Calculate sane default width for side panel. |
---|
| 1858 | int x; |
---|
| 1859 | int y; |
---|
| 1860 | GetClientSize(&x, &y); |
---|
| 1861 | if (x < 600) |
---|
| 1862 | x /= 3; |
---|
| 1863 | else if (x < 1000) |
---|
| 1864 | x = 200; |
---|
| 1865 | else |
---|
| 1866 | x /= 5; |
---|
| 1867 | m_SashPosition = x; |
---|
| 1868 | } |
---|
[bc73093] | 1869 | |
---|
[fb5887c] | 1870 | // Do this before we potentially delete the log window which may own the |
---|
| 1871 | // wxString which parameter file refers to! |
---|
[bc73093] | 1872 | bool same_file = (file == m_File); |
---|
| 1873 | if (!same_file) |
---|
| 1874 | m_File = file; |
---|
| 1875 | |
---|
[fb5887c] | 1876 | wxWindow * win = NULL; |
---|
| 1877 | if (m_Splitter->GetWindow2() == NULL) { |
---|
| 1878 | win = m_Splitter->GetWindow1(); |
---|
| 1879 | if (win == m_Gfx) win = NULL; |
---|
| 1880 | } |
---|
| 1881 | |
---|
[486c619] | 1882 | if (!IsFullScreen()) { |
---|
| 1883 | m_Splitter->SplitVertically(m_Notebook, m_Gfx, m_SashPosition); |
---|
| 1884 | } else { |
---|
| 1885 | was_showing_sidepanel_before_fullscreen = true; |
---|
| 1886 | } |
---|
[fb5887c] | 1887 | |
---|
[bc73093] | 1888 | m_Gfx->Initialise(same_file); |
---|
[d7b53e3] | 1889 | |
---|
| 1890 | if (win) { |
---|
| 1891 | // FIXME: check it actually is the log window! |
---|
| 1892 | if (m_Log && m_Log != win) |
---|
| 1893 | m_Log->Destroy(); |
---|
| 1894 | m_Log = win; |
---|
| 1895 | m_Log->Show(false); |
---|
| 1896 | } |
---|
| 1897 | |
---|
[486c619] | 1898 | if (!IsFullScreen()) { |
---|
| 1899 | m_Notebook->Show(true); |
---|
| 1900 | } |
---|
[bc73093] | 1901 | |
---|
| 1902 | m_Gfx->Show(true); |
---|
| 1903 | m_Gfx->SetFocus(); |
---|
[d7b53e3] | 1904 | } |
---|
[fb5887c] | 1905 | |
---|
[d7b53e3] | 1906 | void MainFrm::HideLog(wxWindow * log_window) |
---|
| 1907 | { |
---|
| 1908 | if (!IsFullScreen()) { |
---|
| 1909 | m_Splitter->SplitVertically(m_Notebook, m_Gfx, m_SashPosition); |
---|
| 1910 | } |
---|
| 1911 | |
---|
| 1912 | m_Log = log_window; |
---|
| 1913 | m_Log->Show(false); |
---|
| 1914 | |
---|
| 1915 | if (!IsFullScreen()) { |
---|
| 1916 | m_Notebook->Show(true); |
---|
| 1917 | } |
---|
| 1918 | |
---|
| 1919 | m_Gfx->Show(true); |
---|
| 1920 | m_Gfx->SetFocus(); |
---|
[137bf99] | 1921 | } |
---|
| 1922 | |
---|
| 1923 | // |
---|
| 1924 | // UI event handlers |
---|
| 1925 | // |
---|
| 1926 | |
---|
[c988ae4] | 1927 | // For Unix we want "*.svx;*.SVX" while for Windows we only want "*.svx". |
---|
| 1928 | #ifdef _WIN32 |
---|
| 1929 | # define CASE(X) |
---|
| 1930 | #else |
---|
| 1931 | # define CASE(X) ";"X |
---|
[496a208] | 1932 | #endif |
---|
| 1933 | |
---|
[137bf99] | 1934 | void MainFrm::OnOpen(wxCommandEvent&) |
---|
| 1935 | { |
---|
[1c6b20d7] | 1936 | AvenAllowOnTop ontop(this); |
---|
[137bf99] | 1937 | #ifdef __WXMOTIF__ |
---|
[5627cbb] | 1938 | wxString filetypes = wxT("*.3d"); |
---|
[137bf99] | 1939 | #else |
---|
[c988ae4] | 1940 | wxString filetypes; |
---|
[d9cd8ae] | 1941 | filetypes.Printf(wxT("%s|*.3d;*.svx;*.plt;*.plf;*.dat;*.mak;*.adj;*.sht;*.una;*.xyz" |
---|
| 1942 | CASE("*.3D;*.SVX;*.PLT;*.PLF;*.DAT;*.MAK;*.ADJ;*.SHT;*.UNA;*.XYZ") |
---|
[71de189] | 1943 | "|%s|*.3d"CASE("*.3D") |
---|
[c988ae4] | 1944 | "|%s|*.svx"CASE("*.SVX") |
---|
| 1945 | "|%s|*.plt;*.plf"CASE("*.PLT;*.PLF") |
---|
| 1946 | "|%s|*.dat;*.mak"CASE("*.DAT;*.MAK") |
---|
[d9cd8ae] | 1947 | "|%s|*.adj;*.sht;*.una;*.xyz"CASE("*.ADJ;*.SHT;*.UNA;*.XYZ") |
---|
[5627cbb] | 1948 | "|%s|%s"), |
---|
[736f7df] | 1949 | /* TRANSLATORS: Here "survey" is a "cave map" rather than |
---|
| 1950 | * list of questions - it should be translated to the |
---|
| 1951 | * terminology that cavers using the language would use. |
---|
| 1952 | */ |
---|
[6e63fd3] | 1953 | wmsg(/*All survey files*/229).c_str(), |
---|
[0b8c321] | 1954 | /* TRANSLATORS: Survex is the name of the software, and "3d" refers to a |
---|
| 1955 | * file extension, so neither should be translated. */ |
---|
[5627cbb] | 1956 | wmsg(/*Survex 3d files*/207).c_str(), |
---|
[0b8c321] | 1957 | /* TRANSLATORS: Survex is the name of the software, and "svx" refers to a |
---|
| 1958 | * file extension, so neither should be translated. */ |
---|
[6e63fd3] | 1959 | wmsg(/*Survex svx files*/329).c_str(), |
---|
[736f7df] | 1960 | /* TRANSLATORS: "Compass" as in Larry Fish’s cave |
---|
| 1961 | * surveying package, so probably shouldn’t be translated |
---|
| 1962 | */ |
---|
[5627cbb] | 1963 | wmsg(/*Compass PLT files*/324).c_str(), |
---|
[736f7df] | 1964 | /* TRANSLATORS: "Compass" as in Larry Fish’s cave |
---|
[0b8c321] | 1965 | * surveying package, so should not be translated |
---|
[736f7df] | 1966 | */ |
---|
[6e63fd3] | 1967 | wmsg(/*Compass DAT and MAK files*/330).c_str(), |
---|
[736f7df] | 1968 | /* TRANSLATORS: "CMAP" is Bob Thrun’s cave surveying |
---|
| 1969 | * package, so don’t translate it. */ |
---|
[5627cbb] | 1970 | wmsg(/*CMAP XYZ files*/325).c_str(), |
---|
| 1971 | wmsg(/*All files*/208).c_str(), |
---|
[c988ae4] | 1972 | wxFileSelectorDefaultWildcardStr); |
---|
[5627cbb] | 1973 | #endif |
---|
[736f7df] | 1974 | /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions |
---|
| 1975 | * - it should be translated to the terminology that cavers using the |
---|
| 1976 | * language would use. |
---|
| 1977 | * |
---|
| 1978 | * File->Open dialog: */ |
---|
[6e63fd3] | 1979 | wxFileDialog dlg(this, wmsg(/*Select a survey file to view*/206), |
---|
[5627cbb] | 1980 | wxString(), wxString(), |
---|
[c988ae4] | 1981 | filetypes, wxFD_OPEN|wxFD_FILE_MUST_EXIST); |
---|
[137bf99] | 1982 | if (dlg.ShowModal() == wxID_OK) { |
---|
[421b7d2] | 1983 | OpenFile(dlg.GetPath()); |
---|
[137bf99] | 1984 | } |
---|
| 1985 | } |
---|
| 1986 | |
---|
[d7b53e3] | 1987 | void MainFrm::OnShowLog(wxCommandEvent&) |
---|
| 1988 | { |
---|
| 1989 | if (!m_Log) return; |
---|
| 1990 | wxWindow * win = m_Splitter->GetWindow1(); |
---|
| 1991 | m_Splitter->ReplaceWindow(win, m_Log); |
---|
| 1992 | if (m_Splitter->IsSplit()) { |
---|
| 1993 | m_SashPosition = m_Splitter->GetSashPosition(); // save width of panel |
---|
| 1994 | m_Splitter->Unsplit(); |
---|
| 1995 | } |
---|
| 1996 | m_Log->Show(true); |
---|
| 1997 | m_Log->SetFocus(); |
---|
| 1998 | m_Log = NULL; |
---|
| 1999 | } |
---|
| 2000 | |
---|
[045e2af] | 2001 | void MainFrm::OnScreenshot(wxCommandEvent&) |
---|
| 2002 | { |
---|
[1c6b20d7] | 2003 | AvenAllowOnTop ontop(this); |
---|
[f302cbaa] | 2004 | wxString baseleaf; |
---|
| 2005 | wxFileName::SplitPath(m_File, NULL, NULL, &baseleaf, NULL, wxPATH_NATIVE); |
---|
[736f7df] | 2006 | /* TRANSLATORS: title of the save screenshot dialog */ |
---|
[5627cbb] | 2007 | wxFileDialog dlg(this, wmsg(/*Save Screenshot*/321), wxString(), |
---|
[f302cbaa] | 2008 | baseleaf + wxT(".png"), |
---|
[5627cbb] | 2009 | wxT("*.png"), wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
---|
[045e2af] | 2010 | if (dlg.ShowModal() == wxID_OK) { |
---|
| 2011 | static bool png_handled = false; |
---|
| 2012 | if (!png_handled) { |
---|
[4a0e6b35] | 2013 | #if 0 // FIXME : enable this to allow other export formats... |
---|
[ee41e88] | 2014 | ::wxInitAllImageHandlers(); |
---|
| 2015 | #else |
---|
[045e2af] | 2016 | wxImage::AddHandler(new wxPNGHandler); |
---|
[ee41e88] | 2017 | #endif |
---|
[045e2af] | 2018 | png_handled = true; |
---|
| 2019 | } |
---|
| 2020 | if (!m_Gfx->SaveScreenshot(dlg.GetPath(), wxBITMAP_TYPE_PNG)) { |
---|
[0804fbe] | 2021 | wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), dlg.GetPath().c_str())); |
---|
[045e2af] | 2022 | } |
---|
| 2023 | } |
---|
| 2024 | } |
---|
| 2025 | |
---|
| 2026 | void MainFrm::OnScreenshotUpdate(wxUpdateUIEvent& event) |
---|
| 2027 | { |
---|
| 2028 | event.Enable(!m_File.empty()); |
---|
| 2029 | } |
---|
| 2030 | |
---|
[02c7c1a] | 2031 | void MainFrm::OnFilePreferences(wxCommandEvent&) |
---|
| 2032 | { |
---|
[edb6576] | 2033 | #ifdef PREFDLG |
---|
[203d2a7] | 2034 | m_PrefsDlg = new PrefsDlg(m_Gfx, this); |
---|
[02c7c1a] | 2035 | m_PrefsDlg->Show(true); |
---|
[edb6576] | 2036 | #endif |
---|
[02c7c1a] | 2037 | } |
---|
[8000d8f] | 2038 | |
---|
[ce403f1] | 2039 | void MainFrm::OnPrint(wxCommandEvent&) |
---|
| 2040 | { |
---|
[6d3938b] | 2041 | m_Gfx->OnPrint(m_File, m_Title, m_DateStamp, m_DateStamp_numeric, m_cs_proj); |
---|
[ce403f1] | 2042 | } |
---|
| 2043 | |
---|
[4ed8154] | 2044 | void MainFrm::PrintAndExit() |
---|
| 2045 | { |
---|
[6d3938b] | 2046 | m_Gfx->OnPrint(m_File, m_Title, m_DateStamp, m_DateStamp_numeric, m_cs_proj, true); |
---|
[4ed8154] | 2047 | } |
---|
| 2048 | |
---|
[ce403f1] | 2049 | void MainFrm::OnPageSetup(wxCommandEvent&) |
---|
| 2050 | { |
---|
[e0ffc2c] | 2051 | wxPageSetupDialog dlg(this, wxGetApp().GetPageSetupDialogData()); |
---|
| 2052 | if (dlg.ShowModal() == wxID_OK) { |
---|
| 2053 | wxGetApp().SetPageSetupDialogData(dlg.GetPageSetupData()); |
---|
| 2054 | } |
---|
[ce403f1] | 2055 | } |
---|
| 2056 | |
---|
[223f1ad] | 2057 | void MainFrm::OnExport(wxCommandEvent&) |
---|
| 2058 | { |
---|
[6d3938b] | 2059 | m_Gfx->OnExport(m_File, m_Title, m_DateStamp, m_DateStamp_numeric, m_cs_proj); |
---|
[223f1ad] | 2060 | } |
---|
| 2061 | |
---|
[137bf99] | 2062 | void MainFrm::OnQuit(wxCommandEvent&) |
---|
| 2063 | { |
---|
[1690fa9] | 2064 | if (m_PresList->Modified()) { |
---|
[1c6b20d7] | 2065 | AvenAllowOnTop ontop(this); |
---|
[1690fa9] | 2066 | // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel] |
---|
[736f7df] | 2067 | /* TRANSLATORS: and the question in that box */ |
---|
[5627cbb] | 2068 | if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327), |
---|
[736f7df] | 2069 | /* TRANSLATORS: title of message box */ |
---|
[5627cbb] | 2070 | wmsg(/*Modified Presentation*/326), |
---|
[1690fa9] | 2071 | wxOK|wxCANCEL|wxICON_QUESTION) == wxCANCEL) { |
---|
| 2072 | return; |
---|
| 2073 | } |
---|
| 2074 | } |
---|
[3db0798] | 2075 | wxConfigBase *b = wxConfigBase::Get(); |
---|
| 2076 | if (IsFullScreen()) { |
---|
[5627cbb] | 2077 | b->Write(wxT("width"), -2); |
---|
| 2078 | b->DeleteEntry(wxT("height")); |
---|
[3db0798] | 2079 | } else if (IsMaximized()) { |
---|
[5627cbb] | 2080 | b->Write(wxT("width"), -1); |
---|
| 2081 | b->DeleteEntry(wxT("height")); |
---|
[3db0798] | 2082 | } else { |
---|
| 2083 | int width, height; |
---|
| 2084 | GetSize(&width, &height); |
---|
[5627cbb] | 2085 | b->Write(wxT("width"), width); |
---|
| 2086 | b->Write(wxT("height"), height); |
---|
[3db0798] | 2087 | } |
---|
| 2088 | b->Flush(); |
---|
[137bf99] | 2089 | exit(0); |
---|
| 2090 | } |
---|
| 2091 | |
---|
| 2092 | void MainFrm::OnClose(wxCloseEvent&) |
---|
| 2093 | { |
---|
[3db0798] | 2094 | wxCommandEvent dummy; |
---|
| 2095 | OnQuit(dummy); |
---|
[137bf99] | 2096 | } |
---|
| 2097 | |
---|
| 2098 | void MainFrm::OnAbout(wxCommandEvent&) |
---|
| 2099 | { |
---|
[1c6b20d7] | 2100 | AvenAllowOnTop ontop(this); |
---|
[261ab22] | 2101 | #ifdef __WXMAC__ |
---|
| 2102 | // GetIcon() returns an invalid wxIcon under OS X. |
---|
| 2103 | AboutDlg dlg(this, wxICON(aven)); |
---|
| 2104 | #else |
---|
[ea1ea51] | 2105 | AboutDlg dlg(this, GetIcon()); |
---|
[261ab22] | 2106 | #endif |
---|
[796aee3] | 2107 | dlg.Centre(); |
---|
| 2108 | dlg.ShowModal(); |
---|
[137bf99] | 2109 | } |
---|
[c6d95d8] | 2110 | |
---|
[7c29c976] | 2111 | void MainFrm::UpdateStatusBar() |
---|
| 2112 | { |
---|
| 2113 | if (!here_text.empty()) { |
---|
| 2114 | GetStatusBar()->SetStatusText(here_text); |
---|
| 2115 | GetStatusBar()->SetStatusText(dist_text, 1); |
---|
| 2116 | } else if (!coords_text.empty()) { |
---|
| 2117 | GetStatusBar()->SetStatusText(coords_text); |
---|
[0633bcc] | 2118 | GetStatusBar()->SetStatusText(distfree_text, 1); |
---|
[7c29c976] | 2119 | } else { |
---|
[5627cbb] | 2120 | GetStatusBar()->SetStatusText(wxString()); |
---|
| 2121 | GetStatusBar()->SetStatusText(wxString(), 1); |
---|
[7c29c976] | 2122 | } |
---|
| 2123 | } |
---|
| 2124 | |
---|
[1fd2edb] | 2125 | void MainFrm::ClearTreeSelection() |
---|
| 2126 | { |
---|
| 2127 | m_Tree->UnselectAll(); |
---|
[19026f3] | 2128 | m_Gfx->SetThere(); |
---|
[381ae6e] | 2129 | ShowInfo(); |
---|
[1fd2edb] | 2130 | } |
---|
| 2131 | |
---|
[156dc16] | 2132 | void MainFrm::ClearCoords() |
---|
| 2133 | { |
---|
[4b031c0] | 2134 | if (!coords_text.empty()) { |
---|
[5627cbb] | 2135 | coords_text = wxString(); |
---|
[4b031c0] | 2136 | UpdateStatusBar(); |
---|
| 2137 | } |
---|
[156dc16] | 2138 | } |
---|
| 2139 | |
---|
[d67450e] | 2140 | void MainFrm::SetCoords(const Vector3 &v) |
---|
[d877aa2] | 2141 | { |
---|
[ccb83b7] | 2142 | Double x = v.GetX(); |
---|
| 2143 | Double y = v.GetY(); |
---|
| 2144 | Double z = v.GetZ(); |
---|
| 2145 | int units; |
---|
[d877aa2] | 2146 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 2147 | units = /*m*/424; |
---|
[d877aa2] | 2148 | } else { |
---|
[ccb83b7] | 2149 | x /= METRES_PER_FOOT; |
---|
| 2150 | y /= METRES_PER_FOOT; |
---|
| 2151 | z /= METRES_PER_FOOT; |
---|
| 2152 | units = /*ft*/428; |
---|
[d877aa2] | 2153 | } |
---|
[736f7df] | 2154 | /* TRANSLATORS: show coordinates (N = North or Northing, E = East or |
---|
| 2155 | * Easting) */ |
---|
[ccb83b7] | 2156 | coords_text.Printf(wmsg(/*%.2f E, %.2f N*/338), x, y); |
---|
| 2157 | coords_text += wxString::Format(wxT(", %s %.2f%s"), |
---|
| 2158 | wmsg(/*Altitude*/335).c_str(), |
---|
| 2159 | z, wmsg(units).c_str()); |
---|
[5627cbb] | 2160 | distfree_text = wxString(); |
---|
[7c29c976] | 2161 | UpdateStatusBar(); |
---|
[d877aa2] | 2162 | } |
---|
| 2163 | |
---|
[0633bcc] | 2164 | const LabelInfo * MainFrm::GetTreeSelection() const { |
---|
| 2165 | wxTreeItemData* sel_wx; |
---|
| 2166 | if (!m_Tree->GetSelectionData(&sel_wx)) return NULL; |
---|
| 2167 | |
---|
[44ed489] | 2168 | const TreeData* data = static_cast<const TreeData*>(sel_wx); |
---|
[0633bcc] | 2169 | if (!data->IsStation()) return NULL; |
---|
| 2170 | |
---|
| 2171 | return data->GetLabel(); |
---|
| 2172 | } |
---|
| 2173 | |
---|
[381ae6e] | 2174 | void MainFrm::SetCoords(Double x, Double y, const LabelInfo * there) |
---|
[156dc16] | 2175 | { |
---|
[7c29c976] | 2176 | wxString & s = coords_text; |
---|
[33b2094] | 2177 | if (m_Gfx->GetMetric()) { |
---|
[5627cbb] | 2178 | s.Printf(wmsg(/*%.2f E, %.2f N*/338), x, y); |
---|
[7a89dc2] | 2179 | } else { |
---|
[5627cbb] | 2180 | s.Printf(wmsg(/*%.2f E, %.2f N*/338), |
---|
[3d4bee1] | 2181 | x / METRES_PER_FOOT, y / METRES_PER_FOOT); |
---|
[7a89dc2] | 2182 | } |
---|
[0633bcc] | 2183 | |
---|
[c00c6713] | 2184 | wxString & t = distfree_text; |
---|
[5627cbb] | 2185 | t = wxString(); |
---|
[381ae6e] | 2186 | if (m_Gfx->ShowingMeasuringLine() && there) { |
---|
| 2187 | Vector3 delta(x - m_Offsets.GetX() - there->GetX(), |
---|
| 2188 | y - m_Offsets.GetY() - there->GetY(), 0); |
---|
[0633bcc] | 2189 | Double dh = sqrt(delta.GetX()*delta.GetX() + delta.GetY()*delta.GetY()); |
---|
| 2190 | Double brg = deg(atan2(delta.GetX(), delta.GetY())); |
---|
| 2191 | if (brg < 0) brg += 360; |
---|
| 2192 | |
---|
| 2193 | wxString from_str; |
---|
[736f7df] | 2194 | /* TRANSLATORS: Used in Aven: |
---|
| 2195 | * From <stationname> |
---|
| 2196 | * H: 123.45m V: 234.56m |
---|
| 2197 | * Dist: 456.78m Brg: 200 */ |
---|
[7b9b700] | 2198 | from_str.Printf(wmsg(/*From %s*/339), there->name_or_anon().c_str()); |
---|
[ccb83b7] | 2199 | int brg_unit; |
---|
[0633bcc] | 2200 | if (m_Gfx->GetDegrees()) { |
---|
[ccb83b7] | 2201 | brg_unit = /*°*/344; |
---|
[0633bcc] | 2202 | } else { |
---|
| 2203 | brg *= 400.0 / 360.0; |
---|
[736f7df] | 2204 | /* TRANSLATORS: alternative angle units (400 grad = 360 degrees = |
---|
| 2205 | * full circle). Try to make this as short as sensibly possible. |
---|
| 2206 | * |
---|
| 2207 | * E.g. in Italian and Spanish we use "g.cent." rather than |
---|
| 2208 | * "gradi quattrocentesimali"/"grados centesimales" */ |
---|
[ccb83b7] | 2209 | brg_unit = /*grad*/345; |
---|
[0633bcc] | 2210 | } |
---|
| 2211 | |
---|
[ccb83b7] | 2212 | int units; |
---|
[0633bcc] | 2213 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 2214 | units = /*m*/424; |
---|
[0633bcc] | 2215 | } else { |
---|
[ccb83b7] | 2216 | dh /= METRES_PER_FOOT; |
---|
| 2217 | units = /*ft*/428; |
---|
[0633bcc] | 2218 | } |
---|
[736f7df] | 2219 | /* TRANSLATORS: "H" is short for "Horizontal", "Brg" for "Bearing" (as |
---|
| 2220 | * in Compass bearing) */ |
---|
[ccb83b7] | 2221 | t.Printf(wmsg(/*%s: H %.2f%s, Brg %03d%s*/374), |
---|
| 2222 | from_str.c_str(), dh, wmsg(units).c_str(), |
---|
| 2223 | int(brg), wmsg(brg_unit).c_str()); |
---|
[0633bcc] | 2224 | } |
---|
| 2225 | |
---|
[7c29c976] | 2226 | UpdateStatusBar(); |
---|
[156dc16] | 2227 | } |
---|
| 2228 | |
---|
[381ae6e] | 2229 | void MainFrm::SetAltitude(Double z, const LabelInfo * there) |
---|
[156dc16] | 2230 | { |
---|
[ccb83b7] | 2231 | double alt = z; |
---|
| 2232 | int units; |
---|
[33b2094] | 2233 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 2234 | units = /*m*/424; |
---|
[7a89dc2] | 2235 | } else { |
---|
[ccb83b7] | 2236 | alt /= METRES_PER_FOOT; |
---|
| 2237 | units = /*ft*/428; |
---|
[7a89dc2] | 2238 | } |
---|
[ccb83b7] | 2239 | coords_text.Printf(wxT("%s %.2f%s"), wmsg(/*Altitude*/335).c_str(), |
---|
| 2240 | alt, wmsg(units).c_str()); |
---|
[0633bcc] | 2241 | |
---|
[c00c6713] | 2242 | wxString & t = distfree_text; |
---|
[5627cbb] | 2243 | t = wxString(); |
---|
[381ae6e] | 2244 | if (m_Gfx->ShowingMeasuringLine() && there) { |
---|
| 2245 | Double dz = z - m_Offsets.GetZ() - there->GetZ(); |
---|
[0633bcc] | 2246 | |
---|
| 2247 | wxString from_str; |
---|
[7b9b700] | 2248 | from_str.Printf(wmsg(/*From %s*/339), there->name_or_anon().c_str()); |
---|
[0633bcc] | 2249 | |
---|
[ccb83b7] | 2250 | if (!m_Gfx->GetMetric()) { |
---|
| 2251 | dz /= METRES_PER_FOOT; |
---|
[0633bcc] | 2252 | } |
---|
[736f7df] | 2253 | // TRANSLATORS: "V" is short for "Vertical" |
---|
[ccb83b7] | 2254 | t.Printf(wmsg(/*%s: V %.2f%s*/375), from_str.c_str(), |
---|
| 2255 | dz, wmsg(units).c_str()); |
---|
[0633bcc] | 2256 | } |
---|
| 2257 | |
---|
[7c29c976] | 2258 | UpdateStatusBar(); |
---|
[2a3d328] | 2259 | } |
---|
| 2260 | |
---|
[381ae6e] | 2261 | void MainFrm::ShowInfo(const LabelInfo *here, const LabelInfo *there) |
---|
[7a89dc2] | 2262 | { |
---|
| 2263 | assert(m_Gfx); |
---|
[f433fda] | 2264 | |
---|
[0633bcc] | 2265 | if (!here) { |
---|
[7c29c976] | 2266 | m_Gfx->SetHere(); |
---|
[570d62c3] | 2267 | m_Tree->SetHere(wxTreeItemId()); |
---|
[1235f9b] | 2268 | // Don't clear "There" mark here. |
---|
[4b031c0] | 2269 | if (here_text.empty() && dist_text.empty()) return; |
---|
[5627cbb] | 2270 | here_text = wxString(); |
---|
| 2271 | dist_text = wxString(); |
---|
[7c29c976] | 2272 | UpdateStatusBar(); |
---|
| 2273 | return; |
---|
| 2274 | } |
---|
| 2275 | |
---|
[0633bcc] | 2276 | Vector3 v = *here + m_Offsets; |
---|
[7c29c976] | 2277 | wxString & s = here_text; |
---|
[ccb83b7] | 2278 | Double x = v.GetX(); |
---|
| 2279 | Double y = v.GetY(); |
---|
| 2280 | Double z = v.GetZ(); |
---|
| 2281 | int units; |
---|
[33b2094] | 2282 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 2283 | units = /*m*/424; |
---|
[7a89dc2] | 2284 | } else { |
---|
[ccb83b7] | 2285 | x /= METRES_PER_FOOT; |
---|
| 2286 | y /= METRES_PER_FOOT; |
---|
| 2287 | z /= METRES_PER_FOOT; |
---|
| 2288 | units = /*ft*/428; |
---|
[7a89dc2] | 2289 | } |
---|
[ccb83b7] | 2290 | s.Printf(wmsg(/*%.2f E, %.2f N*/338), x, y); |
---|
| 2291 | s += wxString::Format(wxT(", %s %.2f%s"), wmsg(/*Altitude*/335).c_str(), |
---|
| 2292 | z, wmsg(units).c_str()); |
---|
[5627cbb] | 2293 | s += wxT(": "); |
---|
[f153906] | 2294 | s += here->name_or_anon(); |
---|
[381ae6e] | 2295 | m_Gfx->SetHere(here); |
---|
[570d62c3] | 2296 | m_Tree->SetHere(here->tree_id); |
---|
[7a89dc2] | 2297 | |
---|
[381ae6e] | 2298 | if (m_Gfx->ShowingMeasuringLine() && there) { |
---|
| 2299 | Vector3 delta = *here - *there; |
---|
[d67450e] | 2300 | |
---|
[87d2ab6] | 2301 | Double d_horiz = sqrt(delta.GetX()*delta.GetX() + |
---|
| 2302 | delta.GetY()*delta.GetY()); |
---|
[0633bcc] | 2303 | Double dr = delta.magnitude(); |
---|
[87d2ab6] | 2304 | Double dz = delta.GetZ(); |
---|
[d67450e] | 2305 | |
---|
[0633bcc] | 2306 | Double brg = deg(atan2(delta.GetX(), delta.GetY())); |
---|
| 2307 | if (brg < 0) brg += 360; |
---|
[421b7d2] | 2308 | |
---|
[0633bcc] | 2309 | wxString from_str; |
---|
[7b9b700] | 2310 | from_str.Printf(wmsg(/*From %s*/339), there->name_or_anon().c_str()); |
---|
[203d2a7] | 2311 | |
---|
[0633bcc] | 2312 | wxString hv_str; |
---|
| 2313 | if (m_Gfx->GetMetric()) { |
---|
[ccb83b7] | 2314 | units = /*m*/424; |
---|
[0633bcc] | 2315 | } else { |
---|
[ccb83b7] | 2316 | d_horiz /= METRES_PER_FOOT; |
---|
| 2317 | dr /= METRES_PER_FOOT; |
---|
[87d2ab6] | 2318 | dz /= METRES_PER_FOOT; |
---|
[ccb83b7] | 2319 | units = /*ft*/428; |
---|
[0633bcc] | 2320 | } |
---|
[ccb83b7] | 2321 | wxString len_unit = wmsg(units); |
---|
[736f7df] | 2322 | /* TRANSLATORS: "H" is short for "Horizontal", "V" for "Vertical" */ |
---|
[ccb83b7] | 2323 | hv_str.Printf(wmsg(/*H %.2f%s, V %.2f%s*/340), |
---|
[87d2ab6] | 2324 | d_horiz, len_unit.c_str(), dz, len_unit.c_str()); |
---|
[ccb83b7] | 2325 | int brg_unit; |
---|
[0633bcc] | 2326 | if (m_Gfx->GetDegrees()) { |
---|
[ccb83b7] | 2327 | brg_unit = /*°*/344; |
---|
[7a89dc2] | 2328 | } else { |
---|
[0633bcc] | 2329 | brg *= 400.0 / 360.0; |
---|
[ccb83b7] | 2330 | brg_unit = /*grad*/345; |
---|
[421b7d2] | 2331 | } |
---|
[0633bcc] | 2332 | wxString & d = dist_text; |
---|
[736f7df] | 2333 | /* TRANSLATORS: "Dist" is short for "Distance", "Brg" for "Bearing" (as |
---|
| 2334 | * in Compass bearing) */ |
---|
[ccb83b7] | 2335 | d.Printf(wmsg(/*%s: %s, Dist %.2f%s, Brg %03d%s*/341), |
---|
| 2336 | from_str.c_str(), hv_str.c_str(), |
---|
| 2337 | dr, len_unit.c_str(), int(brg), wmsg(brg_unit).c_str()); |
---|
[0633bcc] | 2338 | } else { |
---|
[5627cbb] | 2339 | dist_text = wxString(); |
---|
[0633bcc] | 2340 | m_Gfx->SetThere(); |
---|
[156dc16] | 2341 | } |
---|
[7c29c976] | 2342 | UpdateStatusBar(); |
---|
[7a89dc2] | 2343 | } |
---|
| 2344 | |
---|
[8734409] | 2345 | void MainFrm::DisplayTreeInfo(const wxTreeItemData* item) |
---|
[7a89dc2] | 2346 | { |
---|
[8734409] | 2347 | const TreeData* data = static_cast<const TreeData*>(item); |
---|
[887c26e] | 2348 | if (data && data->IsStation()) { |
---|
[381ae6e] | 2349 | m_Gfx->SetHereFromTree(data->GetLabel()); |
---|
[887c26e] | 2350 | } else { |
---|
[381ae6e] | 2351 | ShowInfo(); |
---|
[156dc16] | 2352 | } |
---|
| 2353 | } |
---|
| 2354 | |
---|
[44ed489] | 2355 | void MainFrm::TreeItemSelected(const wxTreeItemData* item, bool zoom) |
---|
[156dc16] | 2356 | { |
---|
[44ed489] | 2357 | const TreeData* data = static_cast<const TreeData*>(item); |
---|
[156dc16] | 2358 | if (data && data->IsStation()) { |
---|
[8734409] | 2359 | const LabelInfo* label = data->GetLabel(); |
---|
[44ed489] | 2360 | if (zoom) m_Gfx->CentreOn(*label); |
---|
[381ae6e] | 2361 | m_Gfx->SetThere(label); |
---|
[5627cbb] | 2362 | dist_text = wxString(); |
---|
[7c29c976] | 2363 | // FIXME: Need to update dist_text (From ... etc) |
---|
[887c26e] | 2364 | // But we don't currently know where "here" is at this point in the |
---|
| 2365 | // code! |
---|
[0580c6a] | 2366 | } else { |
---|
[5627cbb] | 2367 | dist_text = wxString(); |
---|
[0580c6a] | 2368 | m_Gfx->SetThere(); |
---|
[156dc16] | 2369 | } |
---|
[44ed489] | 2370 | if (!data) { |
---|
| 2371 | // Must be the root. |
---|
[5627cbb] | 2372 | m_FindBox->SetValue(wxString()); |
---|
[44ed489] | 2373 | if (zoom) { |
---|
| 2374 | wxCommandEvent dummy; |
---|
| 2375 | OnDefaults(dummy); |
---|
| 2376 | } |
---|
| 2377 | } else if (data && !data->IsStation()) { |
---|
[5627cbb] | 2378 | m_FindBox->SetValue(data->GetSurvey() + wxT(".*")); |
---|
[44ed489] | 2379 | if (zoom) { |
---|
| 2380 | wxCommandEvent dummy; |
---|
| 2381 | OnGotoFound(dummy); |
---|
| 2382 | } |
---|
| 2383 | } |
---|
[7c29c976] | 2384 | UpdateStatusBar(); |
---|
[156dc16] | 2385 | } |
---|
| 2386 | |
---|
[97a414f] | 2387 | void MainFrm::OnPresNew(wxCommandEvent&) |
---|
[156dc16] | 2388 | { |
---|
[1690fa9] | 2389 | if (m_PresList->Modified()) { |
---|
[1c6b20d7] | 2390 | AvenAllowOnTop ontop(this); |
---|
[1690fa9] | 2391 | // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel] |
---|
[5627cbb] | 2392 | if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327), |
---|
| 2393 | wmsg(/*Modified Presentation*/326), |
---|
[1690fa9] | 2394 | wxOK|wxCANCEL|wxICON_QUESTION) == wxCANCEL) { |
---|
| 2395 | return; |
---|
| 2396 | } |
---|
[156dc16] | 2397 | } |
---|
[bd7607c] | 2398 | m_PresList->New(m_File); |
---|
[24961e2] | 2399 | if (!ShowingSidePanel()) ToggleSidePanel(); |
---|
[c8f929b] | 2400 | // Select the presentation page in the notebook. |
---|
| 2401 | m_Notebook->SetSelection(1); |
---|
[156dc16] | 2402 | } |
---|
| 2403 | |
---|
[97a414f] | 2404 | void MainFrm::OnPresOpen(wxCommandEvent&) |
---|
[156dc16] | 2405 | { |
---|
[1c6b20d7] | 2406 | AvenAllowOnTop ontop(this); |
---|
[1690fa9] | 2407 | if (m_PresList->Modified()) { |
---|
| 2408 | // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel] |
---|
[5627cbb] | 2409 | if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327), |
---|
| 2410 | wmsg(/*Modified Presentation*/326), |
---|
[1690fa9] | 2411 | wxOK|wxCANCEL|wxICON_QUESTION) == wxCANCEL) { |
---|
| 2412 | return; |
---|
| 2413 | } |
---|
| 2414 | } |
---|
[156dc16] | 2415 | #ifdef __WXMOTIF__ |
---|
[5627cbb] | 2416 | wxFileDialog dlg(this, wmsg(/*Select a presentation to open*/322), wxString(), wxString(), |
---|
| 2417 | wxT("*.fly"), wxFD_OPEN); |
---|
[156dc16] | 2418 | #else |
---|
[5627cbb] | 2419 | wxFileDialog dlg(this, wmsg(/*Select a presentation to open*/322), wxString(), wxString(), |
---|
| 2420 | wxString::Format(wxT("%s|*.fly|%s|%s"), |
---|
| 2421 | wmsg(/*Aven presentations*/320).c_str(), |
---|
| 2422 | wmsg(/*All files*/208).c_str(), |
---|
| 2423 | wxFileSelectorDefaultWildcardStr), |
---|
| 2424 | wxFD_OPEN|wxFD_FILE_MUST_EXIST); |
---|
[156dc16] | 2425 | #endif |
---|
| 2426 | if (dlg.ShowModal() == wxID_OK) { |
---|
[1690fa9] | 2427 | if (!m_PresList->Load(dlg.GetPath())) { |
---|
| 2428 | return; |
---|
| 2429 | } |
---|
[97a414f] | 2430 | // FIXME : keep a history of loaded/saved presentations, like we do for |
---|
| 2431 | // loaded surveys... |
---|
[c8f929b] | 2432 | // Select the presentation page in the notebook. |
---|
| 2433 | m_Notebook->SetSelection(1); |
---|
[156dc16] | 2434 | } |
---|
| 2435 | } |
---|
[5ffa439] | 2436 | |
---|
[97a414f] | 2437 | void MainFrm::OnPresSave(wxCommandEvent&) |
---|
[8000d8f] | 2438 | { |
---|
[1690fa9] | 2439 | m_PresList->Save(true); |
---|
[8000d8f] | 2440 | } |
---|
| 2441 | |
---|
[97a414f] | 2442 | void MainFrm::OnPresSaveAs(wxCommandEvent&) |
---|
[5ffa439] | 2443 | { |
---|
[1690fa9] | 2444 | m_PresList->Save(false); |
---|
[5ffa439] | 2445 | } |
---|
| 2446 | |
---|
[97a414f] | 2447 | void MainFrm::OnPresMark(wxCommandEvent&) |
---|
[5ffa439] | 2448 | { |
---|
[1690fa9] | 2449 | m_PresList->AddMark(); |
---|
[5ffa439] | 2450 | } |
---|
| 2451 | |
---|
[128fac4] | 2452 | void MainFrm::OnPresFRewind(wxCommandEvent&) |
---|
| 2453 | { |
---|
| 2454 | m_Gfx->PlayPres(-100); |
---|
| 2455 | } |
---|
| 2456 | |
---|
| 2457 | void MainFrm::OnPresRewind(wxCommandEvent&) |
---|
| 2458 | { |
---|
| 2459 | m_Gfx->PlayPres(-10); |
---|
| 2460 | } |
---|
| 2461 | |
---|
| 2462 | void MainFrm::OnPresReverse(wxCommandEvent&) |
---|
| 2463 | { |
---|
| 2464 | m_Gfx->PlayPres(-1); |
---|
| 2465 | } |
---|
| 2466 | |
---|
| 2467 | void MainFrm::OnPresPlay(wxCommandEvent&) |
---|
[5ffa439] | 2468 | { |
---|
[128fac4] | 2469 | m_Gfx->PlayPres(1); |
---|
| 2470 | } |
---|
| 2471 | |
---|
| 2472 | void MainFrm::OnPresFF(wxCommandEvent&) |
---|
| 2473 | { |
---|
| 2474 | m_Gfx->PlayPres(10); |
---|
| 2475 | } |
---|
| 2476 | |
---|
| 2477 | void MainFrm::OnPresFFF(wxCommandEvent&) |
---|
| 2478 | { |
---|
| 2479 | m_Gfx->PlayPres(100); |
---|
| 2480 | } |
---|
| 2481 | |
---|
| 2482 | void MainFrm::OnPresPause(wxCommandEvent&) |
---|
| 2483 | { |
---|
| 2484 | m_Gfx->PlayPres(0); |
---|
| 2485 | } |
---|
| 2486 | |
---|
| 2487 | void MainFrm::OnPresStop(wxCommandEvent&) |
---|
| 2488 | { |
---|
| 2489 | m_Gfx->PlayPres(0, false); |
---|
[5ffa439] | 2490 | } |
---|
| 2491 | |
---|
[97a414f] | 2492 | void MainFrm::OnPresExportMovie(wxCommandEvent&) |
---|
[6a4cdcb6] | 2493 | { |
---|
[1c6b20d7] | 2494 | AvenAllowOnTop ontop(this); |
---|
[97a414f] | 2495 | // FIXME : Taking the leaf of the currently loaded presentation as the |
---|
| 2496 | // default might make more sense? |
---|
[f302cbaa] | 2497 | wxString baseleaf; |
---|
| 2498 | wxFileName::SplitPath(m_File, NULL, NULL, &baseleaf, NULL, wxPATH_NATIVE); |
---|
[6e63fd3] | 2499 | wxFileDialog dlg(this, wmsg(/*Export Movie*/331), wxString(), |
---|
[f302cbaa] | 2500 | baseleaf + wxT(".mpg"), |
---|
[5627cbb] | 2501 | wxT("MPEG|*.mpg|AVI|*.avi|QuickTime|*.mov|WMV|*.wmv;*.asf"), |
---|
[4e98397] | 2502 | wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
---|
[97a414f] | 2503 | if (dlg.ShowModal() == wxID_OK) { |
---|
[091069f] | 2504 | // Error is reported by GfxCore. |
---|
| 2505 | (void)m_Gfx->ExportMovie(dlg.GetPath()); |
---|
[6a4cdcb6] | 2506 | } |
---|
| 2507 | } |
---|
| 2508 | |
---|
[1690fa9] | 2509 | PresentationMark MainFrm::GetPresMark(int which) |
---|
[5ffa439] | 2510 | { |
---|
[1690fa9] | 2511 | return m_PresList->GetPresMark(which); |
---|
[5ffa439] | 2512 | } |
---|
| 2513 | |
---|
[1690fa9] | 2514 | //void MainFrm::OnFileOpenTerrainUpdate(wxUpdateUIEvent& event) |
---|
| 2515 | //{ |
---|
| 2516 | // event.Enable(!m_File.empty()); |
---|
| 2517 | //} |
---|
| 2518 | |
---|
| 2519 | void MainFrm::OnPresNewUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2520 | { |
---|
[1366db2] | 2521 | event.Enable(!m_File.empty()); |
---|
[5ffa439] | 2522 | } |
---|
| 2523 | |
---|
[1690fa9] | 2524 | void MainFrm::OnPresOpenUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2525 | { |
---|
[1690fa9] | 2526 | event.Enable(!m_File.empty()); |
---|
[5ffa439] | 2527 | } |
---|
| 2528 | |
---|
[1690fa9] | 2529 | void MainFrm::OnPresSaveUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2530 | { |
---|
[1690fa9] | 2531 | event.Enable(!m_PresList->Empty()); |
---|
[5ffa439] | 2532 | } |
---|
| 2533 | |
---|
[1690fa9] | 2534 | void MainFrm::OnPresSaveAsUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2535 | { |
---|
[1690fa9] | 2536 | event.Enable(!m_PresList->Empty()); |
---|
[5ffa439] | 2537 | } |
---|
| 2538 | |
---|
[1690fa9] | 2539 | void MainFrm::OnPresMarkUpdate(wxUpdateUIEvent& event) |
---|
[5ffa439] | 2540 | { |
---|
[1690fa9] | 2541 | event.Enable(!m_File.empty()); |
---|
| 2542 | } |
---|
| 2543 | |
---|
[128fac4] | 2544 | void MainFrm::OnPresFRewindUpdate(wxUpdateUIEvent& event) |
---|
| 2545 | { |
---|
| 2546 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2547 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() < -10); |
---|
| 2548 | } |
---|
| 2549 | |
---|
| 2550 | void MainFrm::OnPresRewindUpdate(wxUpdateUIEvent& event) |
---|
| 2551 | { |
---|
| 2552 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2553 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() == -10); |
---|
| 2554 | } |
---|
| 2555 | |
---|
| 2556 | void MainFrm::OnPresReverseUpdate(wxUpdateUIEvent& event) |
---|
| 2557 | { |
---|
| 2558 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2559 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() == -1); |
---|
| 2560 | } |
---|
| 2561 | |
---|
| 2562 | void MainFrm::OnPresPlayUpdate(wxUpdateUIEvent& event) |
---|
[1690fa9] | 2563 | { |
---|
| 2564 | event.Enable(!m_PresList->Empty()); |
---|
[128fac4] | 2565 | event.Check(m_Gfx && m_Gfx->GetPresentationMode() && |
---|
| 2566 | m_Gfx->GetPresentationSpeed() == 1); |
---|
| 2567 | } |
---|
| 2568 | |
---|
| 2569 | void MainFrm::OnPresFFUpdate(wxUpdateUIEvent& event) |
---|
| 2570 | { |
---|
| 2571 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2572 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() == 10); |
---|
| 2573 | } |
---|
| 2574 | |
---|
| 2575 | void MainFrm::OnPresFFFUpdate(wxUpdateUIEvent& event) |
---|
| 2576 | { |
---|
| 2577 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2578 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() > 10); |
---|
| 2579 | } |
---|
| 2580 | |
---|
| 2581 | void MainFrm::OnPresPauseUpdate(wxUpdateUIEvent& event) |
---|
| 2582 | { |
---|
| 2583 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
| 2584 | event.Check(m_Gfx && m_Gfx->GetPresentationSpeed() == 0); |
---|
| 2585 | } |
---|
| 2586 | |
---|
| 2587 | void MainFrm::OnPresStopUpdate(wxUpdateUIEvent& event) |
---|
| 2588 | { |
---|
| 2589 | event.Enable(m_Gfx && m_Gfx->GetPresentationMode()); |
---|
[5ffa439] | 2590 | } |
---|
[2a02de2] | 2591 | |
---|
[6a4cdcb6] | 2592 | void MainFrm::OnPresExportMovieUpdate(wxUpdateUIEvent& event) |
---|
| 2593 | { |
---|
| 2594 | event.Enable(!m_PresList->Empty()); |
---|
| 2595 | } |
---|
| 2596 | |
---|
[b4fe9fb] | 2597 | void MainFrm::OnFind(wxCommandEvent&) |
---|
[2a02de2] | 2598 | { |
---|
[bc60689] | 2599 | pending_find = true; |
---|
| 2600 | } |
---|
| 2601 | |
---|
| 2602 | void MainFrm::OnIdle(wxIdleEvent&) |
---|
| 2603 | { |
---|
| 2604 | if (pending_find) { |
---|
| 2605 | DoFind(); |
---|
| 2606 | } |
---|
| 2607 | } |
---|
| 2608 | |
---|
| 2609 | void MainFrm::DoFind() |
---|
| 2610 | { |
---|
| 2611 | pending_find = false; |
---|
[e98af57] | 2612 | wxBusyCursor hourglass; |
---|
[44ed489] | 2613 | // Find stations specified by a string or regular expression pattern. |
---|
[9d3d8cc] | 2614 | |
---|
[0580c6a] | 2615 | wxString pattern = m_FindBox->GetValue(); |
---|
[d1628e8e] | 2616 | if (pattern.empty()) { |
---|
| 2617 | // Hide any search result highlights. |
---|
| 2618 | list<LabelInfo*>::iterator pos = m_Labels.begin(); |
---|
| 2619 | while (pos != m_Labels.end()) { |
---|
| 2620 | LabelInfo* label = *pos++; |
---|
[5a24583] | 2621 | label->clear_flags(LFLAG_HIGHLIGHTED); |
---|
[c8aff97] | 2622 | } |
---|
[d1628e8e] | 2623 | m_NumHighlighted = 0; |
---|
[0c76ad9] | 2624 | } else { |
---|
[d1628e8e] | 2625 | int re_flags = wxRE_NOSUB; |
---|
| 2626 | |
---|
| 2627 | if (true /* case insensitive */) { |
---|
| 2628 | re_flags |= wxRE_ICASE; |
---|
[0c76ad9] | 2629 | } |
---|
| 2630 | |
---|
[d1628e8e] | 2631 | bool substring = true; |
---|
| 2632 | if (false /*m_RegexpCheckBox->GetValue()*/) { |
---|
| 2633 | re_flags |= wxRE_EXTENDED; |
---|
| 2634 | } else if (true /* simple glob-style */) { |
---|
| 2635 | wxString pat; |
---|
| 2636 | for (size_t i = 0; i < pattern.size(); i++) { |
---|
[5627cbb] | 2637 | wxChar ch = pattern[i]; |
---|
[d1628e8e] | 2638 | // ^ only special at start; $ at end. But this is simpler... |
---|
| 2639 | switch (ch) { |
---|
| 2640 | case '^': case '$': case '.': case '[': case '\\': |
---|
[5627cbb] | 2641 | pat += wxT('\\'); |
---|
[d1628e8e] | 2642 | pat += ch; |
---|
| 2643 | break; |
---|
| 2644 | case '*': |
---|
[5627cbb] | 2645 | pat += wxT(".*"); |
---|
[d1628e8e] | 2646 | substring = false; |
---|
| 2647 | break; |
---|
| 2648 | case '?': |
---|
[5627cbb] | 2649 | pat += wxT('.'); |
---|
[d1628e8e] | 2650 | substring = false; |
---|
| 2651 | break; |
---|
| 2652 | default: |
---|
| 2653 | pat += ch; |
---|
| 2654 | } |
---|
| 2655 | } |
---|
| 2656 | pattern = pat; |
---|
| 2657 | re_flags |= wxRE_BASIC; |
---|
| 2658 | } else { |
---|
| 2659 | wxString pat; |
---|
| 2660 | for (size_t i = 0; i < pattern.size(); i++) { |
---|
[5627cbb] | 2661 | wxChar ch = pattern[i]; |
---|
[d1628e8e] | 2662 | // ^ only special at start; $ at end. But this is simpler... |
---|
| 2663 | switch (ch) { |
---|
| 2664 | case '^': case '$': case '*': case '.': case '[': case '\\': |
---|
[5627cbb] | 2665 | pat += wxT('\\'); |
---|
[d1628e8e] | 2666 | } |
---|
| 2667 | pat += ch; |
---|
| 2668 | } |
---|
| 2669 | pattern = pat; |
---|
| 2670 | re_flags |= wxRE_BASIC; |
---|
| 2671 | } |
---|
[421b7d2] | 2672 | |
---|
[d1628e8e] | 2673 | if (!substring) { |
---|
| 2674 | // FIXME "0u" required to avoid compilation error with g++-3.0 |
---|
[5627cbb] | 2675 | if (pattern.empty() || pattern[0u] != '^') pattern = wxT('^') + pattern; |
---|
[d1628e8e] | 2676 | // FIXME: this fails to cope with "\$" at the end of pattern... |
---|
[5627cbb] | 2677 | if (pattern[pattern.size() - 1] != '$') pattern += wxT('$'); |
---|
[d1628e8e] | 2678 | } |
---|
[2a02de2] | 2679 | |
---|
[d1628e8e] | 2680 | wxRegEx regex; |
---|
| 2681 | if (!regex.Compile(pattern, re_flags)) { |
---|
| 2682 | wxBell(); |
---|
| 2683 | return; |
---|
| 2684 | } |
---|
[2a02de2] | 2685 | |
---|
[d1628e8e] | 2686 | int found = 0; |
---|
[1be3a88] | 2687 | |
---|
[d1628e8e] | 2688 | list<LabelInfo*>::iterator pos = m_Labels.begin(); |
---|
| 2689 | while (pos != m_Labels.end()) { |
---|
| 2690 | LabelInfo* label = *pos++; |
---|
| 2691 | |
---|
[5a24583] | 2692 | if (regex.Matches(label->GetText())) { |
---|
| 2693 | label->set_flags(LFLAG_HIGHLIGHTED); |
---|
[d1628e8e] | 2694 | ++found; |
---|
| 2695 | } else { |
---|
[5a24583] | 2696 | label->clear_flags(LFLAG_HIGHLIGHTED); |
---|
[d1628e8e] | 2697 | } |
---|
[1be3a88] | 2698 | } |
---|
| 2699 | |
---|
[d1628e8e] | 2700 | m_NumHighlighted = found; |
---|
| 2701 | |
---|
| 2702 | // Re-sort so highlighted points get names in preference |
---|
| 2703 | if (found) m_Labels.sort(LabelPlotCmp(separator)); |
---|
| 2704 | } |
---|
[421b7d2] | 2705 | |
---|
[429465a] | 2706 | m_Gfx->UpdateBlobs(); |
---|
[fa42426] | 2707 | m_Gfx->ForceRefresh(); |
---|
[9d3d8cc] | 2708 | |
---|
[d1628e8e] | 2709 | if (!m_NumHighlighted) { |
---|
[857408e] | 2710 | GetToolBar()->SetToolShortHelp(button_HIDE, wmsg(/*No matches were found.*/328)); |
---|
[a2f4720] | 2711 | } else { |
---|
[736f7df] | 2712 | /* TRANSLATORS: "Hide stations" button tooltip when stations are found |
---|
| 2713 | */ |
---|
[857408e] | 2714 | GetToolBar()->SetToolShortHelp(button_HIDE, wxString::Format(wmsg(/*Hide %d found stations*/334).c_str(), m_NumHighlighted)); |
---|
[9d3d8cc] | 2715 | } |
---|
[2a02de2] | 2716 | } |
---|
| 2717 | |
---|
[d1628e8e] | 2718 | void MainFrm::OnGotoFound(wxCommandEvent&) |
---|
[2a02de2] | 2719 | { |
---|
[d1628e8e] | 2720 | if (!m_NumHighlighted) { |
---|
[5627cbb] | 2721 | wxGetApp().ReportError(wmsg(/*No matches were found.*/328)); |
---|
[d1628e8e] | 2722 | return; |
---|
| 2723 | } |
---|
| 2724 | |
---|
| 2725 | Double xmin = DBL_MAX; |
---|
| 2726 | Double xmax = -DBL_MAX; |
---|
| 2727 | Double ymin = DBL_MAX; |
---|
| 2728 | Double ymax = -DBL_MAX; |
---|
| 2729 | Double zmin = DBL_MAX; |
---|
| 2730 | Double zmax = -DBL_MAX; |
---|
| 2731 | |
---|
[fa42426] | 2732 | list<LabelInfo*>::iterator pos = m_Labels.begin(); |
---|
| 2733 | while (pos != m_Labels.end()) { |
---|
| 2734 | LabelInfo* label = *pos++; |
---|
[d1628e8e] | 2735 | |
---|
[5a24583] | 2736 | if (label->get_flags() & LFLAG_HIGHLIGHTED) { |
---|
| 2737 | if (label->GetX() < xmin) xmin = label->GetX(); |
---|
| 2738 | if (label->GetX() > xmax) xmax = label->GetX(); |
---|
| 2739 | if (label->GetY() < ymin) ymin = label->GetY(); |
---|
| 2740 | if (label->GetY() > ymax) ymax = label->GetY(); |
---|
| 2741 | if (label->GetZ() < zmin) zmin = label->GetZ(); |
---|
| 2742 | if (label->GetZ() > zmax) zmax = label->GetZ(); |
---|
[d1628e8e] | 2743 | } |
---|
[fa42426] | 2744 | } |
---|
[d1628e8e] | 2745 | |
---|
| 2746 | m_Gfx->SetViewTo(xmin, xmax, ymin, ymax, zmin, zmax); |
---|
| 2747 | m_Gfx->SetFocus(); |
---|
| 2748 | } |
---|
| 2749 | |
---|
| 2750 | void MainFrm::OnHide(wxCommandEvent&) |
---|
| 2751 | { |
---|
[5627cbb] | 2752 | m_FindBox->SetValue(wxString()); |
---|
[857408e] | 2753 | GetToolBar()->SetToolShortHelp(button_HIDE, wmsg(/*Hide*/333)); |
---|
[2a02de2] | 2754 | } |
---|
[39e460c9] | 2755 | |
---|
[429465a] | 2756 | void MainFrm::OnHideUpdate(wxUpdateUIEvent& ui) |
---|
| 2757 | { |
---|
| 2758 | ui.Enable(m_NumHighlighted != 0); |
---|
| 2759 | } |
---|
| 2760 | |
---|
[9059368] | 2761 | void MainFrm::OnViewSidePanel(wxCommandEvent&) |
---|
[b1de3e0] | 2762 | { |
---|
| 2763 | ToggleSidePanel(); |
---|
| 2764 | } |
---|
| 2765 | |
---|
| 2766 | void MainFrm::ToggleSidePanel() |
---|
[9059368] | 2767 | { |
---|
| 2768 | // Toggle display of the side panel. |
---|
| 2769 | |
---|
| 2770 | assert(m_Gfx); |
---|
| 2771 | |
---|
| 2772 | if (m_Splitter->IsSplit()) { |
---|
[421b7d2] | 2773 | m_SashPosition = m_Splitter->GetSashPosition(); // save width of panel |
---|
[1690fa9] | 2774 | m_Splitter->Unsplit(m_Notebook); |
---|
[b63cf6cc] | 2775 | } else { |
---|
[203d2a7] | 2776 | m_Notebook->Show(true); |
---|
[b1de3e0] | 2777 | m_Gfx->Show(true); |
---|
[203d2a7] | 2778 | m_Splitter->SplitVertically(m_Notebook, m_Gfx, m_SashPosition); |
---|
[9059368] | 2779 | } |
---|
| 2780 | } |
---|
| 2781 | |
---|
| 2782 | void MainFrm::OnViewSidePanelUpdate(wxUpdateUIEvent& ui) |
---|
| 2783 | { |
---|
[f48d6949] | 2784 | ui.Enable(!m_File.empty()); |
---|
[203d2a7] | 2785 | ui.Check(ShowingSidePanel()); |
---|
[9059368] | 2786 | } |
---|
[203d2a7] | 2787 | |
---|
| 2788 | bool MainFrm::ShowingSidePanel() |
---|
| 2789 | { |
---|
| 2790 | return m_Splitter->IsSplit(); |
---|
| 2791 | } |
---|
[fdfa926] | 2792 | |
---|
| 2793 | void MainFrm::ViewFullScreen() { |
---|
[e4b87e5] | 2794 | #ifdef __WXMAC__ |
---|
| 2795 | // On OS X, wxWidgets doesn't currently hide the toolbar or statusbar in |
---|
| 2796 | // full screen mode (last checked with 3.0.2), but it is easy to do |
---|
| 2797 | // ourselves. |
---|
| 2798 | if (!IsFullScreen()) { |
---|
| 2799 | GetToolBar()->Hide(); |
---|
| 2800 | GetStatusBar()->Hide(); |
---|
| 2801 | } |
---|
| 2802 | #endif |
---|
| 2803 | |
---|
[fdfa926] | 2804 | ShowFullScreen(!IsFullScreen()); |
---|
[b75a37d] | 2805 | fullscreen_showing_menus = false; |
---|
[486c619] | 2806 | if (IsFullScreen()) |
---|
| 2807 | was_showing_sidepanel_before_fullscreen = ShowingSidePanel(); |
---|
| 2808 | if (was_showing_sidepanel_before_fullscreen) |
---|
| 2809 | ToggleSidePanel(); |
---|
[e4b87e5] | 2810 | |
---|
| 2811 | #ifdef __WXMAC__ |
---|
| 2812 | if (!IsFullScreen()) { |
---|
| 2813 | GetStatusBar()->Show(); |
---|
| 2814 | GetToolBar()->Show(); |
---|
| 2815 | } |
---|
| 2816 | #endif |
---|
[fdfa926] | 2817 | } |
---|
[b75a37d] | 2818 | |
---|
| 2819 | bool MainFrm::FullScreenModeShowingMenus() const |
---|
| 2820 | { |
---|
| 2821 | return fullscreen_showing_menus; |
---|
| 2822 | } |
---|
| 2823 | |
---|
| 2824 | void MainFrm::FullScreenModeShowMenus(bool show) |
---|
| 2825 | { |
---|
| 2826 | if (!IsFullScreen() || show == fullscreen_showing_menus) |
---|
| 2827 | return; |
---|
[3c65a9f] | 2828 | GetMenuBar()->Show(show); |
---|
[b75a37d] | 2829 | fullscreen_showing_menus = show; |
---|
| 2830 | } |
---|