2009-09-16 19:02:26 +00:00
|
|
|
/***************************************************************************
|
|
|
|
qgsmaptoolrotatepointsymbols.h
|
|
|
|
---------------------
|
|
|
|
begin : September 2009
|
|
|
|
copyright : (C) 2009 by Marco Hugentobler
|
|
|
|
email : marco at hugis dot net
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QGSMAPTOOLROTATEPOINTSYMBOLS_H
|
|
|
|
#define QGSMAPTOOLROTATEPOINTSYMBOLS_H
|
|
|
|
|
2016-04-29 09:43:07 +10:00
|
|
|
#include "qgsmaptoolpointsymbol.h"
|
2017-01-04 12:05:04 +01:00
|
|
|
#include "qgis_app.h"
|
2017-02-07 12:03:31 +10:00
|
|
|
#include <memory>
|
2009-09-16 19:02:26 +00:00
|
|
|
|
|
|
|
class QgsPointRotationItem;
|
2016-08-06 11:01:42 +02:00
|
|
|
class QgsMarkerSymbol;
|
2009-09-16 19:02:26 +00:00
|
|
|
|
2017-10-06 08:19:00 +10:00
|
|
|
/**
|
|
|
|
* \ingroup app
|
2016-04-29 09:43:07 +10:00
|
|
|
* \class QgsMapToolRotatePointSymbols
|
|
|
|
* \brief A class that allows interactive manipulation the value of the rotation field(s) for point layers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class APP_EXPORT QgsMapToolRotatePointSymbols: public QgsMapToolPointSymbol
|
2009-09-16 19:02:26 +00:00
|
|
|
{
|
2010-04-24 18:23:16 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
2009-09-16 19:02:26 +00:00
|
|
|
public:
|
2017-03-03 08:42:00 +01:00
|
|
|
QgsMapToolRotatePointSymbols( QgsMapCanvas *canvas );
|
2017-12-15 08:57:22 +10:00
|
|
|
~QgsMapToolRotatePointSymbols() override;
|
2009-09-16 19:02:26 +00:00
|
|
|
|
2017-03-03 08:42:00 +01:00
|
|
|
void canvasPressEvent( QgsMapMouseEvent *e ) override;
|
|
|
|
void canvasMoveEvent( QgsMapMouseEvent *e ) override;
|
|
|
|
void canvasReleaseEvent( QgsMapMouseEvent *e ) override;
|
2009-09-16 19:02:26 +00:00
|
|
|
|
2017-10-06 08:19:00 +10:00
|
|
|
/**
|
|
|
|
* Returns true if the symbols of a maplayer can be rotated. This means the layer
|
2009-09-16 19:02:26 +00:00
|
|
|
is a vector layer, has type point or multipoint and has at least one rotation attribute in the renderer*/
|
2017-03-03 08:42:00 +01:00
|
|
|
static bool layerIsRotatable( QgsMapLayer *ml );
|
2009-09-16 19:02:26 +00:00
|
|
|
|
2016-04-29 09:43:07 +10:00
|
|
|
protected:
|
|
|
|
|
2017-12-15 08:57:22 +10:00
|
|
|
void canvasPressOnFeature( QgsMapMouseEvent *e, const QgsFeature &feature, const QgsPointXY &snappedPoint ) override;
|
|
|
|
bool checkSymbolCompatibility( QgsMarkerSymbol *markerSymbol, QgsRenderContext &context ) override;
|
|
|
|
void noCompatibleSymbols() override;
|
2016-04-29 09:43:07 +10:00
|
|
|
|
2009-09-16 19:02:26 +00:00
|
|
|
private:
|
2016-04-29 09:43:07 +10:00
|
|
|
|
2016-10-25 09:17:39 +10:00
|
|
|
//! Last azimut between mouse and edited point
|
2009-09-16 19:02:26 +00:00
|
|
|
double mCurrentMouseAzimut;
|
2016-10-25 09:17:39 +10:00
|
|
|
//! Last feature rotation
|
2009-09-16 19:02:26 +00:00
|
|
|
double mCurrentRotationFeature;
|
|
|
|
bool mRotating;
|
2016-04-29 09:43:07 +10:00
|
|
|
QSet<int> mCurrentRotationAttributes;
|
2016-10-25 09:17:39 +10:00
|
|
|
//! Item that displays rotation during mouse move
|
2017-03-03 08:42:00 +01:00
|
|
|
QgsPointRotationItem *mRotationItem = nullptr;
|
2016-10-25 09:17:39 +10:00
|
|
|
//! True if ctrl was pressed during the last mouse move event
|
2009-09-19 13:02:49 +00:00
|
|
|
bool mCtrlPressed;
|
2016-04-29 09:43:07 +10:00
|
|
|
//! Clone of first found marker symbol for feature with rotation attribute set
|
2017-02-07 12:03:31 +10:00
|
|
|
std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
|
2009-09-16 19:02:26 +00:00
|
|
|
|
|
|
|
void drawArrow( double azimut ) const;
|
2016-10-25 09:17:39 +10:00
|
|
|
//! Calculates the azimut between mousePos and mSnappedPoint
|
2016-02-02 19:46:18 +11:00
|
|
|
double calculateAzimut( QPoint mousePos );
|
2016-10-25 09:17:39 +10:00
|
|
|
//! Create item with the point symbol for a specific feature. This will be used to show the rotation to the user
|
2016-08-06 11:01:42 +02:00
|
|
|
void createPixmapItem( QgsMarkerSymbol *markerSymbol );
|
2016-10-25 09:17:39 +10:00
|
|
|
//! Sets the rotation of the pixmap item
|
2009-09-16 19:02:26 +00:00
|
|
|
void setPixmapItemRotation( double rotation );
|
2016-10-25 09:17:39 +10:00
|
|
|
//! Rounds value to 15 degree integer (used if ctrl pressed)
|
2009-09-22 14:02:13 +00:00
|
|
|
static int roundTo15Degrees( double n );
|
2016-04-29 09:43:07 +10:00
|
|
|
|
2009-09-16 19:02:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // QGSMAPTOOLROTATEPOINTSYMBOLS_H
|