mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:40:05 +00:00 
			
		
		
		
	Add geographic coordinates to mouse picking functions
This commit is contained in:
		
							parent
							
								
									6e04e1fab3
								
							
						
					
					
						commit
						a2f2181f1b
					
				
					 19 changed files with 72 additions and 42 deletions
				
			
		|  | @ -57,7 +57,8 @@ bool DrawItem::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& /* params */, | ||||
|    const QPointF& /* mouseLocalPos */, | ||||
|    const QPointF& /* mouseGlobalPos */, | ||||
|    const glm::vec2& /* mouseCoords */) | ||||
|    const glm::vec2& /* mouseCoords */, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
| { | ||||
|    // By default, the draw item is not picked
 | ||||
|    return false; | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/qt/gl/gl.hpp> | ||||
| #include <scwx/common/geographic.hpp> | ||||
| 
 | ||||
| #include <memory> | ||||
| 
 | ||||
|  | @ -41,14 +42,16 @@ public: | |||
|     * @param [in] mouseLocalPos Mouse cursor widget position | ||||
|     * @param [in] mouseGlobalPos Mouse cursor screen position | ||||
|     * @param [in] mouseCoords Mouse cursor location in map screen coordinates | ||||
|     * @param [in] mouseGeoCoords Mouse cursor location in geographic coordinates | ||||
|     * | ||||
|     * @return true if the draw item was picked, otherwise false | ||||
|     */ | ||||
|    virtual bool | ||||
|    RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                    const QPointF&   mouseLocalPos, | ||||
|                    const QPointF&   mouseGlobalPos, | ||||
|                    const glm::vec2& mouseCoords); | ||||
|                    const QPointF&            mouseLocalPos, | ||||
|                    const QPointF&            mouseGlobalPos, | ||||
|                    const glm::vec2&          mouseCoords, | ||||
|                    const common::Coordinate& mouseGeoCoords); | ||||
| 
 | ||||
| protected: | ||||
|    void | ||||
|  |  | |||
|  | @ -794,7 +794,8 @@ bool GeoIcons::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|    const QPointF& /* mouseLocalPos */, | ||||
|    const QPointF&   mouseGlobalPos, | ||||
|    const glm::vec2& mouseCoords) | ||||
|    const glm::vec2& mouseCoords, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
| { | ||||
|    std::unique_lock lock {p->iconMutex_}; | ||||
| 
 | ||||
|  |  | |||
|  | @ -38,9 +38,10 @@ public: | |||
|    void Deinitialize() override; | ||||
| 
 | ||||
|    bool RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                         const QPointF&   mouseLocalPos, | ||||
|                         const QPointF&   mouseGlobalPos, | ||||
|                         const glm::vec2& mouseCoords) override; | ||||
|                         const QPointF&            mouseLocalPos, | ||||
|                         const QPointF&            mouseGlobalPos, | ||||
|                         const glm::vec2&          mouseCoords, | ||||
|                         const common::Coordinate& mouseGeoCoords) override; | ||||
| 
 | ||||
|    /**
 | ||||
|     * Sets the visibility of the geo icons. | ||||
|  |  | |||
|  | @ -688,7 +688,8 @@ bool PlacefileIcons::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|    const QPointF& /* mouseLocalPos */, | ||||
|    const QPointF&   mouseGlobalPos, | ||||
|    const glm::vec2& mouseCoords) | ||||
|    const glm::vec2& mouseCoords, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
| { | ||||
|    std::unique_lock lock {p->iconMutex_}; | ||||
| 
 | ||||
|  |  | |||
|  | @ -36,9 +36,10 @@ public: | |||
|    void Deinitialize() override; | ||||
| 
 | ||||
|    bool RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                         const QPointF&   mouseLocalPos, | ||||
|                         const QPointF&   mouseGlobalPos, | ||||
|                         const glm::vec2& mouseCoords) override; | ||||
|                         const QPointF&            mouseLocalPos, | ||||
|                         const QPointF&            mouseGlobalPos, | ||||
|                         const glm::vec2&          mouseCoords, | ||||
|                         const common::Coordinate& mouseGeoCoords) override; | ||||
| 
 | ||||
