PulseView  0.3.0
A Qt-based sigrok GUI
pv::view::Ruler Class Reference

#include <ruler.hpp>

Inheritance diagram for pv::view::Ruler:
Collaboration diagram for pv::view::Ruler:

Classes

struct  TickPositions
 

Public Member Functions

 Ruler (View &parent)
 
QSize sizeHint () const
 
QSize extended_size_hint () const
 
- Public Member Functions inherited from pv::view::MarginWidget
 MarginWidget (pv::view::View &parent)
 

Static Public Member Functions

static QString format_time_with_distance (const pv::util::Timestamp &distance, const pv::util::Timestamp &t, pv::util::SIPrefix prefix=pv::util::SIPrefix::unspecified, pv::util::TimeUnit unit=pv::util::TimeUnit::Time, unsigned precision=0, bool sign=true)
 

Protected Member Functions

void resizeEvent (QResizeEvent *) override
 
- Protected Member Functions inherited from pv::view::MarginWidget
virtual void item_clicked (const std::shared_ptr< pv::view::ViewItem > &item)
 
void show_popup (const std::shared_ptr< ViewItem > &item)
 
virtual void contextMenuEvent (QContextMenuEvent *event)
 
virtual void keyPressEvent (QKeyEvent *e)
 
- Protected Member Functions inherited from pv::view::ViewWidget
 ViewWidget (View &parent)
 
virtual void item_hover (const std::shared_ptr< pv::view::ViewItem > &item)
 
bool accept_drag () const
 
bool mouse_down () const
 
void drag_items (const QPoint &delta)
 
virtual void drag ()
 
virtual void drag_by (const QPoint &delta)
 
virtual void drag_release ()
 
void mouse_left_press_event (QMouseEvent *event)
 
void mouse_left_release_event (QMouseEvent *event)
 
virtual bool touch_event (QTouchEvent *e)
 
bool event (QEvent *event)
 
void mousePressEvent (QMouseEvent *event)
 
void mouseReleaseEvent (QMouseEvent *event)
 
void mouseMoveEvent (QMouseEvent *event)
 
void leaveEvent (QEvent *event)
 

Private Slots

void hover_point_changed ()
 
void invalidate_tick_position_cache ()
 

Private Member Functions

std::vector< std::shared_ptr< pv::view::ViewItem > > items ()
 
std::shared_ptr< pv::view::ViewItemget_mouse_over_item (const QPoint &pt)
 
void paintEvent (QPaintEvent *event)
 
void mouseDoubleClickEvent (QMouseEvent *e)
 
void draw_hover_mark (QPainter &p, int text_height)
 
int calculate_text_height () const
 

Static Private Member Functions

static TickPositions calculate_tick_positions (const pv::util::Timestamp &major_period, const pv::util::Timestamp &offset, const double scale, const int width, std::function< QString(const pv::util::Timestamp &)> format_function)
 

Private Attributes

boost::optional< TickPositionstick_position_cache_
 

Static Private Attributes

static const float RulerHeight = 2.5f
 Height of the ruler in multipes of the text height. More...
 
static const int MinorTickSubdivision = 4
 
static const float HoverArrowSize = 0.5f
 Height of the hover arrow in multiples of the text height. More...
 

Friends

class RulerTest::tick_position_test_0
 
class RulerTest::tick_position_test_1
 
class RulerTest::tick_position_test_2
 

Additional Inherited Members

- Public Slots inherited from pv::view::ViewWidget
void clear_selection ()
 
- Signals inherited from pv::view::ViewWidget
void selection_changed ()
 
- Protected Attributes inherited from pv::view::ViewWidget
pv::view::Viewview_
 
QPoint mouse_point_
 
QPoint mouse_down_point_
 
std::shared_ptr< ViewItemmouse_down_item_
 
bool item_dragging_
 

Detailed Description

Definition at line 44 of file ruler.hpp.


Class Documentation

struct pv::view::Ruler::TickPositions

Definition at line 136 of file ruler.hpp.

Collaboration diagram for pv::view::Ruler::TickPositions:
Class Members
vector< pair< double, QString > > major
vector< double > minor

Constructor & Destructor Documentation

pv::view::Ruler::Ruler ( View parent)

Definition at line 43 of file ruler.cpp.

Here is the call graph for this function:

Member Function Documentation

int pv::view::Ruler::calculate_text_height ( ) const
private

Definition at line 253 of file ruler.cpp.

Here is the caller graph for this function:

