From: <hug...@li...> - 2010-10-13 19:57:33
|
branch: details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/847139136070 changeset: 4464:847139136070 user: tmodes date: Wed Oct 13 21:57:13 2010 +0200 description: Merged diffstat: src/hugin1/hugin/MainFrame.cpp | 5 +++ src/hugin1/hugin/MainFrame.h | 1 + src/hugin1/hugin/PanoPanel.cpp | 69 ++++++++++++++++++++++++++++++++++++++++++ src/hugin1/hugin/PanoPanel.h | 12 +++++++ 4 files changed, 87 insertions(+), 0 deletions(-) diffs (141 lines): diff -r 61d3ec192625 -r 847139136070 src/hugin1/hugin/MainFrame.cpp --- a/src/hugin1/hugin/MainFrame.cpp Wed Oct 13 21:56:09 2010 +0200 +++ b/src/hugin1/hugin/MainFrame.cpp Wed Oct 13 21:57:13 2010 +0200 @@ -1592,6 +1592,11 @@ cpe->setRightImage(img2); } +void MainFrame::ShowStitcherTab() +{ + ///@todo Stop using magic numbers for the tabs. + m_notebook->SetSelection(8); +} /** update the display */ void MainFrame::updateProgressDisplay() diff -r 61d3ec192625 -r 847139136070 src/hugin1/hugin/MainFrame.h --- a/src/hugin1/hugin/MainFrame.h Wed Oct 13 21:56:09 2010 +0200 +++ b/src/hugin1/hugin/MainFrame.h Wed Oct 13 21:57:13 2010 +0200 @@ -150,6 +150,7 @@ void ShowCtrlPointEditor(unsigned int img1, unsigned int img2); + void ShowStitcherTab(); void resetProgress(double max); bool increaseProgress(double delta); diff -r 61d3ec192625 -r 847139136070 src/hugin1/hugin/PanoPanel.cpp --- a/src/hugin1/hugin/PanoPanel.cpp Wed Oct 13 21:56:09 2010 +0200 +++ b/src/hugin1/hugin/PanoPanel.cpp Wed Oct 13 21:57:13 2010 +0200 @@ -962,6 +962,11 @@ if (pano->getNrOfImages() == 0) { return; } + + if (!CheckGoodSize()) { + // oversized pano and the user no longer wants to stitch. + return; + } // save project // copy pto file to temporary file @@ -1088,6 +1093,9 @@ void PanoPanel::OnSendToBatch ( wxCommandEvent & e ) { + if (!CheckGoodSize()) { + return; + } wxCommandEvent dummy; MainFrame::Get()->OnSaveProject(dummy); wxString projectFile = MainFrame::Get()->getProjectName(); @@ -1279,6 +1287,67 @@ ); } +bool PanoPanel::CheckGoodSize() +{ + vigra::Rect2D cropped_region = pano->getOptions().getROI(); + unsigned long long int area = ((unsigned long int) cropped_region.width()) * ((unsigned long int) cropped_region.height()); + // Argh, more than half a gigapixel! + if (area > 500000000) + { + // Tell the user the stitch will be really big, and give them a + // chance to reduce the size. +#if wxCHECK_VERSION(2,9,0) + // Untested + /** @todo Test this wxWidgets 2.9+ section. + * Eventually remove the the other section. + */ + wxMessageDialog dialog(this, + _("Are you sure you want to stitch such a large panorama?"), + wxT(""), + wxICON_EXCLAMATION | wxYES_NO); + dialog.SetExtendedMessage( + wxString::Format(_("The panorama you are trying to stitch is %.1f gigapixels.\nIf this is too big, reduce the panorama Canvas Size and the cropped region and stitch from the Stitcher tab. Stitching a panorama this size could take a long time and a large amount of memory."), + area / 1000000000.0)); + dialog.SetYesNoLabels(_("Stitch anyway"), _("Let me fix that")); +#else // replacement for old wxWidgets versions. + // wxMessageDialog derives from wxDialog, but I don't understand + // why because on most platforms wxMessageDialog uses the native + // message box, and trying to make descriptive buttons through + // wxDialog::CreateStdButtonSizer causes a crash on wxGTK. + // Descriptive buttons are recommended by the Windows, Gnome, KDE, + // and Apple user interface guidelines. + // Due to this wxWidgets WTF, the buttons will are labeled Yes and + // No on wxWidgets 2.8 and earlier. This makes it a little + // confusing, and it is more likely someone will just click yes + // without reading the message and then wonder why their computer + // has ground to a halt. + /** @todo (Possibly) make a dialog manually with properly labelled + * buttons. + */ + wxMessageDialog dialog(this, + wxString::Format(_("Are you sure you want to stitch such a large panorama?\n\nThe panorama you are trying to stitch is %.1f gigapixels.\nIf this is too big, reduce the panorama Canvas Size and the cropped region and stitch from the Stitcher tab. Stitching a panorama this size could take a long time and a large amount of memory."), + area / 1000000000.0), + wxT(""), + wxICON_EXCLAMATION | wxYES_NO); +#endif + bool result; + switch (dialog.ShowModal()) + { + case wxID_OK: + case wxID_YES: + // Continue stitch. + return true; + break; + default: + // bring the user towards the approptiate controls. + MainFrame::Get()->ShowStitcherTab(); + return false; + } + } + // I see nothing wrong with this... + return true; +} + IMPLEMENT_DYNAMIC_CLASS(PanoPanel, wxPanel) diff -r 61d3ec192625 -r 847139136070 src/hugin1/hugin/PanoPanel.h --- a/src/hugin1/hugin/PanoPanel.h Wed Oct 13 21:56:09 2010 +0200 +++ b/src/hugin1/hugin/PanoPanel.h Wed Oct 13 21:57:13 2010 +0200 @@ -152,6 +152,18 @@ /** enable/disable control influenced by quick mode */ void EnableControls(bool enable); + + /** Check the canvas size isn't overly huge, or the user knows what they are doing. + * The canvas size can become too big if, for example, the field of view is + * more than 180 degrees, then you select rectilinear proection, then press + * "Calculate optimal size", or stitch a wide stereographic image using the + * assistant tab. + * If the canvas size is unreasonable, this function will display a warning. + * The user has the option to continue. + * @return true if the canvas size is reasonable, or the user presses + * "continue anyway" on the warning, false if the stitch should be aborted + */ + bool CheckGoodSize(); // the model Panorama * pano; |