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 wxConfigBase* config = wxConfig::Get();
117 m_sortCol=config->Read(wxT(
"/CPListFrame/SortColumn"), 0l);
118 m_sortAscend = config->Read(wxT(
"/CPListFrame/SortAscending"), 1l) == 1;
135 return wxEmptyString;
141 return wxString::Format(wxT(
"%lu"), static_cast<unsigned long>(
m_internalCPList[item].globalIndex));
144 return wxString::Format(wxT(
"%u"), cp.
image1Nr);
147 return wxString::Format(wxT(
"%u"), cp.
image2Nr);
150 return wxString::Format(wxT(
"%lu"), static_cast<unsigned long>(
m_internalCPList[item].localNumber));
156 return wxString(_(
"normal"));
159 return wxString(_(
"vert. Line"));
162 return wxString(_(
"horiz. Line"));
165 return wxString::Format(_(
"Line %d"), cp.
mode);
170 return wxString::Format(wxT(
"%.2f"), cp.
error);
173 return wxEmptyString;
175 return wxEmptyString;
188 if (GetColumn(5, item))
190 if (isShowingCorrelation)
192 item.SetText(_(
"Correlation"));
196 item.SetText(_(
"Distance"));
200 XRCCTRL(*GetParent(),
"cp_list_select", wxButton)->SetLabel(isShowingCorrelation ? _(
"Select by Correlation") : _(
"Select by Distance"));
215 for (
size_t i = 0; i < cps.size(); i++)
225 std::map<std::string, int>::iterator it =
m_localIds.find(pairId);
242 #define CompareStruct(VAR, TYPESUFFIX, OP) \
243 struct Compare##TYPESUFFIX\
245 bool operator()(const CPListItem& item1, const CPListItem& item2)\
247 return item1.VAR OP item2.VAR;\
257 #define CompareStruct(VAR1, VAR2, TYPESUFFIX, OP)\
258 struct Compare##TYPESUFFIX\
260 explicit Compare##TYPESUFFIX(const HuginBase::CPVector& cps) : m_cps(cps) {};\
261 bool operator()(const CPListItem& item1, const CPListItem& item2)\
263 return m_cps[item1.globalIndex].VAR1 * 1e4 + m_cps[item1.globalIndex].VAR2 + item1.localNumber * 1.0 / m_cps.size() OP\
264 m_cps[item2.globalIndex].VAR1 * 1e4 + m_cps[item2.globalIndex].VAR2 + item2.localNumber * 1.0 / m_cps.size();\
267 const HuginBase::CPVector& m_cps;\
276 #define CompareStruct(VAR, TYPESUFFIX, OP)\
277 struct Compare##TYPESUFFIX\
279 explicit Compare##TYPESUFFIX(const HuginBase::CPVector& cps) : m_cps(cps) {};\
280 bool operator()(const CPListItem& item1, const CPListItem& item2)\
282 return m_cps[item1.globalIndex].VAR OP m_cps[item2.globalIndex].VAR;\
285 const HuginBase::CPVector& m_cps;\
371 if (GetSelectedItemCount() == 1)
382 const int newCol = e.GetColumn();
399 const int colNum = e.GetColumn();
400 wxConfigBase::Get()->Write(wxString::Format(wxT(
"/CPListFrame/ColumnWidth%d"), colNum), GetColumnWidth(colNum));
406 const int nSelected = GetSelectedItemCount();
414 long item = GetFirstSelected();
415 long newSelection = -1;
429 item = GetNextSelected(item);
431 DEBUG_DEBUG(
"about to delete " << selected.size() <<
" points");
434 if (newSelection >= 0)
437 Select(newSelection,
true);
443 const bool invert = threshold < 0;
453 Select(i, ((error > threshold) && (!invert)) || ((error < threshold) && (invert)));
468 switch (e.GetKeyCode())
471 case WXK_NUMPAD_DELETE:
487 CPListCtrlXmlHandler::CPListCtrlXmlHandler()
488 : wxListCtrlXmlHandler()
496 cp->Create(m_parentAsWindow, GetID(), GetPosition(), GetSize(), GetStyle(wxT(
"style")), wxDefaultValidator, GetName());
503 return IsOfClass(node, wxT(
"CPListCtrl"));
509 EVT_BUTTON(XRCID("cp_list_delete"),
CPListFrame::OnDeleteButton)
510 EVT_BUTTON(XRCID("cp_list_select"),
CPListFrame::OnSelectButton)
516 bool ok = wxXmlResource::Get()->LoadFrame(
this, parent, wxT(
"cp_list_frame"));
518 m_list = XRCCTRL(*
this,
"cp_list_frame_list",
CPListCtrl);
520 m_list->Init(&m_pano);
524 this->SetBackgroundColour(XRCCTRL(*
this,
"cp_list_select", wxButton)->GetBackgroundColour());
527 wxIconBundle myIcons(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.ico"),wxBITMAP_TYPE_ICO);
530 wxIcon myIcon(
huginApp::Get()->GetXRCPath() + wxT(
"data/hugin.png"),wxBITMAP_TYPE_PNG);
536 SetSizeHints(200, 300);
565 if(isShowingCorrelation)
574 double min,
max, mean, var;
580 threshold = mean + sqrt(var);
585 t = wxGetTextFromUser(isShowingCorrelation ?
586 _(
"Enter minimum control point correlation.\nAll points with lower correlation will be selected.") :
587 _(
"Enter minimum control point error.\nAll points with a higher error will be selected"),
588 _(
"Select Control Points"),
590 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()
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