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>
60 // XPM files declare the array as static, but we also want it to be const too.
61 // This avoids a compiler warning, and also means the data can go in a
62 // read-only page and be shared between processes.
63 #define static static const
65 #include "../lib/icons/aven.xpm"
67 #include "../lib/icons/log.xpm"
68 #include "../lib/icons/open.xpm"
69 #include "../lib/icons/open_pres.xpm"
70 #include "../lib/icons/rotation.xpm"
71 #include "../lib/icons/plan.xpm"
72 #include "../lib/icons/elevation.xpm"
73 #include "../lib/icons/defaults.xpm"
74 #include "../lib/icons/names.xpm"
75 #include "../lib/icons/crosses.xpm"
76 #include "../lib/icons/entrances.xpm"
77 #include "../lib/icons/fixed_pts.xpm"
78 #include "../lib/icons/exported_pts.xpm"
79 #include "../lib/icons/ug_legs.xpm"
80 #include "../lib/icons/surface_legs.xpm"
81 #include "../lib/icons/tubes.xpm"
82 #include "../lib/icons/solid_surface.xpm"
83 #include "../lib/icons/pres_frew.xpm"
84 #include "../lib/icons/pres_rew.xpm"
85 #include "../lib/icons/pres_go_back.xpm"
86 #include "../lib/icons/pres_pause.xpm"
87 #include "../lib/icons/pres_go.xpm"
88 #include "../lib/icons/pres_ff.xpm"
89 #include "../lib/icons/pres_fff.xpm"
90 #include "../lib/icons/pres_stop.xpm"
91 #include "../lib/icons/find.xpm"
92 #include "../lib/icons/hideresults.xpm"
93 #include "../lib/icons/survey_tree.xpm"
94 #include "../lib/icons/pres_tree.xpm"
97 # define TOOL(x) wxBitmap(x##_xpm)
99 # define TOOL(x) wxBITMAP(x)
104 class AvenSplitterWindow
: public wxSplitterWindow
{
108 explicit AvenSplitterWindow(MainFrm
*parent_
)
109 : wxSplitterWindow(parent_
, -1, wxDefaultPosition
, wxDefaultSize
,
115 void OnSplitterDClick(wxSplitterEvent
&) {
116 parent
->ToggleSidePanel();
120 DECLARE_EVENT_TABLE()
123 BEGIN_EVENT_TABLE(AvenSplitterWindow
, wxSplitterWindow
)
124 EVT_SPLITTER_DCLICK(-1, AvenSplitterWindow::OnSplitterDClick
)
127 class EditMarkDlg
: public wxDialog
{
128 wxTextCtrl
* easting
, * northing
, * altitude
;
129 wxTextCtrl
* angle
, * tilt_angle
, * scale
, * time
;
131 // TRANSLATORS: Title of dialog to edit a waypoint in a presentation.
132 EditMarkDlg(wxWindow
* parent
, const PresentationMark
& p
)
133 : wxDialog(parent
, 500, wmsg(/*Edit Waypoint*/404))
135 easting
= new wxTextCtrl(this, 601, wxString::Format(wxT("%.3f"), p
.GetX()));
136 northing
= new wxTextCtrl(this, 602, wxString::Format(wxT("%.3f"), p
.GetY()));
137 altitude
= new wxTextCtrl(this, 603, wxString::Format(wxT("%.3f"), p
.GetZ()));
138 angle
= new wxTextCtrl(this, 604, wxString::Format(wxT("%.3f"), p
.angle
));
139 tilt_angle
= new wxTextCtrl(this, 605, wxString::Format(wxT("%.3f"), p
.tilt_angle
));
140 scale
= new wxTextCtrl(this, 606, wxString::Format(wxT("%.3f"), p
.scale
));
142 time
= new wxTextCtrl(this, 607, wxString::Format(wxT("%.3f"), p
.time
));
143 } else if (p
.time
< 0.0) {
144 time
= new wxTextCtrl(this, 607, wxString::Format(wxT("*%.3f"), -p
.time
));
146 time
= new wxTextCtrl(this, 607, wxT("0"));
149 wxBoxSizer
* coords
= new wxBoxSizer(wxHORIZONTAL
);
150 coords
->Add(new wxStaticText(this, 610, wxT("(")), 0, wxALIGN_CENTRE_VERTICAL
);
151 coords
->Add(easting
, 1);
152 coords
->Add(new wxStaticText(this, 611, wxT(",")), 0, wxALIGN_CENTRE_VERTICAL
);
153 coords
->Add(northing
, 1);
154 coords
->Add(new wxStaticText(this, 612, wxT(",")), 0, wxALIGN_CENTRE_VERTICAL
);
155 coords
->Add(altitude
, 1);
156 coords
->Add(new wxStaticText(this, 613, wxT(")")), 0, wxALIGN_CENTRE_VERTICAL
);
157 wxBoxSizer
* vert
= new wxBoxSizer(wxVERTICAL
);
158 vert
->Add(coords
, 0, wxALL
, 8);
159 wxBoxSizer
* r2
= new wxBoxSizer(wxHORIZONTAL
);
160 r2
->Add(new wxStaticText(this, 614, wmsg(/*Bearing*/259) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL
);
162 vert
->Add(r2
, 0, wxALL
, 8);
163 wxBoxSizer
* r3
= new wxBoxSizer(wxHORIZONTAL
);
164 r3
->Add(new wxStaticText(this, 615, wmsg(/*Elevation*/118) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL
);
166 vert
->Add(r3
, 0, wxALL
, 8);
167 wxBoxSizer
* r4
= new wxBoxSizer(wxHORIZONTAL
);
168 r4
->Add(new wxStaticText(this, 616, wmsg(/*Scale*/154) + wxT(": ")), 0, wxALIGN_CENTRE_VERTICAL
);
170 /* TRANSLATORS: Note after "Scale" field in dialog to edit a waypoint
171 * in a presentation. */
172 r4
->Add(new wxStaticText(this, 617, wmsg(/* (unused in perspective view)*/278)),
173 0, wxALIGN_CENTRE_VERTICAL
);
174 vert
->Add(r4
, 0, wxALL
, 8);
176 wxBoxSizer
* r5
= new wxBoxSizer(wxHORIZONTAL
);
177 /* TRANSLATORS: Field label in dialog to edit a waypoint in a
179 r5
->Add(new wxStaticText(this, 616, wmsg(/*Time: */279)), 0, wxALIGN_CENTRE_VERTICAL
);
181 /* TRANSLATORS: units+info after time field in dialog to edit a
182 * waypoint in a presentation. */
183 r5
->Add(new wxStaticText(this, 617, wmsg(/* secs (0 = auto; *6 = 6 times auto)*/282)),
184 0, wxALIGN_CENTRE_VERTICAL
);
185 vert
->Add(r5
, 0, wxALL
, 8);
187 wxBoxSizer
* buttons
= new wxBoxSizer(wxHORIZONTAL
);
188 wxButton
* cancel
= new wxButton(this, wxID_CANCEL
);
189 buttons
->Add(cancel
, 0, wxALL
, 8);
190 wxButton
* ok
= new wxButton(this, wxID_OK
);
192 buttons
->Add(ok
, 0, wxALL
, 8);
193 vert
->Add(buttons
, 0, wxALL
|wxALIGN_RIGHT
);
198 vert
->SetSizeHints(this);
200 PresentationMark
GetMark() const {
202 Vector3
v(wxAtof(easting
->GetValue()),
203 wxAtof(northing
->GetValue()),
204 wxAtof(altitude
->GetValue()));
205 a
= wxAtof(angle
->GetValue());
206 t
= wxAtof(tilt_angle
->GetValue());
207 s
= wxAtof(scale
->GetValue());
208 wxString str
= time
->GetValue();
209 if (!str
.empty() && str
[0u] == '*') str
[0u] = '-';
211 return PresentationMark(v
, a
, t
, s
, T
);
215 DECLARE_EVENT_TABLE()
218 // Write a value without trailing zeros after the decimal point.
219 static void write_double(double d
, FILE * fh
) {
221 sprintf(buf
, "%.21f", d
);
222 char * p
= strchr(buf
, ',');
224 size_t l
= strlen(buf
);
225 while (l
> 1 && buf
[l
- 1] == '0') --l
;
226 if (l
> 1 && buf
[l
- 1] == '.') --l
;
227 fwrite(buf
, l
, 1, fh
);
230 class AvenPresList
: public wxListCtrl
{
233 vector
<PresentationMark
> entries
;
240 AvenPresList(MainFrm
* mainfrm_
, wxWindow
* parent
, GfxCore
* gfx_
)
241 : wxListCtrl(parent
, listctrl_PRES
, wxDefaultPosition
, wxDefaultSize
,
242 wxLC_REPORT
|wxLC_VIRTUAL
),
243 mainfrm(mainfrm_
), gfx(gfx_
), current_item(-1), modified(false),
246 InsertColumn(0, wmsg(/*Easting*/378));
247 InsertColumn(1, wmsg(/*Northing*/379));
248 InsertColumn(2, wmsg(/*Altitude*/335));
251 void OnBeginLabelEdit(wxListEvent
& event
) {
252 event
.Veto(); // No editting allowed
254 void OnDeleteItem(wxListEvent
& event
) {
255 long item
= event
.GetIndex();
256 if (current_item
== item
) {
258 } else if (current_item
> item
) {
261 entries
.erase(entries
.begin() + item
);
262 SetItemCount(entries
.size());
265 void OnDeleteAllItems(wxListEvent
&) {
267 SetItemCount(entries
.size());
268 filename
= wxString();
270 force_save_as
= true;
272 void OnListKeyDown(wxListEvent
& event
) {
273 switch (event
.GetKeyCode()) {
275 long item
= GetNextItem(-1, wxLIST_NEXT_ALL
,
276 wxLIST_STATE_SELECTED
);
279 // - 1 because the indices were shifted by DeleteItem()
280 item
= GetNextItem(item
- 1, wxLIST_NEXT_ALL
,
281 wxLIST_STATE_SELECTED
);
286 //printf("event.GetIndex() = %ld %d\n", event.GetIndex(), event.GetKeyCode());
290 void OnActivated(wxListEvent
& event
) {
291 // Jump to this view.
292 long item
= event
.GetIndex();
293 gfx
->SetView(entries
[item
]);
295 void OnFocused(wxListEvent
& event
) {
296 current_item
= event
.GetIndex();
298 void OnRightClick(wxListEvent
& event
) {
299 long item
= event
.GetIndex();
301 AddMark(item
, gfx
->GetView());
304 EditMarkDlg
edit(mainfrm
, entries
[item
]);
305 if (edit
.ShowModal() == wxID_OK
) {
306 entries
[item
] = edit
.GetMark();
309 void OnChar(wxKeyEvent
& event
) {
310 switch (event
.GetKeyCode()) {
312 if (event
.GetModifiers() == wxMOD_CONTROL
) {
313 if (current_item
!= -1 &&
314 size_t(current_item
) < entries
.size()) {
315 AddMark(current_item
, entries
[current_item
]);
318 AddMark(current_item
);
322 // Already handled in OnListKeyDown.
324 case WXK_UP
: case WXK_DOWN
:
328 gfx
->OnKeyPress(event
);
331 void AddMark(long item
= -1) {
332 AddMark(item
, gfx
->GetView());
334 void AddMark(long item
, const PresentationMark
& mark
) {
335 if (item
== -1) item
= entries
.size();
336 entries
.insert(entries
.begin() + item
, mark
);
337 SetItemCount(entries
.size());
340 virtual wxString
OnGetItemText(long item
, long column
) const {
341 if (item
< 0 || item
>= (long)entries
.size()) return wxString();
342 const PresentationMark
& p
= entries
[item
];
345 case 0: v
= p
.GetX(); break;
346 case 1: v
= p
.GetY(); break;
347 case 2: v
= p
.GetZ(); break;
349 case 3: v
= p
.angle
; break;
350 case 4: v
= p
.tilt_angle
; break;
351 case 5: v
= p
.scale
; break;
352 case 6: v
= p
.time
; break;
354 default: return wxString();
356 return wxString::Format(wxT("%ld"), (long)v
);
358 void Save(bool use_default_name
) {
359 wxString fnm
= filename
;
360 if (!use_default_name
|| force_save_as
) {
361 AvenAllowOnTop
ontop(mainfrm
);
363 wxString
ext(wxT("*.fly"));
365 wxString ext
= wmsg(/*Aven presentations*/320);
366 ext
+= wxT("|*.fly");
368 wxFileDialog
dlg(this, wmsg(/*Select an output filename*/319),
369 wxString(), fnm
, ext
,
370 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
371 if (dlg
.ShowModal() != wxID_OK
) return;
375 FILE * fh_pres
= wxFopen(fnm
, wxT("w"));
377 wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), fnm
.c_str()));
380 vector
<PresentationMark
>::const_iterator i
;
381 for (i
= entries
.begin(); i
!= entries
.end(); ++i
) {
382 const PresentationMark
&p
= *i
;
383 write_double(p
.GetX(), fh_pres
);
385 write_double(p
.GetY(), fh_pres
);
387 write_double(p
.GetZ(), fh_pres
);
389 write_double(p
.angle
, fh_pres
);
391 write_double(p
.tilt_angle
, fh_pres
);
393 write_double(p
.scale
, fh_pres
);
396 write_double(p
.time
, fh_pres
);
403 force_save_as
= false;
405 void New(const wxString
&fnm
) {
407 wxFileName::SplitPath(fnm
, NULL
, NULL
, &filename
, NULL
, wxPATH_NATIVE
);
408 filename
+= wxT(".fly");
409 force_save_as
= true;
411 bool Load(const wxString
&fnm
) {
412 FILE * fh_pres
= wxFopen(fnm
, wxT("r"));
415 m
.Printf(wmsg(/*Couldn’t open file “%s”*/24), fnm
.c_str());
416 wxGetApp().ReportError(m
);
421 while (!feof(fh_pres
)) {
424 while (i
< sizeof(buf
) - 1) {
425 int ch
= GETC(fh_pres
);
426 if (ch
== EOF
|| ch
== '\n' || ch
== '\r') break;
431 double x
, y
, z
, a
, t
, s
, T
;
432 int c
= sscanf(buf
, "%lf %lf %lf %lf %lf %lf %lf", &x
, &y
, &z
, &a
, &t
, &s
, &T
);
435 while ((p
= strchr(p
, '.'))) *p
++ = ',';
436 c
= sscanf(buf
, "%lf %lf %lf %lf %lf %lf %lf", &x
, &y
, &z
, &a
, &t
, &s
, &T
);
439 wxGetApp().ReportError(wxString::Format(wmsg(/*Error in format of presentation file “%s”*/323), fnm
.c_str()));
444 AddMark(item
, PresentationMark(Vector3(x
, y
, z
), a
, t
, s
, T
));
451 force_save_as
= false;
454 bool Modified() const { return modified
; }
455 bool Empty() const { return entries
.empty(); }
456 PresentationMark
GetPresMark(int which
) {
457 long item
= current_item
;
458 if (which
== MARK_FIRST
) {
460 } else if (which
== MARK_NEXT
) {
462 } else if (which
== MARK_PREV
) {
465 if (item
== -1 || item
== (long)entries
.size())
466 return PresentationMark();
467 if (item
!= current_item
) {
469 if (current_item
!= -1) {
470 wxListCtrl::SetItemState(current_item
, wxLIST_STATE_FOCUSED
,
473 wxListCtrl::SetItemState(item
, wxLIST_STATE_FOCUSED
,
474 wxLIST_STATE_FOCUSED
);
476 return entries
[item
];
481 DECLARE_NO_COPY_CLASS(AvenPresList
)
482 DECLARE_EVENT_TABLE()
485 BEGIN_EVENT_TABLE(EditMarkDlg
, wxDialog
)
488 BEGIN_EVENT_TABLE(AvenPresList
, wxListCtrl
)
489 EVT_LIST_BEGIN_LABEL_EDIT(listctrl_PRES
, AvenPresList::OnBeginLabelEdit
)
490 EVT_LIST_DELETE_ITEM(listctrl_PRES
, AvenPresList::OnDeleteItem
)
491 EVT_LIST_DELETE_ALL_ITEMS(listctrl_PRES
, AvenPresList::OnDeleteAllItems
)
492 EVT_LIST_KEY_DOWN(listctrl_PRES
, AvenPresList::OnListKeyDown
)
493 EVT_LIST_ITEM_ACTIVATED(listctrl_PRES
, AvenPresList::OnActivated
)
494 EVT_LIST_ITEM_FOCUSED(listctrl_PRES
, AvenPresList::OnFocused
)
495 EVT_LIST_ITEM_RIGHT_CLICK(listctrl_PRES
, AvenPresList::OnRightClick
)
496 EVT_CHAR(AvenPresList::OnChar
)
499 BEGIN_EVENT_TABLE(MainFrm
, wxFrame
)
500 EVT_TEXT(textctrl_FIND
, MainFrm::OnFind
)
501 EVT_TEXT_ENTER(textctrl_FIND
, MainFrm::OnGotoFound
)
502 EVT_MENU(wxID_FIND
, MainFrm::OnGotoFound
)
503 EVT_MENU(button_HIDE
, MainFrm::OnHide
)
504 EVT_UPDATE_UI(button_HIDE
, MainFrm::OnHideUpdate
)
505 EVT_IDLE(MainFrm::OnIdle
)
507 EVT_MENU(wxID_OPEN
, MainFrm::OnOpen
)
508 EVT_MENU(menu_FILE_OPEN_TERRAIN
, MainFrm::OnOpenTerrain
)
509 EVT_MENU(menu_FILE_LOG
, MainFrm::OnShowLog
)
510 EVT_MENU(wxID_PRINT
, MainFrm::OnPrint
)
511 EVT_MENU(menu_FILE_PAGE_SETUP
, MainFrm::OnPageSetup
)
512 EVT_MENU(menu_FILE_SCREENSHOT
, MainFrm::OnScreenshot
)
513 // EVT_MENU(wxID_PREFERENCES, MainFrm::OnFilePreferences)
514 EVT_MENU(menu_FILE_EXPORT
, MainFrm::OnExport
)
515 EVT_MENU(menu_FILE_EXTEND
, MainFrm::OnExtend
)
516 EVT_MENU(wxID_EXIT
, MainFrm::OnQuit
)
517 EVT_MENU_RANGE(wxID_FILE1
, wxID_FILE9
, MainFrm::OnMRUFile
)
519 EVT_MENU(menu_PRES_NEW
, MainFrm::OnPresNew
)
520 EVT_MENU(menu_PRES_OPEN
, MainFrm::OnPresOpen
)
521 EVT_MENU(menu_PRES_SAVE
, MainFrm::OnPresSave
)
522 EVT_MENU(menu_PRES_SAVE_AS
, MainFrm::OnPresSaveAs
)
523 EVT_MENU(menu_PRES_MARK
, MainFrm::OnPresMark
)
524 EVT_MENU(menu_PRES_FREWIND
, MainFrm::OnPresFRewind
)
525 EVT_MENU(menu_PRES_REWIND
, MainFrm::OnPresRewind
)
526 EVT_MENU(menu_PRES_REVERSE
, MainFrm::OnPresReverse
)
527 EVT_MENU(menu_PRES_PLAY
, MainFrm::OnPresPlay
)
528 EVT_MENU(menu_PRES_FF
, MainFrm::OnPresFF
)
529 EVT_MENU(menu_PRES_FFF
, MainFrm::OnPresFFF
)
530 EVT_MENU(menu_PRES_PAUSE
, MainFrm::OnPresPause
)
531 EVT_MENU(wxID_STOP
, MainFrm::OnPresStop
)
532 EVT_MENU(menu_PRES_EXPORT_MOVIE
, MainFrm::OnPresExportMovie
)
534 EVT_UPDATE_UI(menu_PRES_NEW
, MainFrm::OnPresNewUpdate
)
535 EVT_UPDATE_UI(menu_PRES_OPEN
, MainFrm::OnPresOpenUpdate
)
536 EVT_UPDATE_UI(menu_PRES_SAVE
, MainFrm::OnPresSaveUpdate
)
537 EVT_UPDATE_UI(menu_PRES_SAVE_AS
, MainFrm::OnPresSaveAsUpdate
)
538 EVT_UPDATE_UI(menu_PRES_MARK
, MainFrm::OnPresMarkUpdate
)
539 EVT_UPDATE_UI(menu_PRES_FREWIND
, MainFrm::OnPresFRewindUpdate
)
540 EVT_UPDATE_UI(menu_PRES_REWIND
, MainFrm::OnPresRewindUpdate
)
541 EVT_UPDATE_UI(menu_PRES_REVERSE
, MainFrm::OnPresReverseUpdate
)
542 EVT_UPDATE_UI(menu_PRES_PLAY
, MainFrm::OnPresPlayUpdate
)
543 EVT_UPDATE_UI(menu_PRES_FF
, MainFrm::OnPresFFUpdate
)
544 EVT_UPDATE_UI(menu_PRES_FFF
, MainFrm::OnPresFFFUpdate
)
545 EVT_UPDATE_UI(menu_PRES_PAUSE
, MainFrm::OnPresPauseUpdate
)
546 EVT_UPDATE_UI(wxID_STOP
, MainFrm::OnPresStopUpdate
)
547 EVT_UPDATE_UI(menu_PRES_EXPORT_MOVIE
, MainFrm::OnPresExportMovieUpdate
)
549 EVT_CLOSE(MainFrm::OnClose
)
550 EVT_SET_FOCUS(MainFrm::OnSetFocus
)
552 EVT_MENU(menu_ROTATION_TOGGLE
, MainFrm::OnToggleRotation
)
553 EVT_MENU(menu_ROTATION_REVERSE
, MainFrm::OnReverseDirectionOfRotation
)
554 EVT_MENU(menu_ORIENT_MOVE_NORTH
, MainFrm::OnMoveNorth
)
555 EVT_MENU(menu_ORIENT_MOVE_EAST
, MainFrm::OnMoveEast
)
556 EVT_MENU(menu_ORIENT_MOVE_SOUTH
, MainFrm::OnMoveSouth
)
557 EVT_MENU(menu_ORIENT_MOVE_WEST
, MainFrm::OnMoveWest
)
558 EVT_MENU(menu_ORIENT_PLAN
, MainFrm::OnPlan
)
559 EVT_MENU(menu_ORIENT_ELEVATION
, MainFrm::OnElevation
)
560 EVT_MENU(menu_ORIENT_DEFAULTS
, MainFrm::OnDefaults
)
561 EVT_MENU(menu_VIEW_SHOW_LEGS
, MainFrm::OnShowSurveyLegs
)
562 EVT_MENU(menu_SPLAYS_HIDE
, MainFrm::OnHideSplays
)
563 EVT_MENU(menu_SPLAYS_SHOW_DASHED
, MainFrm::OnShowSplaysDashed
)
564 EVT_MENU(menu_SPLAYS_SHOW_FADED
, MainFrm::OnShowSplaysFaded
)
565 EVT_MENU(menu_SPLAYS_SHOW_NORMAL
, MainFrm::OnShowSplaysNormal
)
566 EVT_MENU(menu_DUPES_HIDE
, MainFrm::OnHideDupes
)
567 EVT_MENU(menu_DUPES_SHOW_DASHED
, MainFrm::OnShowDupesDashed
)
568 EVT_MENU(menu_DUPES_SHOW_FADED
, MainFrm::OnShowDupesFaded
)
569 EVT_MENU(menu_DUPES_SHOW_NORMAL
, MainFrm::OnShowDupesNormal
)
570 EVT_MENU(menu_VIEW_SHOW_CROSSES
, MainFrm::OnShowCrosses
)
571 EVT_MENU(menu_VIEW_SHOW_ENTRANCES
, MainFrm::OnShowEntrances
)
572 EVT_MENU(menu_VIEW_SHOW_FIXED_PTS
, MainFrm::OnShowFixedPts
)
573 EVT_MENU(menu_VIEW_SHOW_EXPORTED_PTS
, MainFrm::OnShowExportedPts
)
574 EVT_MENU(menu_VIEW_SHOW_NAMES
, MainFrm::OnShowStationNames
)
575 EVT_MENU(menu_VIEW_SHOW_OVERLAPPING_NAMES
, MainFrm::OnDisplayOverlappingNames
)
576 EVT_MENU(menu_COLOUR_BY_DEPTH
, MainFrm::OnColourByDepth
)
577 EVT_MENU(menu_COLOUR_BY_DATE
, MainFrm::OnColourByDate
)
578 EVT_MENU(menu_COLOUR_BY_ERROR
, MainFrm::OnColourByError
)
579 EVT_MENU(menu_COLOUR_BY_GRADIENT
, MainFrm::OnColourByGradient
)
580 EVT_MENU(menu_COLOUR_BY_LENGTH
, MainFrm::OnColourByLength
)
581 EVT_MENU(menu_VIEW_SHOW_SURFACE
, MainFrm::OnShowSurface
)
582 EVT_MENU(menu_VIEW_GRID
, MainFrm::OnViewGrid
)
583 EVT_MENU(menu_VIEW_BOUNDING_BOX
, MainFrm::OnViewBoundingBox
)
584 EVT_MENU(menu_VIEW_PERSPECTIVE
, MainFrm::OnViewPerspective
)
585 EVT_MENU(menu_VIEW_SMOOTH_SHADING
, MainFrm::OnViewSmoothShading
)
586 EVT_MENU(menu_VIEW_TEXTURED
, MainFrm::OnViewTextured
)
587 EVT_MENU(menu_VIEW_FOG
, MainFrm::OnViewFog
)
588 EVT_MENU(menu_VIEW_SMOOTH_LINES
, MainFrm::OnViewSmoothLines
)
589 EVT_MENU(menu_VIEW_FULLSCREEN
, MainFrm::OnViewFullScreen
)
590 EVT_MENU(menu_VIEW_SHOW_TUBES
, MainFrm::OnToggleTubes
)
591 EVT_MENU(menu_VIEW_TERRAIN
, MainFrm::OnViewTerrain
)
592 EVT_MENU(menu_IND_COMPASS
, MainFrm::OnViewCompass
)
593 EVT_MENU(menu_IND_CLINO
, MainFrm::OnViewClino
)
594 EVT_MENU(menu_IND_COLOUR_KEY
, MainFrm::OnToggleColourKey
)
595 EVT_MENU(menu_IND_SCALE_BAR
, MainFrm::OnToggleScalebar
)
596 EVT_MENU(menu_CTL_SIDE_PANEL
, MainFrm::OnViewSidePanel
)
597 EVT_MENU(menu_CTL_METRIC
, MainFrm::OnToggleMetric
)
598 EVT_MENU(menu_CTL_DEGREES
, MainFrm::OnToggleDegrees
)
599 EVT_MENU(menu_CTL_PERCENT
, MainFrm::OnTogglePercent
)
600 EVT_MENU(menu_CTL_REVERSE
, MainFrm::OnReverseControls
)
601 EVT_MENU(menu_CTL_CANCEL_DIST_LINE
, MainFrm::OnCancelDistLine
)
602 EVT_MENU(wxID_ABOUT
, MainFrm::OnAbout
)
604 EVT_UPDATE_UI(menu_FILE_OPEN_TERRAIN
, MainFrm::OnOpenTerrainUpdate
)
605 EVT_UPDATE_UI(menu_FILE_LOG
, MainFrm::OnShowLogUpdate
)
606 EVT_UPDATE_UI(wxID_PRINT
, MainFrm::OnPrintUpdate
)
607 EVT_UPDATE_UI(menu_FILE_SCREENSHOT
, MainFrm::OnScreenshotUpdate
)
608 EVT_UPDATE_UI(menu_FILE_EXPORT
, MainFrm::OnExportUpdate
)
609 EVT_UPDATE_UI(menu_FILE_EXTEND
, MainFrm::OnExtendUpdate
)
610 EVT_UPDATE_UI(menu_ROTATION_TOGGLE
, MainFrm::OnToggleRotationUpdate
)
611 EVT_UPDATE_UI(menu_ROTATION_REVERSE
, MainFrm::OnReverseDirectionOfRotationUpdate
)
612 EVT_UPDATE_UI(menu_ORIENT_MOVE_NORTH
, MainFrm::OnMoveNorthUpdate
)
613 EVT_UPDATE_UI(menu_ORIENT_MOVE_EAST
, MainFrm::OnMoveEastUpdate
)
614 EVT_UPDATE_UI(menu_ORIENT_MOVE_SOUTH
, MainFrm::OnMoveSouthUpdate
)
615 EVT_UPDATE_UI(menu_ORIENT_MOVE_WEST
, MainFrm::OnMoveWestUpdate
)
616 EVT_UPDATE_UI(menu_ORIENT_PLAN
, MainFrm::OnPlanUpdate
)
617 EVT_UPDATE_UI(menu_ORIENT_ELEVATION
, MainFrm::OnElevationUpdate
)
618 EVT_UPDATE_UI(menu_ORIENT_DEFAULTS
, MainFrm::OnDefaultsUpdate
)
619 EVT_UPDATE_UI(menu_VIEW_SHOW_LEGS
, MainFrm::OnShowSurveyLegsUpdate
)
620 EVT_UPDATE_UI(menu_VIEW_SPLAYS
, MainFrm::OnSplaysUpdate
)
621 EVT_UPDATE_UI(menu_SPLAYS_HIDE
, MainFrm::OnHideSplaysUpdate
)
622 EVT_UPDATE_UI(menu_SPLAYS_SHOW_DASHED
, MainFrm::OnShowSplaysDashedUpdate
)
623 EVT_UPDATE_UI(menu_SPLAYS_SHOW_FADED
, MainFrm::OnShowSplaysFadedUpdate
)
624 EVT_UPDATE_UI(menu_SPLAYS_SHOW_NORMAL
, MainFrm::OnShowSplaysNormalUpdate
)
625 EVT_UPDATE_UI(menu_VIEW_DUPES
, MainFrm::OnDupesUpdate
)
626 EVT_UPDATE_UI(menu_DUPES_HIDE
, MainFrm::OnHideDupesUpdate
)
627 EVT_UPDATE_UI(menu_DUPES_SHOW_DASHED
, MainFrm::OnShowDupesDashedUpdate
)
628 EVT_UPDATE_UI(menu_DUPES_SHOW_FADED
, MainFrm::OnShowDupesFadedUpdate
)
629 EVT_UPDATE_UI(menu_DUPES_SHOW_NORMAL
, MainFrm::OnShowDupesNormalUpdate
)
630 EVT_UPDATE_UI(menu_VIEW_SHOW_CROSSES
, MainFrm::OnShowCrossesUpdate
)
631 EVT_UPDATE_UI(menu_VIEW_SHOW_ENTRANCES
, MainFrm::OnShowEntrancesUpdate
)
632 EVT_UPDATE_UI(menu_VIEW_SHOW_FIXED_PTS
, MainFrm::OnShowFixedPtsUpdate
)
633 EVT_UPDATE_UI(menu_VIEW_SHOW_EXPORTED_PTS
, MainFrm::OnShowExportedPtsUpdate
)
634 EVT_UPDATE_UI(menu_VIEW_SHOW_NAMES
, MainFrm::OnShowStationNamesUpdate
)
635 EVT_UPDATE_UI(menu_VIEW_SHOW_SURFACE
, MainFrm::OnShowSurfaceUpdate
)
636 EVT_UPDATE_UI(menu_VIEW_SHOW_OVERLAPPING_NAMES
, MainFrm::OnDisplayOverlappingNamesUpdate
)
637 EVT_UPDATE_UI(menu_VIEW_COLOUR_BY
, MainFrm::OnColourByUpdate
)
638 EVT_UPDATE_UI(menu_COLOUR_BY_DEPTH
, MainFrm::OnColourByDepthUpdate
)
639 EVT_UPDATE_UI(menu_COLOUR_BY_DATE
, MainFrm::OnColourByDateUpdate
)
640 EVT_UPDATE_UI(menu_COLOUR_BY_ERROR
, MainFrm::OnColourByErrorUpdate
)
641 EVT_UPDATE_UI(menu_COLOUR_BY_GRADIENT
, MainFrm::OnColourByGradientUpdate
)
642 EVT_UPDATE_UI(menu_COLOUR_BY_LENGTH
, MainFrm::OnColourByLengthUpdate
)
643 EVT_UPDATE_UI(menu_VIEW_GRID
, MainFrm::OnViewGridUpdate
)
644 EVT_UPDATE_UI(menu_VIEW_BOUNDING_BOX
, MainFrm::OnViewBoundingBoxUpdate
)
645 EVT_UPDATE_UI(menu_VIEW_PERSPECTIVE
, MainFrm::OnViewPerspectiveUpdate
)
646 EVT_UPDATE_UI(menu_VIEW_SMOOTH_SHADING
, MainFrm::OnViewSmoothShadingUpdate
)
647 EVT_UPDATE_UI(menu_VIEW_TEXTURED
, MainFrm::OnViewTexturedUpdate
)
648 EVT_UPDATE_UI(menu_VIEW_FOG
, MainFrm::OnViewFogUpdate
)
649 EVT_UPDATE_UI(menu_VIEW_SMOOTH_LINES
, MainFrm::OnViewSmoothLinesUpdate
)
650 EVT_UPDATE_UI(menu_VIEW_FULLSCREEN
, MainFrm::OnViewFullScreenUpdate
)
651 EVT_UPDATE_UI(menu_VIEW_SHOW_TUBES
, MainFrm::OnToggleTubesUpdate
)
652 EVT_UPDATE_UI(menu_VIEW_TERRAIN
, MainFrm::OnViewTerrainUpdate
)
653 EVT_UPDATE_UI(menu_IND_COMPASS
, MainFrm::OnViewCompassUpdate
)
654 EVT_UPDATE_UI(menu_IND_CLINO
, MainFrm::OnViewClinoUpdate
)
655 EVT_UPDATE_UI(menu_IND_COLOUR_KEY
, MainFrm::OnToggleColourKeyUpdate
)
656 EVT_UPDATE_UI(menu_IND_SCALE_BAR
, MainFrm::OnToggleScalebarUpdate
)
657 EVT_UPDATE_UI(menu_CTL_INDICATORS
, MainFrm::OnIndicatorsUpdate
)
658 EVT_UPDATE_UI(menu_CTL_SIDE_PANEL
, MainFrm::OnViewSidePanelUpdate
)
659 EVT_UPDATE_UI(menu_CTL_REVERSE
, MainFrm::OnReverseControlsUpdate
)
660 EVT_UPDATE_UI(menu_CTL_CANCEL_DIST_LINE
, MainFrm::OnCancelDistLineUpdate
)
661 EVT_UPDATE_UI(menu_CTL_METRIC
, MainFrm::OnToggleMetricUpdate
)
662 EVT_UPDATE_UI(menu_CTL_DEGREES
, MainFrm::OnToggleDegreesUpdate
)
663 EVT_UPDATE_UI(menu_CTL_PERCENT
, MainFrm::OnTogglePercentUpdate
)
666 class LabelCmp
: public greater
<const LabelInfo
*> {
669 explicit LabelCmp(wxChar separator_
) : separator(separator_
) {}
670 bool operator()(const LabelInfo
* pt1
, const LabelInfo
* pt2
) {
671 return name_cmp(pt1
->GetText(), pt2
->GetText(), separator
) < 0;
675 class LabelPlotCmp
: public greater
<const LabelInfo
*> {
678 explicit LabelPlotCmp(wxChar separator_
) : separator(separator_
) {}
679 bool operator()(const LabelInfo
* pt1
, const LabelInfo
* pt2
) {
680 int n
= pt1
->get_flags() - pt2
->get_flags();
682 wxString l1
= pt1
->GetText().AfterLast(separator
);
683 wxString l2
= pt2
->GetText().AfterLast(separator
);
684 n
= name_cmp(l1
, l2
, separator
);
686 // Prefer non-2-nodes...
688 // if leaf names are the same, prefer shorter labels as we can
689 // display more of them
690 n
= pt1
->GetText().length() - pt2
->GetText().length();
692 // make sure that we don't ever compare different labels as equal
693 return name_cmp(pt1
->GetText(), pt2
->GetText(), separator
) < 0;
697 #if wxUSE_DRAG_AND_DROP
698 class DnDFile
: public wxFileDropTarget
{
700 explicit DnDFile(MainFrm
*parent
) : m_Parent(parent
) { }
701 virtual bool OnDropFiles(wxCoord
, wxCoord
,
702 const wxArrayString
&filenames
);
709 DnDFile::OnDropFiles(wxCoord
, wxCoord
, const wxArrayString
&filenames
)
711 // Load a survey file by drag-and-drop.
712 assert(filenames
.GetCount() > 0);
714 if (filenames
.GetCount() != 1) {
715 /* TRANSLATORS: error if you try to drag multiple files to the aven
717 wxGetApp().ReportError(wmsg(/*You may only view one 3d file at a time.*/336));
721 m_Parent
->OpenFile(filenames
[0]);
726 MainFrm::MainFrm(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
) :
727 wxFrame(NULL
, 101, title
, pos
, size
, wxDEFAULT_FRAME_STYLE
),
729 m_Gfx(NULL
), m_Log(NULL
),
730 pending_find(false), fullscreen_showing_menus(false)
736 // The peculiar name is so that the icon is the first in the file
737 // (required by Microsoft Windows for this type of icon)
738 SetIcon(wxICON(AAA_aven
));
740 SetIcon(wxICON(aven
));
743 #if wxCHECK_VERSION(3,1,0)
744 // Add a full screen button to the right upper corner of title bar under OS
746 EnableFullScreenView();
750 CreateStatusBar(2, wxST_SIZEGRIP
);
753 int widths
[2] = { -1 /* variable width */, -1 };
754 GetStatusBar()->SetStatusWidths(2, widths
);
756 #ifdef __X__ // wxMotif or wxX11
760 // X seems to require a forced resize.
761 SetSize(-1, -1, x
, y
);
764 #if wxUSE_DRAG_AND_DROP
765 SetDropTarget(new DnDFile(this));
769 void MainFrm::CreateMenuBar()
771 // Create the menus and the menu bar.
773 wxMenu
* filemenu
= new wxMenu
;
774 // wxID_OPEN stock label lacks the ellipses
775 /* TRANSLATORS: Aven menu items. An “&” goes before the letter of any
778 * The string "\t" separates the menu text and any accelerator key.
780 * "File" menu. The accelerators must be different within this group.
781 * c.f. 201, 380, 381. */
782 filemenu
->Append(wxID_OPEN
, wmsg(/*&Open...\tCtrl+O*/220));
783 /* TRANSLATORS: Open a "Terrain file" - i.e. a digital model of the
785 filemenu
->Append(menu_FILE_OPEN_TERRAIN
, wmsg(/*Open &Terrain...*/453));
786 filemenu
->AppendCheckItem(menu_FILE_LOG
, wmsg(/*Show &Log*/144));
787 filemenu
->AppendSeparator();
788 // wxID_PRINT stock label lacks the ellipses
789 filemenu
->Append(wxID_PRINT
, wmsg(/*&Print...\tCtrl+P*/380));
790 filemenu
->Append(menu_FILE_PAGE_SETUP
, wmsg(/*P&age Setup...*/381));
791 filemenu
->AppendSeparator();
792 /* TRANSLATORS: In the "File" menu */
793 filemenu
->Append(menu_FILE_SCREENSHOT
, wmsg(/*&Screenshot...*/201));
794 filemenu
->Append(menu_FILE_EXPORT
, wmsg(/*&Export as...*/382));
795 /* TRANSLATORS: In the "File" menu - c.f. n:191 */
796 filemenu
->Append(menu_FILE_EXTEND
, wmsg(/*E&xtended Elevation...*/247));
798 // On wxMac the "Quit" menu item will be moved elsewhere, so we suppress
800 filemenu
->AppendSeparator();
802 // We suppress the "Help" menu under OS X as it would otherwise end up as
803 // an empty menu, but we need to add the "About" menu item somewhere. It
804 // really doesn't matter where as wxWidgets will move it to the "Apple"
806 filemenu
->Append(wxID_ABOUT
);
808 filemenu
->Append(wxID_EXIT
);
810 m_history
.UseMenu(filemenu
);
811 m_history
.Load(*wxConfigBase::Get());
813 wxMenu
* rotmenu
= new wxMenu
;
814 /* TRANSLATORS: "Rotation" menu. The accelerators must be different within
815 * this group. Tickable menu item which toggles auto rotation.
816 * Please don't translate "Space" - that's the shortcut key to use which
817 * wxWidgets needs to parse and it should then handle translating.
819 rotmenu
->AppendCheckItem(menu_ROTATION_TOGGLE
, wmsg(/*Au&to-Rotate\tSpace*/231));
820 rotmenu
->AppendSeparator();
821 rotmenu
->Append(menu_ROTATION_REVERSE
, wmsg(/*&Reverse Direction*/234));
823 wxMenu
* orientmenu
= new wxMenu
;
824 orientmenu
->Append(menu_ORIENT_MOVE_NORTH
, wmsg(/*View &North*/240));
825 orientmenu
->Append(menu_ORIENT_MOVE_EAST
, wmsg(/*View &East*/241));
826 orientmenu
->Append(menu_ORIENT_MOVE_SOUTH
, wmsg(/*View &South*/242));
827 orientmenu
->Append(menu_ORIENT_MOVE_WEST
, wmsg(/*View &West*/243));
828 orientmenu
->AppendSeparator();
829 orientmenu
->Append(menu_ORIENT_PLAN
, wmsg(/*&Plan View*/248));
830 orientmenu
->Append(menu_ORIENT_ELEVATION
, wmsg(/*Ele&vation*/249));
831 orientmenu
->AppendSeparator();
832 orientmenu
->Append(menu_ORIENT_DEFAULTS
, wmsg(/*Restore De&fault View*/254));
834 wxMenu
* presmenu
= new wxMenu
;
835 presmenu
->Append(menu_PRES_NEW
, wmsg(/*&New Presentation*/311));
836 presmenu
->Append(menu_PRES_OPEN
, wmsg(/*&Open Presentation...*/312));
837 presmenu
->Append(menu_PRES_SAVE
, wmsg(/*&Save Presentation*/313));
838 presmenu
->Append(menu_PRES_SAVE_AS
, wmsg(/*Sa&ve Presentation As...*/314));
839 presmenu
->AppendSeparator();
840 /* TRANSLATORS: "Mark" as in "Mark this position" */
841 presmenu
->Append(menu_PRES_MARK
, wmsg(/*&Mark*/315));
842 /* TRANSLATORS: "Play" as in "Play back a recording" */
843 presmenu
->AppendCheckItem(menu_PRES_PLAY
, wmsg(/*Pla&y*/316));
844 presmenu
->Append(menu_PRES_EXPORT_MOVIE
, wmsg(/*&Export as Movie...*/317));
846 wxMenu
* viewmenu
= new wxMenu
;
848 /* TRANSLATORS: Items in the "View" menu: */
849 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_NAMES
, wmsg(/*Station &Names\tCtrl+N*/270));
850 /* TRANSLATORS: Toggles drawing of 3D passages */
851 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_TUBES
, wmsg(/*Passage &Tubes\tCtrl+T*/346));
852 /* TRANSLATORS: Toggles drawing the surface of the Earth */
853 viewmenu
->AppendCheckItem(menu_VIEW_TERRAIN
, wmsg(/*Terr&ain*/449));
854 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_CROSSES
, wmsg(/*&Crosses\tCtrl+X*/271));
855 viewmenu
->AppendCheckItem(menu_VIEW_GRID
, wmsg(/*&Grid\tCtrl+G*/297));
856 viewmenu
->AppendCheckItem(menu_VIEW_BOUNDING_BOX
, wmsg(/*&Bounding Box\tCtrl+B*/318));
857 viewmenu
->AppendSeparator();
858 /* TRANSLATORS: Here a "survey leg" is a set of measurements between two
859 * "survey stations". */
860 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_LEGS
, wmsg(/*&Underground Survey Legs\tCtrl+L*/272));
861 /* TRANSLATORS: Here a "survey leg" is a set of measurements between two
862 * "survey stations". */
863 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_SURFACE
, wmsg(/*&Surface Survey Legs\tCtrl+F*/291));
865 wxMenu
* splaymenu
= new wxMenu
;
866 /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if
867 * this is selected, such legs are not shown. */
868 splaymenu
->AppendCheckItem(menu_SPLAYS_HIDE
, wmsg(/*&Hide*/407));
869 /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if
870 * this is selected, aven will show such legs with dashed lines. */
871 splaymenu
->AppendCheckItem(menu_SPLAYS_SHOW_DASHED
, wmsg(/*&Dashed*/250));
872 /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if
873 * this is selected, aven will show such legs with less bright colours. */
874 splaymenu
->AppendCheckItem(menu_SPLAYS_SHOW_FADED
, wmsg(/*&Fade*/408));
875 /* TRANSLATORS: Item in the "Splay Legs" and "Duplicate Legs" submenus - if
876 * this is selected, such legs are shown the same as other legs. */
877 splaymenu
->AppendCheckItem(menu_SPLAYS_SHOW_NORMAL
, wmsg(/*&Show*/409));
878 viewmenu
->Append(menu_VIEW_SPLAYS
, wmsg(/*Spla&y Legs*/406), splaymenu
);
880 wxMenu
* dupemenu
= new wxMenu
;
881 dupemenu
->AppendCheckItem(menu_DUPES_HIDE
, wmsg(/*&Hide*/407));
882 dupemenu
->AppendCheckItem(menu_DUPES_SHOW_DASHED
, wmsg(/*&Dashed*/250));
883 dupemenu
->AppendCheckItem(menu_DUPES_SHOW_FADED
, wmsg(/*&Fade*/408));
884 dupemenu
->AppendCheckItem(menu_DUPES_SHOW_NORMAL
, wmsg(/*&Show*/409));
885 viewmenu
->Append(menu_VIEW_DUPES
, wmsg(/*&Duplicate Legs*/251), dupemenu
);
887 viewmenu
->AppendSeparator();
888 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_OVERLAPPING_NAMES
, wmsg(/*&Overlapping Names*/273));
890 wxMenu
* colourbymenu
= new wxMenu
;
891 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_DEPTH
, wmsg(/*Colour by &Depth*/292));
892 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_DATE
, wmsg(/*Colour by D&ate*/293));
893 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_ERROR
, wmsg(/*Colour by &Error*/289));
894 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_GRADIENT
, wmsg(/*Colour by &Gradient*/85));
895 colourbymenu
->AppendCheckItem(menu_COLOUR_BY_LENGTH
, wmsg(/*Colour by &Length*/82));
897 viewmenu
->Append(menu_VIEW_COLOUR_BY
, wmsg(/*Co&lour by*/450), colourbymenu
);
899 viewmenu
->AppendSeparator();
900 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_ENTRANCES
, wmsg(/*Highlight &Entrances*/294));
901 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_FIXED_PTS
, wmsg(/*Highlight &Fixed Points*/295));
902 viewmenu
->AppendCheckItem(menu_VIEW_SHOW_EXPORTED_PTS
, wmsg(/*Highlight E&xported Points*/296));
903 viewmenu
->AppendSeparator();
905 /* TRANSLATORS: Please don't translate "Escape" - that's the shortcut key
906 * to use which wxWidgets needs to parse and it should then handle
909 viewmenu
-> Append(menu_VIEW_CANCEL_DIST_LINE
, wmsg(/*&Cancel Measuring Line\tEscape*/281));
911 viewmenu
->AppendCheckItem(menu_VIEW_PERSPECTIVE
, wmsg(/*&Perspective*/237));
912 // FIXME: enable this viewmenu->AppendCheckItem(menu_VIEW_SMOOTH_SHADING, wmsg(/*&Smooth Shading*/?!?);
913 viewmenu
->AppendCheckItem(menu_VIEW_TEXTURED
, wmsg(/*Textured &Walls*/238));
914 /* TRANSLATORS: Toggles OpenGL "Depth Fogging" - feel free to translate
915 * using that term instead if it gives a better translation which most
916 * users will understand. */
917 viewmenu
->AppendCheckItem(menu_VIEW_FOG
, wmsg(/*Fade Distant Ob&jects*/239));
918 /* TRANSLATORS: Here a "survey leg" is a set of measurements between two
919 * "survey stations". */
920 viewmenu
->AppendCheckItem(menu_VIEW_SMOOTH_LINES
, wmsg(/*Smoot&hed Survey Legs*/298));
921 viewmenu
->AppendSeparator();
923 // F11 on OS X is used by the desktop (for speaker volume and/or window
924 // navigation). The standard OS X shortcut for full screen mode is
925 // Ctrl-Command-F which in wxWidgets terms is RawCtrl+Ctrl+F.
926 wxString wxmac_fullscreen
= wmsg(/*Full Screen &Mode\tF11*/356);
927 wxmac_fullscreen
.Replace(wxT("\tF11"), wxT("\tRawCtrl+Ctrl+F"), false);
928 viewmenu
->AppendCheckItem(menu_VIEW_FULLSCREEN
, wxmac_fullscreen
);
929 // FIXME: On OS X, the standard wording here is "Enter Full Screen" and
930 // "Exit Full Screen", depending whether we are in full screen mode or not,
931 // and this isn't a checked menu item.
933 viewmenu
->AppendCheckItem(menu_VIEW_FULLSCREEN
, wmsg(/*Full Screen &Mode\tF11*/356));
936 viewmenu
->AppendSeparator();
937 viewmenu
-> Append(wxID_PREFERENCES
, wmsg(/*&Preferences...*/347));
941 wxMenu
* ctlmenu
= new wxMenu
;
942 ctlmenu
->AppendCheckItem(menu_CTL_REVERSE
, wmsg(/*&Reverse Sense\tCtrl+R*/280));
943 ctlmenu
->AppendSeparator();
945 // wxGTK (at least with GTK+ v2.24), if we specify a short-cut here then
946 // the key handler isn't called, so we can't exit full screen mode on
947 // Escape. wxGTK doesn't actually show the "Escape" shortcut text in the
948 // menu item, so removing it doesn't make any visual difference, and doing
949 // so allows Escape to still cancel the measuring line, but also serve to
950 // exit full screen mode if no measuring line is shown.
951 wxString wxgtk_cancelline
= wmsg(/*&Cancel Measuring Line\tEscape*/281);
952 wxgtk_cancelline
.Replace(wxT("\tEscape"), wxT(""), false);
953 ctlmenu
->Append(menu_CTL_CANCEL_DIST_LINE
, wxgtk_cancelline
);
955 // With wxMac and wxMSW, we can have the short-cut on the menu and still
956 // have Escape handled by the key handler to exit full screen mode.
957 ctlmenu
->Append(menu_CTL_CANCEL_DIST_LINE
, wmsg(/*&Cancel Measuring Line\tEscape*/281));
959 ctlmenu
->AppendSeparator();
960 wxMenu
* indmenu
= new wxMenu
;
961 indmenu
->AppendCheckItem(menu_IND_COMPASS
, wmsg(/*&Compass*/274));
962 indmenu
->AppendCheckItem(menu_IND_CLINO
, wmsg(/*C&linometer*/275));
963 /* TRANSLATORS: The "Colour Key" is the thing in aven showing which colour
964 * corresponds to which depth, date, survey closure error, etc. */
965 indmenu
->AppendCheckItem(menu_IND_COLOUR_KEY
, wmsg(/*Colour &Key*/276));
966 indmenu
->AppendCheckItem(menu_IND_SCALE_BAR
, wmsg(/*&Scale Bar*/277));
967 ctlmenu
->Append(menu_CTL_INDICATORS
, wmsg(/*&Indicators*/299), indmenu
);
968 ctlmenu
->AppendCheckItem(menu_CTL_SIDE_PANEL
, wmsg(/*&Side Panel*/337));
969 ctlmenu
->AppendSeparator();
970 ctlmenu
->AppendCheckItem(menu_CTL_METRIC
, wmsg(/*&Metric*/342));
971 ctlmenu
->AppendCheckItem(menu_CTL_DEGREES
, wmsg(/*&Degrees*/343));
972 ctlmenu
->AppendCheckItem(menu_CTL_PERCENT
, wmsg(/*&Percent*/430));
975 wxMenuBar
* menubar
= new wxMenuBar();
976 /* TRANSLATORS: Aven menu titles. An “&” goes before the letter of any
977 * accelerator key. The accelerators must be different within this group
979 menubar
->Append(filemenu
, wmsg(/*&File*/210));
980 menubar
->Append(rotmenu
, wmsg(/*&Rotation*/211));
981 menubar
->Append(orientmenu
, wmsg(/*&Orientation*/212));
982 menubar
->Append(viewmenu
, wmsg(/*&View*/213));
984 menubar
->Append(ctlmenu
, wmsg(/*&Controls*/214));
986 // TRANSLATORS: "Presentation" in the sense of a talk with a slideshow -
987 // the items in this menu allow the user to animate between preset
989 menubar
->Append(presmenu
, wmsg(/*&Presentation*/216));
991 // On wxMac the "About" menu item will be moved elsewhere, so we suppress
992 // this menu since it will then be empty.
993 wxMenu
* helpmenu
= new wxMenu
;
994 helpmenu
->Append(wxID_ABOUT
);
996 menubar
->Append(helpmenu
, wmsg(/*&Help*/215));
1001 void MainFrm::MakeToolBar()
1003 // Make the toolbar.
1005 #ifdef USING_GENERIC_TOOLBAR
1006 // This OS-X-specific code is only needed to stop the toolbar icons getting
1007 // scaled up, which just makes them look nasty and fuzzy. Once we have
1008 // larger versions of the icons, we can drop this code.
1009 wxSystemOptions::SetOption(wxT("mac.toolbar.no-native"), 1);
1010 wxToolBar
* toolbar
= new wxToolBar(this, wxID_ANY
, wxDefaultPosition
,
1011 wxDefaultSize
, wxNO_BORDER
|wxTB_FLAT
|wxTB_NODIVIDER
|wxTB_NOALIGN
);
1012 wxBoxSizer
* sizer
= new wxBoxSizer(wxVERTICAL
);
1013 sizer
->Add(toolbar
, 0, wxEXPAND
);
1016 wxToolBar
* toolbar
= wxFrame::CreateToolBar();
1020 toolbar
->SetMargins(5, 5);
1023 // FIXME: TRANSLATE tooltips
1024 toolbar
->AddTool(wxID_OPEN
, wxT("Open"), TOOL(open
), wxT("Open a survey file for viewing"));
1025 toolbar
->AddTool(menu_PRES_OPEN
, wxT("Open presentation"), TOOL(open_pres
), wxT("Open a presentation"));
1026 toolbar
->AddCheckTool(menu_FILE_LOG
, wxT("View log"), TOOL(log
), wxNullBitmap
, wxT("View log from processing survey data"));
1027 toolbar
->AddSeparator();
1028 toolbar
->AddCheckTool(menu_ROTATION_TOGGLE
, wxT("Toggle rotation"), TOOL(rotation
), wxNullBitmap
, wxT("Toggle rotation"));
1029 toolbar
->AddTool(menu_ORIENT_PLAN
, wxT("Plan"), TOOL(plan
), wxT("Switch to plan view"));
1030 toolbar
->AddTool(menu_ORIENT_ELEVATION
, wxT("Elevation"), TOOL(elevation
), wxT("Switch to elevation view"));
1031 toolbar
->AddTool(menu_ORIENT_DEFAULTS
, wxT("Default view"), TOOL(defaults
), wxT("Restore default view"));
1032 toolbar
->AddSeparator();
1033 toolbar
->AddCheckTool(menu_VIEW_SHOW_NAMES
, wxT("Names"), TOOL(names
), wxNullBitmap
, wxT("Show station names"));
1034 toolbar
->AddCheckTool(menu_VIEW_SHOW_CROSSES
, wxT("Crosses"), TOOL(crosses
), wxNullBitmap
, wxT("Show crosses on stations"));
1035 toolbar
->AddCheckTool(menu_VIEW_SHOW_ENTRANCES
, wxT("Entrances"), TOOL(entrances
), wxNullBitmap
, wxT("Highlight entrances"));
1036 toolbar
->AddCheckTool(menu_VIEW_SHOW_FIXED_PTS
, wxT("Fixed points"), TOOL(fixed_pts
), wxNullBitmap
, wxT("Highlight fixed points"));
1037 toolbar
->AddCheckTool(menu_VIEW_SHOW_EXPORTED_PTS
, wxT("Exported points"), TOOL(exported_pts
), wxNullBitmap
, wxT("Highlight exported stations"));
1038 toolbar
->AddSeparator();
1039 toolbar
->AddCheckTool(menu_VIEW_SHOW_LEGS
, wxT("Underground legs"), TOOL(ug_legs
), wxNullBitmap
, wxT("Show underground surveys"));
1040 toolbar
->AddCheckTool(menu_VIEW_SHOW_SURFACE
, wxT("Surface legs"), TOOL(surface_legs
), wxNullBitmap
, wxT("Show surface surveys"));
1041 toolbar
->AddCheckTool(menu_VIEW_SHOW_TUBES
, wxT("Tubes"), TOOL(tubes
), wxNullBitmap
, wxT("Show passage tubes"));
1042 toolbar
->AddCheckTool(menu_VIEW_TERRAIN
, wxT("Terrain"), TOOL(solid_surface
), wxNullBitmap
, wxT("Show terrain"));
1043 toolbar
->AddSeparator();
1044 toolbar
->AddCheckTool(menu_PRES_FREWIND
, wxT("Fast Rewind"), TOOL(pres_frew
), wxNullBitmap
, wxT("Very Fast Rewind"));
1045 toolbar
->AddCheckTool(menu_PRES_REWIND
, wxT("Rewind"), TOOL(pres_rew
), wxNullBitmap
, wxT("Fast Rewind"));
1046 toolbar
->AddCheckTool(menu_PRES_REVERSE
, wxT("Backwards"), TOOL(pres_go_back
), wxNullBitmap
, wxT("Play Backwards"));
1047 toolbar
->AddCheckTool(menu_PRES_PAUSE
, wxT("Pause"), TOOL(pres_pause
), wxNullBitmap
, wxT("Pause"));
1048 toolbar
->AddCheckTool(menu_PRES_PLAY
, wxT("Go"), TOOL(pres_go
), wxNullBitmap
, wxT("Play"));
1049 toolbar
->AddCheckTool(menu_PRES_FF
, wxT("FF"), TOOL(pres_ff
), wxNullBitmap
, wxT("Fast Forward"));
1050 toolbar
->AddCheckTool(menu_PRES_FFF
, wxT("Very FF"), TOOL(pres_fff
), wxNullBitmap
, wxT("Very Fast Forward"));
1051 toolbar
->AddTool(wxID_STOP
, wxT("Stop"), TOOL(pres_stop
), wxT("Stop"));
1053 toolbar
->AddSeparator();
1054 m_FindBox
= new wxTextCtrl(toolbar
, textctrl_FIND
, wxString(), wxDefaultPosition
,
1055 wxDefaultSize
, wxTE_PROCESS_ENTER
);
1056 toolbar
->AddControl(m_FindBox
);
1057 /* TRANSLATORS: "Find stations" button tooltip */
1058 toolbar
->AddTool(wxID_FIND
, wmsg(/*Find*/332), TOOL(find
)/*, "Search for station name"*/);
1059 /* TRANSLATORS: "Hide stations" button default tooltip */
1060 toolbar
->AddTool(button_HIDE
, wmsg(/*Hide*/333), TOOL(hideresults
)/*, "Hide search results"*/);
1065 void MainFrm::CreateSidePanel()
1067 m_Splitter
= new AvenSplitterWindow(this);
1068 #ifdef USING_GENERIC_TOOLBAR
1069 // This OS-X-specific code is only needed to stop the toolbar icons getting
1070 // scaled up, which just makes them look nasty and fuzzy. Once we have
1071 // larger versions of the icons, we can drop this code.
1072 GetSizer()->Add(m_Splitter
, 1, wxEXPAND
);
1076 m_Notebook
= new wxNotebook(m_Splitter
, 400, wxDefaultPosition
,
1078 wxBK_BOTTOM
| wxBK_LEFT
);
1079 m_Notebook
->Show(false);
1081 wxPanel
* panel
= new wxPanel(m_Notebook
);
1082 m_Tree
= new AvenTreeCtrl(this, panel
);
1084 // m_RegexpCheckBox = new wxCheckBox(find_panel, -1,
1085 // msg(/*Regular expression*/));
1087 wxBoxSizer
*panel_sizer
= new wxBoxSizer(wxVERTICAL
);
1088 panel_sizer
->Add(m_Tree
, 1, wxALL
| wxEXPAND
, 2);
1089 panel
->SetAutoLayout(true);
1090 panel
->SetSizer(panel_sizer
);
1091 // panel_sizer->SetSizeHints(panel);
1093 m_Control
= new GUIControl();
1094 m_Gfx
= new GfxCore(this, m_Splitter
, m_Control
);
1095 m_Control
->SetView(m_Gfx
);
1097 // Presentation panel:
1098 wxPanel
* prespanel
= new wxPanel(m_Notebook
);
1100 m_PresList
= new AvenPresList(this, prespanel
, m_Gfx
);
1102 wxBoxSizer
*pres_panel_sizer
= new wxBoxSizer(wxVERTICAL
);
1103 pres_panel_sizer
->Add(m_PresList
, 1, wxALL
| wxEXPAND
, 2);
1104 prespanel
->SetAutoLayout(true);
1105 prespanel
->SetSizer(pres_panel_sizer
);
1107 // Overall tabbed structure:
1108 // FIXME: this assumes images are 15x15
1109 wxImageList
* image_list
= new wxImageList(15, 15);
1110 image_list
->Add(TOOL(survey_tree
));
1111 image_list
->Add(TOOL(pres_tree
));
1112 m_Notebook
->SetImageList(image_list
);
1113 /* TRANSLATORS: labels for tabbed side panel this is for the tab with the
1114 * tree hierarchy of survey station names */
1115 m_Notebook
->AddPage(panel
, wmsg(/*Surveys*/376), true, 0);
1116 m_Notebook
->AddPage(prespanel
, wmsg(/*Presentation*/377), false, 1);
1118 m_Splitter
->Initialize(m_Gfx
);
1121 bool MainFrm::LoadData(const wxString
& file
, const wxString
& prefix
)
1123 // Load survey data from file, centre the dataset around the origin,
1124 // and prepare the data for drawing.
1131 int err_msg_code
= Model::Load(file
, prefix
);
1133 wxString m
= wxString::Format(wmsg(err_msg_code
), file
.c_str());
1134 wxGetApp().ReportError(m
);
1138 // Update window title.
1139 SetTitle(GetSurveyTitle() + " - " APP_NAME
);
1141 // Sort the labels ready for filling the tree.
1142 m_Labels
.sort(LabelCmp(GetSeparator()));
1144 // Fill the tree of stations and prefixes.
1145 wxString root_name
= wxFileNameFromPath(file
);
1146 if (!prefix
.empty()) {
1148 root_name
+= prefix
;
1151 FillTree(root_name
);
1153 // Sort labels so that entrances are displayed in preference,
1154 // then fixed points, then exported points, then other points.
1156 // Also sort by leaf name so that we'll tend to choose labels
1157 // from different surveys, rather than labels from surveys which
1158 // are earlier in the list.
1159 m_Labels
.sort(LabelPlotCmp(GetSeparator()));
1161 if (!m_FindBox
->GetValue().empty()) {
1162 // Highlight any stations matching the current search.
1166 m_FileProcessed
= file
;
1172 // Run along a newly read in traverse and make up plausible LRUD where
1175 MainFrm::FixLRUD(traverse
& centreline
)
1177 assert(centreline
.size() > 1);
1179 Double last_size
= 0;
1180 vector
<PointInfo
>::iterator i
= centreline
.begin();
1181 while (i
!= centreline
.end()) {
1182 // Get the coordinates of this vertex.
1183 Point
& pt_v
= *i
++;
1186 if (i
!= centreline
.end()) {
1187 Double h
= sqrd(i
->GetX() - pt_v
.GetX()) +
1188 sqrd(i
->GetY() - pt_v
.GetY());
1189 Double v
= sqrd(i
->GetZ() - pt_v
.GetZ());
1190 if (h
+ v
> 30.0 * 30.0) {
1191 Double scale
= 30.0 / sqrt(h
+ v
);
1195 size
= sqrt(h
+ v
/ 9);
1197 if (i
== centreline
.begin() + 1) {
1201 // Intermediate segment.
1202 swap(size
, last_size
);
1211 Double
& l
= pt_v
.l
;
1212 Double
& r
= pt_v
.r
;
1213 Double
& u
= pt_v
.u
;
1214 Double
& d
= pt_v
.d
;
1216 if (l
== 0 && r
== 0 && u
== 0 && d
== 0) {
1217 l
= r
= u
= d
= -size
;
1219 if (l
< 0 && r
< 0) {
1222 l
= -(2 * size
- r
);
1223 if (l
>= 0) l
= -0.01;
1225 r
= -(2 * size
- l
);
1226 if (r
>= 0) r
= -0.01;
1228 if (u
< 0 && d
< 0) {
1231 u
= -(2 * size
- d
);
1232 if (u
>= 0) u
= -0.01;
1234 d
= -(2 * size
- u
);
1235 if (d
>= 0) d
= -0.01;
1242 void MainFrm::FillTree(const wxString
& root_name
)
1244 m_Tree
->DeleteAllItems();
1246 // Create the root of the tree.
1247 wxTreeItemId treeroot
= m_Tree
->AddRoot(root_name
);
1249 // Fill the tree of stations and prefixes.
1250 stack
<wxTreeItemId
> previous_ids
;
1251 wxString current_prefix
;
1252 wxTreeItemId current_id
= treeroot
;
1253 const wxChar separator
= GetSeparator();
1255 list
<LabelInfo
*>::iterator pos
= m_Labels
.begin();
1256 while (pos
!= m_Labels
.end()) {
1257 LabelInfo
* label
= *pos
++;
1259 if (label
->IsAnon()) continue;
1261 // Determine the current prefix.
1262 wxString prefix
= label
->GetText().BeforeLast(separator
);
1264 // Determine if we're still on the same prefix.
1265 if (prefix
== current_prefix
) {
1266 // no need to fiddle with branches...
1268 // If not, then see if we've descended to a new prefix.
1269 else if (prefix
.length() > current_prefix
.length() &&
1270 prefix
.StartsWith(current_prefix
) &&
1271 (prefix
[current_prefix
.length()] == separator
||
1272 current_prefix
.empty())) {
1273 // We have, so start as many new branches as required.
1274 int current_prefix_length
= current_prefix
.length();
1275 current_prefix
= prefix
;
1276 size_t next_dot
= current_prefix_length
;
1277 if (!next_dot
) --next_dot
;
1279 size_t prev_dot
= next_dot
+ 1;
1281 // Extract the next bit of prefix.
1282 next_dot
= prefix
.find(separator
, prev_dot
+ 1);
1284 wxString bit
= prefix
.substr(prev_dot
, next_dot
- prev_dot
);
1285 assert(!bit
.empty());
1287 // Add the current tree ID to the stack.
1288 previous_ids
.push(current_id
);
1290 // Append the new item to the tree and set this as the current branch.
1291 current_id
= m_Tree
->AppendItem(current_id
, bit
);
1292 m_Tree
->SetItemData(current_id
, new TreeData(prefix
.substr(0, next_dot
)));
1293 } while (next_dot
!= wxString::npos
);
1295 // Otherwise, we must have moved up, and possibly then down again.
1298 bool ascent_only
= (prefix
.length() < current_prefix
.length() &&
1299 current_prefix
.StartsWith(prefix
) &&
1300 (current_prefix
[prefix
.length()] == separator
||
1303 // Find out how much of the current prefix and the new prefix
1305 // Note that we require a match of a whole number of parts
1307 size_t n
= min(prefix
.length(), current_prefix
.length());
1309 for (i
= 0; i
< n
&& prefix
[i
] == current_prefix
[i
]; ++i
) {
1310 if (prefix
[i
] == separator
) count
= i
+ 1;
1313 count
= prefix
.length() + 1;
1316 // Extract the part of the current prefix after the bit (if any)
1317 // which has matched.
1318 // This gives the prefixes to ascend over.
1319 wxString prefixes_ascended
= current_prefix
.substr(count
);
1321 // Count the number of prefixes to ascend over.
1322 int num_prefixes
= prefixes_ascended
.Freq(separator
);
1324 // Reverse up over these prefixes.
1325 for (int i
= 1; i
<= num_prefixes
; i
++) {
1328 current_id
= previous_ids
.top();
1332 // Add branches for this new part.
1333 size_t next_dot
= count
- 1;
1335 size_t prev_dot
= next_dot
+ 1;
1337 // Extract the next bit of prefix.
1338 next_dot
= prefix
.find(separator
, prev_dot
+ 1);
1340 wxString bit
= prefix
.substr(prev_dot
, next_dot
- prev_dot
);
1341 assert(!bit
.empty());
1343 // Add the current tree ID to the stack.
1344 previous_ids
.push(current_id
);
1346 // Append the new item to the tree and set this as the current branch.
1347 current_id
= m_Tree
->AppendItem(current_id
, bit
);
1348 m_Tree
->SetItemData(current_id
, new TreeData(prefix
.substr(0, next_dot
)));
1349 } while (next_dot
!= wxString::npos
);
1352 current_prefix
= prefix
;
1355 // Now add the leaf.
1356 wxString bit
= label
->GetText().AfterLast(separator
);
1357 assert(!bit
.empty());
1358 wxTreeItemId id
= m_Tree
->AppendItem(current_id
, bit
);
1359 m_Tree
->SetItemData(id
, new TreeData(label
));
1360 label
->tree_id
= id
;
1361 // Set the colour for an item in the survey tree.
1362 if (label
->IsEntrance()) {
1363 // Entrances are green (like entrance blobs).
1364 m_Tree
->SetItemTextColour(id
, wxColour(0, 255, 40));
1365 } else if (label
->IsSurface()) {
1366 // Surface stations are dark green.
1367 m_Tree
->SetItemTextColour(id
, wxColour(49, 158, 79));
1371 m_Tree
->Expand(treeroot
);
1372 m_Tree
->SetEnabled();
1375 void MainFrm::OnMRUFile(wxCommandEvent
& event
)
1377 wxString
f(m_history
.GetHistoryFile(event
.GetId() - wxID_FILE1
));
1378 if (!f
.empty()) OpenFile(f
);
1381 void MainFrm::AddToFileHistory(const wxString
& file
)
1383 if (wxIsAbsolutePath(file
)) {
1384 m_history
.AddFileToHistory(file
);
1386 wxString abs
= wxGetCwd();
1387 abs
+= wxCONFIG_PATH_SEPARATOR
;
1389 m_history
.AddFileToHistory(abs
);
1391 wxConfigBase
*b
= wxConfigBase::Get();
1396 void MainFrm::OpenFile(const wxString
& file
, const wxString
& survey
)
1398 wxBusyCursor hourglass
;
1400 // Check if this is an unprocessed survey data file.
1401 if (file
.length() > 4 && file
[file
.length() - 4] == '.') {
1402 wxString
ext(file
, file
.length() - 3, 3);
1404 if (ext
== wxT("svx") || ext
== wxT("dat") || ext
== wxT("mak")) {
1405 CavernLogWindow
* log
= new CavernLogWindow(this, survey
, m_Splitter
);
1406 wxWindow
* win
= m_Splitter
->GetWindow1();
1407 m_Splitter
->ReplaceWindow(win
, log
);
1409 if (m_Splitter
->GetWindow2() == NULL
) {
1410 if (win
!= m_Gfx
) win
->Destroy();
1412 if (m_Splitter
->IsSplit()) m_Splitter
->Unsplit();
1415 if (wxFileExists(file
)) AddToFileHistory(file
);
1417 // Log window will tell us to load file if it successfully completes.
1422 if (!LoadData(file
, survey
))
1424 AddToFileHistory(file
);
1425 InitialiseAfterLoad(file
, survey
);
1427 // If aven is showing the log for a .svx file and you load a .3d file, then
1428 // at this point m_Log will be the log window for the .svx file, so destroy
1429 // it - it should never legitimately be set if we get here.
1436 void MainFrm::InitialiseAfterLoad(const wxString
& file
, const wxString
& prefix
)
1438 if (m_SashPosition
< 0) {
1439 // Calculate sane default width for side panel.
1442 GetClientSize(&x
, &y
);
1452 // Do this before we potentially delete the log window which may own the
1453 // wxString which parameter file refers to!
1454 bool same_file
= (file
== m_File
);
1459 wxWindow
* win
= NULL
;
1460 if (m_Splitter
->GetWindow2() == NULL
) {
1461 win
= m_Splitter
->GetWindow1();
1462 if (win
== m_Gfx
) win
= NULL
;
1465 if (!IsFullScreen()) {
1466 m_Splitter
->SplitVertically(m_Notebook
, m_Gfx
, m_SashPosition
);
1468 was_showing_sidepanel_before_fullscreen
= true;
1471 m_Gfx
->Initialise(same_file
);
1474 // FIXME: check it actually is the log window!
1475 if (m_Log
&& m_Log
!= win
)
1481 if (!IsFullScreen()) {
1482 m_Notebook
->Show(true);
1489 void MainFrm::HideLog(wxWindow
* log_window
)
1491 if (!IsFullScreen()) {
1492 m_Splitter
->SplitVertically(m_Notebook
, m_Gfx
, m_SashPosition
);
1498 if (!IsFullScreen()) {
1499 m_Notebook
->Show(true);
1507 // UI event handlers
1510 // For Unix we want "*.svx;*.SVX" while for Windows we only want "*.svx".
1514 # define CASE(X) ";" X
1517 void MainFrm::OnOpen(wxCommandEvent
&)
1519 AvenAllowOnTop
ontop(this);
1521 wxString filetypes
= wxT("*.3d");
1524 filetypes
.Printf(wxT("%s|*.3d;*.svx;*.plt;*.plf;*.dat;*.mak;*.adj;*.sht;*.una;*.xyz"
1525 CASE("*.3D;*.SVX;*.PLT;*.PLF;*.DAT;*.MAK;*.ADJ;*.SHT;*.UNA;*.XYZ")
1526 "|%s|*.3d" CASE("*.3D")
1527 "|%s|*.svx" CASE("*.SVX")
1528 "|%s|*.plt;*.plf" CASE("*.PLT;*.PLF")
1529 "|%s|*.dat;*.mak" CASE("*.DAT;*.MAK")
1530 "|%s|*.adj;*.sht;*.una;*.xyz" CASE("*.ADJ;*.SHT;*.UNA;*.XYZ")
1532 /* TRANSLATORS: Here "survey" is a "cave map" rather than
1533 * list of questions - it should be translated to the
1534 * terminology that cavers using the language would use.
1536 wmsg(/*All survey files*/229).c_str(),
1537 /* TRANSLATORS: Survex is the name of the software, and "3d" refers to a
1538 * file extension, so neither should be translated. */
1539 wmsg(/*Survex 3d files*/207).c_str(),
1540 /* TRANSLATORS: Survex is the name of the software, and "svx" refers to a
1541 * file extension, so neither should be translated. */
1542 wmsg(/*Survex svx files*/329).c_str(),
1543 /* TRANSLATORS: "Compass" as in Larry Fish’s cave
1544 * surveying package, so probably shouldn’t be translated
1546 wmsg(/*Compass PLT files*/324).c_str(),
1547 /* TRANSLATORS: "Compass" as in Larry Fish’s cave
1548 * surveying package, so should not be translated
1550 wmsg(/*Compass DAT and MAK files*/330).c_str(),
1551 /* TRANSLATORS: "CMAP" is Bob Thrun’s cave surveying
1552 * package, so don’t translate it. */
1553 wmsg(/*CMAP XYZ files*/325).c_str(),
1554 wmsg(/*All files*/208).c_str(),
1555 wxFileSelectorDefaultWildcardStr
);
1557 /* TRANSLATORS: Here "survey" is a "cave map" rather than list of questions
1558 * - it should be translated to the terminology that cavers using the
1559 * language would use.
1561 * File->Open dialog: */
1562 wxFileDialog
dlg(this, wmsg(/*Select a survey file to view*/206),
1563 wxString(), wxString(),
1564 filetypes
, wxFD_OPEN
|wxFD_FILE_MUST_EXIST
);
1565 if (dlg
.ShowModal() == wxID_OK
) {
1566 OpenFile(dlg
.GetPath());
1570 void MainFrm::OnOpenTerrain(wxCommandEvent
&)
1574 if (GetCSProj().empty()) {
1575 wxMessageBox(wxT("No coordinate system specified in survey data"));
1580 wxString filetypes
= wxT("*.*");
1583 filetypes
.Printf(wxT("%s|*.bil;*.hgt;*.zip" CASE("*.BIL;*.HGT;*.ZIP")
1585 wmsg(/*Terrain files*/452).c_str(),
1586 wmsg(/*All files*/208).c_str(),
1587 wxFileSelectorDefaultWildcardStr
);
1589 /* TRANSLATORS: "Terrain file" being a digital model of the terrain (e.g. a
1590 * grid of height values). */
1591 wxFileDialog
dlg(this, wmsg(/*Select a terrain file to view*/451),
1592 wxString(), wxString(),
1593 filetypes
, wxFD_OPEN
|wxFD_FILE_MUST_EXIST
);
1594 if (dlg
.ShowModal() == wxID_OK
&& m_Gfx
->LoadDEM(dlg
.GetPath())) {
1595 if (!m_Gfx
->DisplayingTerrain()) m_Gfx
->ToggleTerrain();
1599 void MainFrm::OnShowLog(wxCommandEvent
&)
1602 HideLog(m_Splitter
->GetWindow1());
1605 wxWindow
* win
= m_Splitter
->GetWindow1();
1606 m_Splitter
->ReplaceWindow(win
, m_Log
);
1608 if (m_Splitter
->IsSplit()) {
1609 m_SashPosition
= m_Splitter
->GetSashPosition(); // save width of panel
1610 m_Splitter
->Unsplit();
1617 void MainFrm::OnScreenshot(wxCommandEvent
&)
1619 AvenAllowOnTop
ontop(this);
1621 wxFileName::SplitPath(m_File
, NULL
, NULL
, &baseleaf
, NULL
, wxPATH_NATIVE
);
1622 /* TRANSLATORS: title of the save screenshot dialog */
1623 wxFileDialog
dlg(this, wmsg(/*Save Screenshot*/321), wxString(),
1624 baseleaf
+ wxT(".png"),
1625 wxT("*.png"), wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1626 if (dlg
.ShowModal() == wxID_OK
) {
1627 static bool png_handled
= false;
1629 #if 0 // FIXME : enable this to allow other export formats...
1630 ::wxInitAllImageHandlers();
1632 wxImage::AddHandler(new wxPNGHandler
);
1636 if (!m_Gfx
->SaveScreenshot(dlg
.GetPath(), wxBITMAP_TYPE_PNG
)) {
1637 wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), dlg
.GetPath().c_str()));
1642 void MainFrm::OnScreenshotUpdate(wxUpdateUIEvent
& event
)
1644 event
.Enable(!m_File
.empty());
1647 void MainFrm::OnFilePreferences(wxCommandEvent
&)
1650 m_PrefsDlg
= new PrefsDlg(m_Gfx
, this);
1651 m_PrefsDlg
->Show(true);
1655 void MainFrm::OnPrint(wxCommandEvent
&)
1657 m_Gfx
->OnPrint(m_File
, GetSurveyTitle(), GetDateString());
1660 void MainFrm::PrintAndExit()
1662 m_Gfx
->OnPrint(m_File
, GetSurveyTitle(), GetDateString(), 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(), GetDateString());
1678 void MainFrm::OnExtend(wxCommandEvent
&)
1680 wxString output
= m_Survey
;
1681 if (output
.empty()) {
1682 wxFileName::SplitPath(m_File
, NULL
, NULL
, &output
, NULL
, wxPATH_NATIVE
);
1684 output
+= wxT("_extend.3d");
1686 AvenAllowOnTop
ontop(this);
1688 wxString
ext(wxT("*.3d"));
1690 /* TRANSLATORS: Survex is the name of the software, and "3d" refers to a
1691 * file extension, so neither should be translated. */
1692 wxString ext
= wmsg(/*Survex 3d files*/207);
1693 ext
+= wxT("|*.3d");
1695 wxFileDialog
dlg(this, wmsg(/*Select an output filename*/319),
1696 wxString(), output
, ext
,
1697 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
1698 if (dlg
.ShowModal() != wxID_OK
) return;
1699 output
= dlg
.GetPath();
1701 wxString cmd
= get_command_path(L
"extend");
1702 cmd
= escape_for_shell(cmd
, false);
1703 if (!m_Survey
.empty()) {
1704 cmd
+= wxT(" --survey=");
1705 cmd
+= escape_for_shell(m_Survey
, false);
1707 cmd
+= wxT(" --show-breaks ");
1708 cmd
+= escape_for_shell(m_FileProcessed
, true);
1710 cmd
+= escape_for_shell(output
, true);
1711 if (wxExecute(cmd
, wxEXEC_SYNC
) < 0) {
1713 m
.Printf(wmsg(/*Couldn’t run external command: “%s”*/17), cmd
.c_str());
1715 m
+= wxString(strerror(errno
), wxConvUTF8
);
1717 wxGetApp().ReportError(m
);
1720 if (LoadData(output
, wxString()))
1721 InitialiseAfterLoad(output
, wxString());
1724 void MainFrm::OnQuit(wxCommandEvent
&)
1726 if (m_PresList
->Modified()) {
1727 AvenAllowOnTop
ontop(this);
1728 // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel]
1729 /* TRANSLATORS: and the question in that box */
1730 if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327),
1731 /* TRANSLATORS: title of message box */
1732 wmsg(/*Modified Presentation*/326),
1733 wxOK
|wxCANCEL
|wxICON_QUESTION
) == wxCANCEL
) {
1737 wxConfigBase
*b
= wxConfigBase::Get();
1738 if (IsFullScreen()) {
1739 b
->Write(wxT("width"), -2);
1740 b
->DeleteEntry(wxT("height"));
1741 } else if (IsMaximized()) {
1742 b
->Write(wxT("width"), -1);
1743 b
->DeleteEntry(wxT("height"));
1746 GetSize(&width
, &height
);
1747 b
->Write(wxT("width"), width
);
1748 b
->Write(wxT("height"), height
);
1754 void MainFrm::OnClose(wxCloseEvent
&)
1756 wxCommandEvent dummy
;
1760 void MainFrm::OnAbout(wxCommandEvent
&)
1762 AvenAllowOnTop
ontop(this);
1764 // GetIcon() returns an invalid wxIcon under OS X.
1765 AboutDlg
dlg(this, wxICON(aven
));
1767 AboutDlg
dlg(this, GetIcon());
1773 void MainFrm::UpdateStatusBar()
1775 if (!here_text
.empty()) {
1776 GetStatusBar()->SetStatusText(here_text
);
1777 GetStatusBar()->SetStatusText(dist_text
, 1);
1778 } else if (!coords_text
.empty()) {
1779 GetStatusBar()->SetStatusText(coords_text
);
1780 GetStatusBar()->SetStatusText(distfree_text
, 1);
1782 GetStatusBar()->SetStatusText(wxString());
1783 GetStatusBar()->SetStatusText(wxString(), 1);
1787 void MainFrm::ClearTreeSelection()
1789 m_Tree
->UnselectAll();
1794 void MainFrm::ClearCoords()
1796 if (!coords_text
.empty()) {
1797 coords_text
= wxString();
1802 void MainFrm::SetCoords(const Vector3
&v
)
1804 Double x
= v
.GetX();
1805 Double y
= v
.GetY();
1806 Double z
= v
.GetZ();
1808 if (m_Gfx
->GetMetric()) {
1811 x
/= METRES_PER_FOOT
;
1812 y
/= METRES_PER_FOOT
;
1813 z
/= METRES_PER_FOOT
;
1816 /* TRANSLATORS: show coordinates (N = North or Northing, E = East or
1818 coords_text
.Printf(wmsg(/*%.2f E, %.2f N*/338), x
, y
);
1819 coords_text
+= wxString::Format(wxT(", %s %.2f%s"),
1820 wmsg(/*Altitude*/335).c_str(),
1821 z
, wmsg(units
).c_str());
1822 distfree_text
= wxString();
1826 const LabelInfo
* MainFrm::GetTreeSelection() const {
1827 wxTreeItemData
* sel_wx
;
1828 if (!m_Tree
->GetSelectionData(&sel_wx
)) return NULL
;
1830 const TreeData
* data
= static_cast<const TreeData
*>(sel_wx
);
1831 if (!data
->IsStation()) return NULL
;
1833 return data
->GetLabel();
1836 void MainFrm::SetCoords(Double x
, Double y
, const LabelInfo
* there
)
1838 wxString
& s
= coords_text
;
1839 if (m_Gfx
->GetMetric()) {
1840 s
.Printf(wmsg(/*%.2f E, %.2f N*/338), x
, y
);
1842 s
.Printf(wmsg(/*%.2f E, %.2f N*/338),
1843 x
/ METRES_PER_FOOT
, y
/ METRES_PER_FOOT
);
1846 wxString
& t
= distfree_text
;
1848 if (m_Gfx
->ShowingMeasuringLine() && there
) {
1849 auto offset
= GetOffset();
1850 Vector3
delta(x
- offset
.GetX() - there
->GetX(),
1851 y
- offset
.GetY() - there
->GetY(), 0);
1852 Double dh
= sqrt(delta
.GetX()*delta
.GetX() + delta
.GetY()*delta
.GetY());
1853 Double brg
= deg(atan2(delta
.GetX(), delta
.GetY()));
1854 if (brg
< 0) brg
+= 360;
1857 /* TRANSLATORS: Used in Aven:
1858 * From <stationname>: H 12.24m, Brg 234.5°
1860 from_str
.Printf(wmsg(/*From %s*/339), there
->name_or_anon().c_str());
1862 if (m_Gfx
->GetDegrees()) {
1863 brg_unit
= /*°*/344;
1865 brg
*= 400.0 / 360.0;
1866 brg_unit
= /*ᵍ*/345;
1870 if (m_Gfx
->GetMetric()) {
1873 dh
/= METRES_PER_FOOT
;
1876 /* TRANSLATORS: "H" is short for "Horizontal", "Brg" for "Bearing" (as
1877 * in Compass bearing) */
1878 t
.Printf(wmsg(/*%s: H %.2f%s, Brg %03.1f%s*/374),
1879 from_str
.c_str(), dh
, wmsg(units
).c_str(),
1880 brg
, wmsg(brg_unit
).c_str());
1886 void MainFrm::SetAltitude(Double z
, const LabelInfo
* there
)
1890 if (m_Gfx
->GetMetric()) {
1893 alt
/= METRES_PER_FOOT
;
1896 coords_text
.Printf(wxT("%s %.2f%s"), wmsg(/*Altitude*/335).c_str(),
1897 alt
, wmsg(units
).c_str());
1899 wxString
& t
= distfree_text
;
1901 if (m_Gfx
->ShowingMeasuringLine() && there
) {
1902 Double dz
= z
- GetOffset().GetZ() - there
->GetZ();
1905 from_str
.Printf(wmsg(/*From %s*/339), there
->name_or_anon().c_str());
1907 if (!m_Gfx
->GetMetric()) {
1908 dz
/= METRES_PER_FOOT
;
1910 // TRANSLATORS: "V" is short for "Vertical"
1911 t
.Printf(wmsg(/*%s: V %.2f%s*/375), from_str
.c_str(),
1912 dz
, wmsg(units
).c_str());
1918 void MainFrm::ShowInfo(const LabelInfo
*here
, const LabelInfo
*there
)
1924 m_Tree
->SetHere(wxTreeItemId());
1925 // Don't clear "There" mark here.
1926 if (here_text
.empty() && dist_text
.empty()) return;
1927 here_text
= wxString();
1928 dist_text
= wxString();
1933 Vector3 v
= *here
+ GetOffset();
1934 wxString
& s
= here_text
;
1935 Double x
= v
.GetX();
1936 Double y
= v
.GetY();
1937 Double z
= v
.GetZ();
1939 if (m_Gfx
->GetMetric()) {
1942 x
/= METRES_PER_FOOT
;
1943 y
/= METRES_PER_FOOT
;
1944 z
/= METRES_PER_FOOT
;
1947 s
.Printf(wmsg(/*%.2f E, %.2f N*/338), x
, y
);
1948 s
+= wxString::Format(wxT(", %s %.2f%s"), wmsg(/*Altitude*/335).c_str(),
1949 z
, wmsg(units
).c_str());
1951 s
+= here
->name_or_anon();
1952 m_Gfx
->SetHere(here
);
1953 m_Tree
->SetHere(here
->tree_id
);
1955 if (m_Gfx
->ShowingMeasuringLine() && there
) {
1956 Vector3 delta
= *here
- *there
;
1958 Double d_horiz
= sqrt(delta
.GetX()*delta
.GetX() +
1959 delta
.GetY()*delta
.GetY());
1960 Double dr
= delta
.magnitude();
1961 Double dz
= delta
.GetZ();
1963 Double brg
= deg(atan2(delta
.GetX(), delta
.GetY()));
1964 if (brg
< 0) brg
+= 360;
1966 Double grd
= deg(atan2(delta
.GetZ(), d_horiz
));
1969 from_str
.Printf(wmsg(/*From %s*/339), there
->name_or_anon().c_str());
1972 if (m_Gfx
->GetMetric()) {
1975 d_horiz
/= METRES_PER_FOOT
;
1976 dr
/= METRES_PER_FOOT
;
1977 dz
/= METRES_PER_FOOT
;
1980 wxString len_unit
= wmsg(units
);
1981 /* TRANSLATORS: "H" is short for "Horizontal", "V" for "Vertical" */
1982 hv_str
.Printf(wmsg(/*H %.2f%s, V %.2f%s*/340),
1983 d_horiz
, len_unit
.c_str(), dz
, len_unit
.c_str());
1985 if (m_Gfx
->GetDegrees()) {
1986 brg_unit
= /*°*/344;
1988 brg
*= 400.0 / 360.0;
1989 brg_unit
= /*ᵍ*/345;
1993 if (m_Gfx
->GetPercent()) {
1996 } else if (grd
< -89.99) {
1999 grd
= int(100 * tan(rad(grd
)));
2001 if (grd
> 99999 || grd
< -99999) {
2002 grd_str
= grd
> 0 ? wxT("+") : wxT("-");
2003 /* TRANSLATORS: infinity symbol - used for the percentage gradient on
2004 * vertical angles. */
2005 grd_str
+= wmsg(/*∞*/431);
2008 } else if (m_Gfx
->GetDegrees()) {
2009 grd_unit
= /*°*/344;
2011 grd
*= 400.0 / 360.0;
2012 grd_unit
= /*ᵍ*/345;
2014 if (grd_str
.empty()) {
2015 grd_str
.Printf(wxT("%+02.1f%s"), grd
, wmsg(grd_unit
).c_str());
2018 wxString
& d
= dist_text
;
2019 /* TRANSLATORS: "Dist" is short for "Distance", "Brg" for "Bearing" (as
2020 * in Compass bearing) and "Grd" for "Gradient" (the slope angle
2021 * measured by the clino) */
2022 d
.Printf(wmsg(/*%s: %s, Dist %.2f%s, Brg %03.1f%s, Grd %s*/341),
2023 from_str
.c_str(), hv_str
.c_str(),
2024 dr
, len_unit
.c_str(),
2025 brg
, wmsg(brg_unit
).c_str(),
2028 dist_text
= wxString();
2034 void MainFrm::DisplayTreeInfo(const wxTreeItemData
* item
)
2036 const TreeData
* data
= static_cast<const TreeData
*>(item
);
2037 if (data
&& data
->IsStation()) {
2038 m_Gfx
->SetHereFromTree(data
->GetLabel());
2044 void MainFrm::TreeItemSelected(const wxTreeItemData
* item
, bool zoom
)
2046 const TreeData
* data
= static_cast<const TreeData
*>(item
);
2047 if (data
&& data
->IsStation()) {
2048 const LabelInfo
* label
= data
->GetLabel();
2049 if (zoom
) m_Gfx
->CentreOn(*label
);
2050 m_Gfx
->SetThere(label
);
2051 dist_text
= wxString();
2052 // FIXME: Need to update dist_text (From ... etc)
2053 // But we don't currently know where "here" is at this point in the
2056 dist_text
= wxString();
2060 // Must be the root.
2061 m_FindBox
->SetValue(wxString());
2063 wxCommandEvent dummy
;
2066 } else if (data
&& !data
->IsStation()) {
2067 m_FindBox
->SetValue(data
->GetSurvey() + wxT(".*"));
2069 wxCommandEvent dummy
;
2076 void MainFrm::OnPresNew(wxCommandEvent
&)
2078 if (m_PresList
->Modified()) {
2079 AvenAllowOnTop
ontop(this);
2080 // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel]
2081 if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327),
2082 wmsg(/*Modified Presentation*/326),
2083 wxOK
|wxCANCEL
|wxICON_QUESTION
) == wxCANCEL
) {
2087 m_PresList
->New(m_File
);
2088 if (!ShowingSidePanel()) ToggleSidePanel();
2089 // Select the presentation page in the notebook.
2090 m_Notebook
->SetSelection(1);
2093 void MainFrm::OnPresOpen(wxCommandEvent
&)
2095 AvenAllowOnTop
ontop(this);
2096 if (m_PresList
->Modified()) {
2097 // FIXME: better to ask "Do you want to save your changes?" and offer [Save] [Discard] [Cancel]
2098 if (wxMessageBox(wmsg(/*The current presentation has been modified. Abandon unsaved changes?*/327),
2099 wmsg(/*Modified Presentation*/326),
2100 wxOK
|wxCANCEL
|wxICON_QUESTION
) == wxCANCEL
) {
2105 wxFileDialog
dlg(this, wmsg(/*Select a presentation to open*/322), wxString(), wxString(),
2106 wxT("*.fly"), wxFD_OPEN
);
2108 wxFileDialog
dlg(this, wmsg(/*Select a presentation to open*/322), wxString(), wxString(),
2109 wxString::Format(wxT("%s|*.fly|%s|%s"),
2110 wmsg(/*Aven presentations*/320).c_str(),
2111 wmsg(/*All files*/208).c_str(),
2112 wxFileSelectorDefaultWildcardStr
),
2113 wxFD_OPEN
|wxFD_FILE_MUST_EXIST
);
2115 if (dlg
.ShowModal() == wxID_OK
) {
2116 if (!m_PresList
->Load(dlg
.GetPath())) {
2119 // FIXME : keep a history of loaded/saved presentations, like we do for
2120 // loaded surveys...
2121 // Select the presentation page in the notebook.
2122 m_Notebook
->SetSelection(1);
2126 void MainFrm::OnPresSave(wxCommandEvent
&)
2128 m_PresList
->Save(true);
2131 void MainFrm::OnPresSaveAs(wxCommandEvent
&)
2133 m_PresList
->Save(false);
2136 void MainFrm::OnPresMark(wxCommandEvent
&)
2138 m_PresList
->AddMark();
2141 void MainFrm::OnPresFRewind(wxCommandEvent
&)
2143 m_Gfx
->PlayPres(-100);
2146 void MainFrm::OnPresRewind(wxCommandEvent
&)
2148 m_Gfx
->PlayPres(-10);
2151 void MainFrm::OnPresReverse(wxCommandEvent
&)
2153 m_Gfx
->PlayPres(-1);
2156 void MainFrm::OnPresPlay(wxCommandEvent
&)
2161 void MainFrm::OnPresFF(wxCommandEvent
&)
2163 m_Gfx
->PlayPres(10);
2166 void MainFrm::OnPresFFF(wxCommandEvent
&)
2168 m_Gfx
->PlayPres(100);
2171 void MainFrm::OnPresPause(wxCommandEvent
&)
2176 void MainFrm::OnPresStop(wxCommandEvent
&)
2178 m_Gfx
->PlayPres(0, false);
2181 void MainFrm::OnPresExportMovie(wxCommandEvent
&)
2184 AvenAllowOnTop
ontop(this);
2185 // FIXME : Taking the leaf of the currently loaded presentation as the
2186 // default might make more sense?
2188 wxFileName::SplitPath(m_File
, NULL
, NULL
, &baseleaf
, NULL
, wxPATH_NATIVE
);
2189 wxFileDialog
dlg(this, wmsg(/*Export Movie*/331), wxString(),
2190 baseleaf
+ wxT(".mp4"),
2191 wxT("MPEG|*.mp4|OGG|*.ogv|AVI|*.avi|QuickTime|*.mov|WMV|*.wmv;*.asf"),
2192 wxFD_SAVE
|wxFD_OVERWRITE_PROMPT
);
2193 if (dlg
.ShowModal() == wxID_OK
) {
2194 // Error is reported by GfxCore.
2195 (void)m_Gfx
->ExportMovie(dlg
.GetPath());
2198 wxGetApp().ReportError(wxT("Movie generation support code not present"));
2202 PresentationMark
MainFrm::GetPresMark(int which
)
2204 return m_PresList
->GetPresMark(which
);
2207 void MainFrm::RestrictTo(const wxString
& survey
)
2209 // The station names will change, so clear the current search.
2210 wxCommandEvent dummy
;
2213 wxString new_prefix
;
2214 if (!survey
.empty()) {
2215 if (!m_Survey
.empty()) {
2216 new_prefix
= m_Survey
;
2217 new_prefix
+= GetSeparator();
2219 new_prefix
+= survey
;
2221 // Reload the processed data rather rather than potentially reprocessing.
2222 if (!LoadData(m_FileProcessed
, new_prefix
))
2224 InitialiseAfterLoad(m_File
, new_prefix
);
2227 void MainFrm::OnOpenTerrainUpdate(wxUpdateUIEvent
& event
)
2229 event
.Enable(!m_File
.empty());
2232 void MainFrm::OnPresNewUpdate(wxUpdateUIEvent
& event
)
2234 event
.Enable(!m_File
.empty());
2237 void MainFrm::OnPresOpenUpdate(wxUpdateUIEvent
& event
)
2239 event
.Enable(!m_File
.empty());
2242 void MainFrm::OnPresSaveUpdate(wxUpdateUIEvent
& event
)
2244 event
.Enable(!m_PresList
->Empty());
2247 void MainFrm::OnPresSaveAsUpdate(wxUpdateUIEvent
& event
)
2249 event
.Enable(!m_PresList
->Empty());
2252 void MainFrm::OnPresMarkUpdate(wxUpdateUIEvent
& event
)
2254 event
.Enable(!m_File
.empty());
2257 void MainFrm::OnPresFRewindUpdate(wxUpdateUIEvent
& event
)
2259 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2260 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() < -10);
2263 void MainFrm::OnPresRewindUpdate(wxUpdateUIEvent
& event
)
2265 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2266 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() == -10);
2269 void MainFrm::OnPresReverseUpdate(wxUpdateUIEvent
& event
)
2271 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2272 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() == -1);
2275 void MainFrm::OnPresPlayUpdate(wxUpdateUIEvent
& event
)
2277 event
.Enable(!m_PresList
->Empty());
2278 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationMode() &&
2279 m_Gfx
->GetPresentationSpeed() == 1);
2282 void MainFrm::OnPresFFUpdate(wxUpdateUIEvent
& event
)
2284 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2285 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() == 10);
2288 void MainFrm::OnPresFFFUpdate(wxUpdateUIEvent
& event
)
2290 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2291 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() > 10);
2294 void MainFrm::OnPresPauseUpdate(wxUpdateUIEvent
& event
)
2296 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2297 event
.Check(m_Gfx
&& m_Gfx
->GetPresentationSpeed() == 0);
2300 void MainFrm::OnPresStopUpdate(wxUpdateUIEvent
& event
)
2302 event
.Enable(m_Gfx
&& m_Gfx
->GetPresentationMode());
2305 void MainFrm::OnPresExportMovieUpdate(wxUpdateUIEvent
& event
)
2307 event
.Enable(!m_PresList
->Empty());
2310 void MainFrm::OnFind(wxCommandEvent
&)
2312 pending_find
= true;
2315 void MainFrm::OnIdle(wxIdleEvent
&)
2322 void MainFrm::DoFind()
2324 pending_find
= false;
2325 wxBusyCursor hourglass
;
2326 // Find stations specified by a string or regular expression pattern.
2328 wxString pattern
= m_FindBox
->GetValue();
2329 if (pattern
.empty()) {
2330 // Hide any search result highlights.
2331 list
<LabelInfo
*>::iterator pos
= m_Labels
.begin();
2332 while (pos
!= m_Labels
.end()) {
2333 LabelInfo
* label
= *pos
++;
2334 label
->clear_flags(LFLAG_HIGHLIGHTED
);
2336 m_NumHighlighted
= 0;
2338 int re_flags
= wxRE_NOSUB
;
2340 if (true /* case insensitive */) {
2341 re_flags
|= wxRE_ICASE
;
2344 bool substring
= true;
2345 if (false /*m_RegexpCheckBox->GetValue()*/) {
2346 re_flags
|= wxRE_EXTENDED
;
2347 } else if (true /* simple glob-style */) {
2349 for (size_t i
= 0; i
< pattern
.size(); i
++) {
2350 wxChar ch
= pattern
[i
];
2351 // ^ only special at start; $ at end. But this is simpler...
2353 case '^': case '$': case '.': case '[': case '\\':
2370 re_flags
|= wxRE_BASIC
;
2373 for (size_t i
= 0; i
< pattern
.size(); i
++) {
2374 wxChar ch
= pattern
[i
];
2375 // ^ only special at start; $ at end. But this is simpler...
2377 case '^': case '$': case '*': case '.': case '[': case '\\':
2383 re_flags
|= wxRE_BASIC
;
2387 // FIXME "0u" required to avoid compilation error with g++-3.0
2388 if (pattern
.empty() || pattern
[0u] != '^') pattern
= wxT('^') + pattern
;
2389 // FIXME: this fails to cope with "\$" at the end of pattern...
2390 if (pattern
[pattern
.size() - 1] != '$') pattern
+= wxT('$');
2394 if (!regex
.Compile(pattern
, re_flags
)) {
2401 list
<LabelInfo
*>::iterator pos
= m_Labels
.begin();
2402 while (pos
!= m_Labels
.end()) {
2403 LabelInfo
* label
= *pos
++;
2405 if (regex
.Matches(label
->GetText())) {
2406 label
->set_flags(LFLAG_HIGHLIGHTED
);
2409 label
->clear_flags(LFLAG_HIGHLIGHTED
);
2413 m_NumHighlighted
= found
;
2415 // Re-sort so highlighted points get names in preference
2416 if (found
) m_Labels
.sort(LabelPlotCmp(GetSeparator()));
2419 m_Gfx
->UpdateBlobs();
2420 m_Gfx
->ForceRefresh();
2422 if (!m_NumHighlighted
) {
2423 GetToolBar()->SetToolShortHelp(button_HIDE
, wmsg(/*No matches were found.*/328));
2425 /* TRANSLATORS: "Hide stations" button tooltip when stations are found
2427 GetToolBar()->SetToolShortHelp(button_HIDE
, wxString::Format(wmsg(/*Hide %d found stations*/334).c_str(), m_NumHighlighted
));
2431 void MainFrm::OnGotoFound(wxCommandEvent
&)
2433 if (!m_NumHighlighted
) {
2434 wxGetApp().ReportError(wmsg(/*No matches were found.*/328));
2438 Double xmin
= DBL_MAX
;
2439 Double xmax
= -DBL_MAX
;
2440 Double ymin
= DBL_MAX
;
2441 Double ymax
= -DBL_MAX
;
2442 Double zmin
= DBL_MAX
;
2443 Double zmax
= -DBL_MAX
;
2445 list
<LabelInfo
*>::iterator pos
= m_Labels
.begin();
2446 while (pos
!= m_Labels
.end()) {
2447 LabelInfo
* label
= *pos
++;
2449 if (label
->get_flags() & LFLAG_HIGHLIGHTED
) {
2450 if (label
->GetX() < xmin
) xmin
= label
->GetX();
2451 if (label
->GetX() > xmax
) xmax
= label
->GetX();
2452 if (label
->GetY() < ymin
) ymin
= label
->GetY();
2453 if (label
->GetY() > ymax
) ymax
= label
->GetY();
2454 if (label
->GetZ() < zmin
) zmin
= label
->GetZ();
2455 if (label
->GetZ() > zmax
) zmax
= label
->GetZ();
2459 m_Gfx
->SetViewTo(xmin
, xmax
, ymin
, ymax
, zmin
, zmax
);
2463 void MainFrm::OnHide(wxCommandEvent
&)
2465 m_FindBox
->SetValue(wxString());
2466 GetToolBar()->SetToolShortHelp(button_HIDE
, wmsg(/*Hide*/333));
2469 void MainFrm::OnHideUpdate(wxUpdateUIEvent
& ui
)
2471 ui
.Enable(m_NumHighlighted
!= 0);
2474 void MainFrm::OnViewSidePanel(wxCommandEvent
&)
2479 void MainFrm::ToggleSidePanel()
2481 // Toggle display of the side panel.
2485 if (m_Splitter
->IsSplit()) {
2486 m_SashPosition
= m_Splitter
->GetSashPosition(); // save width of panel
2487 m_Splitter
->Unsplit(m_Notebook
);
2489 m_Notebook
->Show(true);
2491 m_Splitter
->SplitVertically(m_Notebook
, m_Gfx
, m_SashPosition
);
2495 void MainFrm::OnViewSidePanelUpdate(wxUpdateUIEvent
& ui
)
2497 ui
.Enable(!m_File
.empty());
2498 ui
.Check(ShowingSidePanel());
2501 bool MainFrm::ShowingSidePanel()
2503 return m_Splitter
->IsSplit();
2506 void MainFrm::ViewFullScreen() {
2508 // On OS X, wxWidgets doesn't currently hide the toolbar or statusbar in
2509 // full screen mode (last checked with 3.0.2), but it is easy to do
2511 if (!IsFullScreen()) {
2512 GetToolBar()->Hide();
2513 GetStatusBar()->Hide();
2517 ShowFullScreen(!IsFullScreen());
2518 fullscreen_showing_menus
= false;
2520 was_showing_sidepanel_before_fullscreen
= ShowingSidePanel();
2521 if (was_showing_sidepanel_before_fullscreen
)
2525 if (!IsFullScreen()) {
2526 GetStatusBar()->Show();
2527 GetToolBar()->Show();
2528 #ifdef USING_GENERIC_TOOLBAR
2535 bool MainFrm::FullScreenModeShowingMenus() const
2537 return fullscreen_showing_menus
;
2540 void MainFrm::FullScreenModeShowMenus(bool show
)
2542 if (!IsFullScreen() || show
== fullscreen_showing_menus
)
2545 // On OS X, enabling the menu bar while in full
2546 // screen mode doesn't have any effect, so instead
2547 // make moving the mouse to the top of the screen
2548 // drop us out of full screen mode for now.
2551 GetMenuBar()->Show(show
);
2552 fullscreen_showing_menus
= show
;