Go to the documentation of this file.
10 #ifndef LINKGRAPH_GUI_H
11 #define LINKGRAPH_GUI_H
13 #include "../company_func.h"
14 #include "../station_base.h"
15 #include "../widget_type.h"
16 #include "../window_gui.h"
45 typedef std::map<StationID, LinkProperties> StationLinkMap;
46 typedef std::map<StationID, StationLinkMap> LinkMap;
47 typedef std::vector<std::pair<StationID, uint> > StationSupplyList;
67 bool ShowTooltip(
Point pt, TooltipCloseCondition close_cond);
100 static void DrawVertex(
int x,
int y,
int size,
int colour,
int border_colour);
115 bool OnTooltip(
Point pt,
int widget, TooltipCloseCondition close_cond)
override;
116 void OnClick(
Point pt,
int widget,
int click_count)
override;
uint32 company_mask
Bitmask of companies to be displayed.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
LinkGraphOverlay(Window *w, uint wid, CargoTypes cargo_mask, uint32 company_mask, uint scale)
Create a link graph overlay for the specified window.
Menu window to select cargoes and companies to show in a link graph overlay.
Dimensions (a width and height) of a rectangle in 2D.
CargoID cargo
Cargo type of the link.
void UpdateOverlayCompanies()
Update the overlay with the new company selection.
void RebuildCache()
Rebuild the cache and recalculate which links and stations to be shown.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Invalidate the data of this window if the cargoes or companies have changed.
bool OnTooltip(Point pt, int widget, TooltipCloseCondition close_cond) override
Event to display a custom tooltip.
CargoTypes GetCargoMask()
Get a bitmask of the currently shown cargoes.
void UpdateOverlayCargoes()
Update the overlay with the new cargo selection.
void SetCompanyMask(uint32 company_mask)
Set a new company mask and rebuild the cache.
Window * window
Window to be drawn into.
uint32 time
Travel time of the link.
High level window description.
LinkMap cached_links
Cache for links to reduce recalculation.
StationSupplyList cached_stations
Cache for stations to be drawn.
Handles drawing of links into some window.
static const uint8 LINK_COLOURS[][12]
Colours for the various "load" states of links.
ResizeInfo resize
Resize information.
void SetCargoMask(CargoTypes cargo_mask)
Set a new cargo mask and rebuild the cache.
void AddLinks(const Station *sta, const Station *stb)
Add all "interesting" links between the given stations to the cache.
void SetOverlay(LinkGraphOverlay *overlay)
Set the overlay belonging to this menu and import its company/cargo settings.
bool IsLinkVisible(Point pta, Point ptb, const DrawPixelInfo *dpi, int padding=0) const
Determine if a certain link crosses through the area given by the dpi with some lee way.
uint capacity
Capacity of the link.
Coordinates of a point in 2D.
WindowNumber window_number
Window number within the window class.
uint scale
Width of link lines.
bool dirty
Set if overlay should be rebuilt.
void DrawStationDots(const DrawPixelInfo *dpi) const
Draw dots for stations into the smallmap.
uint planned
Planned usage of the link.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void Draw(const DrawPixelInfo *dpi)
Draw the linkgraph overlay or some part of it, in the area given.
Point GetStationMiddle(const Station *st) const
Determine the middle of a station in the current window.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
bool IsPointVisible(Point pt, const DrawPixelInfo *dpi, int padding=0) const
Determine if a certain point is inside the given DPI, with some lee way.
static void AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_flow, uint32 time, bool new_shared, LinkProperties &cargo)
Add information from a given pair of link stat and flow stat to the given link properties.
uint usage
Actual usage of the link.
bool shared
If this is a shared link to be drawn dashed.
void GetWidgetDpi(DrawPixelInfo *dpi) const
Get a DPI for the widget we will be drawing to.
CargoTypes cargo_mask
Bitmask of cargos to be displayed.
void SetDirty()
Mark the linkgraph dirty to be rebuilt next time Draw() is called.
byte CargoID
Cargo slots to indicate a cargo type within a game.
uint32 GetCompanyMask()
Get a bitmask of the currently shown companies.
void DrawContent(Point pta, Point ptb, const LinkProperties &cargo) const
Draw one specific link.
const uint widget_id
ID of Widget in Window to be drawn to.
Data structure for an opened window.
void DrawLinks(const DrawPixelInfo *dpi) const
Draw the cached links or part of them into the given area.
@ CT_INVALID
Invalid cargo type.
Specification of a rectangle with absolute coordinates of all edges.
static void DrawVertex(int x, int y, int size, int colour, int border_colour)
Draw a square symbolizing a producer of cargo.
uint Usage() const
Return the usage of the link to display.
void ShowLinkGraphLegend()
Open a link graph legend window.
Data about how and where to blit pixels.
Monthly statistics for a link between two stations.