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