30 #include <wx/dcbuffer.h>
33 #include "vigra/transformimage.hxx"
45 wxScrolledWindow::Create(parent,
id, pos, size, style, name);
46 SetBackgroundStyle(wxBG_STYLE_PAINT);
68 ImageCache::getInstance().softFlush();
69 m_img = ImageCache::getInstance().getImage(file);
79 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
80 SetVirtualSize(100, 100);
105 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
107 SetVirtualSize(100, 100);
134 wxPoint viewStart = GetViewStart();
135 viewStart = viewStart - (mouse.GetPosition() -
m_scrollPos);
141 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y, &mpos.x, &mpos.y);
307 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y, &mpos.x, &mpos.y);
311 bool doUpdate =
false;
362 movedLine.
end = movedLine.
end + delta;
393 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y, &mpos.x, &mpos.y);
468 if (rect.size() == 4)
470 wxPoint* polygonPoints =
new wxPoint[4];
471 for (
unsigned int j = 0; j < 4; j++)
476 dc.SetBrush(*wxTRANSPARENT_BRUSH);
477 dc.DrawPolygon(4, polygonPoints);
480 for (
unsigned int j = 0; j < 4; j++)
485 delete[]polygonPoints;
496 for (
const auto& p : lines)
500 dc.DrawLine(start, end);
510 wxAutoBufferedPaintDC dc(
this);
512 dc.SetBackground(GetBackgroundColour());
528 dc.DrawBitmap(
m_bitmap, offset, offset);
556 if (abs(cp.
x1 - cp.
x2) < abs(cp.
y1 - cp.
y2))
592 controlPoints.push_back(
GetCP(index, p.start, p.end));
595 return controlPoints;
603 SetVirtualSize(GetClientSize());
617 for (
const auto& l : lines)
647 if (img.GetWidth() == 0)
651 m_imageSize = wxSize(img.GetWidth(), img.GetHeight());
664 wxImageResizeQuality resizeQuality = wxIMAGE_QUALITY_NORMAL;
665 if (
std::max(img.GetWidth(), img.GetHeight()) > (ULONG_MAX >> 16))
671 resizeQuality = wxIMAGE_QUALITY_BOX_AVERAGE;
673 img = img.Scale(
scale(m_realSize.GetWidth()),
scale(m_realSize.GetHeight()), resizeQuality);
685 img = img.Rotate90(
true);
688 img = img.Rotate180();
691 img = img.Rotate90(
false);
697 if (!
m_img->iccProfile->empty() || wxGetApp().GetToolboxFrame()->HasMonitorProfile())
731 vigra::BRGBImage remappedImage = remapped->
m_image;
732 wxImage remappedwxImage;
733 remappedwxImage.SetData((
unsigned char*)remappedImage.data(), remappedImage.width(), remappedImage.height(),
true);
735 if (!
m_img->iccProfile->empty() || wxGetApp().GetToolboxFrame()->HasMonitorProfile())
747 const double l = (p - a) * r / (r * r);
748 if (l >= 0.0 && l <= 1.0)
764 double minDist = DBL_MAX;
766 for (
int i = 0; i < 4; ++i)
787 double minDist = DBL_MAX;
789 for (
int i = 0; i < 4; ++i)
808 std::vector<double> xpos, ypos;
814 std::sort(xpos.begin(), xpos.end());
815 std::sort(ypos.begin(), ypos.end());
816 const unsigned int index = (xpos.size() - 1) / 2;
817 return (p.
x > xpos[index] && p.
x < xpos[index + 1] && p.
y > ypos[index] && p.
y < ypos[index + 1]) ?
true :
false;
824 double minDist = DBL_MAX;
825 int minLineIndex = -1;
826 bool minLineStart =
false;
827 for (
int i = 0; i <
m_lines.size(); ++i)
832 if (distStart < distEnd)
834 if (distStart < minDist)
844 if (distEnd < minDist)
849 minLineStart =
false;
853 if (minLineIndex != -1 && minDist < DBL_MAX)
858 isStart = minLineStart;
870 double minDist = DBL_MAX;
872 for (
int i = 0; i <
m_lines.size(); ++i)
917 int w = size.GetWidth();
918 int h = size.GetHeight();
926 wxSize csize = GetSize();
927 DEBUG_DEBUG(
"csize: " << csize.GetWidth() <<
"x" << csize.GetHeight() <<
"image: " << w <<
"x" <<
h);
928 double s1 = (double)csize.GetWidth() / w;
929 double s2 = (double)csize.GetHeight() /
h;
931 return s1 < s2 ? s1 : s2;
Dummy progress display, without output.
void rescaleImage()
rescale the image
wxColor m_colour_selected
ImageCache::EntryPtr m_img
image cache entry for current image
void OnRightMouseUp(wxMouseEvent &mouse)
event handler when right mouse button is released
void setPanoImage(const SrcPanoImage &src, const PanoramaOptions &dest, vigra::Rect2D roi)
SrcPanoImage getSrcImage(unsigned imgNr) const
get a description of a source image
double GetDistance(const hugin_utils::FDiff2D &p, const hugin_utils::FDiff2D &a, const hugin_utils::FDiff2D &b)
returns distance between point p and line between points a and p, the footpoint of p has to be betwee...
void OnSize(wxSizeEvent &e)
handler called when size of control was changed
void ChangeRotation(ImageRotation newRot)
Contains functions to transform whole images.
std::vector< hugin_utils::FDiff2D > m_rectPoints
include file for the hugin project
int GetNearestLine(const hugin_utils::FDiff2D &p)
return index of nearest line or -1 if the point is too far from all lines
void setScale(double factor)
set the scaling factor for mask editing display.
void SetRectMode(bool newMode)
set line or rect mode
T applyRot(const T &p) const
ImageRotation m_imgRotation
declaration of preview for lens calibration gui
void OnMiddleMouseDown(wxMouseEvent &mouse)
event handler for middle mouse button, start scrolling
represents a control point
double calcAutoScaleFactor(wxSize size)
calculate new scale factor for this image
void GetMonitorProfile(wxString &profileName, cmsHPROFILE &profile)
void DrawRect(wxDC &dc, const std::vector< hugin_utils::FDiff2D > &rect)
void ClipPos(hugin_utils::FDiff2D &pos)
clip the given pos to image size + offset
void OnPaint(wxPaintEvent &e)
drawing routine
void OnMouseMove(wxMouseEvent &mouse)
event handler when mouse is moving
Panorama duplicate() const
duplicate the panorama
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name="panel")
creates the control
double getScaleFactor() const
get scale factor (calculates factor when fit to window is active)
HuginBase::ControlPoint GetCP(const unsigned int index, const hugin_utils::FDiff2D &p1, const hugin_utils::FDiff2D &p2)
return the HuginBase::ControlPoint, using index as image index, p1 and p2 as position, take image rotation into account to decide if control point is horizontal or vertical
void setImage(const std::string &filename, ImageRotation rot)
set the current image and mask list, this loads also the image from cache
void SetRemappedMode(const HuginBase::Panorama &pano)
set the panorama object for remapping, the mouse handler are deactivated
const vigra::Rect2D & getROI() const
int GetNearestRectanglePoint(const hugin_utils::FDiff2D &p)
return index of nearest rectangle point or -1 if the point is too far from rectangle ...
void AddLines(const HuginBase::CPVector &lines)
add the lines to the list
const int polygonPointSize
half size of markers
int scale(int x) const
helper function for scale, offset and rotation
void CorrectImage(wxImage &image, const vigra::ImageImportInfo::ICCProfile &iccProfile, const cmsHPROFILE &monitorProfile)
apply color correction to given image using input iccProfile and monitor profile
const int PerspectiveOffset
size of border at all sides
void DrawLines(wxDC &dc, const std::vector< Line > &lines)
HuginBase::CPVector GetControlPoints(const unsigned int index)
return list of control points
wxImage imageCacheEntry2wxImage(ImageCache::EntryPtr e)
void remapImage(vigra::triple< ImgIter, ImgIter, ImgAccessor > srcImg, vigra_ext::Interpolator interpol, AppBase::ProgressDisplay *progress, bool singleThreaded=false)
remap a image without alpha channel
RemapImage m_image
remapped image
void SetLineColour(wxColour newColour)
sets the colour for the lines
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
int transform(int x) const
convert image coordinate to screen coordinates, considers additional added border ...
evaluate x, points are on a vertical line
std::vector< Line > m_lines
image previewer for perspective correction
T applyRotInv(const T &p) const
PerspectiveEditorState m_editorState
void OnLeftMouseDown(wxMouseEvent &mouse)
event handler when left mouse button is pressed
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
void OnLeftMouseUp(wxMouseEvent &mouse)
event handler when right mouse button is released
bool IsInsideRect(const hugin_utils::FDiff2D &p)
return true, if the point p is inside the rect
hugin_utils::FDiff2D start
void setOriginalMode()
show the original images with selected zoom ration, the mouse handlers are activated ...
void GenerateRemappedImage(const unsigned int newWidth, const unsigned int newHeight)
generates the remapped image suitable for wxBitmap
int invtransform(int x) const
translate screen coordinates to image coordinates, considers additional added border ...
void OnCaptureLost(wxMouseCaptureLostEvent &e)
event handler, when mouse capture is lost, e.g.
unsigned int getWidth() const
ImageRotation
image rotation.
include file for the hugin project
const PanoramaOptions & getOptions() const
returns the options for this panorama
int GetNearestRectangleLine(const hugin_utils::FDiff2D &p)
return index of nearest rectangle line or -1 if the point is too far from the rectangle lines ...
std::string m_imageFilename
std::vector< Line > m_currentLine
void OnMiddleMouseUp(wxMouseEvent &mouse)
event handler for middle mouse button, end scrolling
const int maxSelectionDistance
maximal distance for selection of one point
std::vector< ControlPoint > CPVector
std::vector< hugin_utils::FDiff2D > m_rectPointsStartDrag
void OnKillFocus(wxFocusEvent &e)
event handler, when editor lost focus, mainly cancels creating new polygon
evaluate y, points are on a horizontal line
struct to hold a image state for stitching
void UpdateVirtualSize()
update the virtual size of the control, necessary for correctly display the scrollbars ...
HuginBase::Panorama m_pano
HuginBase::Panorama object for calculation of remapped image.
void setWidth(unsigned int w, bool keepView=true)
set panorama width keep the HFOV, if keepView=true
wxBitmap m_remappedImg
the remapped image as wxBitmap
T squareDistance(TDiff2D< T > other) const
Return square of the distance to another point.
double getScale() const
return scale factor, 0 for autoscale
int GetNearestLinePoint(const hugin_utils::FDiff2D &p, bool &isStart)
return index of nearest line or -1 if the point to far from line