32 #include "vigra/transformimage.hxx"
44 wxScrolledWindow::Create(parent,
id, pos, size, style, name);
65 ImageCache::getInstance().softFlush();
66 m_img = ImageCache::getInstance().getImage(file);
76 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
77 SetVirtualSize(100, 100);
102 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
104 SetVirtualSize(100, 100);
131 wxPoint viewStart = GetViewStart();
132 viewStart = viewStart - (mouse.GetPosition() -
m_scrollPos);
138 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y, &mpos.x, &mpos.y);
304 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y, &mpos.x, &mpos.y);
308 bool doUpdate =
false;
359 movedLine.
end = movedLine.
end + delta;
390 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y, &mpos.x, &mpos.y);
473 if (rect.size() == 4)
475 wxPoint* polygonPoints =
new wxPoint[4];
476 for (
unsigned int j = 0; j < 4; j++)
481 dc.SetBrush(*wxTRANSPARENT_BRUSH);
482 dc.DrawPolygon(4, polygonPoints);
485 for (
unsigned int j = 0; j < 4; j++)
490 delete[]polygonPoints;
501 for (
const auto& p : lines)
505 dc.DrawLine(start, end);
529 dc.DrawBitmap(
m_bitmap, offset, offset);
548 dc.SetPen(wxPen(GetBackgroundColour(), 1, wxPENSTYLE_SOLID));
549 dc.SetBrush(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
565 if (abs(cp.
x1 - cp.
x2) < abs(cp.
y1 - cp.
y2))
601 controlPoints.push_back(
GetCP(index, p.start, p.end));
604 return controlPoints;
612 SetVirtualSize(GetClientSize());
619 for (
const auto& l : lines)
649 if (img.GetWidth() == 0)
653 m_imageSize = wxSize(img.GetWidth(), img.GetHeight());
666 wxImageResizeQuality resizeQuality = wxIMAGE_QUALITY_NORMAL;
667 if (
std::max(img.GetWidth(), img.GetHeight()) > (ULONG_MAX >> 16))
673 resizeQuality = wxIMAGE_QUALITY_BOX_AVERAGE;
675 img = img.Scale(
scale(m_realSize.GetWidth()),
scale(m_realSize.GetHeight()), resizeQuality);
687 img = img.Rotate90(
true);
690 img = img.Rotate180();
693 img = img.Rotate90(
false);
699 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 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
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 GenerateRemappedImage(const unsigned int newWidth, const unsigned int newHeight)
generates the remapped image suitable for wxBitmap
void update()
initiate redraw
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
virtual void OnDraw(wxDC &dc) wxOVERRIDE
drawing routine
evaluate y, points are on a horizontal line
struct to hold a image state for stitching
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