mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
Map updates:
Allow selection of which device to tune to frequency. Support tuning of multiple frequencies per map item. Update maplibre to maplibregl.
This commit is contained in:
parent
78068fd5f2
commit
070f8077b2
@ -269,12 +269,24 @@ Item {
|
||||
mapModel.moveToFront(mapModelFiltered.mapRowToSource(index))
|
||||
}
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
if (frequency > 0) {
|
||||
freqMenuItem.text = "Set frequency to " + frequencyString
|
||||
freqMenuItem.enabled = true
|
||||
} else {
|
||||
freqMenuItem.text = "No frequency available"
|
||||
freqMenuItem.enabled = false
|
||||
menuItems.clear()
|
||||
menus.clear()
|
||||
if (frequencies.length > 0) {
|
||||
var deviceSets = mapModel.getDeviceSets()
|
||||
for (var i = 0; i < deviceSets.length; i++) {
|
||||
menus.append({
|
||||
title: "Set " + deviceSets[i] + " to...",
|
||||
deviceSet: i
|
||||
})
|
||||
for (var j = 0; j < frequencies.length; j++) {
|
||||
menuItems.append({
|
||||
text: frequencyStrings[j],
|
||||
frequency: frequencies[j],
|
||||
deviceSet: deviceSets[i],
|
||||
menuIndex: i
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
var c = mapPtr.toCoordinate(Qt.point(mouse.x, mouse.y))
|
||||
coordsMenuItem.text = "Coords: " + c.latitude.toFixed(6) + ", " + c.longitude.toFixed(6)
|
||||
@ -308,29 +320,42 @@ Item {
|
||||
mapModel.moveToFront(mapModelFiltered.mapRowToSource(index))
|
||||
}
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
if (frequency > 0) {
|
||||
freqMenuItem.text = "Set frequency to " + frequencyString
|
||||
freqMenuItem.enabled = true
|
||||
} else {
|
||||
freqMenuItem.text = "No frequency available"
|
||||
freqMenuItem.enabled = false
|
||||
menuItems.clear()
|
||||
menus.clear()
|
||||
if (frequencies.length > 0) {
|
||||
var deviceSets = mapModel.getDeviceSets()
|
||||
for (var i = 0; i < deviceSets.length; i++) {
|
||||
menus.append({
|
||||
title: "Set " + deviceSets[i] + " to...",
|
||||
deviceSet: i
|
||||
})
|
||||
for (var j = 0; j < frequencies.length; j++) {
|
||||
menuItems.append({
|
||||
text: frequencyStrings[j],
|
||||
frequency: frequencies[j],
|
||||
deviceSet: deviceSets[i],
|
||||
menuIndex: i
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
var c = mapPtr.toCoordinate(Qt.point(mouse.x, mouse.y))
|
||||
coordsMenuItem.text = "Coords: " + c.latitude.toFixed(6) + ", " + c.longitude.toFixed(6)
|
||||
contextMenu.popup()
|
||||
}
|
||||
}
|
||||
ListModel {
|
||||
id: menus
|
||||
}
|
||||
ListModel {
|
||||
id: menuItems
|
||||
}
|
||||
Menu {
|
||||
id: contextMenu
|
||||
MenuItem {
|
||||
text: "Set as target"
|
||||
onTriggered: target = true
|
||||
}
|
||||
MenuItem {
|
||||
id: freqMenuItem
|
||||
text: "Not set"
|
||||
onTriggered: mapModel.setFrequency(frequency)
|
||||
}
|
||||
MenuItem {
|
||||
text: "Move to front"
|
||||
onTriggered: mapModel.moveToFront(mapModelFiltered.mapRowToSource(index))
|
||||
@ -347,6 +372,38 @@ Item {
|
||||
id: coordsMenuItem
|
||||
text: ""
|
||||
}
|
||||
Instantiator {
|
||||
model: menus
|
||||
delegate: Menu {
|
||||
//cascade: true
|
||||
id: contextSubMenu
|
||||
title: model.title
|
||||
}
|
||||
onObjectAdded: function(index, object) {
|
||||
contextMenu.insertMenu(index, object)
|
||||
}
|
||||
onObjectRemoved: function(index, object) {
|
||||
contextMenu.removeMenu(object)
|
||||
}
|
||||
}
|
||||
Instantiator {
|
||||
model: menuItems
|
||||
delegate: MenuItem {
|
||||
text: model.text
|
||||
onTriggered: mapModel.setFrequency(model.frequency, model.deviceSet)
|
||||
}
|
||||
onObjectAdded: function(index, object) {
|
||||
// index is index in to menuItems model
|
||||
// object is the MenuItem
|
||||
var menuItem = menuItems.get(index)
|
||||
var menu = menus.get(menuItem.menuIndex)
|
||||
contextMenu.menuAt(menuItem.menuIndex).insertItem(index, object)
|
||||
}
|
||||
onObjectRemoved: function(index, object) {
|
||||
// Can't use menuItems.get(index) here, as already removed from model
|
||||
object.menu.removeItem(object)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -282,12 +282,24 @@ Item {
|
||||
mapModel.moveToFront(mapModelFiltered.mapRowToSource(index))
|
||||
}
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
if (frequency > 0) {
|
||||
freqMenuItem.text = "Set frequency to " + frequencyString
|
||||
freqMenuItem.enabled = true
|
||||
} else {
|
||||
freqMenuItem.text = "No frequency available"
|
||||
freqMenuItem.enabled = false
|
||||
menuItems.clear()
|
||||
menus.clear()
|
||||
if (frequencies.length > 0) {
|
||||
var deviceSets = mapModel.getDeviceSets()
|
||||
for (var i = 0; i < deviceSets.length; i++) {
|
||||
menus.append({
|
||||
title: "Set " + deviceSets[i] + " to...",
|
||||
deviceSet: i
|
||||
})
|
||||
for (var j = 0; j < frequencies.length; j++) {
|
||||
menuItems.append({
|
||||
text: frequencyStrings[j],
|
||||
frequency: frequencies[j],
|
||||
deviceSet: deviceSets[i],
|
||||
menuIndex: i
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
var c = mapPtr.map.toCoordinate(Qt.point(mouse.x, mouse.y))
|
||||
coordsMenuItem.text = "Coords: " + c.latitude.toFixed(6) + ", " + c.longitude.toFixed(6)
|
||||
@ -321,29 +333,42 @@ Item {
|
||||
mapModel.moveToFront(mapModelFiltered.mapRowToSource(index))
|
||||
}
|
||||
} else if (mouse.button === Qt.RightButton) {
|
||||
if (frequency > 0) {
|
||||
freqMenuItem.text = "Set frequency to " + frequencyString
|
||||
freqMenuItem.enabled = true
|
||||
} else {
|
||||
freqMenuItem.text = "No frequency available"
|
||||
freqMenuItem.enabled = false
|
||||
menuItems.clear()
|
||||
menus.clear()
|
||||
if (frequencies.length > 0) {
|
||||
var deviceSets = mapModel.getDeviceSets()
|
||||
for (var i = 0; i < deviceSets.length; i++) {
|
||||
menus.append({
|
||||
title: "Set " + deviceSets[i] + " to...",
|
||||
deviceSet: i
|
||||
})
|
||||
for (var j = 0; j < frequencies.length; j++) {
|
||||
menuItems.append({
|
||||
text: frequencyStrings[j],
|
||||
frequency: frequencies[j],
|
||||
deviceSet: deviceSets[i],
|
||||
menuIndex: i
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
var c = mapPtr.map.toCoordinate(Qt.point(mouse.x, mouse.y))
|
||||
coordsMenuItem.text = "Coords: " + c.latitude.toFixed(6) + ", " + c.longitude.toFixed(6)
|
||||
contextMenu.popup()
|
||||
}
|
||||
}
|
||||
ListModel {
|
||||
id: menus
|
||||
}
|
||||
ListModel {
|
||||
id: menuItems
|
||||
}
|
||||
Menu {
|
||||
id: contextMenu
|
||||
MenuItem {
|
||||
text: "Set as target"
|
||||
onTriggered: target = true
|
||||
}
|
||||
MenuItem {
|
||||
id: freqMenuItem
|
||||
text: "Not set"
|
||||
onTriggered: mapModel.setFrequency(frequency)
|
||||
}
|
||||
MenuItem {
|
||||
text: "Move to front"
|
||||
onTriggered: mapModel.moveToFront(mapModelFiltered.mapRowToSource(index))
|
||||
@ -360,6 +385,38 @@ Item {
|
||||
id: coordsMenuItem
|
||||
text: ""
|
||||
}
|
||||
Instantiator {
|
||||
model: menus
|
||||
delegate: Menu {
|
||||
//cascade: true
|
||||
id: contextSubMenu
|
||||
title: model.title
|
||||
}
|
||||
onObjectAdded: function(index, object) {
|
||||
contextMenu.insertMenu(index, object)
|
||||
}
|
||||
onObjectRemoved: function(index, object) {
|
||||
contextMenu.removeMenu(object)
|
||||
}
|
||||
}
|
||||
Instantiator {
|
||||
model: menuItems
|
||||
delegate: MenuItem {
|
||||
text: model.text
|
||||
onTriggered: mapModel.setFrequency(model.frequency, model.deviceSet)
|
||||
}
|
||||
onObjectAdded: function(index, object) {
|
||||
// index is index in to menuItems model
|
||||
// object is the MenuItem
|
||||
var menuItem = menuItems.get(index)
|
||||
var menu = menus.get(menuItem.menuIndex)
|
||||
contextMenu.menuAt(menuItem.menuIndex).insertItem(index, object)
|
||||
}
|
||||
onObjectRemoved: function(index, object) {
|
||||
// Can't use menuItems.get(index) here, as already removed from model
|
||||
object.menu.removeItem(object)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1189,11 +1189,12 @@ void MapGUI::applyMap2DSettings(bool reloadMap)
|
||||
if (!m_settings.m_mapBoxStyles.isEmpty())
|
||||
parameters["mapboxgl.mapping.additional_style_urls"] = m_settings.m_mapBoxStyles;
|
||||
}
|
||||
if (m_settings.m_mapProvider == "maplibre")
|
||||
if (m_settings.m_mapProvider == "maplibregl")
|
||||
{
|
||||
parameters["maplibre.access_token"] = m_settings.m_mapBoxAPIKey;
|
||||
parameters["maplibregl.settings_template"] = "maptiler"; // Or "mapbox"
|
||||
parameters["maplibregl.access_token"] = m_settings.m_maptilerAPIKey;
|
||||
if (!m_settings.m_mapBoxStyles.isEmpty())
|
||||
parameters["maplibre.mapping.additional_style_urls"] = m_settings.m_mapBoxStyles;
|
||||
parameters["maplibregl.mapping.additional_style_urls"] = m_settings.m_mapBoxStyles;
|
||||
}
|
||||
if (m_settings.m_mapProvider == "osm")
|
||||
{
|
||||
|
@ -90,7 +90,7 @@ void ObjectMapItem::update(SWGSDRangel::SWGMapItem *mapItem)
|
||||
m_animations.append(new CesiumInterface::Animation(animation));
|
||||
}
|
||||
}
|
||||
findFrequency();
|
||||
findFrequencies();
|
||||
if (!m_fixedPosition)
|
||||
{
|
||||
updateTrack(mapItem->getTrack());
|
||||
@ -192,29 +192,33 @@ void PolylineMapItem::update(SWGSDRangel::SWGMapItem *mapItem)
|
||||
m_bounds = QGeoRectangle(QGeoCoordinate(latMax, lonMin), QGeoCoordinate(latMin, lonMax));
|
||||
}
|
||||
|
||||
void ObjectMapItem::findFrequency()
|
||||
{
|
||||
// Look for a frequency in the text for this object
|
||||
QRegExp re("(([0-9]+(\\.[0-9]+)?) *([kMG])?Hz)");
|
||||
if (re.indexIn(m_text) != -1)
|
||||
void ObjectMapItem::findFrequencies()
|
||||
{
|
||||
QStringList capture = re.capturedTexts();
|
||||
m_frequency = capture[2].toDouble();
|
||||
m_frequencies.clear();
|
||||
m_frequencyStrings.clear();
|
||||
|
||||
const QRegularExpression re("(([0-9]+(\\.[0-9]+)?) *([kMG])?Hz)");
|
||||
QRegularExpressionMatchIterator itr = re.globalMatch(m_text);
|
||||
while (itr.hasNext())
|
||||
{
|
||||
QRegularExpressionMatch match = itr.next();
|
||||
QStringList capture = match.capturedTexts();
|
||||
double frequency = capture[2].toDouble();
|
||||
|
||||
if (capture.length() == 5)
|
||||
{
|
||||
QChar unit = capture[4][0];
|
||||
if (unit == 'k')
|
||||
m_frequency *= 1000.0;
|
||||
else if (unit == 'M')
|
||||
m_frequency *= 1000000.0;
|
||||
else if (unit == 'G')
|
||||
m_frequency *= 1000000000.0;
|
||||
if (unit == 'k') {
|
||||
frequency *= 1000;
|
||||
} else if (unit == 'M') {
|
||||
frequency *= 1000000;
|
||||
} else if (unit == 'G') {
|
||||
frequency *= 1000000000;
|
||||
}
|
||||
m_frequencyString = capture[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_frequency = 0.0;
|
||||
m_frequencies.append((qint64)frequency);
|
||||
m_frequencyStrings.append(capture[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
void update(SWGSDRangel::SWGMapItem *mapItem) override;
|
||||
|
||||
protected:
|
||||
void findFrequency();
|
||||
void findFrequencies();
|
||||
void updateTrack(QList<SWGSDRangel::SWGMapCoordinate *> *track);
|
||||
void updatePredictedTrack(QList<SWGSDRangel::SWGMapCoordinate *> *track);
|
||||
|
||||
@ -92,8 +92,8 @@ protected:
|
||||
QString m_image;
|
||||
int m_imageRotation;
|
||||
QString m_text;
|
||||
double m_frequency; // Frequency to set
|
||||
QString m_frequencyString;
|
||||
QList<qint64> m_frequencies; // Frequencies that can be tuned (currently only extracted from text)
|
||||
QStringList m_frequencyStrings;
|
||||
bool m_fixedPosition; // Don't record/display track
|
||||
QList<QGeoCoordinate *> m_predictedTrackCoords;
|
||||
QList<QDateTime *> m_predictedTrackDateTimes;
|
||||
|
@ -516,8 +516,8 @@ QHash<int, QByteArray> ObjectMapModel::roleNames() const
|
||||
roles[bubbleColourRole] = "bubbleColour";
|
||||
roles[selectedRole] = "selected";
|
||||
roles[targetRole] = "target";
|
||||
roles[frequencyRole] = "frequency";
|
||||
roles[frequencyStringRole] = "frequencyString";
|
||||
roles[frequenciesRole] = "frequencies";
|
||||
roles[frequencyStringsRole] = "frequencyStrings";
|
||||
roles[predictedGroundTrack1Role] = "predictedGroundTrack1";
|
||||
roles[predictedGroundTrack2Role] = "predictedGroundTrack2";
|
||||
roles[groundTrack1Role] = "groundTrack1";
|
||||
@ -675,10 +675,10 @@ QVariant ObjectMapModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant::fromValue(m_selected[row]);
|
||||
case targetRole:
|
||||
return QVariant::fromValue(m_target == row);
|
||||
case frequencyRole:
|
||||
return QVariant::fromValue(mapItem->m_frequency);
|
||||
case frequencyStringRole:
|
||||
return QVariant::fromValue(mapItem->m_frequencyString);
|
||||
case frequenciesRole:
|
||||
return QVariant::fromValue(mapItem->m_frequencies);
|
||||
case frequencyStringsRole:
|
||||
return QVariant::fromValue(mapItem->m_frequencyStrings);
|
||||
case predictedGroundTrack1Role:
|
||||
{
|
||||
if ( (m_displayAllGroundTracks || (m_displaySelectedGroundTracks && m_selected[row]))
|
||||
@ -780,12 +780,6 @@ void ObjectMapModel::setDisplayAllGroundTracks(bool displayGroundTracks)
|
||||
allUpdated();
|
||||
}
|
||||
|
||||
void ObjectMapModel::setFrequency(double frequency)
|
||||
{
|
||||
// Set as centre frequency
|
||||
ChannelWebAPIUtils::setCenterFrequency(0, frequency);
|
||||
}
|
||||
|
||||
void ObjectMapModel::track3D(int index)
|
||||
{
|
||||
if (index < m_items.count())
|
||||
@ -795,6 +789,22 @@ void ObjectMapModel::track3D(int index)
|
||||
}
|
||||
}
|
||||
|
||||
QStringList ObjectMapModel::getDeviceSets() const
|
||||
{
|
||||
return MainCore::instance()->getDeviceSetIds(true, true, false); // FIXME: MIMO currently disabled, as we can't get channel stream indexes
|
||||
}
|
||||
|
||||
void ObjectMapModel::setFrequency(qint64 frequency, const QString& deviceSetId)
|
||||
{
|
||||
unsigned int deviceSetIndex;
|
||||
|
||||
if (MainCore::getDeviceSetIndexFromId(deviceSetId, deviceSetIndex))
|
||||
{
|
||||
// Set as centre frequency
|
||||
ChannelWebAPIUtils::setCenterFrequency(deviceSetIndex, frequency);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMapModel::splitTracks(ObjectMapItem *item)
|
||||
{
|
||||
if (item->m_takenTrackCoords.size() > 1)
|
||||
|
@ -211,8 +211,8 @@ public:
|
||||
bubbleColourRole = MapModel::lastRole + 4,
|
||||
selectedRole = MapModel::lastRole + 5,
|
||||
targetRole = MapModel::lastRole + 6,
|
||||
frequencyRole = MapModel::lastRole + 7,
|
||||
frequencyStringRole = MapModel::lastRole + 8,
|
||||
frequenciesRole = MapModel::lastRole + 7,
|
||||
frequencyStringsRole = MapModel::lastRole + 8,
|
||||
predictedGroundTrack1Role = MapModel::lastRole + 9,
|
||||
predictedGroundTrack2Role = MapModel::lastRole + 10,
|
||||
groundTrack1Role = MapModel::lastRole + 11,
|
||||
@ -244,8 +244,10 @@ public:
|
||||
void setDisplayNames(bool displayNames);
|
||||
void setDisplaySelectedGroundTracks(bool displayGroundTracks);
|
||||
void setDisplayAllGroundTracks(bool displayGroundTracks);
|
||||
Q_INVOKABLE void setFrequency(double frequency);
|
||||
Q_INVOKABLE void track3D(int index);
|
||||
Q_INVOKABLE QStringList getDeviceSets() const;
|
||||
Q_INVOKABLE void setFrequency(qint64 frequency, const QString& deviceSet);
|
||||
|
||||
|
||||
Q_INVOKABLE void viewChanged(double bottomLeftLongitude, double bottomRightLongitude);
|
||||
|
||||
|
@ -66,7 +66,7 @@ const QStringList MapSettings::m_mapProviders = {
|
||||
QStringLiteral("esri"),
|
||||
QStringLiteral("mapbox"),
|
||||
QStringLiteral("mapboxgl"),
|
||||
QStringLiteral("maplibre")
|
||||
QStringLiteral("maplibregl")
|
||||
};
|
||||
|
||||
MapSettings::MapSettings() :
|
||||
|
@ -95,7 +95,7 @@
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>MapLibre</string>
|
||||
<string>MapLibreGL</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user