@@ -1,5 +1,5 @@
/* **************************************************************************
qgsmaptoolnodetool .h - add/move/delete vertex integrated in one tool
qgsselectedfeature .h - selected feature of nodetool
---------------------
begin : April 2009
copyright : (C) 2009 by Richard Kostecky
Expand All
@@ -13,61 +13,24 @@
* *
***************************************************************************/
#ifndef QGSMAPTOOLNODETOOL_H
#define QGSMAPTOOLNODETOOL_H
#ifndef QGSSELECTEDFEATURE_H
#define QGSSELECTEDFEATURE_H
#include " nodetool/qgsselectedfeature.h"
#include " qgsmaptoolvertexedit.h"
#include " qgsfeature.h"
#include " qgsvertexmarker.h"
#include " qgsgeometryvalidator.h"
#include " qgsmapcanvas.h"
#include " qgslogger.h"
#include " qgsgeometry.h"
#include < QRect>
#include < QRubberBand>
#include < QObject>
class QgsMapCanvas ;
class QgsVectorLayer ;
class QgsMapLayer ;
class QgsRubberBand ;
class QgsGeometryValidator ;
class QgsVertexMarker ;
class VertexEntry
{
bool mSelected ;
QgsPoint mPoint ;
int mEquals ;
bool mInRubberBand ;
int mRubberBandNr ;
int mIndex ;
int mOriginalIndex ;
int mPenWidth ;
QString mToolTip ;
QgsVertexMarker::IconType mType ;
QgsVertexMarker *mMarker ;
QgsMapCanvas *mCanvas ;
QgsMapLayer *mLayer ;
public:
VertexEntry ( QgsMapCanvas *canvas, QgsMapLayer *layer, QgsPoint p, int originalIndex, QString tooltip = QString::null, QgsVertexMarker::IconType type = QgsVertexMarker::ICON_BOX, int penWidth = 2 );
~VertexEntry ();
QgsPoint point () const { return mPoint ; }
int equals () const { return mEquals ; }
bool isSelected () const { return mSelected ; }
bool isInRubberBand () const { return mInRubberBand ; }
void setCenter ( QgsPoint p );
void moveCenter ( double x, double y );
void setEqual ( int index ) { mEquals = index ; }
void setSelected ( bool selected = true );
void setInRubberBand ( bool inRubberBand = true ) { mInRubberBand = inRubberBand; }
int rubberBandNr () const { return mRubberBandNr ; }
int index () { return mIndex ; }
void setRubberBandValues ( bool inRubberBand, int rubberBandNr, int indexInRubberBand );
void update ();
};
/* *
* Set representing set of vertex numbers
*/
typedef QSet<int > Vertexes;
class QgsVertexEntry ;
/* *
* Constant representing zero value for distance. It's 0 because of error in double counting.
Expand All
@@ -77,13 +40,13 @@ const static double ZERO_TOLERANCE = 0.000000001;
/* *
* Class that keeps the selected feature
*/
class SelectedFeature : public QObject
class QgsSelectedFeature : public QObject
{
Q_OBJECT
public:
SelectedFeature ( QgsFeatureId id, QgsVectorLayer *layer, QgsMapCanvas *canvas );
~SelectedFeature ();
QgsSelectedFeature ( QgsFeatureId id, QgsVectorLayer *layer, QgsMapCanvas *canvas );
~QgsSelectedFeature ();
/* *
* Setting selected feature
Expand Down
Expand Up
@@ -148,7 +111,7 @@ class SelectedFeature: public QObject
* Getting vertex map of vertexes
* @return currently used vertex map
*/
QList<VertexEntry *> &vertexMap ();
QList<QgsVertexEntry *> &vertexMap ();
/* *
* Updates whole selection object from the selected object
Expand Down
Expand Up
@@ -253,7 +216,7 @@ class SelectedFeature: public QObject
bool mChangingGeometry ;
QgsVectorLayer* mVlayer ;
QgsRubberBand* mRubberBand ;
QList<VertexEntry *> mVertexMap ;
QList<QgsVertexEntry *> mVertexMap ;
QgsMapCanvas* mCanvas ;
QgsGeometryValidator *mValidator ;
Expand All
@@ -262,125 +225,4 @@ class SelectedFeature: public QObject
QList< QgsVertexMarker * > mGeomErrorMarkers ;
};
/* *A maptool to move/deletes/adds vertices of line or polygon features*/
class QgsMapToolNodeTool : public QgsMapToolVertexEdit
{
Q_OBJECT
public:
QgsMapToolNodeTool ( QgsMapCanvas* canvas );
virtual ~QgsMapToolNodeTool ();
void canvasMoveEvent ( QMouseEvent * e );
void canvasDoubleClickEvent ( QMouseEvent * e );
void canvasPressEvent ( QMouseEvent * e );
void canvasReleaseEvent ( QMouseEvent * e );
void keyPressEvent ( QKeyEvent* e );
void keyReleaseEvent ( QKeyEvent* e );
// ! called when map tool is being deactivated
void deactivate ();
/* *
* Returns closest vertex to given point from selected feature
*/
QgsPoint closestVertex ( QgsPoint point );
public slots:
void selectedFeatureDestroyed ();
private:
/* *
* Deletes the rubber band pointers and clears mRubberBands
*/
void removeRubberBands ();
/* *
* Creating rubber band marker for movin of point
* @param center coordinates of point to be moved
* @param vlayer vector layer on which we are working
* @return rubber band marker
*/
QgsRubberBand* createRubberBandMarker ( QgsPoint center, QgsVectorLayer* vlayer );
/* *
* Function to check if selected feature exists and is same with original one
* stored in internal structures
* @param vlayer vector layer for checking
* @return if feature is same as one in internal structures
*/
bool checkCorrectnessOfFeature ( QgsVectorLayer* vlayer );
/* *
* Creates rubberbands for moving points
*/
void createMovingRubberBands ();
/* *
* Creates rubber bands for ther features when topology editing is enabled
* @param vlayer vector layer for ehich rubber bands are created
* @param vertexMap map of vertexes
* @param vertex currently processed vertex
*/
void createTopologyRubberBands ( QgsVectorLayer* vlayer, const QList<VertexEntry*> &vertexMap, int vertex );
/* * The position of the vertex to move (in map coordinates) to exclude later from snapping*/
QList<QgsPoint> mExcludePoint ;
/* * rubber bands */
QList<QgsRubberBand*> mRubberBands ;
/* * list of topology rubber bands */
QList<QgsRubberBand*> mTopologyRubberBand ;
/* * vertexes of rubberbands which are to be moved */
QMap<QgsFeatureId, Vertexes*> mTopologyMovingVertexes ;
/* * vertexes of features with int id which were already added tu rubber bands */
QMap<QgsFeatureId, Vertexes*> mTopologyRubberBandVertexes ;
/* * object containing selected feature and it's vertexes */
SelectedFeature *mSelectedFeature ;
/* * flag if selection rectangle is active */
bool mSelectionRectangle ;
/* * flag if moving of vertexes is occuring */
bool mMoving ;
/* * flag if click action is still in queue to be processed */
bool mClicked ;
/* * flag if crtl is pressed */
bool mCtrl ;
/* * flag if selection of another feature can occur */
bool mSelectAnother ;
/* * feature id of another feature where user clicked */
QgsFeatureId mAnother ;
/* * stored position of last press down action to count how much vertexes should be moved */
QgsPoint* mLastCoordinates ;
/* * closest vertex to click */
QgsPoint mClosestVertex ;
/* * backup of map coordinates to be able to count change between moves */
QgsPoint mPosMapCoordBackup ;
/* * active rubberband for selecting vertexes */
QRubberBand *mRubberBand ;
/* * rectangle defining area for selecting vertexes */
QRect* mRect ;
/* * flag to tell if edition points */
bool mIsPoint ;
};
#endif