Files
qt5-legatus-legacy/Lts/Viewer/SituationMap/Rubberbands/rubberband_multi_point_feature.h
T
2026-08-13 18:33:10 +02:00

210 lines
7.8 KiB
Objective-C
Executable File

/**
**
** @RDE_HEADER@
** Definition of rubberband class to define multi point feature geoemtry
** $Id$
** $HeadURL$
** $Author$
**
** -----------------------------------------------------------------------------------------------
**
** Hardware-Environment: Intel-PC
** Software-Environment: Windows 7, Qt 5.4. ArcGIS 10.2.5
**
** Language ........: C++ 11
**
** -----------------------------------------------------------------------------------------------
**
** Author ...........: Jörg Turla, SPD G, Tel. 3132
**
** -----------------------------------------------------------------------------------------------
**
** Notes .........:
**
** 10.04.2015, JT : First edition for use with Qt5
**
** -----------------------------------------------------------------------------------------------
*/
#pragma once
#include "rubberband.h"
namespace SituationMap { namespace RB
{
class RubberbandHandle;
class RubberbandFrameHandle;
/**
@class RubberbandMultiPointFeature rubberband_multi_point_feature.h
@brief Implementation of a rubberband to input multi point features, like areals or linears
@see Rubberband
*/
class SITUATIONMAP_EXPORT RubberbandMultiPointFeature : public Rubberband
{
Q_OBJECT
public:
/**
@name Construction & Destruction
@{
*/
private:
friend class RubberbandFactory;
friend class RubberbandArrow;
friend class RubberbandCorridor;
friend class RubberbandPolylineWidth;
friend class RubberbandSmoothLine;
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Constructor delegation doesn't work with Visual Studio 2013
explicit RubberbandMultiPointFeature( SituationMap::Map * map );
explicit RubberbandMultiPointFeature( SituationMap::Map * map, bool complexGeometry );
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/**
Construction of RubberbandMultiPointFeature in most common cases. The parameter parent is
optional.
*/
explicit RubberbandMultiPointFeature( SituationMap::Map * map, QObject * parent = nullptr );
/**
Construction of RubberbandMultiPointFeature in case of controlling complex geometry objects, like
splines or multi point symbols. In this case set complexGeometry true.
*/
explicit RubberbandMultiPointFeature( SituationMap::Map * map, bool complexGeometry, QObject * parent = nullptr );
public:
~RubberbandMultiPointFeature();
/** @} */
bool selectAction ( AbstractEventDispatcher * causer, int x, int y ) override;
bool setCoordinateAction ( AbstractEventDispatcher * causer, int x, int y ) override;
bool moveAction ( AbstractEventDispatcher * causer, int x, int y ) override;
bool movePickedAction ( AbstractEventDispatcher * causer, int x, int y ) override;
void resetAction ( AbstractEventDispatcher * causer, int x, int y ) override;
bool contextMenuAction ( AbstractEventDispatcher * causer, int x, int y ) override;
bool completeStateAction ( AbstractEventDispatcher * causer, int x, int y ) override;
bool deleteAction ( AbstractEventDispatcher * causer, int x, int y ) override;
bool undoAction ( AbstractEventDispatcher * causer, int x, int y ) override;
bool applyAndEndAction ( AbstractEventDispatcher * causer, int x, int y ) override;
/**
If set to true a polygon the rubberband draws a polygon otherwise a polyline.
*/
inline void enableClosed( bool flag )
{
_isClosed = flag;
if (( _isClosed) && (_minimumPointCount < 3)) _minimumPointCount = 3;
if ((!_isClosed) && (_minimumPointCount < 2)) _minimumPointCount = 2;
} /* enableClosed */
/**
Gets the value of the close flag
*/
inline bool isClosedEnabled() const { return _isClosed; }
/**
@name Setting Constrains
@{
*/
/**
Defines minimum count of verticies that has to be defined by users input to complete the rubberband with apply signal. The default value is 0.
*/
inline void minimumPointCount( unsigned int x )
{
if (( _isClosed) && (x < 3)) x = 3;
if ((!_isClosed) && (x < 2)) x = 2;
_minimumPointCount = x;
} /* minimumPointCount */
/**
Defines maximum count of verticies that can be aceppted by the rubberband. A values of 0 stands for undefined. The default is 0.
*/
inline void maximumPointCount( unsigned int x )
{
if (x > 0)
{
if (( _isClosed) && (x < 3)) x = 3;
if ((!_isClosed) && (x < 2)) x = 2;
}
_maximumPointCount = x;
} /* maximumPointCount */
/**
Defines the maximum length of a segment (distance between to adjaced verticies). A value of 0 stands for no limit is set. The default is 0.
*/
inline void maximumSegmentLength( qreal x ) { _maximumSegmentLength = (x > 0) ? x : 0.0; }
inline qreal getMaximumSegmentLength() const{ return _maximumSegmentLength; }
/**
Defines the maximum length of the complete polyline. \c enableClosed must be set to false. A value of 0 stands for no limit is set. The default is 0.
*/
inline void maximumLength( qreal x ) { _maximumLength = (x > 0) ? x : 0.0; }
/** @} */
inline qreal getMaximumLength() const { return _maximumLength; }
virtual QVector<QPointF> coordinateVector( CoordinateSystem cs = CoordinateSystem::Geo ) const override;
virtual QPointF singleCoordinate( unsigned int idx = 0, CoordinateSystem cs = CoordinateSystem::Geo ) const override;
virtual void setCoordinateVector( const QVector<QPointF> &, CoordinateSystem cs = CoordinateSystem::Geo ) override;
signals:
/**
The signal will be emitted, when the mouse cursor has changed and the rubberband is in construction mode and is accepting new input coordinates.
*/
void currentCursorPositionChanged(const Point3D &mapCoord);
protected:
/*
Forward declaration of InternalData to hold private member variables. Becareful the base class Rubberband
has similary a class for internal data member with name "InternalData". Don't be confused it is not the same.
*/
struct InternalData;
InternalData * _internal;
bool _isClosed;
unsigned int _minimumPointCount;
unsigned int _maximumPointCount;
qreal _maximumSegmentLength;
qreal _maximumLength;
void activateButtons() override;
void update() override;
// some helper methodes
RubberbandHandle * constructPoint( QPointF scenePos );
void constructPoint(const QPointF &point, CoordinateSystem cs );
bool selectHandles( int x, int y, const QPointF & scenePos );
bool checkLengthConstrains( unsigned int checkHandleIdx, QPointF & scenePos );
bool checkLengthConstrains( const QPointF & scenePos, const QPointF & deltaScenePos );
void updatePreviewLine( const QPointF & scenePosition );
RubberbandFrameHandle * getFrameHandle() const;
void setCheckMaxAngle( double phi );
}; /* RubberbandMultiPointFeature */
} } /* namespace SituationMap::RB */