Diff of /src/hugin1/hugin/PreviewFrame.cpp [261128] .. [519868]  Maximize  Restore

  Switch to side-by-side view

--- a/src/hugin1/hugin/PreviewFrame.cpp
+++ b/src/hugin1/hugin/PreviewFrame.cpp
@@ -44,23 +44,14 @@
 #include "hugin/PreviewPanel.h"
 #include "hugin/ImagesPanel.h"
 #include "hugin/CommandHistory.h"
-#include "MaskEdEditWnd.h"
-#include "MaskMgr.h"
 
 #include <vigra_ext/ImageTransforms.h>
-#include <vector>
-#include <string>
 
 extern "C" {
-#ifdef HasPANO13
 #include <pano13/queryfeature.h>
-#else
-#include <pano12/queryfeature.h>
-#endif
 }
 
 using namespace utils;
-using namespace std;
 
 // a random id, hope this doesn't break something..
 enum {
@@ -88,8 +79,6 @@
     EVT_TOOL(XRCID("preview_show_all_tool"), PreviewFrame::OnShowAll)
     EVT_TOOL(XRCID("preview_show_none_tool"), PreviewFrame::OnShowNone)
     EVT_TOOL(XRCID("preview_num_transform"), PreviewFrame::OnNumTransform)
-    EVT_TOOL(XRCID("preview_mask_editor"), PreviewFrame::OnMaskEditor)
-    EVT_TOOL(XRCID("action_exit_maskeditor"), PreviewFrame::OnExitMaskEditor)
     EVT_TEXT_ENTER( -1 , PreviewFrame::OnTextCtrlChanged)
 
     EVT_BUTTON(ID_EXPOSURE_DEFAULT, PreviewFrame::OnDefaultExposure)
@@ -98,16 +87,6 @@
     EVT_CHOICE(ID_BLEND_CHOICE, PreviewFrame::OnBlendChoice)
     EVT_CHOICE(ID_PROJECTION_CHOICE, PreviewFrame::OnProjectionChoice)
     EVT_CHOICE(ID_OUTPUTMODE_CHOICE, PreviewFrame::OnOutputChoice)
-
-    EVT_TOOL(XRCID("action_draw_bstroke"), PreviewFrame::OnBStroke)
-    EVT_TOOL(XRCID("action_draw_polygon"), PreviewFrame::OnAddPoint)
-    EVT_TOOL(XRCID("action_zoom_in"), PreviewFrame::OnZoomIn)
-    EVT_TOOL(XRCID("action_zoom_out"), PreviewFrame::OnZoomOut)
-    EVT_TOOL(XRCID("action_set_roi"), PreviewFrame::OnSetROI)
-    EVT_TOOL(XRCID("action_show_overlap"), PreviewFrame::OnShowOverlap)
-    EVT_TOOL(XRCID("action_undo"), PreviewFrame::OnUndo)
-    EVT_TOOL(XRCID("action_redo"), PreviewFrame::OnRedo)
-    EVT_COMBOBOX(XRCID("m_comboSegChoice"), PreviewFrame::OnSegSelUpdate)
 #ifdef USE_TOGGLE_BUTTON
     EVT_TOGGLEBUTTON(-1, PreviewFrame::OnChangeDisplayedImgs)
 #else
@@ -123,7 +102,6 @@
     EVT_SCROLL_THUMBTRACK(PreviewFrame::OnChangeFOV)
 #endif
 
-    
 END_EVENT_TABLE()
 
 #define PF_STYLE (wxMAXIMIZE_BOX | wxRESIZE_BORDER | wxSYSTEM_MENU | wxCAPTION | wxCLOSE_BOX | wxCLIP_CHILDREN)
@@ -131,7 +109,7 @@
 PreviewFrame::PreviewFrame(wxFrame * frame, PT::Panorama &pano)
     : wxFrame(frame,-1, _("Panorama preview"), wxDefaultPosition, wxDefaultSize,
               PF_STYLE),
-      m_pano(pano), m_scale(1.0), m_bPanoChanged(true)
+      m_pano(pano)
 {
 	DEBUG_TRACE("");
 
@@ -143,55 +121,8 @@
 
     m_topsizer = new wxBoxSizer( wxVERTICAL );
 
-    // create our preview panel
-    m_PreviewPanel = new PreviewPanel();
-    m_PreviewPanel->Create(this);
-    m_PreviewPanel->Init(this, &m_pano);
-
-    //create mask editor client window
-    wxSize sz = GetClientSize();
-    m_MaskEdEditWnd = new MaskEdEditWnd(this);
-    m_MaskEdEditWnd->init(this, &m_pano);
-
-    initPreviewMode(); 
-    initMaskEditorMode();
-
-    m_mode = PREVIEW_MODE;
-}
-
-PreviewFrame::~PreviewFrame()
-{
-    DEBUG_TRACE("dtor writing config");
-    wxConfigBase * config = wxConfigBase::Get();
-    wxSize sz = GetClientSize();
-
-    StoreFramePosition(this, wxT("PreviewFrame"));
-
-    if ( (!this->IsIconized()) && (! this->IsMaximized()) && this->IsShown()) {
-        config->Write(wxT("/PreviewFrame/isShown"), 1l);
-    } else {
-        config->Write(wxT("/PreviewFrame/isShown"), 0l);
-    }
-    
-    if(m_mode == PREVIEW_MODE)
-    {
-        bool checked = m_ToolBar->GetToolState(XRCID("preview_auto_update_tool"));
-        config->Write(wxT("/PreviewFrame/autoUpdate"), checked ? 1l: 0l);
-        config->Write(wxT("/PreviewFrame/blendMode"), m_BlendModeChoice->GetSelection());
-    }
-    config->Write(wxT("/PreviewFrame/Mode"), m_mode);
-
-    m_pano.removeObserver(this);
-
-    delete m_MaskEdEditWnd;
-
-    DEBUG_TRACE("dtor end");
-}
-
-void PreviewFrame::initPreviewMode()
-{
     m_ToggleButtonSizer = new wxStaticBoxSizer(
-          new wxStaticBox(this, -1, _("displayed images")),
+        new wxStaticBox(this, -1, _("displayed images")),
     wxHORIZONTAL );
 
 	m_ButtonPanel = new wxScrolledWindow(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
@@ -207,11 +138,16 @@
 
     m_topsizer->Add(m_ToggleButtonSizer, 0, wxEXPAND | wxADJUST_MINSIZE | wxALL, 5);
 
-    m_flexSizer = new wxFlexGridSizer(2,0,5,5);
-    m_flexSizer->AddGrowableCol(0);
-    m_flexSizer->AddGrowableRow(0);
-
-    m_flexSizer->Add(m_PreviewPanel,
+    wxFlexGridSizer * flexSizer = new wxFlexGridSizer(2,0,5,5);
+    flexSizer->AddGrowableCol(0);
+    flexSizer->AddGrowableRow(0);
+
+    // create our preview panel
+    m_PreviewPanel = new PreviewPanel();
+    m_PreviewPanel->Create(this);
+    m_PreviewPanel->Init(this, &pano);
+
+    flexSizer->Add(m_PreviewPanel,
                   1,        // not vertically stretchable
                   wxEXPAND | // horizontally stretchable
                   wxALL,    // draw border all around
@@ -229,7 +165,7 @@
     m_VFOVSlider->SetTickFreq(5,0);
     m_VFOVSlider->SetToolTip(_("drag to change the vertical field of view"));
 
-    m_flexSizer->Add(m_VFOVSlider, 0, wxEXPAND);
+    flexSizer->Add(m_VFOVSlider, 0, wxEXPAND);
 
     m_HFOVSlider = new wxSlider(this, -1, 1,
                                 1, 360,
@@ -243,19 +179,19 @@
 
     m_HFOVSlider->SetToolTip(_("drag to change the horizontal field of view"));
 
-    m_flexSizer->Add(m_HFOVSlider, 0, wxEXPAND);
-
-    m_topsizer->Add(m_flexSizer,
+    flexSizer->Add(m_HFOVSlider, 0, wxEXPAND);
+
+    m_topsizer->Add(flexSizer,
                   1,        // vertically stretchable
                   wxEXPAND | // horizontally stretchable
                   wxALL,    // draw border all around
                   5);       // border width
 
-    m_blendModeSizer = new wxStaticBoxSizer(
+    wxStaticBoxSizer * blendModeSizer = new wxStaticBoxSizer(
         new wxStaticBox(this, -1, _("Preview Options")),
         wxHORIZONTAL);
 
-    m_blendModeSizer->Add(new wxStaticText(this, -1, _("projection (f):")),
+    blendModeSizer->Add(new wxStaticText(this, -1, _("projection (f):")),
                         0,        // not vertically strechable
                         wxALL | wxALIGN_CENTER_VERTICAL, // draw border all around
                         5);       // border width
@@ -263,7 +199,6 @@
                                       wxDefaultPosition, wxDefaultSize);
 
     /* populate with all available projection types */
-#ifdef HasPANO13
     int nP = panoProjectionFormatCount();
     for(int n=0; n < nP; n++) {
         pano_projection_features proj;
@@ -272,33 +207,16 @@
             m_ProjectionChoice->Append(wxGetTranslation(str2));
         }
     }
-#else
-    bool ok = true;
-    int n=0;
-    while(ok) {
-        char name[20];
-        char str[255];
-        sprintf(name,"PanoType%d",n);
-        n++;
-        int len = queryFeatureString(name,str,255);
-        if (len > 0) {
-            wxString str2(str, wxConvLocal);
-            m_ProjectionChoice->Append(wxGetTranslation(str2));
-        } else {
-            ok = false;
-        }
-    }
-#endif
     m_ProjectionChoice->SetSelection(2);
 
-    m_blendModeSizer->Add(m_ProjectionChoice,
+    blendModeSizer->Add(m_ProjectionChoice,
                         0,
                         wxALL | wxALIGN_CENTER_VERTICAL,
                         5);
 
     //////////////////////////////////////////////////////
     // Blend mode
-    m_blendModeSizer->Add(new wxStaticText(this, -1, _("Blend mode:")),
+    blendModeSizer->Add(new wxStaticText(this, -1, _("Blend mode:")),
                         0,        // not vertically strechable
                         wxALL | wxALIGN_CENTER_VERTICAL, // draw border all around
                         5);       // border width
@@ -313,14 +231,14 @@
                                      2, m_choices);
     m_BlendModeChoice->SetSelection((PreviewPanel::BlendMode) oldMode);
 
-    m_blendModeSizer->Add(m_BlendModeChoice,
+    blendModeSizer->Add(m_BlendModeChoice,
                         0,
                         wxALL | wxALIGN_CENTER_VERTICAL,
                         5);
 
     //////////////////////////////////////////////////////
     // LDR, HDR
-    m_blendModeSizer->Add(new wxStaticText(this, -1, _("Output:")),
+    blendModeSizer->Add(new wxStaticText(this, -1, _("Output:")),
                         0,        // not vertically strechable
                         wxALL | wxALIGN_CENTER_VERTICAL, // draw border all around
                         5);       // border width
@@ -331,21 +249,21 @@
                                       wxDefaultPosition, wxDefaultSize,
                                       2, m_choices);
     m_outputModeChoice->SetSelection(0);
-    m_blendModeSizer->Add(m_outputModeChoice,
+    blendModeSizer->Add(m_outputModeChoice,
                         0,
                         wxALL | wxALIGN_CENTER_VERTICAL,
                         5);
 
     /////////////////////////////////////////////////////
     // exposure
-    m_blendModeSizer->Add(new wxStaticText(this, -1, _("EV:")),
+    blendModeSizer->Add(new wxStaticText(this, -1, _("EV:")),
                           0,        // not vertically strechable
                           wxALL | wxALIGN_CENTER_VERTICAL, // draw border all around
                           5);       // border width
     
     m_defaultExposureBut = new wxBitmapButton(this, ID_EXPOSURE_DEFAULT,
                                               wxArtProvider::GetBitmap(wxART_REDO));
-    m_blendModeSizer->Add(m_defaultExposureBut, 0, wxLEFT | wxRIGHT, 5);
+    blendModeSizer->Add(m_defaultExposureBut, 0, wxLEFT | wxRIGHT, 5);
 
 //    m_decExposureBut = new wxBitmapButton(this, ID_EXPOSURE_DECREASE,
 //                                          wxArtProvider::GetBitmap(wxART_GO_BACK));
@@ -353,7 +271,7 @@
 
     m_exposureTextCtrl = new wxTextCtrl(this, ID_EXPOSURE_TEXT, _("0"),
                                         wxDefaultPosition,wxSize(50,-1), wxTE_PROCESS_ENTER);
-    m_blendModeSizer->Add(m_exposureTextCtrl,
+    blendModeSizer->Add(m_exposureTextCtrl,
                           0,        // not vertically strechable
                           wxLEFT | wxTOP | wxBOTTOM  | wxALIGN_CENTER_VERTICAL, // draw border all around
                           5);       // border width
@@ -363,11 +281,10 @@
                                          wxDefaultSize, wxSP_VERTICAL);
     m_exposureSpinBut->SetRange(-0x8000, 0x7fff);
     m_exposureSpinBut->SetValue(0);
-    m_blendModeSizer->Add(m_exposureSpinBut, 0, wxALIGN_CENTER_VERTICAL);
-
-    m_topsizer->Add(m_blendModeSizer, 0, wxEXPAND | wxALL, 5);
-
-#ifdef HasPANO13
+    blendModeSizer->Add(m_exposureSpinBut, 0, wxALIGN_CENTER_VERTICAL);
+
+    m_topsizer->Add(blendModeSizer, 0, wxEXPAND | wxALL, 5);
+
     m_projParamSizer = new wxStaticBoxSizer(
     new wxStaticBox(this, -1, _("Projection Parameters")),
      wxHORIZONTAL);
@@ -402,8 +319,6 @@
     // do not show projection param sizer
     m_topsizer->Show(m_projParamSizer, false, true);
 
-#endif
-
     wxConfigBase * config = wxConfigBase::Get();
 
     // add a status bar
@@ -449,63 +364,25 @@
 
 }
 
-void PreviewFrame::initMaskEditorMode()
-{
-    m_topsizer->Add(m_MaskEdEditWnd, 1, wxEXPAND | wxALL);
-    m_topsizer->Hide(m_MaskEdEditWnd, true);
-}
-
-void PreviewFrame::OnMaskEditor(wxCommandEvent & e)
-{
-    m_mode = MASKEDITOR_MODE;
-
-    SetTitle(wxT("Mask Editor Mode"));
-    delete m_ToolBar;
-    m_ToolBar = wxXmlResource::Get()->LoadToolBar(this, wxT("masked_main_toolbar"));
-    DEBUG_ASSERT(m_ToolBar);
-    // create tool bar
-    SetToolBar(m_ToolBar);
-    MaskMgr::getInstance()->setSegmentationOption(0);
-	wxWindow *pWnd = m_ToolBar;
-#ifdef __WXMSW__
-	pWnd = this;
-#endif
-    vector<string> options = MaskMgr::getInstance()->getSegmentationOptions();
-    for(vector<string>::iterator it = options.begin(); it != options.end(); it++)
-		XRCCTRL(*pWnd, "m_comboSegChoice", wxComboBox)->Append(wxString(it->c_str(), wxConvUTF8));
-	XRCCTRL(*pWnd, "m_comboSegChoice", wxComboBox)->SetValue(wxString(options[0].c_str(), wxConvUTF8));
-
-    m_topsizer->Hide(m_flexSizer, true);
-    m_topsizer->Hide(m_blendModeSizer, true);
-    m_topsizer->Show(m_MaskEdEditWnd, true, true);
-    m_topsizer->Layout();
-    
-    if(m_bPanoChanged) {
-        m_bPanoChanged = false;
-        vector<pair<vigra::BRGBImage*, vigra::BImage*> > remapimgs = m_PreviewPanel->getRemappedImages();
-        MaskMgr::getInstance()->loadImage(remapimgs);
-        m_MaskEdEditWnd->loadImage(remapimgs);
-    }
-    //m_MaskEdEditWnd->ForceUpdate();
-}
-
-void PreviewFrame::OnExitMaskEditor(wxCommandEvent &e)
-{
-    m_mode = PREVIEW_MODE;
-    SetTitle(wxT("Preview"));
-    delete m_ToolBar;
-    m_ToolBar = wxXmlResource::Get()->LoadToolBar(this, wxT("preview_toolbar"));
-    DEBUG_ASSERT(m_ToolBar);
-    // create tool bar
-    SetToolBar(m_ToolBar);
-
-    m_topsizer->Hide(m_MaskEdEditWnd, true);
-    m_topsizer->Show(m_flexSizer, true, true);
-    m_topsizer->Show(m_blendModeSizer, true, true);
-    m_topsizer->Layout();
-    vector<vigra::BImage*> alphas = m_MaskEdEditWnd->getAlpha();
-    m_PreviewPanel->setAlpha(alphas);
-    m_PreviewPanel->ForceUpdate();
+PreviewFrame::~PreviewFrame()
+{
+    DEBUG_TRACE("dtor writing config");
+    wxConfigBase * config = wxConfigBase::Get();
+    wxSize sz = GetClientSize();
+
+    StoreFramePosition(this, wxT("PreviewFrame"));
+
+    if ( (!this->IsIconized()) && (! this->IsMaximized()) && this->IsShown()) {
+        config->Write(wxT("/PreviewFrame/isShown"), 1l);
+    } else {
+        config->Write(wxT("/PreviewFrame/isShown"), 0l);
+    }
+
+    bool checked = m_ToolBar->GetToolState(XRCID("preview_auto_update_tool"));
+    config->Write(wxT("/PreviewFrame/autoUpdate"), checked ? 1l: 0l);
+    config->Write(wxT("/PreviewFrame/blendMode"), m_BlendModeChoice->GetSelection());
+    m_pano.removeObserver(this);
+    DEBUG_TRACE("dtor end");
 }
 
 void PreviewFrame::OnChangeDisplayedImgs(wxCommandEvent & e)
@@ -531,8 +408,6 @@
 
 void PreviewFrame::panoramaChanged(Panorama &pano)
 {
-    m_bPanoChanged = true;
-
     const PanoramaOptions & opts = pano.getOptions();
 
     wxString projection;
@@ -565,7 +440,6 @@
     m_ToolBar->EnableTool(XRCID("preview_straighten_pano_tool"), pano.getNrOfImages() > 0);
 
     // TODO: enable display of parameters and set their limits, if projection has some.
-#ifdef HasPANO13
     int nParam = opts.m_projFeatures.numberOfParameters;
     bool relayout = false;
     // if the projection format has changed
@@ -606,7 +480,6 @@
     if (relayout) {
         m_topsizer->Layout();
     }
-#endif 
     SetStatusText(_("Center panorama with left mouse button, set horizon with right button"),0);
     SetStatusText(wxString::Format(wxT("%.1f x %.1f"), opts.getHFOV(), opts.getVFOV()),2);
     m_HFOVSlider->SetValue(roundi(opts.getHFOV()));
@@ -700,7 +573,6 @@
         DEBUG_DEBUG("closing");
         this->Destroy();
     }
-    m_PreviewPanel->freeAlpha();
 }
 
 void PreviewFrame::OnAutoPreviewToggle(wxCommandEvent & e)
@@ -760,26 +632,15 @@
     }
 }
 
-void PreviewFrame::ForceUpdate()
-{
-    if(m_mode == PREVIEW_MODE)
+void PreviewFrame::OnUpdate(wxCommandEvent& event)
+{
+    m_PreviewPanel->ForceUpdate();
+}
+
+void PreviewFrame::updatePano()
+{
+    if (m_ToolBar->GetToolState(XRCID("preview_auto_update_tool"))) {
         m_PreviewPanel->ForceUpdate();
-    else {
-        m_MaskEdEditWnd->ForceUpdate();
-    }
-}
-
-void PreviewFrame::OnUpdate(wxCommandEvent& event)
-{
-    /*m_PreviewPanel->*/ForceUpdate();
-}
-
-void PreviewFrame::updatePano()
-{
-    if(m_mode == MASKEDITOR_MODE)
-        ForceUpdate();
-    else if (m_ToolBar->GetToolState(XRCID("preview_auto_update_tool"))) {
-        /*m_PreviewPanel->*/ForceUpdate();
     }
 }
 
@@ -884,7 +745,6 @@
             }
         }
         opts.outputExposureValue = p;
-#ifdef HasPANO13
     } else {
         int nParam = opts.m_projFeatures.numberOfParameters;
         std::vector<double> para = opts.getProjectionParameters();
@@ -903,7 +763,6 @@
             }
         }
         opts.setProjectionParameters(para);
-#endif
     }
     GlobalCmdHist::getInstance().addCommand(
             new PT::SetPanoOptionsCmd( m_pano, opts )
@@ -926,7 +785,6 @@
         DEBUG_DEBUG("VFOV changed (slider): " << e.GetInt());
         opt.setVFOV(e.GetInt());
     } else {
-#ifdef HasPANO13
         int nParam = opt.m_projFeatures.numberOfParameters;
         std::vector<double> para = opt.getProjectionParameters();
         for (int i = 0; i < nParam; i++) {
@@ -938,7 +796,6 @@
         opt.setProjectionParameters(para);
 		opt.setHFOV(m_HFOVSlider->GetValue());
 		opt.setVFOV(m_VFOVSlider->GetValue());
-#endif
     }
 
     GlobalCmdHist::getInstance().addCommand(
@@ -1072,75 +929,3 @@
 #endif
 }
 
-void PreviewFrame::OnBStroke(wxCommandEvent &event)
-{
-    m_MaskEdEditWnd->setEditMode(ME_BSTROKE);
-}
-
-void PreviewFrame::OnAddPoint(wxCommandEvent &event)
-{
-    m_MaskEdEditWnd->setEditMode(ME_POLY);
-}
-
-//void PreviewFrame::OnPreference(wxCommandEvent &event)
-//{
-//    //wxDialog dlg;
-//    //wxXmlResource::Get()->LoadDialog(&dlg, this, wxT("MaskEdPrefDlg"));
-//    //dlg.ShowModal();
-//    MaskEdPrefDlg prefdlg(this);
-//    prefdlg.ShowModal();
-//}
-void PreviewFrame::OnQuit(wxCommandEvent &event)
-{
-    Close(true);
-}
-
-void PreviewFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
-{
-    wxMessageBox(wxT("Mask Editor"), wxT("About Mask Editor"),
-        wxOK | wxICON_INFORMATION, this);
-}
-
-void PreviewFrame::OnZoomIn(wxCommandEvent &event)
-{
-    m_scale += 0.1;
-    m_MaskEdEditWnd->zoom(m_scale);
-}
-
-void PreviewFrame::OnZoomOut(wxCommandEvent &event)
-{
-    if(m_scale <= 0.1) return;
-    m_scale -= 0.1;
-    m_MaskEdEditWnd->zoom(m_scale);
-}
-
-void PreviewFrame::OnSetROI(wxCommandEvent &event)
-{
-
-}
-
-void PreviewFrame::OnShowOverlap(wxCommandEvent &event)
-{
-    m_MaskEdEditWnd->toggleShowOverlappedRect();
-}
-
-void PreviewFrame::OnUndo(wxCommandEvent &event)
-{
-    m_MaskEdEditWnd->undo();
-}
-
-void PreviewFrame::OnRedo(wxCommandEvent &event)
-{
-    m_MaskEdEditWnd->redo();
-}
-
-void PreviewFrame::OnSegSelUpdate(wxCommandEvent &event)
-{
-    wxWindow *pWnd = GetToolBar();
-#ifdef __WXMSW__
-    pWnd = this;
-#endif
-   int ichoice = XRCCTRL(*pWnd, "m_comboSegChoice", wxComboBox)->GetSelection();
-   MaskMgr::getInstance()->setSegmentationOption(ichoice);    
-}
-

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks