Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,167 @@
|
||||
|
||||
/**
|
||||
**
|
||||
** @RDE_HEADER@
|
||||
** Implementation of class RubberbandHandleProxy to forward adjust signals from view
|
||||
** $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.07.2015, JT : First edition for use with Qt5
|
||||
**
|
||||
** -----------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "rubberband_handle_proxy.h"
|
||||
|
||||
#include <MathUtils/math_const.h>
|
||||
|
||||
#include <QtCore/QRectF>
|
||||
|
||||
#define BUG_iOSQz_000005
|
||||
|
||||
|
||||
namespace SituationMap { namespace RB
|
||||
{
|
||||
|
||||
void RubberbandHandleProxy::init( QWidget * widget )
|
||||
{
|
||||
zBufferPlane( ZBufferPlane::Widget );
|
||||
|
||||
_widgetsProxy = new QGraphicsProxyWidget();
|
||||
_widgetsProxy -> setWidget( widget );
|
||||
_widgetsProxy -> setZValue( _zBufferValue );
|
||||
|
||||
#ifdef BUG_iOSQz_000005
|
||||
// Bug iOSQz-000005 'QGraphicsProxyWidget will crash'
|
||||
// Adding a widget will let the application crash
|
||||
// Workaround: 'proxy->setOpacity(0.99);'
|
||||
|
||||
_widgetsProxy->setOpacity(0.99);
|
||||
#endif
|
||||
|
||||
_scene->addItem( _widgetsProxy );
|
||||
|
||||
} /* RubberbandHandleProxy::init */
|
||||
|
||||
|
||||
RubberbandHandleProxy::RubberbandHandleProxy( QGraphicsView * view, QWidget * widget )
|
||||
: RubberbandHandle(view)
|
||||
, _coordinate()
|
||||
, _sceneOffset(0, 0)
|
||||
, _rotateSceneOffset(true)
|
||||
, _restoreView(view)
|
||||
{
|
||||
init( widget );
|
||||
} /* RubberbandHandleProxy::RubberbandHandleProxy */
|
||||
|
||||
|
||||
RubberbandHandleProxy::RubberbandHandleProxy( Esri::ArcGISRuntime::MapGraphicsView * view, QWidget * widget )
|
||||
: RubberbandHandle(view)
|
||||
, _coordinate()
|
||||
, _sceneOffset(0, 0)
|
||||
, _rotateSceneOffset(true)
|
||||
, _restoreView(view)
|
||||
{
|
||||
init( widget );
|
||||
} /* RubberbandHandleProxy::RubberbandHandleProxy */
|
||||
|
||||
|
||||
RubberbandHandleProxy::RubberbandHandleProxy( Esri::ArcGISRuntime::MapGraphicsView * view, QGraphicsScene * scene, QWidget * widget )
|
||||
: RubberbandHandle(view, scene)
|
||||
, _coordinate()
|
||||
, _sceneOffset(0, 0)
|
||||
, _rotateSceneOffset(true)
|
||||
, _restoreView(view)
|
||||
{
|
||||
init( widget );
|
||||
} /* RubberbandHandleProxy::RubberbandHandleProxy */
|
||||
|
||||
|
||||
RubberbandHandleProxy::~RubberbandHandleProxy()
|
||||
{
|
||||
if (_scene)
|
||||
{
|
||||
if (_widgetsProxy)
|
||||
{
|
||||
_widgetsProxy->setWidget(nullptr);
|
||||
_scene->removeItem(_widgetsProxy);
|
||||
delete _widgetsProxy;
|
||||
}
|
||||
}
|
||||
_widgetsProxy = nullptr;
|
||||
|
||||
if (_restoreView && _restoreView->viewport())
|
||||
_restoreView->viewport()->setCursor(_restoreCursor); // workaround Qt bug. remove when fixed
|
||||
|
||||
} /* RubberbandHandleProxy::~RubberbandHandleProxy */
|
||||
|
||||
|
||||
QPointF RubberbandHandleProxy::getRotatedSceneOffset() const
|
||||
{
|
||||
if ((_mapView) && (_rotateSceneOffset))
|
||||
{
|
||||
auto rotate = [](const QPointF & p, qreal sinA, qreal cosA) -> QPointF { return QPointF(p.x()*cosA+p.y()*sinA,p.y()*cosA-p.x()*sinA); };
|
||||
|
||||
qreal mapRotatePhi = _mapView->mapRotation() * MathConst::pi / 180.0;
|
||||
|
||||
qreal sinMap = sin(mapRotatePhi);
|
||||
qreal cosMap = cos(mapRotatePhi);
|
||||
|
||||
return rotate( _sceneOffset, sinMap, cosMap );
|
||||
}
|
||||
else return _sceneOffset;
|
||||
} /* RubberbandHandleProxy::getRotatedSceneOffset */
|
||||
|
||||
|
||||
void RubberbandHandleProxy::setPos(const QPointF & pos)
|
||||
{
|
||||
_coordinate.updateSceneCoordinate( _mapView, pos );
|
||||
if (_widgetsProxy)
|
||||
{
|
||||
_widgetsProxy -> setPos(pos+getRotatedSceneOffset());
|
||||
_widgetsProxy -> setZValue( _zBufferValue );
|
||||
}
|
||||
} /* RubberbandHandleProxy::setPos */
|
||||
|
||||
|
||||
bool RubberbandHandleProxy::isPositionInside( const QPointF & scenePosition ) const
|
||||
{
|
||||
const QRectF & bbox = _widgetsProxy->windowFrameGeometry();
|
||||
return bbox.contains(scenePosition);
|
||||
} /* RubberbandHandleProxy::isPositionInside */
|
||||
|
||||
|
||||
void RubberbandHandleProxy::adjustCoordinates()
|
||||
{
|
||||
const QPointF & scenePosition = _coordinate.mapToScene(_mapView);
|
||||
if (_widgetsProxy)
|
||||
{
|
||||
_widgetsProxy -> setZValue( _zBufferValue );
|
||||
_widgetsProxy -> setPos(scenePosition+getRotatedSceneOffset());
|
||||
}
|
||||
emit adjusted();
|
||||
} /* RubberbandHandleProxy::adjustCoordinates */
|
||||
|
||||
|
||||
void RubberbandHandleProxy::adjustWindow( const QRectF & )
|
||||
{
|
||||
onDo_adjustCoordinates();
|
||||
} /* RubberbandHandleProxy::adjustWindow */
|
||||
|
||||
} } /* namespace SituationMap::RB */
|
||||
Reference in new issue
Block a user