From d876c9ed7cdb03c0cbc56ed2c8eab8d7a741860f Mon Sep 17 00:00:00 2001 From: Steven Lovegrove Date: Wed, 28 Jun 2017 10:35:13 -0700 Subject: [PATCH] Plotter: Tick sub-sampling changes (thanks Jakob) --- src/plot/plotter.cpp | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/plot/plotter.cpp b/src/plot/plotter.cpp index f0040081f..ea2b93fc1 100644 --- a/src/plot/plotter.cpp +++ b/src/plot/plotter.cpp @@ -426,9 +426,31 @@ void Plotter::Render() prog_lines.SetUniform("u_color", colour_tk ); const float min_space = 80.0; - int ta[2] = {1,1}; - while(v.w != 0 && v.w * ta[0] *tick[0].val / w < min_space) ta[0] *=2; - while(v.h != 0 && v.h * ta[1] *tick[1].val / h < min_space) ta[1] *=2; + float ta[2] = {1,1}; + + + while(true) + { + if(v.w * ta[0] *tick[0].val / w < min_space) + ta[0] *=2; + if(v.w * ta[0] *tick[0].val / w < min_space) + ta[0] =(5*ta[0])/2; + if(v.w * ta[0] *tick[0].val / w < min_space) + ta[0] *=2; + else + break; + } + while(true) + { + if(v.h * ta[1] *tick[1].val / h < min_space) + ta[1] *=2; + if(v.h * ta[1] *tick[1].val / h < min_space) + ta[1] =(5*ta[1])/2; + if(v.h * ta[1] *tick[1].val / h < min_space) + ta[1] *=2; + else + break; + } const float tdelta[2] = { tick[0].val * ta[0],