placeable_window_proxy.h
Go to the documentation of this file.
00001 // *****************************************************************************
00002 //
00003 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
00004 // All rights reserved.
00005 //
00006 // Redistribution and use in source and binary forms, with or without
00007 // modification, are permitted provided that the following conditions are met:
00008 //     * Redistributions of source code must retain the above copyright
00009 //       notice, this list of conditions and the following disclaimer.
00010 //     * Redistributions in binary form must reproduce the above copyright
00011 //       notice, this list of conditions and the following disclaimer in the
00012 //       documentation and/or other materials provided with the distribution.
00013 //     * Neither the name of Southwest Research Institute® (SwRI®) nor the
00014 //       names of its contributors may be used to endorse or promote products
00015 //       derived from this software without specific prior written permission.
00016 //
00017 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027 //
00028 // *****************************************************************************
00029 #ifndef MAPVIZ_PLUGINS_PLACEABLE_WINDOW_PROXY_H
00030 #define MAPVIZ_PLUGINS_PLACEABLE_WINDOW_PROXY_H
00031 
00032 #include <QObject>
00033 #include <QRect>
00034 #include <QPoint>
00035 
00036 QT_BEGIN_NAMESPACE;
00037 class QMouseEvent;
00038 class QResizeEvent;
00039 QT_END_NAMESPACE;
00040 
00056 namespace mapviz_plugins
00057 {
00058   class PlaceableWindowProxy : public QObject
00059   {
00060   Q_OBJECT
00061 
00062   public:
00063     PlaceableWindowProxy();
00064     ~PlaceableWindowProxy();
00065 
00066     void setContainer(QWidget *);
00067 
00068     QRect rect() const;
00069 
00070   Q_SIGNALS:
00071     void rectChanged(const QRect &);
00072 
00073   public Q_SLOTS:
00074     void setRect(const QRect &);
00075     void setVisible(bool visible);
00076 
00077   protected:
00078     bool eventFilter(QObject *object, QEvent *event);
00079 
00080     bool handleMousePress(QMouseEvent *);
00081     bool handleMouseRelease(QMouseEvent *);
00082     bool handleMouseMove(QMouseEvent *);
00083     bool handleResize(QResizeEvent *);
00084 
00085     void timerEvent(QTimerEvent *);
00086 
00087     void rectResize(int dx, int dy);
00088     void winResize(const QSize &);
00089 
00090     QRectF resizeHelper(const QRectF &rect,
00091                         const QPointF &p1,
00092                         const QPointF &p2,
00093                         const QPointF &p3) const;
00094 
00095 
00096 
00097   private:
00098     enum State {
00099       INACTIVE = 0,
00100       MOVE_ALL,
00101       MOVE_TOP_LEFT,
00102       MOVE_BOTTOM_LEFT,
00103       MOVE_BOTTOM_RIGHT,
00104       MOVE_TOP_RIGHT
00105     };
00106 
00107     QWidget *target_;
00108     bool visible_;
00109 
00110     bool has_cursor_;
00111     State state_;
00112     QRectF rect_;
00113 
00114     QRectF start_rect_;
00115     QPoint start_point_;
00116 
00117     int win_resize_timer_;
00118 
00119     State getNextState(const QPointF &pt) const;
00120   };  // class PlaceableWindowProxy
00121 }  // namespace mapviz_plugins
00122 #endif //MAPVIZ_PLUGINS_CANVAS_CLICK_FILTER_H


mapviz_plugins
Author(s): Marc Alban
autogenerated on Thu Aug 24 2017 02:46:09