Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

[3ff100]: src / hugin1 / hugin / CPEditorPanel.h Maximize Restore History

Download this file

CPEditorPanel.h    287 lines (233 with data), 9.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
// -*- c-basic-offset: 4 -*-
/** @file CPEditorPanel.h
*
* @author Pablo d'Angelo <pablo.dangelo@web.de>
*
* $Id$
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef _CPEDITORPANEL_H
#define _CPEDITORPANEL_H
//-----------------------------------------------------------------------------
// Headers
//-----------------------------------------------------------------------------
#include <vector>
#include <set>
#include <functional>
#include <utility>
#include <string>
// Celeste files
#include "Celeste.h"
#include "CelesteGlobals.h"
#include "Utilities.h"
#include <PT/Panorama.h>
#include "CPImagesComboBox.h"
#include "CPImageCtrl.h"
namespace vigra {
class Diff2D;
}
namespace vigra_ext{
struct CorrelationResult;
}
/** control point editor panel.
*
* This panel is used to create/change/edit control points
*
* @todo support control lines
*/
class CPEditorPanel : public wxPanel, public PT::PanoramaObserver
{
public:
/** ctor.
*/
CPEditorPanel();
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"));
void Init(PT::Panorama * pano);
/** dtor.
*/
virtual ~CPEditorPanel();
/// set left image
void setLeftImage(unsigned int imgNr);
/// set right image
void setRightImage(unsigned int imgNr);
void SetPano(PT::Panorama * panorama)
{ m_pano = panorama; };
/** called when the panorama changes and we should
* update our display
*/
void panoramaChanged(PT::Panorama &pano);
void panoramaImagesChanged(PT::Panorama &pano, const PT::UIntSet & imgNr);
/** Select a point.
*
* This should highlight it in the listview and on the pictures.
*
* Does not change the pictures. The control point must be on the
* two existing images
*/
void SelectGlobalPoint(unsigned int globalNr);
/** show a control point
*
* show control point @p cpNr and the corrosponding images
*/
void ShowControlPoint(unsigned int cpNr);
/** unselect a point */
void ClearSelection();
private:
/** updates the display after another image has been selected.
* updates control points, and other widgets
*/
void UpdateDisplay(bool newImages);
/** enable or disable controls for editing other points */
void EnablePointEdit(bool state);
/** select a local point.
*
* @todo scroll windows so that the point is centred
*/
void SelectLocalPoint(unsigned int LVpointNr);
/// map a global point nr to a local one, if possible
bool globalPNr2LocalPNr(unsigned int & localNr, unsigned int globalNr) const;
/// find a local point
unsigned int localPNr2GlobalPNr(unsigned int localNr) const;
// function called when a new point has been selected or changed
// in one of your images
void NewPointChange(hugin_utils::FDiff2D p, bool left);
// void CreateNewPointRight(wxPoint p);
/// this is used to finally create the point in the panorama model
void CreateNewPoint();
/// search for region in destImg
// bool FindTemplate(unsigned int tmplImgNr, const wxRect &region, unsigned int dstImgNr, vigra_ext::CorrelationResult & res);
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);
const float getVerticalCPBias();
// event handler functions
void OnMyButtonClicked(wxCommandEvent &e);
void OnCPEvent(CPEvent &ev);
void OnLeftChoiceChange(wxCommandEvent & e);
void OnRightChoiceChange(wxCommandEvent & e);
void OnCPListSelect(wxListEvent & e);
void OnCPListDeselect(wxListEvent & e);
void OnAddButton(wxCommandEvent & e);
void OnZoom(wxCommandEvent & e);
void OnTextPointChange(wxCommandEvent &e);
void OnKey(wxKeyEvent & e);
void OnDeleteButton(wxCommandEvent & e);
void OnPrevImg(wxCommandEvent & e);
void OnNextImg(wxCommandEvent & e);
void OnColumnWidthChange( wxListEvent & e );
void OnFineTuneButton(wxCommandEvent & e);
void OnCelesteButton(wxCommandEvent & e);
void FineTuneSelectedPoint(bool left);
void FineTuneNewPoint(bool left);
// local fine tune
hugin_utils::FDiff2D LocalFineTunePoint(unsigned int srcNr,
const vigra::Diff2D & srcPnt,
hugin_utils::FDiff2D & movedSrcPnt,
unsigned int moveNr,
const hugin_utils::FDiff2D & movePnt);
/** Estimate position of point in the other image
*
* @param p point to warp to other image
* @param left true if p is located in left image.
*/
hugin_utils::FDiff2D EstimatePoint(const hugin_utils::FDiff2D & p, bool left);
/** the state machine for point selection:
* it is set to the current selection
*/
enum CPCreationState { NO_POINT, ///< no point selected
LEFT_POINT, ///< point in left image selected
RIGHT_POINT, ///< selected point in right image
RIGHT_POINT_RETRY, ///< point in left image selected, finetune failed in right image
LEFT_POINT_RETRY, ///< right point, finetune for left point failed
BOTH_POINTS_SELECTED ///< left and right point selected, waiting for add point.
};
// used to change the point selection state
void changeState(CPCreationState newState);
/** estimate and set point in other image */
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);
/** calculate rotation required for upright image display from roll, pitch and yaw angles */
CPImageCtrl::ImageRotation GetRot(double yaw, double roll, double pitch);
/** updated the internal transform object for drawing line in controls */
void UpdateTransforms();
CPCreationState cpCreationState;
// GUI controls
CPImagesComboBox *m_leftChoice;
CPImagesComboBox *m_rightChoice;
CPImageCtrl *m_leftImg, *m_rightImg;
wxListCtrl *m_cpList;
wxTextCtrl *m_x1Text, *m_y1Text, *m_x2Text, *m_y2Text, *m_errorText;
wxChoice *m_cpModeChoice;
wxButton *m_addButton;
wxButton *m_delButton;
wxCheckBox *m_autoAddCB;
wxCheckBox *m_fineTuneCB;
wxCheckBox *m_estimateCB;
wxPanel *m_cp_ctrls;
// my data
PT::Panorama * m_pano;
// the current images
unsigned int m_leftImageNr;
unsigned int m_rightImageNr;
std::string m_leftFile;
std::string m_rightFile;
bool m_listenToPageChange;
double m_detailZoomFactor;
// store transformation for drawing line control points
PTools::Transform m_leftTransform;
PTools::Transform m_leftInvTransform;
PTools::Transform m_rightTransform;
PTools::Transform m_rightInvTransform;
unsigned int m_selectedPoint;
// contains the control points shown currently.
HuginBase::CPointVector currentPoints;
// this set contains all points that are mirrored (point 1 in right window,
// point 2 in left window), in local point numbers
std::set<unsigned int> mirroredPoints;
CPImageCtrl::ImageRotation m_leftRot;
CPImageCtrl::ImageRotation m_rightRot;
// needed for receiving events.
DECLARE_EVENT_TABLE();
DECLARE_DYNAMIC_CLASS(CPEditorPanel)
};
/** function for fine-tune with remapping to stereographic projection */
vigra_ext::CorrelationResult PointFineTuneProjectionAware(const SrcPanoImage& templ, const vigra::UInt8RGBImage& templImg,
vigra::Diff2D templPos, int templSize,
const SrcPanoImage& search, const vigra::UInt8RGBImage& searchImg,
vigra::Diff2D searchPos, int sWidth);
/** xrc handler */
class CPEditorPanelXmlHandler : public wxXmlResourceHandler
{
DECLARE_DYNAMIC_CLASS(CPEditorPanelXmlHandler)
public:
CPEditorPanelXmlHandler();
virtual wxObject *DoCreateResource();
virtual bool CanHandle(wxXmlNode *node);
};
#endif // _CPEDITORPANEL_H