Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DSView/pv/mainframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ bool MainFrame::eventFilter(QObject *object, QEvent *event)
}

if (r != l){
SetFormRegion(l, t, r-l, b-t);
SetFormRegion(l, t, r-l+1, b-t+1);
#ifndef _WIN32
saveNormalRegion();
#endif
Expand Down
3 changes: 3 additions & 0 deletions DSView/pv/view/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Trace::Trace(QString name, uint16_t index, int type) :
_view(NULL),
_name(name),
_v_offset(INT_MAX),
_v_offset_orig(INT_MAX),
_type(type),
_sec_index(0),
_totalHeight(30),
Expand All @@ -66,6 +67,7 @@ Trace::Trace(QString name, std::list<int> index_list, int type, int sec_index) :
_view(NULL),
_name(name),
_v_offset(INT_MAX),
_v_offset_orig(INT_MAX),
_type(type),
_index_list(index_list),
_sec_index(sec_index),
Expand All @@ -80,6 +82,7 @@ Trace::Trace(const Trace &t) :
_name(t._name),
_colour(t._colour),
_v_offset(t._v_offset),
_v_offset_orig(INT_MAX),
_type(t._type),
_index_list(t._index_list),
_sec_index(t._sec_index),
Expand Down
11 changes: 10 additions & 1 deletion DSView/pv/view/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,15 @@ class Trace : public SelectableItem
* Sets the vertical layout offset of this signal.
*/
inline void set_v_offset(int v_offset){
_v_offset = v_offset;
_v_offset_orig = _v_offset = v_offset;
}

/**
* Sets the vertical scroll offset of this signal.
* (additional v_offset displacement)
*/
inline void update_v_scroll(int v_scroll) {
_v_offset = _v_offset_orig + v_scroll;
}

/**
Expand Down Expand Up @@ -336,6 +344,7 @@ private slots:
QString _name;
QColor _colour;
int _v_offset;
int _v_offset_orig;
int _type;
std::list<int> _index_list;
int _sec_index;
Expand Down
63 changes: 45 additions & 18 deletions DSView/pv/view/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ const int View::LabelMarginWidth = 70;
const int View::RulerHeight = 50;

const int View::MaxScrollValue = INT_MAX / 2;
const int View::MaxHeightUnit = 20;
const int View::HeightUnit = 20; // also serves as minimum signal height

//const int View::SignalHeight = 30;s
const int View::SignalMargin = 7;
const int View::SignalMargin = 3;
const int View::SignalSnapGridSize = 10;

const QColor View::CursorAreaColour(220, 231, 243);
Expand Down Expand Up @@ -107,6 +106,9 @@ View::View(SigSession *session, pv::toolbars::SamplingBar *sampling_bar, QWidget
_device_agent = session->get_device();

setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// setWidgetResizable(true);
// setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

// trace viewport map
_trace_view_map[SR_CHANNEL_LOGIC] = TIME_VIEW;
Expand Down Expand Up @@ -607,7 +609,7 @@ void View::update_scroll()
assert(_viewcenter);

int width = get_view_width();
if (width == 0){
if (width == 0) {
return;
}

Expand All @@ -632,11 +634,28 @@ void View::update_scroll()
_offset * 1.0 / length * MaxScrollValue);
}

_updating_scroll = false;
// Set up vertical scrollbar
std::vector<Trace*> traces;
get_traces(ALL_VIEW, traces);

// Calculate total required height for all traces
int total_height = 0;
for (auto t : traces) {
if (t->enabled())
total_height += t->get_totalHeight() + 2 * SignalMargin;
}

// Make sure we can scroll the last signal past the status bar
total_height += StatusHeight;

// Set the vertical scrollbar
verticalScrollBar()->setPageStep(areaSize.height());
verticalScrollBar()->setRange(0,0);
// Enable vertical scrolling if total height exceeds viewport
if (total_height > areaSize.height()) {
verticalScrollBar()->setRange(0, total_height - areaSize.height());
verticalScrollBar()->setPageStep(areaSize.height());
} else {
verticalScrollBar()->setRange(0, 0);
}
_updating_scroll = false;
}

void View::update_scale_offset()
Expand Down Expand Up @@ -678,7 +697,7 @@ void View::signals_changed(const Trace* eventTrace)
double actualMargin = SignalMargin;
int total_rows = 0;
int label_size = 0;
uint8_t max_height = MaxHeightUnit;
uint8_t max_height = HeightUnit;
std::vector<Trace*> time_traces;
std::vector<Trace*> fft_traces;
std::vector<Trace*> traces;
Expand Down Expand Up @@ -759,22 +778,21 @@ void View::signals_changed(const Trace* eventTrace)

ret = _device_agent->get_config_byte(SR_CONF_MAX_HEIGHT_VALUE, v);
if (ret) {
max_height = (v + 1) * MaxHeightUnit;
max_height = (v + 1) * HeightUnit;
}

if (height < 2*actualMargin) {
actualMargin /= 2;
_signalHeight = max(1.0, (_time_viewport->height()
//actualMargin /= 2;
_signalHeight = max((double)HeightUnit, (_time_viewport->height()
- 2 * actualMargin * label_size) * 1.0 / total_rows);
}
else {
_signalHeight = (height >= max_height) ? max_height : height;
_signalHeight = max((double)HeightUnit, (height >= max_height) ? max_height : height);
}
}
else if (_device_agent->get_work_mode() == DSO) {
_signalHeight = (_header->height()
_signalHeight = max((double)HeightUnit, (_header->height()
- horizontalScrollBar()->height()
- 2 * actualMargin * label_size) * 1.0 / total_rows;
- 2 * actualMargin * label_size) * 1.0 / total_rows);
}
else {
_signalHeight = (int)((height <= 0) ? 1 : height);
Expand Down Expand Up @@ -967,8 +985,17 @@ void View::h_scroll_value_changed(int value)

void View::v_scroll_value_changed(int value)
{
(void)value;
_header->update();
// Update vertical positions of all traces based on scroll value
std::vector<Trace*> traces;
get_traces(ALL_VIEW, traces);

for (auto t : traces) {
if (t->enabled()) {
t->update_v_scroll(-value);
}
}

_header->update();
viewport_update();
}

Expand Down
2 changes: 1 addition & 1 deletion DSView/pv/view/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class View : public QScrollArea, public IUiWindow
static const int RulerHeight;

static const int MaxScrollValue;
static const int MaxHeightUnit;
static const int HeightUnit;

public:
//static const int SignalHeight;
Expand Down