Skip to content

Commit

Permalink
Alignment help
Browse files Browse the repository at this point in the history
  • Loading branch information
treideme committed Mar 7, 2024
1 parent 1a01eea commit d86e457
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions stereo_viewer/inc/ui/MainWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public Q_SLOTS:
void handleColormap();
void handleFocus();
void handleDeviceControl();
void setRuler(int value);

protected:
void ShowGenWindow( PvGenBrowserWnd *aWnd, PvGenParameterArray *aArray, const QString &aTitle );
Expand Down
3 changes: 2 additions & 1 deletion stereo_viewer/inc/ui/cameraview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class CameraView : public QLabel {
void setImage(QImage &img, bool redraw);
void addTarget(QRect &pos, QString &label, QColor &color, int width);
void addFeature(QPoint &pos, QColor &color, int width);
void setRuler(int val);
void reset();
void redrawPixmap();
void enableFocus(bool value);
Expand All @@ -52,7 +53,7 @@ class CameraView : public QLabel {
std::unique_ptr<QRubberBand> m_rubberband;
std::unique_ptr<QPixmap> m_last_frame;
bool m_scaled;

int m_ruler_pos;
};

} // namespace labforge::ui
Expand Down
18 changes: 18 additions & 0 deletions stereo_viewer/src/ui/cameraview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ void CameraView::reset() {

void CameraView::redrawPixmap() {
QPixmap m;

// Apply ruler
if(m_last_frame &&
m_ruler_pos > 0 &&
m_ruler_pos <
m_last_frame->height()) {
QPainter paint(m_last_frame.get());
paint.setPen(QPen(Qt::red, 3));
paint.drawLine(0, m_ruler_pos, m_last_frame->width(), m_ruler_pos);
}

if(m_scaled && m_last_frame) {
m = m_last_frame->copy(m_crop).scaled(size(), Qt::KeepAspectRatio, Qt::FastTransformation);
} else if(m_last_frame) {
Expand All @@ -154,4 +165,11 @@ void CameraView::redrawPixmap() {

void CameraView::enableFocus(bool value) {
m_focus.enable(value);
}

void CameraView::setRuler(int val) {
m_ruler_pos = val;
if(m_last_frame) {
redrawPixmap();
}
}
6 changes: 6 additions & 0 deletions stereo_viewer/src/viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
connect(cfg.chkColormap, &QCheckBox::stateChanged, this, &MainWindow::handleColormap);
connect(cfg.btnDeviceControl, &QPushButton::released, this, &MainWindow::handleDeviceControl);
connect(cfg.cbxFocus,&QCheckBox::stateChanged, this, &MainWindow::handleFocus);
connect(cfg.spinRuler, QOverload<int>::of(&QSpinBox::valueChanged), this, &MainWindow::setRuler);

// Force disconnected state
OnDisconnected();
Expand Down Expand Up @@ -675,6 +676,11 @@ void MainWindow::handleMonoData(bool is_disparity){
}
}

void MainWindow::setRuler(int value) {
cfg.widgetLeftSensor->setRuler(value);
cfg.widgetRightSensor->setRuler(value);
}

int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QIcon ico(":labforge.ico");
Expand Down
14 changes: 14 additions & 0 deletions stereo_viewer/stereo_viewer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,20 @@
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelRuler">
<property name="text">
<string>Ruler</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinRuler">
<property name="maximum">
<number>2160</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lblFormat">
<property name="text">
Expand Down

0 comments on commit d86e457

Please sign in to comment.