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