namespace trace {
const float Ruler::RulerHeight = 2.5f; // x Text Height
-const int Ruler::MinorTickSubdivision = 4;
const float Ruler::HoverArrowSize = 0.5f; // x Text Height
view_.ruler_offset(),
view_.scale(),
width(),
+ view_.minor_tick_count(),
ffunc);
}
const pv::util::Timestamp& offset,
const double scale,
const int width,
+ const unsigned int minor_tick_count,
function<QString(const pv::util::Timestamp&)> format_function)
{
TickPositions tp;
- const pv::util::Timestamp minor_period = major_period / MinorTickSubdivision;
+ const pv::util::Timestamp minor_period = major_period / minor_tick_count;
const pv::util::Timestamp first_major_division = floor(offset / major_period);
const pv::util::Timestamp first_minor_division = ceil(offset / minor_period);
const pv::util::Timestamp t0 = first_major_division * major_period;
int division = (round(first_minor_division -
- first_major_division * MinorTickSubdivision)).convert_to<int>() - 1;
+ first_major_division * minor_tick_count)).convert_to<int>() - 1;
double x;
pv::util::Timestamp t = t0 + division * minor_period;
x = ((t - offset) / scale).convert_to<double>();
- if (division % MinorTickSubdivision == 0) {
+ if (division % minor_tick_count == 0) {
// Recalculate 't' without using 'minor_period' which is a fraction
- t = t0 + division / MinorTickSubdivision * major_period;
+ t = t0 + division / minor_tick_count * major_period;
tp.major.emplace_back(x, format_function(t));
} else {
tp.minor.emplace_back(x);
/// Height of the ruler in multipes of the text height
static const float RulerHeight;
- static const int MinorTickSubdivision;
-
/// Height of the hover arrow in multiples of the text height
static const float HoverArrowSize;
const pv::util::Timestamp& offset,
const double scale,
const int width,
+ const unsigned int minor_tick_count,
function<QString(const pv::util::Timestamp&)> format_function);
protected:
return tick_period_;
}
+unsigned int View::minor_tick_count() const
+{
+ return minor_tick_count_;
+}
+
void View::set_tick_period(const pv::util::Timestamp& tick_period)
{
if (tick_period_ != tick_period) {
(ScaleUnits[unit++] + tp_margin);
} while (tp_with_margin < min_period && unit < countof(ScaleUnits));
+ minor_tick_count_ = (unit == 2) ? (4) : (5);
tick_period = order_decimal * ScaleUnits[unit - 1];
tick_prefix = static_cast<pv::util::SIPrefix>(
(order - pv::util::exponent(pv::util::SIPrefix::yocto)) / 3);
*/
const pv::util::Timestamp& tick_period() const;
+ /**
+ * Returns number of minor division ticks per time marking.
+ */
+ unsigned int minor_tick_count() const;
+
/**
* Returns the unit of time currently used.
*/
pv::util::Timestamp tick_period_;
pv::util::SIPrefix tick_prefix_;
+ unsigned int minor_tick_count_;
unsigned int tick_precision_;
util::TimeUnit time_unit_;