Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BrowseDialog.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
10 /* This is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public
12  * License as published by the Free Software Foundation; either
13  * version 2 of the License, or (at your option) any later version.
14  *
15  * This software 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 GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public
21  * License along with this software. If not, see
22  * <http://www.gnu.org/licenses/>.
23  *
24  */
25 
26 #ifndef _BROWSEPTOFILESDIALOG_H
27 #define _BROWSEPTOFILESDIALOG_H
28 
29 #include "wx/dialog.h"
30 #include "wx/dirctrl.h"
31 #include "wx/listctrl.h"
32 #include "wx/statbmp.h"
33 #include "wx/stattext.h"
34 #include "wx/splitter.h"
35 #include "wx/arrstr.h"
36 #include "wx/thread.h"
37 #include "wx/datetime.h"
38 #include "wx/filename.h"
40 
42 // forward declaration for easier access on members of dialog
43 class ThumbnailThread;
44 
46 class PanoInfo
47 {
48 public:
49  wxFileName ptoFilename;
50  // number of images in pto file
51  size_t nrImages = 0;
52  // number of active images
53  size_t nrActiveImages = 0;
55  wxString projectionName;
56  wxDateTime start;
57  wxTimeSpan duration;
58  wxString camera;
59  wxString lens;
60  double focalLength35 = 0.0;
62  int imageIndex = -1;
63  double GPSLongitude = DBL_MAX;
64  double GPSLatitude = DBL_MAX;
65  bool HasGPS()
66  {
67  return GPSLongitude != DBL_MAX && GPSLatitude != DBL_MAX;
68  }
69 };
70 
72 class BrowsePTOFilesDialog : public wxDialog
73 {
74 public:
76  BrowsePTOFilesDialog(wxWindow *parent, const wxString startDirectory);
80  wxString GetSelectedProject();
82  wxString GetSelectedPath();
83 
84 protected:
86  void OnOk(wxCommandEvent& e);
88  void OnDirectoryChanged(wxTreeEvent& e);
90  void OnFileChanged(wxListEvent& e);
92  void OnDblClickListCtrl(wxMouseEvent& e);
94  void OnListColClick(wxListEvent& e);
97  void OnThumbnailUpdate(wxCommandEvent& e);
99  void OnListTypeChanged(wxCommandEvent& e);
101  void OnShowOnMap(wxCommandEvent& e);
102 
103 private:
105  long TranslateIndex(const long index);
107  void SortItems();
109  void EndThumbnailThread();
111  PanoInfo ParsePTOFile(const wxFileName file);
113  void FillPanoInfo(const PanoInfo& info, long index);
115  void UpdateItemTexts(long newStyle);
116 #if !wxCHECK_VERSION(3,1,6)
117 
118  void UpdateImagesIndex();
119 #endif
120 
121  void GeneratePreview(int index);
122  // access to some often needed GUI elements
123  wxGenericDirCtrl* m_dirCtrl = nullptr;
124  wxListCtrl* m_listCtrl = nullptr;
125  wxChoice* m_listType = nullptr;
126  wxButton* m_showMap = nullptr;
127  // store current sorting column
128  long m_sortCol = -1;
129  bool m_sortAscending = true;
130  wxStaticBitmap* m_previewCtrl = nullptr;
131  wxStaticText* m_labelControl = nullptr;
132  wxSplitterWindow* m_splitter1;
133  wxSplitterWindow* m_splitter2;
135  std::vector<PanoInfo> m_ptoInfo;
137  wxImageList m_thumbnails;
141  wxCriticalSection m_ThreadCS;
142  friend class ThumbnailThread;
143  DECLARE_EVENT_TABLE()
144 };
145 
146 #endif //_BROWSEPTOFILESDIALOG_H
~BrowsePTOFilesDialog()
destructor, saves position
BrowsePTOFilesDialog(wxWindow *parent, const wxString startDirectory)
Constructor, read from xrc ressource; restore last uses settings and position.
wxListCtrl * m_listCtrl
Definition: BrowseDialog.h:124
size_t nrActiveImages
Definition: BrowseDialog.h:53
void FillPanoInfo(const PanoInfo &info, long index)
add a new item to wxListCtrl and populate all columns
double focalLength35
Definition: BrowseDialog.h:60
void OnFileChanged(wxListEvent &e)
new file selected, generate preview for new file
wxString projectionName
Definition: BrowseDialog.h:55
double GPSLongitude
Definition: BrowseDialog.h:63
void OnThumbnailUpdate(wxCommandEvent &e)
for notifing from ThumbnailThread about new generated thumbnail generated thumbnail is transfered in ...
wxString lens
Definition: BrowseDialog.h:59
void OnDblClickListCtrl(wxMouseEvent &e)
double click does open file
wxSplitterWindow * m_splitter1
Definition: BrowseDialog.h:132
PanoInfo ParsePTOFile(const wxFileName file)
read the given pto file and add all information to wxListCtrl
void OnListColClick(wxListEvent &e)
click on header to sort by column
bool HasGPS()
Definition: BrowseDialog.h:65
wxString focalLengthString
Definition: BrowseDialog.h:61
wxStaticText * m_labelControl
Definition: BrowseDialog.h:131
wxString camera
Definition: BrowseDialog.h:58
Dialog for browsing pto files.
Definition: BrowseDialog.h:72
wxGenericDirCtrl * m_dirCtrl
Definition: BrowseDialog.h:123
void OnDirectoryChanged(wxTreeEvent &e)
directory changed, load files from new directory
wxImageList m_thumbnails
image list with all thumbnails
Definition: BrowseDialog.h:137
HuginBase::PanoramaOptions options
Definition: BrowseDialog.h:54
void GeneratePreview(int index)
generate preview for pto file with index
wxSplitterWindow * m_splitter2
Definition: BrowseDialog.h:133
std::vector< PanoInfo > m_ptoInfo
info about the pto file
Definition: BrowseDialog.h:135
void SortItems()
sort the items according to selected column
wxDateTime start
Definition: BrowseDialog.h:56
wxString GetSelectedProject()
return full path of selected project
wxFileName ptoFilename
Definition: BrowseDialog.h:49
int imageIndex
Definition: BrowseDialog.h:62
wxCriticalSection m_ThreadCS
critical section to synchronize with ThumbnailThread
Definition: BrowseDialog.h:141
background thread to generate thumbnails of all pto files
void UpdateImagesIndex()
update the image indexes
wxStaticBitmap * m_previewCtrl
Definition: BrowseDialog.h:130
size_t nrImages
Definition: BrowseDialog.h:51
void OnListTypeChanged(wxCommandEvent &e)
Change display of wxListCtrl.
static void info(const char *fmt,...)
Definition: svm.cpp:95
class to store some information about a pto file on disc
Definition: BrowseDialog.h:46
double GPSLatitude
Definition: BrowseDialog.h:64
void OnOk(wxCommandEvent &e)
Saves current expression when closing dialog with Ok.
Panorama image options.
ThumbnailThread * m_thumbnailThread
background thumbnail creater thread
Definition: BrowseDialog.h:139
long TranslateIndex(const long index)
translate the index to the index of m_ptoInfo
wxTimeSpan duration
Definition: BrowseDialog.h:57
void OnShowOnMap(wxCommandEvent &e)
show current pano on Openstreetmap
void EndThumbnailThread()
end background thumbnail creating thread
void UpdateItemTexts(long newStyle)
update all item texts
wxString GetSelectedPath()
return last selected path