Added simple pointer tracking signals.
This commit is contained in:
+2
-2
@@ -513,8 +513,8 @@ namespace glabels
|
|||||||
updateCursorInfo();
|
updateCursorInfo();
|
||||||
|
|
||||||
connect( view, SIGNAL(zoomChanged()), this, SLOT(updateZoomInfo()) );
|
connect( view, SIGNAL(zoomChanged()), this, SLOT(updateZoomInfo()) );
|
||||||
|
connect( view, SIGNAL(pointerMoved(double, double)), this, SLOT(updateCursorInfo(double, double)) );
|
||||||
/* TODO: connect cursor signals to appropriate slots. */
|
connect( view, SIGNAL(pointerExited()), this, SLOT(updateCursorInfo()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "View.h"
|
#include "View.h"
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -41,6 +42,8 @@ namespace glabels
|
|||||||
setZoomReal( 1, false );
|
setZoomReal( 1, false );
|
||||||
mModel = 0;
|
mModel = 0;
|
||||||
|
|
||||||
|
setMouseTracking( true );
|
||||||
|
|
||||||
mScene = new QGraphicsScene();
|
mScene = new QGraphicsScene();
|
||||||
setScene( mScene );
|
setScene( mScene );
|
||||||
}
|
}
|
||||||
@@ -154,4 +157,17 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void View::mouseMoveEvent( QMouseEvent* event )
|
||||||
|
{
|
||||||
|
QPointF pointer = mapToScene( event->x(), event->y() );
|
||||||
|
emit pointerMoved( pointer.x(), pointer.y() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void View::leaveEvent( QEvent* event )
|
||||||
|
{
|
||||||
|
emit pointerExited();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-1
@@ -34,19 +34,40 @@ namespace glabels
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Lifecycle
|
||||||
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
View( QWidget *parent = 0 );
|
View( QWidget *parent = 0 );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Signals
|
||||||
|
/////////////////////////////////////
|
||||||
signals:
|
signals:
|
||||||
void zoomChanged();
|
void zoomChanged();
|
||||||
|
void pointerMoved( double x, double y );
|
||||||
|
void pointerExited();
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Parameters
|
||||||
|
/////////////////////////////////////
|
||||||
public:
|
public:
|
||||||
inline double zoom() const;
|
inline double zoom() const;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Model
|
||||||
|
/////////////////////////////////////
|
||||||
|
public:
|
||||||
void setModel( LabelModel* model );
|
void setModel( LabelModel* model );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Zoom operations
|
||||||
|
/////////////////////////////////////
|
||||||
|
public:
|
||||||
void zoomIn();
|
void zoomIn();
|
||||||
void zoomOut();
|
void zoomOut();
|
||||||
void zoom1To1();
|
void zoom1To1();
|
||||||
@@ -57,10 +78,18 @@ namespace glabels
|
|||||||
void setZoomReal( double zoom, bool zoomToFitFlag );
|
void setZoomReal( double zoom, bool zoomToFitFlag );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Event handlers
|
||||||
|
/////////////////////////////////////
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent( QResizeEvent *event );
|
void resizeEvent( QResizeEvent* event );
|
||||||
|
void mouseMoveEvent( QMouseEvent* event );
|
||||||
|
void leaveEvent( QEvent* event );
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////
|
||||||
|
// Private data
|
||||||
|
/////////////////////////////////////
|
||||||
private:
|
private:
|
||||||
QGraphicsScene* mScene;
|
QGraphicsScene* mScene;
|
||||||
|
|
||||||
@@ -72,6 +101,10 @@ namespace glabels
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////
|
||||||
|
// INLINE METHODS
|
||||||
|
/////////////////////////////////
|
||||||
|
|
||||||
inline double View::zoom() const
|
inline double View::zoom() const
|
||||||
{
|
{
|
||||||
return mZoom;
|
return mZoom;
|
||||||
|
|||||||
Reference in New Issue
Block a user