Hugin trunk 0.1
Loading...
Searching...
No Matches
ToolHelper.h
Go to the documentation of this file.
1// -*- c-basic-offset: 4 -*-
2
24/* A preview tool helper manages information that any tool may want to use,
25 * and guides the interaction between tools. These features are available:
26 * - Notification of user events:
27 * - When the mouse moves
28 * - When the set of images under the mouse pointer changes
29 * - When the mouse button is pressed / released.
30 * - When a key is pressed / released
31 * - Notifications when drawing things on the preview, allowing:
32 * - Drawing under / above the set of images.
33 * - Drawing under / above each individual image.
34 * - Replacing or stopping the drawing of each individual image.
35 * - Notification of when:
36 * - The tool is activated.
37 * - The tool can request the mouse position.
38 * - The tool can request a list of images under the mouse.
39 * - The tool can access the panorama, and make changes to it.
40 * - The tool can access the ViewState. This allows it to respond to, and cause,
41 * interactive changes.
42 * - The tool can deactivate itself, for example, when asked to give up events.
43 * - Possible extensions:
44 * - What images have been selected
45 * - Provide a menu over the preview
46 */
47
48#ifndef _PREVIEWTOOLHELPER_H
49#define _PREVIEWTOOLHELPER_H
50
51#if __APPLE__
52#include "panoinc_WX.h"
53#include "panoinc.h"
54#endif
55
56#include "base_wx/wxutils.h"
57#include "base_wx/platform.h"
58#include <wx/defs.h>
59#include <wx/event.h>
60#include <wx/string.h>
61
62#include <set>
63#include <vector>
64
66#include "ViewState.h"
67#include "panodata/Panorama.h"
68
69class Tool;
70class PreviewTool;
71class OverviewTool;
74class GLPreviewFrame;
75
77{
78public:
89 virtual ~ToolHelper();
90 // working with tools
91 // Activate a tool, the tool will then request notifications it needs.
92 // Then return a list of tools that had to be dactivated to comply.
93 std::set<Tool*> ActivateTool(Tool *tool);
94 // deactivate a tool: remove all it's notifications.
95 virtual void DeactivateTool(Tool *tool);
96
97 // Events
98 // the x and y coordinates are in pixels from the top left of the panorama.
99 virtual void MouseMoved(int x, int y, wxMouseEvent & e);
100 // pressed is true if the button is pushed down, false if let go
103 // keycode is the wxWidgets keycode.
104 void KeypressEvent(int keycode, int modifiers, bool pressed);
105 void BeforeDrawImages();
106 void AfterDrawImages();
107 void MarkDirty();
108 // Return true if we want it drawn, return false and draw the image as the
109 // tools specify otherwise.
110 bool BeforeDrawImageNumber(unsigned int image);
111 void AfterDrawImageNumber(unsigned int image);
112 void MouseEnter(int x, int y, wxMouseEvent & e);
113 void MouseLeave();
114
115 // Get information
116 std::set<unsigned int> GetImageNumbersUnderMouse();
117
120
124
125 // Setting up notifications
126 void NotifyMe(Event event, Tool *tool);
127 void NotifyMeBeforeDrawing(unsigned int image_nr, Tool *tool);
128 void NotifyMeAfterDrawing(unsigned int image_nr, Tool *tool);
130 void DoNotNotifyMeBeforeDrawing(unsigned int image_nr, Tool *tool);
131 void DoNotNotifyMeAfterDrawing(unsigned int image_nr, Tool *tool);
132
133 // status message to be something relevant for a tool.
135
137 // return set of images under given position
140
141protected:
142 std::set<Tool *> tools_deactivated;
146
149
150 // What tools are notified of what events.
153 std::set<Tool *> keypress_notified_tools;
155 std::set<Tool *> draw_over_notified_tools;
159 std::set<Tool *> m_tools_need_dirty_flag;
160 // these are vectors: the index is the image that a single tool uses.
161 std::vector<std::set<Tool *> > image_draw_begin_tools;
162 std::vector<std::set<Tool *> > image_draw_end_tools;
163 // stop notifying the given tool of an event.
164 void RemoveTool(Tool *tool, Tool **single);
165 void RemoveTool(Tool *tool, std::set<Tool *> *set);
166 void RemoveTool(Tool *tool, std::vector<std::set<Tool *> > *vector);
167 void RemoveTool(Tool *tool, std::vector<std::set<Tool *> > *vector,
168 unsigned int index);
169 // set the tool up for notification, deactivating any tools in the way.
170 void AddTool(Tool *tool, Tool **single);
171 void AddTool(Tool *tool, std::set<Tool *> *set);
172 void AddTool(Tool *tool, std::vector<std::set<Tool *> > *vector,
173 unsigned int index);
174
175 // is the set of images under the mouse up to date?
177 // which images are under the mouse?
178 std::set<unsigned int> images_under_mouse;
181};
182
194
204
237
238
240{
241public:
246
247 void MouseMoved(int x, int y, wxMouseEvent & e);
248
249 double getPlaneX() {return plane_x;}
250 double getPlaneY() {return plane_y;}
251
252private:
253
254 double plane_x;
255 double plane_y;
256
257};
258
259#endif
The OpenGL preview frame.
Model for a panorama.
Definition Panorama.h:153
OverviewToolHelper(HuginBase::Panorama *pano, VisualizationState *visualization_state, GLPreviewFrame *frame)
Definition ToolHelper.h:198
std::set< Tool * > draw_under_notified_tools_back
Definition ToolHelper.h:231
std::set< Tool * > draw_over_notified_tools_back
Definition ToolHelper.h:233
std::set< Tool * > draw_over_notified_tools_front
Definition ToolHelper.h:234
std::set< Tool * > draw_under_notified_tools_front
Definition ToolHelper.h:232
void NotifyMe(PanosphereOverviewEvent event, PanosphereOverviewTool *tool)
void DeactivateTool(Tool *tool)
void MouseMoved(int x, int y, wxMouseEvent &e)
void DoNotNotifyMe(PanosphereOverviewEvent event, PanosphereOverviewTool *tool)
void MouseMoved(int x, int y, wxMouseEvent &e)
PreviewToolHelper(HuginBase::Panorama *pano, VisualizationState *visualization_state, GLPreviewFrame *frame)
Definition ToolHelper.h:186
void MouseMoved(int x, int y, wxMouseEvent &e)
double mouse_pano_x
Definition ToolHelper.h:148
void DoNotNotifyMeAfterDrawing(unsigned int image_nr, Tool *tool)
hugin_utils::FDiff2D GetMousePanoPosition()
GLPreviewFrame * GetPreviewFrame()
Definition ToolHelper.h:139
void InvalidateImagesUnderMouse()
void NotifyMeAfterDrawing(unsigned int image_nr, Tool *tool)
bool IsMouseOverPano()
Definition ToolHelper.h:136
void KeypressEvent(int keycode, int modifiers, bool pressed)
std::set< unsigned int > images_under_mouse
Definition ToolHelper.h:178
void UpdateImagesUnderMouse()
void MouseEnter(int x, int y, wxMouseEvent &e)
std::vector< std::set< Tool * > > image_draw_begin_tools
Definition ToolHelper.h:161
HuginBase::Panorama * GetPanoramaPtr()
void NotifyMe(Event event, Tool *tool)
std::set< Tool * > ActivateTool(Tool *tool)
std::set< Tool * > keypress_notified_tools
Definition ToolHelper.h:153
std::set< Tool * > mouse_wheel_notified_tools
Definition ToolHelper.h:158
std::set< Tool * > m_tools_need_dirty_flag
Definition ToolHelper.h:159
std::set< Tool * > draw_over_notified_tools
Definition ToolHelper.h:155
bool mouse_over_pano
Definition ToolHelper.h:176
void MouseButtonEvent(wxMouseEvent &e)
GLPreviewFrame * frame
Definition ToolHelper.h:145
bool BeforeDrawImageNumber(unsigned int image)
double mouse_pano_y
Definition ToolHelper.h:148
virtual ~ToolHelper()
std::vector< std::set< Tool * > > image_draw_end_tools
Definition ToolHelper.h:162
HuginBase::UIntSet GetImagesUnderPos(const hugin_utils::FDiff2D &pos)
virtual void DeactivateTool(Tool *tool)
VisualizationState * visualization_state
Definition ToolHelper.h:144
void AddTool(Tool *tool, Tool **single)
ViewState * GetViewStatePtr()
std::set< Tool * > mouse_button_notified_tools
Definition ToolHelper.h:152
double mouse_screen_x
Definition ToolHelper.h:147
virtual void MouseMoved(int x, int y, wxMouseEvent &e)
VisualizationState * GetVisualizationStatePtr()
std::set< Tool * > images_under_mouse_notified_tools
Definition ToolHelper.h:157
void NotifyMeBeforeDrawing(unsigned int image_nr, Tool *tool)
void MouseWheelEvent(wxMouseEvent &e)
std::set< Tool * > really_draw_over_notified_tools
Definition ToolHelper.h:156
std::set< Tool * > mouse_move_notified_tools
Definition ToolHelper.h:151
bool images_under_mouse_current
Definition ToolHelper.h:176
void BeforeDrawImages()
void MouseLeave()
std::set< Tool * > draw_under_notified_tools
Definition ToolHelper.h:154
void DoNotNotifyMe(Event event, Tool *tool)
std::set< unsigned int > GetImageNumbersUnderMouse()
void DoNotNotifyMeBeforeDrawing(unsigned int image_nr, Tool *tool)
hugin_utils::FDiff2D GetMouseScreenPosition()
@ IMAGES_UNDER_MOUSE_CHANGE
Definition ToolHelper.h:83
@ REALLY_DRAW_OVER_IMAGES
Definition ToolHelper.h:83
@ DRAW_UNDER_IMAGES
Definition ToolHelper.h:82
@ DRAW_OVER_IMAGES
Definition ToolHelper.h:82
double mouse_screen_y
Definition ToolHelper.h:147
std::set< Tool * > tools_deactivated
Definition ToolHelper.h:142
void AfterDrawImages()
void AfterDrawImageNumber(unsigned int image)
HuginBase::Panorama * pano
Definition ToolHelper.h:143
void RemoveTool(Tool *tool, Tool **single)
void MarkDirty()
void SetStatusMessage(wxString message)
Definition Tool.h:43
implementation of huginApp Class
misc math function & classes used by other parts of the program
std::set< unsigned int > UIntSet
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.
Definition threshold.h:41