Skip to content

Commit

Permalink
apps/radar/Lucid - working on rubber banding for zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-dixon committed Jan 22, 2025
1 parent c666eb9 commit 58c0e63
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
21 changes: 20 additions & 1 deletion codebase/apps/radar/src/Lucid/HorizWidget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ void HorizWidget::mouseReleaseEvent(QMouseEvent *e)
}

// hide the rubber band


_paintZoomRect();
_rubberBand->hide();
update();

Expand Down Expand Up @@ -2140,6 +2141,7 @@ void HorizWidget::mousePressEvent(QMouseEvent *e)


_rubberBand->setGeometry(pos.x(), pos.y(), 0, 0);
_paintZoomRect();
_rubberBand->show();

_mousePressX = pos.x();
Expand Down Expand Up @@ -2200,6 +2202,7 @@ void HorizWidget::mouseMoveEvent(QMouseEvent * e)
newRect = newRect.normalized();

_rubberBand->setGeometry(newRect);
_paintZoomRect();

}

Expand Down Expand Up @@ -2537,3 +2540,19 @@ void HorizWidget::ShowContextMenu(const QPoint &pos/* , RadxVol *vol */)
contextMenu.exec(this->mapToGlobal(pos));
}

//////////////////////////////////////////
// paint the user-selected zoom rectangle

void HorizWidget::_paintZoomRect()
{
QRect zrect = _rubberBand->geometry();
cerr << "Zoom rect x, y: "
<< zrect.x() << ", " << zrect.y() << endl;
cerr << "Zoom rect width, height: "
<< zrect.width() << ", " << zrect.height() << endl;
QPainter painter(this);
// painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
painter.setPen(QColor(0xff, 0xff, 0xff));
painter.drawRect(zrect);
}

19 changes: 10 additions & 9 deletions codebase/apps/radar/src/Lucid/HorizWidget.hh
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ public:

protected:
void paintEvent(QPaintEvent *event) override {
QRubberBand::paintEvent(event);
#ifdef NOTNOW
QPainter painter(this);
painter.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
// painter.setRenderHint(QPainter::Antialiasing);
// Draw border
painter.setPen(QColor(0xff, 0xff, 0xff));
// painter.setPen(QColor(0xff, 0xff, 0xff));
// Transparent background
// painter.setBrush(Qt::NoBrush);
painter.setBrush(Qt::NoBrush);
// Adjust to stay within bounds
painter.drawRect(rect().adjusted(0, 0, -1, -1));
#endif
}
};

Expand Down Expand Up @@ -454,13 +457,6 @@ class DLL_EXPORT HorizWidget : public QWidget
*/

CustomRubberBand *_rubberBand;
QRect _zoomRect;

/**
* @brief The rubber band origin.
*/

QPoint _rubberBandOrigin;

/**
* @brief The current ring spacing in km. This value is changed when we
Expand Down Expand Up @@ -628,6 +624,11 @@ class DLL_EXPORT HorizWidget : public QWidget
void _doRenderInvalidImages(QPainter &painter,
int index, VertWidget *vert);

// paint the user-selected zoom rectangle

void _setZoomRectPainter();
void _paintZoomRect();

};


Expand Down

0 comments on commit 58c0e63

Please sign in to comment.