Skip to content

Commit

Permalink
[Map] Allows to show/hide MapItems.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien-B committed Feb 21, 2024
1 parent fbf2834 commit c1ae3a0
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 5 deletions.
7 changes: 7 additions & 0 deletions data/tile_sources.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<sources>
<source
name="LubrizolPM5" dir="LubrizolPM5"
addr=""
zoomMin="0" zoomMax="18"
tileSize="256"
format=".png"
/>
<source
name="Voliere" dir="VOLIERE"
addr=""
Expand Down
9 changes: 9 additions & 0 deletions src/widgets/map/map_items/aircraft_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ void AircraftItem::updateZValue() {
}
}

void AircraftItem::setVisible(bool visible) {
graphics_aircraft->setVisible(visible);
graphics_text->setVisible(visible);
alarms->setVisible(visible);
for(auto &line: graphics_lines) {
line->setVisible(visible);
}
}

void AircraftItem::setForbidHighlight(bool fh) {
graphics_aircraft->setForbidHighlight(fh);
}
Expand Down
1 change: 1 addition & 0 deletions src/widgets/map/map_items/aircraft_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AircraftItem : public MapItem

virtual void setHighlighted(bool h);
virtual void updateZValue();
virtual void setVisible(bool visible);
virtual void setForbidHighlight(bool fh);
virtual void setEditable(bool ed){(void)ed;}
virtual void removeFromScene(MapWidget* map);
Expand Down
4 changes: 4 additions & 0 deletions src/widgets/map/map_items/arrow_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ void ArrowItem::updateZValue() {
scene_item->setZValue(z_value);
}

void ArrowItem::setVisible(bool visible) {
scene_item->setVisible(visible);
}

void ArrowItem::setForbidHighlight(bool fh) {
(void)fh;
}
Expand Down
1 change: 1 addition & 0 deletions src/widgets/map/map_items/arrow_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ArrowItem : public MapItem

virtual void setHighlighted(bool h);
virtual void updateZValue();
virtual void setVisible(bool visible);
virtual void setForbidHighlight(bool fh);
virtual void setEditable(bool ed){(void)ed;}
virtual void removeFromScene(MapWidget* map);
Expand Down
8 changes: 8 additions & 0 deletions src/widgets/map/map_items/circle_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ void CircleItem::updateZValue() {
graphics_text->setZValue(z_value + 0.5);
}

void CircleItem::setVisible(bool visible) {
circle->setVisible(visible);
graphics_text->setVisible(visible);
if(ownCenter()) {
center->setVisible(visible);
}
}

