PreviewPanoMaskTool.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00022 #include "PreviewPanoMaskTool.h"
00023 #include <wx/platform.h>
00024 #ifdef __WXMAC__
00025 #include <OpenGL/gl.h>
00026 #else
00027 #include <GL/gl.h>
00028 #endif
00029 
00030 PreviewPanoMaskTool::PreviewPanoMaskTool(PreviewToolHelper *helper)
00031     : PreviewTool(helper)
00032 {
00033 }
00034 
00035 void PreviewPanoMaskTool::Activate()
00036 {
00037     // we draw to the sentcil buffer the desired shape, and enable the stencil
00038     // test before the images are rendered. After they have all been drawn, we
00039     // turn off stenciling so the other tools can draw of the complete area.
00040     helper->NotifyMe(PreviewToolHelper::REALLY_DRAW_OVER_IMAGES, this);
00041 }
00042 
00043 void PreviewPanoMaskTool::BeforeDrawImagesEvent()
00044 {
00045 }
00046 
00047 void PreviewPanoMaskTool::ReallyAfterDrawImagesEvent()
00048 {
00049     switch (helper->GetViewStatePtr()->GetOptions()->getProjection())
00050     {
00051         case HuginBase::PanoramaOptions::SINUSOIDAL:
00052             helper->GetViewStatePtr()->GetTextureManager()->DisableTexture();
00053             glColor3f(0.0, 0.0, 0.0);
00054             {
00055                 // Under a sinusodial projection, we mask off the sides.
00056                 OutputProjectionInfo *info = helper->GetViewStatePtr()->
00057                                                             GetProjectionInfo();
00058                 double x, y;
00059                 glBegin(GL_QUAD_STRIP);
00060                     for (double p = -90; p < 90; p += 1.0)
00061                     {
00062                         info->AngularToImage(x, y, -180.0, p);
00063                         glVertex2d(x, y); glVertex2d(0.0, y);
00064                     }
00065                 glEnd();
00066                 double width = helper->GetViewStatePtr()->GetOptions()->
00067                                                               getSize().width();
00068                 glBegin(GL_QUAD_STRIP);
00069                     for (double p = -90; p < 90; p += 1.0)
00070                     {
00071                         info->AngularToImage(x, y, -180.0, p);
00072                         glVertex2d(width - x, y); glVertex2d(width, y);
00073                     }
00074                 glEnd();
00075             }
00076             glEnable(GL_TEXTURE_2D);
00077             glColor3f(1.0, 1.0, 1.0);
00078             break;
00079         case HuginBase::PanoramaOptions::ALBERS_EQUAL_AREA_CONIC:
00080             // Under a albers equal area conic projection, we mask a circle
00081             // segment with a hole in the middle. The dimensions and centre
00082             // are depended on the projection parameters.
00083             helper->GetViewStatePtr()->GetTextureManager()->DisableTexture();
00084             glColor3f(0.0, 0.0, 0.0);
00085             glStencilFunc(GL_EQUAL, 1, 1);
00086             glEnable(GL_TEXTURE_2D);
00087             glColor3f(1.0, 1.0, 1.0);
00088             break;
00089         default:
00090             // most projections don't need any of this.
00091             // Always pass the stencil test.
00092             glStencilFunc(GL_ALWAYS, 1, 1);
00093             break;
00094     }
00095 }
00096 

Generated on Fri Aug 1 01:25:38 2014 for Hugintrunk by  doxygen 1.3.9.1