From 653d0a1244b29175da97353796778ea3a34ff510 Mon Sep 17 00:00:00 2001 From: Russell Standish Date: Wed, 8 May 2024 12:54:51 +1000 Subject: [PATCH] Added pen labels to interactive marker. For ravel #512. Modulo arithmetic when acessing pen style incorrectly uses the fixed paletteSz rather than palette.size(). For ravel #553. --- include/plot.h | 7 +++++-- src/plot.cc | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/plot.h b/include/plot.h index 8cfc188..43c2019 100644 --- a/include/plot.h +++ b/include/plot.h @@ -224,8 +224,11 @@ namespace ecolab protected: // only protected because of TCL_obj problems /// default formatter suitable for plots of numeric data - static std::string defaultFormatter(double,double); - using Formatter=std::function; + /// @param label - pen label + /// @param x x coordinate of point to be labelled + /// @param y y coordinate of point to be labelled + static std::string defaultFormatter(const string& label,double x,double y); + using Formatter=std::function; /// if \a (x,y) within ([0,1],[0,1]), then paint a value box corresponding to closest curve /// @param tolerance - how close in user relative coordinates the mouse needs to be to a data point /// @param formatter - produce text label given (x,y) values diff --git a/src/plot.cc b/src/plot.cc index 0e41ef0..361375a 100644 --- a/src/plot.cc +++ b/src/plot.cc @@ -892,7 +892,7 @@ namespace ecolab for (size_t i=0; i::max(), yp=xp; double mind=std::numeric_limits::max(); + string penLabel; assert(x.size()==y.size()); for (size_t pen=0; pen