28#include "hugin_config.h"
34#include <wx/dcbuffer.h>
36#include <vigra/inspectimage.hxx>
37#include <vigra/transformimage.hxx>
38#include <vigra/basicimageview.hxx>
238 box.setSize(2*l, 2*l);
242 if(
box.width()<=0 ||
box.height()<=0)
247 vigra::FindAverage<vigra::UInt8>
average;
248 vigra::RGBToGrayAccessor<vigra::RGBValue<vigra::UInt8> >
lumac;
427 for(
size_t i=0;
i<len+1;
i++)
452 dc.DestroyClippingRegion();
516 dc.DestroyClippingRegion();
671#if defined(__WXMSW__)
784 dsp.SetLabel(
_(
"new"));
792 upperLeft =
scale(upperLeft);
796 dc.DrawRectangle(upperLeft.x-width, upperLeft.y-width, 2*width, 2*width);
819 upperLeft =
scale(upperLeft);
836 typedef vigra::RGBValue<vigra::UInt8>
VT;
841 int magWidth = wxConfigBase::Get()->Read(
"/CPEditorPanel/MagnifierWidth",61l);
857 vigra::destImageRange(
magImg),
869 vigra::FindMinMax<vigra::UInt8>
minmax;
870 vigra::inspectImage(vigra::srcImageRange(
magImg),
minmax);
873 vigra::transformImage(vigra::srcImageRange(
magImg), vigra::destImage(
magImg),
874 vigra::linearRangeMapping(
876 VT(0, 0, 0),
VT(255, 255, 255))
884 vigra::UInt8
v = 0.3/255*p.red() + 0.6/255*p.green() + 0.1/255*p.blue() < 0.5 ? 255 : 0;
890 v = 0.3/255*p.red() + 0.6/255*p.green() + 0.1/255*p.blue() < 0.5 ? 255 : 0;
900 img = img.Rotate90(
true);
903 img = img.Rotate180();
906 img = img.Rotate90(
false);
930 if (wxFileName::FileExists(
fn)) {
949 m_img = ImageCache::EntryPtr(
new ImageCache::Entry);
987 if (img.GetWidth() == 0) {
1010 if (std::max(img.GetWidth(), img.GetHeight()) > (
ULONG_MAX >> 16))
1026 img = img.Rotate90(
true);
1029 img = img.Rotate180();
1032 img = img.Rotate90(
false);
1041 vigra::ImageImportInfo::ICCProfile iccProfile;
1043 if (
m_img->imageFloat->width() == 0)
1045 iccProfile = *(
m_img->iccProfile);
1064 dcp.SetLabel(wxString::Format(
"%lu", (
unsigned long int)
m_points.size()));
1119 point =
scale(point);
1151 if(
it->isOccupiedPos(p))
1164#if wxCHECK_VERSION(3,3,0)
1178 dc.DrawRectangle(p1.x,p1.y,p2.x-p1.x,p2.y-p1.y);
1183 if (!
m_img.get())
return;
1198 if (
mouse.LeftIsDown() && !
mouse.ShiftDown()) {
1201 DEBUG_DEBUG(
"mouse down movement without selection, in NO_SELECTION state!");
1206 }
else if (
mpos.x < 0) {
1214 }
else if (
mpos.y < 0) {
1227 DEBUG_DEBUG(
"WARNING: mouse move in new point state")
1245 if (
mouse.MiddleIsDown())
1251 if (
mouse.ShiftDown()) {
1294 if (!
m_img.get())
return;
1328 DEBUG_DEBUG(
"click on new space, select new point");
1351 if (!
m_img.get())
return;
1366 if (!
m_img.get())
return;
1385 if (
mouse.LeftUp()) {
1430 DEBUG_DEBUG(
"middle mouse button released, leaving scroll mode")
1437 DEBUG_DEBUG(
"middle mouse button pressed, entering scroll mode")
1438 if (!
m_img.get())
return;
1466 if (!
m_img.get())
return;
1475 if (
mouse.RightUp())
1492 DEBUG_DEBUG(
"Emitting right click (rmb release)");
1529 int w = size.GetWidth();
1530 int h = size.GetHeight();
1572 if (!
m_img.get())
return;
1576 if ((!e.CmdDown()) && e.GetKeyCode() ==
WXK_LEFT )
delta.x = -1;
1578 if ((!e.CmdDown()) && e.GetKeyCode() ==
WXK_UP )
delta.y = -1;
1579 if ((!e.CmdDown()) && e.GetKeyCode() ==
WXK_DOWN )
delta.y = 1;
1580 if ( (
delta.x != 0 ||
delta.y != 0 ) && (e.ShiftDown() || e.CmdDown())) {
1585 if (e.ShiftDown()) {
1590 }
else if (e.CmdDown()) {
1631 else if (e.m_keyCode ==
'a') {
1632 DEBUG_DEBUG(
"adding point with a key, faking right click");
1644 switch (e.GetKeyCode())
1667 e.SetEventObject(
this);
1669 <<
" origin: id:" << e.GetId() <<
" obj: "
1670 << e.GetEventObject());
1683 if (!
m_img.get())
return;
1685 DEBUG_DEBUG(
"shift or control down, reseting scoll position");
1763 if (x +
delta.x < 0) {
1766 if (y +
delta.y < 0) {
1815 return m_img->get8BitImage();
1828IMPLEMENT_DYNAMIC_CLASS(
CPImageCtrl, wxScrolledWindow)
1831 : wxXmlResourceHandler()
1842 GetPosition(), GetSize(),
void DrawCross(wxDC &dc, wxPoint p, int l)
wxDEFINE_EVENT(EVT_CPEVENT, CPEvent)
Dummy progress display, without output.
control point editor panel.
Events to notify about new point / region / point change.
hugin_utils::FDiff2D point
HuginBase::ControlPoint m_cp
virtual wxEvent * Clone() const
virtual bool CanHandle(wxXmlNode *node)
virtual wxObject * DoCreateResource()
void mouseReleaseLMBEvent(wxMouseEvent &mouse)
void showSearchArea(bool show=true)
show/hide the search area rectangle
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name="panel")
wxPoint roundP(const hugin_utils::FDiff2D &p) const
void mousePressLMBEvent(wxMouseEvent &mouse)
ImageRotation
image rotation.
const wxSize GetRealImageSize() const
return the real size of the image in the control
DisplayedControlPoint m_selectedPoint
const bool GetMouseInWindow() const
void mousePressMMBEvent(wxMouseEvent &mouse)
void clearNewPoint()
clear new point
EditorState isOccupied(wxPoint mousePos, const hugin_utils::FDiff2D &point, unsigned int &pointNr) const
check if p is over a known point, if it is, pointNr contains the point
wxCursor * m_CPSelectCursor
void setTransforms(HuginBase::PTools::Transform *firstTrans, HuginBase::PTools::Transform *firstInvTrans, HuginBase::PTools::Transform *secondInvTrans)
HuginBase::PTools::Transform * getFirstTrans() const
unsigned int selectedPointNr
void mouseReleaseMMBEvent(wxMouseEvent &mouse)
std::vector< wxColour > pointColors
hugin_utils::FDiff2D newPoint
void clearCtrlPointList()
clear internal control point list
wxPoint MaxScrollDelta(wxPoint delta)
calculate maximum delta that is allowed when scrolling
EditorState
state machine for selection process:
bool IsShowingLines() const
HuginBase::PTools::Transform * getFirstInvTrans() const
HuginBase::PTools::Transform * getSecondInvTrans() const
bool emit(CPEvent &ev)
helper func to emit a region
const wxSize GetBitmapSize() const
return the size of the drawn bitmap (possible rotate is applied)
void setSameImage(bool sameImage)
void mousePressRMBEvent(wxMouseEvent &mouse)
void Init(CPEditorPanel *parent)
void setImage(const std::string &filename, ImageRotation rot)
display img.
hugin_utils::FDiff2D rectStartPos
double getScale()
return scale factor, 0 for autoscale
hugin_utils::FDiff2D getNewPoint()
get the new point
void OnKeyDown(wxKeyEvent &e)
HuginBase::ImageCache::ImageCacheRGB8Ptr GetImg()
get pointer to image, for DisplayedControlPoint
double getScaleFactor() const
get scale factor (calculates factor when fit to window is active)
HuginBase::PTools::Transform * m_secondInvTrans
ImageCache::RequestPtr m_imgRequest
void setCtrlPoint(const HuginBase::ControlPoint &cp, const bool mirrored)
add control piont to internal cp list
void deselect()
remove selection.
void OnSize(wxSizeEvent &e)
void OnPaint(wxPaintEvent &e)
paint event
void showPosition(hugin_utils::FDiff2D point, bool warpPointer=false)
Show point x, y.
void DrawSelectionRectangle(hugin_utils::FDiff2D pos1, hugin_utils::FDiff2D pos2)
void OnSizeFinished(wxTimerEvent &e)
HuginBase::PTools::Transform * m_firstTrans
std::string imageFilename
void setNewPoint(const hugin_utils::FDiff2D &p)
set new point to a specific point
wxBitmap & GetMagBitmap(hugin_utils::FDiff2D point)
draw the magnified view of a selected control point
CPEditorPanel * m_editPanel
ImageRotation m_imgRotation
void showTemplateArea(bool show=true)
HuginBase::PTools::Transform * m_firstInvTrans
void ShowLines(bool isShown)
hugin_utils::FDiff2D m_mousePos
void setScale(double factor)
set the scaling factor for cp display.
hugin_utils::FDiff2D m_magImgCenter
void mouseReleaseRMBEvent(wxMouseEvent &mouse)
void setMagTransforms(HuginBase::PTools::Transform *magTrans, HuginBase::PTools::Transform *magInvTrans)
T applyRotInv(const T &p) const
HuginBase::PTools::Transform * m_magTrans
T applyRot(const T &p) const
void ScrollDelta(const wxPoint &delta)
scroll the window by delta pixels
int invScale(int x) const
void OnImageLoaded(ImageCache::EntryPtr entry, std::string filename, bool load_small)
void OnScrollWin(wxScrollWinEvent &e)
const bool GetForceMagnifier() const
wxSize DoGetBestSize() const
void selectPoint(unsigned int, bool scrollTo=true)
select a point for usage
void OnTimer(wxTimerEvent &e)
bool m_sameImage
true, if in control point tab the same image is selected 2 times in this case a special treatment for...
double calcAutoScaleFactor(wxSize size)
calculate new scale factor for this image
void OnMouseLeave(wxMouseEvent &e)
HuginBase::PTools::Transform * m_magInvTrans
std::vector< DisplayedControlPoint > m_points
void OnKey(wxKeyEvent &e)
void mouseMoveEvent(wxMouseEvent &mouse)
void OnMouseEnter(wxMouseEvent &e)
ImageCache::EntryPtr m_img
std::vector< wxColour > textColours
helper class to display and manipulate cp in cp tab
void SetLabel(wxString newLabel)
set label to given wxString
wxColour m_pointColour
colour of the point
wxColour m_textColour
colour of the text background
bool m_mirrored
is first or second image in cp used
const HuginBase::ControlPoint GetControlPoint() const
returns the control point
wxRect m_labelPos
position of the point labels (in screen coordinates)
void UpdateControlPointX(double x)
update x coordinate of selected cp coordinate
DisplayedControlPoint()
default constructor
bool m_line
true, if line control point on same image
void StartLineControlPoint(hugin_utils::FDiff2D newPoint)
starts a new line control point with given coodinates
const bool isOccupiedPos(const hugin_utils::FDiff2D &p) const
check if the given point is over the drawn cp, using image coordinates
void CheckSelection(const wxPoint mousePos, const hugin_utils::FDiff2D &p)
used by manipulating line control points, remember if the selected point given in screen coordinates
void UpdateControlPoint(hugin_utils::FDiff2D newPoint)
update selected cp coordinate
bool IsDrawingLine() const
return true, if line cp should be drawn as separate line
HuginBase::ControlPoint m_cp
representation of underlying control point
wxString m_label
label of displayed control point: number or new
CPImageCtrl * m_control
pointer to control to access some functions
void SetColour(wxColour pointColour, wxColour textColour)
set colours for drawing control points
void DrawLineSegment(wxDC &dc)
draw line control point over different images
bool operator==(const DisplayedControlPoint other)
compare operator
hugin_utils::FDiff2D GetPos() const
returns selected position
const bool isOccupiedLabel(const wxPoint mousePos) const
check if given point is over label of cp, using screen coordinates
void ShiftControlPoint(hugin_utils::FDiff2D shift)
shift selected cp coordinate by given
void Draw(wxDC &dc, const wxRect &visibleRect, bool selected, bool newPoint=false)
draw the control points to the given device context
void DrawLine(wxDC &dc)
draw line control point on same image
wxRect DrawTextMag(wxDC &dc, wxPoint p, hugin_utils::FDiff2D pointInput, bool drawMag, wxColour pointColour, wxColour textColour)
draw magnified area
void UpdateControlPointY(double y)
update y coordinate of selected cp coordinate
void SetControl(CPImageCtrl *control)
remember the control, where the information should be drawn
represents a control point
@ X
evaluate x, points are on a vertical line
std::shared_ptr< vigra::BRGBImage > ImageCacheRGB8Ptr
use reference counted pointers
std::shared_ptr< Entry > EntryPtr
a shared pointer to the entry
bool HasMonitorProfile() const
return true if we found a suitable monitor profile and could loading it
const wxString & GetXRCPath()
return the current xrc path
static huginApp * Get()
hack.. kind of a pseudo singleton...
#define HUGIN_FT_TEMPLATE_SIZE
#define HUGIN_FT_SEARCH_AREA_PERCENT
void CorrectImage(wxImage &image, const vigra::ImageImportInfo::ICCProfile &iccProfile, const cmsHPROFILE &monitorProfile)
apply color correction to given image using input iccProfile and monitor profile
TDiff2D< double > FDiff2D
void transformImageIntern(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > src, vigra::triple< DestImageIterator, DestImageIterator, DestAccessor > dest, std::pair< AlphaImageIterator, AlphaAccessor > alpha, TRANSFORM &transform, PixelTransform &pixelTransform, vigra::Diff2D destUL, Interpolator interp, bool warparound, AppBase::ProgressDisplay *progress, bool singleThreaded)
Transform an image into the panorama.
IMPLEMENT_DYNAMIC_CLASS(wxTreeListHeaderWindow, wxWindow)
include file for the hugin project
include file for the hugin project
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
wxImage imageCacheEntry2wxImage(ImageCache::EntryPtr e)