mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 19:10:06 +00:00
Merge pull request #389 from AdenKoperczak/rework_layer_text
Rework layer text
This commit is contained in:
commit
8dfb2fe69c
12 changed files with 195 additions and 56 deletions
|
|
@ -29,6 +29,7 @@ static const std::string logPrefix_ = "scwx::qt::manager::font_manager";
|
||||||
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||||
|
|
||||||
static const std::string kFcTrueType_ {"TrueType"};
|
static const std::string kFcTrueType_ {"TrueType"};
|
||||||
|
static const std::string kFcOpenType_ {"CFF"};
|
||||||
|
|
||||||
struct FontRecord
|
struct FontRecord
|
||||||
{
|
{
|
||||||
|
|
@ -70,6 +71,7 @@ public:
|
||||||
|
|
||||||
const std::vector<char>& GetRawFontData(const std::string& filename);
|
const std::vector<char>& GetRawFontData(const std::string& filename);
|
||||||
|
|
||||||
|
static bool CheckFontFormat(const FcChar8* format);
|
||||||
static FontRecord MatchFontFile(const std::string& family,
|
static FontRecord MatchFontFile(const std::string& family,
|
||||||
const std::vector<std::string>& styles);
|
const std::vector<std::string>& styles);
|
||||||
|
|
||||||
|
|
@ -457,6 +459,13 @@ void FontManager::Impl::FinalizeFontconfig()
|
||||||
FcFini();
|
FcFini();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FontManager::Impl::CheckFontFormat(const FcChar8* format)
|
||||||
|
{
|
||||||
|
const std::string stdFormat = reinterpret_cast<const char*>(format);
|
||||||
|
|
||||||
|
return stdFormat == kFcTrueType_ || stdFormat == kFcOpenType_;
|
||||||
|
}
|
||||||
|
|
||||||
FontRecord
|
FontRecord
|
||||||
FontManager::Impl::MatchFontFile(const std::string& family,
|
FontManager::Impl::MatchFontFile(const std::string& family,
|
||||||
const std::vector<std::string>& styles)
|
const std::vector<std::string>& styles)
|
||||||
|
|
@ -469,9 +478,6 @@ FontManager::Impl::MatchFontFile(const std::string& family,
|
||||||
|
|
||||||
FcPatternAddString(
|
FcPatternAddString(
|
||||||
pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(family.c_str()));
|
pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(family.c_str()));
|
||||||
FcPatternAddString(pattern,
|
|
||||||
FC_FONTFORMAT,
|
|
||||||
reinterpret_cast<const FcChar8*>(kFcTrueType_.c_str()));
|
|
||||||
FcPatternAddBool(pattern, FC_SYMBOL, FcFalse);
|
FcPatternAddBool(pattern, FC_SYMBOL, FcFalse);
|
||||||
|
|
||||||
if (!styles.empty())
|
if (!styles.empty())
|
||||||
|
|
@ -505,6 +511,7 @@ FontManager::Impl::MatchFontFile(const std::string& family,
|
||||||
FcChar8* fcFamily = nullptr;
|
FcChar8* fcFamily = nullptr;
|
||||||
FcChar8* fcStyle = nullptr;
|
FcChar8* fcStyle = nullptr;
|
||||||
FcChar8* fcFile = nullptr;
|
FcChar8* fcFile = nullptr;
|
||||||
|
FcChar8* fcFormat = nullptr;
|
||||||
FcBool fcSymbol = FcFalse;
|
FcBool fcSymbol = FcFalse;
|
||||||
|
|
||||||
// Match was found, get properties
|
// Match was found, get properties
|
||||||
|
|
@ -515,7 +522,10 @@ FontManager::Impl::MatchFontFile(const std::string& family,
|
||||||
FcPatternGetString(match, FC_FILE, 0, &fcFile) == FcResultMatch &&
|
FcPatternGetString(match, FC_FILE, 0, &fcFile) == FcResultMatch &&
|
||||||
FcPatternGetBool(match, FC_SYMBOL, 0, &fcSymbol) ==
|
FcPatternGetBool(match, FC_SYMBOL, 0, &fcSymbol) ==
|
||||||
FcResultMatch &&
|
FcResultMatch &&
|
||||||
fcSymbol == FcFalse /*Must check fcSymbol manually*/)
|
FcPatternGetString(match, FC_FONTFORMAT, 0, &fcFormat) ==
|
||||||
|
FcResultMatch &&
|
||||||
|
fcSymbol == FcFalse /*Must check fcSymbol manually*/ &&
|
||||||
|
CheckFontFormat(fcFormat))
|
||||||
{
|
{
|
||||||
record.family_ = reinterpret_cast<char*>(fcFamily);
|
record.family_ = reinterpret_cast<char*>(fcFamily);
|
||||||
record.style_ = reinterpret_cast<char*>(fcStyle);
|
record.style_ = reinterpret_cast<char*>(fcStyle);
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,10 @@ public:
|
||||||
|
|
||||||
AlertLayer::AlertLayer(std::shared_ptr<MapContext> context,
|
AlertLayer::AlertLayer(std::shared_ptr<MapContext> context,
|
||||||
awips::Phenomenon phenomenon) :
|
awips::Phenomenon phenomenon) :
|
||||||
DrawLayer(context), p(std::make_unique<Impl>(this, context, phenomenon))
|
DrawLayer(
|
||||||
|
context,
|
||||||
|
fmt::format("AlertLayer {}", awips::GetPhenomenonText(phenomenon))),
|
||||||
|
p(std::make_unique<Impl>(this, context, phenomenon))
|
||||||
{
|
{
|
||||||
for (auto alertActive : {false, true})
|
for (auto alertActive : {false, true})
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
|
#include <ranges>
|
||||||
|
#include <scwx/qt/manager/font_manager.hpp>
|
||||||
#include <scwx/qt/map/draw_layer.hpp>
|
#include <scwx/qt/map/draw_layer.hpp>
|
||||||
|
#include <scwx/qt/model/imgui_context_model.hpp>
|
||||||
#include <scwx/qt/gl/shader_program.hpp>
|
#include <scwx/qt/gl/shader_program.hpp>
|
||||||
#include <scwx/util/logger.hpp>
|
#include <scwx/util/logger.hpp>
|
||||||
|
|
||||||
namespace scwx
|
#include <backends/imgui_impl_opengl3.h>
|
||||||
{
|
#include <backends/imgui_impl_qt.hpp>
|
||||||
namespace qt
|
#include <utility>
|
||||||
{
|
#include <fmt/format.h>
|
||||||
namespace map
|
#include <imgui.h>
|
||||||
|
|
||||||
|
namespace scwx::qt::map
|
||||||
{
|
{
|
||||||
|
|
||||||
static const std::string logPrefix_ = "scwx::qt::map::draw_layer";
|
static const std::string logPrefix_ = "scwx::qt::map::draw_layer";
|
||||||
|
|
@ -15,21 +20,57 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||||
class DrawLayerImpl
|
class DrawLayerImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DrawLayerImpl(std::shared_ptr<MapContext> context) :
|
explicit DrawLayerImpl(std::shared_ptr<MapContext> context,
|
||||||
context_ {context}, drawList_ {}, textureAtlas_ {GL_INVALID_INDEX}
|
const std::string& imGuiContextName) :
|
||||||
|
context_ {std::move(context)}, drawList_ {}
|
||||||
{
|
{
|
||||||
|
static size_t currentLayerId_ {0u};
|
||||||
|
imGuiContextName_ =
|
||||||
|
fmt::format("{} {}", imGuiContextName, ++currentLayerId_);
|
||||||
|
// This must be initialized after the last line
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
|
||||||
|
imGuiContext_ =
|
||||||
|
model::ImGuiContextModel::Instance().CreateContext(imGuiContextName_);
|
||||||
|
|
||||||
|
// Initialize ImGui Qt backend
|
||||||
|
ImGui_ImplQt_Init();
|
||||||
}
|
}
|
||||||
~DrawLayerImpl() {}
|
~DrawLayerImpl()
|
||||||
|
{
|
||||||
|
// Set ImGui Context
|
||||||
|
ImGui::SetCurrentContext(imGuiContext_);
|
||||||
|
|
||||||
|
// Shutdown ImGui Context
|
||||||
|
if (imGuiRendererInitialized_)
|
||||||
|
{
|
||||||
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
|
}
|
||||||
|
ImGui_ImplQt_Shutdown();
|
||||||
|
|
||||||
|
// Destroy ImGui Context
|
||||||
|
model::ImGuiContextModel::Instance().DestroyContext(imGuiContextName_);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawLayerImpl(const DrawLayerImpl&) = delete;
|
||||||
|
DrawLayerImpl& operator=(const DrawLayerImpl&) = delete;
|
||||||
|
DrawLayerImpl(const DrawLayerImpl&&) = delete;
|
||||||
|
DrawLayerImpl& operator=(const DrawLayerImpl&&) = delete;
|
||||||
|
|
||||||
std::shared_ptr<MapContext> context_;
|
std::shared_ptr<MapContext> context_;
|
||||||
std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_;
|
std::vector<std::shared_ptr<gl::draw::DrawItem>> drawList_;
|
||||||
GLuint textureAtlas_;
|
GLuint textureAtlas_ {GL_INVALID_INDEX};
|
||||||
|
|
||||||
std::uint64_t textureAtlasBuildCount_ {};
|
std::uint64_t textureAtlasBuildCount_ {};
|
||||||
|
|
||||||
|
std::string imGuiContextName_;
|
||||||
|
ImGuiContext* imGuiContext_;
|
||||||
|
bool imGuiRendererInitialized_ {};
|
||||||
};
|
};
|
||||||
|
|
||||||
DrawLayer::DrawLayer(const std::shared_ptr<MapContext>& context) :
|
DrawLayer::DrawLayer(const std::shared_ptr<MapContext>& context,
|
||||||
GenericLayer(context), p(std::make_unique<DrawLayerImpl>(context))
|
const std::string& imGuiContextName) :
|
||||||
|
GenericLayer(context),
|
||||||
|
p(std::make_unique<DrawLayerImpl>(context, imGuiContextName))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
DrawLayer::~DrawLayer() = default;
|
DrawLayer::~DrawLayer() = default;
|
||||||
|
|
@ -42,9 +83,45 @@ void DrawLayer::Initialize()
|
||||||
{
|
{
|
||||||
item->Initialize();
|
item->Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGuiInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
|
void DrawLayer::ImGuiFrameStart()
|
||||||
|
{
|
||||||
|
auto defaultFont = manager::FontManager::Instance().GetImGuiFont(
|
||||||
|
types::FontCategory::Default);
|
||||||
|
|
||||||
|
// Setup ImGui Frame
|
||||||
|
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||||
|
|
||||||
|
// Start ImGui Frame
|
||||||
|
ImGui_ImplQt_NewFrame(p->context_->widget());
|
||||||
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
ImGui::PushFont(defaultFont->font());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawLayer::ImGuiFrameEnd()
|
||||||
|
{
|
||||||
|
// Pop default font
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
// Render ImGui Frame
|
||||||
|
ImGui::Render();
|
||||||
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawLayer::ImGuiInitialize()
|
||||||
|
{
|
||||||
|
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||||
|
ImGui_ImplQt_RegisterWidget(p->context_->widget());
|
||||||
|
ImGui_ImplOpenGL3_Init();
|
||||||
|
p->imGuiRendererInitialized_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawLayer::RenderWithoutImGui(
|
||||||
|
const QMapLibre::CustomLayerRenderParameters& params)
|
||||||
{
|
{
|
||||||
gl::OpenGLFunctions& gl = p->context_->gl();
|
gl::OpenGLFunctions& gl = p->context_->gl();
|
||||||
p->textureAtlas_ = p->context_->GetTextureAtlas();
|
p->textureAtlas_ = p->context_->GetTextureAtlas();
|
||||||
|
|
@ -68,6 +145,17 @@ void DrawLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
|
||||||
|
|
||||||
p->textureAtlasBuildCount_ = newTextureAtlasBuildCount;
|
p->textureAtlasBuildCount_ = newTextureAtlasBuildCount;
|
||||||
}
|
}
|
||||||
|
void DrawLayer::ImGuiSelectContext()
|
||||||
|
{
|
||||||
|
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
|
||||||
|
{
|
||||||
|
ImGuiFrameStart();
|
||||||
|
RenderWithoutImGui(params);
|
||||||
|
ImGuiFrameEnd();
|
||||||
|
}
|
||||||
|
|
||||||
void DrawLayer::Deinitialize()
|
void DrawLayer::Deinitialize()
|
||||||
{
|
{
|
||||||
|
|
@ -90,15 +178,15 @@ bool DrawLayer::RunMousePicking(
|
||||||
bool itemPicked = false;
|
bool itemPicked = false;
|
||||||
|
|
||||||
// For each draw item in the draw list in reverse
|
// For each draw item in the draw list in reverse
|
||||||
for (auto it = p->drawList_.rbegin(); it != p->drawList_.rend(); ++it)
|
for (auto& it : std::ranges::reverse_view(p->drawList_))
|
||||||
{
|
{
|
||||||
// Run mouse picking on each draw item
|
// Run mouse picking on each draw item
|
||||||
if ((*it)->RunMousePicking(params,
|
if (it->RunMousePicking(params,
|
||||||
mouseLocalPos,
|
mouseLocalPos,
|
||||||
mouseGlobalPos,
|
mouseGlobalPos,
|
||||||
mouseCoords,
|
mouseCoords,
|
||||||
mouseGeoCoords,
|
mouseGeoCoords,
|
||||||
eventHandler))
|
eventHandler))
|
||||||
{
|
{
|
||||||
// If a draw item was picked, don't process additional items
|
// If a draw item was picked, don't process additional items
|
||||||
itemPicked = true;
|
itemPicked = true;
|
||||||
|
|
@ -114,6 +202,4 @@ void DrawLayer::AddDrawItem(const std::shared_ptr<gl::draw::DrawItem>& drawItem)
|
||||||
p->drawList_.push_back(drawItem);
|
p->drawList_.push_back(drawItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace map
|
} // namespace scwx::qt::map
|
||||||
} // namespace qt
|
|
||||||
} // namespace scwx
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ class DrawLayerImpl;
|
||||||
class DrawLayer : public GenericLayer
|
class DrawLayer : public GenericLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit DrawLayer(const std::shared_ptr<MapContext>& context);
|
explicit DrawLayer(const std::shared_ptr<MapContext>& context,
|
||||||
|
const std::string& imGuiContextName);
|
||||||
virtual ~DrawLayer();
|
virtual ~DrawLayer();
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
|
|
@ -32,6 +33,12 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddDrawItem(const std::shared_ptr<gl::draw::DrawItem>& drawItem);
|
void AddDrawItem(const std::shared_ptr<gl::draw::DrawItem>& drawItem);
|
||||||
|
void ImGuiFrameStart();
|
||||||
|
void ImGuiFrameEnd();
|
||||||
|
void ImGuiInitialize();
|
||||||
|
void
|
||||||
|
RenderWithoutImGui(const QMapLibre::CustomLayerRenderParameters& params);
|
||||||
|
void ImGuiSelectContext();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<DrawLayerImpl> p;
|
std::unique_ptr<DrawLayerImpl> p;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,8 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<view::OverlayProductView> overlayProductView_ {nullptr};
|
std::shared_ptr<view::OverlayProductView> overlayProductView_ {nullptr};
|
||||||
std::shared_ptr<view::RadarProductView> radarProductView_;
|
std::shared_ptr<view::RadarProductView> radarProductView_;
|
||||||
|
|
||||||
|
QWidget* widget_;
|
||||||
};
|
};
|
||||||
|
|
||||||
MapContext::MapContext(
|
MapContext::MapContext(
|
||||||
|
|
@ -109,6 +111,11 @@ int16_t MapContext::radar_product_code() const
|
||||||
return p->radarProductCode_;
|
return p->radarProductCode_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget* MapContext::widget() const
|
||||||
|
{
|
||||||
|
return p->widget_;
|
||||||
|
}
|
||||||
|
|
||||||
void MapContext::set_map(const std::shared_ptr<QMapLibre::Map>& map)
|
void MapContext::set_map(const std::shared_ptr<QMapLibre::Map>& map)
|
||||||
{
|
{
|
||||||
p->map_ = map;
|
p->map_ = map;
|
||||||
|
|
@ -167,6 +174,11 @@ void MapContext::set_radar_product_code(int16_t radarProductCode)
|
||||||
p->radarProductCode_ = radarProductCode;
|
p->radarProductCode_ = radarProductCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapContext::set_widget(QWidget* widget)
|
||||||
|
{
|
||||||
|
p->widget_ = widget;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace map
|
} // namespace map
|
||||||
} // namespace qt
|
} // namespace qt
|
||||||
} // namespace scwx
|
} // namespace scwx
|
||||||
|
|
|
||||||
|
|
@ -38,18 +38,21 @@ public:
|
||||||
MapContext(MapContext&&) noexcept;
|
MapContext(MapContext&&) noexcept;
|
||||||
MapContext& operator=(MapContext&&) noexcept;
|
MapContext& operator=(MapContext&&) noexcept;
|
||||||
|
|
||||||
std::weak_ptr<QMapLibre::Map> map() const;
|
[[nodiscard]] std::weak_ptr<QMapLibre::Map> map() const;
|
||||||
std::string map_copyrights() const;
|
[[nodiscard]] std::string map_copyrights() const;
|
||||||
MapProvider map_provider() const;
|
[[nodiscard]] MapProvider map_provider() const;
|
||||||
MapSettings& settings();
|
[[nodiscard]] MapSettings& settings();
|
||||||
QMargins color_table_margins() const;
|
[[nodiscard]] QMargins color_table_margins() const;
|
||||||
float pixel_ratio() const;
|
[[nodiscard]] float pixel_ratio() const;
|
||||||
common::Coordinate mouse_coordinate() const;
|
[[nodiscard]] common::Coordinate mouse_coordinate() const;
|
||||||
std::shared_ptr<view::OverlayProductView> overlay_product_view() const;
|
[[nodiscard]] std::shared_ptr<view::OverlayProductView>
|
||||||
std::shared_ptr<view::RadarProductView> radar_product_view() const;
|
overlay_product_view() const;
|
||||||
common::RadarProductGroup radar_product_group() const;
|
[[nodiscard]] std::shared_ptr<view::RadarProductView>
|
||||||
std::string radar_product() const;
|
radar_product_view() const;
|
||||||
int16_t radar_product_code() const;
|
[[nodiscard]] common::RadarProductGroup radar_product_group() const;
|
||||||
|
[[nodiscard]] std::string radar_product() const;
|
||||||
|
[[nodiscard]] int16_t radar_product_code() const;
|
||||||
|
[[nodiscard]] QWidget* widget() const;
|
||||||
|
|
||||||
void set_map(const std::shared_ptr<QMapLibre::Map>& map);
|
void set_map(const std::shared_ptr<QMapLibre::Map>& map);
|
||||||
void set_map_copyrights(const std::string& copyrights);
|
void set_map_copyrights(const std::string& copyrights);
|
||||||
|
|
@ -64,6 +67,7 @@ public:
|
||||||
void set_radar_product_group(common::RadarProductGroup radarProductGroup);
|
void set_radar_product_group(common::RadarProductGroup radarProductGroup);
|
||||||
void set_radar_product(const std::string& radarProduct);
|
void set_radar_product(const std::string& radarProduct);
|
||||||
void set_radar_product_code(int16_t radarProductCode);
|
void set_radar_product_code(int16_t radarProductCode);
|
||||||
|
void set_widget(QWidget* widget);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Impl;
|
class Impl;
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ public:
|
||||||
context_->set_map_provider(
|
context_->set_map_provider(
|
||||||
GetMapProvider(generalSettings.map_provider().GetValue()));
|
GetMapProvider(generalSettings.map_provider().GetValue()));
|
||||||
context_->set_overlay_product_view(overlayProductView);
|
context_->set_overlay_product_view(overlayProductView);
|
||||||
|
context_->set_widget(widget);
|
||||||
|
|
||||||
// Initialize map data
|
// Initialize map data
|
||||||
SetRadarSite(generalSettings.default_radar_site().GetValue());
|
SetRadarSite(generalSettings.default_radar_site().GetValue());
|
||||||
|
|
@ -1571,21 +1572,13 @@ void MapWidget::paintGL()
|
||||||
// Handle hotkey updates
|
// Handle hotkey updates
|
||||||
p->HandleHotkeyUpdates();
|
p->HandleHotkeyUpdates();
|
||||||
|
|
||||||
// Setup ImGui Frame
|
|
||||||
ImGui::SetCurrentContext(p->imGuiContext_);
|
|
||||||
|
|
||||||
// Lock ImGui font atlas prior to new ImGui frame
|
// Lock ImGui font atlas prior to new ImGui frame
|
||||||
std::shared_lock imguiFontAtlasLock {
|
std::shared_lock imguiFontAtlasLock {
|
||||||
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
manager::FontManager::Instance().imgui_font_atlas_mutex()};
|
||||||
|
|
||||||
// Start ImGui Frame
|
// Check ImGui fonts
|
||||||
ImGui_ImplQt_NewFrame(this);
|
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
|
||||||
p->ImGuiCheckFonts();
|
p->ImGuiCheckFonts();
|
||||||
ImGui::NewFrame();
|
|
||||||
|
|
||||||
// Set default font
|
|
||||||
ImGui::PushFont(defaultFont->font());
|
|
||||||
|
|
||||||
// Update pixel ratio
|
// Update pixel ratio
|
||||||
p->context_->set_pixel_ratio(pixelRatio());
|
p->context_->set_pixel_ratio(pixelRatio());
|
||||||
|
|
@ -1596,6 +1589,18 @@ void MapWidget::paintGL()
|
||||||
size() * pixelRatio());
|
size() * pixelRatio());
|
||||||
p->map_->render();
|
p->map_->render();
|
||||||
|
|
||||||
|
// ImGui tool tip code
|
||||||
|
// Setup ImGui Frame
|
||||||
|
ImGui::SetCurrentContext(p->imGuiContext_);
|
||||||
|
|
||||||
|
// Start ImGui Frame
|
||||||
|
ImGui_ImplQt_NewFrame(this);
|
||||||
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
|
ImGui::NewFrame();
|
||||||
|
|
||||||
|
// Set default font
|
||||||
|
ImGui::PushFont(defaultFont->font());
|
||||||
|
|
||||||
// Perform mouse picking
|
// Perform mouse picking
|
||||||
if (p->hasMouse_)
|
if (p->hasMouse_)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,8 @@ void MarkerLayer::Impl::ReloadMarkers()
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkerLayer::MarkerLayer(const std::shared_ptr<MapContext>& context) :
|
MarkerLayer::MarkerLayer(const std::shared_ptr<MapContext>& context) :
|
||||||
DrawLayer(context), p(std::make_unique<MarkerLayer::Impl>(this, context))
|
DrawLayer(context, "MarkerLayer"),
|
||||||
|
p(std::make_unique<MarkerLayer::Impl>(this, context))
|
||||||
{
|
{
|
||||||
AddDrawItem(p->geoIcons_);
|
AddDrawItem(p->geoIcons_);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) :
|
OverlayLayer::OverlayLayer(std::shared_ptr<MapContext> context) :
|
||||||
DrawLayer(context), p(std::make_unique<OverlayLayerImpl>(this, context))
|
DrawLayer(context, "OverlayLayer"),
|
||||||
|
p(std::make_unique<OverlayLayerImpl>(this, context))
|
||||||
{
|
{
|
||||||
AddDrawItem(p->activeBoxOuter_);
|
AddDrawItem(p->activeBoxOuter_);
|
||||||
AddDrawItem(p->activeBoxInner_);
|
AddDrawItem(p->activeBoxInner_);
|
||||||
|
|
@ -292,6 +293,8 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
|
||||||
auto& settings = context()->settings();
|
auto& settings = context()->settings();
|
||||||
const float pixelRatio = context()->pixel_ratio();
|
const float pixelRatio = context()->pixel_ratio();
|
||||||
|
|
||||||
|
ImGuiFrameStart();
|
||||||
|
|
||||||
p->sweepTimePicked_ = false;
|
p->sweepTimePicked_ = false;
|
||||||
|
|
||||||
if (radarProductView != nullptr)
|
if (radarProductView != nullptr)
|
||||||
|
|
@ -457,7 +460,7 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
|
||||||
p->icons_->SetIconVisible(p->mapLogoIcon_,
|
p->icons_->SetIconVisible(p->mapLogoIcon_,
|
||||||
generalSettings.show_map_logo().GetValue());
|
generalSettings.show_map_logo().GetValue());
|
||||||
|
|
||||||
DrawLayer::Render(params);
|
DrawLayer::RenderWithoutImGui(params);
|
||||||
|
|
||||||
auto mapCopyrights = context()->map_copyrights();
|
auto mapCopyrights = context()->map_copyrights();
|
||||||
if (mapCopyrights.length() > 0 &&
|
if (mapCopyrights.length() > 0 &&
|
||||||
|
|
@ -491,6 +494,8 @@ void OverlayLayer::Render(const QMapLibre::CustomLayerRenderParameters& params)
|
||||||
p->lastFontSize_ = ImGui::GetFontSize();
|
p->lastFontSize_ = ImGui::GetFontSize();
|
||||||
p->lastColorTableMargins_ = colorTableMargins;
|
p->lastColorTableMargins_ = colorTableMargins;
|
||||||
|
|
||||||
|
ImGuiFrameEnd();
|
||||||
|
|
||||||
SCWX_GL_CHECK_ERROR();
|
SCWX_GL_CHECK_ERROR();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
OverlayProductLayer::OverlayProductLayer(std::shared_ptr<MapContext> context) :
|
OverlayProductLayer::OverlayProductLayer(std::shared_ptr<MapContext> context) :
|
||||||
DrawLayer(context), p(std::make_unique<Impl>(this, context))
|
DrawLayer(context, "OverlayProductLayer"),
|
||||||
|
p(std::make_unique<Impl>(this, context))
|
||||||
{
|
{
|
||||||
auto overlayProductView = context->overlay_product_view();
|
auto overlayProductView = context->overlay_product_view();
|
||||||
connect(overlayProductView.get(),
|
connect(overlayProductView.get(),
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ public:
|
||||||
|
|
||||||
PlacefileLayer::PlacefileLayer(const std::shared_ptr<MapContext>& context,
|
PlacefileLayer::PlacefileLayer(const std::shared_ptr<MapContext>& context,
|
||||||
const std::string& placefileName) :
|
const std::string& placefileName) :
|
||||||
DrawLayer(context),
|
DrawLayer(context, fmt::format("PlacefileLayer {}", placefileName)),
|
||||||
p(std::make_unique<PlacefileLayer::Impl>(this, context, placefileName))
|
p(std::make_unique<PlacefileLayer::Impl>(this, context, placefileName))
|
||||||
{
|
{
|
||||||
AddDrawItem(p->placefileImages_);
|
AddDrawItem(p->placefileImages_);
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
RadarSiteLayer::RadarSiteLayer(std::shared_ptr<MapContext> context) :
|
RadarSiteLayer::RadarSiteLayer(std::shared_ptr<MapContext> context) :
|
||||||
DrawLayer(context), p(std::make_unique<Impl>(this))
|
DrawLayer(context, "RadarSiteLayer"), p(std::make_unique<Impl>(this))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -55,6 +55,8 @@ void RadarSiteLayer::Initialize()
|
||||||
logger_->debug("Initialize()");
|
logger_->debug("Initialize()");
|
||||||
|
|
||||||
p->radarSites_ = config::RadarSite::GetAll();
|
p->radarSites_ = config::RadarSite::GetAll();
|
||||||
|
|
||||||
|
ImGuiInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadarSiteLayer::Render(
|
void RadarSiteLayer::Render(
|
||||||
|
|
@ -84,6 +86,7 @@ void RadarSiteLayer::Render(
|
||||||
p->halfWidth_ = params.width * 0.5f;
|
p->halfWidth_ = params.width * 0.5f;
|
||||||
p->halfHeight_ = params.height * 0.5f;
|
p->halfHeight_ = params.height * 0.5f;
|
||||||
|
|
||||||
|
ImGuiFrameStart();
|
||||||
// Radar site ImGui windows shouldn't have padding
|
// Radar site ImGui windows shouldn't have padding
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2 {0.0f, 0.0f});
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2 {0.0f, 0.0f});
|
||||||
|
|
||||||
|
|
@ -93,6 +96,7 @@ void RadarSiteLayer::Render(
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::PopStyleVar();
|
ImGui::PopStyleVar();
|
||||||
|
ImGuiFrameEnd();
|
||||||
|
|
||||||
SCWX_GL_CHECK_ERROR();
|
SCWX_GL_CHECK_ERROR();
|
||||||
}
|
}
|
||||||
|
|
@ -136,6 +140,7 @@ void RadarSiteLayer::Impl::RenderRadarSite(
|
||||||
if (ImGui::Button(radarSite->id().c_str()))
|
if (ImGui::Button(radarSite->id().c_str()))
|
||||||
{
|
{
|
||||||
Q_EMIT self_->RadarSiteSelected(radarSite->id());
|
Q_EMIT self_->RadarSiteSelected(radarSite->id());
|
||||||
|
self_->ImGuiSelectContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store hover text for mouse picking pass
|
// Store hover text for mouse picking pass
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue