39 #include <vigra/inspectimage.hxx>
71 wxScrolledWindow::Create(parent,
id, pos, size, style, name);
75 m_fitToWindow =
false;
76 m_previewOnly =
false;
77 m_activeMask = UINT_MAX;
78 m_showActiveMasks =
false;
82 m_middleMouseScroll =
false;
97 SetCursor(wxNullCursor);
122 m_img = ImageCache::getInstance().getImage(file);
132 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
138 SetVirtualSize(100, 100);
141 wxCommandEvent e(EVT_LOADING_FAILED);
171 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
177 SetVirtualSize(100,100);
268 double dist=sqrt(
double((pos-pos_center).squaredMagnitude()));
303 int newLeft, newRight, newTop, newBottom;
304 bool needsUpdate=
false;
313 double newHalfWidth=
m_cropRect.width()/2.0-delta.
x;
329 double newHalfWidth=
m_cropRect.width()/2.0+delta.
x;
345 double newHalfHeight=
m_cropRect.height()/2.0-delta.
y;
361 double newHalfHeight=
m_cropRect.height()/2.0+delta.
y;
404 m_cropRect.setUpperLeft(vigra::Point2D(newLeft, newTop));
405 m_cropRect.setLowerRight(vigra::Point2D(newRight, newBottom));
416 wxPoint viewStart = GetViewStart();
417 viewStart = viewStart - (mouse.GetPosition() -
m_scrollPos);
423 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
426 bool doUpdate =
false;
454 switch(
GetClickPos(vigra::Point2D(currentPos.x, currentPos.y)))
459 SetCursor(wxCURSOR_HAND);
463 SetCursor(wxNullCursor);
472 SetCursor(wxCURSOR_SIZENS);
475 SetCursor(wxCURSOR_SIZEWE);
484 SetCursor(wxCURSOR_SIZEWE);
487 SetCursor(wxCURSOR_SIZENS);
491 SetCursor(wxCURSOR_SIZING);
494 SetCursor(wxNullCursor);
525 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
563 for(HuginBase::UIntSet::const_iterator it=points.begin();it!=points.end();++it)
600 if(!mouse.ShiftDown())
602 for(HuginBase::UIntSet::const_iterator it=points.begin();it!=points.end();++it)
614 switch(
GetClickPos(vigra::Point2D(currentPos.x,currentPos.y)))
660 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
719 if(!mouse.ShiftDown())
765 SetCursor(wxNullCursor);
825 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
855 CalcUnscrolledPosition(mouse.GetPosition().x, mouse.GetPosition().y,
901 for(HuginBase::UIntSet::const_reverse_iterator it=points.rbegin();it!=points.rend();++it)
907 for(
unsigned int i=0;i<mappedSelectedPoints.size();i++)
908 mappedSelectedPoints[i]=i;
911 for(HuginBase::UIntSet::const_iterator it=points.begin();it!=points.end();++it)
913 if((*it)<mappedSelectedPoints.size()-1)
914 for(
unsigned int i=(*it)+1;i<mappedSelectedPoints.size();i++)
915 mappedSelectedPoints[i]--;
917 for(HuginBase::UIntSet::const_iterator it=temp.begin();it!=temp.end();++it)
1000 const int key=e.GetKeyCode();
1001 bool processed=
false;
1002 if((key==WXK_DELETE) || (key==WXK_NUMPAD_DELETE))
1020 wxCommandEvent dummy;
1032 wxCommandEvent dummy;
1047 wxCommandEvent zoomEvent(wxEVT_CHOICE, XRCID(
"mask_editor_choice_zoom"));
1048 zoomEvent.SetInt(0);
1049 zoomEvent.SetString(
"update_selection");
1050 GetParent()->GetEventHandler()->AddPendingEvent(zoomEvent);
1056 wxCommandEvent zoomEvent(wxEVT_CHOICE, XRCID(
"mask_editor_choice_zoom"));
1057 zoomEvent.SetInt(2);
1058 zoomEvent.SetString(
"update_selection");
1059 GetParent()->GetEventHandler()->AddPendingEvent(zoomEvent);
1065 wxCommandEvent zoomEvent(wxEVT_CHOICE, XRCID(
"mask_editor_choice_zoom"));
1066 zoomEvent.SetInt(1);
1067 zoomEvent.SetString(
"update_selection");
1068 GetParent()->GetEventHandler()->AddPendingEvent(zoomEvent);
1080 wxPoint offset = GetViewStart();
1082 switch (e.GetKeyCode())
1145 wxClientDC dc(
this);
1155 wxPoint *polygonPoints=
new wxPoint[nrOfPoints];
1156 for(
unsigned int j=0;j<nrOfPoints;j++)
1175 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1177 dc.DrawPolygon(nrOfPoints,polygonPoints);
1179 dc.DrawLine(polygonPoints[0],polygonPoints[1]);
1186 for(
unsigned int j=0;j<nrOfPoints;j++)
1190 dc.SetPen(penSelected);
1191 dc.SetBrush(brushSelected);
1195 dc.SetPen(penUnselected);
1196 dc.SetBrush(brushUnselected);
1202 delete []polygonPoints;
1207 wxClientDC dc(
this);
1219 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1224 dc.DrawLine( middle.x + c, middle.y + c, middle.x - c, middle.y - c);
1225 dc.DrawLine( middle.x - c, middle.y + c, middle.x + c, middle.y - c);
1233 dc.DrawCircle(middle.x, middle.y,
scale(radius));
1242 dc.SetPen(wxPen(GetBackgroundColour(), 1, wxPENSTYLE_SOLID));
1243 dc.SetBrush(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
1244 dc.DrawRectangle(0, 0, offset,
m_bitmap.GetHeight() + 2 * offset);
1245 dc.DrawRectangle(0, 0,
m_bitmap.GetWidth() + 2 * offset, offset);
1246 dc.DrawRectangle(
m_bitmap.GetWidth() + offset, 0,
m_bitmap.GetWidth() + 2 * offset,
m_bitmap.GetHeight() + 2 * offset);
1247 dc.DrawRectangle(0,
m_bitmap.GetHeight() + offset,
m_bitmap.GetWidth() + 2 * offset,
m_bitmap.GetHeight() + 2 * offset);
1248 dc.DrawBitmap(
m_bitmap, offset, offset);
1260 wxSize clientSize=GetClientSize();
1261 if(
m_bitmap.GetWidth()+2*offset<clientSize.GetWidth())
1263 dc.DrawRectangle(
m_bitmap.GetWidth()+2*offset,0,clientSize.GetWidth()-
m_bitmap.GetWidth()+2*offset,clientSize.GetHeight());
1265 if(
m_bitmap.GetHeight()+2*offset<clientSize.GetHeight())
1267 dc.DrawRectangle(0,
m_bitmap.GetHeight()+2*offset,clientSize.GetWidth(),clientSize.GetHeight()-
m_bitmap.GetHeight()+2*offset);
1278 region.Union(wholeImage);
1288 unsigned int nrOfPoints = dc.GetSize().GetWidth() * 2;
1289 wxPoint* circlePoints =
new wxPoint[nrOfPoints];
1292 double interval = 2 *
PI / nrOfPoints;
1293 for (
unsigned int i = 0; i < nrOfPoints; i++)
1297 region.Subtract(wxRegion(nrOfPoints, circlePoints));
1298 delete[]circlePoints;
1310 wxPoint *polygonPoints=
new wxPoint[poly.size()];
1311 for(
unsigned int j=0;j<poly.size();j++)
1315 wxRegion singleRegion(poly.size(),polygonPoints,wxWINDING_RULE);
1318 wxRegion newRegion(wholeImage);
1319 newRegion.Subtract(singleRegion);
1320 region.Union(newRegion);
1324 region.Union(singleRegion);
1326 delete []polygonPoints;
1335 GetViewStart(&x,&y);
1336 region.Offset(-x,-y);
1338 dc.SetDeviceClippingRegion(region);
1340 dc.DestroyClippingRegion();
1348 for(
unsigned int i=0;i<maskList.size();i++)
1364 dc.SetPen(wxPen(GetBackgroundColour(), 1, wxPENSTYLE_SOLID));
1365 dc.SetBrush(wxBrush(GetBackgroundColour(), wxBRUSHSTYLE_SOLID));
1373 DEBUG_TRACE(
"size: " << e.GetSize().GetWidth() <<
"x" << e.GetSize().GetHeight());
1396 vigra::FindAverage<vigra::RGBValue<vigra::UInt8> > average;
1398 vigra::RGBValue<vigra::UInt8> RGBaverage=average.average();
1399 if(RGBaverage[0]<180 && RGBaverage[1]<180 && RGBaverage[2]<180)
1408 if (img.GetWidth() == 0)
1412 m_imageSize = wxSize(img.GetWidth(), img.GetHeight());
1423 wxImageResizeQuality resizeQuality = wxIMAGE_QUALITY_NORMAL;
1424 if (
std::max(img.GetWidth(), img.GetHeight()) > (ULONG_MAX >> 16))
1430 resizeQuality = wxIMAGE_QUALITY_BOX_AVERAGE;
1432 img=img.Scale(
scale(m_realSize.GetWidth()),
scale(m_realSize.GetHeight()), resizeQuality);
1444 img = img.Rotate90(
true);
1447 img = img.Rotate180();
1450 img = img.Rotate90(
false);
1463 img = img.ConvertToDisabled(192);
1473 SetScrollRate(1, 1);
1481 wxClientDC dc(
this);
1486 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1493 unsigned int selectedPolygon=UINT_MAX;
1495 while(selectedPolygon==UINT_MAX && i<
m_imageMask.size())
1501 if(selectedPolygon<UINT_MAX)
1515 for(
unsigned int i=0;i<poly.size();i++)
1517 bool activePoints=
true;
1518 if(considerSelectedOnly)
1520 if(activePoints && xmin<=poly[i].x && poly[i].x<=xmax && ymin<=poly[i].y && poly[i].y<=ymax)
1552 int w = size.GetWidth();
1553 int h = size.GetHeight();
1561 wxSize csize = GetSize();
1562 DEBUG_DEBUG(
"csize: " << csize.GetWidth() <<
"x" << csize.GetHeight() <<
"image: " << w <<
"x" <<
h);
1563 double s1 = (double)csize.GetWidth()/w;
1564 double s2 = (double)csize.GetHeight()/
h;
1566 return s1 < s2 ? s1 : s2;
1583 : wxXmlResourceHandler()
1592 cp->Create(m_parentAsWindow,
1594 GetPosition(), GetSize(),
1595 GetStyle(wxT(
"style")),
1605 return IsOfClass(node, wxT(
"MaskImageCtrl"));
ImageRotation
image rotation.
static const int NO_IMAGE
T applyRotInv(const T &p) const
void UpdateCropFromImage()
updates the displayed crop in the text boxes (for dragging)
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
void DrawImageBitmap(wxDC &dc, int offset)
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
virtual void OnDraw(wxDC &dc) wxOVERRIDE
drawing routine
bool SelectPointsInsideMouseRect(HuginBase::UIntSet &points, const bool considerSelectedOnly)
void SelectMask(unsigned int newMaskNr)
selects the mask with index newMaskNr in the listbox
const cmsHPROFILE GetMonitorProfile() const
returns the monitor profile, if no monitor profile was found the sRGB profile is used instead ...
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
#define PI
Header file for Khan's deghosting algorithm Copyright (C) 2009 Lukáš Jirkovský l...
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 update()
initiate redraw
void OnRightMouseDown(wxMouseEvent &mouse)
event handler when right mouse button is pressed
wxImage imageCacheEntry2wxImage(ImageCache::EntryPtr e)
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)
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 DrawSelectionRectangle()
void selectAllMarkers()
select all points of active mask
void setNewMasks(HuginBase::MaskPolygonVector newMasks, HuginBase::MaskPolygonVector masksToDraw)
updates masks for currently selected image
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
wxSize DoGetBestSize() const
returns size of currently scaled image
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
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