4 // Main frame handling for Aven.
6 // Copyright (C) 2000-2002,2005,2006 Mark R. Shinwell
7 // Copyright (C) 2001-2003,2004,2005,2006,2010,2011,2012,2013,2014,2015,2016,2018 Olly Betts
8 // Copyright (C) 2005 Martin Green
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.
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.
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
22 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 #include "cavernlog.h"
35 #include "img_hosted.h"
36 #include "namecompare.h"
41 #include <wx/confbase.h>
42 //#include <wx/filefn.h>
43 #include <wx/filename.h>
45 #include <wx/imaglist.h>
46 #include <wx/process.h>
48 #ifdef USING_GENERIC_TOOLBAR
49 # include <wx/sysopt.h>
61 #define TOOL(x) wxBitmap(wxT(#x), wxBITMAP_TYPE_PNG_RESOURCE)
63 // XPM files declare the array as static, but we also want it to be const too.
64 // This avoids a compiler warning, and also means the data can go in a
65 // read-only page and be shared between processes.
66 #define static static const
67 #include "../lib/icons/aven.xpm"
68 #include "../lib/icons/log.xpm"
69 #include "../lib/icons/open.xpm"
70 #include "../lib/icons/open_pres.xpm"
71 #include "../lib/icons/rotation.xpm"
72 #include "../lib/icons/plan.xpm"
73 #include "../lib/icons/elevation.xpm"
74 #include "../lib/icons/defaults.xpm"
75 #include "../lib/icons/names.xpm"
76 #include "../lib/icons/crosses.xpm"
77 #include "../lib/icons/entrances.xpm"
78 #include "../lib/icons/fixed_pts.xpm"
79 #include "../lib/icons/exported_pts.xpm"
80 #include "../lib/icons/ug_legs.xpm"
81 #include "../lib/icons/surface_legs.xpm"
82 #include "../lib/icons/tubes.xpm"
83 #include "../lib/icons/solid_surface.xpm"
84 #include "../lib/icons/pres_frew.xpm"
85 #include "../lib/icons/pres_rew.xpm"
86 #include "../lib/icons/pres_go_back.xpm"
87 #include "../lib/icons/pres_pause.xpm"
88 #include "../lib/icons/pres_go.xpm"
89 #include "../lib/icons/pres_ff.xpm"
90 #include "../lib/icons/pres_fff.xpm"
91 #include "../lib/icons/pres_stop.xpm"
92 #include "../lib/icons/find.xpm"
93 #include "../lib/icons/hideresults.xpm"
94 #include "../lib/icons/survey_tree.xpm"
95 #include "../lib/icons/pres_tree.xpm"
97 #define TOOL(x) wxBITMAP(x)
102 class AvenSplitterWindow
: public wxSplitterWindow
{
106 explicit AvenSplitterWindow(MainFrm
*parent_
)
107 : wxSplitterWindow(parent_
, -1, wxDefaultPosition
, wxDefaultSize
,
113 void OnSplitterDClick(wxSplitterEvent
&) {
114 parent
->ToggleSidePanel();
118 DECLARE_EVENT_TABLE()
121 BEGIN_EVENT_TABLE(AvenSplitterWindow
, wxSplitterWindow
)
122 EVT_SPLITTER_DCLICK(-1, AvenSplitterWindow::OnSplitterDClick
)
125 class EditMarkDlg
: public wxDialog
{
126 wxTextCtrl
* easting
, * northing
, * altitude
;
127 wxTextCtrl
* angle
, * tilt_angle
, * scale
, * time
;
129 // TRANSLATORS: Title of dialog to edit a waypoint in a presentation.
130 EditMarkDlg(wxWindow
* parent
, const PresentationMark
& p
)
131 : wxDialog(parent
, 500, wmsg(/*Edit Waypoint*/404))
133 easting
= new wxTextCtrl(this, 601, wxString::Format(wxT("%.3f"), p
.GetX()));
134 northing
= new wxTextCtrl(this, 602, wxString::Format(wxT("%.3f"), p
.GetY()));
135 altitude
= new wxTextCtrl(this, 603, wxString::Format(wxT("%.3f"), p
.GetZ()));
136 angle
= new wxTextCtrl(this, 604, wxString::Format(wxT("%.3f"), p
.angle
));
137 tilt_angle
= new wxTextCtrl(this, 605, wxString::Format(wxT("%.3f"), p
.tilt_angle
));
138 scale
= new wxTextCtrl(this, 606, wxString::Format(wxT("%.3f"), p
.scale
));
140 time
= new wxTextCtrl(this, 607, wxString::Format(wxT("%.3f"), p
.time
));
141 } else if (p
.time
< 0.0) {
142 time
= new wxTextCtrl(this, 607, wxString::Format(wxT("*%.3f"), -p
.time
));
144 time
= new wxTextCtrl(this, 607, wxT("0"));
147 wxBoxSizer
* coords
= new wxBoxSizer(wxHORIZONTAL
);
148 coords
->Add(new wxStaticText(this, 610, wxT("(")), 0, wxALIGN_CENTRE_VERTICAL
);
149 coords
->Add(easting
, 1);
150 coords
->Add(new wxStaticText(this, 611, wxT(",")), 0, wxALIGN_CENTRE_VERTICAL
);
151 coords
->Add(northing
, 1);
152 coords
->Add(new wxStaticText(this, 612, wxT(",")), 0, wxALIGN_CENTRE_VERTICAL
);
153 coords
->Add(altitude
, 1);
154 coords
->Add(new wxStaticText(this, 613, wxT(")")), 0, wxALIGN_CENTRE_VERTICAL
);
155 wxBoxSizer
* vert
= new wxBoxSizer(wxVERTICAL
);
156 vert
->Add(coords
, 0, wxALL
, 8);
157 wxBoxSizer
* r2
= new wxBoxSizer(wxHORIZONTAL
);
158 r2
->Add(new wxStaticText(this, 614, wmsg(/*Bearing*/259) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL
);
160 vert
->Add(r2
, 0, wxALL
, 8);
161 wxBoxSizer
* r3
= new wxBoxSizer(wxHORIZONTAL
);
162 r3
->Add(new wxStaticText(this, 615, wmsg(/*Elevation*/118) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL
);
164 vert
->Add(r3
, 0, wxALL
, 8);
165 wxBoxSizer
* r4
= new wxBoxSizer(wxHORIZONTAL
);
166 r4
->Add(new wxStaticText(this, 616, wmsg(/*Scale*/154) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL
);
168 /* TRANSLATORS: Note after "Scale" field in dialog to edit a waypoint
169 * in a presentation. */
170 r4
->Add(new wxStaticText(this, 617, wmsg(/* (unused in perspective view)*/278)),
171 0, wxALIGN_CENTRE_VERTICAL
);
172 vert
->Add(r4
, 0, wxALL
, 8);
174 wxBoxSizer
* r5
= new wxBoxSizer(wxHORIZONTAL
);
175 /* TRANSLATORS: Field label in dialog to edit a waypoint in a
177 r5
->Add(new wxStaticText(this, 616, wmsg(/*Time: */279)), 0, wxALIGN_CENTRE_VERTICAL
);
179 /* TRANSLATORS: units+info after time field in dialog to edit a
180 * waypoint in a presentation. */
181 r5
->Add(new wxStaticText(this, 617, wmsg(/* secs (0 = auto; *6 = 6 times auto)*/282)),
182 0, wxALIGN_CENTRE_VERTICAL
);
183 vert
->Add(r5
, 0, wxALL
, 8);
185 wxBoxSizer
* buttons
= new wxBoxSizer(wxHORIZONTAL
);
186 wxButton
* cancel
= new wxButton(this, wxID_CANCEL
);
187 buttons
->Add(cancel
, 0, wxALL
, 8);
188 wxButton
* ok
= new wxButton(this, wxID_OK
);
190 buttons
->Add(ok
, 0, wxALL
, 8);
191 vert
->Add(buttons
, 0, wxALL
|wxALIGN_RIGHT
);
196 vert
->SetSizeHints(this);
198 PresentationMark
GetMark() const {
200 Vector3
v(wxAtof(easting
->GetValue()),
201 wxAtof(northing
->GetValue()),
202 wxAtof(altitude
->GetValue()));
203 a
= wxAtof(angle
->GetValue());
204 t
= wxAtof(tilt_angle
->GetValue());
205 s
= wxAtof(scale
->GetValue());
206 wxString str
= time
->GetValue();
207 if (!str
.empty() && str
[0u] == '*') str
[0u] = '-';
209 return PresentationMark(v
, a
, t
, s
, T
);
213 DECLARE_EVENT_TABLE()
216 // Write a value without trailing zeros after the decimal point.
217 static void write_double(double d
, FILE * fh
) {
219 sprintf(buf
, "%.21f", d
);
220 char * p
= strchr(buf
, ',');
222 size_t l
= strlen(buf
);
223 while (l
> 1 && buf
[l
- 1] == '0') --l
;
224 if (l
> 1 && buf
[l
- 1] == '.') --l
;
225 fwrite(buf
, l
, 1, fh
);
228 class AvenPresList
: public wxListCtrl
{
231 vector
<PresentationMark
> entries
;
238 AvenPresList(MainFrm
* mainfrm_
, wxWindow
* parent
, GfxCore
* gfx_
)
239 : wxListCtrl(parent
, listctrl_PRES
, wxDefaultPosition
, wxDefaultSize
,
240 wxLC_REPORT
|wxLC_VIRTUAL
),
241 mainfrm(mainfrm_
), gfx(gfx_
), current_item(-1), modified(false),
244 InsertColumn(0, wmsg(/*Easting*/378));
245 InsertColumn(1, wmsg(/*Northing*/379));
246 InsertColumn(2, wmsg(/*Altitude*/335));
249 void OnBeginLabelEdit(wxListEvent
& event
) {
250 event
.Veto(); // No editting allowed
252 void OnDeleteItem(wxListEvent
& event
) {
253 long item
= event
.GetIndex();
254 if (current_item
== item
) {
256 } else if (current_item
> item
) {
259 entries
.erase(entries
.begin() + item
);
260 SetItemCount(entries
.size());
263 void OnDeleteAllItems(wxListEvent
&) {
265 SetItemCount(entries
.size());
266 filename
= wxString();
268 force_save_as
= true;
270 void OnListKeyDown(wxListEvent
& event
) {
271 switch (event
.GetKeyCode()) {
273 long item
= GetNextItem(-1, wxLIST_NEXT_ALL
,
274 wxLIST_STATE_SELECTED
);
277 // - 1 because the indices were shifted by DeleteItem()
278 item
= GetNextItem(item
- 1, wxLIST_NEXT_ALL
,
279 wxLIST_STATE_SELECTED
);
284 //printf("event.GetIndex() = %ld %d\n", event.GetIndex(), event.GetKeyCode());
288 void OnActivated(wxListEvent
& event
) {
289 // Jump to this view.
290 long item
= event
.GetIndex();
291 gfx
->SetView(entries
[item
]);
293 void OnFocused(wxListEvent
& event
) {
294 current_item
= event
.GetIndex();
296 void OnRightClick(wxListEvent
& event
) {
297 long item
= event
.GetIndex();
299 AddMark(item
, gfx
->GetView());
302 EditMarkDlg
edit(mainfrm
, entries
[item
]);
303 if (edit
.ShowModal() == wxID_OK
) {
304 entries
[item
] = edit
.GetMark();
307 void OnChar(wxKeyEvent
& event
) {
308 switch (event
.GetKeyCode()) {
310 if (event
.GetModifiers() == wxMOD_CONTROL
) {
311 if (current_item
!= -1 &&
312 size_t(current_item
) < entries
.size()) {
313 AddMark(current_item
, entries
[current_item
]);
316 AddMark(current_item
);
320 // Already handled in OnListKeyDown.
322 case WXK_UP
: case WXK_DOWN
:
326 gfx
->OnKeyPress(event
);
329 void AddMark(long item
= -1) {
330 AddMark(item
, gfx
->GetView());
332 void AddMark(long item
, const PresentationMark
& mark
) {
333 if (item
== -1) item
= entries
.size();
334 entries
.insert(entries
.begin() + item
, mark
);
335 SetItemCount(entries
.size());
338 virtual wxString
OnGetItemText(long item
, long column
) const {
339 if (item
< 0 || item
>= (long)entries
.size()) return wxString();
340 const PresentationMark
& p
= entries
[item
];
343 case 0: v
= p
.GetX(); break;
344 case 1: v
= p
.GetY(); break;
345 case 2: v
= p
.GetZ(); break;
347 case 3: v
= p
.angle
; break;
348 case 4: v
= p
.tilt_angle
; break;
349 case 5: v
= p
.scale
; break;
350 case 6: v
= p
.time
; break;
352 default: return wxString();
354 return wxString::Format(wxT("%ld"), (long)v
);
356 void Save(bool use_default_name
) {
357 wxString fnm
= filename
;
358 if (!use_default_name
|| force_save_as
) {
359 AvenAllowOnTop
ontop(mainfrm
);
361 wxString
ext(wxT("*.fly"));
363 wxString ext
= wmsg(/*Aven presentations*/320);
364 ext
+= wxT("|*.fly");
366 wxFileDialog
dlg(this, wmsg(/*Select an output filename*/319),
367 wxString(), fnm
, ext
,
368 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
369 if (dlg
.ShowModal() != wxID_OK
) return;
373 FILE * fh_pres
= wxFopen(fnm
, wxT("w"));
375 wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), fnm
.c_str()));
378 vector
<PresentationMark
>::const_iterator i
;
379 for (i
= entries
.begin(); i
!= entries
.end(); ++i
) {
380 const PresentationMark
&p
= *i
;
381 write_double(p
.GetX(), fh_pres
);
383 write_double(p
.GetY(), fh_pres
);
385 write_double(p
.GetZ(), fh_pres
);
387 write_double(p
.angle
, fh_pres
);
389 write_double(p
.tilt_angle
, fh_pres
);
391 write_double(p
.scale
, fh_pres
);
394 write_double(p
.time
, fh_pres
);
401 force_save_as
= false;
403 void New(const wxString
&fnm
) {
405 wxFileName::SplitPath(fnm
, NULL
, NULL
, &filename
, NULL
, wxPATH_NATIVE
);
406 filename
+= wxT(".fly");
407 force_save_as
= true;
409 bool Load(const wxString
&fnm
) {
410 FILE * fh_pres
= wxFopen(fnm
, wxT("r"));
413 m
.Printf(wmsg(/*Couldn’t open file “%s”*/24), fnm
.c_str());
414 wxGetApp().ReportError(m
);
419 while (!feof(fh_pres
)) {
422 while (i
< sizeof(buf
) - 1) {
423 int ch
= GETC(fh_pres
);
424 if (ch
== EOF
|| ch
== '\n' || ch
== '\r') break;
429 double x
, y
, z
, a
, t
, s
, T
;
430 int c
= sscanf(buf
, "%lf %lf %lf %lf %lf %lf %lf", &x
, &y
, &z
, &a
, &t
, &s
, &T
);
433 while ((p
= strchr(p
, '.'))) *p
++ = ',';
434 c
= sscanf(buf
, "%lf %lf %lf %lf %lf %lf %lf", &x
, &y
, &z
, &a
, &t
, &s
, &T
);
437 wxGetApp().ReportError(wxString::Format(wmsg(/*Error in format of presentation file “%s”*/323), fnm
.c_str()));
442 AddMark(item
, PresentationMark(Vector3(x
, y
, z
), a
, t
, s
, T
));
449 force_save_as
= false;
452 bool Modified() const { return modified
; }
453 bool Empty() const { return entries
.empty(); }
454 PresentationMark
GetPresMark(int which
) {
455 long item
= current_item
;
456 if (which
== MARK_FIRST
) {
458 } else if (which
== MARK_NEXT
) {
460 } else if (which
== MARK_PREV
) {
463 if (item
== -1 || item
== (long)entries
.size())
464 return PresentationMark();
465 if (item
!= current_item
) {
467 if (current_item
!= -1) {
468 wxListCtrl::SetItemState(current_item
, wxLIST_STATE_FOCUSED
,
471 wxListCtrl::SetItemState(item
, wxLIST_STATE_FOCUSED
,
472 wxLIST_STATE_FOCUSED
);
474 return entries
[item
];
479 DECLARE_NO_COPY_CLASS(AvenPresList
)
480 DECLARE_EVENT_TABLE()
483 BEGIN_EVENT_TABLE(EditMarkDlg
, wxDialog
)
486 BEGIN_EVENT_TABLE(AvenPresList
, wxListCtrl
)
487 EVT_LIST_BEGIN_LABEL_EDIT(listctrl_PRES
, AvenPresList::OnBeginLabelEdit
)
488 EVT_LIST_DELETE_ITEM(listctrl_PRES
, AvenPresList::OnDeleteItem
)
489 EVT_LIST_DELETE_ALL_ITEMS(listctrl_PRES
, AvenPresList::OnDeleteAllItems
)
490 EVT_LIST_KEY_DOWN(listctrl_PRES
, AvenPresList::OnListKeyDown
)
491 EVT_LIST_ITEM_ACTIVATED(listctrl_PRES
, AvenPresList::OnActivated
)
492 EVT_LIST_ITEM_FOCUSED(listctrl_PRES
, AvenPresList::OnFocused
)
493 EVT_LIST_ITEM_RIGHT_CLICK(listctrl_PRES
, AvenPresList::OnRightClick
)
494 EVT_CHAR(AvenPresList::OnChar
)
497 BEGIN_EVENT_TABLE(MainFrm
, wxFrame
)
498 EVT_TEXT(textctrl_FIND
, MainFrm::OnFind
)
499 EVT_TEXT_ENTER(textctrl_FIND
, MainFrm::OnGotoFound
)
500 EVT_MENU(wxID_FIND
, MainFrm::OnGotoFound
)
501 EVT_MENU(button_HIDE
, MainFrm::OnHide
)
502 EVT_UPDATE_UI(button_HIDE
, MainFrm::OnHideUpdate
)
503 EVT_IDLE(MainFrm::OnIdle
)
505 EVT_MENU(wxID_OPEN
, MainFrm::OnOpen
)
506 EVT_MENU(menu_FILE_OPEN_TERRAIN
, MainFrm::OnOpenTerrain
)
507 EVT_MENU(menu_FILE_LOG
, MainFrm::OnShowLog
)
508 EVT_MENU(wxID_PRINT
, MainFrm::OnPrint
)
509 EVT_MENU(menu_FILE_PAGE_SETUP
, MainFrm::OnPageSetup
)
510 EVT_MENU(menu_FILE_SCREENSHOT
, MainFrm::OnScreenshot
)
511 // EVT_MENU(wxID_PREFERENCES, MainFrm::OnFilePreferences)
512 EVT_MENU(menu_FILE_EXPORT
, MainFrm::OnExport
)
513 EVT_MENU(menu_FILE_EXTEND
, MainFrm::OnExtend
)
514 EVT_MENU(wxID_EXIT
, MainFrm::OnQuit
)
515 EVT_MENU_RANGE(wxID_FILE1
, wxID_FILE9
, MainFrm::OnMRUFile
)
517 EVT_MENU(menu_PRES_NEW
, MainFrm::OnPresNew
)
518 EVT_MENU(menu_PRES_OPEN
, MainFrm::OnPresOpen
)
519 EVT_MENU(menu_PRES_SAVE
, MainFrm::OnPresSave
)
520 EVT_MENU(menu_PRES_SAVE_AS
, MainFrm::OnPresSaveAs
)
521 EVT_MENU(menu_PRES_MARK
, MainFrm::OnPresMark
)
522 EVT_MENU(menu_PRES_FREWIND
, MainFrm::OnPresFRewind
)
523 EVT_MENU(menu_PRES_REWIND
, MainFrm::OnPresRewind
)
524 EVT_MENU(menu_PRES_REVERSE
, MainFrm::OnPresReverse
)
525 EVT_MENU(menu_PRES_PLAY
, MainFrm::OnPresPlay
)
526 EVT_MENU(menu_PRES_FF
, MainFrm::OnPresFF
)
527 EVT_MENU(menu_PRES_FFF
, MainFrm::OnPresFFF
)
528 EVT_MENU(menu_PRES_PAUSE
, MainFrm::OnPresPause
)
529 EVT_MENU(wxID_STOP
, MainFrm::OnPresStop
)
530 EVT_MENU(menu_PRES_EXPORT_MOVIE
, MainFrm::OnPresExportMovie
)
532 EVT_UPDATE_UI(menu_PRES_NEW
, MainFrm::OnPresNewUpdate
)
533 EVT_UPDATE_UI(menu_PRES_OPEN
, MainFrm::OnPresOpenUpdate
)
534 EVT_UPDATE_UI(menu_PRES_SAVE
, MainFrm::OnPresSaveUpdate
)
535 EVT_UPDATE_UI(menu_PRES_SAVE_AS
, MainFrm::OnPresSaveAsUpdate
)
536 EVT_UPDATE_UI(menu_PRES_MARK
, MainFrm::OnPresMarkUpdate
)
537 EVT_UPDATE_UI(menu_PRES_FREWIND
, MainFrm::OnPresFRewindUpdate
)
538 EVT_UPDATE_UI(menu_PRES_REWIND
, MainFrm::OnPresRewindUpdate
)
539 EVT_UPDATE_UI(menu_PRES_REVERSE
, MainFrm::OnPresReverseUpdate
)
540 EVT_UPDATE_UI(menu_PRES_PLAY
, MainFrm::OnPresPlayUpdate
)
541 EVT_UPDATE_UI(menu_PRES_FF
, MainFrm::OnPresFFUpdate
)
542 EVT_UPDATE_UI(menu_PRES_FFF
, MainFrm::OnPresFFFUpdate
)
543 EVT_UPDATE_UI(menu_PRES_PAUSE
, MainFrm::OnPresPauseUpdate
)
544 EVT_UPDATE_UI(wxID_STOP
, MainFrm::OnPresStopUpdate
)
545 EVT_UPDATE_UI(menu_PRES_EXPORT_MOVIE
, MainFrm::OnPresExportMovieUpdate
)
547 EVT_CLOSE(MainFrm::OnClose
)
548 EVT_SET_FOCUS(MainFrm::OnSetFocus
)
550 EVT_MENU(menu_ROTATION_TOGGLE
, MainFrm::OnToggleRotation
)
551 EVT_MENU(menu_ROTATION_REVERSE
, MainFrm::OnReverseDirectionOfRotation
)
552 EVT_MENU(menu_ORIENT_MOVE_NORTH
, MainFrm::OnMoveNorth
)
553 EVT_MENU(menu_ORIENT_MOVE_EAST
, MainFrm::OnMoveEast
)
554 EVT_MENU(menu_ORIENT_MOVE_SOUTH
, MainFrm::OnMoveSouth
)
555 EVT_MENU(menu_ORIENT_MOVE_WEST
, MainFrm::OnMoveWest
)
556 EVT_MENU(menu_ORIENT_PLAN
, MainFrm::OnPlan
)
557 EVT_MENU(menu_ORIENT_ELEVATION
, MainFrm::OnElevation
)
558 EVT_MENU(menu_ORIENT_DEFAULTS
, MainFrm::OnDefaults
)
559 EVT_MENU(menu_VIEW_SHOW_LEGS
, MainFrm::OnShowSurveyLegs
)
560 EVT_MENU(menu_SPLAYS_HIDE
, MainFrm::OnHideSplays
)
561 EVT_MENU(menu_SPLAYS_SHOW_DASHED
, MainFrm::OnShowSplaysDashed
)
562 EVT_MENU(menu_SPLAYS_SHOW_FADED
, MainFrm::OnShowSplaysFaded
)
563 EVT_MENU(menu_SPLAYS_SHOW_NORMAL
, MainFrm::OnShowSplaysNormal
)
564 EVT_MENU(menu_DUPES_HIDE
, MainFrm::OnHideDupes
)
565 EVT_MENU(menu_DUPES_SHOW_DASHED
, MainFrm::OnShowDupesDashed
)
566 EVT_MENU(menu_DUPES_SHOW_FADED
, MainFrm::OnShowDupesFaded
)
567 EVT_MENU(menu_DUPES_SHOW_NORMAL
, MainFrm::OnShowDupesNormal
)
568 EVT_MENU(menu_VIEW_SHOW_CROSSES
, MainFrm::OnShowCrosses
)
569 EVT_MENU(menu_VIEW_SHOW_ENTRANCES
, MainFrm::OnShowEntrances
)
570 EVT_MENU(menu_VIEW_SHOW_FIXED_PTS
, MainFrm::OnShowFixedPts
)
571 EVT_MENU(menu_VIEW_SHOW_EXPORTED_PTS
, MainFrm::OnShowExportedPts
)
572 EVT_MENU(menu_VIEW_SHOW_NAMES
, MainFrm::OnShowStationNames
)
573 EVT_MENU(menu_VIEW_SHOW_OVERLAPPING_NAMES
, MainFrm::OnDisplayOverlappingNames
)
574 EVT_MENU(menu_COLOUR_BY_DEPTH
, MainFrm::OnColourByDepth
)
575 EVT_MENU(menu_COLOUR_BY_DATE
, MainFrm::OnColourByDate
)
576 EVT_MENU(menu_COLOUR_BY_ERROR
, MainFrm::OnColourByError
)
577 EVT_MENU(menu_COLOUR_BY_GRADIENT
, MainFrm::OnColourByGradient
)
578 EVT_MENU(menu_COLOUR_BY_LENGTH
, MainFrm::OnColourByLength
)
579 EVT_MENU(menu_VIEW_SHOW_SURFACE
, MainFrm::OnShowSurface
)
580 EVT_MENU(menu_VIEW_GRID
, MainFrm::OnViewGrid
)
581 EVT_MENU(menu_VIEW_BOUNDING_BOX
, MainFrm::OnViewBoundingBox
)
582 EVT_MENU(menu_VIEW_PERSPECTIVE
, MainFrm::OnViewPerspective
)
583 EVT_MENU(menu_VIEW_SMOOTH_SHADING
, MainFrm::OnViewSmoothShading
)
584 EVT_MENU(menu_VIEW_TEXTURED
, MainFrm::OnViewTextured
)
585 EVT_MENU(menu_VIEW_FOG
, MainFrm::OnViewFog
)
586 EVT_MENU(menu_VIEW_SMOOTH_LINES
, MainFrm::OnViewSmoothLines
)
587 EVT_MENU(menu_VIEW_FULLSCREEN
, MainFrm::OnViewFullScreen
)
588 EVT_MENU(menu_VIEW_SHOW_TUBES
, MainFrm::OnToggleTubes
)
589 EVT_MENU(menu_VIEW_TERRAIN
, MainFrm::OnViewTerrain
)
590 EVT_MENU(menu_IND_COMPASS
, MainFrm::OnViewCompass
)
591 EVT_MENU(menu_IND_CLINO
, MainFrm::OnViewClino
)
592 EVT_MENU(menu_IND_COLOUR_KEY
, MainFrm::OnToggleColourKey
)
593 EVT_MENU(menu_IND_SCALE_BAR
, MainFrm::OnToggleScalebar
)
594 EVT_MENU(menu_CTL_SIDE_PANEL
, MainFrm::OnViewSidePanel
)
595 EVT_MENU(menu_CTL_METRIC
, MainFrm::OnToggleMetric
)
596 EVT_MENU(menu_CTL_DEGREES
, MainFrm::OnToggleDegrees
)
597 EVT_MENU(menu_CTL_PERCENT
, MainFrm::OnTogglePercent
)
598 EVT_MENU(menu_CTL_REVERSE
, MainFrm::OnReverseControls
)
599 EVT_MENU(menu_CTL_CANCEL_DIST_LINE
, MainFrm::OnCancelDistLine
)
600 EVT_MENU(wxID_ABOUT
, MainFrm::OnAbout
)
602 EVT_UPDATE_UI(menu_FILE_OPEN_TERRAIN
, MainFrm::OnOpenTerrainUpdate
)
603 EVT_UPDATE_UI(menu_FILE_LOG
, MainFrm::OnShowLogUpdate
)
604 EVT_UPDATE_UI(wxID_PRINT
, MainFrm::OnPrintUpdate
)
605 EVT_UPDATE_UI(menu_FILE_SCREENSHOT
, MainFrm::OnScreenshotUpdate
)
606 EVT_UPDATE_UI(menu_FILE_EXPORT
, MainFrm::OnExportUpdate
)
607 EVT_UPDATE_UI(menu_FILE_EXTEND
, MainFrm::OnExtendUpdate
)
608 EVT_UPDATE_UI(menu_ROTATION_TOGGLE
, MainFrm::OnToggleRotationUpdate
)
609 EVT_UPDATE_UI(menu_ROTATION_REVERSE
, MainFrm::OnReverseDirectionOfRotationUpdate
)
610 EVT_UPDATE_UI(menu_ORIENT_MOVE_NORTH
, MainFrm::OnMoveNorthUpdate
)
611 EVT_UPDATE_UI(menu_ORIENT_MOVE_EAST
, MainFrm::OnMoveEastUpdate
)
612 EVT_UPDATE_UI(menu_ORIENT_MOVE_SOUTH
, MainFrm::OnMoveSouthUpdate
)
613 EVT_UPDATE_UI(menu_ORIENT_MOVE_WEST
, MainFrm::OnMoveWestUpdate
)
614 EVT_UPDATE_UI(menu_ORIENT_PLAN
, MainFrm::OnPlanUpdate
)
615 EVT_UPDATE_UI(menu_ORIENT_ELEVATION
, MainFrm::OnElevationUpdate
)
616 EVT_UPDATE_UI(menu_ORIENT_DEFAULTS
, MainFrm::OnDefaultsUpdate
)
617 EVT_UPDATE_UI(menu_VIEW_SHOW_LEGS
, MainFrm::OnShowSurveyLegsUpdate
)
618 EVT_UPDATE_UI(menu_VIEW_SPLAYS
, MainFrm::OnSplaysUpdate
)
619 EVT_UPDATE_UI(menu_SPLAYS_HIDE
, MainFrm::OnHideSplaysUpdate
)
620 EVT_UPDATE_UI(menu_SPLAYS_SHOW_DASHED
, MainFrm::OnShowSplaysDashedUpdate
)
621 EVT_UPDATE_UI(menu_SPLAYS_SHOW_FADED
, MainFrm::OnShowSplaysFadedUpdate
)
622 EVT_UPDATE_UI(menu_SPLAYS_SHOW_NORMAL
, MainFrm::OnShowSplaysNormalUpdate
)
623 EVT_UPDATE_UI(menu_VIEW_DUPES
, MainFrm::OnDupesUpdate
)
624 EVT_UPDATE_UI(menu_DUPES_HIDE
, MainFrm::OnHideDupesUpdate
)
625 EVT_UPDATE_UI(menu_DUPES_SHOW_DASHED
, MainFrm::OnShowDupesDashedUpdate
)
626 EVT_UPDATE_UI(menu_DUPES_SHOW_FADED
, MainFrm::OnShowDupesFadedUpdate
)
627 EVT_UPDATE_UI(menu_DUPES_SHOW_NORMAL
, MainFrm::OnShowDupesNormalUpdate
)
628 EVT_UPDATE_UI(menu_VIEW_SHOW_CROSSES
, MainFrm::OnShowCrossesUpdate
)
629 EVT_UPDATE_UI(menu_VIEW_SHOW_ENTRANCES
, MainFrm::OnShowEntrancesUpdate
)
630 EVT_UPDATE_UI(menu_VIEW_SHOW_FIXED_PTS
, MainFrm::OnShowFixedPtsUpdate
)
631 EVT_UPDATE_UI(menu_VIEW_SHOW_EXPORTED_PTS
, MainFrm::OnShowExportedPtsUpdate
)
632 EVT_UPDATE_UI(menu_VIEW_SHOW_NAMES
, MainFrm::OnShowStationNamesUpdate
)
633 EVT_UPDATE_UI(menu_VIEW_SHOW_SURFACE
, MainFrm::OnShowSurfaceUpdate
)
634 EVT_UPDATE_UI(menu_VIEW_SHOW_OVERLAPPING_NAMES
, MainFrm::OnDisplayOverlappingNamesUpdate
)
635 EVT_UPDATE_UI(menu_VIEW_COLOUR_BY
, MainFrm::OnColourByUpdate
)
636 EVT_UPDATE_UI(menu_COLOUR_BY_DEPTH
, MainFrm::OnColourByDepthUpdate
)
637 EVT_UPDATE_UI(menu_COLOUR_BY_DATE
, MainFrm::OnColourByDateUpdate
)
638 EVT_UPDATE_UI(menu_COLOUR_BY_ERROR
, MainFrm::OnColourByErrorUpdate
)
639 EVT_UPDATE_UI(menu_COLOUR_BY_GRADIENT
, MainFrm::OnColourByGradientUpdate
)
640 EVT_UPDATE_UI(menu_COLOUR_BY_LENGTH
, MainFrm::OnColourByLengthUpdate
)
641 EVT_UPDATE_UI(menu_VIEW_GRID
, MainFrm::OnViewGridUpdate
)
642 EVT_UPDATE_UI(menu_VIEW_BOUNDING_BOX
, MainFrm::OnViewBoundingBoxUpdate
)
643 EVT_UPDATE_UI(menu_VIEW_PERSPECTIVE
, MainFrm::OnViewPerspectiveUpdate
)
644 EVT_UPDATE_UI(menu_VIEW_SMOOTH_SHADING
, MainFrm::OnViewSmoothShadingUpdate
)
645 EVT_UPDATE_UI(menu_VIEW_TEXTURED
, MainFrm::OnViewTexturedUpdate
)
646 EVT_UPDATE_UI(menu_VIEW_FOG
, MainFrm::OnViewFogUpdate
)
647 EVT_UPDATE_UI(menu_VIEW_SMOOTH_LINES
, MainFrm::OnViewSmoothLinesUpdate
)
648 EVT_UPDATE_UI(menu_VIEW_FULLSCREEN
, MainFrm::OnViewFullScreenUpdate
)
649 EVT_UPDATE_UI(menu_VIEW_SHOW_TUBES
, MainFrm::OnToggleTubesUpdate
)
650 EVT_UPDATE_UI(menu_VIEW_TERRAIN
, MainFrm::OnViewTerrainUpdate
)
651 EVT_UPDATE_UI(menu_IND_COMPASS
, MainFrm::OnViewCompassUpdate
)
652 EVT_UPDATE_UI(menu_IND_CLINO
, MainFrm::OnViewClinoUpdate
)
653 EVT_UPDATE_UI(menu_IND_COLOUR_KEY
, MainFrm::OnToggleColourKeyUpdate
)
654 EVT_UPDATE_UI(menu_IND_SCALE_BAR
, MainFrm::OnToggleScalebarUpdate
)
655 EVT_UPDATE_UI(menu_CTL_INDICATORS
, MainFrm::OnIndicatorsUpdate
)
656 EVT_UPDATE_UI(menu_CTL_SIDE_PANEL
, MainFrm::OnViewSidePanelUpdate
)
657 EVT_UPDATE_UI(menu_CTL_REVERSE
, MainFrm::OnReverseControlsUpdate
)
658 EVT_UPDATE_UI(menu_CTL_CANCEL_DIST_LINE
, MainFrm::OnCancelDistLineUpdate
)
659 EVT_UPDATE_UI(menu_CTL_METRIC
, MainFrm::OnToggleMetricUpdate
)
660 EVT_UPDATE_UI(menu_CTL_DEGREES
, MainFrm::OnToggleDegreesUpdate
)
661 EVT_UPDATE_UI(menu_CTL_PERCENT
, MainFrm::OnTogglePercentUpdate
)
664 class LabelCmp
: public greater
<const LabelInfo
*> {
667 explicit LabelCmp(wxChar separator_
) : separator(separator_
) {}
668 bool operator()(const LabelInfo
* pt1
, const LabelInfo
* pt2
) {
669 return name_cmp(pt1
->GetText(), pt2
->GetText(), separator
) < 0;
673 class LabelPlotCmp
: public greater
<const LabelInfo
*> {
676 explicit LabelPlotCmp(wxChar separator_
) : separator(separator_
) {}
677 bool operator()(const LabelInfo
* pt1
, const LabelInfo
* pt2
) {
678 int n
= pt1
->get_flags() - pt2
->get_flags();
680 wxString l1
= pt1
->GetText().AfterLast(separator
);
681 wxString l2
= pt2
->GetText().AfterLast(separator
);
682 n
= name_cmp(l1
, l2
, separator
);
684 // Prefer non-2-nodes...
686 // if leaf names are the same, prefer shorter labels as we can
687 // display more of them
688 n
= pt1
->GetText().length() - pt2
->GetText().length();
690 // make sure that we don't ever compare different labels as equal
691 return name_cmp(pt1
->GetText(), pt2
->GetText(), separator
) < 0;
695 #if wxUSE_DRAG_AND_DROP
696 class DnDFile
: public wxFileDropTarget
{
698 explicit DnDFile(MainFrm
*parent
) : m_Parent(parent
) { }
699 virtual bool OnDropFiles(wxCoord
, wxCoord
,
700 const wxArrayString
&filenames
);
707 DnDFile::OnDropFiles(wxCoord
, wxCoord
, const wxArrayString
&filenames
)
709 // Load a survey file by drag-and-drop.
710 assert(filenames
.GetCount() > 0);
712 if (filenames
.GetCount() != 1) {
713 /* TRANSLATORS: error if you try to drag multiple files to the aven
715 wxGetApp().ReportError(wmsg(/*You may only view one 3d file at a time.*/336));
719 m_Parent
->OpenFile(filenames
[0]);
724 MainFrm::MainFrm(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
) :
725 wxFrame(NULL
, 101, title
, pos
, size
, wxDEFAULT_FRAME_STYLE
),
727 m_Gfx(NULL
), m_Log(NULL
),
728 pending_find(false), fullscreen_showing_menus(false)
734 // The peculiar name is so that the icon is the first in the file
735 // (required by Microsoft Windows for this type of icon)
736 SetIcon(wxICON(AAA_aven
));
738 SetIcon(wxICON(aven
));
741 #if wxCHECK_VERSION(3,1,0)
742 // Add a full screen button to the right upper corner of title bar under OS
744 EnableFullScreenView();
748 CreateStatusBar(2, wxST_SIZEGRIP
);
751 int widths
[2] = { -1 /* variable width */, -1 };
752 GetStatusBar()->SetStatusWidths(2, widths
);
754 #ifdef __X__ // wxMotif or wxX11
758 // X seems to require a forced resize.
759 SetSize(-1, -1, x
, y
);
762 #if wxUSE_DRAG_AND_DROP
763 SetDropTarget(new DnDFile(this));
767 void MainFrm::CreateMenuBar()
769 // Create the menus and the menu bar.
771 wxMenu
* filemenu
= new wxMenu
;
772 // wxID_OPEN stock label lacks the ellipses
773 /* TRANSLATORS: Aven menu items. An “&” goes before the letter of any
776 * The string "\t" separates the menu text and any accelerator key.
778 * "File" menu. The accelerators must be different within this group.
779 * c.f. 201, 380, 381. */
780 filemenu
->Append(wxID_OPEN
, wmsg(/*&Open...\tCtrl+O*/220));
781 /* TRANSLATORS: Open a "Terrain file" - i.e. a digital model of the
783 filemenu
->Append(menu_FILE_OPEN_TERRAIN
, wmsg(/*Open &Terrain...*/453));
784 filemenu
->AppendCheckItem(menu_FILE_LOG
, wmsg(/*Show &Log*/144));
785 filemenu
->AppendSeparator();
786 // wxID_PRINT stock label lacks the ellipses
787 filemenu
->Append(wxID_PRINT
, wmsg(/*&Print...\tCtrl+P*/380));
788 filemenu
->Append(menu_FILE_PAGE_SETUP
, wmsg(/*P&age Setup...*/381));
789 filemenu
->AppendSeparator();
790 /* TRANSLATORS: In the "File" menu */
791 filemenu
->Append(menu_FILE_SCREENSHOT
, wmsg(/*&Screenshot...*/201));
792 filemenu
->Append(menu_FILE_EXPORT
, wmsg(/*&Export as...*/382));
793 /* TRANSLATORS: In the "File" menu - c.f. n:191 */
794 filemenu
->Append(menu_FILE_EXTEND
, wmsg(/*E&xtended Elevation...*/247));
796 // On wxMac the "Quit" menu item will be moved elsewhere, so we suppress
798 filemenu
->AppendSeparator();
800 // We suppress the "Help" menu under OS X as it would otherwise end up as
801 // an empty menu, but we need to add the "About" menu item somewhere. It
802 // really doesn't matter where as wxWidgets will move it to the "Apple"
804 filemenu
->Append(wxID_ABOUT
);
806 filemenu
->Append(wxID_EXIT
);
808 m_history
.UseMenu(filemenu
);
809 m_history
.Load(*wxConfigBase::Get());
811 wxMenu
* rotmenu
= new wxMenu
;
812 /* TRANSLATORS: "Rotation" menu. The accelerators must be different within
813 * this group. Tickable menu item which toggles auto rotation.
814 * Please don't translate "Space" - that's the shortcut key to use which
815 * wxWidgets needs to parse and it should then handle translating.
817 rotmenu
->AppendCheckItem(menu_ROTATION_TOGGLE
, wmsg(/*Au&to-Rotate\tSpace*/231));
818 rotmenu
->AppendSeparator();
819 rotmenu
->Append(menu_ROTATION_REVERSE
, wmsg(/*&Reverse Direction*/234));
821 wxMenu
* orientmenu
= new wxMenu
;
822 orientmenu
->Append(menu_ORIENT_MOVE_NORTH
, wmsg(/*View &North*/240));
823 orientmenu
->Append(menu_ORIENT_MOVE_EAST
, wmsg(/*View &East*/241));
824 orientmenu
->Append(menu_ORIENT_MOVE_SOUTH
, wmsg(/*View &South*/242));
825 orientmenu
->Append(menu_ORIENT_MOVE_WEST
, wmsg(/*View &West*/243));
826 orientmenu
->AppendSeparator();
827 orientmenu
->Append(menu_ORIENT_PLAN
, wmsg(/*&Plan View*/248));
828 orientmenu
->Append(menu_ORIENT_ELEVATION
, wmsg(/*Ele&vation*/249));
829 orientmenu
->AppendSeparator();
830 orientmenu
->Append(menu_ORIENT_DEFAULTS
, wmsg(/*Restore De&fault View*/254));
832 wxMenu
* presmenu
= new wxMenu
;
833 presmenu
->Append(menu_PRES_NEW
, wmsg(/*&New Presentation*/311));
834 presmenu
->Append(menu_PRES_OPEN
, wmsg(/*&Open Presentation...*/312));
835 presmenu
->Append(menu_PRES_SAVE
, wmsg(/*&Save Presentation*/313));
836 presmenu
->Append(menu_PRES_SAVE_AS
, wmsg(/*Sa&ve Presentation As...*/314));
837 presmenu
->AppendSeparator();
838 /* TRANSLATORS: "Mark" as in "Mark this position" */
839 presmenu
->Append(menu_PRES_MARK
, wmsg(/*&Mark*/315));
840 /* TRANSLATORS: "Play" as in "Play back a recording" */
841 presmenu
->AppendCheckItem(menu_PRES_PLAY
, wmsg(/*Pla&y*/316));
842 presmenu
->Append(menu_PRES_EXPORT_MOVIE
, wmsg(/*&Export as Movie...*/317));
844 wxMenu
* viewmenu
= new wxMenu
;
846 /* TRANSLATORS: Items in the "View" menu: */
847 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_NAMES
, wmsg(/*Station &Names\tCtrl+N*/270));
848 /* TRANSLATORS: Toggles drawing of 3D passages */
849 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_TUBES
, wmsg(/*Passage &Tubes\tCtrl+T*/346));
850 /* TRANSLATORS: Toggles drawing the surface of the Earth */
851 viewmenu
->AppendCheckItem(menu_VIEW_TERRAIN
, wmsg(/*Terr&ain*/449));
852 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_CROSSES
, wmsg(/*&Crosses\tCtrl+X*/271));
853 viewmenu
->AppendCheckItem(menu_VIEW_GRID
, wmsg(/*&Grid\tCtrl+G*/297));
854 viewmenu
->AppendCheckItem(menu_VIEW_BOUNDING_BOX
, wmsg(/*&Bounding Box\tCtrl+B*/318));
855 viewmenu
->AppendSeparator();
856 /* TRANSLATORS: Here a "survey leg" is a set of measurements between two
857 * "survey stations". */
858 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_LEGS
, wmsg(/*&Underground Survey Legs\tCtrl+L*/272));
859 /* TRANSLATORS: Here a "survey leg" is a set of measurements between two
860 * "survey stations". */
861 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_SURFACE
, wmsg(/*&Surface Survey Legs\tCtrl+F*/291));
863 wxMenu
* splaymenu
= new wxMenu
;
864 /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if
865 * this is selected, such legs are not shown. */
866 splaymenu
->AppendCheckItem(menu_SPLAYS_HIDE
, wmsg(/*&Hide*/407));
867 /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if
868 * this is selected, aven will show such legs with dashed lines. */
869 splaymenu
->AppendCheckItem(menu_SPLAYS_SHOW_DASHED
, wmsg(/*&Dashed*/250));
870 /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if
871 * this is selected, aven will show such legs with less bright colours. */
872 splaymenu
->AppendCheckItem(menu_SPLAYS_SHOW_FADED
, wmsg(/*&Fade*/408));
873 /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if
874 * this is selected, such legs are shown the same as other legs. */
875 splaymenu
->AppendCheckItem(menu_SPLAYS_SHOW_NORMAL
, wmsg(/*&Show*/409));
876 viewmenu
->Append(menu_VIEW_SPLAYS
, wmsg(/*Spla&y Legs*/406), splaymenu
);
878 wxMenu
* dupemenu
= new wxMenu
;
879 dupemenu
->AppendCheckItem(menu_DUPES_HIDE
, wmsg(/*&Hide*/407));
880 dupemenu
->AppendCheckItem(menu_DUPES_SHOW_DASHED
, wmsg(/*&Dashed*/250));
881 dupemenu
->AppendCheckItem(menu_DUPES_SHOW_FADED
, wmsg(/*&Fade*/408));
882 dupemenu
->AppendCheckItem(menu_DUPES_SHOW_NORMAL
, wmsg(/*&Show*/409));
883 viewmenu
->Append(menu_VIEW_DUPES
, wmsg(/*&Duplicate Legs*/251), dupemenu
);
885 viewmenu
->AppendSeparator();
886 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_OVERLAPPING_NAMES
, wmsg(/*&Overlapping Names*/273));
888 wxMenu
* colourbymenu
= new wxMenu
;
889 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_DEPTH
, wmsg(/*Colour by &Depth*/292));
890 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_DATE
, wmsg(/*Colour by D&ate*/293));
891 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_ERROR
, wmsg(/*Colour by &Error*/289));
892 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_GRADIENT
, wmsg(/*Colour by &Gradient*/85));
893 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_LENGTH
, wmsg(/*Colour by &Length*/82));
895 viewmenu
->Append(menu_VIEW_COLOUR_BY
, wmsg(/*Co&lour by*/450), colourbymenu
);
897 viewmenu
->AppendSeparator();
898 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_ENTRANCES
, wmsg(/*Highlight &Entrances*/294));
899 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_FIXED_PTS
, wmsg(/*Highlight &Fixed Points*/295));
900 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_EXPORTED_PTS
, wmsg(/*Highlight E&xported Points*/296));
901 viewmenu
->AppendSeparator();
903 /* TRANSLATORS: Please don't translate "Escape" - that's the shortcut key
904 * to use which wxWidgets needs to parse and it should then handle
907 viewmenu
-> Append(menu_VIEW_CANCEL_DIST_LINE
, wmsg(/*&Cancel Measuring Line\tEscape*/281));
909 viewmenu
->AppendCheckItem(menu_VIEW_PERSPECTIVE
, wmsg(/*&Perspective*/237));
910 // FIXME: enable this viewmenu->AppendCheckItem(menu_VIEW_SMOOTH_SHADING, wmsg(/*&Smooth Shading*/?!?);
911 viewmenu
->AppendCheckItem(menu_VIEW_TEXTURED
, wmsg(/*Textured &Walls*/238));
912 /* TRANSLATORS: Toggles OpenGL "Depth Fogging" - feel free to translate
913 * using that term instead if it gives a better translation which most
914 * users will understand. */
915 viewmenu
->AppendCheckItem(menu_VIEW_FOG
, wmsg(/*Fade Distant Ob&jects*/239));
916 /* TRANSLATORS: Here a "survey leg" is a set of measurements between two
917 * "survey stations". */
918 viewmenu
->AppendCheckItem(menu_VIEW_SMOOTH_LINES
, wmsg(/*Smoot&hed Survey Legs*/298));
919 viewmenu
->AppendSeparator();
921 // F11 on OS X is used by the desktop (for speaker volume and/or window
922 // navigation). The standard OS X shortcut for full screen mode is
923 // Ctrl-Command-F which in wxWidgets terms is RawCtrl+Ctrl+F.
924 wxString wxmac_fullscreen
= wmsg(/*Full Screen &Mode\tF11*/356);
925 wxmac_fullscreen
.Replace(wxT("\tF11"), wxT("\tRawCtrl+Ctrl+F"), false);
926 viewmenu
->AppendCheckItem(menu_VIEW_FULLSCREEN
, wxmac_fullscreen
);
927 // FIXME: On OS X, the standard wording here is "Enter Full Screen" and
928 // "Exit Full Screen", depending whether we are in full screen mode or not,
929 // and this isn't a checked menu item.
931 viewmenu
->AppendCheckItem(menu_VIEW_FULLSCREEN
, wmsg(/*Full Screen &Mode\tF11*/356));
934 viewmenu
->AppendSeparator();
935 viewmenu
-> Append(wxID_PREFERENCES
, wmsg(/*&Preferences...*/347));
939 wxMenu
* ctlmenu
= new wxMenu
;
940 ctlmenu
->AppendCheckItem(menu_CTL_REVERSE
, wmsg(/*&Reverse Sense\tCtrl+R*/280));
941 ctlmenu
->AppendSeparator();
943 // wxGTK (at least with GTK+ v2.24), if we specify a short-cut here then
944 // the key handler isn't called, so we can't exit full screen mode on
945 // Escape. wxGTK doesn't actually show the "Escape" shortcut text in the
946 // menu item, so removing it doesn't make any visual difference, and doing
947 // so allows Escape to still cancel the measuring line, but also serve to
948 // exit full screen mode if no measuring line is shown.
949 wxString wxgtk_cancelline
= wmsg(/*&Cancel Measuring Line\tEscape*/281);
950 wxgtk_cancelline
.Replace(wxT("\tEscape"), wxT(""), false);
951 ctlmenu
->Append(menu_CTL_CANCEL_DIST_LINE
, wxgtk_cancelline
);
953 // With wxMac and wxMSW, we can have the short-cut on the menu and still
954 // have Escape handled by the key handler to exit full screen mode.
955 ctlmenu
->Append(menu_CTL_CANCEL_DIST_LINE
, wmsg(/*&Cancel Measuring Line\tEscape*/281));
957 ctlmenu
->AppendSeparator();
958 wxMenu
* indmenu
= new wxMenu
;
959 indmenu
->AppendCheckItem(menu_IND_COMPASS
, wmsg(/*&Compass*/274));
960 indmenu
->AppendCheckItem(menu_IND_CLINO
, wmsg(/*C&linometer*/275));
961 /* TRANSLATORS: The "Colour Key" is the thing in aven showing which colour
962 * corresponds to which depth, date, survey closure error, etc. */
963 indmenu
->AppendCheckItem(menu_IND_COLOUR_KEY
, wmsg(/*Colour &Key*/276));
964 indmenu
->AppendCheckItem(menu_IND_SCALE_BAR
, wmsg(/*&Scale Bar*/277));
965 ctlmenu
->Append(menu_CTL_INDICATORS
, wmsg(/*&Indicators*/299), indmenu
);
966 ctlmenu
->AppendCheckItem(menu_CTL_SIDE_PANEL
, wmsg(/*&Side Panel*/337));
967 ctlmenu
->AppendSeparator();
968 ctlmenu
->AppendCheckItem(menu_CTL_METRIC
, wmsg(/*&Metric*/342));
969 ctlmenu
->AppendCheckItem(menu_CTL_DEGREES
, wmsg(/*&Degrees*/343));
970 ctlmenu
->AppendCheckItem(menu_CTL_PERCENT
, wmsg(/*&Percent*/430));
973 wxMenuBar
* menubar
= new wxMenuBar();
974 /* TRANSLATORS: Aven menu titles. An “&” goes before the letter of any
975 * accelerator key. The accelerators must be different within this group
977 menubar
->Append(filemenu
, wmsg(/*&File*/210));
978 menubar
->Append(rotmenu
, wmsg(/*&Rotation*/211));
979 menubar
->Append(orientmenu
, wmsg(/*&Orientation*/212));
980 menubar
->Append(viewmenu
, wmsg(/*&View*/213));
982 menubar
->Append(ctlmenu
, wmsg(/*&Controls*/214));
984 // TRANSLATORS: "Presentation" in the sense of a talk with a slideshow -
985 // the items in this menu allow the user to animate between preset
987 menubar
->Append(presmenu
, wmsg(/*&Presentation*/216));
989 // On wxMac the "About" menu item will be moved elsewhere, so we suppress
990 // this menu since it will then be empty.
991 wxMenu
* helpmenu
= new wxMenu
;
992 helpmenu
->Append(wxID_ABOUT
);
994 menubar
->Append(helpmenu
, wmsg(/*&Help*/215));
999 void MainFrm::MakeToolBar()
1001 // Make the toolbar.
1003 #ifdef USING_GENERIC_TOOLBAR
1004 // This OS-X-specific code is only needed to stop the toolbar icons getting
1005 // scaled up, which just makes them look nasty and fuzzy. Once we have
1006 // larger versions of the icons, we can drop this code.
1007 wxSystemOptions::SetOption(wxT("mac.toolbar.no-native"), 1);
1008 wxToolBar
* toolbar
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
,
1009 wxDefaultSize
, wxNO_BORDER
|wxTB_FLAT
|wxTB_NODIVIDER
|wxTB_NOALIGN
);
1010 wxBoxSizer
* sizer
= new wxBoxSizer(wxVERTICAL
);
1011 sizer
->Add(toolbar
, 0, wxEXPAND
);
1014 wxToolBar
* toolbar
= wxFrame::CreateToolBar();
1018 toolbar
->SetMargins(5, 5);
1021 // FIXME: TRANSLATE tooltips
1022 toolbar
->AddTool(wxID_OPEN
, wxT("Open"), TOOL(open
), wxT("Open a survey file for viewing"));
1023 toolbar
->AddTool(menu_PRES_OPEN
, wxT("Open presentation"), TOOL(open_pres
), wxT("Open a presentation"));
1024 toolbar
->AddCheckTool(menu_FILE_LOG
, wxT("View log"), TOOL(log
), wxNullBitmap
, wxT("View log from processing survey data"));
1025 toolbar
->AddSeparator();
1026 toolbar
->AddCheckTool(menu_ROTATION_TOGGLE
, wxT("Toggle rotation"), TOOL(rotation
), wxNullBitmap
, wxT("Toggle rotation"));
1027 toolbar
->AddTool(menu_ORIENT_PLAN
, wxT("Plan"), TOOL(plan
), wxT("Switch to plan view"));
1028 toolbar
->AddTool(menu_ORIENT_ELEVATION
, wxT("Elevation"), TOOL(elevation
), wxT("Switch to elevation view"));
1029 toolbar
->AddTool(menu_ORIENT_DEFAULTS
, wxT("Default view"), TOOL(defaults
), wxT("Restore default view"));
1030 toolbar
->AddSeparator();
1031 toolbar
->AddCheckTool(menu_VIEW_SHOW_NAMES
, wxT("Names"), TOOL(names
), wxNullBitmap
, wxT("Show station names"));
1032 toolbar
->AddCheckTool(menu_VIEW_SHOW_CROSSES
, wxT("Crosses"), TOOL(crosses
), wxNullBitmap
, wxT("Show crosses on stations"));
1033 toolbar
->AddCheckTool(menu_VIEW_SHOW_ENTRANCES
, wxT("Entrances"), TOOL(entrances
), wxNullBitmap
, wxT("Highlight entrances"));
1034 toolbar
->AddCheckTool(menu_VIEW_SHOW_FIXED_PTS
, wxT("Fixed points"), TOOL(fixed_pts
), wxNullBitmap
, wxT("Highlight fixed points"));
1035 toolbar
->AddCheckTool(menu_VIEW_SHOW_EXPORTED_PTS
, wxT("Exported points"), TOOL(exported_pts
), wxNullBitmap
, wxT("Highlight exported stations"));
1036 toolbar
->AddSeparator();
1037 toolbar
->AddCheckTool(menu_VIEW_SHOW_LEGS
, wxT("Underground legs"), TOOL(ug_legs
), wxNullBitmap
, wxT("Show underground surveys"));
1038 toolbar
->AddCheckTool(menu_VIEW_SHOW_SURFACE
, wxT("Surface legs"), TOOL(surface_legs
), wxNullBitmap
, wxT("Show surface surveys"));
1039 toolbar
->AddCheckTool(menu_VIEW_SHOW_TUBES
, wxT("Tubes"), TOOL(tubes
), wxNullBitmap
, wxT("Show passage tubes"));
1040 toolbar
->AddCheckTool(menu_VIEW_TERRAIN
, wxT("Terrain"), TOOL(solid_surface
), wxNullBitmap
, wxT("Show terrain"));
1041 toolbar
->AddSeparator();
1042 toolbar
->AddCheckTool(menu_PRES_FREWIND
, wxT("Fast Rewind"), TOOL(pres_frew
), wxNullBitmap
, wxT("Very Fast Rewind"));
1043 toolbar
->AddCheckTool(menu_PRES_REWIND
, wxT("Rewind"), TOOL(pres_rew
), wxNullBitmap
, wxT("Fast Rewind"));
1044 toolbar
->AddCheckTool(menu_PRES_REVERSE
, wxT("Backwards"), TOOL(pres_go_back
), wxNullBitmap
, wxT("Play Backwards"));
1045 toolbar
->AddCheckTool(menu_PRES_PAUSE
, wxT("Pause"), TOOL(pres_pause
), wxNullBitmap
, wxT("Pause"));
1046 toolbar
->AddCheckTool(menu_PRES_PLAY
, wxT("Go"), TOOL(pres_go
), wxNullBitmap
, wxT("Play"));
1047 toolbar
->AddCheckTool(menu_PRES_FF
, wxT("FF"), TOOL(pres_ff
), wxNullBitmap
, wxT("Fast Forward"));
1048 toolbar
->AddCheckTool(menu_PRES_FFF
, wxT("Very FF"), TOOL(pres_fff
), wxNullBitmap
, wxT("Very Fast Forward"));
1049 toolbar
->AddTool(wxID_STOP
, wxT("Stop"), TOOL(pres_stop
), wxT("Stop"));
1051 toolbar
->AddSeparator();
1052 m_FindBox
= new wxTextCtrl(toolbar
, textctrl_FIND
, wxString(), wxDefaultPosition
,
1053 wxDefaultSize
, wxTE_PROCESS_ENTER
);
1054 toolbar
->AddControl(m_FindBox
);
1055 /* TRANSLATORS: "Find stations" button tooltip */
1056 toolbar
->AddTool(wxID_FIND
, wmsg(/*Find*/332), TOOL(find
)/*, "Search for station name"*/);
1057 /* TRANSLATORS: "Hide stations" button default tooltip */
1058 toolbar
->AddTool(button_HIDE
, wmsg(/*Hide*/333), TOOL(hideresults
)/*, "Hide search results"*/);
1063 void MainFrm::CreateSidePanel()
1065 m_Splitter
= new AvenSplitterWindow(this);
1066 #ifdef USING_GENERIC_TOOLBAR
1067 // This OS-X-specific code is only needed to stop the toolbar icons getting
1068 // scaled up, which just makes them look nasty and fuzzy. Once we have
1069 // larger versions of the icons, we can drop this code.
1070 GetSizer()->Add(m_Splitter
, 1, wxEXPAND
);
1074 m_Notebook
= new wxNotebook(m_Splitter
, 400, wxDefaultPosition
,
1076 wxBK_BOTTOM
| wxBK_LEFT
);
1077 m_Notebook
->Show(false);
1079 wxPanel
* panel
= new wxPanel(m_Notebook
);
1080 m_Tree
= new AvenTreeCtrl(this, panel
);
1082 // m_RegexpCheckBox = new wxCheckBox(find_panel, -1,
1083 // msg(/*Regular expression*/));
1085 wxBoxSizer
*panel_sizer
= new wxBoxSizer(wxVERTICAL
);
1086 panel_sizer
->Add(m_Tree
, 1, wxALL
| wxEXPAND
, 2);
1087 panel
->SetAutoLayout(true);
1088 panel
->SetSizer(panel_sizer
);
1089 // panel_sizer->SetSizeHints(panel);
1091 m_Control
= new GUIControl();
1092 m_Gfx
= new GfxCore(this, m_Splitter
, m_Control
);
1093 m_Control
->SetView(m_Gfx
);
1095 // Presentation panel:
1096 wxPanel
* prespanel
= new wxPanel(m_Notebook
);
1098 m_PresList
= new AvenPresList(this, prespanel
, m_Gfx
);
1100 wxBoxSizer
*pres_panel_sizer
= new wxBoxSizer(wxVERTICAL
);
1101 pres_panel_sizer
->Add(m_PresList
, 1, wxALL
| wxEXPAND
, 2);
1102 prespanel
->SetAutoLayout(true);
1103 prespanel
->SetSizer(pres_panel_sizer
);
1105 // Overall tabbed structure:
1106 // FIXME: this assumes images are 15x15
1107 wxImageList
* image_list
= new wxImageList(15, 15);
1108 image_list
->Add(TOOL(survey_tree
));
1109 image_list
->Add(TOOL(pres_tree
));
1110 m_Notebook
->SetImageList(image_list
);
1111 /* TRANSLATORS: labels for tabbed side panel this is for the tab with the
1112 * tree hierarchy of survey station names */
1113 m_Notebook
->AddPage(panel
, wmsg(/*Surveys*/376), true, 0);
1114 m_Notebook
->AddPage(prespanel
, wmsg(/*Presentation*/377), false, 1);
1116 m_Splitter
->Initialize(m_Gfx
);
1119 bool MainFrm::LoadData(const wxString
& file
, const wxString
& prefix
)
1121 // Load survey data from file, centre the dataset around the origin,
1122 // and prepare the data for drawing.
1129 int err_msg_code
= Model::Load(file
, prefix
);
1131 wxString m
= wxString::Format(wmsg(err_msg_code
), file
.c_str());
1132 wxGetApp().ReportError(m
);
1136 // Update window title.
1137 SetTitle(GetSurveyTitle() + " - " APP_NAME
);
1139 // Sort the labels ready for filling the tree.
1140 m_Labels
.sort(LabelCmp(GetSeparator()));
1142 // Fill the tree of stations and prefixes.
1143 wxString root_name
= wxFileNameFromPath(file
);
1144 if (!prefix
.empty()) {
1146 root_name
+= prefix
;
1149 FillTree(root_name
);
1151 // Sort labels so that entrances are displayed in preference,
1152 // then fixed points, then exported points, then other points.
1154 // Also sort by leaf name so that we'll tend to choose labels
1155 // from different surveys, rather than labels from surveys which
1156 // are earlier in the list.
1157 m_Labels
.sort(LabelPlotCmp(GetSeparator()));
1159 if (!m_FindBox
->GetValue().empty()) {
1160 // Highlight any stations matching the current search.
1164 m_FileProcessed
= file
;
1170 // Run along a newly read in traverse and make up plausible LRUD where
1173 MainFrm::FixLRUD(traverse
& centreline
)
1175 assert(centreline
.size() > 1);
1177 Double last_size
= 0;
1178 vector
<PointInfo
>::iterator i
= centreline
.begin();
1179 while (i
!= centreline
.end()) {
1180 // Get the coordinates of this vertex.
1181 Point
& pt_v
= *i
++;
1184 if (i
!= centreline
.end()) {
1185 Double h
= sqrd(i
->GetX() - pt_v
.GetX()) +
1186 sqrd(i
->GetY() - pt_v
.GetY());
1187 Double v
= sqrd(i
->GetZ() - pt_v
.GetZ());
1188 if (h
+ v
> 30.0 * 30.0) {
1189 Double scale
= 30.0 / sqrt(h
+ v
);
1193 size
= sqrt(h
+ v
/ 9);
1195 if (i
== centreline
.begin() + 1) {
1199 // Intermediate segment.
1200 swap(size
, last_size
);
1209 Double
& l
= pt_v
.l
;
1210 Double
& r
= pt_v
.r
;
1211 Double
& u
= pt_v
.u
;
1212 Double
& d
= pt_v
.d
;
1214 if (l
== 0 && r
== 0 && u
== 0 && d
== 0) {
1215 l
= r
= u
= d
= -size
;
1217 if (l
< 0 && r
< 0) {
1220 l
= -(2 * size
- r
);
1221 if (l
>= 0) l
= -0.01;
1223 r
= -(2 * size
- l
);
1224 if (r
>= 0) r
= -0.01;
1226 if (u
< 0 && d
< 0) {
1229 u
= -(2 * size
- d
);
1230 if (u
>= 0) u
= -0.01;
1232 d
= -(2 * size
- u
);
1233 if (d
>= 0) d
= -0.01;
1240 void MainFrm::FillTree(const wxString
& root_name
)
1242 m_Tree
->DeleteAllItems();
1244 // Create the root of the tree.
1245 wxTreeItemId treeroot
= m_Tree
->AddRoot(root_name
);
1247 // Fill the tree of stations and prefixes.
1248 stack
<wxTreeItemId
> previous_ids
;
1249 wxString current_prefix
;
1250 wxTreeItemId current_id
= treeroot
;
1251 const wxChar separator
= GetSeparator();
1253 list
<LabelInfo
*>::iterator pos
= m_Labels
.begin();
1254 while (pos
!= m_Labels
.end()) {
1255 LabelInfo
* label
= *pos
++;
1257 if (label
->IsAnon()) continue;
1259 // Determine the current prefix.
1260 wxString prefix
= label
->GetText().BeforeLast(separator
);
1262 // Determine if we're still on the same prefix.
1263 if (prefix
== current_prefix
) {
1264 // no need to fiddle with branches...
1266 // If not, then see if we've descended to a new prefix.
1267 else if (prefix
.length() > current_prefix
.length() &&
1268 prefix
.StartsWith(current_prefix
) &&
1269 (prefix
[current_prefix
.length()] == separator
||
1270 current_prefix
.empty())) {
1271 // We have, so start as many new branches as required.
1272 int current_prefix_length
= current_prefix
.length();
1273 current_prefix
= prefix
;
1274 size_t next_dot
= current_prefix_length
;
1275 if (!next_dot
) --next_dot
;
1277 size_t prev_dot
= next_dot
+ 1;
1279 // Extract the next bit of prefix.
1280 next_dot
= prefix
.find(separator
, prev_dot
+ 1);
1282 wxString bit
= prefix
.substr(prev_dot
, next_dot
- prev_dot
);
1283 assert(!bit
.empty());
1285 // Add the current tree ID to the stack.
1286 previous_ids
.push(current_id
);
1288 // Append the new item to the tree and set this as the current branch.
1289 current_id
= m_Tree
->AppendItem(current_id
, bit
);
1290 m_Tree
->SetItemData(current_id
, new TreeData(prefix
.substr(0, next_dot
)));
1291 } while (next_dot
!= wxString::npos
);
1293 // Otherwise, we must have moved up, and possibly then down again.
1296 bool ascent_only
= (prefix
.length() < current_prefix
.length() &&
1297 current_prefix
.StartsWith(prefix
) &&
1298 (current_prefix
[prefix
.length()] == separator
||
1301 // Find out how much of the current prefix and the new prefix
1303 // Note that we require a match of a whole number of parts
1305 size_t n
= min(prefix
.length(), current_prefix
.length());
1307 for (i
= 0; i
< n
&& prefix
[i
] == current_prefix
[i
]; ++i
) {
1308 if (prefix
[i
] == separator
) count
= i
+ 1;
1311 count
= prefix
.length() + 1;
1314 // Extract the part of the current prefix after the bit (if any)
1315 // which has matched.
1316 // This gives the prefixes to ascend over.
1317 wxString prefixes_ascended
= current_prefix
.substr(count
);
1319 // Count the number of prefixes to ascend over.
1320 int num_prefixes
= prefixes_ascended
.Freq(separator
);
1322 // Reverse up over these prefixes.
1323 for (int i
= 1; i
<= num_prefixes
; i
++) {
1326 current_id
= previous_ids
.top();
1330 // Add branches for this new part.
1331 size_t next_dot
= count
- 1;
1333 size_t prev_dot
= next_dot
+ 1;
1335 // Extract the next bit of prefix.
1336 next_dot
= prefix
.find(separator
, prev_dot
+ 1);
1338 wxString bit
= prefix
.substr(prev_dot
, next_dot
- prev_dot
);
1339 assert(!bit
.empty());
1341 // Add the current tree ID to the stack.
1342 previous_ids
.push(current_id
);
1344 // Append the new item to the tree and set this as the current branch.
1345 current_id
= m_Tree
->AppendItem(current_id
, bit
);
1346 m_Tree
->SetItemData(current_id
, new TreeData(prefix
.substr(0, next_dot
)));
1347 } while (next_dot
!= wxString::npos
);
1350 current_prefix
= prefix
;
1353 // Now add the leaf.
1354 wxString bit
= label
->GetText().AfterLast(separator
);
1355 assert(!bit
.empty());
1356 wxTreeItemId id
= m_Tree
->AppendItem(current_id
, bit
);
1357 m_Tree
->SetItemData(id
, new TreeData(label
));
1358 label
->tree_id
= id
;
1359 // Set the colour for an item in the survey tree.
1360 if (label
->IsEntrance()) {
1361 // Entrances are green (like entrance blobs).
1362 m_Tree
->SetItemTextColour(id
, wxColour(0, 255, 40));
1363 } else if (label
->IsSurface()) {
1364 // Surface stations are dark green.
1365 m_Tree
->SetItemTextColour(id
, wxColour(49, 158, 79));
1369 m_Tree
->Expand(treeroot
);
1370 m_Tree
->SetEnabled();
1373 void MainFrm::OnMRUFile(wxCommandEvent
& event
)
1375 wxString
f(m_history
.GetHistoryFile(event
.GetId() - wxID_FILE1
));
1376 if (!f
.empty()) OpenFile(f
);
1379 void MainFrm::AddToFileHistory(const wxString
& file
)
1381 if (wxIsAbsolutePath(file
)) {
1382 m_history
.AddFileToHistory(file
);
1384 wxString abs
= wxGetCwd();
1385 abs
+= wxCONFIG_PATH_SEPARATOR
;
1387 m_history
.AddFileToHistory(abs
);
1389 wxConfigBase
*b
= wxConfigBase::Get();
1394 void MainFrm::OpenFile(const wxString
& file
, const wxString
& survey
)
1396 wxBusyCursor hourglass
;
1398 // Check if this is an unprocessed survey data file.
1399 if (file
.length() > 4 && file
[file
.length() - 4] == '.') {
1400 wxString
ext(file
, file
.length() - 3, 3);
1402 if (ext
== wxT("svx") || ext
== wxT("dat") || ext
== wxT("mak")) {
1403 CavernLogWindow
* log
= new CavernLogWindow(this, survey
, m_Splitter
);
1404 wxWindow
* win
= m_Splitter
->GetWindow1();
1405 m_Splitter
->ReplaceWindow(win
, log
);
1407 if (m_Splitter
->GetWindow2() == NULL
) {
1408 if (win
!= m_Gfx
) win
->Destroy();
1410 if (m_Splitter
->IsSplit()) m_Splitter
->Unsplit();
1413 if (wxFileExists(file
)) AddToFileHistory(file
);
1415 // Log window will tell us to load file if it successfully completes.
1420 if (!LoadData(file
, survey
))
1422 AddToFileHistory(file
);
1423 InitialiseAfterLoad(file
, survey
);
1425 // If aven is showing the log for a .svx file and you load a .3d file, then
1426 // at this point m_Log will be the log window for the .svx file, so destroy
1427 // it - it should never legitimately be set if we get here.
1434 void MainFrm::InitialiseAfterLoad(const wxString
& file
, const wxString
& prefix
)
1436 if (m_SashPosition
< 0) {
1437 // Calculate sane default width for side panel.
1440 GetClientSize(&x
, &y
);
1450 // Do this before we potentially delete the log window which may own the
1451 // wxString which parameter file refers to!
1452 bool same_file
= (file
== m_File
);
1457 wxWindow
* win
= NULL
;
1458 if (m_Splitter
->GetWindow2() == NULL
) {
1459 win
= m_Splitter
->GetWindow1();
1460 if (win
== m_Gfx
) win
= NULL
;
1463 if (!IsFullScreen()) {
1464 m_Splitter
->SplitVertically(m_Notebook
, m_Gfx
, m_SashPosition
);
1466 was_showing_sidepanel_before_fullscreen
= true;
1469 m_Gfx
->Initialise(same_file
);
1472 // FIXME: check it actually is the log window!
1473 if (m_Log
&& m_Log
!= win
)
1479 if (!IsFullScreen()) {
1480 m_Notebook
->Show(true);
1487 void MainFrm::HideLog(wxWindow
* log_window
)
1489 if (!IsFullScreen()) {
1490 m_Splitter
->SplitVertically(m_Notebook
, m_Gfx
, m_SashPosition
);
1496 if (!IsFullScreen()) {
1497 m_Notebook
->Show(true);
1505 // UI event handlers
1508 // For Unix we want "*.svx;*.SVX" while for Windows we only want "*.svx".
1512 # define CASE(X) ";" X
1515 void MainFrm::OnOpen(wxCommandEvent
&)
1517 AvenAllowOnTop
ontop(this);
1519 wxString filetypes
= wxT("*.3d");
1522 filetypes
.Printf(wxT("%s|*.3d;*.svx;*.plt;*.plf;*.dat;*.mak;*.adj;*.sht;*.una;*.xyz"
1523 CASE("*.3D;*.SVX;*.PLT;*.PLF;*.DAT;*.MAK;*.ADJ;*.SHT;*.UNA;*.XYZ")
1524 "|%s|*.3d" CASE("*.3D")
1525 "|%s|*.svx" CASE("*.SVX")
1526 "|%s|*.plt;*.plf" CASE("*.PLT;*.PLF")
1527 "|%s|*.dat;*.mak" CASE("*.DAT;*.MAK")
1528 "|%s|*.adj;*.sht;*.una;*.xyz" CASE("*.ADJ;*.SHT;*.UNA;*.XYZ")
1530 /* TRANSLATORS: Here "survey" is a "cave map" rather than
1531 * list of questions - it should be translated to the
1532 * terminology that cavers using the language would use.
1534 wmsg(/*All survey files*/229).c_str(),
1535 /* TRANSLATORS: Survex is the name of the software, and "3d" refers to a
1536 * file extension, so neither should be translated. */
1537 wmsg(/*Survex 3d files*/207).c_str(),
1538 /* TRANSLATORS: Survex is the name of the software, and "svx" refers to a
1539 * file extension, so neither should be translated. */
1540 wmsg(/*Survex svx files*/329).c_str(),
1541 /* TRANSLATORS: "Compass" as in Larry Fish’s cave
1542 * surveying package, so probably shouldn’t be translated
1544 wmsg(/*Compass PLT files*/324).c_str(),
1545 /* TRANSLATORS: "Compass" as in Larry Fish’s cave
1546 * surveying package, so should not be translated
1548 wmsg(/*Compass DAT and MAK files*/330).c_str(),
1549 /* TRANSLATORS: "CMAP" is Bob Thrun’s cave surveying
1550 * package, so don’t translate it. */
1551 wmsg(/*CMAP XYZ files*/325).c_str(),
1552 wmsg(/*All files*/208).c_str(),
1553 wxFileSelectorDefaultWildcardStr
);
1555 /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions
1556 * - it should be translated to the terminology that cavers using the
1557 * language would use.
1559 * File->Open dialog: */
1560 wxFileDialog
dlg(this, wmsg(/*Select a survey file to view*/206),
1561 wxString(), wxString(),
1562 filetypes
, wxFD_OPEN
|wxFD_FILE_MUST_EXIST
);
1563 if (dlg
.ShowModal() == wxID_OK
) {
1564 OpenFile(dlg
.GetPath());
1568 void MainFrm::OnOpenTerrain(wxCommandEvent
&)
1572 if (GetCSProj().empty()) {
1573 wxMessageBox(wxT("No coordinate system specified in survey data"));
1578 wxString filetypes
= wxT("*.*");
1581 filetypes
.Printf(wxT("%s|*.bil;*.hgt;*.zip" CASE("*.BIL;*.HGT;*.ZIP")
1583 wmsg(/*Terrain files*/452).c_str(),
1584 wmsg(/*All files*/208).c_str(),
1585 wxFileSelectorDefaultWildcardStr
);
1587 /* TRANSLATORS: "Terrain file" being a digital model of the terrain (e.g. a
1588 * grid of height values). */
1589 wxFileDialog
dlg(this, wmsg(/*Select a terrain file to view*/451),
1590 wxString(), wxString(),
1591 filetypes
, wxFD_OPEN
|wxFD_FILE_MUST_EXIST
);
1592 if (dlg
.ShowModal() == wxID_OK
&& m_Gfx
->LoadDEM(dlg
.GetPath())) {
1593 if (!m_Gfx
->DisplayingTerrain()) m_Gfx
->ToggleTerrain();
1597 void MainFrm::OnShowLog(wxCommandEvent
&)
1600 HideLog(m_Splitter
->GetWindow1());
1603 wxWindow
* win
= m_Splitter
->GetWindow1();
1604 m_Splitter
->ReplaceWindow(win
, m_Log
);
1606 if (m_Splitter
->IsSplit()) {
1607 m_SashPosition
= m_Splitter
->GetSashPosition(); // save width of panel
1608 m_Splitter
->Unsplit();
1615 void MainFrm::OnScreenshot(wxCommandEvent
&)
1617 AvenAllowOnTop
ontop(this);
1619 wxFileName::SplitPath(m_File
, NULL
, NULL
, &baseleaf
, NULL
, wxPATH_NATIVE
);
1620 /* TRANSLATORS: title of the save screenshot dialog */
1621 wxFileDialog
dlg(this, wmsg(/*Save Screenshot*/321), wxString(),
1622 baseleaf
+ wxT(".png"),
1623 wxT("*.png"), wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1624 if (dlg
.ShowModal() == wxID_OK
) {
1625 static bool png_handled
= false;
1627 #if 0 // FIXME : enable this to allow other export formats...
1628 ::wxInitAllImageHandlers();
1630 wxImage::AddHandler(new wxPNGHandler
);
1634 if (!m_Gfx
->SaveScreenshot(dlg
.GetPath(), wxBITMAP_TYPE_PNG
)) {
1635 wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), dlg
.GetPath().c_str()));
1640 void MainFrm::OnScreenshotUpdate(wxUpdateUIEvent
& event
)
1642 event
.Enable(!m_File
.empty());
1645 void MainFrm::OnFilePreferences(wxCommandEvent
&)
1648 m_PrefsDlg
= new PrefsDlg(m_Gfx
, this);
1649 m_PrefsDlg
->Show(true);
1653 void MainFrm::OnPrint(wxCommandEvent
&)
1655 m_Gfx
->OnPrint(m_File
, GetSurveyTitle(),
1656 GetDateString(), GetCSProj());
1659 void MainFrm::PrintAndExit()
1661 m_Gfx
->OnPrint(m_File
, GetSurveyTitle(),
1662 GetDateString(), GetCSProj(), true);
1665 void MainFrm::OnPageSetup(wxCommandEvent
&)
1667 wxPageSetupDialog
dlg(this, wxGetApp().GetPageSetupDialogData());
1668 if (dlg
.ShowModal() == wxID_OK
) {
1669 wxGetApp().SetPageSetupDialogData(dlg
.GetPageSetupData());
1673 void MainFrm::OnExport(wxCommandEvent
&)
1675 m_Gfx
->OnExport(m_File
, GetSurveyTitle(),
1676 GetDateString(), GetCSProj());
1679 void MainFrm::OnExtend(wxCommandEvent
&)
1681 wxString output
= m_Survey
;
1682 if (output
.empty()) {
1683 wxFileName::SplitPath(m_File
, NULL
, NULL
, &output
, NULL
, wxPATH_NATIVE
);
1685 output
+= wxT("_extend.3d");
1687 AvenAllowOnTop
ontop(this);
1689 wxString
ext(wxT("*.3d"));
1691 /* TRANSLATORS: Survex is the name of the software, and "3d" refers to a
1692 * file extension, so neither should be translated. */
1693 wxString ext
= wmsg(/*Survex 3d files*/207);
1694 ext
+= wxT("|*.3d");
1696 wxFileDialog
dlg(this, wmsg(/*Select an output filename*/319),
1697 wxString(), output
, ext
,
1698 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1699 if (dlg
.ShowModal() != wxID_OK
) return;
1700 output
= dlg
.GetPath();
1702 wxString cmd
= get_command_path(L
"extend");
1703 cmd
= escape_for_shell(cmd
, false);
1704 if (!m_Survey
.empty()) {
1705 cmd
+= wxT(" --survey=");
1706 cmd
+= escape_for_shell(m_Survey
, false);
1708 cmd
+= wxT(" --show-breaks ");
1709 cmd
+= escape_for_shell(m_FileProcessed
, true);
1711 cmd
+= escape_for_shell(output
, true);
1712 if (wxExecute(cmd
, wxEXEC_SYNC
) < 0) {
1714 m
.Printf(wmsg(/*Couldn’t run external command: “%s”*/17), cmd
.c_str());
1716 m
+= wxString(strerror(errno
), wxConvUTF8
);
1718 wxGetApp().ReportError(m
);
1721 if (LoadData(output
, wxString()))
1722 InitialiseAfterLoad(output
, wxString());
1725 void MainFrm::OnQuit(wxCommandEvent
&)
1727 if (m_PresList
->Modified()) {
1728 AvenAllowOnTop
ontop(this);
1729 // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel]
1730 /* TRANSLATORS: and the question in that box */
1731 if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327),
1732 /* TRANSLATORS: title of message box */
1733 wmsg(/*Modified Presentation*/326),
1734 wxOK
|wxCANCEL
|wxICON_QUESTION
) == wxCANCEL
) {
1738 wxConfigBase
*b
= wxConfigBase::Get();
1739 if (IsFullScreen()) {
1740 b
->Write(wxT("width"), -2);
1741 b
->DeleteEntry(wxT("height"));
1742 } else if (IsMaximized()) {
1743 b
->Write(wxT("width"), -1);
1744 b
->DeleteEntry(wxT("height"));
1747 GetSize(&width
, &height
);
1748 b
->Write(wxT("width"), width
);
1749 b
->Write(wxT("height"), height
);
1755 void MainFrm::OnClose(wxCloseEvent
&)
1757 wxCommandEvent dummy
;
1761 void MainFrm::OnAbout(wxCommandEvent
&)
1763 AvenAllowOnTop
ontop(this);
1765 // GetIcon() returns an invalid wxIcon under OS X.
1766 AboutDlg
dlg(this, wxICON(aven
));
1768 AboutDlg
dlg(this, GetIcon());
1774 void MainFrm::UpdateStatusBar()
1776 if (!here_text
.empty()) {
1777 GetStatusBar()->SetStatusText(here_text
);
1778 GetStatusBar()->SetStatusText(dist_text
, 1);
1779 } else if (!coords_text
.empty()) {
1780 GetStatusBar()->SetStatusText(coords_text
);
1781 GetStatusBar()->SetStatusText(distfree_text
, 1);
1783 GetStatusBar()->SetStatusText(wxString());
1784 GetStatusBar()->SetStatusText(wxString(), 1);
1788 void MainFrm::ClearTreeSelection()
1790 m_Tree
->UnselectAll();
1795 void MainFrm::ClearCoords()
1797 if (!coords_text
.empty()) {
1798 coords_text
= wxString();
1803 void MainFrm::SetCoords(const Vector3
&v
)
1805 Double x
= v
.GetX();
1806 Double y
= v
.GetY();
1807 Double z
= v
.GetZ();
1809 if (m_Gfx
->GetMetric()) {
1812 x
/= METRES_PER_FOOT
;
1813 y
/= METRES_PER_FOOT
;
1814 z
/= METRES_PER_FOOT
;
1817 /* TRANSLATORS: show coordinates (N = North or Northing, E = East or
1819 coords_text
.Printf(wmsg(/*%.2f E, %.2f N*/338), x
, y
);
1820 coords_text
+= wxString::Format(wxT(", %s %.2f%s"),
1821 wmsg(/*Altitude*/335).c_str(),
1822 z
, wmsg(units
).c_str());
1823 distfree_text
= wxString();
1827 const LabelInfo
* MainFrm::GetTreeSelection() const {
1828 wxTreeItemData
* sel_wx
;
1829 if (!m_Tree
->GetSelectionData(&sel_wx
)) return NULL
;
1831 const TreeData
* data
= static_cast<const TreeData
*>(sel_wx
);
1832 if (!data
->IsStation()) return NULL
;
1834 return data
->GetLabel();
1837 void MainFrm::SetCoords(Double x
, Double y
, const LabelInfo
* there
)
1839 wxString
& s
= coords_text
;
1840 if (m_Gfx
->GetMetric()) {
1841 s
.Printf(wmsg(/*%.2f E, %.2f N*/338), x
, y
);
1843 s
.Printf(wmsg(/*%.2f E, %.2f N*/338),
1844 x
/ METRES_PER_FOOT
, y
/ METRES_PER_FOOT
);
1847 wxString
& t
= distfree_text
;
1849 if (m_Gfx
->ShowingMeasuringLine() && there
) {
1850 auto offset
= GetOffset();
1851 Vector3
delta(x
- offset
.GetX() - there
->GetX(),
1852 y
- offset
.GetY() - there
->GetY(), 0);
1853 Double dh
= sqrt(delta
.GetX()*delta
.GetX() + delta
.GetY()*delta
.GetY());
1854 Double brg
= deg(atan2(delta
.GetX(), delta
.GetY()));
1855 if (brg
< 0) brg
+= 360;
1858 /* TRANSLATORS: Used in Aven:
1859 * From <stationname>: H 12.24m, Brg 234.5°
1861 from_str
.Printf(wmsg(/*From %s*/339), there
->name_or_anon().c_str());
1863 if (m_Gfx
->GetDegrees()) {
1864 brg_unit
= /*°*/344;
1866 brg
*= 400.0 / 360.0;
1867 brg_unit
= /*ᵍ*/345;
1871 if (m_Gfx
->GetMetric()) {
1874 dh
/= METRES_PER_FOOT
;
1877 /* TRANSLATORS: "H" is short for "Horizontal", "Brg" for "Bearing" (as
1878 * in Compass bearing) */
1879 t
.Printf(wmsg(/*%s: H %.2f%s, Brg %03.1f%s*/374),
1880 from_str
.c_str(), dh
, wmsg(units
).c_str(),
1881 brg
, wmsg(brg_unit
).c_str());
1887 void MainFrm::SetAltitude(Double z
, const LabelInfo
* there
)
1891 if (m_Gfx
->GetMetric()) {
1894 alt
/= METRES_PER_FOOT
;
1897 coords_text
.Printf(wxT("%s %.2f%s"), wmsg(/*Altitude*/335).c_str(),
1898 alt
, wmsg(units
).c_str());
1900 wxString
& t
= distfree_text
;
1902 if (m_Gfx
->ShowingMeasuringLine() && there
) {
1903 Double dz
= z
- GetOffset().GetZ() - there
->GetZ();
1906 from_str
.Printf(wmsg(/*From %s*/339), there
->name_or_anon().c_str());
1908 if (!m_Gfx
->GetMetric()) {
1909 dz
/= METRES_PER_FOOT
;
1911 // TRANSLATORS: "V" is short for "Vertical"
1912 t
.Printf(wmsg(/*%s: V %.2f%s*/375), from_str
.c_str(),
1913 dz
, wmsg(units
).c_str());
1919 void MainFrm::ShowInfo(const LabelInfo
*here
, const LabelInfo
*there
)
1925 m_Tree
->SetHere(wxTreeItemId());
1926 // Don't clear "There" mark here.
1927 if (here_text
.empty() && dist_text
.empty()) return;
1928 here_text
= wxString();
1929 dist_text
= wxString();
1934 Vector3 v
= *here
+ GetOffset();
1935 wxString
& s
= here_text
;
1936 Double x
= v
.GetX();
1937 Double y
= v
.GetY();
1938 Double z
= v
.GetZ();
1940 if (m_Gfx
->GetMetric()) {
1943 x
/= METRES_PER_FOOT
;
1944 y
/= METRES_PER_FOOT
;
1945 z
/= METRES_PER_FOOT
;
1948 s
.Printf(wmsg(/*%.2f E, %.2f N*/338), x
, y
);
1949 s
+= wxString::Format(wxT(", %s %.2f%s"), wmsg(/*Altitude*/335).c_str(),
1950 z
, wmsg(units
).c_str());
1952 s
+= here
->name_or_anon();
1953 m_Gfx
->SetHere(here
);
1954 m_Tree
->SetHere(here
->tree_id
);
1956 if (m_Gfx
->ShowingMeasuringLine() && there
) {
1957 Vector3 delta
= *here
- *there
;
1959 Double d_horiz
= sqrt(delta
.GetX()*delta
.GetX() +
1960 delta
.GetY()*delta
.GetY());
1961 Double dr
= delta
.magnitude();
1962 Double dz
= delta
.GetZ();
1964 Double brg
= deg(atan2(delta
.GetX(), delta
.GetY()));
1965 if (brg
< 0) brg
+= 360;
1967 Double grd
= deg(atan2(delta
.GetZ(), d_horiz
));
1970 from_str
.Printf(wmsg(/*From %s*/339), there
->name_or_anon().c_str());
1973 if (m_Gfx
->GetMetric()) {
1976 d_horiz
/= METRES_PER_FOOT
;
1977 dr
/= METRES_PER_FOOT
;
1978 dz
/= METRES_PER_FOOT
;
1981 wxString len_unit
= wmsg(units
);
1982 /* TRANSLATORS: "H" is short for "Horizontal", "V" for "Vertical" */
1983 hv_str
.Printf(wmsg(/*H %.2f%s, V %.2f%s*/340),
1984 d_horiz
, len_unit
.c_str(), dz
, len_unit
.c_str());
1986 if (m_Gfx
->GetDegrees()) {
1987 brg_unit
= /*°*/344;
1989 brg
*= 400.0 / 360.0;
1990 brg_unit
= /*ᵍ*/345;
1994 if (m_Gfx
->GetPercent()) {
1997 } else if (grd
< -89.99) {
2000 grd
= int(100 * tan(rad(grd
)));
2002 if (grd
> 99999 || grd
< -99999) {
2003 grd_str
= grd
> 0 ? wxT("+") : wxT("-");
2004 /* TRANSLATORS: infinity symbol - used for the percentage gradient on
2005 * vertical angles. */
2006 grd_str
+= wmsg(/*∞*/431);
2009 } else if (m_Gfx
->GetDegrees()) {
2010 grd_unit
= /*°*/344;
2012 grd
*= 400.0 / 360.0;
2013 grd_unit
= /*ᵍ*/345;
2015 if (grd_str
.empty()) {
2016 grd_str
.Printf(wxT("%+02.1f%s"), grd
, wmsg(grd_unit
).c_str());
2019 wxString
& d
= dist_text
;
2020 /* TRANSLATORS: "Dist" is short for "Distance", "Brg" for "Bearing" (as
2021 * in Compass bearing) and "Grd" for "Gradient" (the slope angle
2022 * measured by the clino) */
2023 d
.Printf(wmsg(/*%s: %s, Dist %.2f%s, Brg %03.1f%s, Grd %s*/341),
2024 from_str
.c_str(), hv_str
.c_str(),
2025 dr
, len_unit
.c_str(),
2026 brg
, wmsg(brg_unit
).c_str(),
2029 dist_text
= wxString();
2035 void MainFrm::DisplayTreeInfo(const wxTreeItemData
* item
)
2037 const TreeData
* data
= static_cast<const TreeData
*>(item
);
2038 if (data
&& data
->IsStation()) {
2039 m_Gfx
->SetHereFromTree(data
->GetLabel());
2045 void MainFrm::TreeItemSelected(const wxTreeItemData
* item
, bool zoom
)
2047 const TreeData
* data
= static_cast<const TreeData
*>(item
);
2048 if (data
&& data
->IsStation()) {
2049 const LabelInfo
* label
= data
->GetLabel();
2050 if (zoom
) m_Gfx
->CentreOn(*label
);
2051 m_Gfx
->SetThere(label
);
2052 dist_text
= wxString();
2053 // FIXME: Need to update dist_text (From ... etc)
2054 // But we don't currently know where "here" is at this point in the
2057 dist_text
= wxString();
2061 // Must be the root.
2062 m_FindBox
->SetValue(wxString());
2064 wxCommandEvent dummy
;
2067 } else if (data
&& !data
->IsStation()) {
2068 m_FindBox
->SetValue(data
->GetSurvey() + wxT(".*"));
2070 wxCommandEvent dummy
;
2077 void MainFrm::OnPresNew(wxCommandEvent
&)
2079 if (m_PresList
->Modified()) {
2080 AvenAllowOnTop
ontop(this);
2081 // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel]
2082 if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327),
2083 wmsg(/*Modified Presentation*/326),
2084 wxOK
|wxCANCEL
|wxICON_QUESTION
) == wxCANCEL
) {
2088 m_PresList
->New(m_File
);
2089 if (!ShowingSidePanel()) ToggleSidePanel();
2090 // Select the presentation page in the notebook.
2091 m_Notebook
->SetSelection(1);
2094 void MainFrm::OnPresOpen(wxCommandEvent
&)
2096 AvenAllowOnTop
ontop(this);
2097 if (m_PresList
->Modified()) {
2098 // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel]
2099 if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327),
2100 wmsg(/*Modified Presentation*/326),
2101 wxOK
|wxCANCEL
|wxICON_QUESTION
) == wxCANCEL
) {
2106 wxFileDialog
dlg(this, wmsg(/*Select a presentation to open*/322), wxString(), wxString(),
2107 wxT("*.fly"), wxFD_OPEN
);
2109 wxFileDialog
dlg(this, wmsg(/*Select a presentation to open*/322), wxString(), wxString(),
2110 wxString::Format(wxT("%s|*.fly|%s|%s"),
2111 wmsg(/*Aven presentations*/320).c_str(),
2112 wmsg(/*All files*/208).c_str(),
2113 wxFileSelectorDefaultWildcardStr
),
2114 wxFD_OPEN
|wxFD_FILE_MUST_EXIST
);
2116 if (dlg
.ShowModal() == wxID_OK
) {
2117 if (!m_PresList
->Load(dlg
.GetPath())) {
2120 // FIXME : keep a history of loaded/saved presentations, like we do for
2121 // loaded surveys...
2122 // Select the presentation page in the notebook.
2123 m_Notebook
->SetSelection(1);
2127 void MainFrm::OnPresSave(wxCommandEvent
&)
2129 m_PresList
->Save(true);
2132 void MainFrm::OnPresSaveAs(wxCommandEvent
&)
2134 m_PresList
->Save(false);
2137 void MainFrm::OnPresMark(wxCommandEvent
&)
2139 m_PresList
->AddMark();
2142 void MainFrm::OnPresFRewind(wxCommandEvent
&)
2144 m_Gfx
->PlayPres(-100);
2147 void MainFrm::OnPresRewind(wxCommandEvent
&)
2149 m_Gfx
->PlayPres(-10);
2152 void MainFrm::OnPresReverse(wxCommandEvent
&)
2154 m_Gfx
->PlayPres(-1);
2157 void MainFrm::OnPresPlay(wxCommandEvent
&)
2162 void MainFrm::OnPresFF(wxCommandEvent
&)
2164 m_Gfx
->PlayPres(10);
2167 void MainFrm::OnPresFFF(wxCommandEvent
&)
2169 m_Gfx
->PlayPres(100);
2172 void MainFrm::OnPresPause(wxCommandEvent
&)
2177 void MainFrm::OnPresStop(wxCommandEvent
&)
2179 m_Gfx
->PlayPres(0, false);
2182 void MainFrm::OnPresExportMovie(wxCommandEvent
&)
2185 AvenAllowOnTop
ontop(this);
2186 // FIXME : Taking the leaf of the currently loaded presentation as the
2187 // default might make more sense?
2189 wxFileName::SplitPath(m_File
, NULL
, NULL
, &baseleaf
, NULL
, wxPATH_NATIVE
);
2190 wxFileDialog
dlg(this, wmsg(/*Export Movie*/331), wxString(),
2191 baseleaf
+ wxT(".mp4"),
2192 wxT("MPEG|*.mp4|OGG|*.ogv|AVI|*.avi|QuickTime|*.mov|WMV|*.wmv;*.asf"),
2193 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
2194 if (dlg
.ShowModal() == wxID_OK
) {
2195 // Error is reported by GfxCore.
2196 (void)m_Gfx
->ExportMovie(dlg
.GetPath());
2199 wxGetApp().ReportError(wxT("Movie generation support code not present"));
2203 PresentationMark
MainFrm::GetPresMark(int which
)
2205 return m_PresList
->GetPresMark(which
);
2208 void MainFrm::RestrictTo(const wxString
& survey
)
2210 // The station names will change, so clear the current search.
2211 wxCommandEvent dummy
;
2214 wxString new_prefix
;
2215 if (!survey
.empty()) {
2216 if (!m_Survey
.empty()) {
2217 new_prefix
= m_Survey
;
2218 new_prefix
+= GetSeparator();
2220 new_prefix
+= survey
;
2222 // Reload the processed data rather rather than potentially reprocessing.
2223 if (!LoadData(m_FileProcessed
, new_prefix
))
2225 InitialiseAfterLoad(m_File
, new_prefix
);
2228 void MainFrm::OnOpenTerrainUpdate(wxUpdateUIEvent
& event
)
2230 event
.Enable(!m_File
.empty());
2233 void MainFrm::OnPresNewUpdate(wxUpdateUIEvent
& event
)
2235 event
.Enable(!m_File
.empty());
2238 void MainFrm::OnPresOpenUpdate(wxUpdateUIEvent
& event
)
2240 event
.Enable(!m_File
.empty());
2243 void MainFrm::OnPresSaveUpdate(wxUpdateUIEvent
& event
)
2245 event
.Enable(!m_PresList
->Empty());
2248 void MainFrm::OnPresSaveAsUpdate(wxUpdateUIEvent
& event
)
2250 event
.Enable(!m_PresList
->Empty());
2253 void MainFrm::OnPresMarkUpdate(wxUpdateUIEvent
& event
)
2255 event
.Enable(!m_File
.empty());
2258 void MainFrm::OnPresFRewindUpdate(wxUpdateUIEvent
& event
)
2260 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2261 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() < -10);
2264 void MainFrm::OnPresRewindUpdate(wxUpdateUIEvent
& event
)
2266 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2267 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() == -10);
2270 void MainFrm::OnPresReverseUpdate(wxUpdateUIEvent
& event
)
2272 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2273 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() == -1);
2276 void MainFrm::OnPresPlayUpdate(wxUpdateUIEvent
& event
)
2278 event
.Enable(!m_PresList
->Empty());
2279 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationMode() &&
2280 m_Gfx
->GetPresentationSpeed() == 1);
2283 void MainFrm::OnPresFFUpdate(wxUpdateUIEvent
& event
)
2285 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2286 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() == 10);
2289 void MainFrm::OnPresFFFUpdate(wxUpdateUIEvent
& event
)
2291 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2292 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() > 10);
2295 void MainFrm::OnPresPauseUpdate(wxUpdateUIEvent
& event
)
2297 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2298 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() == 0);
2301 void MainFrm::OnPresStopUpdate(wxUpdateUIEvent
& event
)
2303 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2306 void MainFrm::OnPresExportMovieUpdate(wxUpdateUIEvent
& event
)
2308 event
.Enable(!m_PresList
->Empty());
2311 void MainFrm::OnFind(wxCommandEvent
&)
2313 pending_find
= true;
2316 void MainFrm::OnIdle(wxIdleEvent
&)
2323 void MainFrm::DoFind()
2325 pending_find
= false;
2326 wxBusyCursor hourglass
;
2327 // Find stations specified by a string or regular expression pattern.
2329 wxString pattern
= m_FindBox
->GetValue();
2330 if (pattern
.empty()) {
2331 // Hide any search result highlights.
2332 list
<LabelInfo
*>::iterator pos
= m_Labels
.begin();
2333 while (pos
!= m_Labels
.end()) {
2334 LabelInfo
* label
= *pos
++;
2335 label
->clear_flags(LFLAG_HIGHLIGHTED
);
2337 m_NumHighlighted
= 0;
2339 int re_flags
= wxRE_NOSUB
;
2341 if (true /* case insensitive */) {
2342 re_flags
|= wxRE_ICASE
;
2345 bool substring
= true;
2346 if (false /*m_RegexpCheckBox->GetValue()*/) {
2347 re_flags
|= wxRE_EXTENDED
;
2348 } else if (true /* simple glob-style */) {
2350 for (size_t i
= 0; i
< pattern
.size(); i
++) {
2351 wxChar ch
= pattern
[i
];
2352 // ^ only special at start; $ at end. But this is simpler...
2354 case '^': case '$': case '.': case '[': case '\\':
2371 re_flags
|= wxRE_BASIC
;
2374 for (size_t i
= 0; i
< pattern
.size(); i
++) {
2375 wxChar ch
= pattern
[i
];
2376 // ^ only special at start; $ at end. But this is simpler...
2378 case '^': case '$': case '*': case '.': case '[': case '\\':
2384 re_flags
|= wxRE_BASIC
;
2388 // FIXME "0u" required to avoid compilation error with g++-3.0
2389 if (pattern
.empty() || pattern
[0u] != '^') pattern
= wxT('^') + pattern
;
2390 // FIXME: this fails to cope with "\$" at the end of pattern...
2391 if (pattern
[pattern
.size() - 1] != '$') pattern
+= wxT('$');
2395 if (!regex
.Compile(pattern
, re_flags
)) {
2402 list
<LabelInfo
*>::iterator pos
= m_Labels
.begin();
2403 while (pos
!= m_Labels
.end()) {
2404 LabelInfo
* label
= *pos
++;
2406 if (regex
.Matches(label
->GetText())) {
2407 label
->set_flags(LFLAG_HIGHLIGHTED
);
2410 label
->clear_flags(LFLAG_HIGHLIGHTED
);
2414 m_NumHighlighted
= found
;
2416 // Re-sort so highlighted points get names in preference
2417 if (found
) m_Labels
.sort(LabelPlotCmp(GetSeparator()));
2420 m_Gfx
->UpdateBlobs();
2421 m_Gfx
->ForceRefresh();
2423 if (!m_NumHighlighted
) {
2424 GetToolBar()->SetToolShortHelp(button_HIDE
, wmsg(/*No matches were found.*/328));
2426 /* TRANSLATORS: "Hide stations" button tooltip when stations are found
2428 GetToolBar()->SetToolShortHelp(button_HIDE
, wxString::Format(wmsg(/*Hide %d found stations*/334).c_str(), m_NumHighlighted
));
2432 void MainFrm::OnGotoFound(wxCommandEvent
&)
2434 if (!m_NumHighlighted
) {
2435 wxGetApp().ReportError(wmsg(/*No matches were found.*/328));
2439 Double xmin
= DBL_MAX
;
2440 Double xmax
= -DBL_MAX
;
2441 Double ymin
= DBL_MAX
;
2442 Double ymax
= -DBL_MAX
;
2443 Double zmin
= DBL_MAX
;
2444 Double zmax
= -DBL_MAX
;
2446 list
<LabelInfo
*>::iterator pos
= m_Labels
.begin();
2447 while (pos
!= m_Labels
.end()) {
2448 LabelInfo
* label
= *pos
++;
2450 if (label
->get_flags() & LFLAG_HIGHLIGHTED
) {
2451 if (label
->GetX() < xmin
) xmin
= label
->GetX();
2452 if (label
->GetX() > xmax
) xmax
= label
->GetX();
2453 if (label
->GetY() < ymin
) ymin
= label
->GetY();
2454 if (label
->GetY() > ymax
) ymax
= label
->GetY();
2455 if (label
->GetZ() < zmin
) zmin
= label
->GetZ();
2456 if (label
->GetZ() > zmax
) zmax
= label
->GetZ();
2460 m_Gfx
->SetViewTo(xmin
, xmax
, ymin
, ymax
, zmin
, zmax
);
2464 void MainFrm::OnHide(wxCommandEvent
&)
2466 m_FindBox
->SetValue(wxString());
2467 GetToolBar()->SetToolShortHelp(button_HIDE
, wmsg(/*Hide*/333));
2470 void MainFrm::OnHideUpdate(wxUpdateUIEvent
& ui
)
2472 ui
.Enable(m_NumHighlighted
!= 0);
2475 void MainFrm::OnViewSidePanel(wxCommandEvent
&)
2480 void MainFrm::ToggleSidePanel()
2482 // Toggle display of the side panel.
2486 if (m_Splitter
->IsSplit()) {
2487 m_SashPosition
= m_Splitter
->GetSashPosition(); // save width of panel
2488 m_Splitter
->Unsplit(m_Notebook
);
2490 m_Notebook
->Show(true);
2492 m_Splitter
->SplitVertically(m_Notebook
, m_Gfx
, m_SashPosition
);
2496 void MainFrm::OnViewSidePanelUpdate(wxUpdateUIEvent
& ui
)
2498 ui
.Enable(!m_File
.empty());
2499 ui
.Check(ShowingSidePanel());
2502 bool MainFrm::ShowingSidePanel()
2504 return m_Splitter
->IsSplit();
2507 void MainFrm::ViewFullScreen() {
2509 // On OS X, wxWidgets doesn't currently hide the toolbar or statusbar in
2510 // full screen mode (last checked with 3.0.2), but it is easy to do
2512 if (!IsFullScreen()) {
2513 GetToolBar()->Hide();
2514 GetStatusBar()->Hide();
2518 ShowFullScreen(!IsFullScreen());
2519 fullscreen_showing_menus
= false;
2521 was_showing_sidepanel_before_fullscreen
= ShowingSidePanel();
2522 if (was_showing_sidepanel_before_fullscreen
)
2526 if (!IsFullScreen()) {
2527 GetStatusBar()->Show();
2528 GetToolBar()->Show();
2529 #ifdef USING_GENERIC_TOOLBAR
2536 bool MainFrm::FullScreenModeShowingMenus() const
2538 return fullscreen_showing_menus
;
2541 void MainFrm::FullScreenModeShowMenus(bool show
)
2543 if (!IsFullScreen() || show
== fullscreen_showing_menus
)
2546 // On OS X, enabling the menu bar while in full
2547 // screen mode doesn't have any effect, so instead
2548 // make moving the mouse to the top of the screen
2549 // drop us out of full screen mode for now.
2552 GetMenuBar()->Show(show
);
2553 fullscreen_showing_menus
= show
;