31 #include <wx/dcbuffer.h>
40 #include <vigra/inspectimage.hxx>
54 wxScrolledWindow::Create(parent,
id, pos, size, style, name);
66 SetBackgroundStyle(wxBG_STYLE_PAINT);
107 SetCursor(wxNullCursor);
132 m_img = ImageCache::getInstance().getImage(file);
142 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
148 SetVirtualSize(100, 100);
151 wxCommandEvent e(EVT_LOADING_FAILED);
181 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
187 SetVirtualSize(100,100);
278 double dist=sqrt(
double((pos-pos_center).squaredMagnitude()));
313 int newLeft, newRight, newTop, newBottom;
314 bool needsUpdate=
false;
323 double newHalfWidth=
m_cropRect.width()/2.0-delta.
x;
339 double newHalfWidth=
m_cropRect.width()/2.0+delta.
x;
355 double newHalfHeight=
m_cropRect.height()/2.0-delta.
y;
371 double newHalfHeight=
m_cropRect.height()/2.0+delta.
y;
414 m_cropRect.setUpperLeft(vigra::Point2D(newLeft, newTop));
415 m_cropRect.setLowerRight(vigra::Point2D(newRight, newBottom));
426 wxPoint viewStart = GetViewStart();
427 viewStart = viewStart - (mouse.GetPosition() -
m_scrollPos);
433 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
436 bool doUpdate =
false;
464 switch(
GetClickPos(vigra::Point2D(currentPos.x, currentPos.y)))
469 SetCursor(wxCURSOR_HAND);
473 SetCursor(wxNullCursor);
482 SetCursor(wxCURSOR_SIZENS);
485 SetCursor(wxCURSOR_SIZEWE);
494 SetCursor(wxCURSOR_SIZEWE);
497 SetCursor(wxCURSOR_SIZENS);
501 SetCursor(wxCURSOR_SIZING);
504 SetCursor(wxNullCursor);
535 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
573 for(HuginBase::UIntSet::const_iterator it=points.begin();it!=points.end();++it)
610 if(!mouse.ShiftDown())
612 for(HuginBase::UIntSet::const_iterator it=points.begin();it!=points.end();++it)
624 switch(
GetClickPos(vigra::Point2D(currentPos.x,currentPos.y)))
670 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
730 if(!mouse.ShiftDown())
776 SetCursor(wxNullCursor);
836 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
866 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
912 for(HuginBase::UIntSet::const_reverse_iterator it=points.rbegin();it!=points.rend();++it)
918 for(
unsigned int i=0;i<mappedSelectedPoints.size();i++)
919 mappedSelectedPoints[i]=i;
922 for(HuginBase::UIntSet::const_iterator it=points.begin();it!=points.end();++it)
924 if((*it)<mappedSelectedPoints.size()-1)
925 for(
unsigned int i=(*it)+1;i<mappedSelectedPoints.size();i++)
926 mappedSelectedPoints[i]--;
928 for(HuginBase::UIntSet::const_iterator it=temp.begin();it!=temp.end();++it)
1020 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y, &mpos.x, &mpos.y);
1057 const int key=e.GetKeyCode();
1058 bool processed=
false;
1059 if((key==WXK_DELETE) || (key==WXK_NUMPAD_DELETE))
1077 wxCommandEvent dummy;
1089 wxCommandEvent dummy;
1104 wxCommandEvent zoomEvent(wxEVT_CHOICE, XRCID(
"mask_editor_choice_zoom"));
1105 zoomEvent.SetInt(0);
1106 zoomEvent.SetString(
"update_selection");
1107 GetParent()->GetEventHandler()->AddPendingEvent(zoomEvent);
1113 wxCommandEvent zoomEvent(wxEVT_CHOICE, XRCID(
"mask_editor_choice_zoom"));
1114 zoomEvent.SetInt(2);
1115 zoomEvent.SetString(
"update_selection");
1116 GetParent()->GetEventHandler()->AddPendingEvent(zoomEvent);
1122 wxCommandEvent zoomEvent(wxEVT_CHOICE, XRCID(
"mask_editor_choice_zoom"));
1123 zoomEvent.SetInt(1);
1124 zoomEvent.SetString(
"update_selection");
1125 GetParent()->GetEventHandler()->AddPendingEvent(zoomEvent);
1137 wxPoint offset = GetViewStart();
1139 switch (e.GetKeyCode())
1205 wxPoint *polygonPoints=
new wxPoint[nrOfPoints];
1206 for(
unsigned int j=0;j<nrOfPoints;j++)
1225 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1227 dc.DrawPolygon(nrOfPoints,polygonPoints);
1229 dc.DrawLine(polygonPoints[0],polygonPoints[1]);
1236 for(
unsigned int j=0;j<nrOfPoints;j++)
1240 dc.SetPen(penSelected);
1241 dc.SetBrush(brushSelected);
1245 dc.SetPen(penUnselected);
1246 dc.SetBrush(brushUnselected);
1252 delete []polygonPoints;
1261 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1266 dc.DrawLine( middle.x + c, middle.y + c, middle.x - c, middle.y - c);
1267 dc.DrawLine( middle.x - c, middle.y + c, middle.x + c, middle.y - c);
1275 dc.DrawCircle(middle.x, middle.y,
scale(radius));
1282 wxAutoBufferedPaintDC dc(
this);
1284 dc.SetBackground(GetBackgroundColour());
1289 dc.DrawBitmap(
m_bitmap, offset, offset);
1298 region.Union(wholeImage);
1308 unsigned int nrOfPoints = dc.GetSize().GetWidth() * 2;
1309 wxPoint* circlePoints =
new wxPoint[nrOfPoints];
1312 double interval = 2 *
PI / nrOfPoints;
1313 for (
unsigned int i = 0; i < nrOfPoints; i++)
1317 region.Subtract(wxRegion(nrOfPoints, circlePoints));
1318 delete[]circlePoints;
1330 wxPoint *polygonPoints=
new wxPoint[poly.size()];
1331 for(
unsigned int j=0;j<poly.size();j++)
1335 wxRegion singleRegion(poly.size(),polygonPoints,wxWINDING_RULE);
1338 wxRegion newRegion(wholeImage);
1339 newRegion.Subtract(singleRegion);
1340 region.Union(newRegion);
1344 region.Union(singleRegion);
1346 delete []polygonPoints;
1355 GetViewStart(&x,&y);
1356 region.Offset(-x,-y);
1358 dc.SetDeviceClippingRegion(region);
1360 dc.DestroyClippingRegion();
1368 for(
unsigned int i=0;i<maskList.size();i++)
1418 vigra::FindAverage<vigra::RGBValue<vigra::UInt8> > average;
1420 vigra::RGBValue<vigra::UInt8> RGBaverage=average.average();
1421 if(RGBaverage[0]<180 && RGBaverage[1]<180 && RGBaverage[2]<180)
1430 if (img.GetWidth() == 0)
1434 m_imageSize = wxSize(img.GetWidth(), img.GetHeight());
1445 wxImageResizeQuality resizeQuality = wxIMAGE_QUALITY_NORMAL;
1446 if (
std::max(img.GetWidth(), img.GetHeight()) > (ULONG_MAX >> 16))
1452 resizeQuality = wxIMAGE_QUALITY_BOX_AVERAGE;
1454 img=img.Scale(
scale(m_realSize.GetWidth()),
scale(m_realSize.GetHeight()), resizeQuality);
1466 img = img.Rotate90(
true);
1469 img = img.Rotate180();
1472 img = img.Rotate90(
false);
1480 vigra::ImageImportInfo::ICCProfile iccProfile;
1482 if (
m_img->imageFloat->width() == 0)
1484 iccProfile = *(
m_img->iccProfile);
1491 img = img.ConvertToDisabled(192);
1501 SetScrollRate(1, 1);
1509 #if wxCHECK_VERSION(3,3,0)
1514 wxClientDC dc(
this);
1520 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1527 unsigned int selectedPolygon=UINT_MAX;
1529 while(selectedPolygon==UINT_MAX && i<
m_imageMask.size())
1535 if(selectedPolygon<UINT_MAX)
1549 for(
unsigned int i=0;i<poly.size();i++)
1551 bool activePoints=
true;
1552 if(considerSelectedOnly)
1554 if(activePoints && xmin<=poly[i].x && poly[i].x<=xmax && ymin<=poly[i].y && poly[i].y<=ymax)
1586 int w = size.GetWidth();
1587 int h = size.GetHeight();
1595 wxSize csize = GetSize();
1596 DEBUG_DEBUG(
"csize: " << csize.GetWidth() <<
"x" << csize.GetHeight() <<
"image: " << w <<
"x" <<
h);
1597 double s1 = (double)csize.GetWidth()/w;
1598 double s2 = (double)csize.GetHeight()/
h;
1600 return s1 < s2 ? s1 : s2;
1617 : wxXmlResourceHandler()
1626 cp->Create(m_parentAsWindow,
1628 GetPosition(), GetSize(),
1639 return IsOfClass(node,
"MaskImageCtrl");
ImageRotation
image rotation.
T applyRotInv(const T &p) const
void UpdateCropFromImage()
updates the displayed crop in the text boxes (for dragging)
hugin_utils::FDiff2D getCenter() const
return the center point of the polygon
bool isInside(const hugin_utils::FDiff2D p) const
checks if given point is inside of the stored polygon
void removePoint(const unsigned int index)
removes point at the position index from the polygon
wxColour m_color_selection
void OnKeyUp(wxKeyEvent &e)
event handler for keyboard
HuginBase::SrcPanoImage::CropMode m_cropMode
const int maskOffset
polygon can exceed the image maximal maskOffset pixels in each direction bigger polygons will be clip...
void movePointBy(const unsigned int index, const hugin_utils::FDiff2D diff)
relativ moves the point at position index by diff
void setActiveMask(unsigned int newMask, bool doUpdate=true)
mark mask with image as beeing editing
bool SelectPointsInsideMouseRect(HuginBase::UIntSet &points, const bool considerSelectedOnly)
void SelectMask(unsigned int newMaskNr)
selects the mask with index newMaskNr in the listbox
MaskEditorPanel * m_editPanel
std::string m_imageFilename
virtual wxObject * DoCreateResource()
bool set_contains(const _Container &c, const typename _Container::key_type &key)
hugin_utils::FDiff2D m_cropCenter
include file for the hugin project
void rescaleImage()
rescale the image
void OnLeftMouseDblClick(wxMouseEvent &mouse)
event handler for left double click
wxColor m_colour_point_selected
void GetMonitorProfile(wxString &profileName, cmsHPROFILE &profile)
#define PI
Header file for Khan's deghosting algorithm Copyright (C) 2009 Lukáš Jirkovský l...
void OnPaint(wxPaintEvent &e)
drawing routine
static huginApp * Get()
hack.. kind of a pseudo singleton...
HuginBase::MaskPolygonVector m_imageMask
VectorPolygon getMaskPolygon() const
returns vector with coordinates of the polygon
void OnMouseMove(wxMouseEvent &mouse)
event handler when mouse is moving
std::set< unsigned int > UIntSet
void OnRightMouseUp(wxMouseEvent &mouse)
event handler when right mouse button is released
xrc handler for mask editor
void setImage(const std::string &filename, HuginBase::MaskPolygonVector newMask, HuginBase::MaskPolygonVector masksToDraw, ImageRotation rot)
set the current image and mask list, this loads also the image from cache
const int polygonPointSize
half size of markers
int invtransform(int x) const
translate screen coordinates to image coordinates, considers additional added border ...
void CorrectImage(wxImage &image, const vigra::ImageImportInfo::ICCProfile &iccProfile, const cmsHPROFILE &monitorProfile)
apply color correction to given image using input iccProfile and monitor profile
static MainFrame * Get()
hack.. kind of a pseudo singleton...
void OnRightMouseDown(wxMouseEvent &mouse)
event handler when right mouse button is pressed
wxImage imageCacheEntry2wxImage(ImageCache::EntryPtr e)
void OnMouseWheel(wxMouseEvent &mouse)
event handler for mouse wheel
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
double calcAutoScaleFactor(wxSize size)
calculate new scale factor for this image
bool HasMonitorProfile() const
return true if we found a suitable monitor profile and could loading it
void UpdateMask()
called when mask where changed in MaskImageCtrl
void OnSize(wxSizeEvent &e)
handler called when size of control was changed
void UpdateCrop(bool updateFromImgCtrl=false)
updated the crop in the Panorama object with the current values from GUI
int scale(int x) const
scale of width/height
void OnCaptureLost(wxMouseCaptureLostEvent &e)
event handler, when mouse capture is lost, e.g.
double getScaleFactor() const
get scale factor (calculates factor when fit to window is active)
wxSize DoGetBestSize() const override
returns size of currently scaled image
std::vector< MaskPolygon > MaskPolygonVector
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 OnKillFocus(wxFocusEvent &e)
event handler, when editor lost focus, mainly cancels creating new polygon
void OnSizeFinished(wxTimerEvent &e)
handler called at end of all resize
void DrawSelectionRectangle()
void selectAllMarkers()
select all points of active mask
void setNewMasks(HuginBase::MaskPolygonVector newMasks, HuginBase::MaskPolygonVector masksToDraw)
updates masks for currently selected image
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name="panel")
void OnMiddleMouseDown(wxMouseEvent &mouse)
event handler for middle mouse button, start scrolling
ImageRotation m_imgRotation
include file for the hugin project
void movePointTo(const unsigned int index, const hugin_utils::FDiff2D p)
moves the point at position index to the new absolute position p
void OnLeftMouseUp(wxMouseEvent &mouse)
event handler when right mouse button is released
void insertPoint(const unsigned int index, const hugin_utils::FDiff2D p)
insert point at the position index into the polygon
void setScale(double factor)
set the scaling factor for mask editing display.
MaskEditorState m_maskEditState
std::vector< hugin_utils::FDiff2D > VectorPolygon
vector, which stores coordinates of one polygon
ClickPos GetClickPos(vigra::Point2D pos)
void Init(MaskEditorPanel *parent)
void SetMaskMode(bool newMaskMode)
sets the control to mask (newMaskMode=true) or crop (newMaskMode=false) mode
const int maxSelectionDistance
maximal distance for selection of one point
unsigned int FindPointNearPos(const hugin_utils::FDiff2D p, const double tol) const
search a point which lies near the polygon line and return the index for inserting the new point ...
void DrawPolygon(wxDC &dc, HuginBase::MaskPolygon poly, bool isSelected, bool drawMarker)
void OnMaskDelete(wxCommandEvent &e)
called when user wants to delete active mask
HuginBase::UIntSet m_selectedPoints
ImageCache::EntryPtr m_img
MaskType getMaskType() const
returns mask type
wxColor m_colour_polygon_positive
void fill_set(_Container &c, typename _Container::key_type begin, typename _Container::key_type end)
void OnScroll(wxScrollWinEvent &e)
event handler for remember scroll position
T applyRot(const T &p) const
void startNewPolygon()
starts creating a new polygon
wxBitmap m_disabledBitmap
unsigned int m_activeMask
wxColor m_colour_polygon_negative
wxColor m_colour_point_unselected
void AddMask()
called when new mask added in MaskImageCtrl
void FindPolygon(hugin_utils::FDiff2D p)
void setCrop(HuginBase::SrcPanoImage::CropMode newCropMode, vigra::Rect2D newCropRect, bool isCentered, hugin_utils::FDiff2D center, bool isCircleCrop)
updates the crop mode and crop rect
int transform(int x) const
convert image coordinate to screen coordinates, considers additional added border ...
HuginBase::MaskPolygonVector m_masksToDraw
void UpdateCrop(hugin_utils::FDiff2D delta)
virtual bool CanHandle(wxXmlNode *node)
void OnMiddleMouseUp(wxMouseEvent &mouse)
event handler for middle mouse button, end scrolling
void OnLeftMouseDown(wxMouseEvent &mouse)
event handler when left mouse button is pressed
void addPoint(const hugin_utils::FDiff2D p)
adds point at the end to the polygon
void scale(const double factorx, const double factory)
scales all polygon coordinates by factorx for x position and factory for y position ...
base class, which stores one mask polygon
void OnChar(wxKeyEvent &e)
event handler for scrolling with keyboard
void setDrawingActiveMasks(bool newDrawActiveMasks)
set if active masks should be drawn
HuginBase::MaskPolygon m_editingMask