MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / Locator_Default

Function Locator_Default

Source/3rdParty/implot/implot.cpp:760–798  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

758constexpr float TICK_FILL_Y = 1.0f;
759
760void Locator_Default(ImPlotTicker& ticker, const ImPlotRange& range, float pixels, bool vertical, ImPlotFormatter formatter, void* formatter_data) {
761 if (range.Min == range.Max)
762 return;
763 const int nMinor = 10;
764 const int nMajor = ImMax(2, (int)IM_ROUND(pixels / (vertical ? 300.0f : 400.0f)));
765 const double nice_range = NiceNum(range.Size() * 0.99, false);
766 const double interval = NiceNum(nice_range / (nMajor - 1), true);
767 const double graphmin = floor(range.Min / interval) * interval;
768 const double graphmax = ceil(range.Max / interval) * interval;
769 bool first_major_set = false;
770 int first_major_idx = 0;
771 const int idx0 = ticker.TickCount(); // ticker may have user custom ticks
772 ImVec2 total_size(0,0);
773 for (double major = graphmin; major < graphmax + 0.5 * interval; major += interval) {
774 // is this zero? combat zero formatting issues
775 if (major-interval < 0 && major+interval > 0)
776 major = 0;
777 if (range.Contains(major)) {
778 if (!first_major_set) {
779 first_major_idx = ticker.TickCount();
780 first_major_set = true;
781 }
782 total_size += ticker.AddTick(major, true, 0, true, formatter, formatter_data).LabelSize;
783 }
784 for (int i = 1; i < nMinor; ++i) {
785 double minor = major + i * interval / nMinor;
786 if (range.Contains(minor)) {
787 total_size += ticker.AddTick(minor, false, 0, true, formatter, formatter_data).LabelSize;
788 }
789 }
790 }
791 // prune if necessary
792 if ((!vertical && total_size.x > pixels*TICK_FILL_X) || (vertical && total_size.y > pixels*TICK_FILL_Y)) {
793 for (int i = first_major_idx-1; i >= idx0; i -= 2)
794 ticker.Ticks[i].ShowLabel = false;
795 for (int i = first_major_idx+1; i < ticker.TickCount(); i += 2)
796 ticker.Ticks[i].ShowLabel = false;
797 }
798}
799
800bool CalcLogarithmicExponents(const ImPlotRange& range, float pix, bool vertical, int& exp_min, int& exp_max, int& exp_step) {
801 if (range.Min * range.Max > 0) {

Callers 2

Locator_SymLogFunction · 0.85
ColormapScaleFunction · 0.85

Calls 7

ImMaxFunction · 0.85
NiceNumFunction · 0.85
TickCountMethod · 0.80
SizeMethod · 0.65
floorFunction · 0.50
ceilFunction · 0.50
ContainsMethod · 0.45

Tested by

no test coverage detected