Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
009ea8c816 | ||
|
|
79f864c4aa | ||
|
|
b25cc5f29d | ||
|
|
0001a8a702 | ||
|
|
621978d1d6 | ||
|
|
bfdf025c37 | ||
|
|
329e81bf86 | ||
|
|
19b6447eaf | ||
|
|
7befa142a6 | ||
|
|
97c2c4d3bb | ||
|
|
1086a98e7b | ||
|
|
a76a7f221d | ||
|
|
3291fa0867 |
No files matched your search
@@ -390,6 +390,12 @@ or **💾 Save As…** from the sidebar.
|
||||
|
||||
## 🖼️ Screenshots 🖼️
|
||||
|
||||
### Single BSSID
|
||||
<p align="center">
|
||||
<img src="extras/example_export.png" alt="An image of the wifi heatmap generator heatmap export">
|
||||
</p>
|
||||
|
||||
### Single BSSID w/AP
|
||||
<p align="center">
|
||||
<img src="extras/example_export_with_ap.png" alt="An image of the wifi heatmap generator heatmap export with access point">
|
||||
</p>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 458 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 157 KiB |
+4
-4
@@ -7,8 +7,8 @@ VSVersionInfo(
|
||||
ffi=FixedFileInfo(
|
||||
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
|
||||
# Set not needed items to zero 0. Must always contain 4 elements.
|
||||
filevers=(2026,5,3,0),
|
||||
prodvers=(2026,5,3,0),
|
||||
filevers=(2026,5,5,0),
|
||||
prodvers=(2026,5,5,0),
|
||||
# Contains a bitmask that specifies the valid bits 'flags'r
|
||||
mask=0x3f,
|
||||
# Contains a bitmask that specifies the Boolean attributes of the file.
|
||||
@@ -32,12 +32,12 @@ VSVersionInfo(
|
||||
u'040904B0',
|
||||
[StringStruct(u'CompanyName', u''),
|
||||
StringStruct(u'FileDescription', u'pyFi: WiFi Heatmap Generator'),
|
||||
StringStruct(u'FileVersion', u'2026.5.3.0'),
|
||||
StringStruct(u'FileVersion', u'2026.5.5.0'),
|
||||
StringStruct(u'InternalName', u'pyFi'),
|
||||
StringStruct(u'LegalCopyright', u'© iamdoubz'),
|
||||
StringStruct(u'OriginalFilename', u'pyFi.exe'),
|
||||
StringStruct(u'ProductName', u'pyFi'),
|
||||
StringStruct(u'ProductVersion', u'2026.5.3.0')])
|
||||
StringStruct(u'ProductVersion', u'2026.5.5.0')])
|
||||
]),
|
||||
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
|
||||
]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
main.py — WiFi Heatmap Generator GUI
|
||||
main.py — pyFi WiFi Heatmap Generator GUI
|
||||
Cross-platform tkinter application for collecting and visualizing WiFi signal data.
|
||||
|
||||
Usage:
|
||||
@@ -14,6 +14,7 @@ import tkinter as tk
|
||||
from tkinter import ttk, filedialog, messagebox
|
||||
import threading
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import time
|
||||
from dataclasses import dataclass, field
|
||||
@@ -30,6 +31,19 @@ from data import Session, Measurement
|
||||
from renderer import render_heatmap, SIGNAL_CMAP
|
||||
|
||||
|
||||
def _resource_path(relative_path: str) -> str:
|
||||
"""
|
||||
Resolve a path to a bundled resource at runtime.
|
||||
|
||||
PyInstaller extracts bundled files to a temporary folder at runtime and
|
||||
sets sys._MEIPASS to that folder's path. When running from source,
|
||||
the directory containing main.py is used instead — so both the compiled
|
||||
binary and plain `python main.py` resolve assets correctly.
|
||||
"""
|
||||
base = getattr(sys, "_MEIPASS", os.path.dirname(os.path.abspath(__file__)))
|
||||
return os.path.join(base, relative_path)
|
||||
|
||||
|
||||
# ── Palette ───────────────────────────────────────────────────────────────────
|
||||
BG = "#0d0d1a"
|
||||
BG2 = "#131325"
|
||||
@@ -109,7 +123,7 @@ AP_COLUMNS = [
|
||||
class WiFiHeatmapApp:
|
||||
def __init__(self, root: tk.Tk, initial_session: Optional[str] = None):
|
||||
self.root = root
|
||||
self.root.title("WiFi Heatmap Generator")
|
||||
self.root.title("pyFi")
|
||||
self.root.configure(bg=BG)
|
||||
self.root.minsize(1200, 720)
|
||||
|
||||
@@ -183,9 +197,21 @@ class WiFiHeatmapApp:
|
||||
def _build_sidebar(self):
|
||||
f = self.sidebar
|
||||
|
||||
tk.Label(f, text="📡", font=("Segoe UI Emoji", 28), bg=BG2, fg=ACCENT).pack(pady=(20, 4))
|
||||
tk.Label(f, text="WiFi Heatmap", font=("Georgia", 13, "bold"), bg=BG2, fg=TEXT).pack()
|
||||
tk.Label(f, text="Generator", font=("Georgia", 11), bg=BG2, fg=TEXT_DIM).pack(pady=(0, 16))
|
||||
# Logo image — load pyfi-mini.png, fall back to emoji if file is missing
|
||||
try:
|
||||
_logo_img = tk.PhotoImage(file=_resource_path(
|
||||
os.path.join("extras", "pyfi-mini.png")))
|
||||
# Use a single divisor for both axes to preserve aspect ratio.
|
||||
# Target ~64px on the longest side.
|
||||
_divisor = max(1, max(_logo_img.width(), _logo_img.height()) // 92)
|
||||
_logo_img = _logo_img.subsample(_divisor, _divisor)
|
||||
tk.Label(f, image=_logo_img, bg=BG2).pack(pady=(20, 4))
|
||||
f._logo_img_ref = _logo_img # prevent garbage collection
|
||||
except Exception:
|
||||
tk.Label(f, text="📡", font=("Segoe UI Emoji", 28), bg=BG2, fg=ACCENT).pack(pady=(20, 4))
|
||||
|
||||
tk.Label(f, text="WiFi", font=("Georgia", 13, "bold"), bg=BG2, fg=TEXT).pack()
|
||||
tk.Label(f, text="Heatmap Generator", font=("Georgia", 10), bg=BG2, fg=TEXT_DIM).pack(pady=(0, 16))
|
||||
|
||||
ttk.Separator(f, orient="horizontal").pack(fill="x", padx=12, pady=4)
|
||||
|
||||
@@ -1330,16 +1356,23 @@ class WiFiHeatmapApp:
|
||||
# ── Entry point ───────────────────────────────────────────────────────────────
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="WiFi Heatmap Generator")
|
||||
parser = argparse.ArgumentParser(description="pyFi — WiFi Heatmap Generator")
|
||||
parser.add_argument("--session", help="Path to a .json session file to load on startup")
|
||||
args = parser.parse_args()
|
||||
|
||||
root = tk.Tk()
|
||||
root.title("WiFi Heatmap Generator")
|
||||
root.title("pyFi")
|
||||
|
||||
# Set taskbar / window icon
|
||||
_icon_path = _resource_path(os.path.join("extras", "pyfi-logo.ico"))
|
||||
try:
|
||||
root.iconbitmap(default="")
|
||||
root.iconbitmap(default=_icon_path)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
_icon_img = tk.PhotoImage(file=_icon_path)
|
||||
root.iconphoto(True, _icon_img)
|
||||
except Exception:
|
||||
pass # icon is cosmetic — silently skip if unavailable
|
||||
|
||||
WiFiHeatmapApp(root, initial_session=args.session)
|
||||
root.protocol("WM_DELETE_WINDOW", lambda: (root.destroy()))
|
||||
|
||||
+88
-175
@@ -15,6 +15,8 @@ Ekahau-style rendering:
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.colors as mcolors
|
||||
import matplotlib.patches as mpatches
|
||||
import matplotlib.path as mpath
|
||||
from matplotlib.figure import Figure
|
||||
from matplotlib.axes import Axes
|
||||
from matplotlib.patches import Circle
|
||||
@@ -28,8 +30,6 @@ from interpolator import interpolate, HeatmapData
|
||||
|
||||
# ── Colormaps ─────────────────────────────────────────────────────────────────
|
||||
|
||||
# Ekahau-style: red (excellent) → orange → yellow → green → teal → blue → violet (poor)
|
||||
# This is the reverse of our old colormap — strong signal is warm, weak is cool.
|
||||
_EKAHAU_COLORS = [
|
||||
(0.45, 0.00, 0.55), # -90 dBm violet / purple
|
||||
(0.10, 0.10, 0.80), # -80 dBm blue
|
||||
@@ -42,11 +42,6 @@ _EKAHAU_COLORS = [
|
||||
]
|
||||
SIGNAL_CMAP = mcolors.LinearSegmentedColormap.from_list("ekahau", _EKAHAU_COLORS)
|
||||
|
||||
# Separate single-color black cmap used only for the "no signal" dot markers
|
||||
_BLACK_CMAP = mcolors.LinearSegmentedColormap.from_list("black_only",
|
||||
[(0,0,0), (0,0,0)])
|
||||
|
||||
# dBm range the colormap spans
|
||||
VMIN, VMAX = -90, -30
|
||||
|
||||
|
||||
@@ -70,20 +65,7 @@ def render_heatmap(
|
||||
|
||||
If any selected BSSIDs have physical positions set in session.ap_positions,
|
||||
synthetic anchor points are injected into the interpolation so the heatmap
|
||||
peak is correctly located at the real transmitter position. AP positions
|
||||
are shown as distinct diamond icons, visually separate from measurement dots.
|
||||
|
||||
Args:
|
||||
session: The data session with measurements.
|
||||
bssids: List of BSSIDs. Multiple BSSIDs are averaged per point.
|
||||
fig/ax: Existing figure/axes (creates new if None).
|
||||
alpha: Maximum opacity of the heatmap overlay (default 0.85).
|
||||
show_points: Draw measurement dot markers and AP position icons.
|
||||
show_colorbar: Draw the dBm color scale.
|
||||
export_path: If set, save figure to this path.
|
||||
|
||||
Returns:
|
||||
(figure, axes, heatmap_data)
|
||||
peak is correctly located at the real transmitter position.
|
||||
"""
|
||||
if not bssids:
|
||||
raise ValueError("At least one BSSID must be provided.")
|
||||
@@ -97,13 +79,11 @@ def render_heatmap(
|
||||
ax_obj.remove()
|
||||
ax.clear()
|
||||
|
||||
points, values = session.get_points_and_values_multi(bssids)
|
||||
missing_points = session.get_missing_points(bssids)
|
||||
points, values = session.get_points_and_values_multi(bssids)
|
||||
missing_points = session.get_missing_points(bssids)
|
||||
anchor_pts, anchor_vals = session.get_anchor_points(bssids)
|
||||
w, h = session.canvas_width, session.canvas_height
|
||||
w, h = session.canvas_width, session.canvas_height
|
||||
|
||||
# Merge anchor points into the interpolation input when available.
|
||||
# Anchors are synthetic — they don't appear as measurement dots.
|
||||
interp_points = points + anchor_pts
|
||||
interp_values = values + anchor_vals
|
||||
|
||||
@@ -139,15 +119,7 @@ def render_heatmap(
|
||||
if len(interp_points) >= MIN_POINTS:
|
||||
heatmap_data = interpolate(interp_points, interp_values, w, h)
|
||||
grid = heatmap_data.grid_z
|
||||
|
||||
rgba = _build_ekahau_rgba(grid, alpha)
|
||||
|
||||
_sm = ax.imshow(
|
||||
grid,
|
||||
extent=[0, w, 0, h], origin='upper',
|
||||
cmap=SIGNAL_CMAP, vmin=VMIN, vmax=VMAX,
|
||||
alpha=0, zorder=0, aspect='auto'
|
||||
)
|
||||
rgba = _build_ekahau_rgba(grid, alpha)
|
||||
|
||||
ax.imshow(
|
||||
rgba,
|
||||
@@ -156,20 +128,7 @@ def render_heatmap(
|
||||
)
|
||||
|
||||
if show_colorbar:
|
||||
cax = fig.add_axes([0.91, 0.15, 0.02, 0.70])
|
||||
cbar = fig.colorbar(_sm, cax=cax)
|
||||
cbar.set_label("Signal Strength (dBm)", fontsize=10)
|
||||
cbar.ax.tick_params(labelsize=8)
|
||||
cbar.ax.text(1.4, VMIN, "Poor",
|
||||
transform=cbar.ax.get_yaxis_transform(),
|
||||
fontsize=7, color='gray', va='bottom')
|
||||
cbar.ax.text(1.4, VMAX, "Excellent",
|
||||
transform=cbar.ax.get_yaxis_transform(),
|
||||
fontsize=7, color='gray', va='top')
|
||||
cbar.ax.text(1.4, VMIN - 5, "No signal",
|
||||
transform=cbar.ax.get_yaxis_transform(),
|
||||
fontsize=7, color='black', va='top',
|
||||
bbox=dict(facecolor='white', edgecolor='none', pad=1.5))
|
||||
_draw_colorbar(fig)
|
||||
|
||||
else:
|
||||
collected = len(interp_points)
|
||||
@@ -188,10 +147,9 @@ def render_heatmap(
|
||||
# ── Measurement dots ──────────────────────────────────────────────────────
|
||||
radius = max(w, h) * 0.012
|
||||
if show_points:
|
||||
# Valid signal measurement points — filled circles
|
||||
for (px, py), dbm in zip(points, values):
|
||||
norm_val = (dbm - VMIN) / (VMAX - VMIN)
|
||||
color = SIGNAL_CMAP(norm_val)
|
||||
color = SIGNAL_CMAP(np.clip(norm_val, 0.0, 1.0))
|
||||
ax.add_patch(Circle((px, py), radius=radius,
|
||||
facecolor=color, edgecolor='white',
|
||||
linewidth=1.5, zorder=5, alpha=0.95))
|
||||
@@ -199,7 +157,6 @@ def render_heatmap(
|
||||
ha='center', va='bottom', fontsize=7,
|
||||
color='white', fontweight='bold', zorder=6)
|
||||
|
||||
# Out-of-range measurement points — black circles with "?"
|
||||
for (px, py) in missing_points:
|
||||
ax.add_patch(Circle((px, py), radius=radius,
|
||||
facecolor='black', edgecolor='white',
|
||||
@@ -208,7 +165,6 @@ def render_heatmap(
|
||||
ha='center', va='center', fontsize=7,
|
||||
color='white', fontweight='bold', zorder=6)
|
||||
|
||||
# AP position markers — drawn last so they sit on top of everything
|
||||
_draw_ap_markers(ax, session, bssids, radius)
|
||||
|
||||
# ── Labels & axes ─────────────────────────────────────────────────────────
|
||||
@@ -218,8 +174,9 @@ def render_heatmap(
|
||||
point_note += f" • {len(missing_points)} out of range (●)"
|
||||
if len(bssids) > 1:
|
||||
point_note += f" • avg of {len(bssids)} BSSIDs"
|
||||
if anchor_pts:
|
||||
point_note += f" • {len(anchor_pts)} AP position{'s' if len(anchor_pts) != 1 else ''} pinned (◆)"
|
||||
n_pinned = sum(1 for b in bssids if b in session.ap_positions)
|
||||
if n_pinned:
|
||||
point_note += f" • {n_pinned} AP position{'s' if n_pinned != 1 else ''} pinned (◆)"
|
||||
if not session.floorplan_path:
|
||||
point_note += " ⚠ No floorplan — adding one increases accuracy"
|
||||
|
||||
@@ -238,46 +195,80 @@ def render_heatmap(
|
||||
return fig, ax, heatmap_data
|
||||
|
||||
|
||||
# ── Colorbar ──────────────────────────────────────────────────────────────────
|
||||
|
||||
def _draw_colorbar(fig: Figure):
|
||||
"""
|
||||
Draw the signal strength colorbar by rendering the colormap gradient
|
||||
directly as an imshow onto a dedicated axes.
|
||||
|
||||
This approach is backend-agnostic and guaranteed to show color — it does
|
||||
not rely on fig.colorbar() interpreting a ScalarMappable, which can silently
|
||||
render white on some matplotlib/backend combinations.
|
||||
"""
|
||||
cax = fig.add_axes([0.91, 0.15, 0.025, 0.70])
|
||||
|
||||
# Build the gradient image: 256 rows (dBm steps) × 1 column, RGBA
|
||||
gradient = np.linspace(1.0, 0.0, 256).reshape(256, 1) # top=VMAX, bottom=VMIN
|
||||
cax.imshow(gradient, aspect='auto', cmap=SIGNAL_CMAP,
|
||||
extent=[0, 1, VMIN, VMAX], origin='upper')
|
||||
|
||||
# Style the axes
|
||||
cax.yaxis.set_label_position('right')
|
||||
cax.yaxis.tick_right()
|
||||
cax.set_ylabel("Signal Strength (dBm)", fontsize=9, color='white', labelpad=8)
|
||||
cax.tick_params(axis='y', labelsize=7, colors='white', length=3)
|
||||
cax.tick_params(axis='x', which='both', bottom=False, labelbottom=False)
|
||||
cax.set_xlim(0, 1)
|
||||
cax.set_ylim(VMIN, VMAX)
|
||||
|
||||
# Spine styling
|
||||
for spine in cax.spines.values():
|
||||
spine.set_edgecolor('#444444')
|
||||
|
||||
# Qualitative labels
|
||||
cax.text(1.6, VMAX, "Excellent", transform=cax.get_yaxis_transform(),
|
||||
fontsize=7, color='#cccccc', va='top')
|
||||
cax.text(1.6, VMIN, "Poor", transform=cax.get_yaxis_transform(),
|
||||
fontsize=7, color='#cccccc', va='bottom')
|
||||
|
||||
# "No signal" swatch below the bar
|
||||
cax.text(0.5, VMIN - 3, "No signal",
|
||||
transform=cax.get_yaxis_transform(),
|
||||
fontsize=6, color='white', va='top', ha='center',
|
||||
bbox=dict(facecolor='black', edgecolor='#444444',
|
||||
pad=2.0, boxstyle='round'))
|
||||
|
||||
|
||||
# ── RGBA builder ──────────────────────────────────────────────────────────────
|
||||
|
||||
def _build_ekahau_rgba(grid: np.ndarray, max_alpha: float) -> np.ndarray:
|
||||
"""
|
||||
Convert a dBm grid into an RGBA uint8 image with Ekahau-style rendering.
|
||||
|
||||
Alpha channel logic:
|
||||
Alpha channel:
|
||||
- Signal ≥ VMAX (-30 dBm) → fully opaque (max_alpha)
|
||||
- Signal ≤ FADE_FLOOR → fully transparent
|
||||
- Between → smooth cosine ramp so zone edges blend
|
||||
naturally without a hard cutoff
|
||||
- Between → cosine ramp for natural bubble-edge blending
|
||||
|
||||
A Gaussian blur is applied to the alpha channel before compositing so
|
||||
overlapping coverage zones blend smoothly rather than showing sharp
|
||||
interpolation triangle edges.
|
||||
Gaussian blur on alpha blends overlapping AP coverage zones smoothly.
|
||||
"""
|
||||
FADE_FLOOR = -85.0 # dBm at which the overlay becomes fully transparent
|
||||
BLUR_SIGMA = 8.0 # pixels — controls softness of zone edges
|
||||
FADE_FLOOR = -85.0
|
||||
BLUR_SIGMA = 8.0
|
||||
|
||||
res_h, res_w = grid.shape
|
||||
|
||||
# ── RGB from colormap ─────────────────────────────────────────────────────
|
||||
norm = np.clip((grid - VMIN) / (VMAX - VMIN), 0.0, 1.0)
|
||||
rgb_float = SIGNAL_CMAP(norm)[:, :, :3] # (H, W, 3) float 0-1
|
||||
rgb_float = SIGNAL_CMAP(norm)[:, :, :3]
|
||||
|
||||
# ── Alpha from signal strength ────────────────────────────────────────────
|
||||
# Use a cosine ramp so the transition from opaque to transparent is smooth
|
||||
# rather than linear (cosine gives a more natural "bubble" appearance).
|
||||
fade_range = VMAX - FADE_FLOOR
|
||||
t = np.clip((grid - FADE_FLOOR) / fade_range, 0.0, 1.0)
|
||||
alpha_raw = 0.5 * (1.0 - np.cos(np.pi * t)) # cosine ease-in-out
|
||||
|
||||
# NaN cells (outside interpolation hull) → transparent
|
||||
alpha_raw = 0.5 * (1.0 - np.cos(np.pi * t))
|
||||
alpha_raw[np.isnan(grid)] = 0.0
|
||||
|
||||
# Gaussian blur softens zone boundaries and blends overlapping AP zones
|
||||
alpha_blur = gaussian_filter(alpha_raw, sigma=BLUR_SIGMA)
|
||||
alpha_blur = np.clip(alpha_blur * max_alpha, 0.0, max_alpha)
|
||||
|
||||
# ── Assemble RGBA uint8 ───────────────────────────────────────────────────
|
||||
rgba = np.zeros((res_h, res_w, 4), dtype=np.uint8)
|
||||
rgba[:, :, 0] = (rgb_float[:, :, 0] * 255).astype(np.uint8)
|
||||
rgba[:, :, 1] = (rgb_float[:, :, 1] * 255).astype(np.uint8)
|
||||
@@ -287,72 +278,6 @@ def _build_ekahau_rgba(grid: np.ndarray, max_alpha: float) -> np.ndarray:
|
||||
return rgba
|
||||
|
||||
|
||||
# ── AP position markers ───────────────────────────────────────────────────────
|
||||
|
||||
def _draw_ap_markers(ax: Axes, session: Session, bssids: list[str], radius: float):
|
||||
"""
|
||||
Draw a distinct diamond icon at each AP's known physical position.
|
||||
|
||||
Visual design (clearly different from measurement dots):
|
||||
- Outer diamond: white filled, black border — highly visible on any background
|
||||
- Inner WiFi arc symbol: drawn in the AP's signal color
|
||||
- SSID label below the icon
|
||||
- Small "◆" glyph instead of a dBm number so it's never confused with
|
||||
a measurement dot
|
||||
|
||||
Only BSSIDs in `bssids` that also have an entry in session.ap_positions
|
||||
are drawn.
|
||||
"""
|
||||
import matplotlib.patches as mpatches
|
||||
import matplotlib.path as mpath
|
||||
|
||||
icon_r = radius * 1.6 # diamond half-size — larger than measurement dots
|
||||
label_r = radius * 2.8 # label offset below center
|
||||
|
||||
for bssid in bssids:
|
||||
if bssid not in session.ap_positions:
|
||||
continue
|
||||
px, py = session.ap_positions[bssid]
|
||||
ssid = session.get_ssid(bssid)
|
||||
|
||||
# ── Diamond shape (rotated square) via Path ───────────────────────────
|
||||
diamond_verts = [
|
||||
(px, py - icon_r), # top
|
||||
(px + icon_r, py ), # right
|
||||
(px, py + icon_r), # bottom
|
||||
(px - icon_r, py ), # left
|
||||
(px, py - icon_r), # close
|
||||
]
|
||||
diamond_codes = [
|
||||
mpath.Path.MOVETO,
|
||||
mpath.Path.LINETO,
|
||||
mpath.Path.LINETO,
|
||||
mpath.Path.LINETO,
|
||||
mpath.Path.CLOSEPOLY,
|
||||
]
|
||||
diamond_path = mpath.Path(diamond_verts, diamond_codes)
|
||||
diamond_patch = mpatches.PathPatch(
|
||||
diamond_path,
|
||||
facecolor='white', edgecolor='#111111',
|
||||
linewidth=2.0, zorder=8, alpha=0.95
|
||||
)
|
||||
ax.add_patch(diamond_patch)
|
||||
|
||||
# ── WiFi arc symbol (three concentric arcs, bottom-left origin) ───────
|
||||
# Drawn as text using the Unicode WiFi / signal character
|
||||
ax.text(px, py, "📶",
|
||||
ha='center', va='center',
|
||||
fontsize=max(6, int(icon_r * 0.55)),
|
||||
zorder=9, alpha=0.85)
|
||||
|
||||
# ── SSID label below the diamond ──────────────────────────────────────
|
||||
ax.text(px, py + label_r, ssid,
|
||||
ha='center', va='top', fontsize=7,
|
||||
color='white', fontweight='bold', zorder=9,
|
||||
bbox=dict(boxstyle='round,pad=0.2',
|
||||
facecolor='#111111', edgecolor='none', alpha=0.7))
|
||||
|
||||
|
||||
# ── AP position markers ───────────────────────────────────────────────────────
|
||||
|
||||
def _draw_ap_markers(ax: Axes, session: Session, bssids: list[str], radius: float):
|
||||
@@ -360,67 +285,54 @@ def _draw_ap_markers(ax: Axes, session: Session, bssids: list[str], radius: floa
|
||||
Draw a distinct diamond ◆ icon at each AP whose physical position is known.
|
||||
|
||||
Visual design (intentionally different from measurement circles):
|
||||
- Outer diamond: white-filled rotated square, larger than measurement dots
|
||||
- Inner diamond: signal-colored fill
|
||||
- WiFi arc lines above the diamond
|
||||
- SSID label beneath
|
||||
- Thin pulse ring to make them easy to spot on a busy floorplan
|
||||
|
||||
These markers are purely informational — they are not measurement points
|
||||
and do not affect the interpolation directly (the anchor injection in
|
||||
render_heatmap() handles that separately).
|
||||
- Outer dashed pulse ring
|
||||
- White-bordered diamond
|
||||
- Signal-colored inner diamond
|
||||
- Three WiFi arc lines above
|
||||
- SSID label below
|
||||
"""
|
||||
import matplotlib.patches as mpatches
|
||||
import matplotlib.transforms as mtransforms
|
||||
|
||||
for bssid in bssids:
|
||||
if bssid not in session.ap_positions:
|
||||
continue
|
||||
|
||||
px, py = session.ap_positions[bssid]
|
||||
ssid = session.get_ssid(bssid)
|
||||
r = radius * 1.6 # diamond is larger than measurement dots
|
||||
px, py = session.ap_positions[bssid]
|
||||
ssid = session.get_ssid(bssid)
|
||||
r = radius * 1.6
|
||||
|
||||
# ── Outer pulse ring ─────────────────────────────────────────────────
|
||||
# Pulse ring
|
||||
ax.add_patch(Circle((px, py), radius=r * 1.9,
|
||||
facecolor='none', edgecolor='white',
|
||||
linewidth=0.8, zorder=7, alpha=0.35,
|
||||
linestyle='--'))
|
||||
|
||||
# ── White border diamond ──────────────────────────────────────────────
|
||||
diamond_outer = mpatches.RegularPolygon(
|
||||
# Outer white diamond
|
||||
ax.add_patch(mpatches.RegularPolygon(
|
||||
(px, py), numVertices=4, radius=r * 1.15,
|
||||
orientation=np.pi / 4, # rotate 45° → diamond orientation
|
||||
orientation=np.pi / 4,
|
||||
facecolor='white', edgecolor='white',
|
||||
linewidth=0, zorder=8, alpha=0.95)
|
||||
ax.add_patch(diamond_outer)
|
||||
linewidth=0, zorder=8, alpha=0.95))
|
||||
|
||||
# ── Coloured inner diamond ────────────────────────────────────────────
|
||||
# Use the anchor dBm value for the color
|
||||
# Signal-colored inner diamond
|
||||
real_pts, real_vals = session.get_points_and_values(bssid)
|
||||
anchor_dbm = min(-25, max(real_vals) + 5) if real_vals else -35
|
||||
norm_val = np.clip((anchor_dbm - VMIN) / (VMAX - VMIN), 0.0, 1.0)
|
||||
color = SIGNAL_CMAP(norm_val)
|
||||
|
||||
diamond_inner = mpatches.RegularPolygon(
|
||||
ax.add_patch(mpatches.RegularPolygon(
|
||||
(px, py), numVertices=4, radius=r * 0.80,
|
||||
orientation=np.pi / 4,
|
||||
facecolor=color, edgecolor='none',
|
||||
zorder=9, alpha=0.95)
|
||||
ax.add_patch(diamond_inner)
|
||||
zorder=9, alpha=0.95))
|
||||
|
||||
# ── WiFi arcs above the diamond ───────────────────────────────────────
|
||||
# Three concentric arcs drawn as partial circles
|
||||
# WiFi arcs
|
||||
for arc_r, arc_alpha in [(r * 0.55, 0.9), (r * 0.9, 0.65), (r * 1.25, 0.40)]:
|
||||
arc = mpatches.Arc(
|
||||
(px, py - r * 0.15), # slightly above centre
|
||||
ax.add_patch(mpatches.Arc(
|
||||
(px, py - r * 0.15),
|
||||
width=arc_r * 2, height=arc_r * 2,
|
||||
angle=0, theta1=30, theta2=150, # upper semicircle arc
|
||||
angle=0, theta1=30, theta2=150,
|
||||
color='white', linewidth=1.4,
|
||||
zorder=10, alpha=arc_alpha)
|
||||
ax.add_patch(arc)
|
||||
zorder=10, alpha=arc_alpha))
|
||||
|
||||
# ── SSID label below the marker ───────────────────────────────────────
|
||||
# SSID label
|
||||
ax.text(px, py + r * 2.2, ssid,
|
||||
ha='center', va='top', fontsize=7,
|
||||
color='white', fontweight='bold', zorder=10,
|
||||
@@ -428,12 +340,13 @@ def _draw_ap_markers(ax: Axes, session: Session, bssids: list[str], radius: floa
|
||||
facecolor='#000000', alpha=0.55,
|
||||
edgecolor='none'))
|
||||
|
||||
# ── ◆ glyph as a tiny anchor indicator ───────────────────────────────
|
||||
# Centre glyph
|
||||
ax.text(px, py, '◆',
|
||||
ha='center', va='center', fontsize=6,
|
||||
color='white', zorder=11, alpha=0.7)
|
||||
|
||||
|
||||
# ── Grid background ───────────────────────────────────────────────────────────
|
||||
|
||||
def _draw_grid_background(ax: Axes, w: int, h: int):
|
||||
"""Draw a subtle coordinate grid when no floorplan is loaded."""
|
||||
|
||||
Reference in new issue
Block a user