summaryrefslogtreecommitdiff
path: root/include/glamac_view.h
diff options
context:
space:
mode:
authoradmin <admin@optics-design.com>2025-08-05 10:11:14 +0200
committeradmin <admin@optics-design.com>2025-08-05 10:11:14 +0200
commit9496ae0a50e6848121c7e913ca2dc55c8e6c84c1 (patch)
tree0a8705a31233bc07710950e653d1f55e7155f78a /include/glamac_view.h
parentb59995f9732720e8c82e22f44c0c8cb3efe2c708 (diff)
rewrote clustering
Diffstat (limited to 'include/glamac_view.h')
-rw-r--r--include/glamac_view.h66
1 files changed, 57 insertions, 9 deletions
diff --git a/include/glamac_view.h b/include/glamac_view.h
index 9eec63a..6ca4b9b 100644
--- a/include/glamac_view.h
+++ b/include/glamac_view.h
@@ -20,14 +20,45 @@
#define LABEL_OFFSET_Y -8 // Vertical offset from glass point (pixels)
#define LABEL_SIZE_SCALE 1.4f // Scale factor for glass name labels
-// Glass clustering for nearly identical glasses
-#define MAX_CLUSTER_SIZE 8
+// Tight clustering parameters
+#define MAX_CLUSTER_SIZE 8 // Maximum glasses per cluster
+#define DEFAULT_TIGHT_CLUSTER_ND_THRESHOLD 0.0005f // Default nd difference threshold
+#define DEFAULT_TIGHT_CLUSTER_VD_THRESHOLD 0.15f // Default vd difference threshold
+
+// Loose clustering parameters (zoom-dependent)
+#define DEFAULT_LOOSE_CLUSTER_ND_THRESHOLD 0.3f // Default nd base threshold
+#define DEFAULT_LOOSE_CLUSTER_VD_THRESHOLD 0.55f // Default vd base threshold
+#define DEFAULT_LOOSE_CLUSTER_ND_FRACTION 4.9f // Default nd fraction of visible range
+#define DEFAULT_LOOSE_CLUSTER_VD_FRACTION 0.9f // Default vd fraction of visible range
+
+// Global tight cluster thresholds (adjustable parameters)
+extern f32 g_tight_cluster_nd_threshold;
+extern f32 g_tight_cluster_vd_threshold;
+
+// Global loose cluster parameters (adjustable parameters)
+extern f32 g_loose_cluster_nd_threshold; // Base threshold
+extern f32 g_loose_cluster_vd_threshold; // Base threshold
+extern f32 g_loose_cluster_nd_fraction; // Zoom scaling fraction
+extern f32 g_loose_cluster_vd_fraction; // Zoom scaling fraction
+
+// Tight cluster structure
typedef struct {
i32 glassIndices[MAX_CLUSTER_SIZE]; // Indices of glasses in this cluster
i32 count; // Number of glasses in cluster
- f32 avgAbbeNumber; // Average position for rendering
+ i32 representativeIndex; // Index of glass with shortest name
+ f32 avgAbbeNumber; // Average position for reference
f32 avgRefractiveIndex;
-} GlassCluster;
+} TightCluster;
+
+// Loose cluster structure (zoom-dependent)
+typedef struct {
+ i32 glassIndices[MAX_CLUSTER_SIZE]; // Indices of glasses in this cluster
+ i32 count; // Number of glasses in cluster
+ i32 representativeIndex; // Index of glass with shortest name
+ f32 avgAbbeNumber; // Average position for reference
+ f32 avgRefractiveIndex;
+} LooseCluster;
+
// State for zooming and panning
typedef struct {
@@ -44,7 +75,15 @@ typedef struct {
b32 gKeyPressed; // Flag to track if 'g' was pressed
u32 gKeyTime; // Time when 'g' was pressed for sequence timing
i32 selectedGlass; // Index of selected glass (-1 if none)
- i32 selectedCluster; // Index of selected cluster (-1 if none)
+ i32 selectedCluster; // Index of selected tight cluster (-1 if none)
+
+ // Tight cluster data (per catalog)
+ TightCluster* tightClusters; // Array of tight clusters for current catalog
+ i32 tightClusterCount; // Number of tight clusters
+
+ // Loose cluster data (per catalog, zoom-dependent)
+ LooseCluster* looseClusters; // Array of loose clusters for current catalog
+ i32 looseClusterCount; // Number of loose clusters
// Label recalculation tracking
f32 lastZoomLevel; // Last zoom level for which labels were calculated
@@ -119,9 +158,18 @@ void toggle_fullscreen(SDL_Window* window);
// Reset view to default
void reset_view(ViewState* view);
-// Glass clustering functions
-GlassCluster* create_glass_clusters(i32* clusterCount);
-void free_glass_clusters(GlassCluster* clusters);
-i32 find_cluster_at_position(GlassCluster* clusters, i32 clusterCount, i32 x, i32 y, const ViewState* view);
+// Tight clustering functions
+void create_tight_clusters(ViewState* view);
+void free_tight_clusters(ViewState* view);
+i32 find_tight_cluster_for_glass(i32 glassIndex, const ViewState* view);
+
+// Loose clustering functions (zoom-dependent)
+void create_loose_clusters(ViewState* view);
+void free_loose_clusters(ViewState* view);
+i32 find_loose_cluster_for_glass(i32 glassIndex, const ViewState* view);
+
+// Combined clustering logic
+b32 should_show_glass_label(i32 glassIndex, const ViewState* view);
+
#endif /* GLAMAC_VIEW_H */
Back to https://optics-design.com