00001
00002
00024 #include <hugin/PreviewControlPointTool.h>
00025 #include <panodata/ControlPoint.h>
00026
00027
00028 #include <wx/platform.h>
00029 #ifdef __WXMAC__
00030 #include <OpenGL/gl.h>
00031 #else
00032 #ifdef __WXMSW__
00033 #include <vigra/windows.h>
00034 #endif
00035 #include <GL/gl.h>
00036 #endif
00037
00038 PreviewControlPointTool::PreviewControlPointTool(ToolHelper *helper)
00039 : Tool(helper)
00040 {
00041 m_greatCircles.setVisualizationState(helper->GetVisualizationStatePtr());
00042 }
00043
00044
00045 void PreviewControlPointTool::Activate()
00046 {
00047 helper->NotifyMe(PreviewToolHelper::DRAW_OVER_IMAGES, this);
00048 }
00049
00050
00051 void PreviewControlPointTool::AfterDrawImagesEvent()
00052 {
00053
00054 MakeTransforms();
00055
00056
00057 const HuginBase::CPVector &control_points = helper->GetPanoramaPtr()->getCtrlPoints();
00058
00059
00060 helper->GetViewStatePtr()->GetTextureManager()->DisableTexture();
00061 glColor3f(1.0, 0.5, 0.0);
00062 size_t cp_count = control_points.size();
00063 for (size_t cp_index = 0; cp_index < cp_count; cp_index++)
00064 {
00065 const HuginBase::ControlPoint &cp = control_points[cp_index];
00066
00067 if ( helper->GetPanoramaPtr()->getImage(cp.image1Nr).getActive()
00068 && helper->GetPanoramaPtr()->getImage(cp.image2Nr).getActive())
00069 {
00070
00071 bool line = cp.mode != HuginBase::ControlPoint::X_Y;
00072 if (line)
00073 {
00074 glColor3f(0.0, 0.5, 1.0);
00075 }
00076 else
00077 {
00078 double red, green, blue;
00079 hugin_utils::ControlPointErrorColour(cp.error,red,green,blue);
00080 glColor3d(red, green, blue);
00081 }
00082
00083 double x1, y1, x2, y2;
00084 transforms[cp.image1Nr].transformImgCoord(x1, y1, cp.x1, cp.y1);
00085 transforms[cp.image2Nr].transformImgCoord(x2, y2, cp.x2, cp.y2);
00086 m_greatCircles.drawLineFromSpherical(x1, y1, x2, y2);
00087 }
00088 }
00089 glColor3f(1.0, 1.0, 1.0);
00090 glEnable(GL_TEXTURE_2D);
00091
00092
00093 delete [] transforms;
00094 }
00095
00096 void PreviewControlPointTool::MakeTransforms()
00097 {
00099 const size_t images_count = helper->GetPanoramaPtr()->getNrOfImages();
00100 transforms = new HuginBase::PTools::Transform [images_count];
00101
00102 HuginBase::PanoramaOptions options;
00103 options.setWidth(360);
00104 options.setHeight(180);
00105 for (unsigned int image_number = 0; image_number < images_count; image_number++)
00106 {
00107
00108 transforms[image_number].createInvTransform(
00109 *(helper->GetVisualizationStatePtr()->GetSrcImage(image_number)),
00110 options
00111 );
00112 }
00113 }
00114