27 #include "hugin_config.h"
46 std::string
makePairId(
unsigned int id1,
unsigned int id2)
50 std::ostringstream oss;
53 oss << id1 <<
"_" << id2;
56 oss << id2 <<
"_" << id1;
73 wxConfigBase* config = wxConfig::Get();
74 config->Write(wxT(
"/CPListFrame/SortColumn"),
m_sortCol);
75 config->Write(wxT(
"/CPListFrame/SortAscending"),
m_sortAscend ? 1 : 0);
84 const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
86 if (!wxListCtrl::Create(parent,
id, pos, size, style))
90 InsertColumn(0, _(
"G CP#"), wxLIST_FORMAT_RIGHT, 25);
91 InsertColumn(1, _(
"Left Img."), wxLIST_FORMAT_RIGHT, 65);
92 InsertColumn(2, _(
"Right Img."), wxLIST_FORMAT_RIGHT, 65);
93 InsertColumn(3, _(
"P CP#"), wxLIST_FORMAT_RIGHT, 25);
94 InsertColumn(4, _(
"Alignment"), wxLIST_FORMAT_LEFT, 80);
95 InsertColumn(5,
MainFrame::Get()->IsShowingCorrelation() ? _(
"Correlation") : _(
"Distance"), wxLIST_FORMAT_RIGHT, 80);
98 for (
int j = 0; j < GetColumnCount(); j++)
101 int width = wxConfigBase::Get()->Read(wxString::Format(wxT(
"/CPListFrame/ColumnWidth%d"), j), -1);
104 SetColumnWidth(j, width);
107 EnableAlternateRowColours(
true);
109 wxConfigBase* config = wxConfig::Get();
110 m_sortCol=config->Read(wxT(
"/CPListFrame/SortColumn"), 0l);
111 m_sortAscend = config->Read(wxT(
"/CPListFrame/SortAscending"), 1l) == 1;
134 return wxEmptyString;
140 return wxString::Format(wxT(
"%lu"), static_cast<unsigned long>(
m_internalCPList[item].globalIndex));
143 return wxString::Format(wxT(
"%u"), cp.
image1Nr);
146 return wxString::Format(wxT(
"%u"), cp.
image2Nr);
149 return wxString::Format(wxT(
"%lu"), static_cast<unsigned long>(
m_internalCPList[item].localNumber));
155 return wxString(_(
"normal"));
158 return wxString(_(
"vert. Line"));
161 return wxString(_(
"horiz. Line"));
164 return wxString::Format(_(
"Line %d"), cp.
mode);
169 return wxString::Format(wxT(
"%.2f"), cp.
error);
172 return wxEmptyString;
174 return wxEmptyString;
187 if (GetColumn(5, item))
189 if (isShowingCorrelation)
191 item.SetText(_(
"Correlation"));
195 item.SetText(_(
"Distance"));
199 XRCCTRL(*GetParent(),
"cp_list_select", wxButton)->SetLabel(isShowingCorrelation ? _(
"Select by Correlation") : _(
"Select by Distance"));
214 for (
size_t i = 0; i < cps.size(); i++)
224 std::map<std::string, int>::iterator it =
m_localIds.find(pairId);
241 #define CompareStruct(VAR, TYPESUFFIX, OP) \
242 struct Compare##TYPESUFFIX\
244 bool operator()(const CPListItem& item1, const CPListItem& item2)\
246 return item1.VAR OP item2.VAR;\
256 #define CompareStruct(VAR1, VAR2, TYPESUFFIX, OP)\
257 struct Compare##TYPESUFFIX\
259 explicit Compare##TYPESUFFIX(const HuginBase::CPVector& cps) : m_cps(cps) {};\
260 bool operator()(const CPListItem& item1, const CPListItem& item2)\
262 return m_cps[item1.globalIndex].VAR1 * 1e4 + m_cps[item1.globalIndex].VAR2 + item1.localNumber * 1.0 / m_cps.size() OP\
263 m_cps[item2.globalIndex].VAR1 * 1e4 + m_cps[item2.globalIndex].VAR2 + item2.localNumber * 1.0 / m_cps.size();\
266 const HuginBase::CPVector& m_cps;\
275 #define CompareStruct(VAR, TYPESUFFIX, OP)\
276 struct Compare##TYPESUFFIX\
278 explicit Compare##TYPESUFFIX(const HuginBase::CPVector& cps) : m_cps(cps) {};\
279 bool operator()(const CPListItem& item1, const CPListItem& item2)\
281 return m_cps[item1.globalIndex].VAR OP m_cps[item2.globalIndex].VAR;\
284 const HuginBase::CPVector& m_cps;\
370 if (GetSelectedItemCount() == 1)
381 const int newCol = e.GetColumn();
398 const int colNum = e.GetColumn();
399 wxConfigBase::Get()->Write(wxString::Format(wxT(
"/CPListFrame/ColumnWidth%d"), colNum), GetColumnWidth(colNum));
405 const int nSelected = GetSelectedItemCount();
413 long item = GetFirstSelected();
414 long newSelection = -1;
428 item = GetNextSelected(item);
430 DEBUG_DEBUG(
"about to delete " << selected.size() <<
" points");
433 if (newSelection >= 0)
436 Select(newSelection,
true);
442 const bool invert = threshold < 0;
452 Select(i, ((error > threshold) && (!invert)) || ((error < threshold) && (invert)));
467 switch (e.GetKeyCode())
470 case WXK_NUMPAD_DELETE:
486 CPListCtrlXmlHandler::CPListCtrlXmlHandler()
487 : wxListCtrlXmlHandler()
495 cp->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT(
"style")), wxDefaultValidator, GetName());
502 return IsOfClass(node, wxT(
"CPListCtrl"));
508 bool ok = wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"cp_list_frame"));
515 SetSizeHints(200, 300);
547 if(isShowingCorrelation)
556 double min,
max, mean, var;
562 threshold = mean + sqrt(var);
567 t = wxGetTextFromUser(isShowingCorrelation ?
568 _(
"Enter minimum control point correlation.\nAll points with lower correlation will be selected.") :
569 _(
"Enter minimum control point error.\nAll points with a higher error will be selected"),
570 _(
"Select Control Points"),
572 if (t == wxEmptyString) {
const bool GetOptimizeOnlyActiveImages() const
void OnColumnWidthChange(wxListEvent &e)
column width changed
void DeleteSelected()
Delete the selected points.
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxLC_REPORT|wxLC_VIRTUAL, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxListCtrlNameStr)
void UpdateInternalCPList()
helper class for virtual listview control
bool str2double(const wxString &s, double &d)
bool removeObserver(PanoramaObserver *observer)
remove a panorama observer.
virtual int OnGetItemImage(long item) const
show no images
std::vector< CPListItem > m_internalCPList
CPListFrame(wxWindow *parent, HuginBase::Panorama &pano)
ctor.
void OnDeleteButton(wxCommandEvent &e)
static void calcCtrlPntsErrorStats(const PanoramaData &pano, double &min, double &max, double &mean, double &var, const int &imgNr=-1, const bool onlyActive=false, const bool ignoreLineCp=false)
void Init(HuginBase::Panorama *pano)
void OnClose(wxCloseEvent &event)
void OnSelectButton(wxCommandEvent &e)
void SortInternalList(bool isAscending)
wxString doubleTowxString(double d, int digits)
virtual wxString OnGetItemText(long item, long column) const
create labels for virtual list control
bool set_contains(const _Container &c, const typename _Container::key_type &key)
#define CompareStruct(VAR, TYPESUFFIX, OP)
#define DEBUG_ASSERT(cond)
include file for the hugin project
const CPVector & getCtrlPoints() const
get all control point of this Panorama
remove several control points
represents a control point
std::set< unsigned int > UIntSet
void OnChar(wxKeyEvent &e)
handle keystrokes
void ShowCtrlPoint(unsigned int cpNr)
void SelectAll()
select all items
List all control points of this project.
static MainFrame * Get()
hack.. kind of a pseudo singleton...
HuginBase::Panorama * m_pano
void OnCPListFrameClosed()
const ControlPoint & getCtrlPoint(std::size_t nr) const
get a control point, counting starts with 0
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
evaluate x, points are on a vertical line
xrc handler for CPImagesComboBox
static GlobalCmdHist & getInstance()
void OnCPListSelectionChanged(wxListEvent &e)
selection event handler
virtual wxObject * DoCreateResource()
Create CPImagesComboBox from resource.
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
virtual ~CPListFrame()
dtor.
void addCommand(PanoCommand *command, bool execute=true)
Adds a command to the history.
void SelectDistanceThreshold(double threshold)
select all cp with the given error bigger than the threshold
UIntSet getActiveImages() const
get active images
void OnCPListHeaderClick(wxListEvent &e)
sort criterium changed
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
void addObserver(PanoramaObserver *o)
add a panorama observer.
include file for the hugin project
#define HUGIN_FT_CORR_THRESHOLD
std::string makePairId(unsigned int id1, unsigned int id2)
std::vector< ControlPoint > CPVector
std::map< std::string, int > m_localIds
virtual bool CanHandle(wxXmlNode *node)
Internal use to identify right xml handler.
bool IsShowingCorrelation() const
virtual void panoramaChanged(HuginBase::Panorama &pano)
Notification about a Panorama change.
evaluate y, points are on a horizontal line
HuginBase::Panorama & m_pano
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.