NonaOptionsDialog.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00028 #include <config.h>
00029 #include <errno.h>
00030 #include "panoinc_WX.h"
00031 
00032 #include "panoinc.h"
00033 
00034 #include "nona/Stitcher.h"
00035 
00036 #include "base_wx/wxPlatform.h"
00037 #include "hugin/config_defaults.h"
00038 #include "base_wx/CommandHistory.h"
00039 #include "base_wx/PanoCommand.h"
00040 #include "hugin/NonaOptionsDialog.h"
00041 
00042 using namespace HuginBase;
00043 using namespace std;
00044 using namespace hugin_utils;
00045 
00046 //-----------------------------------------------------------------------------
00047 
00048 BEGIN_EVENT_TABLE(NonaOptionsDialog, wxDialog)
00049     EVT_CHOICE ( XRCID("nona_choice_interpolator"),NonaOptionsDialog::InterpolatorChanged)
00050     EVT_CHECKBOX( XRCID("nona_cb_cropped"), NonaOptionsDialog::OnSaveCropped)
00051 END_EVENT_TABLE()
00052 
00053 
00054 // Define a constructor for the Pano Panel
00055 NonaOptionsDialog::NonaOptionsDialog(wxWindow *parent, Panorama & pano)
00056     : wxDialog(parent, 1, wxString(_("Nona options"))),
00057       pano(pano),
00058       updatesDisabled(false)
00059 {
00060 
00061     // loading xrc resources in selfcreated this panel
00062     wxXmlResource::Get()->LoadPanel ( this, wxT("nona_options_dialog"));
00063 
00064     // converts KILL_FOCUS events to usable TEXT_ENTER events
00065     // get gui controls
00066     m_InterpolatorChoice = XRCCTRL(*this, "nona_choice_interpolator",
00067                                    wxChoice);
00068     DEBUG_ASSERT(m_InterpolatorChoice);
00069 
00070     m_SaveCroppedCB = XRCCTRL(*this, "nona_cb_cropped", wxCheckBox);
00071     DEBUG_ASSERT(m_SaveCroppedCB);
00072 
00073     UpdateDisplay(pano.getOptions());
00074 
00075     // observe the panorama
00076     pano.addObserver (this);
00077 
00078     Fit();
00079     wxSize sz = GetSize();
00080     SetSizeHints(sz.GetWidth(), sz.GetHeight());
00081 
00082     DEBUG_DEBUG("setting minsize to:" << sz.GetWidth() << "x" << sz.GetHeight());
00083 }
00084 
00085 
00086 NonaOptionsDialog::~NonaOptionsDialog(void)
00087 {
00088     DEBUG_TRACE("dtor");
00089     pano.removeObserver(this);
00090     DEBUG_TRACE("dtor end");
00091 }
00092 
00093 
00094 void NonaOptionsDialog::panoramaChanged (HuginBase::Panorama &pano)
00095 {
00096         DEBUG_TRACE("");
00097     HuginBase::PanoramaOptions opt = pano.getOptions();
00098     // update all options for dialog and notebook tab
00099     UpdateDisplay(opt);
00100     m_oldOpt = opt;
00101 }
00102 
00103 void NonaOptionsDialog::UpdateDisplay(const HuginBase::PanoramaOptions & opt)
00104 {
00105     m_InterpolatorChoice->SetSelection(opt.interpolator);
00106     m_SaveCroppedCB->SetValue(opt.tiff_saveROI);
00107 }
00108 
00109 
00110 void NonaOptionsDialog::InterpolatorChanged ( wxCommandEvent & e )
00111 {
00112     if (updatesDisabled) return;
00113     HuginBase::PanoramaOptions opt = pano.getOptions();
00114     //Interpolator from PanoramaMemento.h
00115     int lt = m_InterpolatorChoice->GetSelection();
00116 
00117     opt.interpolator = (vigra_ext::Interpolator) lt;
00118     PanoCommand::GlobalCmdHist::getInstance().addCommand(
00119         new PanoCommand::SetPanoOptionsCmd( pano, opt )
00120         );
00121     DEBUG_DEBUG ("Interpolator changed to: " << lt );
00122 }
00123 
00124 void NonaOptionsDialog::OnSaveCropped(wxCommandEvent & e)
00125 {
00126     HuginBase::PanoramaOptions opt = pano.getOptions();
00127 
00128     opt.tiff_saveROI= m_SaveCroppedCB->GetValue();
00129 
00130     PanoCommand::GlobalCmdHist::getInstance().addCommand(
00131             new PanoCommand::SetPanoOptionsCmd( pano, opt )
00132                                            );
00133 }

Generated on 30 Jul 2015 for Hugintrunk by  doxygen 1.4.7