Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CPEditorPanel.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
24 #ifndef _CPEDITORPANEL_H
25 #define _CPEDITORPANEL_H
26 
27 
28 //-----------------------------------------------------------------------------
29 // Headers
30 //-----------------------------------------------------------------------------
31 
32 #include <vector>
33 #include <set>
34 #include <functional>
35 #include <utility>
36 #include <string>
37 
38 // Celeste files
39 #include "Celeste.h"
40 #include "CelesteGlobals.h"
41 #include "Utilities.h"
42 
43 #include <panodata/Panorama.h>
44 
45 #include "CPImagesComboBox.h"
46 
47 #include "CPImageCtrl.h"
49 
50 namespace vigra {
51  class Diff2D;
52 }
53 
54 namespace vigra_ext{
55  struct CorrelationResult;
56 }
57 
64 class CPEditorPanel : public wxPanel, public HuginBase::PanoramaObserver
65 {
66 public:
69  CPEditorPanel();
70 
71  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"));
72 
73  void Init(HuginBase::Panorama * pano);
74 
77  virtual ~CPEditorPanel();
78 
80  void setLeftImage(unsigned int imgNr);
82  void setRightImage(unsigned int imgNr);
83 
84  void SetPano(HuginBase::Panorama * panorama)
85  { m_pano = panorama; };
86 
92 
93 
101  void SelectGlobalPoint(unsigned int globalNr);
102 
107  void ShowControlPoint(unsigned int cpNr);
108 
110  void ClearSelection();
111 
112 private:
113 
117  void UpdateDisplay(bool newImages);
118 
120  void EnablePointEdit(bool state);
121 
127  void SelectLocalPoint(unsigned int LVpointNr, bool scrollLeft = true, bool scrollRight = true);
128 
130  bool globalPNr2LocalPNr(unsigned int & localNr, unsigned int globalNr) const;
132  unsigned int localPNr2GlobalPNr(unsigned int localNr) const;
133 
134  // function called when a new point has been selected or changed
135  // in one of your images
136  void NewPointChange(hugin_utils::FDiff2D p, bool left);
137 // void CreateNewPointRight(wxPoint p);
138 
140  void CreateNewPoint();
141 
143 // bool FindTemplate(unsigned int tmplImgNr, const wxRect &region, unsigned int dstImgNr, vigra_ext::CorrelationResult & res);
144 
145  bool PointFineTune(unsigned int tmplImgNr,
146  const vigra::Diff2D &tmplPoint,
147  int tmplWidth,
148  unsigned int subjImgNr,
149  const hugin_utils::FDiff2D &subjPoint,
150  int searchWidth,
151  vigra_ext::CorrelationResult & tunedPos);
152 
153  const float getVerticalCPBias();
154  // event handler functions
155  void OnCPEvent(CPEvent &ev);
156  void OnLeftChoiceChange(wxCommandEvent & e);
157  void OnRightChoiceChange(wxCommandEvent & e);
158  void OnCPListSelect(wxListEvent & e);
159  void OnCPListDeselect(wxListEvent & e);
160  void OnAddButton(wxCommandEvent & e);
161  void OnZoom(wxCommandEvent & e);
162  void OnTextPointChange(wxCommandEvent &e);
163  void OnKey(wxKeyEvent & e);
164  void OnDeleteButton(wxCommandEvent & e);
165  void OnPrevImg(wxCommandEvent & e);
166  void OnNextImg(wxCommandEvent & e);
167 
168  void OnColumnWidthChange( wxListEvent & e );
169  void OnColumnHeaderClick(wxListEvent & e);
170 
171  void OnFineTuneButton(wxCommandEvent & e);
172  void OnActionButton(wxCommandEvent& e);
173  void OnCreateCPButton(wxCommandEvent& e);
174  void OnCelesteButton(wxCommandEvent & e);
175  void OnCleanCPButton(wxCommandEvent& e);
176  void OnShowLinesCheckbox(wxCommandEvent& e);
177 
178  void OnActionSelectCreate(wxCommandEvent& e);
179  void OnActionSelectCeleste(wxCommandEvent& e);
180  void OnActionSelectCleanCP(wxCommandEvent& e);
181  void OnActionContextMenu(wxContextMenuEvent& e);
182 
183  void FineTuneSelectedPoint(bool left);
184  void FineTuneNewPoint(bool left);
185  // local fine tune
186  hugin_utils::FDiff2D LocalFineTunePoint(unsigned int srcNr,
187  const vigra::Diff2D & srcPnt,
188  hugin_utils::FDiff2D & movedSrcPnt,
189  unsigned int moveNr,
190  const hugin_utils::FDiff2D & movePnt);
191 
198 
199 
209  };
210  // used to change the point selection state
211  void changeState(CPCreationState newState);
212 
215  bool left,
216  CPImageCtrl * thisImg,
217  unsigned int thisImgNr,
218  CPCreationState THIS_POINT,
219  CPCreationState THIS_POINT_RETRY,
220  CPImageCtrl * otherImg,
221  unsigned int otherImgNr,
222  CPCreationState OTHER_POINT,
223  CPCreationState OTHER_POINT_RETRY);
224 
226  CPImageCtrl::ImageRotation GetRot(double yaw, double roll, double pitch);
228  void UpdateTransforms();
230  void SortList();
231 
233 
235  {
239  };
243  // GUI controls
247  wxListCtrl *m_cpList;
248 
250  wxChoice *m_cpModeChoice;
251  wxButton *m_addButton;
252  wxButton *m_delButton;
253  wxButton* m_actionButton;
254  wxCheckBox *m_autoAddCB;
255  wxCheckBox *m_fineTuneCB;
256  wxCheckBox *m_estimateCB;
257  wxCheckBox *m_showLinesCB;
258  wxPanel *m_cp_ctrls;
259 
260  // my data
262  // the current images
263  unsigned int m_leftImageNr;
264  unsigned int m_rightImageNr;
265  std::string m_leftFile;
266  std::string m_rightFile;
269  // store transformation for drawing line control points
274  // store transformation for drawing the magnifier
279 
280  unsigned int m_selectedPoint;
281 
282  // contains the control points shown currently.
284  // this set contains all points that are mirrored (point 1 in right window,
285  // point 2 in left window), in local point numbers
286  std::set<unsigned int> mirroredPoints;
287  size_t m_countCP;
288  // store current sorting column
289  long m_sortCol = -1;
290  bool m_sortAscending = true;
291 
294 
296  {
300  } ;
302 
303 
304  // needed for receiving events.
306 
307  DECLARE_DYNAMIC_CLASS(CPEditorPanel)
308 
309 };
310 
312 vigra_ext::CorrelationResult PointFineTuneProjectionAware(const HuginBase::SrcPanoImage& templ, const vigra::UInt8RGBImage& templImg,
313  vigra::Diff2D templPos, int templSize,
314  const HuginBase::SrcPanoImage& search, const vigra::UInt8RGBImage& searchImg,
315  vigra::Diff2D searchPos, int sWidth);
316 
318 class CPEditorPanelXmlHandler : public wxXmlResourceHandler
319 {
320  DECLARE_DYNAMIC_CLASS(CPEditorPanelXmlHandler)
321 
322 public:
324  virtual wxObject *DoCreateResource();
325  virtual bool CanHandle(wxXmlNode *node);
326 };
327 
328 #endif // _CPEDITORPANEL_H
void OnColumnHeaderClick(wxListEvent &e)
void SelectGlobalPoint(unsigned int globalNr)
Select a point.
void NewPointChange(hugin_utils::FDiff2D p, bool left)
HuginBase::PTools::Transform m_leftInvTransformMag
virtual wxObject * DoCreateResource()
wxCheckBox * m_autoAddCB
vigra_ext::CorrelationResult PointFineTuneProjectionAware(const HuginBase::SrcPanoImage &templ, const vigra::UInt8RGBImage &templImg, vigra::Diff2D templPos, int templSize, const HuginBase::SrcPanoImage &search, const vigra::UInt8RGBImage &searchImg, vigra::Diff2D searchPos, int sWidth)
function for fine-tune with remapping to stereographic projection
wxString m_currentCPDetector
wxMenu * m_cpActionContextMenu
CPImagesComboBox * m_leftChoice
wxButton * m_addButton
void SortList()
sorting functions
control point editor panel.
Definition: CPEditorPanel.h:64
bool PointFineTune(unsigned int tmplImgNr, const vigra::Diff2D &tmplPoint, int tmplWidth, unsigned int subjImgNr, const hugin_utils::FDiff2D &subjPoint, int searchWidth, vigra_ext::CorrelationResult &tunedPos)
search for region in destImg
void OnCPListDeselect(wxListEvent &e)
CPImagesComboBox * m_rightChoice
virtual bool CanHandle(wxXmlNode *node)
Definition of CPImagesComboBox and CPImagesComboBoxXmlHandler class.
void OnAddButton(wxCommandEvent &e)
no point selected
void OnCreateCPButton(wxCommandEvent &e)
void OnCPListSelect(wxListEvent &e)
CPTabActionButtonMode m_cpActionButtonMode
Events to notify about new point / region / point change.
Definition: CPImageCtrl.h:40
CPImageCtrl * m_rightImg
wxTextCtrl * m_x1Text
void FineTuneSelectedPoint(bool left)
void OnKey(wxKeyEvent &e)
void OnFineTuneButton(wxCommandEvent &e)
wxTextCtrl * m_y1Text
void setLeftImage(unsigned int imgNr)
set left image
wxTextCtrl * m_y2Text
Owner Drawn ComboBox for showing connected images on CP tab.
brief description.
Definition: CPImageCtrl.h:186
void EnablePointEdit(bool state)
enable or disable controls for editing other points
void OnNextImg(wxCommandEvent &e)
void ShowControlPoint(unsigned int cpNr)
show a control point
void SetPano(HuginBase::Panorama *panorama)
Definition: CPEditorPanel.h:84
void OnActionContextMenu(wxContextMenuEvent &e)
virtual ~CPEditorPanel()
dtor.
void OnActionButton(wxCommandEvent &e)
unsigned int m_leftImageNr
std::set< unsigned int > UIntSet
Definition: PanoramaData.h:51
void OnCleanCPButton(wxCommandEvent &e)
void OnTextPointChange(wxCommandEvent &e)
Model for a panorama.
Definition: Panorama.h:152
wxCheckBox * m_fineTuneCB
right point, finetune for left point failed
void OnLeftChoiceChange(wxCommandEvent &e)
wxTextCtrl * m_errorText
wxCheckBox * m_showLinesCB
void CreateNewPoint()
this is used to finally create the point in the panorama model
void OnZoom(wxCommandEvent &e)
wxPanel * m_cp_ctrls
CPCreationState
the state machine for point selection: it is set to the current selection
void FineTuneNewPoint(bool left)
CPImageCtrl::ImageRotation GetRot(double yaw, double roll, double pitch)
calculate rotation required for upright image display from roll, pitch and yaw angles ...
hugin_utils::FDiff2D EstimatePoint(const hugin_utils::FDiff2D &p, bool left)
Estimate position of point in the other image.
HuginBase::PTools::Transform m_rightTransform
CPImageCtrl * m_leftImg
Maximum of correlation, position and value.
Definition: Correlation.h:56
void OnDeleteButton(wxCommandEvent &e)
bool globalPNr2LocalPNr(unsigned int &localNr, unsigned int globalNr) const
map a global point nr to a local one, if possible
wxListCtrl * m_cpList
CPCreationState cpCreationState
unsigned int localPNr2GlobalPNr(unsigned int localNr) const
find a local point
void OnActionSelectCleanCP(wxCommandEvent &e)
void OnActionSelectCeleste(wxCommandEvent &e)
point in left image selected
void OnShowLinesCheckbox(wxCommandEvent &e)
std::set< unsigned int > mirroredPoints
CPImageCtrl::ImageRotation m_rightRot
HuginBase::PTools::Transform m_leftTransformMag
std::string m_leftFile
void ClearSelection()
unselect a point
HuginBase::PTools::Transform m_leftInvTransform
HuginBase::PTools::Transform m_rightInvTransform
std::string m_rightFile
std::vector< CPoint > CPointVector
Definition: ControlPoint.h:102
CPImageCtrl::ImageRotation m_leftRot
wxButton * m_delButton
wxButton * m_actionButton
unsigned int m_rightImageNr
void Init(HuginBase::Panorama *pano)
void estimateAndAddOtherPoint(const hugin_utils::FDiff2D &p, bool left, CPImageCtrl *thisImg, unsigned int thisImgNr, CPCreationState THIS_POINT, CPCreationState THIS_POINT_RETRY, CPImageCtrl *otherImg, unsigned int otherImgNr, CPCreationState OTHER_POINT, CPCreationState OTHER_POINT_RETRY)
estimate and set point in other image
void OnCPEvent(CPEvent &ev)
void changeState(CPCreationState newState)
void UpdateTransforms()
updated the internal transform object for drawing line in controls
void OnPrevImg(wxCommandEvent &e)
void OnRightChoiceChange(wxCommandEvent &e)
this handler class will receive change events from the Panorama.
Definition: PanoramaData.h:401
void SelectLocalPoint(unsigned int LVpointNr, bool scrollLeft=true, bool scrollRight=true)
select a local point.
HuginBase::Panorama * m_pano
void setRightImage(unsigned int imgNr)
set right image
CPScrollHint m_scrollHint
void panoramaChanged(HuginBase::Panorama &pano)
called when the panorama changes and we should update our display
void OnActionSelectCreate(wxCommandEvent &e)
void OnColumnWidthChange(wxListEvent &e)
CPEditorPanel()
ctor.
Holds transformations for Image -&gt; Pano and the other way.
HuginBase::PTools::Transform m_rightInvTransformMag
const float getVerticalCPBias()
bool m_listenToPageChange
HuginBase::PTools::Transform m_rightTransformMag
wxCheckBox * m_estimateCB
selected point in right image
wxChoice * m_cpModeChoice
point in left image selected, finetune failed in right image
hugin_utils::FDiff2D LocalFineTunePoint(unsigned int srcNr, const vigra::Diff2D &srcPnt, hugin_utils::FDiff2D &movedSrcPnt, unsigned int moveNr, const hugin_utils::FDiff2D &movePnt)
HuginBase::PTools::Transform m_leftTransform
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"))
All variables of a source image.
Definition: SrcPanoImage.h:194
HuginBase::CPointVector currentPoints
left and right point selected, waiting for add point.
double m_detailZoomFactor
void OnCelesteButton(wxCommandEvent &e)
ImageRotation
image rotation.
Definition: CPImageCtrl.h:258
void panoramaImagesChanged(HuginBase::Panorama &pano, const HuginBase::UIntSet &imgNr)
notifies about changes to images
unsigned int m_selectedPoint
void UpdateDisplay(bool newImages)
updates the display after another image has been selected.
wxTextCtrl * m_x2Text