Ruler::TickPositions pv::view::Ruler::calculate_tick_positions ( const pv::util::Timestamp major_period,
const pv::util::Timestamp offset,
const double  scale,
const int  width,
std::function< QString(const pv::util::Timestamp &)>  format_function 
)
staticprivate

Calculates the major and minor tick positions.

Parameters
major_periodThe period between the major ticks.
offsetThe time at the left border of the ruler.
scaleThe scale in seconds per pixel.
widththe Width of the ruler.
format_functionA function used to format the major tick times.
Returns
An object of type 'TickPositions' that contains the major tick positions together with the labels at that ticks, and the minor tick positions.

Definition at line 191 of file ruler.cpp.

Here is the caller graph for this function:

void pv::view::Ruler::draw_hover_mark ( QPainter &  p,
int  text_height 
)
private

Draw a hover arrow under the cursor position.

Parameters
pThe painter to draw into.
text_heightThe height of a single text ascent.

Definition at line 233 of file ruler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QSize pv::view::Ruler::extended_size_hint ( ) const
virtual

The extended area that the header widget would like to be sized to.

Remarks
This area is the area specified by sizeHint, extended by the area to overlap the viewport.

Implements pv::view::MarginWidget.

Definition at line 70 of file ruler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

QString pv::view::Ruler::format_time_with_distance ( const pv::util::Timestamp distance,
const pv::util::Timestamp t,
pv::util::SIPrefix  prefix = pv::util::SIPrefix::unspecified,
pv::util::TimeUnit  unit = pv::util::TimeUnit::Time,
unsigned  precision = 0,
bool  sign = true 
)
static

Formats a timestamp depending on its distance to another timestamp.

Heuristic function, useful when multiple timestamps should be put side by side. The function procedes in the following order:

Parameters
distanceThe distance between the timestamp to format and an adjacent one.
tThe value to format
prefixThe SI prefix to use.
unitThe representation of the timestamp value.
precisionThe number of digits after the decimal separator.
signWhether or not to add a sign also for positive numbers.
Returns
The formated value.

Definition at line 80 of file ruler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

shared_ptr< ViewItem > pv::view::Ruler::get_mouse_over_item ( const QPoint &  pt)
privatevirtual

Gets the first view item which has a label that contains pt .

Parameters
ptthe point to search with.
Returns
the view item that has been found, or and empty shared_ptr if no item was found.

Implements pv::view::ViewWidget.

Definition at line 119 of file ruler.cpp.

Here is the call graph for this function:

void pv::view::Ruler::hover_point_changed ( )
privateslot

Definition at line 258 of file ruler.cpp.

Here is the caller graph for this function:

void pv::view::Ruler::invalidate_tick_position_cache ( )
privateslot

Definition at line 263 of file ruler.cpp.

Here is the caller graph for this function:

vector< shared_ptr< ViewItem > > pv::view::Ruler::items ( )
privatevirtual

Gets the time items.

Implements pv::view::ViewWidget.

Definition at line 112 of file ruler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void pv::view::Ruler::mouseDoubleClickEvent ( QMouseEvent *  e)
private

Definition at line 228 of file ruler.cpp.

Here is the call graph for this function:

void pv::view::Ruler::paintEvent ( QPaintEvent *  event)
private

Definition at line 128 of file ruler.cpp.

Here is the call graph for this function:

void pv::view::Ruler::resizeEvent ( QResizeEvent *  )
overrideprotected

Definition at line 268 of file ruler.cpp.

Here is the call graph for this function:

QSize pv::view::Ruler::sizeHint ( ) const

Definition at line 64 of file ruler.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class RulerTest::tick_position_test_0
friend

Definition at line 48 of file ruler.hpp.

friend class RulerTest::tick_position_test_1
friend

Definition at line 49 of file ruler.hpp.

friend class RulerTest::tick_position_test_2
friend

Definition at line 50 of file ruler.hpp.

Member Data Documentation

const float pv::view::Ruler::HoverArrowSize = 0.5f
staticprivate

Height of the hover arrow in multiples of the text height.

Definition at line 60 of file ruler.hpp.

const int pv::view::Ruler::MinorTickSubdivision = 4
staticprivate

Definition at line 57 of file ruler.hpp.

const float pv::view::Ruler::RulerHeight = 2.5f
staticprivate

Height of the ruler in multipes of the text height.

Definition at line 55 of file ruler.hpp.

boost::optional<TickPositions> pv::view::Ruler::tick_position_cache_
private

Holds the tick positions so that they don't have to be recalculated on every redraw. Set by 'paintEvent()' when needed.

Definition at line 146 of file ruler.hpp.


The documentation for this class was generated from the following files: