Hugin trunk 0.1
Loading...
Searching...
No Matches
PreviewGuideTool.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
11/* This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This software is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public
22 * License along with this software. If not, see
23 * <http://www.gnu.org/licenses/>.
24 *
25 */
26
27#ifdef _WIN32
28#include "wx/msw/wrapwin.h"
29#endif
30#include "PreviewGuideTool.h"
31#ifdef __WXMAC__
32#include <OpenGL/gl.h>
33#else
34#include <GL/gl.h>
35#endif
36
38{
39}
40
45
46void DrawThirds(const vigra::Rect2D roi)
47{
48 double width3 = (double) roi.width()/3.0;
49 double height3 = (double) roi.height()/3.0;
51 glVertex2f((double)roi.left()+width3,roi.top());
52 glVertex2f((double)roi.left()+width3,roi.bottom());
53 glVertex2f((double)roi.left()+2.0*width3,roi.top());
54 glVertex2f((double)roi.left()+2.0*width3,roi.bottom());
55 glVertex2f(roi.left(), (double)roi.top()+height3);
56 glVertex2f(roi.right(),(double)roi.top()+height3);
57 glVertex2f(roi.left(), (double)roi.top()+2.0*height3);
58 glVertex2f(roi.right(),(double)roi.top()+2.0*height3);
59 glEnd();
60};
61
62void DrawGoldenRatio(const vigra::Rect2D roi)
63{
64 double width = (double) roi.width();
65 double height = (double) roi.height();
67 glVertex2f((double)roi.left()+width*0.382,roi.top());
68 glVertex2f((double)roi.left()+width*0.382,roi.bottom());
69 glVertex2f((double)roi.left()+width*0.618,roi.top());
70 glVertex2f((double)roi.left()+width*0.618,roi.bottom());
71 glVertex2f(roi.left(), (double)roi.top()+height*0.382);
72 glVertex2f(roi.right(),(double)roi.top()+height*0.382);
73 glVertex2f(roi.left(), (double)roi.top()+height*0.618);
74 glVertex2f(roi.right(),(double)roi.top()+height*0.618);
75 glEnd();
76};
77
78void DrawDiagonal(const vigra::Rect2D roi)
79{
81 glVertex2f(roi.left(), roi.top());
82 glVertex2f(roi.right(), roi.bottom());
83 glVertex2f(roi.left(), roi.bottom());
84 glVertex2f(roi.right(), roi.top());
85 glVertex2f(roi.left(), roi.top()+roi.height()/2.0);
86 glVertex2f(roi.right(), roi.top()+roi.height()/2.0);
87 glVertex2f(roi.left()+roi.width()/2.0, roi.top());
88 glVertex2f(roi.left()+roi.width()/2.0, roi.bottom());
89 glEnd();
90};
91
92void DrawTriangle(const vigra::Rect2D roi, const bool up)
93{
94 double w=roi.width();
95 double h=roi.height();
96 double x=w/(1+pow(w/h,2));
97 double y=h/(1+pow(w/h,2));
99 if(up)
100 {
101 glVertex2f(roi.left(), roi.bottom());
102 glVertex2f(roi.right(), roi.top());
103 glVertex2f(roi.right()-x, roi.top()+y);
104 glVertex2f(roi.right(), roi.bottom());
105 glVertex2f(roi.left()+x, roi.bottom()-y);
106 glVertex2f(roi.left(), roi.top());
107 }
108 else
109 {
110 glVertex2f(roi.left(), roi.top());
111 glVertex2f(roi.right(), roi.bottom());
112 glVertex2f(roi.right()-x, roi.bottom()-y);
113 glVertex2f(roi.right(), roi.top());
114 glVertex2f(roi.left()+x, roi.top()+y);
115 glVertex2f(roi.left(), roi.bottom());
116 }
117 glEnd();
118};
119
120void DrawDiagonalMethod(const vigra::Rect2D roi)
121{
122 double w=roi.width();
123 double h=roi.height();
125 glVertex2f(roi.left(), roi.top());
126 if(w>h)
127 {
128 glVertex2f(roi.left()+h, roi.bottom());
129 }
130 else
131 {
132 glVertex2f(roi.right(), roi.top()+w);
133 };
134 glVertex2f(roi.left(), roi.bottom());
135 if(w>h)
136 {
137 glVertex2f(roi.left()+h, roi.top());
138 }
139 else
140 {
141 glVertex2f(roi.right(), roi.bottom()-w);
142 };
143 glVertex2f(roi.right(), roi.top());
144 if(w>h)
145 {
146 glVertex2f(roi.right()-h, roi.bottom());
147 }
148 else
149 {
150 glVertex2f(roi.left(), roi.top()+w);
151 };
152 glVertex2f(roi.right(), roi.bottom());
153 if(w>h)
154 {
155 glVertex2f(roi.right()-h, roi.top());
156 }
157 else
158 {
159 glVertex2f(roi.left(), roi.bottom()-w);
160 };
161 glEnd();
162};
163
165{
166 if(m_guide==NONE)
167 {
168 return;
169 };
171 vigra::Rect2D roi = opts->getROI();
173 glColor3f(1,1,0);
174 switch(m_guide)
175 {
176 case THIRDS:
178 break;
179 case GOLDENRATIO:
181 break;
182 case DIAGONAL:
184 break;
185 case TRIANGLE_DOWN:
186 DrawTriangle(roi,false);
187 break;
188 case TRIANGLE_UP:
189 DrawTriangle(roi,true);
190 break;
191 case DIAGONAL_METHOD:
193 break;
194 case NONE:
195 break;
196 };
198}
199
205
210
void DrawTriangle(const vigra::Rect2D roi, const bool up)
void DrawThirds(const vigra::Rect2D roi)
void DrawDiagonal(const vigra::Rect2D roi)
void DrawGoldenRatio(const vigra::Rect2D roi)
void DrawDiagonalMethod(const vigra::Rect2D roi)
interface to ToolHelper for drawing guide lines over pano
Panorama image options.
const vigra::Rect2D & getROI() const
PreviewGuideTool(PreviewToolHelper *helper)
constructor
const Guides GetGuideStyle() const
returns the current guide style
void ReallyAfterDrawImagesEvent()
draws the lines
void Activate()
activate the tool
void SetGuideStyle(const Guides newGuideStyle)
sets the guide style to the given style
void NotifyMe(Event event, Tool *tool)
ViewState * GetViewStatePtr()
@ REALLY_DRAW_OVER_IMAGES
Definition ToolHelper.h:83
ToolHelper * helper
The PreviewToolHelper that uses the same preview window and panorama as the tool should.
Definition Tool.h:109
HuginBase::PanoramaOptions * GetOptions()
void Redraw()
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