branch:
details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/f96f56d17f65
changeset: 5336:f96f56d17f65
user: tmodes
date: Mon Jun 20 22:13:46 2011 +0200
description:
Redesign of images tab to allow better extensibility
Integration of Python scripts currently commented out because of bug 799905
diffstat:
src/hugin1/hugin/CMakeLists.txt | 4 +-
src/hugin1/hugin/ImagesPanel.cpp | 510 ++------------------
src/hugin1/hugin/ImagesPanel.h | 73 +--
src/hugin1/hugin/MainFrame.cpp | 353 ++------------
src/hugin1/hugin/PanoOperation.cpp | 607 +++++++++++++++++++++++++
src/hugin1/hugin/PanoOperation.h | 169 +++++++
src/hugin1/hugin/PanoOperationTree.cpp | 180 +++++++
src/hugin1/hugin/PanoOperationTree.h | 77 +++
src/hugin1/hugin/PluginItems.cpp | 29 +
src/hugin1/hugin/PluginItems.h | 14 +
src/hugin1/hugin/huginApp.cpp | 2 +
src/hugin1/hugin/wxPanoCommand.cpp | 55 +-
src/hugin1/hugin/wxPanoCommand.h | 21 +-
src/hugin1/hugin/xrc/images_panel.xrc | 908 +++++++++++++++----------------------
14 files changed, 1633 insertions(+), 1369 deletions(-)
diffs (truncated from 3699 to 500 lines):
diff -r a4627a193a65 -r f96f56d17f65 src/hugin1/hugin/CMakeLists.txt
--- a/src/hugin1/hugin/CMakeLists.txt Sun Jun 19 23:58:20 2011 -0400
+++ b/src/hugin1/hugin/CMakeLists.txt Mon Jun 20 22:13:46 2011 +0200
@@ -34,7 +34,7 @@
PreviewCropTool.cpp DragTool.cpp PreviewIdentifyTool.cpp PanosphereSphereTool.cpp
PreviewDifferenceTool.cpp PreviewPanoMaskTool.cpp PreviewControlPointTool.cpp
GreatCircles.cpp AboutDialog.cpp LayoutRemapper.cpp PreviewLayoutLinesTool.cpp PreviewColorPickerTool.cpp
-MaskEditorPanel.cpp MaskImageCtrl.cpp MaskLoadDialog.cpp HtmlWindow.cpp)
+MaskEditorPanel.cpp MaskImageCtrl.cpp MaskLoadDialog.cpp HtmlWindow.cpp PanoOperation.cpp PanoOperationTree.cpp)
set(hugin_HEADERS
huginApp.h ImagesList.h MainFrame.h CPImageCtrl.h CPImagesComboBox.h CPEditorPanel.h CPDetectorDialog.h LensPanel.h
@@ -49,7 +49,7 @@
PreviewCropTool.h DragTool.h PreviewIdentifyTool.h PanosphereSphereTool.h
PreviewDifferenceTool.h PreviewPanoMaskTool.h PreviewControlPointTool.h
GreatCircles.h AboutDialog.h LayoutRemapper.h PreviewLayoutLinesTool.h PreviewColorPickerTool.h
-MaskEditorPanel.h MaskImageCtrl.h MaskLoadDialog.h HtmlWindow.h)
+MaskEditorPanel.h MaskImageCtrl.h MaskLoadDialog.h HtmlWindow.h PanoOperation.h PanoOperationTree.h)
IF(BUILD_HSI)
LIST(APPEND hugin_SOURCES PluginItems.cpp)
diff -r a4627a193a65 -r f96f56d17f65 src/hugin1/hugin/ImagesPanel.cpp
--- a/src/hugin1/hugin/ImagesPanel.cpp Sun Jun 19 23:58:20 2011 -0400
+++ b/src/hugin1/hugin/ImagesPanel.cpp Mon Jun 20 22:13:46 2011 +0200
@@ -34,38 +34,24 @@
#include <vector>
#include <map>
-//#include <vigra_ext/PointMatching.h>
-//#include <vigra_ext/LoweSIFT.h>
-
#include "hugin/ImagesPanel.h"
#include "hugin/CommandHistory.h"
#include "hugin/TextKillFocusHandler.h"
-#include "hugin/CPEditorPanel.h"
#include "hugin/ImagesList.h"
#include "hugin/MainFrame.h"
#include "hugin/huginApp.h"
-#include "icpfind/AutoCtrlPointCreator.h"
#include "hugin/config_defaults.h"
-#include "base_wx/MyProgressDialog.h"
-#include "base_wx/PTWXDlg.h"
-#include <algorithms/control_points/CleanCP.h>
-#include <PT/PTOptimise.h>
+#include "hugin/PanoOperationTree.h"
+#include "hugin/PanoOperation.h"
#include <panodata/StandardImageVariableGroups.h>
-// Celeste header
-#include "Celeste.h"
-#include "CelesteGlobals.h"
-#include "Utilities.h"
-
using namespace PT;
using namespace hugin_utils;
using namespace vigra;
using namespace vigra_ext;
using namespace std;
-ImgPreview * canvas;
-
#define m_XRCID(str_id) \
wxXmlResource::GetXRCID(str_id)
#define m_XRCCTRL(window, id, type) \
@@ -76,26 +62,17 @@
#define GET_VAR(val) pano->getVariable(orientationEdit_RefImg).val.getValue()
BEGIN_EVENT_TABLE(ImagesPanel, wxPanel)
-// EVT_SIZE ( ImagesPanel::OnSize )
-// EVT_MOUSE_EVENTS ( ImagesPanel::OnMouse )
-// EVT_MOTION ( ImagesPanel::ChangePreview )
-// EVT_SPLITTER_SASH_POS_CHANGED(XRCID("image_panel_splitter"), ImagesPanel::OnPositionChanged)
EVT_LIST_ITEM_SELECTED( XRCID("images_list_unknown"),
ImagesPanel::ListSelectionChanged )
EVT_LIST_ITEM_DESELECTED( XRCID("images_list_unknown"),
ImagesPanel::ListSelectionChanged )
- EVT_BUTTON ( XRCID("images_opt_anchor_button"), ImagesPanel::OnOptAnchorChanged)
- EVT_BUTTON ( XRCID("images_color_anchor_button"), ImagesPanel::OnColorAnchorChanged)
- EVT_BUTTON ( XRCID("images_feature_matching"), ImagesPanel::SIFTMatching)
- EVT_BUTTON ( XRCID("images_cp_clean"), ImagesPanel::OnCleanCP)
- EVT_BUTTON ( XRCID("images_remove_cp"), ImagesPanel::OnRemoveCtrlPoints)
EVT_BUTTON ( XRCID("images_reset_pos"), ImagesPanel::OnResetImagePositions)
+#ifndef __WXGTK__
EVT_BUTTON ( XRCID("action_remove_images"), ImagesPanel::OnRemoveImages)
+#endif
EVT_BUTTON ( XRCID("images_move_image_down"), ImagesPanel::OnMoveImageDown)
EVT_BUTTON ( XRCID("images_move_image_up"), ImagesPanel::OnMoveImageUp)
- EVT_BUTTON ( XRCID("images_celeste_button"), ImagesPanel::OnCelesteButton)
- EVT_BUTTON ( XRCID("images_new_stack"), ImagesPanel::OnNewStack)
- EVT_BUTTON ( XRCID("images_change_stack"), ImagesPanel::OnChangeStack)
+ EVT_BUTTON ( XRCID("images_execute_operation"), ImagesPanel::OnExecuteOperation)
EVT_TEXT_ENTER ( XRCID("images_text_y"), ImagesPanel::OnVarTextChanged )
EVT_TEXT_ENTER ( XRCID("images_text_p"), ImagesPanel::OnVarTextChanged )
EVT_TEXT_ENTER ( XRCID("images_text_r"), ImagesPanel::OnVarTextChanged )
@@ -109,7 +86,7 @@
ImagesPanel::ImagesPanel()
{
- pano = 0;
+ pano = NULL;
m_restoreLayoutOnResize = false;
}
@@ -133,32 +110,15 @@
m_showImgNr = INT_MAX;
- m_optAnchorButton = XRCCTRL(*this, "images_opt_anchor_button", wxButton);
- DEBUG_ASSERT(m_optAnchorButton);
-
- m_colorAnchorButton = XRCCTRL(*this, "images_color_anchor_button", wxButton);
- DEBUG_ASSERT(m_colorAnchorButton);
- m_matchingButton = XRCCTRL(*this, "images_feature_matching", wxButton);
- DEBUG_ASSERT(m_matchingButton);
- m_cleaningButton = XRCCTRL(*this, "images_cp_clean", wxButton);
- DEBUG_ASSERT(m_cleaningButton);
- m_removeCPButton = XRCCTRL(*this, "images_remove_cp", wxButton);
- DEBUG_ASSERT(m_removeCPButton);
m_moveUpButton = XRCCTRL(*this, "images_move_image_up", wxButton);
DEBUG_ASSERT(m_moveUpButton);
m_moveDownButton = XRCCTRL(*this, "images_move_image_down", wxButton);
DEBUG_ASSERT(m_moveDownButton);
- m_stackNewButton = XRCCTRL(*this, "images_new_stack", wxButton);
- DEBUG_ASSERT(m_stackNewButton);
- m_stackChangeButton = XRCCTRL(*this, "images_change_stack", wxButton);
- DEBUG_ASSERT(m_stackChangeButton);
-
m_linkCheckBox = XRCCTRL(*this, "images_check_link", wxCheckBox);
-
- m_img_ctrls = XRCCTRL(*this, "image_control_panel", wxPanel);
- DEBUG_ASSERT(m_img_ctrls);
-
- m_CPDetectorChoice = XRCCTRL(*this, "cpdetector_settings", wxChoice);
+ DEBUG_ASSERT(m_linkCheckBox);
+ m_operationTree = XRCCTRL(*this, "images_pano_operation_tree", PanoOperationTreeCtrl);
+ DEBUG_ASSERT(m_operationTree);
+ m_operationTree->GenerateTree();
// Image Preview
m_smallImgCtrl = XRCCTRL(*this, "images_selected_image", wxStaticBitmap);
@@ -178,10 +138,6 @@
// wxBITMAP_TYPE_PNG);
m_smallImgCtrl->SetBitmap(m_empty);
- wxListEvent ev;
- ListSelectionChanged(ev);
- DEBUG_TRACE("end");
-
// SetAutoLayout(false);
wxConfigBase* config=wxConfigBase::Get();
@@ -191,8 +147,11 @@
//write current autopano generator settings
cpdetector_config.Write(config);
config->Flush();
- cpdetector_config.FillControl(m_CPDetectorChoice,true);
+ m_operationTree->UpdateCPDetectorItems(cpdetector_config);
Layout();
+ wxListEvent ev;
+ ListSelectionChanged(ev);
+ DEBUG_TRACE("end");
return true;
}
@@ -205,6 +164,15 @@
pano->addObserver(this);
}
+#ifdef HUGIN_HSI
+void ImagesPanel::AddPythonOperations(PluginItems items)
+{
+ m_operationTree->GeneratePythonTree(items);
+ UIntSet images;
+ m_operationTree->UpdateState(*pano,images);
+};
+#endif
+
ImagesPanel::~ImagesPanel()
{
DEBUG_TRACE("dtor");
@@ -263,21 +231,7 @@
if (pano.getNrOfImages() == 0)
{
DisableImageCtrls();
- m_removeCPButton->Disable();
- m_matchingButton->Disable();
- } else {
- m_removeCPButton->Enable();
- m_matchingButton->Enable();
- }
- if (pano.getNrOfImages()>1)
- {
- if(pano.getNrOfCtrlPoints()>2)
- m_cleaningButton->Enable();
- else
- m_cleaningButton->Disable();
- }
- else
- m_cleaningButton->Disable();
+ };
if (selected.size() == 1 &&
*(selected.begin()) < pano.getNrOfImages() &&
@@ -290,6 +244,7 @@
{
ClearImgParameters( );
}
+ m_operationTree->UpdateState(pano,selected);
DEBUG_TRACE("");
}
@@ -303,84 +258,6 @@
}
// ##### Here start the eventhandlers #####
-
-/** run sift matching on selected images, and add control points */
-void ImagesPanel::SIFTMatching(wxCommandEvent & e)
-{
- UIntSet selImg = images_list->GetSelected();
- if ( selImg.size() < 2) {
- // add all images.
- selImg.clear();
- unsigned int nImg = pano->getNrOfImages();
- for (unsigned int i=0; i < nImg; i++) {
- selImg.insert(i);
- }
- }
-
- if (selImg.size() == 0) {
- return;
- }
-
- long nFeatures = XRCCTRL(*this, "images_points_per_overlap"
- , wxSpinCtrl)->GetValue();
-
- AutoCtrlPointCreator matcher;
- CPVector cps = matcher.automatch(cpdetector_config.settings[m_CPDetectorChoice->GetSelection()],
- *pano, selImg, nFeatures,this);
- wxString msg;
- wxMessageBox(wxString::Format(_("Added %lu control points"), (unsigned long) cps.size()), _("Control point detector result"),wxOK|wxICON_INFORMATION,this);
- GlobalCmdHist::getInstance().addCommand(
- new PT::AddCtrlPointsCmd(*pano, cps)
- );
-
-};
-
-void ImagesPanel::OnCleanCP(wxCommandEvent & e)
-{
- if (pano->getNrOfImages()<2)
- return;
-
- if (pano->getNrOfCtrlPoints()<2)
- return;
-
- deregisterPTWXDlgFcn();
- // work around a flaw in wxProgresDialog that results in incorrect layout
- // by pre-allocting sufficient horizontal space
- ProgressReporterDialog progress(2, _("Cleaning Control points"), _("Checking pairwise")+wxString((wxChar)' ',10),this, wxPD_AUTO_HIDE | wxPD_APP_MODAL | wxPD_ELAPSED_TIME);
- UIntSet CPremove=getCPoutsideLimit_pair(*pano,2.0);
-
- unsigned int NrRemoved=CPremove.size();
- if(NrRemoved>0)
- {
- GlobalCmdHist::getInstance().addCommand(
- new PT::RemoveCtrlPointsCmd(*pano,CPremove)
- );
-
- };
- CPremove.clear();
-
- //check for unconnected images
- CPGraph graph;
- createCPGraph(*pano, graph);
- CPComponents comps;
- int n=findCPComponents(graph, comps);
- progress.increaseProgress(1, std::wstring(wxString(_("Checking whole project")).wc_str(wxConvLocal)));
- if (n <= 1)
- {
- CPremove=getCPoutsideLimit(*pano,2.0);
- }
- progress.increaseProgress(1, std::wstring(wxString(_("Finished cleaning")).wc_str(wxConvLocal)));
- registerPTWXDlgFcn(MainFrame::Get());
- if(CPremove.size()>0)
- {
- GlobalCmdHist::getInstance().addCommand(
- new PT::RemoveCtrlPointsCmd(*pano,CPremove)
- );
- NrRemoved+=CPremove.size();
- };
- wxMessageBox(wxString::Format(_("Removed %u control points"), NrRemoved), _("Cleaning"),wxOK|wxICON_INFORMATION,this);
-};
-
void ImagesPanel::OnVarTextChanged ( wxCommandEvent & e )
{
@@ -439,41 +316,6 @@
);
}
-void ImagesPanel::OnOptAnchorChanged(wxCommandEvent &e )
-{
- const UIntSet & sel = images_list->GetSelected();
- if ( sel.size() == 1 ) {
- // set first image to be the anchor
- PanoramaOptions opt = pano->getOptions();
- opt.optimizeReferenceImage = *(sel.begin());
-
- GlobalCmdHist::getInstance().addCommand(
- new PT::SetPanoOptionsCmd( *pano, opt )
- );
- }
-}
-
-void ImagesPanel::OnColorAnchorChanged(wxCommandEvent &e )
-{
- const UIntSet & sel = images_list->GetSelected();
- if ( sel.size() == 1 ) {
- // set first image to be the anchor
- PanoramaOptions opt = pano->getOptions();
- opt.colorReferenceImage = *(sel.begin());
- // Set the color correction mode so that the anchor image is persisted
- if (opt.colorCorrection == 0) {
- opt.colorCorrection = (PanoramaOptions::ColorCorrection) 1;
- }
- DEBUG_INFO("Color reference image is now: " << opt.colorReferenceImage);
- DEBUG_INFO("Color correction mode : " << opt.colorCorrection);
- GlobalCmdHist::getInstance().addCommand(
- new PT::SetPanoOptionsCmd( *pano, opt )
- );
- }
-
-}
-
-
void ImagesPanel::ListSelectionChanged(wxListEvent & e)
{
DEBUG_TRACE(e.GetIndex());
@@ -493,8 +335,6 @@
unsigned int imgNr = *(sel.begin());
// single selection, show its parameters
ShowImgParameters(imgNr);
- m_optAnchorButton->Enable();
- m_colorAnchorButton->Enable();
m_moveDownButton->Enable();
m_moveUpButton->Enable();
} else {
@@ -502,12 +342,20 @@
// multiselection, clear all values
// we don't know which images parameters to show.
ClearImgParameters();
- m_optAnchorButton->Disable();
- m_colorAnchorButton->Disable();
m_moveDownButton->Disable();
m_moveUpButton->Disable();
}
}
+ if(pano!=NULL)
+ {
+ m_operationTree->UpdateState(*pano,sel);
+ }
+ else
+ {
+ Panorama pano2;
+ UIntSet images;
+ m_operationTree->UpdateState(pano2,images);
+ };
}
@@ -525,15 +373,12 @@
m_smallImgCtrl->SetBitmap(m_empty);
m_smallImgCtrl->GetParent()->Layout();
m_smallImgCtrl->Refresh();
- m_optAnchorButton->Disable();
- m_colorAnchorButton->Disable();
m_moveDownButton->Disable();
m_moveUpButton->Disable();
XRCCTRL(*this, "images_reset_pos", wxButton)->Disable();
+#ifndef __WXGTK__
XRCCTRL(*this, "action_remove_images", wxButton)->Disable();
- XRCCTRL(*this, "images_celeste_button", wxButton)->Disable();
- m_stackNewButton->Disable();
- m_stackChangeButton->Disable();
+#endif
m_linkCheckBox->Disable();
}
@@ -549,10 +394,9 @@
m_moveDownButton->Enable();
m_moveUpButton->Enable();
XRCCTRL(*this, "images_reset_pos", wxButton)->Enable();
+#ifndef __WXGTK__
XRCCTRL(*this, "action_remove_images", wxButton)->Enable();
- XRCCTRL(*this, "images_celeste_button", wxButton)->Enable();
- m_stackNewButton->Enable();
- m_stackChangeButton->Enable();
+#endif
m_linkCheckBox->Enable();
}
}
@@ -689,6 +533,7 @@
XRCCTRL(*this, "images_focal_length", wxStaticText) ->SetLabel(wxT(""));
XRCCTRL(*this, "images_aperture", wxStaticText) ->SetLabel(wxT(""));
XRCCTRL(*this, "images_shutter_speed", wxStaticText) ->SetLabel(wxT(""));
+ XRCCTRL(*this, "images_iso",wxStaticText)->SetLabel(wxT(""));
}
@@ -746,75 +591,6 @@
}
}
-
-#if 0
-void ImagesPanel::ShowImage(unsigned int imgNr)
-{
- // show preview image
-
- // static bitmap behaves strangely under windows,
- // we need to resize it to its maximum size every time before
- // a new image is set, else it will keep the old size..
- // however, I'm not sure how this should be done with wxWindows
-
-
- const wxImage * img = ImageCache::getInstance().getSmallImage(
- pano->getImage(imgNr).getFilename());
-
- double iRatio = (double)img->GetWidth() / img->GetHeight();
-
- wxSize sz;
-#ifdef USE_WX253
- // get width from splitter window
- wxSize szs = m_img_splitter->GetSize();
- wxSize sz1 = m_img_splitter->GetWindow1()->GetSize();
- wxSize sz2 = m_img_splitter->GetWindow2()->GetSize();
-
- // estimate image size
- sz = m_img_splitter->GetWindow2()->GetSize();
- int maxw = sz.GetWidth() - 40;
- int maxh = sz.GetHeight() - m_smallImgCtrl->GetPosition().y - 20;
- sz.SetHeight(std::max(maxh, 20));
- sz.SetWidth(std::max(maxw, 20));
- double sRatio = (double)sz.GetWidth() / sz.GetHeight();
- if (iRatio > sRatio) {
- // image is wider than screen, display landscape
- sz.SetHeight((int) (sz.GetWidth() / iRatio));
- } else {
- // portrait
- sz.SetWidth((int) (sz.GetHeight() * iRatio));
- }
-
-#else
- // get size from parent panel (its just there, to provide the size..
- wxPanel * imgctrlpanel = XRCCTRL(*this, "images_selected_image_panel", wxPanel);
- DEBUG_ASSERT(imgctrlpanel);
- wxSize sz = imgctrlpanel->GetSize();
- DEBUG_DEBUG("imgctrl panel size: " << sz.x << "," << sz.y);
- double sRatio = (double)sz.GetWidth() / sz.GetHeight();
-
- if (iRatio > sRatio) {
- // image is wider than screen, display landscape
- sz.SetHeight((int) (sz.GetWidth() / iRatio));
- } else {
- // portrait
- sz.SetWidth((int) (sz.GetHeight() * iRatio));
- }
-#if (wxMAJOR_VERSION == 2 && wxMINOR_VERSION == 4)
- imgctrlpanel->Clear();
-#else
- imgctrlpanel->ClearBackground();
-#endif
- imgctrlpanel->SetSize(sz.GetWidth(),sz.GetHeight());
-
-#endif
-
- wxImage scaled = img->Scale(sz.GetWidth(),sz.GetHeight());
- m_smallImgCtrl->SetSize(sz.GetWidth(),sz.GetHeight());
- m_smallImgCtrl->SetBitmap(wxBitmap(scaled));
-}
-#endif
-
void ImagesPanel::OnResetImagePositions(wxCommandEvent & e)
{
DEBUG_TRACE("");
@@ -837,7 +613,6 @@
GlobalCmdHist::getInstance().addCommand(
new PT::UpdateImagesVariablesCmd( *pano, selImg, vars ));
}
-
}
void ImagesPanel::OnAddImages(wxCommandEvent &e)
@@ -847,59 +622,15 @@
void ImagesPanel::OnRemoveImages(wxCommandEvent & e)
{
- DEBUG_TRACE("");
-
|