fastmap/DrawView.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of fastmap.
00004 **
00005 **  This file may be distributed and/or modified under the terms of the
00006 **  GNU General Public License version 2 or 3 as published by the Free
00007 **  Software Foundation and appearing in the file LICENSE.GPL included
00008 **  in the packaging of this file.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
00013 **  more details.
00014 **
00015 **  You should have received a copy of the GNU General Public License
00016 **  along with this program. If not, see <http://www.gnu.org/licenses/>.
00017 **
00018 **  See http://www.geopsy.org for more information.
00019 **
00020 **  Created : 2008-09-12
00021 **  Authors:
00022 **    Marc Wathelet
00023 **    Marc Wathelet (LGIT, Grenoble, France)
00024 **
00025 ***************************************************************************/
00026 
00027 #ifndef DRAWVIEW_H
00028 #define DRAWVIEW_H
00029 
00030 #include <QtGui>
00031 
00032 class DrawScene;
00033 
00034 class DrawView : public QGraphicsView
00035 {
00036   Q_OBJECT
00037 public:
00038   DrawView(DrawScene * scene);
00039   ~DrawView();
00040 
00041   DrawScene * scene() const;
00042 
00043   enum SnapOption {NoSnap=0, SnapX=1, SnapY=2};
00044   Q_DECLARE_FLAGS(SnapOptions, SnapOption)
00045   enum SnapType {SnapNodes, SnapGrid, SnapContours};
00046 
00047   void setSnapOption(SnapOptions ms) {_snapOption=ms;}
00048   SnapOptions snapOption() const {return _snapOption;}
00049 
00050   void setSnapType(SnapType ms) {_snapType=ms;}
00051   SnapType snapType() const {return _snapType;}
00052 
00053   void setMousePoint(const QPointF& p);
00054 signals:
00055   void mouseMoved(const QPointF& p);
00056   void mouseReleased(const QPointF& p);
00057 protected:
00058   virtual void wheelEvent(QWheelEvent * e);
00059   virtual void mouseMoveEvent(QMouseEvent * e);
00060   virtual void mouseReleaseEvent(QMouseEvent * e);
00061   virtual void drawBackground(QPainter * painter, const QRectF & rect);
00062   virtual void drawForeground(QPainter * painter, const QRectF & rect);
00063 private:
00064   void autoTicks(qreal delta, qreal& majorTicks, qreal& minorTicks);
00065 
00066   SnapType _snapType;
00067   SnapOptions _snapOption;
00068   QPointF _mousePoint;
00069 };
00070 
00071 Q_DECLARE_OPERATORS_FOR_FLAGS(DrawView::SnapOptions)
00072 
00073 #endif // DRAWVIEW_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines