summaryrefslogtreecommitdiff
path: root/DSLogic-gui/pv/view/header.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'DSLogic-gui/pv/view/header.cpp')
-rw-r--r--DSLogic-gui/pv/view/header.cpp240
1 files changed, 165 insertions, 75 deletions
diff --git a/DSLogic-gui/pv/view/header.cpp b/DSLogic-gui/pv/view/header.cpp
index 9bbea0b..6803e3a 100644
--- a/DSLogic-gui/pv/view/header.cpp
+++ b/DSLogic-gui/pv/view/header.cpp
@@ -39,6 +39,7 @@
#include <QPainter>
#include <QRect>
#include <QStyleOption>
+#include <QMessageBox>
using namespace boost;
using namespace std;
@@ -46,14 +47,6 @@ using namespace std;
namespace pv {
namespace view {
-const int Header::COLOR = 1;
-const int Header::NAME = 2;
-const int Header::POSTRIG = 3;
-const int Header::HIGTRIG = 4;
-const int Header::NEGTRIG = 5;
-const int Header::LOWTRIG = 6;
-const int Header::LABEL = 7;
-
Header::Header(View &parent) :
QWidget(&parent),
_view(parent),
@@ -90,16 +83,16 @@ int Header::get_nameEditWidth()
return 0;
}
-boost::shared_ptr<pv::view::Signal> Header::get_mouse_over_signal(
+boost::shared_ptr<pv::view::Signal> Header::get_mSig(
int &action,
const QPoint &pt)
{
const int w = width();
- const vector< shared_ptr<Signal> > sigs(
+ const vector< boost::shared_ptr<Signal> > sigs(
_view.session().get_signals());
const int v_offset = _view.v_offset();
- BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
+ BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
{
assert(s);
@@ -108,7 +101,7 @@ boost::shared_ptr<pv::view::Signal> Header::get_mouse_over_signal(
return s;
}
- return shared_ptr<Signal>();
+ return boost::shared_ptr<Signal>();
}
void Header::paintEvent(QPaintEvent*)
@@ -122,7 +115,7 @@ void Header::paintEvent(QPaintEvent*)
const int w = width();
int action;
- const vector< shared_ptr<Signal> > sigs(
+ const vector< boost::shared_ptr<Signal> > sigs(
_view.session().get_signals());
//QPainter painter(this);
@@ -130,7 +123,7 @@ void Header::paintEvent(QPaintEvent*)
const int v_offset = _view.v_offset();
const bool dragging = !_drag_sigs.empty();
- BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
+ BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
{
assert(s);
@@ -147,7 +140,7 @@ void Header::paintEvent(QPaintEvent*)
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 {
+ } 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);
}
@@ -157,7 +150,7 @@ void Header::paintEvent(QPaintEvent*)
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 {
+ } 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);
}
@@ -171,7 +164,7 @@ void Header::mousePressEvent(QMouseEvent *event)
{
assert(event);
- const vector< shared_ptr<Signal> > sigs(
+ const vector< boost::shared_ptr<Signal> > sigs(
_view.session().get_signals());
int action;
@@ -179,23 +172,24 @@ void Header::mousePressEvent(QMouseEvent *event)
_mouse_down_point = event->pos();
// Save the offsets of any signals which will be dragged
- BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
+ BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
if (s->selected())
_drag_sigs.push_back(
make_pair(s, s->get_v_offset()));
// Select the signal if it has been clicked
- const shared_ptr<Signal> mouse_over_signal =
- get_mouse_over_signal(action, event->pos());
- if (action == COLOR && mouse_over_signal) {
+ const boost::shared_ptr<Signal> mSig =
+ get_mSig(action, event->pos());
+ if (action == Signal::COLOR && mSig) {
_colorFlag = true;
- } else if (action == NAME && mouse_over_signal) {
+ } else if (action == Signal::NAME && mSig) {
_nameFlag = true;
- } else if (action == LABEL && mouse_over_signal) {
- if (mouse_over_signal->selected())
- mouse_over_signal->select(false);
+ } else if (action == Signal::LABEL && mSig) {
+ if (mSig->selected())
+ mSig->select(false);
else {
- mouse_over_signal->select(true);
+ if (mSig->get_type() != Signal::DS_DSO)
+ mSig->select(true);
if (~QApplication::keyboardModifiers() &
Qt::ControlModifier)
@@ -204,37 +198,91 @@ void Header::mousePressEvent(QMouseEvent *event)
// Add the signal to the drag list
if (event->button() & Qt::LeftButton)
_drag_sigs.push_back(
- make_pair(mouse_over_signal,
- mouse_over_signal->get_v_offset()));
+ make_pair(mSig,
+ (mSig->get_type() == Signal::DS_DSO) ? mSig->get_zeroPos() : mSig->get_v_offset()));
}
- mouse_over_signal->set_old_v_offset(mouse_over_signal->get_v_offset());
- } else if (action == POSTRIG && mouse_over_signal) {
- if (mouse_over_signal->get_trig() == POSTRIG)
- mouse_over_signal->set_trig(0);
+ 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
- mouse_over_signal->set_trig(POSTRIG);
- } else if (action == HIGTRIG && mouse_over_signal) {
- if (mouse_over_signal->get_trig() == HIGTRIG)
- mouse_over_signal->set_trig(0);
+ mSig->set_trig(Signal::POSTRIG);
+ } else if (action == Signal::HIGTRIG && mSig) {
+ if (mSig->get_trig() == Signal::HIGTRIG)
+ mSig->set_trig(0);
else
- mouse_over_signal->set_trig(HIGTRIG);
- } else if (action == NEGTRIG && mouse_over_signal) {
- if (mouse_over_signal->get_trig() == NEGTRIG)
- mouse_over_signal->set_trig(0);
+ mSig->set_trig(Signal::HIGTRIG);
+ } else if (action == Signal::NEGTRIG && mSig) {
+ if (mSig->get_trig() == Signal::NEGTRIG)
+ mSig->set_trig(0);
else
- mouse_over_signal->set_trig(NEGTRIG);
- } else if (action == LOWTRIG && mouse_over_signal) {
- if (mouse_over_signal->get_trig() == LOWTRIG)
- mouse_over_signal->set_trig(0);
+ mSig->set_trig(Signal::NEGTRIG);
+ } else if (action == Signal::LOWTRIG && mSig) {
+ if (mSig->get_trig() == Signal::LOWTRIG)
+ mSig->set_trig(0);
else
- mouse_over_signal->set_trig(LOWTRIG);
+ 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);
+ }
+ }
+ 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;
+ }
+ }
+ 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 (~QApplication::keyboardModifiers() & Qt::ControlModifier) {
// Unselect all other signals because the Ctrl is not
// pressed
- BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
- if (s != mouse_over_signal)
+ BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs)
+ if (s != mSig)
s->select(false);
}
update();
@@ -247,15 +295,15 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
// judge for color / name / trigger / move
int action;
- const shared_ptr<Signal> mouse_over_signal =
- get_mouse_over_signal(action, event->pos());
- if (mouse_over_signal){
- if (action == COLOR && _colorFlag) {
- _context_signal = mouse_over_signal;
+ const boost::shared_ptr<Signal> mSig =
+ get_mSig(action, event->pos());
+ if (mSig){
+ if (action == Signal::COLOR && _colorFlag) {
+ _context_signal = mSig;
changeColor(event);
_view.set_need_update(true);
- } else if (action == NAME && _nameFlag) {
- _context_signal = mouse_over_signal;
+ } else if (action == Signal::NAME && _nameFlag) {
+ _context_signal = mSig;
changeName(event);
}
}
@@ -270,12 +318,48 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
_view.normalize_layout();
}
+void Header::wheelEvent(QWheelEvent *event)
+{
+ assert(event);
+
+ if (event->orientation() == Qt::Vertical) {
+ const vector< shared_ptr<Signal> > sigs(
+ _view.session().get_signals());
+ // 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());
+ 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);
+ }
+ }
+ }
+ update();
+ }
+}
+
void Header::move(QMouseEvent *event)
{
bool _moveValid = false;
bool _moveUp = false;
bool firstCheck = true;
- const vector< shared_ptr<Signal> > sigs(
+ const vector< boost::shared_ptr<Signal> > sigs(
_view.session().get_signals());
boost::shared_ptr<Signal> minDragSig;
boost::shared_ptr<Signal> maxDragSig;
@@ -323,7 +407,7 @@ void Header::move(QMouseEvent *event)
}
if (!_moveValid && firstCheck){
firstCheck = false;
- BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
+ 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()))) {
@@ -360,7 +444,7 @@ void Header::move(QMouseEvent *event)
}
}
if (_moveValid) {
- BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
+ BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
if (_moveUp) {
if (s->selected() && s == minDragSig) {
s->set_v_offset(targetOffset);
@@ -393,7 +477,7 @@ void Header::move(QMouseEvent *event)
if (_moveValid) {
signals_moved();
} else {
- BOOST_FOREACH(const shared_ptr<Signal> s, sigs) {
+ BOOST_FOREACH(const boost::shared_ptr<Signal> s, sigs) {
if (s->selected()) {
s->set_v_offset(s->get_old_v_offset());
s->select(false);
@@ -439,24 +523,31 @@ void Header::mouseMoveEvent(QMouseEvent *event)
i != _drag_sigs.end(); i++) {
const boost::shared_ptr<Signal> sig((*i).first);
if (sig) {
- const int y = (*i).second + delta;
- const int y_snap =
- ((y + View::SignalSnapGridSize / 2) /
- View::SignalSnapGridSize) *
- View::SignalSnapGridSize;
- if (y_snap != sig->get_v_offset()) {
- _moveFlag = true;
- sig->set_v_offset(y_snap);
+ int y = (*i).second + delta;
+ if (sig->get_type() != Signal::DS_DSO) {
+ const int y_snap =
+ ((y + View::SignalSnapGridSize / 2) /
+ View::SignalSnapGridSize) *
+ View::SignalSnapGridSize;
+ if (y_snap != sig->get_v_offset()) {
+ _moveFlag = true;
+ sig->set_v_offset(y_snap);
+ }
+ // Ensure the signal 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();
}
- // Ensure the signal is selected
- sig->select(true);
}
-
}
-
//signals_moved();
}
-
update();
}
@@ -470,10 +561,9 @@ void Header::contextMenuEvent(QContextMenuEvent *event)
{
int action;
- const shared_ptr<Signal> s = get_mouse_over_signal(action, _mouse_point);
+ const boost::shared_ptr<Signal> s = get_mSig(action, _mouse_point);
- //if (!s || action != LABEL)
- if (!s || !s->selected() || action != LABEL)
+ if (!s || !s->selected() || action != Signal::LABEL)
return;
QMenu menu(this);
@@ -489,7 +579,7 @@ void Header::contextMenuEvent(QContextMenuEvent *event)
void Header::on_action_set_name_triggered()
{
- shared_ptr<view::Signal> context_signal = _context_signal;
+ boost::shared_ptr<view::Signal> context_signal = _context_signal;
if (!context_signal)
return;