/** ** ** @RDE_HEADER@ ** Implementation of rubberband class to define point feature geometry in 3d ** $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 ** ** ----------------------------------------------------------------------------------------------- */ #include #include "rubberband_point_feature_3d.h" #include "rubberband_base_internal.h" #include #include #include #include #include #include #include namespace SituationMap { namespace RB { struct RubberbandPointFeature3D::InternalData { QPoint m_screenCordinate = QPoint(std::numeric_limits::min(),std::numeric_limits::min()); Point3D m_position; GraphicalObjectPictureMarker * m_marker = nullptr; ScreenToLocationHelper * m_screenToMap = nullptr; AbstractEventDispatcher * m_causer = nullptr; bool m_modifyPosition = false; bool m_positionReady = false; InternalData() = default; ~InternalData() { delete m_marker; delete m_screenToMap; } }; // RubberbandPointFeature3D::InternalData RubberbandPointFeature3D::RubberbandPointFeature3D( SituationMap::Map * map, QObject * parent, bool isActive ) : Rubberband3D(map,parent,isActive) , _internal( new RubberbandPointFeature3D::InternalData() ) { MapImpl *mapImpl = static_cast(_baseInternal->_map.data()); Esri::ArcGISRuntime::SceneGraphicsView *view = mapImpl->getEsriSceneGraphicsView(); _internal->m_screenToMap = new ScreenToLocationHelper(view); connect( _internal->m_screenToMap, &ScreenToLocationHelper::mouseScenePositionChanged, this, &RubberbandPointFeature3D::onMapPosition ); } // RubberbandPointFeature3D::RubberbandPointFeature3D( SituationMap::Map * map, QObject * parent = nullptr, bool isActive ) RubberbandPointFeature3D::~RubberbandPointFeature3D() { delete _internal; _internal = nullptr; } // RubberbandPointFeature3D::~RubberbandPointFeature3D() void RubberbandPointFeature3D::enableModificationState() { _internal->m_modifyPosition = true; _internal->m_positionReady = true; } // void RubberbandPointFeature3D::enableModificationState() void RubberbandPointFeature3D::onMapPosition(const Point3D &mapCoordinate) { if (qIsNaN(mapCoordinate.x())) return; // illegal map position if (qIsNaN(mapCoordinate.y())) return; _internal->m_position = mapCoordinate; if (nullptr == _internal->m_marker) { MapImpl *mapImpl = static_cast(_baseInternal->_map.data()); Esri::ArcGISRuntime::SceneGraphicsView *view = mapImpl->getEsriSceneGraphicsView(); Esri::ArcGISRuntime::GraphicsOverlay *graphicsLayer = mapImpl->getGraphicsLayer(mapImpl->layerFactory().rubberbandLayer()); if (nullptr == view) return; _internal->m_marker = new GraphicalObjectPictureMarker( view, graphicsLayer, QStringLiteral("RubberbandPointFeature3D"), INVALID_MAP_ID ); _internal->m_marker->setImage(markerImage()); } _internal->m_marker->setOrigin( mapCoordinate ); update(); if (_internal->m_causer) { _internal->m_positionReady = true; completeStateAction(_internal->m_causer,_internal->m_screenCordinate.x(), _internal->m_screenCordinate.y()); } } // void RubberbandPointFeature3D::onMapPosition(const QPointF &mapCoordinate) bool RubberbandPointFeature3D::selectAction(AbstractEventDispatcher *, int x, int y) { if (rubberbandIsAlive()) { if (nullptr ==_internal->m_causer) { _internal->m_screenCordinate = QPoint(x,y); _internal->m_screenToMap->screenToLocation(x,y); } return true; } return false; } // bool RubberbandPointFeature3D::selectAction(AbstractEventDispatcher *, int x, int y) bool RubberbandPointFeature3D::setCoordinateAction(AbstractEventDispatcher * causer, int x, int y) { if (rubberbandIsAlive()) { _internal->m_causer = (_internal->m_modifyPosition) ? nullptr : causer; _internal->m_screenCordinate = QPoint(x,y); _internal->m_screenToMap->screenToLocation(x,y); return true; } return false; } // bool RubberbandPointFeature3D::setCoordinateAction(AbstractEventDispatcher * causer, int x, int y) bool RubberbandPointFeature3D::movePickedAction(AbstractEventDispatcher *, int x, int y) { if (rubberbandIsAlive()) { if (nullptr == _internal->m_causer) { _internal->m_screenCordinate = QPoint(x,y); _internal->m_screenToMap->screenToLocation(x,y); } return true; } return false; } // bool RubberbandPointFeature3D::movePickedAction(AbstractEventDispatcher *, int x, int y) bool RubberbandPointFeature3D::moveAction(AbstractEventDispatcher*,int,int) { if (rubberbandIsAlive()) { } return false; } // bool RubberbandPointFeature3D::moveAction(AbstractEventDispatcher*,int,int) bool RubberbandPointFeature3D::completeStateAction ( AbstractEventDispatcher * causer, int x, int y ) { if (coordinateCount() > 0) { return applyAndEndAction(causer,x,y); } return false; } // bool RubberbandPointFeature3D::completeStateAction ( AbstractEventDispatcher * causer, int x, int y ) bool RubberbandPointFeature3D::contextMenuAction ( AbstractEventDispatcher*,int,int ) { return rubberbandIsAlive(); } bool RubberbandPointFeature3D::deleteAction ( AbstractEventDispatcher*,int,int ) { return rubberbandIsAlive(); } bool RubberbandPointFeature3D::undoAction ( AbstractEventDispatcher*,int,int ) { return rubberbandIsAlive(); } unsigned int RubberbandPointFeature3D::coordinateCount() const { return (_internal->m_positionReady) ? 1 : 0; } // unsigned int RubberbandPointFeature3D::coordinateCount() const void RubberbandPointFeature3D::update() { if (_internal->m_marker) _internal->m_marker->updateView(); externalUpdate(); } // RubberbandPointFeature3D::update() QVector RubberbandPointFeature3D::coordinateVector( CoordinateSystem cs ) const { if (coordinateCount() > 0) { const QPointF &geoPos = projectCoordinateFromMap( cs, _internal->m_position.toPointF() ); return QVector() << geoPos; } return QVector(); } // QVector RubberbandPointFeature3D::coordinateVector( CoordinateSystem cs ) const QPointF RubberbandPointFeature3D::singleCoordinate( unsigned int idx, CoordinateSystem cs ) const { Q_UNUSED(idx); if (coordinateCount() > 0) { return coordinateVector(cs).value(0); } return QPointF(); } // QPointF RubberbandPointFeature3D::singleCoordinate( unsigned int idx, CoordinateSystem cs ) const void RubberbandPointFeature3D::setCoordinateVector( const QVector & coordinateVector, CoordinateSystem cs ) { if (coordinateVector.size() > 0) { const QPointF &mapPos = projectCoordinateToMap(cs,coordinateVector[0]); onMapPosition( Point3D::fromQPointF(mapPos) ); } } // void RubberbandPointFeature3D::setCoordinateVector( const QVector & coordinateVector, CoordinateSystem cs ) void RubberbandPointFeature3D::setCoordinateVector(const QVector & coordinateVector, CoordinateSystem cs ) { if (coordinateVector.size() > 0) { const QPointF &mapPos = projectCoordinateToMap(cs,coordinateVector[0].toPointF()); _internal->m_position = Point3D(mapPos.x(),mapPos.y(),coordinateVector[0].z()); } } // void RubberbandPointFeature3D::setCoordinateVector(const QVector & coordinateVector, CoordinateSystem cs ) QVector RubberbandPointFeature3D::coordinateVector3D( CoordinateSystem cs ) const { if (coordinateCount() > 0) { const QPointF &geoPos = projectCoordinateFromMap( cs, _internal->m_position.toPointF() ); return QVector() << Point3D(geoPos.x(),geoPos.y(),_internal->m_position.z()); } return QVector(); } // QVector RubberbandPointFeature3D::coordinateVector3D( CoordinateSystem cs ) const Point3D RubberbandPointFeature3D::singleCoordinate3D(unsigned int idx , CoordinateSystem cs) const { Q_UNUSED(idx); if (coordinateCount() > 0) { return coordinateVector3D(cs).value(0); } return Point3D(); } // Point3D RubberbandPointFeature3D::singleCoordinate3D(unsigned int idx, CoordinateSystem cs) const } } /* namespace SituationMap::RB */