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

Generated on Sun Apr 20 01:25:35 2014 for Hugintrunk by  doxygen 1.3.9.1