Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

qsctool.h

00001 /***************************************************************************
00002                                qsctool.h
00003                              -------------------
00004     begin                : Sun Jan 30 2000
00005     copyright            : (C) 2000 by Kamil Dobkowski
00006     email                : kamildbk@friko.onet.pl
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QSCTOOL_H
00019 #define QSCTOOL_H
00020 
00021 #include<qobject.h>
00022 #include<qevent.h>
00023 #include"qscoord.h"
00024 
00025 class QSPlotView;
00026 class QSDrvQt;
00027 
00036 class QSTool : public QObject
00037   {
00038     Q_OBJECT
00039    public:
00043     QSTool( QObject *parent = NULL );
00047     virtual ~QSTool();
00054     virtual void activate( QSPlotView *parentView );
00058     virtual void deactivate();
00065     virtual bool canvasEvent( QEvent *e );
00071     virtual void draw() {}
00072 
00073    protected:
00077     virtual void canvasClicked( const QPoint& pos, int keyState );
00081     virtual void canvasMiddleButtonClicked( const QPoint& pos, int keyState );
00085     virtual void canvasRightButtonClicked( const QPoint& pos, int keyState );
00089     virtual void canvasDoubleClicked( const QPoint& pos, int keyState );
00094     virtual bool canvasDragStart( const QPoint& pos, int keyState );
00098     virtual void canvasDragMove( const QPoint& pos, const QPoint& prevPos, const QPoint& startPos, int keyState, int prevKeyState, int startKeyState );
00103     virtual void canvasDragEnd( const QPoint& pos, const QPoint& startPos, int keyState, int startKeyState );
00107     virtual void canvasMove( const QPoint& pos );
00111     QSPt2f snapToGrid( const QPoint& pos, int keyState=0 );
00115     QSPt2f snapToGrid( const QSPt2f& pos, int keyState=0 );
00120         double snapToGridX( double canvas_x, int keyState=0 );
00124         double snapToGridY( double canvas_y, int keyState=0 );
00128     int snapAngle( int angle, int keyState=0 );
00132     virtual bool eventMouseDblClick( QMouseEvent * );
00136     virtual bool eventMousePress( QMouseEvent*  );
00140     virtual bool eventMouseRelease( QMouseEvent*  );
00144     virtual bool eventMouseMove( QMouseEvent*  );
00148     virtual bool eventKeyPress(  QKeyEvent*  );
00152     virtual bool eventKeyRelease( QKeyEvent*  );
00157         QSDrvQt *driver();
00158 
00159     QSDrvQt    *m_drv;
00160     QSPlotView *m_view;
00161   private:
00162     enum State {    StateReady = 0,
00163             StateLeftButtonPressed,
00164             StateMiddleButtonPressed,
00165             StateRightButtonPressed,
00166             StateDragging };
00167     State m_state;
00168     bool m_snap_to_grid;
00169         QPoint m_drag_start_pos;
00170     QPoint m_drag_prev_pos;
00171     int m_drag_start_key;
00172     int m_drag_prev_key;
00173     void release_driver();
00174   };
00175 
00176 #endif

Generated on Mon Mar 18 19:16:32 2002 for KMatplot library by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002