|    /**
 | ||||
|     * Resets and prepares the draw item for adding a new set of icons. | ||||
|  |  | |||
|  | @ -499,7 +499,8 @@ bool PlacefileLines::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|    const QPointF& /* mouseLocalPos */, | ||||
|    const QPointF&   mouseGlobalPos, | ||||
|    const glm::vec2& mouseCoords) | ||||
|    const glm::vec2& mouseCoords, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
| { | ||||
|    std::unique_lock lock {p->lineMutex_}; | ||||
| 
 | ||||
|  |  | |||
|  | @ -33,9 +33,10 @@ public: | |||
|    void Deinitialize() override; | ||||
| 
 | ||||
|    bool RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                         const QPointF&   mouseLocalPos, | ||||
|                         const QPointF&   mouseGlobalPos, | ||||
|                         const glm::vec2& mouseCoords) override; | ||||
|                         const QPointF&            mouseLocalPos, | ||||
|                         const QPointF&            mouseGlobalPos, | ||||
|                         const glm::vec2&          mouseCoords, | ||||
|                         const common::Coordinate& mouseGeoCoords) override; | ||||
| 
 | ||||
|    /**
 | ||||
|     * Resets and prepares the draw item for adding a new set of lines. | ||||
|  |  | |||
|  | @ -241,7 +241,8 @@ bool PlacefileText::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& /* params */, | ||||
|    const QPointF& /* mouseLocalPos */, | ||||
|    const QPointF& mouseGlobalPos, | ||||
|    const glm::vec2& /* mouseCoords */) | ||||
|    const glm::vec2& /* mouseCoords */, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
| { | ||||
|    bool itemPicked = false; | ||||
| 
 | ||||
|  |  | |||
|  | @ -38,9 +38,10 @@ public: | |||
|    void Deinitialize() override; | ||||
| 
 | ||||
|    bool RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                         const QPointF&   mouseLocalPos, | ||||
|                         const QPointF&   mouseGlobalPos, | ||||
|                         const glm::vec2& mouseCoords) override; | ||||
|                         const QPointF&            mouseLocalPos, | ||||
|                         const QPointF&            mouseGlobalPos, | ||||
|                         const glm::vec2&          mouseCoords, | ||||
|                         const common::Coordinate& mouseGeoCoords) override; | ||||
| 
 | ||||
|    /**
 | ||||
|     * Resets and prepares the draw item for adding a new set of text. | ||||
|  |  | |||
|  | @ -80,7 +80,8 @@ bool DrawLayer::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|    const QPointF&                                  mouseLocalPos, | ||||
|    const QPointF&                                  mouseGlobalPos, | ||||
|    const glm::vec2&                                mouseCoords) | ||||
|    const glm::vec2&                                mouseCoords, | ||||
|    const common::Coordinate&                       mouseGeoCoords) | ||||
| { | ||||
|    bool itemPicked = false; | ||||
| 
 | ||||
|  | @ -88,8 +89,11 @@ bool DrawLayer::RunMousePicking( | |||
|    for (auto it = p->drawList_.rbegin(); it != p->drawList_.rend(); ++it) | ||||
|    { | ||||
|       // Run mouse picking on each draw item
 | ||||
|       if ((*it)->RunMousePicking( | ||||
|              params, mouseLocalPos, mouseGlobalPos, mouseCoords)) | ||||
|       if ((*it)->RunMousePicking(params, | ||||
|                                  mouseLocalPos, | ||||
|                                  mouseGlobalPos, | ||||
|                                  mouseCoords, | ||||
|                                  mouseGeoCoords)) | ||||
|       { | ||||
|          // If a draw item was picked, don't process additional items
 | ||||
|          itemPicked = true; | ||||
|  |  | |||
|  | @ -25,9 +25,10 @@ public: | |||
| 
 | ||||
|    virtual bool | ||||
|    RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                    const QPointF&   mouseLocalPos, | ||||
|                    const QPointF&   mouseGlobalPos, | ||||
|                    const glm::vec2& mouseCoords) override; | ||||
|                    const QPointF&            mouseLocalPos, | ||||
|                    const QPointF&            mouseGlobalPos, | ||||
|                    const glm::vec2&          mouseCoords, | ||||
|                    const common::Coordinate& mouseGeoCoords) override; | ||||
| 
 | ||||
| protected: | ||||
|    void AddDrawItem(const std::shared_ptr<gl::draw::DrawItem>& drawItem); | ||||
|  |  | |||
|  | @ -30,7 +30,8 @@ bool GenericLayer::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& /* params */, | ||||
|    const QPointF& /* mouseLocalPos */, | ||||
|    const QPointF& /* mouseGlobalPos */, | ||||
|    const glm::vec2& /* mousePos */) | ||||
|    const glm::vec2& /* mousePos */, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
| { | ||||
|    // By default, the layer has nothing to pick
 | ||||
|    return false; | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| #pragma once | ||||
| 
 | ||||
| #include <scwx/qt/map/map_context.hpp> | ||||
| #include <scwx/common/geographic.hpp> | ||||
| 
 | ||||
| #include <memory> | ||||
| 
 | ||||
|  | @ -36,14 +37,16 @@ public: | |||
|     * @param [in] mouseLocalPos Mouse cursor widget position | ||||
|     * @param [in] mouseGlobalPos Mouse cursor screen position | ||||
|     * @param [in] mouseCoords Mouse cursor location in map screen coordinates | ||||
|     * @param [in] mouseGeoCoords Mouse cursor location in geographic coordinates | ||||
|     * | ||||
|     * @return true if a draw item was picked, otherwise false | ||||
|     */ | ||||
|    virtual bool | ||||
|    RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                    const QPointF&   mouseLocalPos, | ||||
|                    const QPointF&   mouseGlobalPos, | ||||
|                    const glm::vec2& mouseCoords); | ||||
|                    const QPointF&            mouseLocalPos, | ||||
|                    const QPointF&            mouseGlobalPos, | ||||
|                    const glm::vec2&          mouseCoords, | ||||
|                    const common::Coordinate& mouseGeoCoords); | ||||
| 
 | ||||
