24{
25 TickOutputs majorOutputs{
26 allOutputs.majorLabels, allOutputs.bits, allOutputs.box };
27
29 const int mLength = context.
mLength;
30
31 const int mLeft = context.
mLeft;
32 const int mTop = context.
mTop;
33 const int mBottom = context.
mBottom;
34 const int mRight = context.
mRight;
36
37 const double mMin = context.
mMin;
38 const double mMax = context.
mMax;
41
44
45
46
47
48
49 double UPP = (mHiddenMax - mHiddenMin) / mLength;
50 TickSizes tickSizes{ UPP, mOrientation, context.
mpRulerFormat,
false };
51
52 auto TickAtValue =
53 [this, &tickSizes, &dc, &majorOutputs, &mFonts, mOrientation,
54 mMin, mMax, mLength, mRight, mBottom, &context]
55 (double value) -> int {
56
58 return -1;
59 if (value > std::max(mMin, mMax))
60 return -1;
61
62 int mid;
64
65 if (value)
66 return -1;
68 }
69 else
70 mid = (int)(mLength * ((mMin - value) / (mMin - mMax)) + 0.5);
71
72 const int iMaxPos = (mOrientation == wxHORIZONTAL) ? mRight : mBottom - 5;
73 if (mid >= 0 && mid < iMaxPos)
74 Tick(dc, mid, value, tickSizes, mFonts.
major, majorOutputs, context);
75 else
76 return -1;
77
78 return mid;
79 };
80
81 if (mDbMirrorValue) {
82
83
84
85
86 TickAtValue(-mDbMirrorValue);
87
88
89 TickAtValue(0.0);
90
91
92 TickAtValue(-2 * mDbMirrorValue);
93 }
94
95 if (!mDbMirrorValue) {
96
97 TickAtValue(0.0);
98 }
99
100 double sign = UPP > 0.0 ? 1.0 : -1.0;
101
102 int nDroppedMinorLabels = 0;
103
104 for (int jj = 0; jj < 3; ++jj) {
105 const double denom = jj == 0 ? tickSizes.mMajor :
106 jj == 1 ? tickSizes.mMinor : tickSizes.mMinorMinor;
109 if (denom == 0) continue;
110 auto font = jj == 0 ? mFonts.
major :
112 TickOutputs outputs{
113 (jj == 0 ? allOutputs.majorLabels :
114 jj == 1 ? allOutputs.minorLabels : allOutputs.minorMinorLabels),
115 allOutputs.bits, allOutputs.box
116 };
117 int ii = -1, j = 0;
118 double d, warpedD, nextD;
119
120 double prevTime = 0.0, time = 0.0;
125 d = (prevTime + time) / 2.0;
126 }
127 else
128 d = mMin - UPP / 2;
129 if (envelope)
131 else
132 warpedD = d;
133
134
135 double step = floor(sign * warpedD / denom);
136 while (ii <= mLength) {
137 ii++;
139 {
140 prevTime = time;
142 nextD = (prevTime + time) / 2.0;
143
144 }
145 else
146 nextD = d + UPP;
147 if (envelope)
149 else
150 warpedD = nextD;
151 d = nextD;
152
153 if (floor(sign * warpedD / denom) > step) {
154 step = floor(sign * warpedD / denom);
155 bool ticked =
Tick(dc, ii, sign * step * denom, tickSizes,
156 font, outputs, context);
157 bool major = jj == 0;
158 if (!major && !ticked) {
159 nDroppedMinorLabels++;
160 }
161 }
162 }
163 }
164
166
167
168
169
170
171
172
173 if (nDroppedMinorLabels >
174 (allOutputs.majorLabels.size() + (mLabelEdges ? 2 : 0))
176
177
178
179 for (
auto&
label : allOutputs.minorLabels) {
182 }
183 for (
auto&
label : allOutputs.minorMinorLabels) {
186 }
187 }
188
189
190 if (mLabelEdges) {
191 Tick(dc, 0, mMin, tickSizes, mFonts.
major, majorOutputs, context);
192 Tick(dc, mLength, mMax, tickSizes, mFonts.
major, majorOutputs, context);
193 }
194
196}
double ComputeWarpedLength(const Envelope &env, double t0, double t1) const
bool Tick(wxDC &dc, int pos, double d, const TickSizes &tickSizes, wxFont font, TickOutputs outputs, const RulerStruct &context) const
void BoxAdjust(UpdateOutputs &allOutputs, const RulerStruct &context) const
double PositionToTime(int64 position, int64 origin=0, bool ignoreFisheye=false) const
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
std::unique_ptr< Fonts > mpFonts
const RulerFormat * mpRulerFormat