1 // -*- c-basic-offset: 4 -*-
2 /** @file ImagesPanel.h
3  *
4  *  @author Kai-Uwe Behrmann <web@tiscali.de>
5  *
6  *  $Id$
7  *
8  *  This is free software; you can redistribute it and/or
9  *  modify it under the terms of the GNU General Public
10  *  License as published by the Free Software Foundation; either
11  *  version 2 of the License, or (at your option) any later version.
12  *
13  *  This software is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *  Lesser General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public
19  *  License along with this software. If not, see
20  *  <http://www.gnu.org/licenses/>.
21  *
22  */
23 
24 #ifndef _IMAGESPANEL_H
25 #define _IMAGESPANEL_H
26 
27 #include "hugin/MainFrame.h"
28 
29 #include "base_wx/wxImageCache.h"
30 
31 // forward declarations, to save the #include statements
32 class ImagesTreeCtrl;
33 
34 /** Hugin's first panel
35  *
36  *  This Panel is for loading of images into Panorama.
37  *  Here one can set first values vor the camera orientation and
38  *  link these parameters for the optimization.
39  */
40 class ImagesPanel: public wxPanel, public HuginBase::PanoramaObserver
41 {
42 public:
43     ImagesPanel();
44 
45     bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL, const wxString& name = wxT("panel"));
46 
47     void Init(HuginBase::Panorama * pano);
48 
49     ~ImagesPanel();
50 
51     /** this is called whenever the panorama has changed.
52      *
53      *  This function must now update all the gui representations
54      *  of the panorama to display the new state.
55      *
56      *  Functions that change the panororama must not update
57      *  the GUI directly. The GUI should always be updated
58      *  to reflect the current panorama state in this function.
59      *
60      *  This avoids unnessecary close coupling between the
61      *  controller and the view (even if they sometimes
62      *  are in the same object). See model view controller
63      *  pattern.
64      *
65      *  @todo   react on different update signals more special
66      */
67 //    virtual void panoramaChanged(HuginBase::Panorama &pano);
68     /** receives notification about panorama changes */
69     virtual void panoramaChanged(HuginBase::Panorama & pano);
70     virtual void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet & imgNr);
71     /** Reloads the cp detector settings from config, necessary after edit preferences */
72     void ReloadCPDetectorSettings();
73     /** returns the default cp detector settings */
GetDefaultSetting()74     CPDetectorSetting& GetDefaultSetting() { return cpdetector_config.settings.Item(cpdetector_config.GetDefaultGenerator());};
75 
76     /** sets the GuiLevel for all controls on this panel */
77     void SetGuiLevel(GuiLevel newGuiLevel);
78     /** return the currently selected optimizer setting as string from the drop down list box */
79     wxString GetCurrentOptimizerString();
80     /** run the cp generator with the given setting on selected images */
81     void RunCPGenerator(CPDetectorSetting &setting, const HuginBase::UIntSet& img);
82     /** runs the currently selected cp generator on given images */
83     void RunCPGenerator(const HuginBase::UIntSet& img);
84     /** return the currently selected cp generator description */
85     const wxString GetSelectedCPGenerator();
86 protected:
87     /** event handler for geometric optimizer */
88     void OnOptimizeButton(wxCommandEvent &e);
89     /** event handler for photometric optimizer */
90     void OnPhotometricOptimizeButton(wxCommandEvent &e);
91 
92 private:
93     // a window event
94     void OnSize(wxSizeEvent & e);
95 
96     /** the model */
97     HuginBase::Panorama * m_pano;
98 
99     /** control point detection event handler*/
100     void CPGenerate(wxCommandEvent & e);
101     /** change displayed variables if the selection
102      *  has changed.
103      */
104     void OnSelectionChanged(wxTreeEvent & e);
105 
106     /** updates the lens type for the selected images */
107     void OnLensTypeChanged(wxCommandEvent & e);
108     /** updates the focal length for the selected images */
109     void OnFocalLengthChanged(wxCommandEvent & e);
110     /** updates the crop factor for the selected images */
111     void OnCropFactorChanged(wxCommandEvent & e);
112     /** updates the minimum overlap */
113     void OnMinimumOverlapChanged(wxCommandEvent & e);
114     /** updates the max ev difference */
115     void OnMaxEvDiffChanged(wxCommandEvent& e);
116 
117     /** event handler when grouping selection was changed */
118     void OnGroupModeChanged(wxCommandEvent & e);
119     /** event handler when display mode (which information should be shown) was changed */
120     void OnDisplayModeChanged(wxCommandEvent & e);
121     /** event handler, when optimizer master switch was changed */
122     void OnOptimizerSwitchChanged(wxCommandEvent &e);
123     /** event handler, when photometric optimizer master switch was changed */
124     void OnPhotometricOptimizerSwitchChanged(wxCommandEvent &e);
125     /** fills the grouping wxChoice with values depending on GuiLevel */
126     void FillGroupChoice();
127     /** fills the optmizer wxChoices with values depending on GuiLevel */
128     void FillOptimizerChoice();
129 
130     void DisableImageCtrls();
131     void EnableImageCtrls();
132 
133     /** show a bigger thumbnail */
134     void ShowImage(unsigned int imgNr);
135     void UpdatePreviewImage();
136 
137     /** bitmap with default image */
138     wxBitmap m_empty;
139 
140     /** Request for thumbnail image */
141     HuginBase::ImageCache::RequestPtr thumbnail_request;
142 
143     /** pointer to the main control */
144     ImagesTreeCtrl* m_images_tree;
145     /** pointer to the preview image control */
146     wxStaticBitmap * m_smallImgCtrl;
147     /** pointer to lens type selector */
148     wxChoice *m_lenstype;
149     /** pointer to optimizer switch selector */
150     wxChoice *m_optChoice;
151     /** pointer to photometric optimizer switch selector */
152     wxChoice *m_optPhotoChoice;
153     /** the text input control for focal length */
154     wxTextCtrl *m_focallength;
155     /** the text input control for crop factor */
156     wxTextCtrl *m_cropfactor;
157     /** the text input control for minimum overlap */
158     wxTextCtrl *m_overlap;
159     /** the text input control for max ev difference */
160     wxTextCtrl *m_maxEv;
161     size_t m_showImgNr;
162 
163     wxButton * m_matchingButton;
164     wxChoice *m_CPDetectorChoice;
165     //storing for different cp detector settings
166     CPDetectorConfig cpdetector_config;
167 
168     GuiLevel m_guiLevel;
169     int m_degDigits;
170 
171     DECLARE_EVENT_TABLE()
172     DECLARE_DYNAMIC_CLASS(ImagesPanel)
173 };
174 
175 /** xrc handler */
176 class ImagesPanelXmlHandler : public wxXmlResourceHandler
177 {
178     DECLARE_DYNAMIC_CLASS(ImagesPanelXmlHandler)
179 
180 public:
181     ImagesPanelXmlHandler();
182     virtual wxObject *DoCreateResource();
183     virtual bool CanHandle(wxXmlNode *node);
184 };
185 
186 #endif // _IMAGESPANEL_H
187