27 #include "hugin_config.h"
49 #include <pano13/queryfeature.h>
76 EVT_TOOL(XRCID("preview_center_tool"),
PreviewFrame::OnCenterHorizontally)
77 EVT_TOOL(XRCID("preview_fit_pano_tool"),
PreviewFrame::OnFitPano)
78 EVT_TOOL(XRCID("preview_straighten_pano_tool"),
PreviewFrame::OnStraighten)
79 EVT_TOOL(XRCID("preview_auto_update_tool"),
PreviewFrame::OnAutoPreviewToggle)
80 EVT_TOOL(XRCID("preview_update_tool"),
PreviewFrame::OnUpdate)
81 EVT_TOOL(XRCID("preview_show_all_tool"),
PreviewFrame::OnShowAll)
82 EVT_TOOL(XRCID("preview_show_none_tool"),
PreviewFrame::OnShowNone)
83 EVT_TOOL(XRCID("preview_num_transform"),
PreviewFrame::OnNumTransform)
88 EVT_SPIN_UP(ID_EXPOSURE_SPIN,
PreviewFrame::OnIncreaseExposure)
90 EVT_SPIN_UP(ID_RANGE_COMPRESSION_SPIN,
PreviewFrame::OnRangeCompressionIncrease)
94 EVT_TOGGLEBUTTON(-1,
PreviewFrame::OnChangeDisplayedImgs)
102 #define PF_STYLE (wxMAXIMIZE_BOX | wxMINIMIZE_BOX | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
105 : wxFrame(frame,-1, _(
"Panorama preview"), wxDefaultPosition, wxDefaultSize,
112 m_ToolBar = wxXmlResource::Get()->LoadToolBar(
this, wxT(
"preview_toolbar"));
120 new wxStaticBox(
this, -1, _(
"displayed images")),
123 m_ButtonPanel =
new wxScrolledWindow(
this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
136 wxFlexGridSizer * flexSizer =
new wxFlexGridSizer(2,0,5,5);
137 flexSizer->AddGrowableCol(0);
138 flexSizer->AddGrowableRow(0);
154 wxDefaultPosition, wxDefaultSize,
155 wxSL_VERTICAL | wxSL_AUTOTICKS,
161 m_VFOVSlider->SetToolTip(_(
"drag to change the vertical field of view"));
167 wxDefaultPosition, wxDefaultSize,
168 wxSL_HORIZONTAL | wxSL_AUTOTICKS,
175 m_HFOVSlider->SetToolTip(_(
"drag to change the horizontal field of view"));
185 wxStaticBoxSizer * blendModeSizer =
new wxStaticBoxSizer(
186 new wxStaticBox(
this, -1, _(
"Preview Options")),
189 blendModeSizer->Add(
new wxStaticText(
this, -1, _(
"projection (f):")),
191 wxALL | wxALIGN_CENTER_VERTICAL,
194 wxDefaultPosition, wxDefaultSize);
197 int nP = panoProjectionFormatCount();
198 for(
int n=0; n < nP; n++) {
199 pano_projection_features proj;
200 if (panoProjectionFeaturesQuery(n, &proj)) {
201 wxString str2(proj.name, wxConvLocal);
209 wxALL | wxALIGN_CENTER_VERTICAL,
214 blendModeSizer->Add(
new wxStaticText(
this, -1, _(
"Blend mode:")),
216 wxALL | wxALIGN_CENTER_VERTICAL,
222 int oldMode = wxConfigBase::Get()->Read(wxT(
"/PreviewFrame/blendMode"), 0l);
223 if (oldMode > 1) oldMode = 0;
225 wxDefaultPosition, wxDefaultSize,
231 wxALL | wxALIGN_CENTER_VERTICAL,
236 blendModeSizer->Add(
new wxStaticText(
this, -1, _(
"Output:")),
238 wxALL | wxALIGN_CENTER_VERTICAL,
244 wxDefaultPosition, wxDefaultSize,
249 wxALL | wxALIGN_CENTER_VERTICAL,
254 blendModeSizer->Add(
new wxStaticText(
this, -1, _(
"EV:")),
256 wxALL | wxALIGN_CENTER_VERTICAL,
260 wxArtProvider::GetBitmap(wxART_REDO));
268 wxDefaultPosition,wxSize(50,-1), wxTE_PROCESS_ENTER);
271 wxLEFT | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL,
276 wxDefaultSize, wxSP_VERTICAL);
281 blendModeSizer->Add(
new wxStaticText(
this, wxID_ANY, _(
"Range compression:")), 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 5);
283 wxDefaultPosition, wxSize(30, -1), wxTE_PROCESS_ENTER);
285 m_rangeCompressionSpinBut =
new wxSpinButton(
this, ID_RANGE_COMPRESSION_SPIN, wxDefaultPosition, wxDefaultSize, wxSP_VERTICAL);
290 m_topsizer->Add(blendModeSizer, 0, wxEXPAND | wxALL, 5);
293 new wxStaticBox(
this, -1, _(
"Projection Parameters")),
296 wxBitmapButton * resetProjButton=
new wxBitmapButton(
this, PROJ_PARAM_RESET_ID,
297 wxArtProvider::GetBitmap(wxART_REDO));
298 resetProjButton->SetToolTip(_(
"Resets the projection's parameters to their default values."));
299 m_projParamSizer->Add(resetProjButton, 0, wxLEFT | wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
305 for (
int i=0; i < PANO_PROJECTION_MAX_PARMS; i++) {
310 wxALL | wxALIGN_CENTER_VERTICAL,
313 wxDefaultPosition, wxSize(35,-1), wxTE_PROCESS_ENTER);
317 wxALL | wxALIGN_CENTER_VERTICAL,
323 wxALL | wxALIGN_CENTER_VERTICAL,
332 wxConfigBase * config = wxConfigBase::Get();
336 int widths[3] = {-3, 150, 150};
337 SetStatusWidths(3, widths);
338 SetStatusText(_(
"Left click to define new center point, right click to move point to horizon."),0);
339 SetStatusText(wxT(
""),1);
340 SetStatusText(wxT(
""),2);
348 wxIconBundle myIcons(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.ico"),wxBITMAP_TYPE_ICO);
351 wxIcon myIcon(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.png"),wxBITMAP_TYPE_PNG);
361 long aup = config->Read(wxT(
"/PreviewFrame/autoUpdate"),0l);
364 m_ToolBar->ToggleTool(XRCID(
"preview_auto_update_tool"), aup !=0);
371 if (config->Read(wxT(
"/PreviewFrame/isShown"), 0l) != 0) {
374 SetStatusText(_(
"Center panorama with left mouse button, set horizon with right button"),0);
375 wxAcceleratorEntry entries[3];
377 entries[0].Set(wxACCEL_CMD,(
int)
'F',ID_FULL_SCREEN);
379 entries[0].Set(wxACCEL_NORMAL,WXK_F11,ID_FULL_SCREEN);
381 entries[1].Set(wxACCEL_CMD,(
int)
'Z',ID_UNDO);
382 entries[2].Set(wxACCEL_CMD,(
int)
'R',ID_REDO);
383 wxAcceleratorTable accel(3, entries);
384 SetAcceleratorTable(accel);
394 wxConfigBase * config = wxConfigBase::Get();
398 if ( (!this->IsIconized()) && (! this->IsMaximized()) && this->IsShown()) {
399 config->Write(wxT(
"/PreviewFrame/isShown"), 1l);
401 config->Write(wxT(
"/PreviewFrame/isShown"), 0l);
404 bool checked =
m_ToolBar->GetToolState(XRCID(
"preview_auto_update_tool"));
405 config->Write(wxT(
"/PreviewFrame/autoUpdate"), checked ? 1l: 0l);
406 config->Write(wxT(
"/PreviewFrame/blendMode"),
m_BlendModeChoice->GetSelection());
407 for (
int i=0; i < PANO_PROJECTION_MAX_PARMS; i++)
421 if (
id >= 0 &&
id < nImg) {
423 activeImages.insert(
id);
425 activeImages.erase(
id);
464 m_ToolBar->EnableTool(XRCID(
"preview_center_tool"), activeImgs);
465 m_ToolBar->EnableTool(XRCID(
"preview_fit_pano_tool"), activeImgs);
466 m_ToolBar->EnableTool(XRCID(
"preview_update_tool"), activeImgs);
467 m_ToolBar->EnableTool(XRCID(
"preview_num_transform"), activeImgs);
472 bool relayout =
false;
480 for (i=0; i < nParam; i++) {
481 const pano_projection_parameter * pp = & (opts.
m_projFeatures.parm[i]);
482 wxString str2(pp->name, wxConvLocal);
483 str2 = wxGetTranslation(str2);
487 for(;i < PANO_PROJECTION_MAX_PARMS; i++) {
501 assert((
int) params.size() == nParam);
502 for (
int i=0; i < nParam; i++) {
512 SetStatusText(_(
"Center panorama with left mouse button, set horizon with right button"),0);
513 SetStatusText(wxString::Format(wxT(
"%.1f x %.1f"), opts.
getHFOV(), opts.
getVFOV()),2);
533 for (
int i=nrButtons-1; i>=(int)nrImages; i--)
542 if ( nrImages >= nrButtons ) {
543 for(HuginBase::UIntSet::const_iterator it = changed.begin(); it != changed.end(); ++it){
544 if (*it >= nrButtons) {
549 wxString::Format(wxT(
" %d "),*it),
550 wxDefaultPosition, wxDefaultSize,
565 for (
unsigned i=0; i < nrImages; i++) {
585 if (event.CanVeto()) {
605 void PreviewFrame::OnProjectionChanged()
611 case PanoramaOptions::RECTILINEAR: Ip = _(
"Rectilinear");
break;
612 case PanoramaOptions::CYLINDRICAL: Ip = _(
"Cylindrical");
break;
613 case PanoramaOptions::EQUIRECTANGULAR: Ip = _(
"Equirectangular");
break;
615 opt.projectionFormat = (PanoramaOptions::ProjectionFormat) lt;
619 DEBUG_DEBUG (
"Projection changed: " << lt <<
":" << Ip )
650 if (
m_ToolBar->GetToolState(XRCID(
"preview_auto_update_tool"))) {
681 displayedImgs.insert(i);
709 wxXmlResource::Get()->LoadDialog(&dlg,
this, wxT(
"dlg_numtrans"));
710 dlg.CentreOnParent();
711 if (dlg.ShowModal() == wxID_OK ) {
712 wxString text = XRCCTRL(dlg,
"numtrans_yaw", wxTextCtrl)->GetValue();
715 wxLogError(_(
"Yaw value must be numeric."));
718 text = XRCCTRL(dlg,
"numtrans_pitch", wxTextCtrl)->GetValue();
721 wxLogError(_(
"Pitch value must be numeric."));
724 text = XRCCTRL(dlg,
"numtrans_roll", wxTextCtrl)->GetValue();
727 wxLogError(_(
"Roll value must be numeric."));
746 DEBUG_INFO (
"target exposure = " << text.mb_str(wxConvLocal) );
748 if (text != wxT(
"")) {
750 wxLogError(_(
"Value must be numeric."));
769 wxLogError(_(
"Value must be numeric."));
774 wxLogError(_(
"Value for range compression is outside of valid range."));
787 for (
int i = 0; i < nParam; i++)
792 DEBUG_INFO(
"param " << i <<
": = " << text.mb_str(wxConvLocal));
798 wxLogError(_(
"Value must be numeric."));
835 DEBUG_DEBUG(
"VFOV changed (slider): " << e.GetInt());
840 for (
int i = 0; i < nParam; i++) {
843 para[i] = e.GetInt();
859 int sel = e.GetSelection();
871 DEBUG_WARN(
"wxChoice event from unknown object received");
942 DEBUG_WARN(
"wxChoice event from unknown object received");
959 DEBUG_WARN(
"wxChoice event from unknown object received");
969 msg = wxGetTranslation(wxString(
m_message.c_str(), wxConvLocal));
972 msg.Append(wxT(
" "));
976 GetStatusBar()->SetStatusText(msg, 0);
985 ShowFullScreen(!IsFullScreen(), wxFULLSCREEN_NOBORDER | wxFULLSCREEN_NOCAPTION);
988 GetToolBar()->Show(
true);
997 wxCommandEvent dummy(wxEVT_COMMAND_MENU_SELECTED, XRCID(
"ID_EDITUNDO"));
998 m_parent->GetEventHandler()->AddPendingEvent(dummy);
1010 wxCommandEvent dummy(wxEVT_COMMAND_MENU_SELECTED, XRCID(
"ID_EDITREDO"));
1011 m_parent->GetEventHandler()->AddPendingEvent(dummy);
void OnShowAll(wxCommandEvent &e)
HuginBase::Panorama & m_pano
PanoramaOptions::ProjectionFormat getProjection() const
void OnUpdate(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxT("panel"))
double outputRangeCompression
void setHeight(unsigned int h)
set panorama height
pano_projection_features m_projFeatures
static double calcMeanExposure(const PanoramaData &pano)
bool str2double(const wxString &s, double &d)
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
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 StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
void OnRedo(wxCommandEvent &e)
event handler for redo
virtual double getResultHeight()
void OnProjectionChoice(wxCommandEvent &e)
void SetBlendMode(BlendMode b)
void OnShowNone(wxCommandEvent &e)
wxBitmapButton * m_defaultExposureBut
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.
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.
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