forked from Ivasoft/DSView
v0.4 release
This commit is contained in:
@@ -24,8 +24,14 @@
|
||||
#include "header.h"
|
||||
#include "view.h"
|
||||
|
||||
#include "signal.h"
|
||||
#include "trace.h"
|
||||
#include "dsosignal.h"
|
||||
#include "logicsignal.h"
|
||||
#include "analogsignal.h"
|
||||
#include "groupsignal.h"
|
||||
#include "decodetrace.h"
|
||||
#include "../sigsession.h"
|
||||
#include "../device/devinst.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -70,8 +76,8 @@ Header::Header(View &parent) :
|
||||
connect(nameEdit, SIGNAL(editingFinished()),
|
||||
this, SLOT(on_action_set_name_triggered()));
|
||||
|
||||
connect(&_view, SIGNAL(signals_moved()),
|
||||
this, SLOT(on_signals_moved()));
|
||||
connect(&_view, SIGNAL(traces_moved()),
|
||||
this, SLOT(on_traces_moved()));
|
||||
}
|
||||
|
||||
|
||||
@@ -83,30 +89,28 @@ int Header::get_nameEditWidth()
|
||||
return 0;
|
||||
}
|
||||
|
||||
boost::shared_ptr<pv::view::Signal> Header::get_mSig(
|
||||
boost::shared_ptr<pv::view::Trace> Header::get_mTrace(
|
||||
int &action,
|
||||
const QPoint &pt)
|
||||
{
|
||||
const int w = width();
|
||||
const vector< boost::shared_ptr<Signal> > sigs(
|
||||
_view.session().get_signals());
|
||||
const vector< boost::shared_ptr<Trace> > traces(
|
||||
_view.get_traces());
|
||||
|
||||
const int v_offset = _view.v_offset();
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
{
|
||||
assert(s);
|
||||
assert(t);
|
||||
|
||||
if ((action = s->pt_in_rect(s->get_v_offset() - v_offset - _view.get_signalHeight() / 2,
|
||||
w, pt)))
|
||||
return s;
|
||||
if ((action = t->pt_in_rect(t->get_y(), w, pt)))
|
||||
return t;
|
||||
}
|
||||
|
||||
return boost::shared_ptr<Signal>();
|
||||
return boost::shared_ptr<Trace>();
|
||||
}
|
||||
|
||||
void Header::paintEvent(QPaintEvent*)
|
||||
{
|
||||
using pv::view::Signal;
|
||||
using pv::view::Trace;
|
||||
|
||||
QStyleOption o;
|
||||
o.initFrom(this);
|
||||
@@ -114,47 +118,22 @@ void Header::paintEvent(QPaintEvent*)
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &o, &painter, this);
|
||||
|
||||
const int w = width();
|
||||
int action;
|
||||
const vector< boost::shared_ptr<Signal> > sigs(
|
||||
_view.session().get_signals());
|
||||
int action = 0;
|
||||
const vector< boost::shared_ptr<Trace> > traces(
|
||||
_view.get_traces());
|
||||
|
||||
//QPainter painter(this);
|
||||
//painter.setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
const int v_offset = _view.v_offset();
|
||||
const bool dragging = !_drag_sigs.empty();
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
|
||||
const bool dragging = !_drag_traces.empty();
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
{
|
||||
assert(s);
|
||||
assert(t);
|
||||
|
||||
const int y = s->get_v_offset() - v_offset - _view.get_signalHeight() / 2;
|
||||
const int y = t->get_y();
|
||||
const bool highlight = !dragging &&
|
||||
(action = s->pt_in_rect(y, w, _mouse_point));
|
||||
s->paint_label(painter, y, w, highlight, action);
|
||||
// Paint the Backgroud
|
||||
painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
painter.setPen(Signal::dsGray);
|
||||
if (s->selected() && _moveFlag) {
|
||||
if (s->get_type() == Signal::DS_ANALOG) {
|
||||
painter.drawLine(0, s->get_old_v_offset() - v_offset - s->get_signalHeight(),
|
||||
w, s->get_old_v_offset() - v_offset - s->get_signalHeight());
|
||||
painter.drawLine(0, s->get_old_v_offset() - v_offset,
|
||||
w, s->get_old_v_offset() - v_offset);
|
||||
} else if (s->get_type() == Signal::DS_LOGIC){
|
||||
painter.drawLine(0, s->get_old_v_offset() - v_offset + 10,
|
||||
w, s->get_old_v_offset() - v_offset + 10);
|
||||
}
|
||||
} else {
|
||||
if (s->get_type() == Signal::DS_ANALOG) {
|
||||
painter.drawLine(0, s->get_v_offset() - v_offset,
|
||||
w, s->get_v_offset() - v_offset);
|
||||
painter.drawLine(0, s->get_v_offset() - v_offset - s->get_signalHeight(),
|
||||
w, s->get_v_offset() - v_offset - s->get_signalHeight());
|
||||
} else if (s->get_type() == Signal::DS_LOGIC) {
|
||||
painter.drawLine(0, s->get_v_offset() - v_offset + 10,
|
||||
w, s->get_v_offset() - v_offset + 10);
|
||||
}
|
||||
}
|
||||
(action = t->pt_in_rect(y, w, _mouse_point));
|
||||
t->paint_label(painter, w, highlight, action);
|
||||
}
|
||||
|
||||
painter.end();
|
||||
@@ -164,126 +143,116 @@ void Header::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
assert(event);
|
||||
|
||||
const vector< boost::shared_ptr<Signal> > sigs(
|
||||
_view.session().get_signals());
|
||||
const vector< boost::shared_ptr<Trace> > traces(
|
||||
_view.get_traces());
|
||||
int action;
|
||||
|
||||
if (event->button() & Qt::LeftButton) {
|
||||
_mouse_down_point = event->pos();
|
||||
|
||||
// Save the offsets of any signals which will be dragged
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
|
||||
if (s->selected())
|
||||
_drag_sigs.push_back(
|
||||
make_pair(s, s->get_v_offset()));
|
||||
// Save the offsets of any Traces which will be dragged
|
||||
BOOST_FOREACH(const boost::shared_ptr<Trace> t, traces)
|
||||
if (t->selected())
|
||||
_drag_traces.push_back(
|
||||
make_pair(t, t->get_v_offset()));
|
||||
|
||||
// Select the signal if it has been clicked
|
||||
const boost::shared_ptr<Signal> mSig =
|
||||
get_mSig(action, event->pos());
|
||||
if (action == Signal::COLOR && mSig) {
|
||||
// Select the Trace if it has been clicked
|
||||
const boost::shared_ptr<Trace> mTrace =
|
||||
get_mTrace(action, event->pos());
|
||||
if (action == Trace::COLOR && mTrace) {
|
||||
_colorFlag = true;
|
||||
} else if (action == Signal::NAME && mSig) {
|
||||
} else if (action == Trace::NAME && mTrace) {
|
||||
_nameFlag = true;
|
||||
} else if (action == Signal::LABEL && mSig) {
|
||||
if (mSig->selected())
|
||||
mSig->select(false);
|
||||
} else if (action == Trace::LABEL && mTrace) {
|
||||
if (mTrace->selected())
|
||||
mTrace->select(false);
|
||||
else {
|
||||
if (mSig->get_type() != Signal::DS_DSO)
|
||||
mSig->select(true);
|
||||
if (mTrace->get_type() != Trace::DS_DSO)
|
||||
mTrace->select(true);
|
||||
|
||||
if (~QApplication::keyboardModifiers() &
|
||||
Qt::ControlModifier)
|
||||
_drag_sigs.clear();
|
||||
_drag_traces.clear();
|
||||
|
||||
// Add the signal to the drag list
|
||||
if (event->button() & Qt::LeftButton)
|
||||
_drag_sigs.push_back(
|
||||
make_pair(mSig,
|
||||
(mSig->get_type() == Signal::DS_DSO) ? mSig->get_zeroPos() : mSig->get_v_offset()));
|
||||
}
|
||||
mSig->set_old_v_offset(mSig->get_v_offset());
|
||||
} else if (action == Signal::POSTRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::POSTRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mSig->set_trig(Signal::POSTRIG);
|
||||
} else if (action == Signal::HIGTRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::HIGTRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mSig->set_trig(Signal::HIGTRIG);
|
||||
} else if (action == Signal::NEGTRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::NEGTRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mSig->set_trig(Signal::NEGTRIG);
|
||||
} else if (action == Signal::LOWTRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::LOWTRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mSig->set_trig(Signal::LOWTRIG);
|
||||
} else if (action == Signal::EDGETRIG && mSig) {
|
||||
if (mSig->get_trig() == Signal::EDGETRIG)
|
||||
mSig->set_trig(0);
|
||||
else
|
||||
mSig->set_trig(Signal::EDGETRIG);
|
||||
} else if (action == Signal::VDIAL && mSig) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
s->set_hDialActive(false);
|
||||
if (s != mSig) {
|
||||
s->set_vDialActive(false);
|
||||
// Add the Trace to the drag list
|
||||
if (event->button() & Qt::LeftButton) {
|
||||
_drag_traces.push_back(make_pair(mTrace, mTrace->get_zeroPos()));
|
||||
}
|
||||
}
|
||||
mSig->set_vDialActive(!mSig->get_vDialActive());
|
||||
} else if (action == Signal::HDIAL && mSig) {
|
||||
if (mSig->get_hDialActive()) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
s->set_vDialActive(false);
|
||||
s->set_hDialActive(false);
|
||||
}
|
||||
} else {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
s->set_vDialActive(false);
|
||||
s->set_hDialActive(true);
|
||||
}
|
||||
}
|
||||
} else if (action == Signal::CHEN && mSig) {
|
||||
int channel;
|
||||
if (mSig->get_index() == 0) {
|
||||
bool last = 1;
|
||||
channel = 0;
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
if (s->get_index() != 0 && s->get_active()) {
|
||||
QMessageBox msg(this);
|
||||
msg.setText("Tips");
|
||||
msg.setInformativeText("If only one channel want, Channel0 has a higher maximum sample rate!");
|
||||
msg.setStandardButtons(QMessageBox::Ok);
|
||||
msg.setIcon(QMessageBox::Information);
|
||||
msg.exec();
|
||||
s->set_active(!s->get_active());
|
||||
last = 0;
|
||||
channel = s->get_index();
|
||||
break;
|
||||
mTrace->set_old_v_offset(mTrace->get_v_offset());
|
||||
} else if (action == Trace::POSTRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::POSTRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::POSTRIG);
|
||||
} else if (action == Trace::HIGTRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::HIGTRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::HIGTRIG);
|
||||
} else if (action == Trace::NEGTRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::NEGTRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::NEGTRIG);
|
||||
} else if (action == Trace::LOWTRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::LOWTRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::LOWTRIG);
|
||||
} else if (action == Trace::EDGETRIG && mTrace) {
|
||||
if (mTrace->get_trig() == Trace::EDGETRIG)
|
||||
mTrace->set_trig(0);
|
||||
else
|
||||
mTrace->set_trig(Trace::EDGETRIG);
|
||||
} else if (action == Trace::VDIAL && mTrace) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
BOOST_FOREACH(const shared_ptr<Trace> t, traces) {
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->set_hDialActive(false);
|
||||
if (t != mTrace) {
|
||||
dsoSig->set_vDialActive(false);
|
||||
}
|
||||
}
|
||||
if (last)
|
||||
mSig->set_active(!mSig->get_active());
|
||||
} else {
|
||||
mSig->set_active(!mSig->get_active());
|
||||
channel = mSig->get_index();
|
||||
}
|
||||
ch_changed(channel);
|
||||
} else if (action == Signal::ACDC && mSig) {
|
||||
mSig->set_acCoupling(!mSig->get_acCoupling());
|
||||
acdc_changed(mSig->get_index());
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace))
|
||||
dsoSig->set_vDialActive(!dsoSig->get_vDialActive());
|
||||
} else if (action == Trace::HDIAL && mTrace) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
if (dsoSig->get_hDialActive()) {
|
||||
BOOST_FOREACH(const shared_ptr<Trace> t, traces) {
|
||||
if(dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->set_vDialActive(false);
|
||||
dsoSig->set_hDialActive(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BOOST_FOREACH(const shared_ptr<Trace> t, traces) {
|
||||
if(dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
dsoSig->set_vDialActive(false);
|
||||
dsoSig->set_hDialActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (action == Trace::CHEN && mTrace) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace)) {
|
||||
dsoSig->set_enable(!dsoSig->enabled());
|
||||
}
|
||||
} else if (action == Trace::ACDC && mTrace) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(mTrace))
|
||||
dsoSig->set_acCoupling(!dsoSig->get_acCoupling());
|
||||
}
|
||||
|
||||
if (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
|
||||
// Unselect all other signals because the Ctrl is not
|
||||
// Unselect all other Traces because the Ctrl is not
|
||||
// pressed
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
|
||||
if (s != mSig)
|
||||
s->select(false);
|
||||
BOOST_FOREACH(const shared_ptr<Trace> t, traces)
|
||||
if (t != mTrace)
|
||||
t->select(false);
|
||||
}
|
||||
update();
|
||||
}
|
||||
@@ -295,26 +264,27 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
||||
// judge for color / name / trigger / move
|
||||
int action;
|
||||
const boost::shared_ptr<Signal> mSig =
|
||||
get_mSig(action, event->pos());
|
||||
if (mSig){
|
||||
if (action == Signal::COLOR && _colorFlag) {
|
||||
_context_signal = mSig;
|
||||
const boost::shared_ptr<Trace> mTrace =
|
||||
get_mTrace(action, event->pos());
|
||||
if (mTrace){
|
||||
if (action == Trace::COLOR && _colorFlag) {
|
||||
_context_trace = mTrace;
|
||||
changeColor(event);
|
||||
_view.set_need_update(true);
|
||||
} else if (action == Signal::NAME && _nameFlag) {
|
||||
_context_signal = mSig;
|
||||
} else if (action == Trace::NAME && _nameFlag) {
|
||||
_context_trace = mTrace;
|
||||
changeName(event);
|
||||
}
|
||||
}
|
||||
if (_moveFlag) {
|
||||
move(event);
|
||||
//move(event);
|
||||
_view.signals_changed();
|
||||
_view.set_need_update(true);
|
||||
}
|
||||
_colorFlag = false;
|
||||
_nameFlag = false;
|
||||
_moveFlag = false;
|
||||
_drag_sigs.clear();
|
||||
_drag_traces.clear();
|
||||
_view.normalize_layout();
|
||||
}
|
||||
|
||||
@@ -323,30 +293,24 @@ void Header::wheelEvent(QWheelEvent *event)
|
||||
assert(event);
|
||||
|
||||
if (event->orientation() == Qt::Vertical) {
|
||||
const vector< shared_ptr<Signal> > sigs(
|
||||
_view.session().get_signals());
|
||||
const vector< shared_ptr<Trace> > traces(
|
||||
_view.get_traces());
|
||||
// Vertical scrolling
|
||||
double shift = event->delta() / 20.0;
|
||||
if (shift > 1.0) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
if (s->get_vDialActive()) {
|
||||
if(s->go_vDialNext())
|
||||
vDial_changed(s->get_index());
|
||||
BOOST_FOREACH(const shared_ptr<Trace> t, traces) {
|
||||
shared_ptr<view::DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<view::DsoSignal>(t)) {
|
||||
if (dsoSig->get_vDialActive()) {
|
||||
if (shift > 1.0)
|
||||
dsoSig->go_vDialNext();
|
||||
else if (shift < -1.0)
|
||||
dsoSig->go_vDialPre();
|
||||
break;
|
||||
} else if (s->get_hDialActive()) {
|
||||
if(s->go_hDialNext())
|
||||
hDial_changed(0);
|
||||
}
|
||||
}
|
||||
} else if (shift < -1.0) {
|
||||
BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
|
||||
if (s->get_vDialActive()) {
|
||||
if(s->go_vDialPre())
|
||||
vDial_changed(s->get_index());
|
||||
break;
|
||||
} else if (s->get_hDialActive()) {
|
||||
if(s->go_hDialPre())
|
||||
hDial_changed(0);
|
||||
} else if (dsoSig->get_hDialActive()) {
|
||||
if (shift > 1.0)
|
||||
dsoSig->go_hDialNext();
|
||||
else if (shift < -1.0)
|
||||
dsoSig->go_hDialPre();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,145 +318,11 @@ void Header::wheelEvent(QWheelEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void Header::move(QMouseEvent *event)
|
||||
{
|
||||
bool _moveValid = false;
|
||||
bool _moveUp = false;
|
||||
bool firstCheck = true;
|
||||
const vector< boost::shared_ptr<Signal> > sigs(
|
||||
_view.session().get_signals());
|
||||
boost::shared_ptr<Signal> minDragSig;
|
||||
boost::shared_ptr<Signal> maxDragSig;
|
||||
int minOffset;
|
||||
int minOldOffset;
|
||||
int maxOffset;
|
||||
int maxOldOffset;
|
||||
int targetOffset;
|
||||
std::list<std::pair<boost::weak_ptr<Signal>,
|
||||
int> >::iterator minJ;
|
||||
std::list<std::pair<boost::weak_ptr<Signal>,
|
||||
int> >::iterator maxJ;
|
||||
int targetOrder;
|
||||
|
||||
// reCalculate _v_offset of all signals after dragging release
|
||||
if ((event->button() == Qt::LeftButton)) {
|
||||
while (!_drag_sigs.empty()) {
|
||||
minOffset = INT_MAX;
|
||||
maxOffset = 0;
|
||||
for (std::list<std::pair<boost::weak_ptr<Signal>,
|
||||
int> >::iterator i = _drag_sigs.begin();
|
||||
i != _drag_sigs.end(); i++) {
|
||||
const boost::shared_ptr<Signal> sig((*i).first);
|
||||
if (sig) {
|
||||
if (sig->get_v_offset() < minOffset) {
|
||||
minDragSig = sig;
|
||||
minOldOffset = (*i).second;
|
||||
minOffset = sig->get_v_offset();
|
||||
minJ = i;
|
||||
}
|
||||
if (sig->get_v_offset() > maxOffset) {
|
||||
maxDragSig = sig;
|
||||
maxOldOffset = (*i).second;
|
||||
maxOffset = sig->get_v_offset();
|
||||
maxJ = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (minOffset > minOldOffset) {
|
||||
_moveUp = false;
|
||||
_drag_sigs.erase(maxJ);
|
||||
} else {
|
||||
_moveUp = true;
|
||||
_drag_sigs.erase(minJ);
|
||||
}
|
||||
if (!_moveValid && firstCheck){
|
||||
firstCheck = false;
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
if (_moveUp) {
|
||||
if (s->selected()) {
|
||||
if ((minOffset <= s->get_old_v_offset()) && (minOffset > (s->get_old_v_offset() - _view.get_spanY()))) {
|
||||
_moveValid = true;
|
||||
targetOffset = s->get_old_v_offset();
|
||||
targetOrder = s->get_order();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((minOffset <= s->get_v_offset()) && (minOffset > (s->get_v_offset() - _view.get_spanY()))) {
|
||||
_moveValid = true;
|
||||
targetOffset = s->get_v_offset();
|
||||
targetOrder = s->get_order();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (s->selected()) {
|
||||
if ((maxOffset >= s->get_old_v_offset()) && (maxOffset < (s->get_old_v_offset() + _view.get_spanY()))) {
|
||||
_moveValid = true;
|
||||
targetOffset = s->get_old_v_offset();
|
||||
targetOrder = s->get_order();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if ((maxOffset >= s->get_v_offset()) && (maxOffset < (s->get_v_offset() + _view.get_spanY()))) {
|
||||
_moveValid = true;
|
||||
targetOffset = s->get_v_offset();
|
||||
targetOrder = s->get_order();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_moveValid) {
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
if (_moveUp) {
|
||||
if (s->selected() && s == minDragSig) {
|
||||
s->set_v_offset(targetOffset);
|
||||
s->set_order(targetOrder);
|
||||
s->select(false);
|
||||
} else if (!s->selected() && s->get_v_offset() >= targetOffset && s->get_v_offset() < minOldOffset) {
|
||||
s->set_v_offset(s->get_v_offset() + _view.get_spanY());
|
||||
s->set_order(s->get_order() + 1);
|
||||
}
|
||||
} else {
|
||||
if (s->selected() && s == maxDragSig) {
|
||||
s->set_v_offset(targetOffset);
|
||||
s->set_order(targetOrder);
|
||||
s->select(false);
|
||||
} else if (!s->selected() && s->get_v_offset() <= targetOffset && s->get_v_offset() > maxOldOffset) {
|
||||
s->set_v_offset(s->get_v_offset() - _view.get_spanY());
|
||||
s->set_order(s->get_order() - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_moveUp) {
|
||||
targetOffset += _view.get_spanY();
|
||||
targetOrder++;
|
||||
} else {
|
||||
targetOffset -= _view.get_spanY();
|
||||
targetOrder--;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_moveValid) {
|
||||
signals_moved();
|
||||
} else {
|
||||
BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
|
||||
if (s->selected()) {
|
||||
s->set_v_offset(s->get_old_v_offset());
|
||||
s->select(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_moveValid = false;
|
||||
}
|
||||
|
||||
void Header::changeName(QMouseEvent *event)
|
||||
{
|
||||
if ((event->button() == Qt::LeftButton)) {
|
||||
header_resize();
|
||||
nameEdit->setText(_context_signal->get_name());
|
||||
nameEdit->setText(_context_trace->get_name());
|
||||
nameEdit->selectAll();
|
||||
nameEdit->setFocus();
|
||||
nameEdit->show();
|
||||
@@ -503,9 +333,9 @@ void Header::changeName(QMouseEvent *event)
|
||||
void Header::changeColor(QMouseEvent *event)
|
||||
{
|
||||
if ((event->button() == Qt::LeftButton)) {
|
||||
const QColor new_color = QColorDialog::getColor(_context_signal->get_colour(), this, tr("Set Channel Colour"));
|
||||
const QColor new_color = QColorDialog::getColor(_context_trace->get_colour(), this, tr("Set Channel Colour"));
|
||||
if (new_color.isValid())
|
||||
_context_signal->set_colour(new_color);
|
||||
_context_trace->set_colour(new_color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,17 +344,17 @@ void Header::mouseMoveEvent(QMouseEvent *event)
|
||||
assert(event);
|
||||
_mouse_point = event->pos();
|
||||
|
||||
// Move the signals if we are dragging
|
||||
if (!_drag_sigs.empty()) {
|
||||
// Move the Traces if we are dragging
|
||||
if (!_drag_traces.empty()) {
|
||||
const int delta = event->pos().y() - _mouse_down_point.y();
|
||||
|
||||
for (std::list<std::pair<boost::weak_ptr<Signal>,
|
||||
int> >::iterator i = _drag_sigs.begin();
|
||||
i != _drag_sigs.end(); i++) {
|
||||
const boost::shared_ptr<Signal> sig((*i).first);
|
||||
for (std::list<std::pair<boost::weak_ptr<Trace>,
|
||||
int> >::iterator i = _drag_traces.begin();
|
||||
i != _drag_traces.end(); i++) {
|
||||
const boost::shared_ptr<Trace> sig((*i).first);
|
||||
if (sig) {
|
||||
int y = (*i).second + delta;
|
||||
if (sig->get_type() != Signal::DS_DSO) {
|
||||
if (sig->get_type() != Trace::DS_DSO) {
|
||||
const int y_snap =
|
||||
((y + View::SignalSnapGridSize / 2) /
|
||||
View::SignalSnapGridSize) *
|
||||
@@ -533,20 +363,19 @@ void Header::mouseMoveEvent(QMouseEvent *event)
|
||||
_moveFlag = true;
|
||||
sig->set_v_offset(y_snap);
|
||||
}
|
||||
// Ensure the signal is selected
|
||||
// Ensure the Trace is selected
|
||||
sig->select(true);
|
||||
} else {
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y > height())
|
||||
y = height();
|
||||
sig->set_zeroPos(y);
|
||||
sig->select(false);
|
||||
signals_moved();
|
||||
shared_ptr<DsoSignal> dsoSig;
|
||||
if (dsoSig = dynamic_pointer_cast<DsoSignal>(sig)) {
|
||||
dsoSig->set_zeroPos(y);
|
||||
dsoSig->select(false);
|
||||
traces_moved();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//signals_moved();
|
||||
//traces_moved();
|
||||
}
|
||||
update();
|
||||
}
|
||||
@@ -561,33 +390,33 @@ void Header::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
int action;
|
||||
|
||||
const boost::shared_ptr<Signal> s = get_mSig(action, _mouse_point);
|
||||
const boost::shared_ptr<Trace> t = get_mTrace(action, _mouse_point);
|
||||
|
||||
if (!s || !s->selected() || action != Signal::LABEL)
|
||||
if (!t || !t->selected() || action != Trace::LABEL)
|
||||
return;
|
||||
|
||||
QMenu menu(this);
|
||||
if (s->get_type() == Signal::DS_LOGIC)
|
||||
if (t->get_type() == Trace::DS_LOGIC)
|
||||
menu.addAction(_action_add_group);
|
||||
else if (s->get_type() == Signal::DS_GROUP)
|
||||
else if (t->get_type() == Trace::DS_GROUP)
|
||||
menu.addAction(_action_del_group);
|
||||
|
||||
_context_signal = s;
|
||||
_context_trace = t;
|
||||
menu.exec(event->globalPos());
|
||||
_context_signal.reset();
|
||||
_context_trace.reset();
|
||||
}
|
||||
|
||||
void Header::on_action_set_name_triggered()
|
||||
{
|
||||
boost::shared_ptr<view::Signal> context_signal = _context_signal;
|
||||
if (!context_signal)
|
||||
boost::shared_ptr<view::Trace> context_Trace = _context_trace;
|
||||
if (!context_Trace)
|
||||
return;
|
||||
|
||||
if (nameEdit->isModified()) {
|
||||
context_signal->set_name(nameEdit->text());
|
||||
if (context_signal->get_type() == Signal::DS_LOGIC ||
|
||||
context_signal->get_type() == Signal::DS_ANALOG)
|
||||
sr_dev_probe_name_set(_view.session().get_device(), context_signal->get_index(), nameEdit->text().toUtf8().constData());
|
||||
context_Trace->set_name(nameEdit->text());
|
||||
if (context_Trace->get_type() == Trace::DS_LOGIC ||
|
||||
context_Trace->get_type() == Trace::DS_ANALOG)
|
||||
sr_dev_probe_name_set(_view.session().get_device()->dev_inst(), context_Trace->get_index(), nameEdit->text().toUtf8().constData());
|
||||
}
|
||||
|
||||
nameEdit->hide();
|
||||
@@ -604,7 +433,7 @@ void Header::on_action_del_group_triggered()
|
||||
_view.session().del_group();
|
||||
}
|
||||
|
||||
void Header::on_signals_moved()
|
||||
void Header::on_traces_moved()
|
||||
{
|
||||
update();
|
||||
}
|
||||
@@ -612,9 +441,9 @@ void Header::on_signals_moved()
|
||||
void Header::header_resize()
|
||||
{
|
||||
//if (nameEdit->isVisible()) {
|
||||
if (_context_signal) {
|
||||
const int y = _context_signal->get_v_offset() - _view.v_offset() - _view.get_signalHeight() / 2;
|
||||
nameEdit->move(QPoint(_context_signal->get_leftWidth(), y - nameEdit->height() / 2));
|
||||
if (_context_trace) {
|
||||
const int y = _context_trace->get_y();
|
||||
nameEdit->move(QPoint(_context_trace->get_leftWidth(), y - nameEdit->height() / 2));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user