| signals: | ||||
|    void NeedsRendering(); | ||||
|  |  | |||
|  | @ -1215,8 +1215,11 @@ void MapWidgetImpl::RunMousePicking() | |||
|    for (auto it = genericLayers_.rbegin(); it != genericLayers_.rend(); ++it) | ||||
|    { | ||||
|       // Run mouse picking for each layer
 | ||||
|       if ((*it)->RunMousePicking( | ||||
|              params, lastPos_, lastGlobalPos_, mouseScreenCoordinate)) | ||||
|       if ((*it)->RunMousePicking(params, | ||||
|                                  lastPos_, | ||||
|                                  lastGlobalPos_, | ||||
|                                  mouseScreenCoordinate, | ||||
|                                  {coordinate.first, coordinate.second})) | ||||
|       { | ||||
|          // If a draw item was picked, don't process additional layers
 | ||||
|          itemPicked = true; | ||||
|  |  | |||
|  | @ -277,7 +277,8 @@ bool OverlayLayer::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& /* params */, | ||||
|    const QPointF& /* mouseLocalPos */, | ||||
|    const QPointF& /* mouseGlobalPos */, | ||||
|    const glm::vec2& /* mouseCoords */) | ||||
|    const glm::vec2& /* mouseCoords */, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
| { | ||||
|    // If sweep time was picked, don't process additional items
 | ||||
|    return p->sweepTimePicked_; | ||||
|  |  | |||
|  | @ -21,10 +21,12 @@ public: | |||
|    void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final; | ||||
|    void Deinitialize() override final; | ||||
| 
 | ||||
|    bool RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                         const QPointF&   mouseLocalPos, | ||||
|                         const QPointF&   mouseGlobalPos, | ||||
|                         const glm::vec2& mouseCoords) override final; | ||||
|    bool | ||||
|    RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                    const QPointF&            mouseLocalPos, | ||||
|                    const QPointF&            mouseGlobalPos, | ||||
|                    const glm::vec2&          mouseCoords, | ||||
|                    const common::Coordinate& mouseGeoCoords) override final; | ||||
| 
 | ||||
| public slots: | ||||
|    void UpdateSweepTimeNextFrame(); | ||||
|  |  | |||
|  | @ -157,7 +157,8 @@ bool RadarSiteLayer::RunMousePicking( | |||
|    const QMapLibreGL::CustomLayerRenderParameters& /* params */, | ||||
|    const QPointF& /* mouseLocalPos */, | ||||
|    const QPointF& mouseGlobalPos, | ||||
|    const glm::vec2& /* mouseCoords */) | ||||
|    const glm::vec2& /* mouseCoords */, | ||||
|    const common::Coordinate& /* mouseGeoCoords */) | ||||
| { | ||||
|    if (!p->hoverText_.empty()) | ||||
|    { | ||||
|  |  | |||
|  | @ -22,10 +22,12 @@ public: | |||
|    void Render(const QMapLibreGL::CustomLayerRenderParameters&) override final; | ||||
|    void Deinitialize() override final; | ||||
| 
 | ||||
|    bool RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                         const QPointF&   mouseLocalPos, | ||||
|                         const QPointF&   mouseGlobalPos, | ||||
|                         const glm::vec2& mouseCoords) override final; | ||||
|    bool | ||||
|    RunMousePicking(const QMapLibreGL::CustomLayerRenderParameters& params, | ||||
|                    const QPointF&            mouseLocalPos, | ||||
|                    const QPointF&            mouseGlobalPos, | ||||
|                    const glm::vec2&          mouseCoords, | ||||
|                    const common::Coordinate& mouseGeoCoords) override final; | ||||
| 
 | ||||
| signals: | ||||
|    void RadarSiteSelected(const std::string& id); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat