Hugin trunk 0.1
Loading...
Searching...
No Matches
PreviewCameraTool.cpp
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
23#ifdef _WIN32
24#include "wx/msw/wrapwin.h"
25#endif
26#include "PreviewCameraTool.h"
27#include "GLViewer.h"
28
36
38{
40 if (zoomIn)
41 {
42 state->SetZoomLevel((state->GetZoomLevel()) * 1.2);
43 // update center to zoom in at given position
45 newScrollPos.x = scrollPos.x / state->GetOptions()->getWidth();
46 newScrollPos.y = scrollPos.y / state->GetOptions()->getHeight();
48 }
49 else
50 {
51 // out-zoom, keep current position
52 state->SetZoomLevel((state->GetZoomLevel()) / 1.2);
53 };
54 // redraw
55 state->ForceRequireRedraw();
56 state->Redraw();
57}
58
60{
61 if (e.GetWheelRotation() != 0 && helper->IsMouseOverPano())
62 {
63 ChangeZoomLevel(e.GetWheelRotation() > 0, helper->GetMousePanoPosition());
64 }
65}
66
68{
70 // move center by given distance
72 currentCenter.x -= moveDist.x / state->GetOptions()->getWidth() / state->GetScale();
73 currentCenter.y -= moveDist.y / state->GetOptions()->getHeight() / state->GetScale();
75 state->SetDirtyViewport();
76 state->ForceRequireRedraw();
77 state->Redraw();
78}
79
81{
82 // listen only to middle button events
83 if (!m_moving && e.MiddleDown())
84 {
86 {
87 // start dragging
88 m_moving = true;
90 };
91 }
92 else
93 {
94 if (m_moving && e.MiddleUp())
95 {
96 // end dragging, update center
97 m_moving = false;
99 {
101 };
102 };
103 };
104}
105
107{
108 if (m_moving)
109 {
110 // mouse is moving, if middle mouse button is pressed update center in real time
111 if (e.MiddleIsDown())
112 {
113 if (helper->IsMouseOverPano())
114 {
117 if (diffPos.squareLength() > 100)
118 {
119 // update only when mouse moved at least 10 pixel
122 };
123 };
124 }
125 else
126 {
127 // we are still moving, but middle button is not pressed any more
128 // so reset moving bit
129 m_moving = false;
130 };
131 };
132}
unsigned int getWidth() const
unsigned int getHeight() const
get panorama height
void ChangeZoomLevel(bool zoomIn, const hugin_utils::FDiff2D &scrollPos)
update zoom level
void MouseWheelEvent(wxMouseEvent &)
event for mouse wheel processing
void UpdateCenter(const hugin_utils::FDiff2D &moveDist)
update center, used for panning
void MouseMoveEvent(double x, double y, wxMouseEvent &e)
event for mouse move
bool m_moving
flag to indicate that we are moving the view with middle mouse button
void Activate()
Switch on a tool.
void MouseButtonEvent(wxMouseEvent &e)
event for mouse button processing
hugin_utils::FDiff2D m_lastScreenPos
last screen position during moving , needed for real-time update
hugin_utils::FDiff2D GetMousePanoPosition()
bool IsMouseOverPano()
Definition ToolHelper.h:136
void NotifyMe(Event event, Tool *tool)
VisualizationState * GetVisualizationStatePtr()
hugin_utils::FDiff2D GetMouseScreenPosition()
ToolHelper * helper
The PreviewToolHelper that uses the same preview window and panorama as the tool should.
Definition Tool.h:109
void SetZoomLevel(const float new_zoom)
void SetViewingCenter(const hugin_utils::FDiff2D &center)
virtual HuginBase::PanoramaOptions * GetOptions()
double GetZoomLevel() const
Definition ViewState.h:227
void SetDirtyViewport()
Definition ViewState.h:249
hugin_utils::FDiff2D GetViewingCenter() const
Definition ViewState.h:232
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.
Definition threshold.h:41