27 #include "hugin_config.h"
47 EVT_LIST_ITEM_SELECTED(wxID_ANY,
CPListCtrl::OnCPListSelectionChanged)
48 EVT_LIST_ITEM_DESELECTED(wxID_ANY,
CPListCtrl::OnCPListSelectionChanged)
49 EVT_LIST_COL_CLICK(wxID_ANY,
CPListCtrl::OnCPListHeaderClick)
50 EVT_LIST_COL_END_DRAG(wxID_ANY,
CPListCtrl::OnColumnWidthChange)
53 std::
string makePairId(
unsigned int id1,
unsigned int id2)
57 std::ostringstream oss;
60 oss << id1 <<
"_" << id2;
63 oss << id2 <<
"_" << id1;
80 wxConfigBase* config = wxConfig::Get();
81 config->Write(wxT(
"/CPListFrame/SortColumn"),
m_sortCol);
82 config->Write(wxT(
"/CPListFrame/SortAscending"),
m_sortAscend ? 1 : 0);
91 const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
93 if (!wxListCtrl::Create(parent,
id, pos, size, style))
97 InsertColumn(0, _(
"G CP#"), wxLIST_FORMAT_RIGHT, 25);
98 InsertColumn(1, _(
"Left Img."), wxLIST_FORMAT_RIGHT, 65);
99 InsertColumn(2, _(
"Right Img."), wxLIST_FORMAT_RIGHT, 65);
100 InsertColumn(3, _(
"P CP#"), wxLIST_FORMAT_RIGHT, 25);
101 InsertColumn(4, _(
"Alignment"), wxLIST_FORMAT_LEFT, 80);
102 InsertColumn(5,
MainFrame::Get()->IsShowingCorrelation() ? _(
"Correlation") : _(
"Distance"), wxLIST_FORMAT_RIGHT, 80);
105 for (
int j = 0; j < GetColumnCount(); j++)
108 int width = wxConfigBase::Get()->Read(wxString::Format(wxT(
"/CPListFrame/ColumnWidth%d"), j), -1);
111 SetColumnWidth(j, width);
114 EnableAlternateRowColours(
true);
116 #if !wxCHECK_VERSION(3,1,6)
118 memDC.SetFont(GetFont());
119 wxSize fontSize = memDC.GetTextExtent(wxT(
"\u25b3"));
120 wxCoord charSize =
std::max(fontSize.GetWidth(), fontSize.GetHeight());
121 wxImageList* sortIcons =
new wxImageList(charSize, charSize,
true, 0);
123 wxBitmap bmp(charSize, charSize);
125 dc.SetBackgroundMode(wxPENSTYLE_TRANSPARENT);
126 dc.SetBackground(GetBackgroundColour());
128 dc.SetFont(GetFont());
129 dc.DrawText(wxT(
"\u25b3"), (charSize - fontSize.GetWidth()) / 2, (charSize - fontSize.GetHeight()) / 2);
130 dc.SelectObject(wxNullBitmap);
131 sortIcons->Add(bmp, GetBackgroundColour());
134 wxBitmap bmp(charSize, charSize);
136 dc.SetBackgroundMode(wxPENSTYLE_TRANSPARENT);
137 dc.SetBackground(GetBackgroundColour());
139 dc.SetFont(GetFont());
140 dc.DrawText(wxT(
"\u25bd"), (charSize - fontSize.GetWidth()) / 2, (charSize - fontSize.GetHeight()) / 2);
141 dc.SelectObject(wxNullBitmap);
142 sortIcons->Add(bmp, GetBackgroundColour());
144 AssignImageList(sortIcons, wxIMAGE_LIST_SMALL);
146 wxConfigBase* config = wxConfig::Get();
147 m_sortCol=config->Read(wxT(
"/CPListFrame/SortColumn"), 0l);
148 m_sortAscend = config->Read(wxT(
"/CPListFrame/SortAscending"), 1l) == 1;
150 #if wxCHECK_VERSION(3,1,6)
169 return wxEmptyString;
175 return wxString::Format(wxT(
"%lu"), static_cast<unsigned long>(
m_internalCPList[item].globalIndex));
178 return wxString::Format(wxT(
"%u"), cp.
image1Nr);
181 return wxString::Format(wxT(
"%u"), cp.
image2Nr);
184 return wxString::Format(wxT(
"%lu"), static_cast<unsigned long>(
m_internalCPList[item].localNumber));
190 return wxString(_(
"normal"));
193 return wxString(_(
"vert. Line"));
196 return wxString(_(
"horiz. Line"));
199 return wxString::Format(_(
"Line %d"), cp.
mode);
204 return wxString::Format(wxT(
"%.2f"), cp.
error);
207 return wxEmptyString;
209 return wxEmptyString;
222 if (GetColumn(5, item))
224 if (isShowingCorrelation)
226 item.SetText(_(
"Correlation"));
230 item.SetText(_(
"Distance"));
234 XRCCTRL(*GetParent(),
"cp_list_select", wxButton)->SetLabel(isShowingCorrelation ? _(
"Select by Correlation") : _(
"Select by Distance"));
249 for (
size_t i = 0; i < cps.size(); i++)
259 std::map<std::string, int>::iterator it =
m_localIds.find(pairId);
276 #define CompareStruct(VAR, TYPESUFFIX, OP) \
277 struct Compare##TYPESUFFIX\
279 bool operator()(const CPListItem& item1, const CPListItem& item2)\
281 return item1.VAR OP item2.VAR;\
291 #define CompareStruct(VAR1, VAR2, TYPESUFFIX, OP)\
292 struct Compare##TYPESUFFIX\
294 explicit Compare##TYPESUFFIX(const HuginBase::CPVector& cps) : m_cps(cps) {};\
295 bool operator()(const CPListItem& item1, const CPListItem& item2)\
297 return m_cps[item1.globalIndex].VAR1 * 1e4 + m_cps[item1.globalIndex].VAR2 + item1.localNumber * 1.0 / m_cps.size() OP\
298 m_cps[item2.globalIndex].VAR1 * 1e4 + m_cps[item2.globalIndex].VAR2 + item2.localNumber * 1.0 / m_cps.size();\
301 const HuginBase::CPVector& m_cps;\
310 #define CompareStruct(VAR, TYPESUFFIX, OP)\
311 struct Compare##TYPESUFFIX\
313 explicit Compare##TYPESUFFIX(const HuginBase::CPVector& cps) : m_cps(cps) {};\
314 bool operator()(const CPListItem& item1, const CPListItem& item2)\
316 return m_cps[item1.globalIndex].VAR OP m_cps[item2.globalIndex].VAR;\
319 const HuginBase::CPVector& m_cps;\
405 if (GetSelectedItemCount() == 1)
416 const int newCol = e.GetColumn();
417 #if wxCHECK_VERSION(3,1,6)
448 const int colNum = e.GetColumn();
449 wxConfigBase::Get()->Write(wxString::Format(wxT(
"/CPListFrame/ColumnWidth%d"), colNum), GetColumnWidth(colNum));
455 const int nSelected = GetSelectedItemCount();
463 long item = GetFirstSelected();
464 long newSelection = -1;
478 item = GetNextSelected(item);
480 DEBUG_DEBUG(
"about to delete " << selected.size() <<
" points");
483 if (newSelection >= 0)
486 Select(newSelection,
true);
492 const bool invert = threshold < 0;
502 Select(i, ((error > threshold) && (!invert)) || ((error < threshold) && (invert)));
517 switch (e.GetKeyCode())
520 case WXK_NUMPAD_DELETE:
536 CPListCtrlXmlHandler::CPListCtrlXmlHandler()
537 : wxListCtrlXmlHandler()
545 cp->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT(
"style")), wxDefaultValidator, GetName());
552 return IsOfClass(node, wxT(
"CPListCtrl"));
558 EVT_BUTTON(XRCID("cp_list_delete"),
CPListFrame::OnDeleteButton)
559 EVT_BUTTON(XRCID("cp_list_select"),
CPListFrame::OnSelectButton)
565 bool ok = wxXmlResource::Get()->LoadFrame(
this, parent, wxT(
"cp_list_frame"));
567 m_list = XRCCTRL(*
this,
"cp_list_frame_list",
CPListCtrl);
569 m_list->Init(&m_pano);
573 this->SetBackgroundColour(XRCCTRL(*
this,
"cp_list_select", wxButton)->GetBackgroundColour());
576 wxIconBundle myIcons(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.ico"),wxBITMAP_TYPE_ICO);
579 wxIcon myIcon(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.png"),wxBITMAP_TYPE_PNG);
585 SetSizeHints(200, 300);
614 if(isShowingCorrelation)
623 double min,
max, mean, var;
629 threshold = mean + sqrt(var);
634 t = wxGetTextFromUser(isShowingCorrelation ?
635 _(
"Enter minimum control point correlation.\nAll points with lower correlation will be selected.") :
636 _(
"Enter minimum control point error.\nAll points with a higher error will be selected"),
637 _(
"Select Control Points"),
639 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
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
static huginApp * Get()
hack.. kind of a pseudo singleton...
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()
void SetColumnImage(wxListCtrl *list, int col, int image)
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