Hugin trunk 0.1
Loading...
Searching...
No Matches
PreviewControlPointTool.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
24#ifdef _WIN32
25#include "wx/msw/wrapwin.h"
26#endif
29
30
31#include <wx/platform.h>
32#ifdef __WXMAC__
33#include <OpenGL/gl.h>
34#else
35#ifdef __WXMSW__
36#include <vigra/windows.h>
37#endif
38#include <GL/gl.h>
39#endif
40
46
47// we want to draw over the panorama when in use, so make sure we get notice.
52
53// The panorama has been drawn, draw the control points over the top.
55{
56 // Make Transforms for each image so we don't have to do it twice for each control point.
58
59 // get all of the control points:
61
62 // now draw each control point in turn:
64 glColor3f(1.0, 0.5, 0.0);
65 size_t cp_count = control_points.size();
66 for (size_t cp_index = 0; cp_index < cp_count; cp_index++)
67 {
69 // only draw the control point if both images have been enabled.
70 if ( helper->GetPanoramaPtr()->getImage(cp.image1Nr).getActive()
71 && helper->GetPanoramaPtr()->getImage(cp.image2Nr).getActive())
72 {
73 // draw line control points blue instead of orange.
74 const bool line = cp.mode != HuginBase::ControlPoint::X_Y;
75 if (line)
76 {
77 glColor3f(0.0, 0.5, 1.0);
78 }
79 else
80 {
81 double red, green, blue;
84 }
85 // draw a the smallest great circle arc between these two points.
86 double x1, y1, x2, y2;
87 transforms[cp.image1Nr].transformImgCoord(x1, y1, cp.x1, cp.y1);
88 transforms[cp.image2Nr].transformImgCoord(x2, y2, cp.x2, cp.y2);
89 m_greatCircles.drawLineFromSpherical(x1, y1, x2, y2, 1.0, line);
90 }
91 }
92 glColor3f(1.0, 1.0, 1.0);
94
95 // free transforms
96 delete [] transforms;
97}
98
100{
102 const size_t images_count = helper->GetPanoramaPtr()->getNrOfImages();
104 // make a pretend output options to get spherical coordinates.
106 options.setWidth(360);
107 options.setHeight(180);
108 for (unsigned int image_number = 0; image_number < images_count; image_number++)
109 {
110 // we are transforming image coordinates to spherical coordinates.
111 transforms[image_number].createInvTransform(
112 *(helper->GetVisualizationStatePtr()->GetSrcImage(image_number)),
113 options
114 );
115 }
116}
117
void setVisualizationState(VisualizationState *visualizationState)
Set the ViewState to use for information on output projection and preview display.
void drawLineFromSpherical(double startLat, double startLong, double endLat, double endLong, double width=1.0, bool straightLine=false)
Draw the shortest segment of the great circle crossing two spherical coordinates.
represents a control point
Holds transformations for Image -> Pano and the other way.
bool transformImgCoord(double &x_dest, double &y_dest, double x_src, double y_src) const
like transform, but return image coordinates, not cartesian coordinates
void createInvTransform(const vigra::Diff2D &srcSize, VariableMap srcVars, Lens::LensProjectionFormat srcProj, const vigra::Diff2D &destSize, PanoramaOptions::ProjectionFormat destProj, const std::vector< double > &destProjParam, double destHFOV, const vigra::Diff2D &origSrcSize)
create image->pano transformation
Panorama image options.
void setHeight(unsigned int h)
set panorama height
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition Panorama.h:211
const CPVector & getCtrlPoints() const
get all control point of this Panorama
Definition Panorama.h:319
std::size_t getNrOfImages() const
number of images.
Definition Panorama.h:205
void AfterDrawImagesEvent()
Draw (using OpenGL) images above the others.
HuginBase::PTools::Transform * transforms
void Activate()
Switch on a tool.
PreviewControlPointTool(ToolHelper *helper)
void DisableTexture(bool maskOnly=false)
HuginBase::Panorama * GetPanoramaPtr()
void NotifyMe(Event event, Tool *tool)
ViewState * GetViewStatePtr()
VisualizationState * GetVisualizationStatePtr()
@ DRAW_OVER_IMAGES
Definition ToolHelper.h:82
Definition Tool.h:43
ToolHelper * helper
The PreviewToolHelper that uses the same preview window and panorama as the tool should.
Definition Tool.h:109
TextureManager * GetTextureManager()
Definition ViewState.h:104
virtual HuginBase::SrcPanoImage * GetSrcImage(unsigned int image_nr)
implementation of huginApp Class
std::vector< ControlPoint > CPVector
void ControlPointErrorColour(const double cperr, double &r, double &g, double &b)
Definition utils.cpp:341
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.
Definition threshold.h:41