27 #include "hugin_config.h"
45 std::string
makePairId(
unsigned int id1,
unsigned int id2)
49 std::ostringstream oss;
52 oss << id1 <<
"_" << id2;
55 oss << id2 <<
"_" << id1;
72 wxConfigBase* config = wxConfig::Get();
73 config->Write(wxT(
"/CPListFrame/SortColumn"),
m_sortCol);
74 config->Write(wxT(
"/CPListFrame/SortAscending"),
m_sortAscend ? 1 : 0);
83 const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
85 if (!wxListCtrl::Create(parent,
id, pos, size, style))
89 InsertColumn(0, _(
"G CP#"), wxLIST_FORMAT_RIGHT, 25);
90 InsertColumn(1, _(
"Left Img."), wxLIST_FORMAT_RIGHT, 65);
91 InsertColumn(2, _(
"Right Img."), wxLIST_FORMAT_RIGHT, 65);
92 InsertColumn(3, _(
"P CP#"), wxLIST_FORMAT_RIGHT, 25);
93 InsertColumn(4, _(
"Alignment"), wxLIST_FORMAT_LEFT, 80);
94 InsertColumn(5,
MainFrame::Get()->IsShowingCorrelation() ? _(
"Correlation") : _(
"Distance"), wxLIST_FORMAT_RIGHT, 80);
97 for (
int j = 0; j < GetColumnCount(); j++)
100 int width = wxConfigBase::Get()->Read(wxString::Format(wxT(
"/CPListFrame/ColumnWidth%d"), j), -1);
103 SetColumnWidth(j, width);
106 EnableAlternateRowColours(
true);
108 wxConfigBase* config = wxConfig::Get();
109 m_sortCol=config->Read(wxT(
"/CPListFrame/SortColumn"), 0l);
110 m_sortAscend = config->Read(wxT(
"/CPListFrame/SortAscending"), 1l) == 1;
133 return wxEmptyString;
139 return wxString::Format(wxT(
"%lu"), static_cast<unsigned long>(
m_internalCPList[item].globalIndex));
142 return wxString::Format(wxT(
"%u"), cp.
image1Nr);
145 return wxString::Format(wxT(
"%u"), cp.
image2Nr);
148 return wxString::Format(wxT(
"%lu"), static_cast<unsigned long>(
m_internalCPList[item].localNumber));
154 return wxString(_(
"normal"));
157 return wxString(_(
"vert. Line"));
160 return wxString(_(
"horiz. Line"));
163 return wxString::Format(_(
"Line %d"), cp.
mode);
168 return wxString::Format(wxT(
"%.2f"), cp.
error);
171 return wxEmptyString;
173 return wxEmptyString;
186 if (GetColumn(5, item))
188 if (isShowingCorrelation)
190 item.SetText(_(
"Correlation"));
194 item.SetText(_(
"Distance"));
198 XRCCTRL(*GetParent(),
"cp_list_select", wxButton)->SetLabel(isShowingCorrelation ? _(
"Select by Correlation") : _(
"Select by Distance"));
213 for (
size_t i = 0; i < cps.size(); i++)
223 std::map<std::string, int>::iterator it =
m_localIds.find(pairId);
240 #define CompareStruct(VAR, TYPESUFFIX, OP) \
241 struct Compare##TYPESUFFIX\
243 bool operator()(const CPListItem& item1, const CPListItem& item2)\
245 return item1.VAR OP item2.VAR;\
255 #define CompareStruct(VAR1, VAR2, TYPESUFFIX, OP)\
256 struct Compare##TYPESUFFIX\
258 explicit Compare##TYPESUFFIX(const HuginBase::CPVector& cps) : m_cps(cps) {};\
259 bool operator()(const CPListItem& item1, const CPListItem& item2)\
261 return m_cps[item1.globalIndex].VAR1 * 1e4 + m_cps[item1.globalIndex].VAR2 + item1.localNumber * 1.0 / m_cps.size() OP\
262 m_cps[item2.globalIndex].VAR1 * 1e4 + m_cps[item2.globalIndex].VAR2 + item2.localNumber * 1.0 / m_cps.size();\
265 const HuginBase::CPVector& m_cps;\
274 #define CompareStruct(VAR, TYPESUFFIX, OP)\
275 struct Compare##TYPESUFFIX\
277 explicit Compare##TYPESUFFIX(const HuginBase::CPVector& cps) : m_cps(cps) {};\
278 bool operator()(const CPListItem& item1, const CPListItem& item2)\
280 return m_cps[item1.globalIndex].VAR OP m_cps[item2.globalIndex].VAR;\
283 const HuginBase::CPVector& m_cps;\
369 if (GetSelectedItemCount() == 1)
380 const int newCol = e.GetColumn();
397 const int colNum = e.GetColumn();
398 wxConfigBase::Get()->Write(wxString::Format(wxT(
"/CPListFrame/ColumnWidth%d"), colNum), GetColumnWidth(colNum));
404 const int nSelected = GetSelectedItemCount();
412 long item = GetFirstSelected();
413 long newSelection = -1;
427 item = GetNextSelected(item);
429 DEBUG_DEBUG(
"about to delete " << selected.size() <<
" points");
432 if (newSelection >= 0)
435 Select(newSelection,
true);
441 const bool invert = threshold < 0;
451 Select(i, ((error > threshold) && (!invert)) || ((error < threshold) && (invert)));
466 switch (e.GetKeyCode())
469 case WXK_NUMPAD_DELETE:
485 CPListCtrlXmlHandler::CPListCtrlXmlHandler()
486 : wxListCtrlXmlHandler()
494 cp->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT(
"style")), wxDefaultValidator, GetName());
501 return IsOfClass(node, wxT(
"CPListCtrl"));
507 bool ok = wxXmlResource::Get()->LoadDialog(
this, parent, wxT(
"cp_list_frame"));
514 SetSizeHints(200, 300);
546 if(isShowingCorrelation)
555 double min,
max, mean, var;
561 threshold = mean + sqrt(var);
566 t = wxGetTextFromUser(isShowingCorrelation ?
567 _(
"Enter minimum control point correlation.\nAll points with lower correlation will be selected.") :
568 _(
"Enter minimum control point error.\nAll points with a higher error will be selected"),
569 _(
"Select Control Points"),
571 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...
void StoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Store window size and position in configfile/registry.
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
void RestoreFramePosition(wxTopLevelWindow *frame, const wxString &basename)
Restore window size and position from configfile/registry.
xrc handler for CPImagesComboBox
static GlobalCmdHist & getInstance()
void OnCPListSelectionChanged(wxListEvent &e)
selection event handler
virtual wxObject * DoCreateResource()
Create CPImagesComboBox from resource.
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