QGIS/src/app/qgsmaptooladdregularpolygon.h
lbartoletti 8ea5fe7d05 - mParentTool -> intialize to nullptr;
- =delete to explicit class;
- move clean() to private;
- remove unnecessary initializer;
2017-10-09 12:05:19 +02:00

68 lines
2.5 KiB
C++

/***************************************************************************
qgsmaptooladdregularpolygon.h - map tool for adding regular polygon
---------------------
begin : July 2017
copyright : (C) 2017
email : lbartoletti at tuxfamily dot org
***************************************************************************
* *
* 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 QGSMAPTOOLADDREGULARPOLYGON_H
#define QGSMAPTOOLADDREGULARPOLYGON_H
#include "qgsregularpolygon.h"
#include "qgsmaptoolcapture.h"
#include "qspinbox.h"
class QSpinBox;
class QgsMapToolAddRegularPolygon: public QgsMapToolCapture
{
Q_OBJECT
public:
QgsMapToolAddRegularPolygon( QgsMapToolCapture *parentTool, QgsMapCanvas *canvas, CaptureMode mode = CaptureLine );
~QgsMapToolAddRegularPolygon();
void keyPressEvent( QKeyEvent *e ) override;
void keyReleaseEvent( QKeyEvent *e ) override;
void deactivate() override;
void activate() override;
protected:
explicit QgsMapToolAddRegularPolygon( QgsMapCanvas *canvas ) = delete; //forbidden
std::unique_ptr<QSpinBox> mNumberSidesSpinBox;
int mNumberSides;
//! (re-)create the spin box to enter the number of sides
void createNumberSidesSpinBox();
//! delete the spin box to enter the number of sides, if it exists
void deleteNumberSidesSpinBox();
/** The parent map tool, e.g. the add feature tool.
* Completed regular polygon will be added to this tool by calling its addCurve() method.
* */
QgsMapToolCapture *mParentTool = nullptr;
//! Regular Shape points (in map coordinates)
QgsPointSequence mPoints;
//! The rubberband to show the regular polygon currently working on
QgsGeometryRubberBand *mTempRubberBand = nullptr;
//! Regular shape as a regular polygon
QgsRegularPolygon mRegularPolygon;
private:
//! convenient method to clean members
void clean();
};
#endif // QGSMAPTOOLADDREGULARPOLYGON_H