27 #include "hugin_config.h" 
   50 #include <pano13/queryfeature.h> 
   74 #define PF_STYLE (wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN) 
   77     : wxFrame(frame,-1, _(
"Panorama preview"), wxDefaultPosition, wxDefaultSize,
 
   84     m_ToolBar = wxXmlResource::Get()->LoadToolBar(
this, 
"preview_toolbar");
 
   92         new wxStaticBox(
this, -1, _(
"displayed images")),
 
   95         m_ButtonPanel = 
new wxScrolledWindow(
this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
 
  108     wxFlexGridSizer * flexSizer = 
new wxFlexGridSizer(2,0,5,5);
 
  109     flexSizer->AddGrowableCol(0);
 
  110     flexSizer->AddGrowableRow(0);
 
  126                                 wxDefaultPosition, wxDefaultSize,
 
  127                                 wxSL_VERTICAL | wxSL_AUTOTICKS,
 
  133     m_VFOVSlider->SetToolTip(_(
"drag to change the vertical field of view"));
 
  139                                 wxDefaultPosition, wxDefaultSize,
 
  140                                 wxSL_HORIZONTAL | wxSL_AUTOTICKS,
 
  147     m_HFOVSlider->SetToolTip(_(
"drag to change the horizontal field of view"));
 
  157     wxStaticBoxSizer * blendModeSizer = 
new wxStaticBoxSizer(
 
  158         new wxStaticBox(
this, -1, _(
"Preview Options")),
 
  161     blendModeSizer->Add(
new wxStaticText(
this, -1, _(
"projection (f):")),
 
  163                         wxALL | wxALIGN_CENTER_VERTICAL, 
 
  166                                       wxDefaultPosition, wxDefaultSize);
 
  170     int nP = panoProjectionFormatCount();
 
  171     for(
int n=0; n < nP; n++) {
 
  172         pano_projection_features proj;
 
  173         if (panoProjectionFeaturesQuery(n, &proj)) {
 
  174             wxString str2(proj.name, wxConvLocal);
 
  182                         wxALL | wxALIGN_CENTER_VERTICAL,
 
  187     blendModeSizer->Add(
new wxStaticText(
this, -1, _(
"Blend mode:")),
 
  189                         wxALL | wxALIGN_CENTER_VERTICAL, 
 
  195     int oldMode = wxConfigBase::Get()->Read(
"/PreviewFrame/blendMode", 0l);
 
  196     if (oldMode > 1) oldMode = 0;
 
  198                                      wxDefaultPosition, wxDefaultSize,
 
  205                         wxALL | wxALIGN_CENTER_VERTICAL,
 
  210     blendModeSizer->Add(
new wxStaticText(
this, -1, _(
"Output:")),
 
  212                         wxALL | wxALIGN_CENTER_VERTICAL, 
 
  218                                       wxDefaultPosition, wxDefaultSize,
 
  224                         wxALL | wxALIGN_CENTER_VERTICAL,
 
  229     blendModeSizer->Add(
new wxStaticText(
this, -1, _(
"EV:")),
 
  231                           wxALL | wxALIGN_CENTER_VERTICAL, 
 
  235                                               wxArtProvider::GetBitmap(wxART_REDO));
 
  245                                         wxDefaultPosition,wxSize(50,-1), wxTE_PROCESS_ENTER);
 
  249                           wxLEFT | wxTOP | wxBOTTOM  | wxALIGN_CENTER_VERTICAL, 
 
  254                                          wxDefaultSize, wxSP_VERTICAL);
 
  262     blendModeSizer->Add(
new wxStaticText(
this, wxID_ANY, _(
"Range compression:")), 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
 
  264         wxDefaultPosition, wxSize(30, -1), wxTE_PROCESS_ENTER);
 
  275     m_topsizer->Add(blendModeSizer, 0, wxEXPAND | wxALL, 5);
 
  278     new wxStaticBox(
this, -1, _(
"Projection Parameters")),
 
  282         wxArtProvider::GetBitmap(wxART_REDO));
 
  283     resetProjButton->SetToolTip(_(
"Resets the projection's parameters to their default values."));
 
  285     m_projParamSizer->Add(resetProjButton, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
 
  291     for (
int i=0; i < PANO_PROJECTION_MAX_PARMS; i++) {
 
  296                         wxALL | wxALIGN_CENTER_VERTICAL, 
 
  299                                     wxDefaultPosition, wxSize(35,-1), wxTE_PROCESS_ENTER);
 
  304                         wxALL | wxALIGN_CENTER_VERTICAL, 
 
  310                         wxALL | wxALIGN_CENTER_VERTICAL, 
 
  319     wxConfigBase * config = wxConfigBase::Get();
 
  323     int widths[3] = {-3, 150, 150};
 
  324     SetStatusWidths(3, widths);
 
  325     SetStatusText(_(
"Left click to define new center point, right click to move point to horizon."),0);
 
  326     SetStatusText(wxEmptyString,1);
 
  327     SetStatusText(wxEmptyString,2);
 
  335     wxIconBundle myIcons(
huginApp::Get()->GetXRCPath() + 
"data/hugin.ico",wxBITMAP_TYPE_ICO);
 
  338     wxIcon myIcon(
huginApp::Get()->GetXRCPath() + 
"data/hugin.png",wxBITMAP_TYPE_PNG);
 
  348     long aup = config->Read(
"/PreviewFrame/autoUpdate",0l);
 
  351     m_ToolBar->ToggleTool(XRCID(
"preview_auto_update_tool"), aup !=0);
 
  358     if (config->Read(
"/PreviewFrame/isShown", 0l) != 0) {
 
  361     SetStatusText(_(
"Center panorama with left mouse button, set horizon with right button"),0);
 
  362     wxAcceleratorEntry entries[3];
 
  368     entries[1].Set(wxACCEL_CMD,(
int)
'Z',
ID_UNDO);
 
  369     entries[2].Set(wxACCEL_CMD,(
int)
'R',
ID_REDO);
 
  370     wxAcceleratorTable accel(3, entries);
 
  371     SetAcceleratorTable(accel);
 
  395     wxConfigBase * config = wxConfigBase::Get();
 
  399     if ( (!this->IsIconized()) && (! this->IsMaximized()) && this->IsShown()) {
 
  400         config->Write(
"/PreviewFrame/isShown", 1l);
 
  402         config->Write(
"/PreviewFrame/isShown", 0l);
 
  405     bool checked = 
m_ToolBar->GetToolState(XRCID(
"preview_auto_update_tool"));
 
  406     config->Write(
"/PreviewFrame/autoUpdate", checked ? 1l: 0l);
 
  408     for (
int i=0; i < PANO_PROJECTION_MAX_PARMS; i++)
 
  422     if (
id >= 0 && 
id < nImg) {
 
  424             activeImages.insert(
id);
 
  426             activeImages.erase(
id);
 
  465     m_ToolBar->EnableTool(XRCID(
"preview_center_tool"), activeImgs);
 
  466     m_ToolBar->EnableTool(XRCID(
"preview_fit_pano_tool"), activeImgs);
 
  467     m_ToolBar->EnableTool(XRCID(
"preview_update_tool"), activeImgs);
 
  468     m_ToolBar->EnableTool(XRCID(
"preview_num_transform"), activeImgs);
 
  473     bool relayout = 
false;
 
  481             for (i=0; i < nParam; i++) {
 
  482                 const pano_projection_parameter * pp = & (opts.
m_projFeatures.parm[i]);
 
  483                 wxString str2(pp->name, wxConvLocal);
 
  484                 str2 = wxGetTranslation(str2);
 
  488             for(;i < PANO_PROJECTION_MAX_PARMS; i++) {
 
  502         assert((
int) params.size() == nParam);
 
  503         for (
int i=0; i < nParam; i++) {
 
  513     SetStatusText(_(
"Center panorama with left mouse button, set horizon with right button"),0);
 
  514     SetStatusText(wxString::Format(
"%.1f x %.1f", opts.
getHFOV(), opts.
getVFOV()),2);
 
  534     for (
int i=nrButtons-1; i>=(int)nrImages; i--)
 
  543     if ( nrImages >= nrButtons ) {
 
  544         for(HuginBase::UIntSet::const_iterator it = changed.begin(); it != changed.end(); ++it){
 
  545             if (*it >= nrButtons) {
 
  550                                                           wxString::Format(
" %d ",*it),
 
  551                                                           wxDefaultPosition, wxDefaultSize,
 
  567     for (
unsigned i=0; i < nrImages; i++) {
 
  587     if (event.CanVeto()) {
 
  607 void PreviewFrame::OnProjectionChanged()
 
  613     case PanoramaOptions::RECTILINEAR:       Ip = _(
"Rectilinear"); 
break;
 
  614     case PanoramaOptions::CYLINDRICAL:       Ip = _(
"Cylindrical"); 
break;
 
  615     case PanoramaOptions::EQUIRECTANGULAR:   Ip = _(
"Equirectangular"); 
break;
 
  617     opt.projectionFormat = (PanoramaOptions::ProjectionFormat) lt;
 
  621     DEBUG_DEBUG (
"Projection changed: "  << lt << 
":" << Ip )
 
  652     if (
m_ToolBar->GetToolState(XRCID(
"preview_auto_update_tool"))) {
 
  683         displayedImgs.insert(i);
 
  711     wxXmlResource::Get()->LoadDialog(&dlg, 
this, 
"dlg_numtrans");
 
  712     dlg.CentreOnParent();
 
  713     if (dlg.ShowModal() == wxID_OK ) {
 
  714         wxString text = XRCCTRL(dlg, 
"numtrans_yaw", wxTextCtrl)->GetValue();
 
  717             wxLogError(_(
"Yaw value must be numeric."));
 
  720         text = XRCCTRL(dlg, 
"numtrans_pitch", wxTextCtrl)->GetValue();
 
  723             wxLogError(_(
"Pitch value must be numeric."));
 
  726         text = XRCCTRL(dlg, 
"numtrans_roll", wxTextCtrl)->GetValue();
 
  729             wxLogError(_(
"Roll value must be numeric."));
 
  751             wxLogError(_(
"Value must be numeric."));
 
  772         wxLogError(_(
"Value must be numeric."));
 
  777         wxLogError(_(
"Value for range compression is outside of valid range."));
 
  795     for (
int i = 0; i < nParam; i++)
 
  800             DEBUG_INFO(
"param " << i << 
":  = " << text.mb_str(wxConvLocal));
 
  806                     wxLogError(_(
"Value must be numeric."));
 
  838         DEBUG_DEBUG(
"VFOV changed (slider): " << e.GetInt());
 
  843         for (
int i = 0; i < nParam; i++) {
 
  846                 para[i] = e.GetInt();
 
  862         int sel = e.GetSelection();
 
  874         DEBUG_WARN(
"wxChoice event from unknown object received");
 
  945         DEBUG_WARN(
"wxChoice event from unknown object received");
 
  962         DEBUG_WARN(
"wxChoice event from unknown object received");
 
  972         msg = wxGetTranslation(wxString(
m_message.c_str(), wxConvLocal));
 
  979     GetStatusBar()->SetStatusText(msg, 0);
 
  988     ShowFullScreen(!IsFullScreen(), wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION);
 
  991     GetToolBar()->Show(
true);
 
 1000         wxCommandEvent dummy(wxEVT_COMMAND_MENU_SELECTED, XRCID(
"ID_EDITUNDO"));
 
 1001         m_parent->GetEventHandler()->AddPendingEvent(dummy);
 
 1013         wxCommandEvent dummy(wxEVT_COMMAND_MENU_SELECTED, XRCID(
"ID_EDITREDO"));
 
 1014         m_parent->GetEventHandler()->AddPendingEvent(dummy);
 
void OnShowAll(wxCommandEvent &e)
HuginBase::Panorama & m_pano
PanoramaOptions::ProjectionFormat getProjection() const 
void OnUpdate(wxCommandEvent &event)
double outputRangeCompression
void setHeight(unsigned int h)
set panorama height 
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
pano_projection_features m_projFeatures
static double calcMeanExposure(const PanoramaData &pano)
bool str2double(const wxString &s, double &d)
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename, const bool ignoreMaximize)
void OnBlendChoice(wxCommandEvent &e)
center panorama horizontically 
void OnNumTransform(wxCommandEvent &e)
void OnTextCtrlChanged(wxCommandEvent &e)
std::vector< wxStaticText * > m_projParamNamesLabel
bool fovCalcSupported(ProjectionFormat f) const 
true, if FOV calcuations are supported for projection f 
bool removeObserver(PanoramaObserver *observer)
remove a panorama observer. 
virtual ~PreviewFrame()
dtor. 
wxSpinButton * m_exposureSpinBut
unsigned int getHeight() const 
get panorama height 
std::vector< wxSlider * > m_projParamSlider
wxChoice * m_ProjectionChoice
bool set_contains(const _Container &c, const typename _Container::key_type &key)
#define DEBUG_ASSERT(cond)
void setProjectionParameters(const std::vector< double > ¶ms)
set the optional parameters (they need to be of the correct size) 
include file for the hugin project 
virtual void run()
runs the algorithm. 
void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &changed)
notifies about changes to images 
void OnRangeCompressionTextChanged(wxCommandEvent &e)
std::string doubleToString(double d, int digits)
convert a double to a string, suitable for display within a GUI. 
static huginApp * Get()
hack.. kind of a pseudo singleton... 
std::set< unsigned int > UIntSet
void OnCenterHorizontally(wxCommandEvent &e)
void OnIncreaseExposure(wxSpinEvent &e)
void Init(PreviewFrame *parent, HuginBase::Panorama *pano)
void OnUndo(wxCommandEvent &e)
event handler for undo 
void resetProjectionParameters()
sets the optional parameters to their default values 
std::size_t getNrOfImages() const 
number of images. 
void SetAutoUpdate(bool enabled)
void OnRedo(wxCommandEvent &e)
event handler for redo 
virtual double getResultHeight()
void OnExposureTextChanged(wxCommandEvent &e)
void OnProjectionChoice(wxCommandEvent &e)
void SetBlendMode(BlendMode b)
void OnShowNone(wxCommandEvent &e)
wxBitmapButton * m_defaultExposureBut
std::vector< wxToggleButton * > m_ToggleButtons
static GlobalCmdHist & getInstance()
std::vector< wxTextCtrl * > m_projParamTextCtrl
void OnChangeFOV(wxScrollEvent &e)
wxBoxSizer * m_ButtonSizer
void addCommand(PanoCommand *command, bool execute=true)
Adds a command to the history. 
wxScrolledWindow * m_ButtonPanel
void panoramaChanged(HuginBase::Panorama &pano)
Notification about a Panorama change. 
straighten panorama horizontically 
UIntSet getActiveImages() const 
get active images 
void OnStraighten(wxCommandEvent &e)
void setHFOV(double h, bool keepView=true)
set the horizontal field of view. 
void addObserver(PanoramaObserver *o)
add a panorama observer. 
include file for the hugin project 
const PanoramaOptions & getOptions() const 
returns the options for this panorama 
Handle EVT_KILL_FOCUS and convert it to a EVT_TEXT_ENTER event. 
virtual double getResultHorizontalFOV()
void OnClose(wxCloseEvent &e)
PreviewFrame(wxFrame *frame, HuginBase::Panorama &pano)
ctor. 
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name="panel")
void OnChangeDisplayedImgs(wxCommandEvent &e)
const std::vector< double > & getProjectionParameters() const 
Get the optional projection parameters. 
wxSpinButton * m_rangeCompressionSpinBut
void OnFitPano(wxCommandEvent &e)
void OnProjParameterReset(wxCommandEvent &e)
event handler for reset projection parameters 
void OnOutputChoice(wxCommandEvent &e)
const SrcPanoImage & getImage(std::size_t nr) const 
get a panorama image, counting starts with 0 
wxStaticBoxSizer * m_projParamSizer
void OnRangeCompressionIncrease(wxSpinEvent &e)
void OnRangeCompressionDecrease(wxSpinEvent &e)
A preview panel that renders the pictures using the panotools library. 
void OnDefaultExposure(wxCommandEvent &e)
PreviewPanel * m_PreviewPanel
ProjectionFormat
Projection of final panorama. 
wxTextCtrl * m_exposureTextCtrl
void setProjection(ProjectionFormat f)
set the Projection format and adjust the hfov/vfov if nessecary 
wxStaticBoxSizer * m_ToggleButtonSizer
void OnAutoPreviewToggle(wxCommandEvent &e)
wxTextCtrl * m_rangeCompressionTextCtrl
void updateProgressDisplay()
update the display 
void OnDecreaseExposure(wxSpinEvent &e)
wxChoice * m_BlendModeChoice
void OnFullScreen(wxCommandEvent &e)
event handler for full screen 
wxChoice * m_outputModeChoice
double outputExposureValue