CPEditorPanel.h

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00024 #ifndef _CPEDITORPANEL_H
00025 #define _CPEDITORPANEL_H
00026 
00027 
00028 //-----------------------------------------------------------------------------
00029 // Headers
00030 //-----------------------------------------------------------------------------
00031 
00032 #include <vector>
00033 #include <set>
00034 #include <functional>
00035 #include <utility>
00036 #include <string>
00037 
00038 // Celeste files
00039 #include "Celeste.h"
00040 #include "CelesteGlobals.h"
00041 #include "Utilities.h"
00042 
00043 #include <panodata/Panorama.h>
00044 
00045 #include "CPImagesComboBox.h"
00046 
00047 #include "CPImageCtrl.h"
00048 #include <panotools/PanoToolsInterface.h>
00049 
00050 namespace vigra {
00051     class Diff2D;
00052 }
00053 
00054 namespace vigra_ext{
00055     struct CorrelationResult;
00056 }
00057 
00064 class CPEditorPanel : public wxPanel, public HuginBase::PanoramaObserver
00065 {
00066 public:
00069     CPEditorPanel();
00070 
00071     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"));
00072 
00073     void Init(HuginBase::Panorama * pano);
00074 
00077     virtual ~CPEditorPanel();
00078 
00080     void setLeftImage(unsigned int imgNr);
00082     void setRightImage(unsigned int imgNr);
00083 
00084     void SetPano(HuginBase::Panorama * panorama)
00085         { m_pano = panorama; };
00086 
00090     void panoramaChanged(HuginBase::Panorama &pano);
00091     void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet & imgNr);
00092 
00093 
00101     void SelectGlobalPoint(unsigned int globalNr);
00102 
00107     void ShowControlPoint(unsigned int cpNr);
00108 
00110     void ClearSelection();
00111 
00112 private:
00113 
00117     void UpdateDisplay(bool newImages);
00118 
00120     void EnablePointEdit(bool state);
00121 
00126     void SelectLocalPoint(unsigned int LVpointNr);
00127 
00129     bool globalPNr2LocalPNr(unsigned int & localNr, unsigned int globalNr) const;
00131     unsigned int localPNr2GlobalPNr(unsigned int localNr) const;
00132 
00133     // function called when a new point has been selected or changed
00134     // in one of your images
00135     void NewPointChange(hugin_utils::FDiff2D p, bool left);
00136 //    void CreateNewPointRight(wxPoint p);
00137 
00139     void CreateNewPoint();
00140 
00142 //    bool FindTemplate(unsigned int tmplImgNr, const wxRect &region, unsigned int dstImgNr, vigra_ext::CorrelationResult & res);
00143 
00144     bool PointFineTune(unsigned int tmplImgNr,
00145                        const vigra::Diff2D &tmplPoint,
00146                        int tmplWidth,
00147                        unsigned int subjImgNr,
00148                        const hugin_utils::FDiff2D &subjPoint,
00149                        int searchWidth,
00150                        vigra_ext::CorrelationResult & tunedPos);
00151 
00152     const float getVerticalCPBias();
00153     // event handler functions
00154     void OnCPEvent(CPEvent &ev);
00155     void OnLeftChoiceChange(wxCommandEvent & e);
00156     void OnRightChoiceChange(wxCommandEvent & e);
00157     void OnCPListSelect(wxListEvent & e);
00158     void OnCPListDeselect(wxListEvent & e);
00159     void OnAddButton(wxCommandEvent & e);
00160     void OnZoom(wxCommandEvent & e);
00161     void OnTextPointChange(wxCommandEvent &e);
00162     void OnKey(wxKeyEvent & e);
00163     void OnDeleteButton(wxCommandEvent & e);
00164     void OnPrevImg(wxCommandEvent & e);
00165     void OnNextImg(wxCommandEvent & e);
00166 
00167     void OnColumnWidthChange( wxListEvent & e );
00168 
00169     void OnFineTuneButton(wxCommandEvent & e);
00170     void OnActionButton(wxCommandEvent& e);
00171     void OnCreateCPButton(wxCommandEvent& e);
00172     void OnCelesteButton(wxCommandEvent & e);
00173     void OnCleanCPButton(wxCommandEvent& e);
00174 
00175     void OnActionSelectCreate(wxCommandEvent& e);
00176     void OnActionSelectCeleste(wxCommandEvent& e);
00177     void OnActionSelectCleanCP(wxCommandEvent& e);
00178     void OnActionContextMenu(wxContextMenuEvent& e);
00179 
00180     void FineTuneSelectedPoint(bool left);
00181     void FineTuneNewPoint(bool left);
00182     // local fine tune
00183     hugin_utils::FDiff2D LocalFineTunePoint(unsigned int srcNr,
00184                                const vigra::Diff2D & srcPnt,
00185                                hugin_utils::FDiff2D & movedSrcPnt,
00186                                unsigned int moveNr,
00187                                const hugin_utils::FDiff2D & movePnt);
00188 
00194     hugin_utils::FDiff2D EstimatePoint(const hugin_utils::FDiff2D & p, bool left);
00195 
00196 
00200     enum CPCreationState { NO_POINT,  
00201                            LEFT_POINT, 
00202                            RIGHT_POINT, 
00203                            RIGHT_POINT_RETRY, 
00204                            LEFT_POINT_RETRY,  
00205                            BOTH_POINTS_SELECTED 
00206     };
00207     // used to change the point selection state
00208     void changeState(CPCreationState newState);
00209 
00211     void estimateAndAddOtherPoint(const hugin_utils::FDiff2D & p,
00212                                   bool left,
00213                                   CPImageCtrl * thisImg,
00214                                   unsigned int thisImgNr,
00215                                   CPCreationState THIS_POINT,
00216                                   CPCreationState THIS_POINT_RETRY,
00217                                   CPImageCtrl * otherImg,
00218                                   unsigned int otherImgNr,
00219                                   CPCreationState OTHER_POINT,
00220                                   CPCreationState OTHER_POINT_RETRY);
00221 
00223     CPImageCtrl::ImageRotation GetRot(double yaw, double roll, double pitch);
00225     void UpdateTransforms();
00226 
00227     CPCreationState cpCreationState;
00228 
00229     enum CPTabActionButtonMode
00230     {
00231         CPTAB_ACTION_CREATE_CP = 0,
00232         CPTAB_ACTION_CELESTE = 1,
00233         CPTAB_ACTION_CLEAN_CP = 2
00234     };
00235     CPTabActionButtonMode m_cpActionButtonMode;
00236     wxMenu* m_cpActionContextMenu;
00237     wxString m_currentCPDetector;
00238     // GUI controls
00239     CPImagesComboBox *m_leftChoice;
00240     CPImagesComboBox *m_rightChoice;
00241     CPImageCtrl *m_leftImg, *m_rightImg;
00242     wxListCtrl *m_cpList;
00243 
00244     wxTextCtrl *m_x1Text, *m_y1Text, *m_x2Text, *m_y2Text, *m_errorText;
00245     wxChoice *m_cpModeChoice;
00246     wxButton *m_addButton;
00247     wxButton *m_delButton;
00248     wxButton* m_actionButton;
00249     wxCheckBox *m_autoAddCB;
00250     wxCheckBox *m_fineTuneCB;
00251     wxCheckBox *m_estimateCB;
00252     wxPanel *m_cp_ctrls;
00253 
00254     // my data
00255     HuginBase::Panorama * m_pano;
00256     // the current images
00257     unsigned int m_leftImageNr;
00258     unsigned int m_rightImageNr;
00259     std::string m_leftFile;
00260     std::string m_rightFile;
00261     bool m_listenToPageChange;
00262     double m_detailZoomFactor;
00263     // store transformation for drawing line control points
00264     HuginBase::PTools::Transform m_leftTransform;
00265     HuginBase::PTools::Transform m_leftInvTransform;
00266     HuginBase::PTools::Transform m_rightTransform;
00267     HuginBase::PTools::Transform m_rightInvTransform;
00268 
00269     unsigned int m_selectedPoint;
00270 
00271     // contains the control points shown currently.
00272     HuginBase::CPointVector currentPoints;
00273     // this set contains all points that are mirrored (point 1 in right window,
00274     // point 2 in left window), in local point numbers
00275     std::set<unsigned int> mirroredPoints;
00276     size_t m_countCP;
00277 
00278     CPImageCtrl::ImageRotation m_leftRot;
00279     CPImageCtrl::ImageRotation m_rightRot;
00280 
00281     // needed for receiving events.
00282     DECLARE_EVENT_TABLE();
00283 
00284     DECLARE_DYNAMIC_CLASS(CPEditorPanel)
00285 
00286 };
00287 
00289 vigra_ext::CorrelationResult PointFineTuneProjectionAware(const HuginBase::SrcPanoImage& templ, const vigra::UInt8RGBImage& templImg,
00290     vigra::Diff2D templPos, int templSize,
00291     const SrcPanoImage& search, const vigra::UInt8RGBImage& searchImg,
00292     vigra::Diff2D searchPos, int sWidth);
00293 
00295 class CPEditorPanelXmlHandler : public wxXmlResourceHandler
00296 {
00297     DECLARE_DYNAMIC_CLASS(CPEditorPanelXmlHandler)
00298 
00299 public:
00300     CPEditorPanelXmlHandler();
00301     virtual wxObject *DoCreateResource();
00302     virtual bool CanHandle(wxXmlNode *node);
00303 };
00304 
00305 #endif // _CPEDITORPANEL_H

Generated on 27 Jul 2015 for Hugintrunk by  doxygen 1.4.7