void CircleItem::updateGraphics(MapWidget* map, uint32_t update_event) {
if(update_event & (UpdateEvent::ITEM_CHANGED | UpdateEvent::MAP_ZOOMED)) {
double s = getScale(map->zoom(), map->scaleFactor());
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/map/map_items/circle_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class CircleItem : public MapItem
WaypointItem* getCenter() { return center;}
GraphicsCircle* getGraphicsCircle() {return circle;}
void setOwnCenter(bool own) { if(own) {center->setParent(this);} }
bool ownCenter() {return center->parent() == this;}
void setScalable(bool scalable) {
circle->setIgnoreEvent(!scalable);
}
Expand All @@ -25,6 +26,7 @@ class CircleItem : public MapItem
void setForbidHighlight(bool fh);
virtual void setEditable(bool ed);
virtual void updateZValue();
virtual void setVisible(bool visible);
virtual void updateGraphics(MapWidget* map, uint32_t update_event);
virtual void removeFromScene(MapWidget* map);
void setText(QString text);
Expand Down
5 changes: 5 additions & 0 deletions src/widgets/map/map_items/intruder_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,8 @@ void IntruderItem::updateZValue() {
graphics_intruder->setZValue(z_value);
graphics_text->setZValue(z_value);
}

void IntruderItem::setVisible(bool visible) {
graphics_intruder->setVisible(visible);
graphics_text->setVisible(visible);
}
1 change: 1 addition & 0 deletions src/widgets/map/map_items/intruder_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class IntruderItem : public MapItem
virtual void setForbidHighlight(bool fh) override;
virtual void setEditable(bool ed) override;
virtual void updateZValue() override;
virtual void setVisible(bool visible) override;

void setPosition(Point2DLatLon pt);
void setCourse(double c);
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/map/map_items/map_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ MapItem::MapItem(QString ac_id, double neutral_scale_zoom, QObject *parent) :
QObject(parent),
ac_id(ac_id),
zoom_factor(1), neutral_scale_zoom(neutral_scale_zoom),
z_value(0)
z_value(0),
visible(true)
{
auto color = AircraftManager::get()->getAircraft(ac_id)->getColor();
this->palette = PprzPalette(color);
Expand All @@ -21,7 +22,8 @@ MapItem::MapItem(QString ac_id, PprzPalette palette, double neutral_scale_zoom,
QObject(parent),
ac_id(ac_id), palette(palette),
zoom_factor(1), neutral_scale_zoom(neutral_scale_zoom),
z_value(0)
z_value(0),
visible(true)
{
}

Expand Down
3 changes: 3 additions & 0 deletions src/widgets/map/map_items/map_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class MapItem : public QObject
double neutralScaleZoom() {return neutral_scale_zoom;}
void setZoomFactor(double zf) {zoom_factor = zf;}
virtual void updateZValue() = 0;
bool isVisible() {return visible;}
virtual void setVisible(bool visible) = 0;
qreal zValue() {return z_value;}
QString acId() {return ac_id;}
void requestUpdate() {emit itemChanged();}
Expand Down Expand Up @@ -75,6 +77,7 @@ class MapItem : public QObject
double neutral_scale_zoom;
qreal z_value;
bool highlighted;
bool visible;

qreal z_value_highlighted;
qreal z_value_unhighlighted;
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/map/map_items/quiver_item.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "quiver_item.h"
#include "gcs_utils.h"
#include "mapwidget.h"

Expand Down Expand Up @@ -132,4 +133,4 @@ void QuiverItem::updateZValue() {
// QPointF(-m_size * cos(angle), -m_size * sin(angle))
// });
// return arrow_poly;
// }
// }
4 changes: 2 additions & 2 deletions src/widgets/map/map_items/quiver_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class QuiverItem : public MapItem
virtual void updateZValue() override;
virtual void setEditable(bool ed) override;

void setVisible(bool vis);
virtual void setVisible(bool vis);
void addQuiver(Point2DLatLon pos, Point2DLatLon vpos);
void removeQuivers();

Expand All @@ -33,4 +33,4 @@ class QuiverItem : public MapItem
QList<double> distance_l;
};

#endif // QUIVERITEM_H
#endif // QUIVERITEM_H
5 changes: 5 additions & 0 deletions src/widgets/map/map_items/waypoint_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ void WaypointItem::updateZValue() {
graphics_text->setZValue(z_value);
}

void WaypointItem::setVisible(bool visible) {
point->setVisible(visible);
graphics_text->setVisible(visible);
}

void WaypointItem::updateGraphics(MapWidget* map, uint32_t update_event) {
if(update_event & (UpdateEvent::ITEM_CHANGED | UpdateEvent::MAP_ZOOMED | UpdateEvent::MAP_ROTATED)) {
QPointF scene_pos = scenePoint(Point2DLatLon(_waypoint), zoomLevel(map->zoom()), map->tileSize());
Expand Down
1 change: 1 addition & 0 deletions src/widgets/map/map_items/waypoint_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class WaypointItem : public MapItem
virtual void addToMap(MapWidget* map);
virtual void setHighlighted(bool h);
virtual void updateZValue();
virtual void setVisible(bool visible);
virtual void setForbidHighlight(bool fh);
virtual void setEditable(bool ed);
virtual void removeFromScene(MapWidget* map);
Expand Down

0 comments on commit c1ae3a0

Please sign in to comment.