Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
28 #include <panodata/ControlPoint.h>
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 
42  : Tool(helper)
43 {
45 }
46 
47 // we want to draw over the panorama when in use, so make sure we get notice.
49 {
51 }
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:
60  const HuginBase::CPVector &control_points = helper->GetPanoramaPtr()->getCtrlPoints();
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  {
68  const HuginBase::ControlPoint &cp = control_points[cp_index];
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.
75  if (line)
76  {
77  glColor3f(0.0, 0.5, 1.0);
78  }
79  else
80  {
81  double red, green, blue;
83  glColor3d(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);
90  }
91  }
92  glColor3f(1.0, 1.0, 1.0);
93  glEnable(GL_TEXTURE_2D);
94 
95  // free transforms
96  delete [] transforms;
97 }
98 
100 {
102  const size_t images_count = helper->GetPanoramaPtr()->getNrOfImages();
103  transforms = new HuginBase::PTools::Transform [images_count];
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 
implementation of huginApp Class
void drawLineFromSpherical(double startLat, double startLong, double endLat, double endLong, double width=1.0)
Draw the shortest segment of the great circle crossing two spherical coordinates. ...
PreviewControlPointTool(ToolHelper *helper)
void Activate()
Switch on a tool.
ViewState * GetViewStatePtr()
Definition: ToolHelper.cpp:305
void setHeight(unsigned int h)
set panorama height
HuginBase::Panorama * GetPanoramaPtr()
Definition: ToolHelper.cpp:310
void DisableTexture(bool maskOnly=false)
void NotifyMe(Event event, Tool *tool)
Definition: ToolHelper.cpp:315
static char * line
Definition: svm.cpp:2784
const CPVector & getCtrlPoints() const
get all control point of this Panorama
Definition: Panorama.h:319
represents a control point
Definition: ControlPoint.h:38
HuginBase::PTools::Transform * transforms
void setVisualizationState(VisualizationState *visualizationState)
Set the ViewState to use for information on output projection and preview display.
VisualizationState * GetVisualizationStatePtr()
Definition: ToolHelper.cpp:300
ToolHelper * helper
The PreviewToolHelper that uses the same preview window and panorama as the tool should.
Definition: Tool.h:102
void AfterDrawImagesEvent()
Draw (using OpenGL) images above the others.
Definition: Tool.h:42
virtual HuginBase::SrcPanoImage * GetSrcImage(unsigned int image_nr)
Definition: ViewState.cpp:478
std::size_t getNrOfImages() const
number of images.
Definition: Panorama.h:205
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-&gt;pano transformation
TextureManager * GetTextureManager()
Definition: ViewState.h:104
bool transformImgCoord(double &x_dest, double &y_dest, double x_src, double y_src) const
like transform, but return image coordinates, not cartesian coordinates
Holds transformations for Image -&gt; Pano and the other way.
void ControlPointErrorColour(const double cperr, double &r, double &g, double &b)
Definition: utils.cpp:341
std::vector< ControlPoint > CPVector
Definition: ControlPoint.h:99
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
Definition: Panorama.h:211
Panorama image options.
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true