Index: src/hugin1/hugin/xrc/preview_frame.xrc
===================================================================
--- src/hugin1/hugin/xrc/preview_frame.xrc (revision 4266)
+++ src/hugin1/hugin/xrc/preview_frame.xrc (working copy)
@@ -425,6 +425,12 @@
Match images to their numbers
+
22,223
Index: src/hugin1/hugin/xrc/data/preview_control_point_tool.svg
===================================================================
--- src/hugin1/hugin/xrc/data/preview_control_point_tool.svg (revision 0)
+++ src/hugin1/hugin/xrc/data/preview_control_point_tool.svg (revision 0)
@@ -0,0 +1,456 @@
+
+
+
+
+
+
Index: src/hugin1/hugin/PreviewControlPointTool.cpp
===================================================================
--- src/hugin1/hugin/PreviewControlPointTool.cpp (revision 0)
+++ src/hugin1/hugin/PreviewControlPointTool.cpp (revision 0)
@@ -0,0 +1,109 @@
+// -*- c-basic-offset: 4 -*-
+
+/** @file PreviewCropTool.cpp
+ *
+ * @author James Legg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include "panoinc_WX.h"
+#include "panoinc.h"
+#include "PreviewControlPointTool.h"
+#include
+#include "base_wx/platform.h"
+#include "hugin/config_defaults.h"
+#include "CommandHistory.h"
+#include "wxPanoCommand.h"
+
+#include
+#ifdef __WXMAC__
+#include
+#else
+#include
+#endif
+
+PreviewControlPointTool::PreviewControlPointTool(PreviewToolHelper *helper)
+ : PreviewTool(helper)
+{
+ // this was just to make sure parent's contstructor was called.
+}
+
+// we want to draw over the panorama when in use, so make sure we get notice.
+void PreviewControlPointTool::Activate()
+{
+ helper->NotifyMe(PreviewToolHelper::DRAW_OVER_IMAGES, this);
+}
+
+// The panorama has been drawn, draw the control points over the top.
+void PreviewControlPointTool::AfterDrawImagesEvent()
+{
+ // Make Transforms for each image so we don't have to do it twice for each control point.
+ MakeTransforms();
+
+ // get all of the control points:
+ const CPVector &control_points = helper->GetPanoramaPtr()->getCtrlPoints();
+
+ // now draw each control point in turn:
+ glDisable(GL_TEXTURE_2D);
+ glColor3f(1.0, 0.5, 0.0);
+ glBegin(GL_LINES);
+ int cp_count = control_points.size();
+ for (size_t cp_index = 0; cp_index < cp_count; cp_index++)
+ {
+ const ControlPoint &cp = control_points[cp_index];
+ // only draw the control point if both images have been enabled.
+ if ( helper->GetPanoramaPtr()->getImage(cp.image1Nr).getOptions().active
+ && helper->GetPanoramaPtr()->getImage(cp.image2Nr).getOptions().active)
+ {
+ // draw line control points blue instead of orange.
+ bool line = cp.mode != HuginBase::ControlPoint::X_Y;
+ if (line) glColor3f(0.0, 0.5, 1.0);
+ // draw a vertex for each end
+ DrawVertex(cp.image1Nr, cp.x1, cp.y1);
+ DrawVertex(cp.image2Nr, cp.x2, cp.y2);
+ if (line) glColor3f(1.0, 0.5, 0.0);
+ }
+ }
+ glEnd();
+ glColor3f(1.0, 1.0, 1.0);
+ glEnable(GL_TEXTURE_2D);
+
+ // free transforms
+ delete [] transforms;
+}
+
+void PreviewControlPointTool::MakeTransforms()
+{
+ // TODO [efficiency] check the ViewState to see if we can keep the last one.
+ const size_t images_count = helper->GetPanoramaPtr()->getNrOfImages();
+ transforms = new HuginBase::PTools::Transform [images_count];
+ for (unsigned int image_number = 0; image_number < images_count; image_number++)
+ {
+ // we are transforming image coordinates to panorama coordinates.
+ transforms[image_number].createInvTransform(
+ *(helper->GetViewStatePtr()->GetSrcImage(image_number)),
+ *(helper->GetViewStatePtr()->GetOptions())
+ );
+ }
+}
+
+void PreviewControlPointTool::DrawVertex(const size_t image_number, const double x, const double y) const
+{
+ double ox, oy;
+ transforms[image_number].transformImgCoord(ox, oy, x, y);
+ glVertex2d(ox, oy);
+}
Index: src/hugin1/hugin/PreviewControlPointTool.h
===================================================================
--- src/hugin1/hugin/PreviewControlPointTool.h (revision 0)
+++ src/hugin1/hugin/PreviewControlPointTool.h (revision 0)
@@ -0,0 +1,114 @@
+// -*- c-basic-offset: 4 -*-
+
+/** @file PreviewCropTool.h
+ *
+ * @author James Legg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/** \todo:
+ *Where the line crosses a seam in the projection, don't draw the line.
+ e.g. with control points close the +/- 180 degree seem in
+ equirectangular, the ends might be on different
+ sides, causing a very long line.
+ *Delete them when clicked and show the control point window on right
+ click / middle click / modifier-key click?
+ perhaps not - not responding to user input allows us to
+ show the control points while using the other tools.
+*/
+
+
+#ifndef _PREVIEWCONTROLPOINTTOOL_H
+#define _PREVIEWCONTROLPOINTTOOL_H
+
+#include "PreviewTool.h"
+
+#include
+
+/** The PreviewCropTool shows lines between the ends of control points in the fast preview.
+ */
+class PreviewControlPointTool : public PreviewTool
+{
+public:
+ PreviewControlPointTool(PreviewToolHelper *helper);
+ void Activate();
+ void AfterDrawImagesEvent();
+private:
+ HuginBase::PTools::Transform *transforms;
+ void MakeTransforms();
+ void DrawVertex(const size_t image_number, const double x, const double y) const;
+};
+
+#endif
+
+// -*- c-basic-offset: 4 -*-
+
+/** @file PreviewCropTool.h
+ *
+ * @author James Legg
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+/** \todo:
+ *Where the line crosses a seam in the projection, don't draw the line.
+ e.g. with control points close the +/- 180 degree seem in
+ equirectangular, the ends might be on different
+ sides, causing a very long line.
+ *Delete them when clicked and show the control point window on right
+ click / middle click / modifier-key click?
+ perhaps not - not responding to user input allows us to
+ show the control points while using the other tools.
+*/
+
+
+#ifndef _PREVIEWCONTROLPOINTTOOL_H
+#define _PREVIEWCONTROLPOINTTOOL_H
+
+#include "PreviewTool.h"
+
+#include
+
+/** The PreviewCropTool shows lines between the ends of control points in the fast preview.
+ */
+class PreviewControlPointTool : public PreviewTool
+{
+public:
+ PreviewControlPointTool(PreviewToolHelper *helper);
+ void Activate();
+ void AfterDrawImagesEvent();
+private:
+ HuginBase::PTools::Transform *transforms;
+ void MakeTransforms();
+ void DrawVertex(const size_t image_number, const double x, const double y) const;
+};
+
+#endif
+
Index: src/hugin1/hugin/GLPreviewFrame.h
===================================================================
--- src/hugin1/hugin/GLPreviewFrame.h (revision 4266)
+++ src/hugin1/hugin/GLPreviewFrame.h (working copy)
@@ -45,6 +45,7 @@
class PreviewIdentifyTool;
class PreviewDifferenceTool;
class PreviewPanoMaskTool;
+class PreviewControlPointTool;
#include "common/utils.h"
#include
@@ -116,6 +117,7 @@
void OnCrop(wxCommandEvent & e);
void OnDrag(wxCommandEvent & e);
void OnIdentify(wxCommandEvent &e);
+ void OnControlPoint(wxCommandEvent &e);
void OnNumTransform(wxCommandEvent & e);
void OnChangeFOV(wxScrollEvent & e);
void OnTrackChangeFOV(wxScrollEvent & e);
@@ -139,7 +141,7 @@
GLViewer * m_GLViewer;
wxToolBar * m_ToolBar;
- int drag_tool_id, crop_tool_id, identify_tool_id;
+ int drag_tool_id, crop_tool_id, identify_tool_id, control_point_tool_id;
wxSlider * m_HFOVSlider;
wxSlider * m_VFOVSlider;
wxChoice * m_BlendModeChoice;
@@ -180,7 +182,8 @@
PreviewDragTool *drag_tool;
PreviewIdentifyTool *identify_tool;
PreviewDifferenceTool *difference_tool;
- PreviewPanoMaskTool *pano_mask_tool;
+ PreviewControlPointTool *control_point_tool;
+ PreviewPanoMaskTool *pano_mask_tool;
void TurnOffTools(std::set tools);
void CleanButtonColours();
};
Index: src/hugin1/hugin/CMakeLists.txt
===================================================================
--- src/hugin1/hugin/CMakeLists.txt (revision 4266)
+++ src/hugin1/hugin/CMakeLists.txt (working copy)
@@ -33,7 +33,7 @@
TexCoordRemapper.cpp ChoosyRemapper.cpp MeshManager.cpp ViewState.cpp
OutputProjectionInfo.cpp PreviewToolHelper.cpp PreviewTool.cpp
PreviewCropTool.cpp PreviewDragTool.cpp PreviewIdentifyTool.cpp
-PreviewDifferenceTool.cpp PreviewPanoMaskTool.cpp)
+PreviewDifferenceTool.cpp PreviewPanoMaskTool.cpp PreviewControlPointTool.cpp)
IF(APPLE)
if (MAC_SELF_CONTAINED_BUNDLE)
Index: src/hugin1/hugin/GLPreviewFrame.cpp
===================================================================
--- src/hugin1/hugin/GLPreviewFrame.cpp (revision 4266)
+++ src/hugin1/hugin/GLPreviewFrame.cpp (working copy)
@@ -66,6 +66,7 @@
#include "PreviewIdentifyTool.h"
#include "PreviewDifferenceTool.h"
#include "PreviewPanoMaskTool.h"
+#include "PreviewControlPointTool.h"
using namespace utils;
@@ -97,6 +98,7 @@
EVT_TOOL(XRCID("preview_crop_tool"), GLPreviewFrame::OnCrop)
EVT_TOOL(XRCID("preview_drag_tool"), GLPreviewFrame::OnDrag)
EVT_TOOL(XRCID("preview_identify_tool"), GLPreviewFrame::OnIdentify)
+ EVT_TOOL(XRCID("preview_control_point_tool"), GLPreviewFrame::OnControlPoint)
EVT_TEXT_ENTER( -1 , GLPreviewFrame::OnTextCtrlChanged)
@@ -153,7 +155,8 @@
DEBUG_ASSERT(crop_tool_id != -2);
identify_tool_id = wxXmlResource::Get()->GetXRCID(wxT("preview_identify_tool"));
DEBUG_ASSERT(identify_tool_id != -2);
-
+ control_point_tool_id = wxXmlResource::Get()->GetXRCID(wxT("preview_control_point_tool"));
+ DEBUG_ASSERT(control_point_tool_id != -2);
m_topsizer = new wxBoxSizer( wxVERTICAL );
@@ -1047,6 +1050,7 @@
identify_tool = new PreviewIdentifyTool(helper, this);
difference_tool = new PreviewDifferenceTool(helper);
pano_mask_tool = new PreviewPanoMaskTool(helper);
+ control_point_tool = new PreviewControlPointTool(helper);
// activate tools that are always active.
helper->ActivateTool(pano_mask_tool);
@@ -1098,6 +1102,18 @@
m_GLViewer->Refresh();
}
+void GLPreviewFrame::OnControlPoint(wxCommandEvent & e)
+{
+ SetStatusText(wxT(""), 0); // blank status text as it refers to an old tool.
+ if (e.IsChecked())
+ {
+ TurnOffTools(helper->ActivateTool(control_point_tool));
+ } else {
+ helper->DeactivateTool(control_point_tool);
+ }
+ m_GLViewer->Refresh();
+}
+
void GLPreviewFrame::TurnOffTools(std::set tools)
{
std::set::iterator i;
@@ -1122,6 +1138,12 @@
// cover up its indicators and restore normal button colours.
m_GLViewer->Refresh();
CleanButtonColours();
+ } else if (*i == control_point_tool)
+ {
+ // disabled the control point tool.
+ m_ToolBar->ToggleTool(control_point_tool_id, false);
+ // cover up the control point lines.
+ m_GLViewer->Refresh();
}
}
}