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 <PT/Panorama.h>
00044 
00045 #include "CPImagesComboBox.h"
00046 
00047 #include "CPImageCtrl.h"
00048 
00049 namespace vigra {
00050     class Diff2D;
00051 }
00052 
00053 namespace vigra_ext{
00054     struct CorrelationResult;
00055 }
00056 
00063 class CPEditorPanel : public wxPanel, public PT::PanoramaObserver
00064 {
00065 public:
00068     CPEditorPanel();
00069 
00070     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"));
00071 
00072     void Init(PT::Panorama * pano);
00073 
00076     virtual ~CPEditorPanel();
00077 
00079     void setLeftImage(unsigned int imgNr);
00081     void setRightImage(unsigned int imgNr);
00082 
00083     void SetPano(PT::Panorama * panorama)
00084         { m_pano = panorama; };
00085 
00089     void panoramaChanged(PT::Panorama &pano);
00090     void panoramaImagesChanged(PT::Panorama &pano, const PT::UIntSet & imgNr);
00091 
00092 
00100     void SelectGlobalPoint(unsigned int globalNr);
00101 
00106     void ShowControlPoint(unsigned int cpNr);
00107 
00109     void ClearSelection();
00110 
00111 private:
00112 
00116     void UpdateDisplay(bool newImages);
00117 
00119     void EnablePointEdit(bool state);
00120 
00125     void SelectLocalPoint(unsigned int LVpointNr);
00126 
00128     bool globalPNr2LocalPNr(unsigned int & localNr, unsigned int globalNr) const;
00130     unsigned int localPNr2GlobalPNr(unsigned int localNr) const;
00131 
00132     // function called when a new point has been selected or changed
00133     // in one of your images
00134     void NewPointChange(hugin_utils::FDiff2D p, bool left);
00135 //    void CreateNewPointRight(wxPoint p);
00136 
00138     void CreateNewPoint();
00139 
00141 //    bool FindTemplate(unsigned int tmplImgNr, const wxRect &region, unsigned int dstImgNr, vigra_ext::CorrelationResult & res);
00142 
00143     bool PointFineTune(unsigned int tmplImgNr,
00144                        const vigra::Diff2D &tmplPoint,
00145                        int tmplWidth,
00146                        unsigned int subjImgNr,
00147                        const hugin_utils::FDiff2D &subjPoint,
00148                        int searchWidth,
00149                        vigra_ext::CorrelationResult & tunedPos);
00150 
00151     const float getVerticalCPBias();
00152     // event handler functions
00153     void OnMyButtonClicked(wxCommandEvent &e);
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 OnCelesteButton(wxCommandEvent & e);
00171 
00172     void FineTuneSelectedPoint(bool left);
00173     void FineTuneNewPoint(bool left);
00174     // local fine tune
00175     hugin_utils::FDiff2D LocalFineTunePoint(unsigned int srcNr,
00176                                const vigra::Diff2D & srcPnt,
00177                                unsigned int moveNr,
00178                                const hugin_utils::FDiff2D & movePnt);
00179 
00191     hugin_utils::FDiff2D EstimatePoint(const hugin_utils::FDiff2D & p, bool left);
00192 
00193 
00197     enum CPCreationState { NO_POINT,  
00198                            LEFT_POINT, 
00199                            RIGHT_POINT, 
00200                            RIGHT_POINT_RETRY, 
00201                            LEFT_POINT_RETRY,  
00202                            BOTH_POINTS_SELECTED 
00203     };
00204     // used to change the point selection state
00205     void changeState(CPCreationState newState);
00206 
00208     void estimateAndAddOtherPoint(const hugin_utils::FDiff2D & p,
00209                                   bool left,
00210                                   CPImageCtrl * thisImg,
00211                                   unsigned int thisImgNr,
00212                                   CPCreationState THIS_POINT,
00213                                   CPCreationState THIS_POINT_RETRY,
00214                                   CPImageCtrl * otherImg,
00215                                   unsigned int otherImgNr,
00216                                   CPCreationState OTHER_POINT,
00217                                   CPCreationState OTHER_POINT_RETRY);
00218 
00220     CPImageCtrl::ImageRotation GetRot(double yaw, double roll, double pitch);
00222     void UpdateTransforms();
00223 
00224     CPCreationState cpCreationState;
00225 
00226     // GUI controls
00227     CPImagesComboBox *m_leftChoice;
00228     CPImagesComboBox *m_rightChoice;
00229     CPImageCtrl *m_leftImg, *m_rightImg;
00230     wxListCtrl *m_cpList;
00231 
00232     wxTextCtrl *m_x1Text, *m_y1Text, *m_x2Text, *m_y2Text, *m_errorText;
00233     wxChoice *m_cpModeChoice;
00234     wxButton *m_addButton;
00235     wxButton *m_delButton;
00236     wxCheckBox *m_autoAddCB;
00237     wxCheckBox *m_fineTuneCB;
00238     wxCheckBox *m_estimateCB;
00239     wxPanel *m_cp_ctrls;
00240 
00241     // my data
00242     PT::Panorama * m_pano;
00243     // the current images
00244     unsigned int m_leftImageNr;
00245     unsigned int m_rightImageNr;
00246     std::string m_leftFile;
00247     std::string m_rightFile;
00248     bool m_listenToPageChange;
00249     double m_detailZoomFactor;
00250     // store transformation for drawing line control points
00251     PTools::Transform m_leftTransform;
00252     PTools::Transform m_leftInvTransform;
00253     PTools::Transform m_rightTransform;
00254     PTools::Transform m_rightInvTransform;
00255 
00256     unsigned int m_selectedPoint;
00257 
00258     // contains the control points shown currently.
00259     HuginBase::CPointVector currentPoints;
00260     // this set contains all points that are mirrored (point 1 in right window,
00261     // point 2 in left window), in local point numbers
00262     std::set<unsigned int> mirroredPoints;
00263 
00264     CPImageCtrl::ImageRotation m_leftRot;
00265     CPImageCtrl::ImageRotation m_rightRot;
00266 
00267     // needed for receiving events.
00268     DECLARE_EVENT_TABLE();
00269 
00270     DECLARE_DYNAMIC_CLASS(CPEditorPanel)
00271 
00272 };
00273 
00275 class CPEditorPanelXmlHandler : public wxXmlResourceHandler
00276 {
00277     DECLARE_DYNAMIC_CLASS(CPEditorPanelXmlHandler)
00278 
00279 public:
00280     CPEditorPanelXmlHandler();
00281     virtual wxObject *DoCreateResource();
00282     virtual bool CanHandle(wxXmlNode *node);
00283 };
00284 
00285 #endif // _CPEDITORPANEL_H

Generated on Fri Apr 25 01:25:30 2014 for Hugintrunk by  doxygen 1.3.9.1