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

154 lines
4.5 KiB
Objective-C
Executable File

/**
**
** @RDE_HEADER@
** Definition of base class for rubberband frame handles
** $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 .........:
**
** 27.03.2015, JT : First edition for use with Qt5
**
** -----------------------------------------------------------------------------------------------
*/
#pragma once
#include <QtCore/QPointF>
#include <QtWidgets/QGraphicsPolygonItem>
#include <cmath>
#include <Common/ref_pointer.h>
#include "rubberband_handle.h"
#include "rubberband_line_handle.h"
class QGraphicsScene;
namespace SituationMap { namespace RB
{
/**
@class RubberbandFrameHandle rubberband_frame_handle.h
@brief Implementation of a frame handle for rubberband internal use.
@see RubberbandHandle
*/
class RubberbandFrameHandle : public RubberbandHandle
{
Q_OBJECT
public:
RubberbandFrameHandle( Esri::ArcGISRuntime::MapGraphicsView * mapView
, QGraphicsScene * scene
, qreal sceneMargin );
~RubberbandFrameHandle();
inline void updateFrameShape(const QVector<RubberbandCoordinate> & vertexList)
{
updateFrameShape( vertexList, 0.0, 1.0 );
} /* updateFrameShape */
void updateFrameShape( const QVector<RubberbandCoordinate> & vertexList, qreal sinA, qreal cosA );
bool isPositionInside( const QPointF & scenePosition ) const override;
virtual void updateCoordinate( const QPointF & scenePosition );
virtual void moveCoordinate ( const QPointF & sceneDelta );
virtual RubberbandCoordinate getCoordinate() const;
inline qreal frameRotationAngle() const
{
qreal phi = acos(_frameRotationCos);
return (_frameRotationSin < 0.0) ? -phi : phi;
} /* frameRotationAngle */
inline void frameRotationAngle( qreal & sinA, qreal & cosA )
{
sinA = _frameRotationSin;
cosA = _frameRotationCos;
} /* frameRotationAngle */
inline qreal frameSceneMargin() const { return _frameSceneMargin; }
inline void updateFrameRotationAngle( qreal sinA, qreal cosA )
{
_frameRotationSin = sinA;
_frameRotationCos = cosA;
updateFrameShape();
} /* updateFrameRotationAngle */
inline void updateFrameRotationAngle( qreal x )
{
_frameRotationSin = sin(x);
_frameRotationCos = cos(x);
updateFrameShape();
} /* updateFrameRotationAngle */
inline void updateFrameSceneMargin(qreal x) { _frameSceneMargin = x; updateFrameShape(); }
inline void drawDisabled(bool v)
{
_drawDisabled = v;
if (_drawDisabled) _frameSymbol->hide();
else _frameSymbol->show();
} /* drawDisabled */
inline bool drawDisabled() const { return _drawDisabled; }
protected:
QGraphicsPolygonItem * _frameSymbol;
qreal _frameSceneMargin;
qreal _frameRotationSin;
qreal _frameRotationCos;
qreal _frameWidth;
qreal _frameHeight;
RubberbandCoordinate _frameCenterCoordinate;
RubberbandCoordinate _frameVertexCoordinate[4];
qreal _mapRotateSin;
qreal _mapRotateCos;
bool _drawDisabled;
QList<SituationMap::RefPointer<RubberbandLineHandle>> _frameLineHandleList;
void updateGraphic() override;
void updateFrameShape();
void updateFramePolygonItem();
void buildFrameVertexCoordinates();
void adjustCoordinates() override;
void adjustWindow( const QRectF& ) override;
QPointF getMapRotation() { return QPointF( _mapRotateCos, _mapRotateSin ); }
}; /* RubberbandFrameHandle */
} } /* namespace SituationMap::RB */