From: <hug...@li...> - 2011-07-10 18:45:26
|
branch: gsoc2011_onomou details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgrepo/h/hu/hugin/hugin/rev/1eb794e209e3 changeset: 5380:1eb794e209e3 user: onomou <on...@gm...> date: Mon Jul 04 22:43:28 2011 -0700 description: 'Add Line' associated functions framework - no useful functionality yet diffstat: src/hugin1/hugin/CPEditorPanel.cpp | 46 ++++++++++++++++++++++- src/hugin1/hugin/CPEditorPanel.h | 7 +++ src/hugin1/hugin/CPImageCtrl.cpp | 47 ++++++++++++++++++++++- src/hugin1/hugin/CPImageCtrl.h | 29 ++++++++++++++- src/hugin1/hugin/CPSharedStructs.h | 4 ++ 5 files changed, 127 insertions(+), 6 deletions(-) diffs (301 lines): diff -r 4f213f11a6ea -r 1eb794e209e3 src/hugin1/hugin/CPEditorPanel.cpp --- a/src/hugin1/hugin/CPEditorPanel.cpp Mon Jul 04 00:55:21 2011 -0700 +++ b/src/hugin1/hugin/CPEditorPanel.cpp Mon Jul 04 22:43:28 2011 -0700 @@ -1581,6 +1581,20 @@ } m_leftImg->setCtrlPoints(left); m_rightImg->setCtrlPoints(right); + + // get list of control lines + + for (int i = 0; i < allLines.size(); i++) { + if ((allLines[i].img1Nr == m_leftImageNr) && (allLines[i].img2Nr == m_rightImageNr)) { + m_leftImg->setCtrlLines( allLines[i].img1lines ); + m_rightImg->setCtrlLines( allLines[i].img2lines ); + i = allLines.size(); + } else if ((allLines[i].img2Nr == m_leftImageNr) && (allLines[i].img1Nr == m_rightImageNr)) { + m_leftImg->setCtrlLines( allLines[i].img2lines ); + m_rightImg->setCtrlLines( allLines[i].img1lines ); + i = allLines.size(); + } + } // put these control points into our listview. unsigned int selectedCP = UINT_MAX; @@ -2020,15 +2034,43 @@ void CPEditorPanel::OnAddLine(wxCommandEvent & e) { - wxListEvent dummy; - OnCPListDeselect(dummy); + //wxListEvent dummy; + //OnCPListDeselect(dummy); + + const char* addl = "Add Line"; const char* cncl = "Cancel"; // toggle add line mode if (addingLine) { + m_cpModeChoice->Enable(); + m_autoAddCB->Enable(); + m_fineTuneCB->Enable(); + m_estimateCB->Enable(); + m_addLineButton->Enable(); + XRCCTRL(*this, "cp_editor_finetune_button", wxButton)->Enable(); + XRCCTRL(*this, "cp_editor_celeste_button", wxButton)->Enable(); + //XRCCTRL(*this, "cp_editor_choice_zoom", wxChoice)->Enable(); + XRCCTRL(*this, "cp_editor_previous_img", wxButton)->Enable(); + XRCCTRL(*this, "cp_editor_swap_img", wxButton)->Enable(); + XRCCTRL(*this, "cp_editor_next_img", wxButton)->Enable(); m_addLineButton->SetLabel(wxString(addl,wxConvUTF8)); addingLine = false; } else { + m_autoAddCB->Disable(); + m_fineTuneCB->Disable(); + m_estimateCB->Disable(); + m_cpModeChoice->Disable(); + m_addButton->Disable(); + m_delButton->Disable(); + XRCCTRL(*this, "cp_editor_finetune_button", wxButton)->Disable(); + XRCCTRL(*this, "cp_editor_celeste_button", wxButton)->Disable(); + //XRCCTRL(*this, "cp_editor_choice_zoom", wxChoice)->Disable(); + XRCCTRL(*this, "cp_editor_previous_img", wxButton)->Disable(); + XRCCTRL(*this, "cp_editor_swap_img", wxButton)->Disable(); + XRCCTRL(*this, "cp_editor_next_img", wxButton)->Disable(); + m_selectedPoint = UINT_MAX; + changeState(NO_POINT); + UpdateDisplay(true); m_addLineButton->SetLabel(wxString(cncl,wxConvUTF8)); addingLine = true; } diff -r 4f213f11a6ea -r 1eb794e209e3 src/hugin1/hugin/CPEditorPanel.h --- a/src/hugin1/hugin/CPEditorPanel.h Mon Jul 04 00:55:21 2011 -0700 +++ b/src/hugin1/hugin/CPEditorPanel.h Mon Jul 04 22:43:28 2011 -0700 @@ -44,6 +44,11 @@ #include "CPImagesComboBox.h" +#ifndef _LINEFILE +#include "CPSharedStructs.h" +#define _LINEFILE +#endif + // Always use wxChoice, the tabs behave badly with many images on GTK as well. #define HUGIN_CP_IMG_CHOICE @@ -255,6 +260,8 @@ // Line controls bool addingLine; + struct linesPair { int img1Nr, img2Nr; std::vector<StraightLine> img1lines, img2lines; }; + std::vector<linesPair> allLines; // GUI controls #ifdef HUGIN_CP_IMG_CHOICE diff -r 4f213f11a6ea -r 1eb794e209e3 src/hugin1/hugin/CPImageCtrl.cpp --- a/src/hugin1/hugin/CPImageCtrl.cpp Mon Jul 04 00:55:21 2011 -0700 +++ b/src/hugin1/hugin/CPImageCtrl.cpp Mon Jul 04 22:43:28 2011 -0700 @@ -159,6 +159,7 @@ m_savedScale = 1; m_editPanel = 0; m_imgRotation = ROT0; + addingLine = false; wxString filename; @@ -266,6 +267,8 @@ } switch(editState) { + case NEW_LINE: // fix these + break; case SELECT_REGION: dc.SetLogicalFunction(wxINVERT); dc.SetPen(wxPen(wxT("WHITE"), 1, wxSOLID)); @@ -301,6 +304,9 @@ case KNOWN_POINT_SELECTED: m_labelPos[selectedPointNr] = drawPoint(dc, points[selectedPointNr], selectedPointNr, true); break; + case ADDING_LINE: + drawLine(dc, newLine); + break; case NO_SELECTION: case NO_IMAGE: break; @@ -536,6 +542,16 @@ #endif +void CPImageCtrl::drawLine(wxDC & dc, const StraightLine in) +{ + wxCoord x1,x2,y1,y2; + x1 = roundi(in.start.x); + y1 = roundi(in.start.y); + x2 = m_mousePos.x; + y2 = m_mousePos.y; + dc.DrawLine(x1,y1,x2,y2); +} + class ScalingTransform { public: @@ -768,7 +784,13 @@ update(); } - +void CPImageCtrl::setCtrlLines(const std::vector<StraightLine> & linesIn) +{ + lines = linesIn; + if(editState == ADDING_LINE) + editState = NO_SELECTION; + update(); +} void CPImageCtrl::clearNewPoint() { @@ -903,6 +925,11 @@ // only if the shift key is not pressed. if (mouse.LeftIsDown() && ! mouse.ShiftDown()) { switch(editState) { + case ADDING_LINE: // fix these + //mousePos = mouse.GetLogicalPosition(); + case NEW_LINE: + doUpdate = true; + break; case NO_SELECTION: DEBUG_DEBUG("mouse down movement without selection, in NO_SELECTION state!"); break; @@ -1020,12 +1047,18 @@ } unsigned int selPointNr = 0; // EditorState oldstate = editState; - EditorState clickState = isOccupied(mouse.GetPosition(), mpos, selPointNr); + EditorState clickState = isOccupied(mouse.GetPosition(), mpos, selPointNr); // check if mouse is over a CP + if (mouse.LeftDown() && editState != NO_IMAGE && mpos.x < m_realSize.x && mpos.y < m_realSize.y) { + if (editState == ADDING_LINE) { // clicking second point on line + + } else if (editState == NEW_LINE) { // clicking first point on line + editState = ADDING_LINE; + // we can always select a new point - if (clickState == KNOWN_POINT_SELECTED) { + } else if (clickState == KNOWN_POINT_SELECTED) { DEBUG_DEBUG("click on point: " << selPointNr); selectedPointNr = selPointNr; point = points[selectedPointNr]; @@ -1080,6 +1113,9 @@ // EditorState oldState = editState; if (mouse.LeftUp()) { switch(editState) { + case ADDING_LINE: // fix these + case NEW_LINE: + break; case NO_SELECTION: DEBUG_DEBUG("mouse release without selection"); break; @@ -1486,6 +1522,11 @@ // out its own change messages. } +void CPImageCtrl::setNewLine(const StraightLine & l) +{ + +} + void CPImageCtrl::showSearchArea(bool show) { m_showSearchArea = show; diff -r 4f213f11a6ea -r 1eb794e209e3 src/hugin1/hugin/CPImageCtrl.h --- a/src/hugin1/hugin/CPImageCtrl.h Mon Jul 04 00:55:21 2011 -0700 +++ b/src/hugin1/hugin/CPImageCtrl.h Mon Jul 04 22:43:28 2011 -0700 @@ -29,6 +29,11 @@ #include <base_wx/wxImageCache.h> +#ifndef _LINEFILE +#include "CPSharedStructs.h" +#define _LINEFILE +#endif + class CPEditorPanel; /** Events to notify about new point / region / point change @@ -132,6 +137,10 @@ /// control point inside this image void setCtrlPoints(const std::vector<hugin_utils::FDiff2D> & points); + + /// control lines inside this image + //extern struct StraightLine; + void setCtrlLines(const std::vector<StraightLine> & linesIn); /// clear new point void clearNewPoint(); @@ -139,6 +148,9 @@ /// set new point to a specific point void setNewPoint(const hugin_utils::FDiff2D & p); + /// set new point to a specific point + void setNewLine(const StraightLine & l); + /// select a point for usage void selectPoint(unsigned int); @@ -196,6 +208,8 @@ protected: wxRect drawPoint(wxDC & p, const hugin_utils::FDiff2D & point, int i, bool selected = false) const; + void drawLine(wxDC & DC, const StraightLine in); + // draw the magnified view of a selected control point wxBitmap generateMagBitmap(hugin_utils::FDiff2D point, wxPoint canvasPos) const; // display the image when loading finishes @@ -235,6 +249,9 @@ wxSize m_realSize; std::vector<hugin_utils::FDiff2D> points; + //struct line { hugin_utils::FDiff2D start, end; }; + std::vector<StraightLine> lines; + StraightLine newLine; // position of the point labels (in screen coordinates) std::vector<wxRect> m_labelPos; @@ -408,8 +425,16 @@ * - SELECT_DELETE_REGION user can draw rectangle inside which all cp should be removed * - NO_SELECTION + * - ADDING_LINE (a new line is being added), mouse up reports change, + * movement can be tracked? + * - A line should be drawn from the active line's start point to the mouse cursor + * - Next click will add mouse click location as line's end point + * - + * - + * - + * */ - enum EditorState {NO_IMAGE=0, NO_SELECTION, KNOWN_POINT_SELECTED, NEW_POINT_SELECTED, SELECT_REGION, SELECT_DELETE_REGION}; + enum EditorState {NO_IMAGE=0, NO_SELECTION, KNOWN_POINT_SELECTED, NEW_POINT_SELECTED, SELECT_REGION, SELECT_DELETE_REGION, ADDING_LINE, NEW_LINE}; EditorState editState; // colors for the different points @@ -429,6 +454,8 @@ bool m_tempZoom; double m_savedScale; + + bool addingLine; /// check if p is over a known point, if it is, pointNr contains /// the point diff -r 4f213f11a6ea -r 1eb794e209e3 src/hugin1/hugin/CPSharedStructs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hugin1/hugin/CPSharedStructs.h Mon Jul 04 22:43:28 2011 -0700 @@ -0,0 +1,4 @@ +struct StraightLine +{ + hugin_utils::FDiff2D start, end; +}; |