ResetDialog.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00011 /*  This is free software; you can redistribute it and/or
00012  *  modify it under the terms of the GNU General Public
00013  *  License as published by the Free Software Foundation; either
00014  *  version 2 of the License, or (at your option) any later version.
00015  *
00016  *  This software is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *  Lesser General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public
00022  *  License along with this software. If not, see
00023  *  <http://www.gnu.org/licenses/>.
00024  *
00025  */
00026 
00027 #include "hugin/ResetDialog.h"
00028 #include "base_wx/wxPlatform.h"
00029 #include "panoinc.h"
00030 
00031 #include "hugin/huginApp.h"
00032 
00033 BEGIN_EVENT_TABLE(ResetDialog,wxDialog)
00034     EVT_BUTTON(wxID_OK, ResetDialog::OnOk)
00035     EVT_CHECKBOX(XRCID("reset_exposure"), ResetDialog::OnSelectExposure)
00036     EVT_CHECKBOX(XRCID("reset_color"), ResetDialog::OnSelectColor)
00037 END_EVENT_TABLE()
00038 
00039 ResetDialog::ResetDialog(wxWindow *parent, GuiLevel guiLevel)
00040 {
00041     // load our children. some children might need special
00042     // initialization. this will be done later.
00043     wxXmlResource::Get()->LoadDialog(this, parent, wxT("reset_dialog"));
00044 
00045 #ifdef __WXMSW__
00046     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
00047 #else
00048     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
00049 #endif
00050     SetIcon(myIcon);
00051     //set parameters
00052     wxConfigBase * cfg = wxConfigBase::Get();
00053     bool check;
00054     cfg->Read(wxT("/ResetDialog/ResetPosition"),&check,true);
00055     XRCCTRL(*this,"reset_pos",wxCheckBox)->SetValue(check);
00056     cfg->Read(wxT("/ResetDialog/ResetTranslation"), &check, true);
00057     wxCheckBox* reset_translation=XRCCTRL(*this,"reset_translation",wxCheckBox);
00058     reset_translation->SetValue(check);
00059     if(guiLevel<GUI_EXPERT)
00060     {
00061         reset_translation->Hide();
00062     };
00063     cfg->Read(wxT("/ResetDialog/ResetFOV"),&check,true);
00064     XRCCTRL(*this,"reset_fov",wxCheckBox)->SetValue(check);
00065     cfg->Read(wxT("/ResetDialog/ResetLens"),&check,true);
00066     XRCCTRL(*this,"reset_lens",wxCheckBox)->SetValue(check);
00067     cfg->Read(wxT("/ResetDialog/ResetExposure"),&check,true);
00068     XRCCTRL(*this,"reset_exposure",wxCheckBox)->SetValue(check);
00069     int exp_param;
00070     cfg->Read(wxT("/ResetDialog/ResetExposureParam"),&exp_param,0);
00071     XRCCTRL(*this,"combo_exposure",wxComboBox)->Select(exp_param);
00072     wxCommandEvent dummy;
00073     OnSelectExposure(dummy);
00074     cfg->Read(wxT("/ResetDialog/ResetColor"),&check,true);
00075     XRCCTRL(*this,"reset_color",wxCheckBox)->SetValue(check);
00076     cfg->Read(wxT("/ResetDialog/ResetColorParam"),&exp_param,0);
00077     OnSelectColor(dummy);
00078     XRCCTRL(*this,"combo_color",wxComboBox)->Select(exp_param);
00079     cfg->Read(wxT("/ResetDialog/ResetVignetting"),&check,true);
00080     XRCCTRL(*this,"reset_vignetting",wxCheckBox)->SetValue(check);
00081     cfg->Read(wxT("/ResetDialog/ResetResponse"),&check,true);
00082     XRCCTRL(*this,"reset_response",wxCheckBox)->SetValue(check);
00083     GetSizer()->Fit(this);
00084     //position
00085     int x = cfg->Read(wxT("/ResetDialog/positionX"),-1l);
00086     int y = cfg->Read(wxT("/ResetDialog/positionY"),-1l);
00087     if ( y >= 0 && x >= 0) 
00088     {
00089         this->Move(x, y);
00090     } 
00091     else 
00092     {
00093         this->Move(0, 44);
00094     };
00095 };
00096 
00097 void ResetDialog::LimitToGeometric()
00098 {
00099     XRCCTRL(*this,"reset_exposure",wxCheckBox)->Show(false);
00100     XRCCTRL(*this,"combo_exposure",wxComboBox)->Show(false);
00101     XRCCTRL(*this,"reset_color",wxCheckBox)->Show(false);
00102     XRCCTRL(*this,"combo_color",wxComboBox)->Show(false);
00103     XRCCTRL(*this,"reset_vignetting",wxCheckBox)->Show(false);
00104     XRCCTRL(*this,"reset_response",wxCheckBox)->Show(false);
00105     GetSizer()->Fit(this);
00106 };
00107 
00108 void ResetDialog::LimitToPhotometric()
00109 {
00110     XRCCTRL(*this,"reset_pos",wxCheckBox)->Show(false);
00111     XRCCTRL(*this,"reset_translation",wxCheckBox)->Show(false);
00112     XRCCTRL(*this,"reset_fov",wxCheckBox)->Show(false);
00113     XRCCTRL(*this,"reset_lens",wxCheckBox)->Show(false);
00114     GetSizer()->Fit(this);
00115 };
00116 
00117 void ResetDialog::OnOk(wxCommandEvent & e)
00118 {
00119     wxConfigBase * cfg = wxConfigBase::Get();
00120     wxPoint ps = this->GetPosition();
00121     cfg->Write(wxT("/ResetDialog/positionX"), ps.x);
00122     cfg->Write(wxT("/ResetDialog/positionY"), ps.y);
00123     cfg->Write(wxT("/ResetDialog/ResetPosition"),GetResetPos());
00124     cfg->Write(wxT("/ResetDialog/ResetTranslation"), GetResetTranslation());
00125     cfg->Write(wxT("/ResetDialog/ResetFOV"),GetResetFOV());
00126     cfg->Write(wxT("/ResetDialog/ResetLens"),GetResetLens());
00127     cfg->Write(wxT("/ResetDialog/ResetExposure"),GetResetExposure());
00128     int exp_param;
00129     exp_param=XRCCTRL(*this,"combo_exposure",wxComboBox)->GetSelection();
00130     cfg->Write(wxT("/ResetDialog/ResetExposureParam"),exp_param);
00131     cfg->Write(wxT("/ResetDialog/ResetColor"),GetResetColor());
00132     exp_param=XRCCTRL(*this,"combo_color",wxComboBox)->GetSelection();
00133     cfg->Write(wxT("/ResetDialog/ResetColorParam"), exp_param);
00134     cfg->Write(wxT("/ResetDialog/ResetVignetting"),GetResetVignetting());
00135     cfg->Write(wxT("/ResetDialog/ResetResponse"),GetResetResponse());
00136     cfg->Flush();
00137     e.Skip();
00138 };
00139 
00140 void ResetDialog::OnSelectExposure(wxCommandEvent & e)
00141 {
00142     XRCCTRL(*this,"combo_exposure",wxComboBox)->Enable(XRCCTRL(*this, "reset_exposure", wxCheckBox)->GetValue());
00143 };
00144 
00145 void ResetDialog::OnSelectColor(wxCommandEvent & e)
00146 {
00147     XRCCTRL(*this,"combo_color",wxComboBox)->Enable(XRCCTRL(*this, "reset_color", wxCheckBox)->GetValue());
00148 };
00149 
00150 bool ResetDialog::GetResetPos()
00151 {
00152     return XRCCTRL(*this, "reset_pos", wxCheckBox)->GetValue();
00153 };
00154 
00155 bool ResetDialog::GetResetTranslation()
00156 {
00157     return XRCCTRL(*this, "reset_translation", wxCheckBox)->GetValue();
00158 };
00159 
00160 bool ResetDialog::GetResetFOV()
00161 {
00162     return XRCCTRL(*this, "reset_fov", wxCheckBox)->GetValue();
00163 };
00164 
00165 bool ResetDialog::GetResetLens()
00166 {
00167     return XRCCTRL(*this, "reset_lens", wxCheckBox)->GetValue();
00168 };
00169 
00170 bool ResetDialog::GetResetExposure()
00171 {
00172     return XRCCTRL(*this, "reset_exposure", wxCheckBox)->GetValue();
00173 };
00174 
00175 bool ResetDialog::GetResetExposureToExif()
00176 {
00177     if(!GetResetExposure())
00178         return false;
00179     return XRCCTRL(*this, "combo_exposure", wxComboBox)->GetSelection()==0;
00180 };
00181 
00182 bool ResetDialog::GetResetColor()
00183 {
00184     return XRCCTRL(*this, "reset_color", wxCheckBox)->GetValue();
00185 };
00186 
00187 bool ResetDialog::GetResetColorToExif()
00188 {
00189     if(!GetResetColor())
00190         return false;
00191     return XRCCTRL(*this, "combo_color", wxComboBox)->GetSelection()==0;
00192 };
00193 
00194 bool ResetDialog::GetResetVignetting()
00195 {
00196     return XRCCTRL(*this, "reset_vignetting", wxCheckBox)->GetValue();
00197 };
00198 
00199 bool ResetDialog::GetResetResponse()
00200 {
00201     return XRCCTRL(*this, "reset_response", wxCheckBox)->GetValue();
00202 };

Generated on 3 Sep 2015 for Hugintrunk by  doxygen 1.4.7