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