Algunos cambios de UI

This commit is contained in:
sebastian 2026-08-12 08:44:39 -03:00
parent c76b363d4b
commit c13794ada0
3 changed files with 20 additions and 58 deletions

View file

@ -42,10 +42,7 @@ void MainWindow::createUI()
btnOpen->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton)); btnOpen->setIcon(style()->standardIcon(QStyle::SP_DialogOpenButton));
btnOpen->setFixedHeight(36); btnOpen->setFixedHeight(36);
m_lblImgDimensions = new QLabel("Resolución: -", grpFile);
fileLayout->addWidget(btnOpen); fileLayout->addWidget(btnOpen);
fileLayout->addWidget(m_lblImgDimensions);
panelLayout->addWidget(grpFile); panelLayout->addWidget(grpFile);
// Calibration setup section // Calibration setup section
@ -61,15 +58,11 @@ void MainWindow::createUI()
formCalib->addRow("Largo Real Patrón:", m_spinCalibMm); formCalib->addRow("Largo Real Patrón:", m_spinCalibMm);
calibLayout->addLayout(formCalib); calibLayout->addLayout(formCalib);
m_btnCalibrate = new QPushButton("Fijar Calibración con Línea Actual", grpCalib); m_btnCalibrate = new QPushButton("Calibrar Escala", grpCalib);
m_btnCalibrate->setFixedHeight(34); m_btnCalibrate->setFixedHeight(34);
m_btnCalibrate->setStyleSheet("font-weight: bold; background-color: #2b5b84; color: white; border-radius: 4px;"); m_btnCalibrate->setStyleSheet("font-weight: bold; background-color: #2b5b84; color: white; border-radius: 4px;");
m_lblScale = new QLabel("Escala: Sin Calibrar", grpCalib);
m_lblScale->setStyleSheet("font-weight: bold; color: #ffb400;");
calibLayout->addWidget(m_btnCalibrate); calibLayout->addWidget(m_btnCalibrate);
calibLayout->addWidget(m_lblScale);
panelLayout->addWidget(grpCalib); panelLayout->addWidget(grpCalib);
// Measurement readout section // Measurement readout section
@ -79,25 +72,10 @@ void MainWindow::createUI()
m_lblMeasurement = new QLabel("Medida: -\nDistancia: - px", grpMeas); m_lblMeasurement = new QLabel("Medida: -\nDistancia: - px", grpMeas);
m_lblMeasurement->setStyleSheet("font-size: 14px; font-weight: bold; color: #ff5555; background: #1e1e24; padding: 10px; border-radius: 4px;"); m_lblMeasurement->setStyleSheet("font-size: 14px; font-weight: bold; color: #ff5555; background: #1e1e24; padding: 10px; border-radius: 4px;");
QPushButton *btnResetLine = new QPushButton("Centrar Línea en Pantalla", grpMeas);
measLayout->addWidget(m_lblMeasurement); measLayout->addWidget(m_lblMeasurement);
measLayout->addWidget(btnResetLine);
panelLayout->addWidget(grpMeas); panelLayout->addWidget(grpMeas);
// Instructions box
QGroupBox *grpHelp = new QGroupBox("Modo de Uso", panel);
QVBoxLayout *helpLayout = new QVBoxLayout(grpHelp);
QLabel *lblHelp = new QLabel(
"1. Coloque la línea roja de 1 px sobre el patrón de la imagen cuyo largo conozca.\n\n"
"2. Ingrese la distancia real en mm y presione 'Fijar Calibración'.\n\n"
"3. Arrastre esa misma línea a cualquier punto para medir la soldadura o distancia deseada.\n\n"
"• Rueda del mouse: Zoom.\n"
"• Clic derecho + arrastrar: Desplazarse.", grpHelp);
lblHelp->setWordWrap(true);
lblHelp->setStyleSheet("color: #ccc; font-size: 11px;");
helpLayout->addWidget(lblHelp);
panelLayout->addWidget(grpHelp);
panelLayout->addStretch(); panelLayout->addStretch();
@ -110,13 +88,8 @@ void MainWindow::createUI()
// Connect signals & slots // Connect signals & slots
connect(btnOpen, &QPushButton::clicked, this, &MainWindow::openImage); connect(btnOpen, &QPushButton::clicked, this, &MainWindow::openImage);
connect(m_btnCalibrate, &QPushButton::clicked, this, &MainWindow::onCalibrateClicked); connect(m_btnCalibrate, &QPushButton::clicked, this, &MainWindow::onCalibrateClicked);
connect(btnResetLine, &QPushButton::clicked, m_glWidget, &WeldOpenGLWidget::resetLine);
connect(m_glWidget, &WeldOpenGLWidget::calibrationUpdated, this, &MainWindow::updateCalibrationInfo);
connect(m_glWidget, &WeldOpenGLWidget::measurementUpdated, this, &MainWindow::updateMeasurementInfo); connect(m_glWidget, &WeldOpenGLWidget::measurementUpdated, this, &MainWindow::updateMeasurementInfo);
connect(m_glWidget, &WeldOpenGLWidget::imageLoaded, this, [this](int w, int h) {
m_lblImgDimensions->setText(QString("Resolución: %1 x %2 px").arg(w).arg(h));
});
} }
void MainWindow::createDefaultSampleImage() void MainWindow::createDefaultSampleImage()
@ -181,16 +154,7 @@ void MainWindow::onCalibrateClicked()
.arg(m_glWidget->mmPerPixel(), 0, 'g', 5)); .arg(m_glWidget->mmPerPixel(), 0, 'g', 5));
} }
void MainWindow::updateCalibrationInfo(double mmPerPx)
{
if (m_glWidget->isCalibrated() && mmPerPx > 0.0) {
m_lblScale->setText(QString("Escala: %1 mm/px").arg(mmPerPx, 0, 'g', 5));
m_lblScale->setStyleSheet("font-weight: bold; color: #55ff55;");
} else {
m_lblScale->setText("Escala: Sin Calibrar");
m_lblScale->setStyleSheet("font-weight: bold; color: #ffb400;");
}
}
void MainWindow::updateMeasurementInfo(double px, double mm) void MainWindow::updateMeasurementInfo(double px, double mm)
{ {

View file

@ -18,7 +18,6 @@ public:
private slots: private slots:
void openImage(); void openImage();
void onCalibrateClicked(); void onCalibrateClicked();
void updateCalibrationInfo(double mmPerPx);
void updateMeasurementInfo(double px, double mm); void updateMeasurementInfo(double px, double mm);
private: private:
@ -29,9 +28,7 @@ private:
QDoubleSpinBox *m_spinCalibMm = nullptr; QDoubleSpinBox *m_spinCalibMm = nullptr;
QPushButton *m_btnCalibrate = nullptr; QPushButton *m_btnCalibrate = nullptr;
QLabel *m_lblScale = nullptr;
QLabel *m_lblMeasurement = nullptr; QLabel *m_lblMeasurement = nullptr;
QLabel *m_lblImgDimensions = nullptr;
}; };
#endif // MAIN_WINDOW_H #endif // MAIN_WINDOW_H

