summaryrefslogtreecommitdiffstats
path: root/clients
diff options
context:
space:
mode:
Diffstat (limited to 'clients')
-rw-r--r--clients/tde/src/part/scope/part.cpp10
-rw-r--r--clients/tde/src/widgets/tracewidget.cpp187
-rw-r--r--clients/tde/src/widgets/tracewidget.h11
3 files changed, 177 insertions, 31 deletions
diff --git a/clients/tde/src/part/scope/part.cpp b/clients/tde/src/part/scope/part.cpp
index ae27923..b0e72de 100644
--- a/clients/tde/src/part/scope/part.cpp
+++ b/clients/tde/src/part/scope/part.cpp
@@ -64,6 +64,16 @@ ScopePart::ScopePart( TQWidget *parentWidget, const char *widgetName, TQObject *
m_updateTimeoutTimer = new TQTimer(this);
connect(m_updateTimeoutTimer, SIGNAL(timeout()), this, SLOT(mainEventLoop()));
+ // Initialize data
+ m_hdivs = 0;
+ m_vdivs = 0;
+ for (int traceno=0; traceno<=MAXTRACES; traceno++) {
+ m_samplesInTrace[traceno] = 0;
+ m_channelActive[traceno] = false;
+ m_voltsDiv[traceno] = 0;
+ m_secsDiv[traceno] = 0;
+ }
+
// Create widgets
m_base = new ScopeBase(widget());
m_traceWidget = m_base->traceWidget;
diff --git a/clients/tde/src/widgets/tracewidget.cpp b/clients/tde/src/widgets/tracewidget.cpp
index 10299e5..7ba4b6e 100644
--- a/clients/tde/src/widgets/tracewidget.cpp
+++ b/clients/tde/src/widgets/tracewidget.cpp
@@ -22,6 +22,8 @@
#define CURSOR_DARKNESS_FACTOR 200
#define ZOOM_SHADING_DARKNESS_FACTOR 200
+#define CURSOR_MOVE_CAPTURE_DISTANCE 0
+
TQRectF::TQRectF() {
m_valid = false;
}
@@ -227,6 +229,8 @@ void TraceData::resetVPosition() {
CursorData::CursorData(TraceWidget* parent, TQWidget* labelParent) : TQObject(), parentWidget(parent) {
color = TQColor(0, 255, 0);
+ highlightColor = TQColor(192, 255, 192);
+ highlighted = false;
enabled = false;
orientation = TQt::Vertical;
position = 50;
@@ -285,7 +289,12 @@ CursorData::~CursorData() {
}
void CursorData::drawCursor(TQPainter* p, int graticule_width, int graticule_height) {
- p->setPen(color.dark(parentWidget->m_cursorDarkness));
+ if (highlighted) {
+ p->setPen(highlightColor.dark(parentWidget->m_cursorDarkness));
+ }
+ else {
+ p->setPen(color.dark(parentWidget->m_cursorDarkness));
+ }
if (orientation == TQt::Vertical) {
int x = abs(((position)/(100.0))*(graticule_width));
@@ -388,8 +397,11 @@ void CursorData::moveNegMultiTicks() {
GraticuleWidget::GraticuleWidget(TraceWidget* parent, const char* name) : TQWidget(parent, name),
m_base(parent),
m_graticulePixmap(0),
- leftMouseDown(false),
- middleMouseDown(false) {
+ m_leftMouseDown(false),
+ m_middleMouseDown(false),
+ m_closestCursor(-1),
+ m_closestCursorDistance(-1),
+ m_movingCursor(-1) {
setBackgroundMode(NoBackground);
setSizePolicy(TQSizePolicy(TQSizePolicy::MinimumExpanding, TQSizePolicy::MinimumExpanding));
@@ -474,47 +486,62 @@ void GraticuleWidget::resizeEvent(TQResizeEvent *) {
}
void GraticuleWidget::mousePressEvent(TQMouseEvent *e) {
- if ((e->button() == TQt::LeftButton) && (!leftMouseDown) && (!middleMouseDown)) {
- m_prevCursorRect = m_base->zoomCursorBox();
- if (m_base->m_zoomBoxEnabled) {
- leftMouseDown = true;
+ if ((e->button() == TQt::LeftButton) && (!m_leftMouseDown) && (!m_middleMouseDown)) {
+ if (m_closestCursorDistance <= CURSOR_MOVE_CAPTURE_DISTANCE) {
m_prevDownPos = e->pos();
+ m_movingCursor = m_closestCursor;
+ m_prevCursorPos = m_base->m_cursorArray[m_movingCursor]->position;
+ m_leftMouseDown = true;
+ }
+ else {
+ m_prevCursorRect = m_base->zoomCursorBox();
+ if (m_base->m_zoomBoxEnabled) {
+ m_leftMouseDown = true;
+ m_prevDownPos = e->pos();
+ }
}
}
- else if ((e->button() == TQt::MidButton) && (!leftMouseDown) && (!middleMouseDown)) {
+ else if ((e->button() == TQt::MidButton) && (!m_leftMouseDown) && (!m_middleMouseDown)) {
m_prevCursorRect = m_base->zoomCursorBox();
if (m_base->m_zoomBoxEnabled) {
- middleMouseDown = true;
+ m_middleMouseDown = true;
m_prevDownPos = e->pos();
}
}
}
void GraticuleWidget::mouseReleaseEvent(TQMouseEvent *e) {
- if (leftMouseDown) {
+ if (m_leftMouseDown) {
if (e->button() == TQt::LeftButton) {
- leftMouseDown = false;
-
- double x1 = m_prevDownPos.x();
- double y1 = m_prevDownPos.y();
- double x2 = e->x();
- double y2 = e->y();
- if ((x1 < width()) && (y1 < height()) && (x2 < width()) && (y2 < height()) && (x1 > 0) && (y1 > 0) && (x2 > 0) && (y2 > 0)) {
- x1 = ((x1/width())*100.0);
- y1 = ((y1/height())*100.0);
- x2 = ((x2/width())*100.0);
- y2 = ((y2/height())*100.0);
- m_base->setZoomCursorBox(TQRectF(x1, y1, x2, y2));
+ m_leftMouseDown = false;
+
+ if (m_movingCursor >= 0) {
+ m_movingCursor = -1;
}
else {
- // Reset original zoom box
- m_base->setZoomCursorBox(m_prevCursorRect);
+ double x1 = m_prevDownPos.x();
+ double y1 = m_prevDownPos.y();
+ double x2 = e->x();
+ double y2 = e->y();
+ double pixelDiffX = fabs(x1-x2);
+ double pixelDiffY = fabs(y1-y2);
+ if ((x1 < width()) && (y1 < height()) && (x2 < width()) && (y2 < height()) && (x1 > 0) && (y1 > 0) && (x2 > 0) && (y2 > 0) && (pixelDiffX>0) && (pixelDiffY>0)) {
+ x1 = ((x1/width())*100.0);
+ y1 = ((y1/height())*100.0);
+ x2 = ((x2/width())*100.0);
+ y2 = ((y2/height())*100.0);
+ m_base->setZoomCursorBox(TQRectF(x1, y1, x2, y2));
+ }
+ else {
+ // Reset original zoom box
+ m_base->setZoomCursorBox(m_prevCursorRect);
+ }
}
}
}
- else if (middleMouseDown) {
+ else if (m_middleMouseDown) {
if (e->button() == TQt::MidButton) {
- middleMouseDown = false;
+ m_middleMouseDown = false;
double x1 = m_prevDownPos.x();
double y1 = m_prevDownPos.y();
@@ -531,6 +558,9 @@ void GraticuleWidget::mouseReleaseEvent(TQMouseEvent *e) {
}
}
}
+
+ updateGraticule();
+ repaint(true);
}
void GraticuleWidget::mouseDoubleClickEvent(TQMouseEvent *) {
@@ -538,6 +568,67 @@ void GraticuleWidget::mouseDoubleClickEvent(TQMouseEvent *) {
}
void GraticuleWidget::mouseMoveEvent(TQMouseEvent *e) {
+ // If we are within X pixels of a cursor, change icon to appopriate drag arrows and set up to drag the cursor instead of replacing the zoom box
+ // Replacing the zoom box might need to be assigned to the right mouse button...
+ bool cursorHighlightChanged = false;
+ m_closestCursor = -1;
+ m_closestCursorDistance = -1;
+ if ((!m_leftMouseDown) && (!m_middleMouseDown) && (m_movingCursor < 0)) {
+ for (uint cursor=0;cursor<m_base->m_cursorArray.count();cursor++) {
+ double scaledYPos = (e->y()*100.0)/height();
+ double scaledXPos = (e->x()*100.0)/width();
+ unsigned int pixelDistance;
+ if (m_base->m_cursorArray[cursor]->orientation == TQt::Horizontal) {
+ pixelDistance = (fabs(m_base->m_cursorArray[cursor]->position - scaledYPos)*height())/100.0;
+ if (pixelDistance < m_closestCursorDistance) {
+ m_closestCursorDistance = pixelDistance;
+ m_closestCursor = cursor;
+ }
+ }
+ else {
+ pixelDistance = (fabs(m_base->m_cursorArray[cursor]->position - scaledXPos)*width())/100.0;
+ if (pixelDistance < m_closestCursorDistance) {
+ m_closestCursorDistance = pixelDistance;
+ m_closestCursor = cursor;
+ }
+ }
+ // Ensure previous highlighting is cleared
+ // This is needed when two cursors are placed right next to one another
+ if (m_base->m_cursorArray[m_closestCursor]->highlighted) {
+ cursorHighlightChanged = true;
+ }
+ m_base->m_cursorArray[cursor]->highlighted = false;
+ }
+ if (m_closestCursor >= 0) {
+ if (m_closestCursorDistance <= CURSOR_MOVE_CAPTURE_DISTANCE) {
+ if (m_base->m_cursorArray[m_closestCursor]->orientation == TQt::Horizontal) {
+ setCursor(tqsizeVerCursor);
+ }
+ else {
+ setCursor(tqsizeHorCursor);
+ }
+ if (!m_base->m_cursorArray[m_closestCursor]->highlighted) {
+ cursorHighlightChanged = true;
+ }
+ m_base->m_cursorArray[m_closestCursor]->highlighted = true;
+ }
+ else {
+ setCursor(tqcrossCursor);
+ if (m_base->m_cursorArray[m_closestCursor]->highlighted) {
+ cursorHighlightChanged = true;
+ }
+ m_base->m_cursorArray[m_closestCursor]->highlighted = false;
+ }
+ }
+ else {
+ setCursor(tqcrossCursor);
+ if (m_base->m_cursorArray[m_closestCursor]->highlighted) {
+ cursorHighlightChanged = true;
+ }
+ m_base->m_cursorArray[m_closestCursor]->highlighted = false;
+ }
+ }
+
// Print current cursor location for all traces
if ((e->x() < width()) && (e->y() < height())) {
for (uint trace=0;trace<m_base->m_traceArray.count();trace++) {
@@ -563,7 +654,7 @@ void GraticuleWidget::mouseMoveEvent(TQMouseEvent *e) {
}
}
- if (leftMouseDown) {
+ if ((m_leftMouseDown) && (m_movingCursor < 0)) {
double x1 = m_prevDownPos.x();
double y1 = m_prevDownPos.y();
double x2 = e->x();
@@ -576,11 +667,36 @@ void GraticuleWidget::mouseMoveEvent(TQMouseEvent *e) {
m_base->setZoomCursorBox(TQRectF(x1, y1, x2, y2));
}
}
- else if (middleMouseDown) {
+ else if ((m_leftMouseDown) && (m_movingCursor >= 0)) {
+ TQPoint diff = e->pos() - m_prevDownPos;
+ diff = TQPoint(diff.x()*(100.0/width()), diff.y()*(100.0/height()));
+ if (m_base->m_cursorArray[m_movingCursor]->orientation == TQt::Horizontal) {
+ m_base->m_cursorArray[m_movingCursor]->position = m_prevCursorPos+diff.y();
+ }
+ else {
+ m_base->m_cursorArray[m_movingCursor]->position = m_prevCursorPos+diff.x();
+ }
+ if (m_base->m_cursorArray[m_movingCursor]->position < 0.0) {
+ m_base->m_cursorArray[m_movingCursor]->position = 0.0;
+ }
+ if (m_base->m_cursorArray[m_movingCursor]->position > 100.0) {
+ m_base->m_cursorArray[m_movingCursor]->position = 100.0;
+ }
+ updateGraticule();
+ repaint(true);
+ cursorHighlightChanged = false;
+ }
+ else if (m_middleMouseDown) {
TQPoint diff = e->pos() - m_prevDownPos;
diff = TQPoint(diff.x()*(100.0/width()), diff.y()*(100.0/height()));
m_base->setZoomCursorBox(TQRectF(m_prevCursorRect.x()+diff.x(), m_prevCursorRect.y()+diff.y(), m_prevCursorRect.width()+diff.x(), m_prevCursorRect.height()+diff.y()));
}
+
+ m_base->updateCursorText();
+ if (cursorHighlightChanged) {
+ updateGraticule();
+ repaint(true);
+ }
}
void GraticuleWidget::enterEvent(TQEvent *) {
@@ -732,7 +848,20 @@ void TraceWidget::updateTraceText() {
void TraceWidget::updateCursorText() {
for (uint cursor=0;cursor<m_cursorArray.count();cursor++) {
m_cursorArray[cursor]->paramLabel->setPaletteBackgroundColor(paletteBackgroundColor());
- m_cursorArray[cursor]->paramLabel->setPaletteForegroundColor(m_cursorArray[cursor]->color);
+ if (m_cursorArray[cursor]->highlighted) {
+ m_cursorArray[cursor]->paramLabel->setPaletteForegroundColor(m_cursorArray[cursor]->highlightColor);
+ m_cursorArray[cursor]->singleIncrBtn->setPaletteForegroundColor(m_cursorArray[cursor]->highlightColor);
+ m_cursorArray[cursor]->singleDecrBtn->setPaletteForegroundColor(m_cursorArray[cursor]->highlightColor);
+ m_cursorArray[cursor]->multiIncrBtn->setPaletteForegroundColor(m_cursorArray[cursor]->highlightColor);
+ m_cursorArray[cursor]->multiDecrBtn->setPaletteForegroundColor(m_cursorArray[cursor]->highlightColor);
+ }
+ else {
+ m_cursorArray[cursor]->paramLabel->setPaletteForegroundColor(m_cursorArray[cursor]->color);
+ m_cursorArray[cursor]->singleIncrBtn->setPaletteForegroundColor(m_cursorArray[cursor]->color);
+ m_cursorArray[cursor]->singleDecrBtn->setPaletteForegroundColor(m_cursorArray[cursor]->color);
+ m_cursorArray[cursor]->multiIncrBtn->setPaletteForegroundColor(m_cursorArray[cursor]->color);
+ m_cursorArray[cursor]->multiDecrBtn->setPaletteForegroundColor(m_cursorArray[cursor]->color);
+ }
TQString cursorText;
cursorText = TQString("<qt><nobr>%1").arg(m_cursorArray[cursor]->cursorName);
// If this is a horizontal cursor, list all vertical positions for all channels
diff --git a/clients/tde/src/widgets/tracewidget.h b/clients/tde/src/widgets/tracewidget.h
index 0dfaead..649077b 100644
--- a/clients/tde/src/widgets/tracewidget.h
+++ b/clients/tde/src/widgets/tracewidget.h
@@ -104,6 +104,8 @@ class CursorData : public TQObject
private:
TQColor color;
+ TQColor highlightColor;
+ bool highlighted;
bool enabled;
TQt::Orientation orientation;
double position;
@@ -116,6 +118,7 @@ class CursorData : public TQObject
TraceWidget* parentWidget;
friend class TraceWidget;
+ friend class GraticuleWidget;
};
typedef TQMemArray<CursorData*> CursorList;
@@ -144,8 +147,12 @@ class GraticuleWidget : public TQWidget
private:
TraceWidget* m_base;
TQPixmap* m_graticulePixmap;
- bool leftMouseDown;
- bool middleMouseDown;
+ bool m_leftMouseDown;
+ bool m_middleMouseDown;
+ int m_closestCursor;
+ unsigned int m_closestCursorDistance;
+ int m_movingCursor;
+ double m_prevCursorPos;
TQPoint m_prevDownPos;
TQRectF m_prevCursorRect;