mirror of git://sigrok.org/pulseview
Change the number of minor ticks to be either 4 or 5
Depends on the current tick interval size, in the sense of the 1, 2, 5 sequence. It was originally always 4.
This commit is contained in:
parent
ffc00fdd59
commit
4a07615736
|
@ -37,7 +37,6 @@ namespace views {
|
|||
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
|
||||
|
||||
|
@ -143,6 +142,7 @@ void Ruler::paintEvent(QPaintEvent*)
|
|||
view_.ruler_offset(),
|
||||
view_.scale(),
|
||||
width(),
|
||||
view_.minor_tick_count(),
|
||||
ffunc);
|
||||
}
|
||||
|
||||
|
@ -194,17 +194,18 @@ Ruler::TickPositions Ruler::calculate_tick_positions(
|
|||
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;
|
||||
|
||||
|
@ -212,9 +213,9 @@ Ruler::TickPositions Ruler::calculate_tick_positions(
|
|||
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);
|
||||
|
|
|
@ -63,8 +63,6 @@ private:
|
|||
/// 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;
|
||||
|
||||
|
@ -170,6 +168,7 @@ private:
|
|||
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:
|
||||
|
|
|
@ -506,6 +506,11 @@ const pv::util::Timestamp& View::tick_period() const
|
|||
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) {
|
||||
|
@ -896,6 +901,7 @@ void View::calculate_tick_spacing()
|
|||
(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);
|
||||
|
|
|
@ -187,6 +187,11 @@ public:
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -479,6 +484,7 @@ private:
|
|||
|
||||
pv::util::Timestamp tick_period_;
|
||||
pv::util::SIPrefix tick_prefix_;
|
||||
unsigned int minor_tick_count_;
|
||||
unsigned int tick_precision_;
|
||||
util::TimeUnit time_unit_;
|
||||
|
||||
|
|
Loading…
Reference in New Issue