Copyright (C) 2010 Ixonos Plc. Authors:
Sami Rämö - sami.ramo@ixonos.com
+ Pekka Nissinen - pekka.nissinen@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
#define MAPVIEW_H
#include <QGraphicsView>
+#include <QPropertyAnimation>
/**
* @brief Map view widget
*
* @author Sami Rämö - sami.ramo (at) ixonos.com
+* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
*/
class MapView : public QGraphicsView
{
Q_OBJECT
+
+ /**
+ * @brief View scaling
+ *
+ * @property viewScale
+ */
+ Q_PROPERTY(qreal viewScale READ viewScale WRITE setViewScale)
+
public:
/**
* @brief Constructor
/**
* @brief Called when view is resized.
*
- * @event resize event
+ * @param event resize event
*/
void resizeEvent(QResizeEvent *event);
*/
void mousePressEvent(QMouseEvent *event);
- /**
- * @brief Event handler for timer events, used for smooth zoom effect
- *
- * @param event
- */
- void timerEvent(QTimerEvent *event);
-
/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
*/
void setZoomLevel(int zoomLevel);
+ /**
+ * @brief updates view ports content
+ */
+ void updateViewPortContent();
+
+ /**
+ * @brief Slot for catching request to get view port contents.
+ * implementation of this slot sends signal that includes visble area of view port.
+ */
+ QRect viewportContent();
+
private:
/**
- * @brief get current horizontal scale (vertical should be same)
+ * @brief Set new view scale
*
- * @return qreal Current horizontal scale value
+ * @param viewScale New scaling factor
*/
- qreal currentScale();
+ void setViewScale(qreal viewScale);
-/*******************************************************************************
- * SIGNALS
- ******************************************************************************/
-signals:
/**
- * @brief Signal for view scale factor change events
+ * @brief Get current view scale
*
- * Can be used to trigger scaling of zoom buttons, friend indicators and other
- * MapScene elements which should retain their visual size
- * @param scaleFactor view's scale factor
+ * @return Current view scaling factor
*/
- void scalingFactorChanged(qreal scaleFactor);
+ qreal viewScale();
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
/**
* @brief Signal for view resize events.
*
*/
void viewScrolled(QPoint sceneCoordinate);
+ /**
+ * @brief Signal for informing that zooming animation is finished
+ */
+ void viewZoomFinished();
+
+ /**
+ * @brief Signal for updating view content
+ *
+ * Signal is emitted when view content needs an update.
+ * @param viewTopLeft Scene coordinate of the viewport top left corner
+ */
+ void viewContentChanged(QPoint viewTopLeft);
+
+ /**
+ * @brief Signal that sends visible area of map scene
+ *
+ * @param viewArea visible area of map scene
+ */
+ void updateViewContent(QRect viewArea);
+
+ /**
+ * @brief Signal for drawing OSM license
+ *
+ * Signal is emitted when view is resized.
+ * @param width Viewport width
+ * @param height Viewport height
+ */
+ void viewResizedNewSize(int width, int height);
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
private:
QPoint m_mousePosition; ///< Previous mouse event position
QPoint m_scenePosition; ///< New center position
- qreal m_zoomScaleDelta; ///< Scaling factor delta for smooth zoom transition effect
- qreal m_zoomTargetScale; ///< Scaling factor of the target zoom level
+ QPropertyAnimation *m_zoomAnimation; ///< Zoom animation
};
#endif // MAPVIEW_H