1 /*******************************************************************************
2 **
3 ** Photivo
4 **
5 ** Copyright (C) 2012 Bernd Schoeler <brjohn@brother-john.net>
6 **
7 ** This file is part of Photivo.
8 **
9 ** Photivo is free software: you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License version 3
11 ** as published by the Free Software Foundation.
12 **
13 ** Photivo is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with Photivo.  If not, see <http://www.gnu.org/licenses/>.
20 **
21 *******************************************************************************/
22 /*!
23   \class ptSpotInteraction
24 
25   \brief Class for a simple interaction where the user selects a coordinate on
26   the image by clicking on it.
27 */
28 
29 #ifndef PTSPOTINTERACTION_H
30 #define PTSPOTINTERACTION_H
31 
32 //==============================================================================
33 
34 #include <ptAbstractInteraction.h>
35 
36 #include <QPoint>
37 #include <QMouseEvent>
38 #include <QKeyEvent>
39 
40 //==============================================================================
41 
42 class ptSpotInteraction: public ptAbstractInteraction {
43 Q_OBJECT
44 
45 public:
46   explicit ptSpotInteraction(QGraphicsView *AView);
47   ~ptSpotInteraction();
48 
49   /*! Reimplemented from base class. */
50   virtual void abortMouseAction(const ptMouseAction /*AAction*/);
51 
52   /*! Reimplemented from base class. */
modifiers()53   virtual Qt::KeyboardModifiers modifiers()    const { return Qt::NoModifier; }
54 
55   /*! Reimplemented from base class. */
mouseActions()56   virtual ptMouseActions        mouseActions() const { return maClick; }
57 
58   /*! Reimplemented from base class. */
mouseButtons()59   virtual Qt::MouseButtons      mouseButtons() const { return Qt::LeftButton; }
60 
61   /*! Stops the spotinteraction. Makes sure any necessary cleanup happens properly
62       and emits finished() afterwards.  */
63   void stop();
64 
65 //------------------------------------------------------------------------------
66 
67 private:
68   bool          FAbortNextMouseAction;
69 
70 //------------------------------------------------------------------------------
71 
72 signals:
73   /*!
74    *  Signal emitted when the user left-clicks a spot on the image.
75    *  \param APos
76    *    Coordinates of the clicked image position in current pipe size scale.
77    */
78   void clicked(const QPoint &APos);
79 
80 //------------------------------------------------------------------------------
81 
82 private slots:
83   void mouseAction(QMouseEvent *AEvent);
84 
85 
86 };
87 #endif // PTSPOTINTERACTION_H
88