From: <hug...@li...> - 2012-06-24 11:14:15
|
branch: gui_overhaul details: http://hugin.hg.sourceforge.net/hgweb/hugin/hugin/hgroot/hugin/hugin/rev/3260c1a9b806 changeset: 5865:3260c1a9b806 user: tmodes date: Sun Jun 24 13:11:03 2012 +0200 description: Workaround for not working wxInvert raster operation on MacOS in mask/crop tab diffstat: src/hugin1/hugin/MaskImageCtrl.cpp | 50 ++++++++++++++++++++++++++++++++++++++ src/hugin1/hugin/MaskImageCtrl.h | 13 +++++++++ 2 files changed, 63 insertions(+), 0 deletions(-) diffs (160 lines): diff -r 150ec3e50185 -r 3260c1a9b806 src/hugin1/hugin/MaskImageCtrl.cpp --- a/src/hugin1/hugin/MaskImageCtrl.cpp Wed Jun 20 19:06:35 2012 +0200 +++ b/src/hugin1/hugin/MaskImageCtrl.cpp Sun Jun 24 13:11:03 2012 +0200 @@ -34,6 +34,9 @@ #include "hugin/MaskImageCtrl.h" #include "hugin/MaskEditorPanel.h" #include "base_wx/wxImageCache.h" +#ifndef SUPPORTS_WXINVERT +#include <vigra/inspectimage.hxx> +#endif using namespace hugin_utils; @@ -376,7 +379,9 @@ case POLYGON_SELECTING: case REGION_SELECTING: case POINTS_DELETING: +#if defined SUPPORTS_WXINVERT DrawSelectionRectangle(); +#endif m_currentPos=mpos; DrawSelectionRectangle(); break; @@ -444,10 +449,16 @@ case CROP_TOP_MOVING: case CROP_BOTTOM_MOVING: case CROP_CIRCLE_SCALING: +#if defined SUPPORTS_WXINVERT DrawCrop(); +#else + doUpdate=true; +#endif UpdateCrop(currentPos); m_currentPos=mpos; +#if defined SUPPORTS_WXINVERT DrawCrop(); +#endif m_editPanel->UpdateCropFromImage(); break; }; @@ -582,9 +593,14 @@ { if(m_cropMode==SrcPanoImage::NO_CROP && m_cropCircle) { +#if defined SUPPORTS_WXINVERT DrawCrop(); m_cropMode=SrcPanoImage::CROP_CIRCLE; DrawCrop(); +#else + m_cropMode=SrcPanoImage::CROP_CIRCLE; + update(); +#endif }; }; break; @@ -638,7 +654,11 @@ case POLYGON_SELECTING: if(HasCapture()) ReleaseMouse(); +#if defined SUPPORTS_WXINVERT DrawSelectionRectangle(); +#else + doUpdate=true; +#endif m_currentPos=mpos; m_maskEditState=NO_SELECTION; { @@ -700,8 +720,15 @@ case CROP_CIRCLE_SCALING: if(HasCapture()) ReleaseMouse(); +#if defined SUPPORTS_WXINVERT DrawCrop(); +#else + doUpdate=true; +#endif UpdateCrop(currentPos); +#if defined SUPPORTS_WXINVERT + DrawCrop(); +#endif m_maskEditState=CROP_SHOWING; SetCursor(wxNullCursor); m_editPanel->UpdateCrop(true); @@ -1055,7 +1082,11 @@ { // draw all areas without fillings dc.SetBrush(*wxTRANSPARENT_BRUSH); +#if defined SUPPORTS_WXINVERT dc.SetLogicalFunction (wxINVERT); +#else + dc.SetPen(wxPen(m_color_selection, 1, wxPENSTYLE_SOLID)); +#endif wxPoint middle=transform(applyRot((m_cropRect.lowerRight()+m_cropRect.upperLeft())/2)); int c = 8; // size of midpoint cross @@ -1214,6 +1245,20 @@ { return; } +#ifndef SUPPORTS_WXINVERT + //determine average colour and set selection colour corresponding + vigra::FindAverage<vigra::RGBValue<vigra::UInt8> > average; + vigra::inspectImage(vigra::srcImageRange(*(m_img->get8BitImage())), average); + vigra::RGBValue<vigra::UInt8> RGBaverage=average.average(); + if(RGBaverage[0]<180 && RGBaverage[1]<180 && RGBaverage[2]<180) + { + m_color_selection=*wxWHITE; + } + else + { + m_color_selection=*wxBLACK; + }; +#endif wxImage img = imageCacheEntry2wxImage(m_img); if (img.GetWidth() == 0) { @@ -1296,8 +1341,13 @@ { wxClientDC dc(this); PrepareDC(dc); +#if defined SUPPORTS_WXINVERT dc.SetLogicalFunction(wxINVERT); dc.SetPen(wxPen(*wxWHITE,1,wxDOT)); +#else + OnDraw(dc); + dc.SetPen(wxPen(m_color_selection, scale(1), wxDOT)); +#endif dc.SetBrush(*wxTRANSPARENT_BRUSH); dc.DrawRectangle(m_dragStartPos.x,m_dragStartPos.y, (m_currentPos.x-m_dragStartPos.x),(m_currentPos.y-m_dragStartPos.y)); diff -r 150ec3e50185 -r 3260c1a9b806 src/hugin1/hugin/MaskImageCtrl.h --- a/src/hugin1/hugin/MaskImageCtrl.h Wed Jun 20 19:06:35 2012 +0200 +++ b/src/hugin1/hugin/MaskImageCtrl.h Sun Jun 24 13:11:03 2012 +0200 @@ -28,6 +28,16 @@ #include <base_wx/wxImageCache.h> +#if defined __WXOSX_CARBON__ || defined __WXOSX_COCOA__ +// on wxMac wxInvert does not work for drawing rubberband, so we are the following workaround +// instead of using wxInvert we are drawing the background image before the selection rectangle +// or the crop rectangle, the color of the selection is defined by the overall colour of the image +// this approach is already used for the polygon editor also on wxMSW and wxGTK +#undef SUPPORTS_WXINVERT +#else +#define SUPPORTS_WXINVERT 1 +#endif + class MaskEditorPanel; /** @brief mask editor @@ -312,6 +322,9 @@ wxColor m_colour_polygon_positive; wxColor m_colour_point_selected; wxColor m_colour_point_unselected; +#ifndef SUPPORTS_WXINVERT + wxColour m_color_selection; +#endif DECLARE_EVENT_TABLE(); DECLARE_DYNAMIC_CLASS(MaskImageCtrl) |