Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages
hugin1/hugin/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 // Always use wxChoice, the tabs behave badly with many images on GTK as well. 00048 #define HUGIN_CP_IMG_CHOICE 00049 00050 // Do not use a splitter between the ctrl points list and the images 00051 //#define HUGIN_CP_USE_SPLITTER 00052 00053 //#ifdef __WXMAC__ 00055 //#define HUGIN_CP_IMG_CHOICE 00056 //#else 00058 //#define HUGIN_CP_IMG_TAB 00059 //#endif 00060 00061 #include "CPImageCtrl.h" 00062 00063 // forward declarations 00064 /* 00065 class CPImageCtrl; 00066 class CPEvent; 00067 class wxTabView; 00068 class wxNotebook; 00069 class wxNotebookEvent; 00070 class wxListEvent; 00071 class wxListCtrl; 00072 */ 00073 00074 //class CPFineTuneFrame; 00075 00076 namespace vigra { 00077 class Diff2D; 00078 } 00079 00080 namespace vigra_ext{ 00081 struct CorrelationResult; 00082 } 00083 00084 00091 class CPEditorPanel : public wxPanel, public PT::PanoramaObserver 00092 { 00093 public: 00096 CPEditorPanel(); 00097 00098 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")); 00099 00100 void Init(PT::Panorama * pano); 00101 00104 virtual ~CPEditorPanel(); 00105 00107 void setLeftImage(unsigned int imgNr); 00109 void setRightImage(unsigned int imgNr); 00110 00111 void SetPano(PT::Panorama * panorama) 00112 { m_pano = panorama; }; 00113 00117 void panoramaChanged(PT::Panorama &pano); 00118 void panoramaImagesChanged(PT::Panorama &pano, const PT::UIntSet & imgNr); 00119 00120 00128 void SelectGlobalPoint(unsigned int globalNr); 00129 00134 void ShowControlPoint(unsigned int cpNr); 00135 00137 void ClearSelection(); 00138 00139 private: 00140 00144 void UpdateDisplay(bool newImages); 00145 00147 void EnablePointEdit(bool state); 00148 00153 void SelectLocalPoint(unsigned int LVpointNr); 00154 00156 bool globalPNr2LocalPNr(unsigned int & localNr, unsigned int globalNr) const; 00158 unsigned int localPNr2GlobalPNr(unsigned int localNr) const; 00159 00160 // function called when a new point has been selected or changed 00161 // in one of your images 00162 void NewPointChange(hugin_utils::FDiff2D p, bool left); 00163 // void CreateNewPointRight(wxPoint p); 00164 00166 void CreateNewPoint(); 00167 00168 00170 // bool FindTemplate(unsigned int tmplImgNr, const wxRect ®ion, unsigned int dstImgNr, vigra_ext::CorrelationResult & res); 00171 00172 bool PointFineTune(unsigned int tmplImgNr, 00173 const vigra::Diff2D &tmplPoint, 00174 int tmplWidth, 00175 unsigned int subjImgNr, 00176 const hugin_utils::FDiff2D &subjPoint, 00177 int searchWidth, 00178 vigra_ext::CorrelationResult & tunedPos); 00179 00180 const float getVerticalCPBias(); 00181 // event handler functions 00182 void OnMyButtonClicked(wxCommandEvent &e); 00183 void OnCPEvent(CPEvent &ev); 00184 #ifdef HUGIN_CP_IMG_CHOICE 00185 void OnLeftChoiceChange(wxCommandEvent & e); 00186 void OnRightChoiceChange(wxCommandEvent & e); 00187 #endif 00188 #ifdef HUGIN_CP_IMG_TAB 00189 void OnLeftImgChange(wxNotebookEvent & e); 00190 void OnRightImgChange(wxNotebookEvent & e); 00191 #endif 00192 void OnCPListSelect(wxListEvent & e); 00193 void OnAddButton(wxCommandEvent & e); 00194 void OnZoom(wxCommandEvent & e); 00195 void OnTextPointChange(wxCommandEvent &e); 00196 void OnKey(wxKeyEvent & e); 00197 void OnKeyDown(wxKeyEvent & e); 00198 void OnKeyUp(wxKeyEvent & e); 00199 void OnDeleteButton(wxCommandEvent & e); 00200 void OnAutoAddCB(wxCommandEvent & e); 00201 void OnPrevImg(wxCommandEvent & e); 00202 void OnNextImg(wxCommandEvent & e); 00203 00204 void OnColumnWidthChange( wxListEvent & e ); 00205 00206 void OnFineTuneButton(wxCommandEvent & e); 00207 void OnCelesteButton(wxCommandEvent & e); 00208 00209 void OnSize(wxSizeEvent & e); 00210 00211 void FineTuneSelectedPoint(bool left); 00212 void FineTuneNewPoint(bool left); 00213 // local fine tune 00214 hugin_utils::FDiff2D LocalFineTunePoint(unsigned int srcNr, 00215 const vigra::Diff2D & srcPnt, 00216 unsigned int moveNr, 00217 const hugin_utils::FDiff2D & movePnt); 00218 00219 // experimental corner detector. 00220 void OnAutoCreateCP(); 00221 00233 hugin_utils::FDiff2D EstimatePoint(const hugin_utils::FDiff2D & p, bool left); 00234 00235 00239 enum CPCreationState { NO_POINT, 00240 LEFT_POINT, 00241 RIGHT_POINT, 00242 RIGHT_POINT_RETRY, 00243 LEFT_POINT_RETRY, 00244 BOTH_POINTS_SELECTED 00245 }; 00246 // used to change the point selection state 00247 void changeState(CPCreationState newState); 00248 00250 void estimateAndAddOtherPoint(const hugin_utils::FDiff2D & p, 00251 bool left, 00252 CPImageCtrl * thisImg, 00253 unsigned int thisImgNr, 00254 CPCreationState THIS_POINT, 00255 CPCreationState THIS_POINT_RETRY, 00256 CPImageCtrl * otherImg, 00257 unsigned int otherImgNr, 00258 CPCreationState OTHER_POINT, 00259 CPCreationState OTHER_POINT_RETRY); 00260 00262 CPImageCtrl::ImageRotation GetRot(double yaw, double roll, double pitch); 00263 00264 CPCreationState cpCreationState; 00265 00266 00267 // GUI controls 00268 #ifdef HUGIN_CP_IMG_CHOICE 00269 CPImagesComboBox *m_leftChoice; 00270 CPImagesComboBox *m_rightChoice; 00271 #endif 00272 #ifdef HUGIN_CP_IMG_TAB 00273 wxNotebook *m_leftTabs, *m_rightTabs; 00274 #endif 00275 CPImageCtrl *m_leftImg, *m_rightImg; 00276 //CPFineTuneFrame * m_fineTuneFrame; 00277 wxListCtrl *m_cpList; 00278 00279 wxTextCtrl *m_x1Text, *m_y1Text, *m_x2Text, *m_y2Text, *m_errorText; 00280 wxChoice *m_cpModeChoice; 00281 wxButton *m_addButton; 00282 wxButton *m_delButton; 00283 wxCheckBox *m_autoAddCB; 00284 wxCheckBox *m_fineTuneCB; 00285 wxCheckBox *m_estimateCB; 00286 wxPanel *m_cp_ctrls; 00287 #ifdef HUGIN_CP_USE_SPLITTER 00288 wxSplitterWindow *m_cp_splitter; 00289 #endif 00290 //wxSplitterWindow *m_cp_splitter_img; 00291 00292 // my data 00293 PT::Panorama * m_pano; 00294 // the current images 00295 unsigned int m_leftImageNr; 00296 unsigned int m_rightImageNr; 00297 std::string m_leftFile; 00298 std::string m_rightFile; 00299 bool m_listenToPageChange; 00300 double m_detailZoomFactor; 00301 00302 unsigned int m_selectedPoint; 00303 unsigned int m_cursorType; 00304 00305 // pair of global control point number and corrosponding control point 00306 typedef std::pair<unsigned int, PT::ControlPoint> CPoint; 00307 00308 // contains the control points shown currently. 00309 std::vector<CPoint> currentPoints; 00310 // this set contains all points that are mirrored (point 1 in right window, 00311 // point 2 in left window), in local point numbers 00312 std::set<unsigned int> mirroredPoints; 00313 00314 CPImageCtrl::ImageRotation m_leftRot; 00315 CPImageCtrl::ImageRotation m_rightRot; 00316 00317 // needed for receiving events. 00318 DECLARE_EVENT_TABLE(); 00319 00320 DECLARE_DYNAMIC_CLASS(CPEditorPanel) 00321 00322 }; 00323 00325 class CPEditorPanelXmlHandler : public wxXmlResourceHandler 00326 { 00327 DECLARE_DYNAMIC_CLASS(CPEditorPanelXmlHandler) 00328 00329 public: 00330 CPEditorPanelXmlHandler(); 00331 virtual wxObject *DoCreateResource(); 00332 virtual bool CanHandle(wxXmlNode *node); 00333 }; 00334 00335 00336 #endif // _CPEDITORPANEL_H
1.3.9.1