mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:30:05 +00:00
Highlight active map
This commit is contained in:
parent
8b515dd3d2
commit
9ff6eabd2a
6 changed files with 81 additions and 9 deletions
|
|
@ -312,6 +312,11 @@ void MainWindowImpl::SetActiveMap(map::MapWidget* mapWidget)
|
|||
}
|
||||
|
||||
activeMap_ = mapWidget;
|
||||
|
||||
for (map::MapWidget* widget : maps_)
|
||||
{
|
||||
widget->SetActive(mapWidget == widget);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindowImpl::UpdateElevationSelection(float elevation)
|
||||
|
|
|
|||
|
|
@ -57,9 +57,15 @@ public:
|
|||
radarProductLayer_ {nullptr},
|
||||
radarProductView_ {nullptr},
|
||||
overlayLayer_ {nullptr},
|
||||
isActive_ {false},
|
||||
lastPos_(),
|
||||
currentStyleIndex_ {0},
|
||||
frameDraws_(0)
|
||||
frameDraws_(0),
|
||||
prevLatitude_ {0.0},
|
||||
prevLongitude_ {0.0},
|
||||
prevZoom_ {0.0},
|
||||
prevBearing_ {0.0},
|
||||
prevPitch_ {0.0}
|
||||
{
|
||||
}
|
||||
~MapWidgetImpl() = default;
|
||||
|
|
@ -79,6 +85,7 @@ public:
|
|||
std::shared_ptr<RadarProductLayer> radarProductLayer_;
|
||||
std::shared_ptr<OverlayLayer> overlayLayer_;
|
||||
|
||||
bool isActive_;
|
||||
QPointF lastPos_;
|
||||
uint8_t currentStyleIndex_;
|
||||
|
||||
|
|
@ -133,6 +140,7 @@ void MapWidget::SelectRadarProduct(common::Level2Product product)
|
|||
|
||||
p->radarProductView_ = view::RadarProductViewFactory::Create(
|
||||
product, currentElevation, p->radarProductManager_);
|
||||
p->radarProductView_->SetActive(p->isActive_);
|
||||
|
||||
connect(
|
||||
p->radarProductView_.get(),
|
||||
|
|
@ -169,6 +177,17 @@ void MapWidget::SelectRadarProduct(common::Level2Product product)
|
|||
}
|
||||
}
|
||||
|
||||
void MapWidget::SetActive(bool isActive)
|
||||
{
|
||||
p->isActive_ = isActive;
|
||||
|
||||
if (p->radarProductView_ != nullptr)
|
||||
{
|
||||
p->radarProductView_->SetActive(isActive);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void MapWidget::SetMapParameters(
|
||||
double latitude, double longitude, double zoom, double bearing, double pitch)
|
||||
{
|
||||
|
|
@ -345,7 +364,7 @@ void MapWidget::initializeGL()
|
|||
&MapWidgetImpl::Update);
|
||||
|
||||
// Set default location to KLSX.
|
||||
p->map_->setCoordinateZoom(QMapbox::Coordinate(38.6986, -90.6828), 11);
|
||||
p->map_->setCoordinateZoom(QMapbox::Coordinate(38.6986, -90.6828), 9);
|
||||
p->UpdateStoredMapParameters();
|
||||
|
||||
QString styleUrl = qgetenv("MAPBOX_STYLE_URL");
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public:
|
|||
std::vector<float> GetElevationCuts() const;
|
||||
void SelectElevation(float elevation);
|
||||
void SelectRadarProduct(common::Level2Product product);
|
||||
void SetActive(bool isActive);
|
||||
void SetMapParameters(double latitude,
|
||||
double longitude,
|
||||
double zoom,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
gl::ShaderProgram shaderProgram_;
|
||||
GLint uMVPMatrixLocation_;
|
||||
GLint uColorLocation_;
|
||||
GLuint vbo_;
|
||||
std::array<GLuint, 2> vbo_;
|
||||
GLuint vao_;
|
||||
GLuint texture_;
|
||||
|
||||
|
|
@ -108,12 +108,20 @@ void OverlayLayer::initialize()
|
|||
gl.glGenVertexArrays(1, &p->vao_);
|
||||
|
||||
// Generate vertex buffer objects
|
||||
gl.glGenBuffers(1, &p->vbo_);
|
||||
gl.glGenBuffers(static_cast<GLsizei>(p->vbo_.size()), p->vbo_.data());
|
||||
|
||||
gl.glBindVertexArray(p->vao_);
|
||||
|
||||
// Active box (dynamic sized)
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
|
||||
gl.glBufferData(
|
||||
GL_ARRAY_BUFFER, sizeof(float) * 5 * 2, nullptr, GL_DYNAMIC_DRAW);
|
||||
|
||||
gl.glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, static_cast<void*>(0));
|
||||
gl.glEnableVertexAttribArray(0);
|
||||
|
||||
// Upper right panel (dynamic sized)
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[1]);
|
||||
gl.glBufferData(
|
||||
GL_ARRAY_BUFFER, sizeof(float) * 6 * 2, nullptr, GL_DYNAMIC_DRAW);
|
||||
|
||||
|
|
@ -160,6 +168,27 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
|||
gl.glUniformMatrix4fv(
|
||||
p->uMVPMatrixLocation_, 1, GL_FALSE, glm::value_ptr(projection));
|
||||
|
||||
if (p->radarProductView_->IsActive())
|
||||
{
|
||||
const float vertexLX = 1.0f;
|
||||
const float vertexRX = static_cast<float>(params.width) - 1.0f;
|
||||
const float vertexTY = static_cast<float>(params.height) - 1.0f;
|
||||
const float vertexBY = 1.0f;
|
||||
const float vertices[5][2] = {{vertexLX, vertexTY}, // TL
|
||||
{vertexLX, vertexBY}, // BL
|
||||
{vertexRX, vertexBY}, // BR
|
||||
{vertexRX, vertexTY}, // TR
|
||||
{vertexLX, vertexTY}}; // TL
|
||||
|
||||
// Draw vertices
|
||||
gl.glBindVertexArray(p->vao_);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
|
||||
gl.glVertexAttribPointer(
|
||||
0, 2, GL_FLOAT, GL_FALSE, 0, static_cast<void*>(0));
|
||||
gl.glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
|
||||
gl.glDrawArrays(GL_LINE_STRIP, 0, 5);
|
||||
}
|
||||
|
||||
if (p->sweepTimeString_.length() > 0)
|
||||
{
|
||||
const float fontSize = 16.0f;
|
||||
|
|
@ -182,7 +211,9 @@ void OverlayLayer::render(const QMapbox::CustomLayerRenderParameters& params)
|
|||
|
||||
// Draw vertices
|
||||
gl.glBindVertexArray(p->vao_);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_);
|
||||
gl.glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[1]);
|
||||
gl.glVertexAttribPointer(
|
||||
0, 2, GL_FLOAT, GL_FALSE, 0, static_cast<void*>(0));
|
||||
gl.glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
|
||||
gl.glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
|
|
@ -209,7 +240,7 @@ void OverlayLayer::deinitialize()
|
|||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "deinitialize()";
|
||||
|
||||
gl.glDeleteVertexArrays(1, &p->vao_);
|
||||
gl.glDeleteBuffers(1, &p->vbo_);
|
||||
gl.glDeleteBuffers(static_cast<GLsizei>(p->vbo_.size()), p->vbo_.data());
|
||||
gl.glDeleteTextures(1, &p->texture_);
|
||||
|
||||
p->uMVPMatrixLocation_ = GL_INVALID_INDEX;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,10 @@ static const uint16_t DEFAULT_COLOR_TABLE_MAX = 255u;
|
|||
class RadarProductViewImpl
|
||||
{
|
||||
public:
|
||||
explicit RadarProductViewImpl() = default;
|
||||
~RadarProductViewImpl() = default;
|
||||
explicit RadarProductViewImpl() : isActive_ {false} {};
|
||||
~RadarProductViewImpl() = default;
|
||||
|
||||
bool isActive_;
|
||||
};
|
||||
|
||||
RadarProductView::RadarProductView() :
|
||||
|
|
@ -85,6 +87,16 @@ RadarProductView::GetCfpMomentData() const
|
|||
return std::tie(data, dataSize, componentSize);
|
||||
}
|
||||
|
||||
bool RadarProductView::IsActive() const
|
||||
{
|
||||
return p->isActive_;
|
||||
}
|
||||
|
||||
void RadarProductView::SetActive(bool isActive)
|
||||
{
|
||||
p->isActive_ = isActive;
|
||||
}
|
||||
|
||||
void RadarProductView::ComputeSweep()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ComputeSweep()";
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ public:
|
|||
virtual std::tuple<const void*, size_t, size_t> GetMomentData() const = 0;
|
||||
virtual std::tuple<const void*, size_t, size_t> GetCfpMomentData() const;
|
||||
|
||||
bool IsActive() const;
|
||||
|
||||
void SetActive(bool isActive);
|
||||
|
||||
protected:
|
||||
virtual void UpdateColorTable() = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue