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 ResetDialog::ResetDialog(wxWindow *parent, GuiLevel guiLevel)
34 {
35  // load our children. some children might need special
36  // initialization. this will be done later.
37  wxXmlResource::Get()->LoadDialog(this, parent, wxT("reset_dialog"));
38 
39 #ifdef __WXMSW__
40  wxIconBundle myIcons(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
41  SetIcons(myIcons);
42 #else
43  wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
44  SetIcon(myIcon);
45 #endif
46 
47  //set parameters
48  wxConfigBase * cfg = wxConfigBase::Get();
49  bool check;
50  cfg->Read(wxT("/ResetDialog/ResetPosition"),&check,true);
51  XRCCTRL(*this,"reset_pos",wxCheckBox)->SetValue(check);
52  cfg->Read(wxT("/ResetDialog/ResetTranslation"), &check, true);
53  wxCheckBox* reset_translation=XRCCTRL(*this,"reset_translation",wxCheckBox);
54  reset_translation->SetValue(check);
55  if(guiLevel<GUI_EXPERT)
56  {
57  reset_translation->Hide();
58  };
59  cfg->Read(wxT("/ResetDialog/ResetFOV"),&check,true);
60  XRCCTRL(*this,"reset_fov",wxCheckBox)->SetValue(check);
61  cfg->Read(wxT("/ResetDialog/ResetLens"),&check,true);
62  XRCCTRL(*this,"reset_lens",wxCheckBox)->SetValue(check);
63  cfg->Read(wxT("/ResetDialog/ResetExposure"),&check,true);
64  wxCheckBox* checkbox = XRCCTRL(*this, "reset_exposure", wxCheckBox);
65  checkbox->SetValue(check);
66  checkbox->Bind(wxEVT_CHECKBOX, &ResetDialog::OnSelectExposure, this);
67  int exp_param;
68  cfg->Read(wxT("/ResetDialog/ResetExposureParam"),&exp_param,0);
69  XRCCTRL(*this,"combo_exposure",wxComboBox)->Select(exp_param);
70  wxCommandEvent dummy;
71  OnSelectExposure(dummy);
72  cfg->Read(wxT("/ResetDialog/ResetColor"),&check,true);
73  checkbox = XRCCTRL(*this, "reset_color", wxCheckBox);
74  checkbox->SetValue(check);
75  checkbox->Bind(wxEVT_CHECKBOX, &ResetDialog::OnSelectColor, this);
76  cfg->Read(wxT("/ResetDialog/ResetColorParam"),&exp_param,0);
77  OnSelectColor(dummy);
78  XRCCTRL(*this,"combo_color",wxComboBox)->Select(exp_param);
79  cfg->Read(wxT("/ResetDialog/ResetVignetting"),&check,true);
80  XRCCTRL(*this,"reset_vignetting",wxCheckBox)->SetValue(check);
81  cfg->Read(wxT("/ResetDialog/ResetResponse"),&check,true);
82  XRCCTRL(*this,"reset_response",wxCheckBox)->SetValue(check);
83  GetSizer()->Fit(this);
84  //position
85  int x = cfg->Read(wxT("/ResetDialog/positionX"),-1l);
86  int y = cfg->Read(wxT("/ResetDialog/positionY"),-1l);
87  if ( y >= 0 && x >= 0)
88  {
89  this->Move(x, y);
90  }
91  else
92  {
93  this->Move(0, 44);
94  };
95  Bind(wxEVT_BUTTON, &ResetDialog::OnOk, this, wxID_OK);
96 };
97 
99 {
100  XRCCTRL(*this,"reset_exposure",wxCheckBox)->Show(false);
101  XRCCTRL(*this,"combo_exposure",wxComboBox)->Show(false);
102  XRCCTRL(*this,"reset_color",wxCheckBox)->Show(false);
103  XRCCTRL(*this,"combo_color",wxComboBox)->Show(false);
104  XRCCTRL(*this,"reset_vignetting",wxCheckBox)->Show(false);
105  XRCCTRL(*this,"reset_response",wxCheckBox)->Show(false);
106  GetSizer()->Fit(this);
107 };
108 
110 {
111  XRCCTRL(*this,"reset_pos",wxCheckBox)->Show(false);
112  XRCCTRL(*this,"reset_translation",wxCheckBox)->Show(false);
113  XRCCTRL(*this,"reset_fov",wxCheckBox)->Show(false);
114  XRCCTRL(*this,"reset_lens",wxCheckBox)->Show(false);
115  GetSizer()->Fit(this);
116 };
117 
118 void ResetDialog::OnOk(wxCommandEvent & e)
119 {
120  wxConfigBase * cfg = wxConfigBase::Get();
121  wxPoint ps = this->GetPosition();
122  cfg->Write(wxT("/ResetDialog/positionX"), ps.x);
123  cfg->Write(wxT("/ResetDialog/positionY"), ps.y);
124  cfg->Write(wxT("/ResetDialog/ResetPosition"),GetResetPos());
125  cfg->Write(wxT("/ResetDialog/ResetTranslation"), GetResetTranslation());
126  cfg->Write(wxT("/ResetDialog/ResetFOV"),GetResetFOV());
127  cfg->Write(wxT("/ResetDialog/ResetLens"),GetResetLens());
128  cfg->Write(wxT("/ResetDialog/ResetExposure"),GetResetExposure());
129  int exp_param;
130  exp_param=XRCCTRL(*this,"combo_exposure",wxComboBox)->GetSelection();
131  cfg->Write(wxT("/ResetDialog/ResetExposureParam"),exp_param);
132  cfg->Write(wxT("/ResetDialog/ResetColor"),GetResetColor());
133  exp_param=XRCCTRL(*this,"combo_color",wxComboBox)->GetSelection();
134  cfg->Write(wxT("/ResetDialog/ResetColorParam"), exp_param);
135  cfg->Write(wxT("/ResetDialog/ResetVignetting"),GetResetVignetting());
136  cfg->Write(wxT("/ResetDialog/ResetResponse"),GetResetResponse());
137  cfg->Flush();
138  e.Skip();
139 };
140 
141 void ResetDialog::OnSelectExposure(wxCommandEvent & e)
142 {
143  XRCCTRL(*this,"combo_exposure",wxComboBox)->Enable(XRCCTRL(*this, "reset_exposure", wxCheckBox)->GetValue());
144 };
145 
146 void ResetDialog::OnSelectColor(wxCommandEvent & e)
147 {
148  XRCCTRL(*this,"combo_color",wxComboBox)->Enable(XRCCTRL(*this, "reset_color", wxCheckBox)->GetValue());
149 };
150 
152 {
153  return XRCCTRL(*this, "reset_pos", wxCheckBox)->GetValue();
154 };
155 
157 {
158  return XRCCTRL(*this, "reset_translation", wxCheckBox)->GetValue();
159 };
160 
162 {
163  return XRCCTRL(*this, "reset_fov", wxCheckBox)->GetValue();
164 };
165 
167 {
168  return XRCCTRL(*this, "reset_lens", wxCheckBox)->GetValue();
169 };
170 
172 {
173  return XRCCTRL(*this, "reset_exposure", wxCheckBox)->GetValue();
174 };
175 
177 {
178  if(!GetResetExposure())
179  return false;
180  return XRCCTRL(*this, "combo_exposure", wxComboBox)->GetSelection()==0;
181 };
182 
184 {
185  return XRCCTRL(*this, "reset_color", wxCheckBox)->GetValue();
186 };
187 
189 {
190  if(!GetResetColor())
191  return false;
192  return XRCCTRL(*this, "combo_color", wxComboBox)->GetSelection()==0;
193 };
194 
196 {
197  return XRCCTRL(*this, "reset_vignetting", wxCheckBox)->GetValue();
198 };
199 
201 {
202  return XRCCTRL(*this, "reset_response", wxCheckBox)->GetValue();
203 };
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.
bool GetResetExposure()
Return TRUE, when user selected &quot;Reset exposure&quot;.
void LimitToPhotometric()
limits the displayed parameters to photometric parameters
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:641
bool GetResetColor()
Return TRUE, when user selected &quot;Reset color&quot;.
bool GetResetVignetting()
Return TRUE, when user selected &quot;Reset vignetting&quot;.
ResetDialog(wxWindow *parent, GuiLevel guiLevel)
Constructor, read from xrc ressource; restore last uses settings, size and position.
Definition: ResetDialog.cpp:33
void LimitToGeometric()
limits the displayed parameters to geometric parameters
Definition: ResetDialog.cpp:98
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;.