26 #include "hugin_config.h"
35 #if defined HAVE_EPOXY && HAVE_EPOXY
42 #include <OpenGL/gl.h>
43 #include <OpenGL/glu.h>
56 #define circle_ts_multiple 4
57 #define circle_ts (rect_ts * circle_ts_multiple)
58 #define circle_middle ((float) (circle_ts - 1) / 2.0)
59 #define circle_border_outer (circle_middle - 0.5 * (float) circle_ts_multiple)
60 #define circle_border_inner (circle_middle - 2.5 * (float) circle_ts_multiple)
61 #define circle_border_peak (circle_middle - 1.5 * (float) circle_ts_multiple)
70 #define FONT_TEXTURE_HEIGHT 75
71 wxBitmap
GenerateFontTexture(
const int textureHeight,
int& textureWidth, std::vector<int>& glyphWidth)
73 wxBitmap bitmap(10 * textureHeight, textureHeight);
74 wxMemoryDC dc(bitmap);
75 dc.SetBackground(*wxBLACK_BRUSH);
77 wxFont font(wxSize(0, textureHeight), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
79 dc.SetTextForeground(*wxWHITE);
80 dc.DrawText(wxT(
"0123456789"), 0, 0);
82 glyphWidth.resize(10, 0);
83 for (
int i = 0; i < 10; ++i)
87 wxSize textSize = dc.GetTextExtent(number);
88 textureWidth += textSize.GetWidth();
89 glyphWidth[i] = textSize.GetWidth();
91 dc.SelectObject(wxNullBitmap);
119 for (
unsigned int x = 0; x <
rect_ts; x++)
121 for (
unsigned int y = 0; y <
rect_ts; y++)
123 rect_tex_data[x][y][0] = 255;
127 for (
unsigned int x = 2; x < rect_ts - 2; x++)
129 for (
unsigned int y = 2; y < rect_ts - 2; y++)
131 rect_tex_data[x][y][1] = 63;
135 for (
unsigned int d = 1; d < rect_ts - 1; d++)
137 rect_tex_data[d][1][1] = 255;
138 rect_tex_data[d][rect_ts - 2][1] = 255;
139 rect_tex_data[1][d][1] = 255;
140 rect_tex_data[rect_ts - 2][d][1] = 255;
143 for (
unsigned int d = 0; d <
rect_ts; d++)
145 rect_tex_data[d][0][1] = 0;
146 rect_tex_data[d][rect_ts - 1][1] = 0;
147 rect_tex_data[0][d][1] = 0;
148 rect_tex_data[rect_ts - 1][d][1] = 0;
151 gluBuild2DMipmaps(GL_TEXTURE_2D, GL_LUMINANCE_ALPHA, rect_ts, rect_ts,
152 GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, rect_tex_data);
153 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
154 GL_LINEAR_MIPMAP_LINEAR);
156 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
157 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
165 for (
unsigned int x = 0; x <
circle_ts; x++)
167 for (
unsigned int y = 0; y <
circle_ts; y++)
171 radius = sqrt(x_offs * x_offs + y_offs * y_offs),
188 circle_tex_data[x][y][0] = 255;
189 circle_tex_data[x][y][1] = (
unsigned char) intensity;
193 gluBuild2DMipmaps(GL_TEXTURE_2D,
194 GL_LUMINANCE_ALPHA, circle_ts, circle_ts,
195 GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, circle_tex_data);
196 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
197 GL_LINEAR_MIPMAP_LINEAR);
199 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
200 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
205 wxImage image = fontTexture.ConvertToImage();
206 glGenTextures(1, (GLuint*)&
font_tex);
207 glBindTexture(GL_TEXTURE_2D,
font_tex);
209 for (
size_t x = 0; x < textureWidth; ++x)
213 const unsigned char value = image.GetRed(x, y);
214 font_tex_data[2 * y * textureWidth + 2 * x] = value;
215 font_tex_data[2 * y * textureWidth + 2 * x + 1] = value;
218 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
219 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
221 GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, font_tex_data);
222 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
223 GL_LINEAR_MIPMAP_LINEAR);
224 delete[] font_tex_data;
228 for (
int loop = 0; loop<10; loop++)
232 glTexCoord2f(posX, 0);
234 glTexCoord2f(posX +
m_glyphWidth[loop] / static_cast<float>(textureWidth), 0);
236 glTexCoord2f(posX +
m_glyphWidth[loop] / static_cast<float>(textureWidth), 1);
238 glTexCoord2f(posX, 1);
243 posX +=
m_glyphWidth[loop] /
static_cast<float>(textureWidth);
257 glDeleteTextures(1, (GLuint*)&
font_tex);
287 DEBUG_ASSERT(img < helper->GetPanoramaPtr()->getNrOfImages());
317 if (
m_stopUpdating && !e.LeftIsDown() && !e.MiddleIsDown() && !e.RightIsDown()) {
348 if (keycode == WXK_CONTROL) {
363 if (constant_on_in) {
405 const unsigned int num_images =
m_image_set.size();
409 glMatrixMode(GL_MODELVIEW);
412 DEBUG_ASSERT(*it < helper->GetPanoramaPtr()->getNrOfImages());
417 glMatrixMode(GL_TEXTURE);
421 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
422 unsigned int image_counter = 0;
427 glMatrixMode(GL_TEXTURE);
433 glActiveTexture(GL_TEXTURE0);
439 int width = src->getSize().width(), height = src->getSize().height();
440 vigra::Rect2D crop_region = src->getCropRect();
442 switch (src->getCropMode())
447 if (crop_region.width() < crop_region.height())
450 int diff = (crop_region.width() - crop_region.height()) / 2;
453 crop_region.addBorder(0, diff);
454 }
else if (crop_region.width() > crop_region.height())
457 int diff = (crop_region.height() - crop_region.width()) / 2;
458 crop_region.addBorder(diff, 0);
461 float diameter = (float) crop_region.width();
462 glScalef((
float) width / diameter,
463 (
float) height / diameter, 1.0);
464 glTranslatef(-(
float) crop_region.left() / (float) width,
465 -(
float) crop_region.top() / (float) height,
472 crop_region &= vigra::Rect2D(src->getSize());
474 glScalef((
float) width / (
float) crop_region.width(),
475 (float) height / (
float) crop_region.height(),
477 glTranslatef(-(
float) crop_region.left() / (float) width,
478 -(
float) crop_region.top() / (float) height,
486 glMatrixMode(GL_MODELVIEW);
492 glMatrixMode(GL_TEXTURE);
506 if (transform.
transformImgCoord(imageCenterPano, imageCenter) && !wxGetKeyState(WXK_ALT))
508 glBindTexture(GL_TEXTURE_2D,
font_tex);
511 glActiveTexture(GL_TEXTURE1);
512 glDisable(GL_TEXTURE_2D);
513 glActiveTexture(GL_TEXTURE0);
515 glMatrixMode(GL_MODELVIEW);
520 unsigned char* listIndex =
new unsigned char[number.Length()];
521 for (
size_t i = 0; i < number.Length(); ++i)
524 listIndex[i] = number[i].GetValue() - 48;
527 imageCenterPano.x = std::min<double>(std::max<double>(imageCenterPano.x, textWidth*scaleFactor / 2.0), canvasWidth - textWidth * scaleFactor / 2.0);
529 glTranslatef(imageCenterPano.x, imageCenterPano.y, 0);
530 glScalef(scaleFactor, scaleFactor, 1.0);
533 glCallLists(number.Length(), GL_UNSIGNED_BYTE, listIndex);
534 glMatrixMode(GL_MODELVIEW);
541 glMatrixMode(GL_MODELVIEW);
543 glColor3ub(255, 255, 255);
549 DEBUG_ASSERT(image < helper->GetPanoramaPtr()->getNrOfImages());
556 DEBUG_ASSERT(image < helper->GetPanoramaPtr()->getNrOfImages());
589 unsigned char &green,
594 float hue = ((float) index / (
float) count) * 6.0;
599 green = (
unsigned char) (hue * 255.0);
601 }
else if (hue < 2.0) {
603 red = (
unsigned char) ((-hue + 2.0) * 255.0);
606 }
else if (hue < 3.0) {
610 blue = (
unsigned char) ((hue - 2.0) * 255.0);
611 }
else if (hue < 4.0) {
614 green = (
unsigned char) ((-hue + 4.0) * 255.0);
616 }
else if (hue < 5.0) {
618 red = (
unsigned char) ((hue - 4.0) * 255.0);
625 blue = (
unsigned char) ((-hue + 6.0) * 255.0);
663 if (e.ButtonUp() && !e.MiddleIsDown() && !e.RightIsDown()) {
680 new_image_set.begin(), new_image_set.end(),
681 std::inserter(difference,difference.end()));
682 if (!difference.empty())
684 for (
auto& img : difference)
686 DEBUG_ASSERT(img < helper->GetPanoramaPtr()->getNrOfImages());
696 if (!new_image_set.empty())
699 std::set_difference(new_image_set.begin(), new_image_set.end(),
701 std::inserter(difference, difference.end()));
702 if (!difference.empty())
704 for (
auto& img : difference)
706 DEBUG_ASSERT(img < helper->GetPanoramaPtr()->getNrOfImages());
The OpenGL preview frame.
unsigned int getHeight() const
get panorama height
#define DEBUG_ASSERT(cond)
include file for the hugin project
void ForceRequireRedraw()
HuginBase::PanoramaOptions * GetOptions()
std::set< unsigned int > UIntSet
static MainFrame * Get()
hack.. kind of a pseudo singleton...
TextureManager * GetTextureManager()
void UpdateIdentifyTools(std::set< unsigned int > new_image_set)
void ShowMaskEditor(size_t imgNr, bool switchToCropMode=false)
opens the mask/crop editor with the given image selected
void BindTexture(unsigned int image_number)
unsigned int getWidth() const
include file for the hugin project
void ShowCtrlPointEditor(unsigned int img1, unsigned int img2)
opens the control points tab with the both images selected
HuginBase::SrcPanoImage * GetSrcImage(unsigned int image_nr)
All variables of a source image.
unsigned int GetMeshDisplayList(unsigned int image_nr)
void SetImageButtonColour(unsigned int image_nr, unsigned char red, unsigned char green, unsigned char blue)
bool GetSupportMultiTexture() const