Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ResetDialog.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
11 /* This is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This software is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public
22  * License along with this software. If not, see
23  * <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #include "hugin/ResetDialog.h"
28 #include "base_wx/wxPlatform.h"
29 #include "panoinc.h"
30 
31 #include "hugin/huginApp.h"
32 
33 BEGIN_EVENT_TABLE(ResetDialog,wxDialog)
34  EVT_BUTTON(wxID_OK, ResetDialog::OnOk)
35  EVT_CHECKBOX(XRCID("reset_exposure"), ResetDialog::OnSelectExposure)
36  EVT_CHECKBOX(XRCID("reset_color"), ResetDialog::OnSelectColor)
38 
39 ResetDialog::ResetDialog(wxWindow *parent, GuiLevel guiLevel)
40 {
41  // load our children. some children might need special
42  // initialization. this will be done later.
43  wxXmlResource::Get()->LoadDialog(this, parent, wxT("reset_dialog"));
44 
45 #ifdef __WXMSW__
46  wxIconBundle myIcons(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
47  SetIcons(myIcons);
48 #else
49  wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
50  SetIcon(myIcon);
51 #endif
52 
53  //set parameters
54  wxConfigBase * cfg = wxConfigBase::Get();
55  bool check;
56  cfg->Read(wxT("/ResetDialog/ResetPosition"),&check,true);
57  XRCCTRL(*this,"reset_pos",wxCheckBox)->SetValue(check);
58  cfg->Read(wxT("/ResetDialog/ResetTranslation"), &check, true);
59  wxCheckBox* reset_translation=XRCCTRL(*this,"reset_translation",wxCheckBox);
60  reset_translation->SetValue(check);
61  if(guiLevel<GUI_EXPERT)
62  {
63  reset_translation->Hide();
64  };
65  cfg->Read(wxT("/ResetDialog/ResetFOV"),&check,true);
66  XRCCTRL(*this,"reset_fov",wxCheckBox)->SetValue(check);
67  cfg->Read(wxT("/ResetDialog/ResetLens"),&check,true);
68  XRCCTRL(*this,"reset_lens",wxCheckBox)->SetValue(check);
69  cfg->Read(wxT("/ResetDialog/ResetExposure"),&check,true);
70  XRCCTRL(*this,"reset_exposure",wxCheckBox)->SetValue(check);
71  int exp_param;
72  cfg->Read(wxT("/ResetDialog/ResetExposureParam"),&exp_param,0);
73  XRCCTRL(*this,"combo_exposure",wxComboBox)->Select(exp_param);
74  wxCommandEvent dummy;
75  OnSelectExposure(dummy);
76  cfg->Read(wxT("/ResetDialog/ResetColor"),&check,true);
77  XRCCTRL(*this,"reset_color",wxCheckBox)->SetValue(check);
78  cfg->Read(wxT("/ResetDialog/ResetColorParam"),&exp_param,0);
79  OnSelectColor(dummy);
80  XRCCTRL(*this,"combo_color",wxComboBox)->Select(exp_param);
81  cfg->Read(wxT("/ResetDialog/ResetVignetting"),&check,true);
82  XRCCTRL(*this,"reset_vignetting",wxCheckBox)->SetValue(check);
83  cfg->Read(wxT("/ResetDialog/ResetResponse"),&check,true);
84  XRCCTRL(*this,"reset_response",wxCheckBox)->SetValue(check);
85  GetSizer()->Fit(this);
86  //position
87  int x = cfg->Read(wxT("/ResetDialog/positionX"),-1l);
88  int y = cfg->Read(wxT("/ResetDialog/positionY"),-1l);
89  if ( y >= 0 && x >= 0)
90  {
91  this->Move(x, y);
92  }
93  else
94  {
95  this->Move(0, 44);
96  };
97 };
98 
100 {
101  XRCCTRL(*this,"reset_exposure",wxCheckBox)->Show(false);
102  XRCCTRL(*this,"combo_exposure",wxComboBox)->Show(false);
103  XRCCTRL(*this,"reset_color",wxCheckBox)->Show(false);
104  XRCCTRL(*this,"combo_color",wxComboBox)->Show(false);
105  XRCCTRL(*this,"reset_vignetting",wxCheckBox)->Show(false);
106  XRCCTRL(*this,"reset_response",wxCheckBox)->Show(false);
107  GetSizer()->Fit(this);
108 };
109 
111 {
112  XRCCTRL(*this,"reset_pos",wxCheckBox)->Show(false);
113  XRCCTRL(*this,"reset_translation",wxCheckBox)->Show(false);
114  XRCCTRL(*this,"reset_fov",wxCheckBox)->Show(false);
115  XRCCTRL(*this,"reset_lens",wxCheckBox)->Show(false);
116  GetSizer()->Fit(this);
117 };
118 
119 void ResetDialog::OnOk(wxCommandEvent & e)
120 {
121  wxConfigBase * cfg = wxConfigBase::Get();
122  wxPoint ps = this->GetPosition();
123  cfg->Write(wxT("/ResetDialog/positionX"), ps.x);
124  cfg->Write(wxT("/ResetDialog/positionY"), ps.y);
125  cfg->Write(wxT("/ResetDialog/ResetPosition"),GetResetPos());
126  cfg->Write(wxT("/ResetDialog/ResetTranslation"), GetResetTranslation());
127  cfg->Write(wxT("/ResetDialog/ResetFOV"),GetResetFOV());
128  cfg->Write(wxT("/ResetDialog/ResetLens"),GetResetLens());
129  cfg->Write(wxT("/ResetDialog/ResetExposure"),GetResetExposure());
130  int exp_param;
131  exp_param=XRCCTRL(*this,"combo_exposure",wxComboBox)->GetSelection();
132  cfg->Write(wxT("/ResetDialog/ResetExposureParam"),exp_param);
133  cfg->Write(wxT("/ResetDialog/ResetColor"),GetResetColor());
134  exp_param=XRCCTRL(*this,"combo_color",wxComboBox)->GetSelection();
135  cfg->Write(wxT("/ResetDialog/ResetColorParam"), exp_param);
136  cfg->Write(wxT("/ResetDialog/ResetVignetting"),GetResetVignetting());
137  cfg->Write(wxT("/ResetDialog/ResetResponse"),GetResetResponse());
138  cfg->Flush();
139  e.Skip();
140 };
141 
142 void ResetDialog::OnSelectExposure(wxCommandEvent & e)
143 {
144  XRCCTRL(*this,"combo_exposure",wxComboBox)->Enable(XRCCTRL(*this, "reset_exposure", wxCheckBox)->GetValue());
145 };
146 
147 void ResetDialog::OnSelectColor(wxCommandEvent & e)
148 {
149  XRCCTRL(*this,"combo_color",wxComboBox)->Enable(XRCCTRL(*this, "reset_color", wxCheckBox)->GetValue());
150 };
151 
153 {
154  return XRCCTRL(*this, "reset_pos", wxCheckBox)->GetValue();
155 };
156 
158 {
159  return XRCCTRL(*this, "reset_translation", wxCheckBox)->GetValue();
160 };
161 
163 {
164  return XRCCTRL(*this, "reset_fov", wxCheckBox)->GetValue();
165 };
166 
168 {
169  return XRCCTRL(*this, "reset_lens", wxCheckBox)->GetValue();
170 };
171 
173 {
174  return XRCCTRL(*this, "reset_exposure", wxCheckBox)->GetValue();
175 };
176 
178 {
179  if(!GetResetExposure())
180  return false;
181  return XRCCTRL(*this, "combo_exposure", wxComboBox)->GetSelection()==0;
182 };
183 
185 {
186  return XRCCTRL(*this, "reset_color", wxCheckBox)->GetValue();
187 };
188 
190 {
191  if(!GetResetColor())
192  return false;
193  return XRCCTRL(*this, "combo_color", wxComboBox)->GetSelection()==0;
194 };
195 
197 {
198  return XRCCTRL(*this, "reset_vignetting", wxCheckBox)->GetValue();
199 };
200 
202 {
203  return XRCCTRL(*this, "reset_response", wxCheckBox)->GetValue();
204 };
bool GetResetLens()
Return TRUE, when user selected &quot;Reset lens&quot;.
void OnOk(wxCommandEvent &e)
Saves current state of all checkboxes when closing dialog with Ok.
Dialog for reset panorama settings.
Definition: ResetDialog.h:44
bool GetResetExposure()
Return TRUE, when user selected &quot;Reset exposure&quot;.
void LimitToPhotometric()
limits the displayed parameters to photometric parameters
END_EVENT_TABLE()
include file for the hugin project
bool GetResetFOV()
Return TRUE, when user selected &quot;Reset FOV&quot;.
Definition of ResetDialog class.
bool GetResetExposureToExif()
Return TRUE, when user selected &quot;Reset exposure to EXIF&quot;, Return FALSE, when user selected &quot;Reset exp...
static huginApp * Get()
hack.. kind of a pseudo singleton...
Definition: huginApp.cpp:649
bool GetResetColor()
Return TRUE, when user selected &quot;Reset color&quot;.
bool GetResetVignetting()
Return TRUE, when user selected &quot;Reset vignetting&quot;.
void LimitToGeometric()
limits the displayed parameters to geometric parameters
Definition: ResetDialog.cpp:99
bool GetResetColorToExif()
Return TRUE, when user selected &quot;Reset color to EXIF&quot;, Return FALSE, when user selected &quot;Reset color ...
void OnSelectColor(wxCommandEvent &e)
Method for enabling/disable combobox to select reset color to EXIF or ONE depending on state of &quot;Rese...
platform/compiler specific stuff.
GuiLevel
Definition: GuiLevel.h:31
bool GetResetTranslation()
Return TRUE, when user selected &quot;Reset translation&quot;.
bool GetResetResponse()
Return TRUE, when user selected &quot;Reset Camera Response&quot;.
void OnSelectExposure(wxCommandEvent &e)
Method for enabling/disable combobox to select reset exposure to EXIF or ZERO depending on state of &quot;...
bool GetResetPos()
Return TRUE, when user selected &quot;Reset position&quot;.