mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 00:40:06 +00:00 
			
		
		
		
	Update placefile text data outside of render loop, polygon cleanup
This commit is contained in:
		
							parent
							
								
									8f2b87790a
								
							
						
					
					
						commit
						b159540215
					
				
					 6 changed files with 60 additions and 36 deletions
				
			
		|  | @ -815,6 +815,12 @@ void MapWidgetImpl::UpdatePlacefileLayers() | |||
|          placefileLayers_.push_back(placefileLayer); | ||||
|          AddLayer( | ||||
|             GetPlacefileLayerName(placefileName), placefileLayer, "colorTable"); | ||||
| 
 | ||||
|          // When the layer updates, trigger a map widget update
 | ||||
|          connect(placefileLayer.get(), | ||||
|                  &PlacefileLayer::DataReloaded, | ||||
|                  widget_, | ||||
|                  [this]() { widget_->update(); }); | ||||
|       } | ||||
|    } | ||||
| } | ||||
|  |  | |||
|  | @ -59,6 +59,8 @@ PlacefileLayer::PlacefileLayer(std::shared_ptr<MapContext> context, | |||
|    AddDrawItem(p->placefileIcons_); | ||||
|    AddDrawItem(p->placefilePolygons_); | ||||
|    AddDrawItem(p->placefileText_); | ||||
| 
 | ||||
|    ReloadData(); | ||||
| } | ||||
| 
 | ||||
| PlacefileLayer::~PlacefileLayer() = default; | ||||
|  | @ -128,19 +130,10 @@ void PlacefileLayer::Render( | |||
|          p->placefileIcons_->SetIconFiles(placefile->icon_files(), | ||||
|                                           placefile->name()); | ||||
| 
 | ||||
|          // Reset Placefile Text
 | ||||
|          p->placefileText_->Reset(); | ||||
| 
 | ||||
|          for (auto& drawItem : placefile->GetDrawItems()) | ||||
|          { | ||||
|             switch (drawItem->itemType_) | ||||
|             { | ||||
|             case gr::Placefile::ItemType::Text: | ||||
|                p->placefileText_->AddText( | ||||
|                   std::static_pointer_cast<gr::Placefile::TextDrawItem>( | ||||
|                      drawItem)); | ||||
|                break; | ||||
| 
 | ||||
|             case gr::Placefile::ItemType::Icon: | ||||
|                p->placefileIcons_->AddIcon( | ||||
|                   std::static_pointer_cast<gr::Placefile::IconDrawItem>( | ||||
|  | @ -168,7 +161,7 @@ void PlacefileLayer::Deinitialize() | |||
| 
 | ||||
| void PlacefileLayer::ReloadData() | ||||
| { | ||||
|    // TODO: No longer needed after moving Icon and Text Render items here
 | ||||
|    // TODO: No longer needed after moving Icon Render items here
 | ||||
|    p->dirty_ = true; | ||||
| 
 | ||||
|    boost::asio::post( | ||||
|  | @ -188,15 +181,18 @@ void PlacefileLayer::ReloadData() | |||
|             return; | ||||
|          } | ||||
| 
 | ||||
|          // Reset Placefile Polygons
 | ||||
|          // Start draw items
 | ||||
|          p->placefilePolygons_->StartPolygons(); | ||||
|          p->placefileText_->StartText(); | ||||
| 
 | ||||
|          for (auto& drawItem : placefile->GetDrawItems()) | ||||
|          { | ||||
|             switch (drawItem->itemType_) | ||||
|             { | ||||
|             case gr::Placefile::ItemType::Text: | ||||
|                // TODO
 | ||||
|                p->placefileText_->AddText( | ||||
|                   std::static_pointer_cast<gr::Placefile::TextDrawItem>( | ||||
|                      drawItem)); | ||||
|                break; | ||||
| 
 | ||||
|             case gr::Placefile::ItemType::Icon: | ||||
|  | @ -214,8 +210,11 @@ void PlacefileLayer::ReloadData() | |||
|             } | ||||
|          } | ||||
| 
 | ||||
|          // Finish Placefile Polygons
 | ||||
|          // Finish draw items
 | ||||
|          p->placefilePolygons_->FinishPolygons(); | ||||
|          p->placefileText_->FinishText(); | ||||
| 
 | ||||
|          Q_EMIT DataReloaded(); | ||||
|       }); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -13,6 +13,8 @@ namespace map | |||
| 
 | ||||
| class PlacefileLayer : public DrawLayer | ||||
| { | ||||
|    Q_OBJECT | ||||
| 
 | ||||
| public: | ||||
|    explicit PlacefileLayer(std::shared_ptr<MapContext> context, | ||||
|                            const std::string&          placefileName); | ||||
|  | @ -28,6 +30,9 @@ public: | |||
| 
 | ||||
|    void ReloadData(); | ||||
| 
 | ||||
| signals: | ||||
|    void DataReloaded(); | ||||
| 
 | ||||
| private: | ||||
|    class Impl; | ||||
|    std::unique_ptr<Impl> p; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat