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