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, write to the Free Software
00023  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 END_EVENT_TABLE()
00037 
00038 ResetDialog::ResetDialog(wxWindow *parent, GuiLevel guiLevel)
00039 {
00040     // load our children. some children might need special
00041     // initialization. this will be done later.
00042     wxXmlResource::Get()->LoadDialog(this, parent, wxT("reset_dialog"));
00043 
00044 #ifdef __WXMSW__
00045     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
00046 #else
00047     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
00048 #endif
00049     SetIcon(myIcon);
00050     //set parameters
00051     wxConfigBase * cfg = wxConfigBase::Get();
00052     bool check;
00053     cfg->Read(wxT("/ResetDialog/ResetPosition"),&check,true);
00054     XRCCTRL(*this,"reset_pos",wxCheckBox)->SetValue(check);
00055     cfg->Read(wxT("/ResetDialog/ResetTranslation"), &check, true);
00056     wxCheckBox* reset_translation=XRCCTRL(*this,"reset_translation",wxCheckBox);
00057     reset_translation->SetValue(check);
00058     if(guiLevel<GUI_EXPERT)
00059     {
00060         reset_translation->Hide();
00061     };
00062     cfg->Read(wxT("/ResetDialog/ResetFOV"),&check,true);
00063     XRCCTRL(*this,"reset_fov",wxCheckBox)->SetValue(check);
00064     cfg->Read(wxT("/ResetDialog/ResetLens"),&check,true);
00065     XRCCTRL(*this,"reset_lens",wxCheckBox)->SetValue(check);
00066     cfg->Read(wxT("/ResetDialog/ResetExposure"),&check,true);
00067     XRCCTRL(*this,"reset_exposure",wxCheckBox)->SetValue(check);
00068     int exp_param;
00069     cfg->Read(wxT("/ResetDialog/ResetExposureParam"),&exp_param,0);
00070     XRCCTRL(*this,"combo_exposure",wxComboBox)->Select(exp_param);
00071     wxCommandEvent dummy;
00072     OnSelectExposure(dummy);
00073     cfg->Read(wxT("/ResetDialog/ResetColor"),&check,true);
00074     XRCCTRL(*this,"reset_color",wxCheckBox)->SetValue(check);
00075     cfg->Read(wxT("/ResetDialog/ResetVignetting"),&check,true);
00076     XRCCTRL(*this,"reset_vignetting",wxCheckBox)->SetValue(check);
00077     cfg->Read(wxT("/ResetDialog/ResetResponse"),&check,true);
00078     XRCCTRL(*this,"reset_response",wxCheckBox)->SetValue(check);
00079     GetSizer()->Fit(this);
00080     //position
00081     int x = cfg->Read(wxT("/ResetDialog/positionX"),-1l);
00082     int y = cfg->Read(wxT("/ResetDialog/positionY"),-1l);
00083     if ( y >= 0 && x >= 0) 
00084     {
00085         this->Move(x, y);
00086     } 
00087     else 
00088     {
00089         this->Move(0, 44);
00090     };
00091 };
00092 
00093 void ResetDialog::LimitToGeometric()
00094 {
00095     XRCCTRL(*this,"reset_exposure",wxCheckBox)->Show(false);
00096     XRCCTRL(*this,"combo_exposure",wxComboBox)->Show(false);
00097     XRCCTRL(*this,"reset_color",wxCheckBox)->Show(false);
00098     XRCCTRL(*this,"reset_vignetting",wxCheckBox)->Show(false);
00099     XRCCTRL(*this,"reset_response",wxCheckBox)->Show(false);
00100     GetSizer()->Fit(this);
00101 };
00102 
00103 void ResetDialog::LimitToPhotometric()
00104 {
00105     XRCCTRL(*this,"reset_pos",wxCheckBox)->Show(false);
00106     XRCCTRL(*this,"reset_translation",wxCheckBox)->Show(false);
00107     XRCCTRL(*this,"reset_fov",wxCheckBox)->Show(false);
00108     XRCCTRL(*this,"reset_lens",wxCheckBox)->Show(false);
00109     GetSizer()->Fit(this);
00110 };
00111 
00112 void ResetDialog::OnOk(wxCommandEvent & e)
00113 {
00114     wxConfigBase * cfg = wxConfigBase::Get();
00115     wxPoint ps = this->GetPosition();
00116     cfg->Write(wxT("/ResetDialog/positionX"), ps.x);
00117     cfg->Write(wxT("/ResetDialog/positionY"), ps.y);
00118     cfg->Write(wxT("/ResetDialog/ResetPosition"),GetResetPos());
00119     cfg->Write(wxT("/ResetDialog/ResetTranslation"), GetResetTranslation());
00120     cfg->Write(wxT("/ResetDialog/ResetFOV"),GetResetFOV());
00121     cfg->Write(wxT("/ResetDialog/ResetLens"),GetResetLens());
00122     cfg->Write(wxT("/ResetDialog/ResetExposure"),GetResetExposure());
00123     int exp_param;
00124     exp_param=XRCCTRL(*this,"combo_exposure",wxComboBox)->GetSelection();
00125     cfg->Write(wxT("/ResetDialog/ResetExposureParam"),exp_param);
00126     cfg->Write(wxT("/ResetDialog/ResetColor"),GetResetColor());
00127     cfg->Write(wxT("/ResetDialog/ResetVignetting"),GetResetVignetting());
00128     cfg->Write(wxT("/ResetDialog/ResetResponse"),GetResetResponse());
00129     cfg->Flush();
00130     e.Skip();
00131 };
00132 
00133 void ResetDialog::OnSelectExposure(wxCommandEvent & e)
00134 {
00135     if(XRCCTRL(*this, "reset_exposure", wxCheckBox)->GetValue())
00136         XRCCTRL(*this,"combo_exposure",wxComboBox)->Enable();
00137     else
00138         XRCCTRL(*this,"combo_exposure",wxComboBox)->Disable();
00139 };
00140 
00141 bool ResetDialog::GetResetPos()
00142 {
00143     return XRCCTRL(*this, "reset_pos", wxCheckBox)->GetValue();
00144 };
00145 
00146 bool ResetDialog::GetResetTranslation()
00147 {
00148     return XRCCTRL(*this, "reset_translation", wxCheckBox)->GetValue();
00149 };
00150 
00151 bool ResetDialog::GetResetFOV()
00152 {
00153     return XRCCTRL(*this, "reset_fov", wxCheckBox)->GetValue();
00154 };
00155 
00156 bool ResetDialog::GetResetLens()
00157 {
00158     return XRCCTRL(*this, "reset_lens", wxCheckBox)->GetValue();
00159 };
00160 
00161 bool ResetDialog::GetResetExposure()
00162 {
00163     return XRCCTRL(*this, "reset_exposure", wxCheckBox)->GetValue();
00164 };
00165 
00166 bool ResetDialog::GetResetExposureToExif()
00167 {
00168     if(!GetResetExposure())
00169         return false;
00170     return XRCCTRL(*this, "combo_exposure", wxComboBox)->GetSelection()==0;
00171 };
00172 
00173 bool ResetDialog::GetResetColor()
00174 {
00175     return XRCCTRL(*this, "reset_color", wxCheckBox)->GetValue();
00176 };
00177 
00178 bool ResetDialog::GetResetVignetting()
00179 {
00180     return XRCCTRL(*this, "reset_vignetting", wxCheckBox)->GetValue();
00181 };
00182 
00183 bool ResetDialog::GetResetResponse()
00184 {
00185     return XRCCTRL(*this, "reset_response", wxCheckBox)->GetValue();
00186 };

Generated on Sat Jul 26 01:25:37 2014 for Hugintrunk by  doxygen 1.3.9.1