View file

@ -157,17 +157,7 @@ void WeldOpenGLWidget::paintGL()
drawLineOverlay(painter, m_head, m_tail, color); drawLineOverlay(painter, m_head, m_tail, color);
} }
// Draw HUD info top-left corner
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(0, 0, 0, 170));
painter.drawRoundedRect(10, 10, 290, 60, 6, 6);
painter.setFont(QFont("Monospace", 9, QFont::Bold));
painter.setPen(m_isCalibrated ? QColor(255, 200, 50) : QColor(180, 180, 180));
painter.drawText(20, 30, m_isCalibrated ? QString("Escala: %1 mm/px").arg(m_mmPerPixel, 0, 'g', 4) : QString("Escala: Sin Calibrar"));
painter.setPen(QColor(255, 75, 75));
painter.drawText(20, 50, m_isCalibrated ? QString("Línea: %1 mm").arg(measuredMm(), 0, 'f', 2)
: QString("Línea: Sin Calibrar"));
} }
void WeldOpenGLWidget::drawLineOverlay(QPainter &painter, const QPointF &imgHead, const QPointF &imgTail, void WeldOpenGLWidget::drawLineOverlay(QPainter &painter, const QPointF &imgHead, const QPointF &imgTail,
@ -183,13 +173,24 @@ void WeldOpenGLWidget::drawLineOverlay(QPainter &painter, const QPointF &imgHead
painter.setPen(linePen); painter.setPen(linePen);
painter.drawLine(wHead, wTail); painter.drawLine(wHead, wTail);
// Compact drag handles (Circle & Square in pure red) // Compact drag handles (short perpendicular ticks)
double handleRadius = 5.0; QLineF line(wHead, wTail);
double dx = line.dx();
double dy = line.dy();
double len = line.length();
if (len > 0.0) {
double px = -dy / len;
double py = dx / len;
double tickHalfLen = 6.0; // short length perpendicular to measurement line
painter.setBrush(QBrush(color)); QPointF headP1 = wHead + QPointF(px * tickHalfLen, py * tickHalfLen);
painter.setPen(QPen(color, 1.0)); QPointF headP2 = wHead - QPointF(px * tickHalfLen, py * tickHalfLen);
painter.drawEllipse(wHead, handleRadius, handleRadius); painter.drawLine(headP1, headP2);
painter.drawRect(QRectF(wTail.x() - handleRadius, wTail.y() - handleRadius, handleRadius * 2, handleRadius * 2));
QPointF tailP1 = wTail + QPointF(px * tickHalfLen, py * tickHalfLen);
QPointF tailP2 = wTail - QPointF(px * tickHalfLen, py * tickHalfLen);
painter.drawLine(tailP1, tailP2);
}
// End labels // End labels
painter.setFont(QFont("Arial", 8, QFont::Bold)); painter.setFont(QFont("Arial", 8, QFont::Bold));