mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:10:05 +00:00
Add toolbox for radar display control
This commit is contained in:
parent
cd5d60bc0b
commit
7c606b85ff
8 changed files with 325 additions and 6 deletions
|
|
@ -2,6 +2,12 @@
|
||||||
#include "./ui_main_window.h"
|
#include "./ui_main_window.h"
|
||||||
|
|
||||||
#include <scwx/qt/map/map_widget.hpp>
|
#include <scwx/qt/map/map_widget.hpp>
|
||||||
|
#include <scwx/qt/ui/flow_layout.hpp>
|
||||||
|
#include <scwx/common/products.hpp>
|
||||||
|
|
||||||
|
#include <QToolButton>
|
||||||
|
|
||||||
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
namespace scwx
|
namespace scwx
|
||||||
{
|
{
|
||||||
|
|
@ -10,6 +16,8 @@ namespace qt
|
||||||
namespace main
|
namespace main
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static const std::string logPrefix_ = "[scwx::qt::main::main_window] ";
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent) :
|
MainWindow::MainWindow(QWidget* parent) :
|
||||||
QMainWindow(parent), ui(new Ui::MainWindow)
|
QMainWindow(parent), ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
|
|
@ -20,6 +28,20 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||||
settings.setCacheDatabaseMaximumSize(20 * 1024 * 1024);
|
settings.setCacheDatabaseMaximumSize(20 * 1024 * 1024);
|
||||||
|
|
||||||
ui->centralwidget->layout()->addWidget(new map::MapWidget(settings));
|
ui->centralwidget->layout()->addWidget(new map::MapWidget(settings));
|
||||||
|
|
||||||
|
// Add Level2 Products
|
||||||
|
QLayout* level2Layout = new ui::FlowLayout();
|
||||||
|
ui->level2Products->setLayout(level2Layout);
|
||||||
|
|
||||||
|
for (common::Level2Product product : common::Level2ProductIterator())
|
||||||
|
{
|
||||||
|
QToolButton* toolButton = new QToolButton();
|
||||||
|
toolButton->setText(
|
||||||
|
QString::fromStdString(common::GetLevel2Name(product)));
|
||||||
|
toolButton->setStatusTip(
|
||||||
|
tr(common::GetLevel2Description(product).c_str()));
|
||||||
|
level2Layout->addWidget(toolButton);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
|
@ -27,6 +49,33 @@ MainWindow::~MainWindow()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::showEvent(QShowEvent* event)
|
||||||
|
{
|
||||||
|
QMainWindow::showEvent(event);
|
||||||
|
|
||||||
|
// Cycle through each item in the toolbox to render
|
||||||
|
QToolBox* toolbox = ui->radarToolbox;
|
||||||
|
int currentIndex = toolbox->currentIndex();
|
||||||
|
for (int i = 0; i < toolbox->count(); i++)
|
||||||
|
{
|
||||||
|
toolbox->setCurrentIndex(i);
|
||||||
|
}
|
||||||
|
toolbox->setCurrentIndex(currentIndex);
|
||||||
|
|
||||||
|
// Set each level 2 product's tool button to the same size
|
||||||
|
int level2MaxWidth = 0;
|
||||||
|
for (QWidget* widget : ui->level2Products->findChildren<QWidget*>())
|
||||||
|
{
|
||||||
|
level2MaxWidth = std::max(level2MaxWidth, widget->width());
|
||||||
|
}
|
||||||
|
for (QWidget* widget : ui->level2Products->findChildren<QWidget*>())
|
||||||
|
{
|
||||||
|
widget->setMinimumWidth(level2MaxWidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
resizeDocks({ui->radarToolboxDock}, {150}, Qt::Horizontal);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace main
|
} // namespace main
|
||||||
} // namespace qt
|
} // namespace qt
|
||||||
} // namespace scwx
|
} // namespace scwx
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ public:
|
||||||
MainWindow(QWidget* parent = nullptr);
|
MainWindow(QWidget* parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
void showEvent(QShowEvent* event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,15 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>1024</width>
|
||||||
<height>600</height>
|
<height>768</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>MainWindow</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
|
@ -34,12 +34,117 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>1024</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar"/>
|
<widget class="QStatusBar" name="statusbar"/>
|
||||||
|
<widget class="QDockWidget" name="radarToolboxDock">
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Toolbox</string>
|
||||||
|
</property>
|
||||||
|
<attribute name="dockWidgetArea">
|
||||||
|
<number>1</number>
|
||||||
|
</attribute>
|
||||||
|
<widget class="QWidget" name="radarToolboxDockContents">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolBox" name="radarToolbox">
|
||||||
|
<widget class="QWidget" name="radarSitesPage">
|
||||||
|
<attribute name="label">
|
||||||
|
<string>Radar Sites</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QTableWidget" name="tableWidget"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="radarSitesSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="radarProductsPage">
|
||||||
|
<attribute name="label">
|
||||||
|
<string>Radar Products</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="level2Products">
|
||||||
|
<property name="title">
|
||||||
|
<string>Level 2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="radarProductsSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="productSettingsPage">
|
||||||
|
<attribute name="label">
|
||||||
|
<string>Product Settings</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="elevationSettings">
|
||||||
|
<property name="title">
|
||||||
|
<string>Elevation</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="productSettingsSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,35 @@
|
||||||
<source>MainWindow</source>
|
<source>MainWindow</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../source/scwx/qt/main/main_window.ui" line="45"/>
|
||||||
|
<source>Toolbox</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../source/scwx/qt/main/main_window.ui" line="68"/>
|
||||||
|
<source>Radar Sites</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../source/scwx/qt/main/main_window.ui" line="91"/>
|
||||||
|
<source>Radar Products</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../source/scwx/qt/main/main_window.ui" line="97"/>
|
||||||
|
<source>Level 2</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../source/scwx/qt/main/main_window.ui" line="118"/>
|
||||||
|
<source>Product Settings</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../source/scwx/qt/main/main_window.ui" line="124"/>
|
||||||
|
<source>Elevation</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
|
||||||
35
wxdata/include/scwx/common/products.hpp
Normal file
35
wxdata/include/scwx/common/products.hpp
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <scwx/util/iterator.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace common
|
||||||
|
{
|
||||||
|
|
||||||
|
const std::string LEVEL2_GROUP_ID = "L2";
|
||||||
|
|
||||||
|
enum class Level2Product
|
||||||
|
{
|
||||||
|
Reflectivity,
|
||||||
|
Velocity,
|
||||||
|
SpectrumWidth,
|
||||||
|
DifferentialReflectivity,
|
||||||
|
DifferentialPhase,
|
||||||
|
CorrelationCoefficient,
|
||||||
|
ClutterFilterPowerRemoved,
|
||||||
|
Unknown
|
||||||
|
};
|
||||||
|
typedef util::Iterator<Level2Product,
|
||||||
|
Level2Product::Reflectivity,
|
||||||
|
Level2Product::ClutterFilterPowerRemoved>
|
||||||
|
Level2ProductIterator;
|
||||||
|
|
||||||
|
const std::string& GetLevel2Name(Level2Product product);
|
||||||
|
const std::string& GetLevel2Description(Level2Product product);
|
||||||
|
const Level2Product GetLevel2Product(const std::string& id);
|
||||||
|
|
||||||
|
} // namespace common
|
||||||
|
} // namespace scwx
|
||||||
35
wxdata/include/scwx/util/iterator.hpp
Normal file
35
wxdata/include/scwx/util/iterator.hpp
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
|
template<typename T, T beginValue, T endValue>
|
||||||
|
class Iterator
|
||||||
|
{
|
||||||
|
typedef typename std::underlying_type<T>::type value_t;
|
||||||
|
int value_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Iterator(const T& v) : value_(static_cast<value_t>(v)) {}
|
||||||
|
Iterator() : value_(static_cast<value_t>(beginValue)) {}
|
||||||
|
Iterator operator++()
|
||||||
|
{
|
||||||
|
++value_;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
T operator*() { return static_cast<T>(value_); }
|
||||||
|
Iterator begin() { return *this; } // Default constructor
|
||||||
|
Iterator end()
|
||||||
|
{
|
||||||
|
static const Iterator endIterator = ++Iterator(endValue);
|
||||||
|
return endIterator;
|
||||||
|
}
|
||||||
|
bool operator!=(const Iterator& i) { return value_ != i.value_; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace util
|
||||||
|
} // namespace scwx
|
||||||
60
wxdata/source/scwx/common/products.cpp
Normal file
60
wxdata/source/scwx/common/products.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
#include <scwx/common/products.hpp>
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace scwx
|
||||||
|
{
|
||||||
|
namespace common
|
||||||
|
{
|
||||||
|
|
||||||
|
static const std::unordered_map<Level2Product, std::string> level2Name_ {
|
||||||
|
{Level2Product::Reflectivity, "REF"},
|
||||||
|
{Level2Product::Velocity, "VEL"},
|
||||||
|
{Level2Product::SpectrumWidth, "SW"},
|
||||||
|
{Level2Product::DifferentialReflectivity, "ZDR"},
|
||||||
|
{Level2Product::DifferentialPhase, "PHI"},
|
||||||
|
{Level2Product::CorrelationCoefficient, "RHO"},
|
||||||
|
{Level2Product::ClutterFilterPowerRemoved, "CFP"},
|
||||||
|
{Level2Product::Unknown, "?"}};
|
||||||
|
|
||||||
|
static const std::unordered_map<Level2Product, std::string> level2Description_ {
|
||||||
|
{Level2Product::Reflectivity, "Reflectivity"},
|
||||||
|
{Level2Product::Velocity, "Velocity"},
|
||||||
|
{Level2Product::SpectrumWidth, "Spectrum Width"},
|
||||||
|
{Level2Product::DifferentialReflectivity, "Differential Reflectivity"},
|
||||||
|
{Level2Product::DifferentialPhase, "Differential Phase"},
|
||||||
|
{Level2Product::CorrelationCoefficient, "Correlation Coefficient"},
|
||||||
|
{Level2Product::ClutterFilterPowerRemoved, "Clutter Filter Power Removed"},
|
||||||
|
{Level2Product::Unknown, "?"}};
|
||||||
|
|
||||||
|
const std::string& GetLevel2Name(Level2Product product)
|
||||||
|
{
|
||||||
|
return level2Name_.at(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& GetLevel2Description(Level2Product product)
|
||||||
|
{
|
||||||
|
return level2Description_.at(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Level2Product GetLevel2Product(const std::string& name)
|
||||||
|
{
|
||||||
|
auto result = std::find_if(
|
||||||
|
level2Name_.cbegin(),
|
||||||
|
level2Name_.cend(),
|
||||||
|
[&](const std::pair<Level2Product, std::string>& pair) -> bool {
|
||||||
|
return pair.second == name;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (result != level2Name_.cend())
|
||||||
|
{
|
||||||
|
return result->first;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Level2Product::Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace common
|
||||||
|
} // namespace scwx
|
||||||
|
|
@ -4,9 +4,12 @@ find_package(Boost)
|
||||||
|
|
||||||
set(HDR_COMMON include/scwx/common/color_table.hpp
|
set(HDR_COMMON include/scwx/common/color_table.hpp
|
||||||
include/scwx/common/constants.hpp
|
include/scwx/common/constants.hpp
|
||||||
|
include/scwx/common/products.hpp
|
||||||
include/scwx/common/types.hpp)
|
include/scwx/common/types.hpp)
|
||||||
set(SRC_COMMON source/scwx/common/color_table.cpp)
|
set(SRC_COMMON source/scwx/common/color_table.cpp
|
||||||
set(HDR_UTIL include/scwx/util/rangebuf.hpp
|
source/scwx/common/products.cpp)
|
||||||
|
set(HDR_UTIL include/scwx/util/iterator.hpp
|
||||||
|
include/scwx/util/rangebuf.hpp
|
||||||
include/scwx/util/vectorbuf.hpp)
|
include/scwx/util/vectorbuf.hpp)
|
||||||
set(SRC_UTIL source/scwx/util/rangebuf.cpp
|
set(SRC_UTIL source/scwx/util/rangebuf.cpp
|
||||||
source/scwx/util/vectorbuf.cpp)
|
source/scwx/util/vectorbuf.cpp)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue