From 0736ce9ad5559fdc605c4fc652a418b8ea859f91 Mon Sep 17 00:00:00 2001 From: Arthur Glowacki Date: Mon, 2 Dec 2024 12:53:52 -0600 Subject: [PATCH] Connected light to microprobe coords --- src/core/uProbeX.cpp | 11 +- src/gstar/CoordinateWidget.h | 2 + src/mvc/LiveMapsElementsWidget.cpp | 2 + src/mvc/LiveMapsElementsWidget.h | 2 + src/mvc/ScanQueueWidget.cpp | 7 - src/mvc/ScanQueueWidget.h | 2 - src/mvc/SolverProfileWidget.cpp | 65 ++------ src/mvc/SolverProfileWidget.h | 14 +- src/mvc/SolverWidget.cpp | 14 +- src/mvc/VLM_Widget.cpp | 222 +++++--------------------- src/mvc/VLM_Widget.h | 19 +-- src/preferences/ProfileTable.cpp | 29 ++-- src/preferences/ProfileTable.h | 8 +- src/solver/LinearCoordTransformer.cpp | 8 +- 14 files changed, 86 insertions(+), 319 deletions(-) diff --git a/src/core/uProbeX.cpp b/src/core/uProbeX.cpp index 6a4f6e1..0e906de 100644 --- a/src/core/uProbeX.cpp +++ b/src/core/uProbeX.cpp @@ -442,11 +442,7 @@ void uProbeX::make_VLM_Window(VLM_Model* model) VLM_Widget* widget = new VLM_Widget(); widget->resize(1027, 768); widget->setModel(model); - /* TODO: connect properly - connect(widget, &VLM_Widget::solverStart, this, &uProbeX::solverStart); - connect(widget, &VLM_Widget::solverVariableUpdate, this, &uProbeX::solverVariableUpdate); - connect(widget, &VLM_Widget::cancelSolverVariableUpdate, this, &uProbeX::cancelSolverVariableUpdate); -*/ + SubWindow* w = new SubWindow(m_mdiArea); connect(w, &SubWindow::windowClosing, this, &uProbeX::subWindowClosed); @@ -520,11 +516,6 @@ void uProbeX::make_VLM_Window(QString path, bool newWindow) return; } - /*TODO: connect properly - connect(widget, &VLM_Widget::solverStart, this, &uProbeX::solverStart); - connect(widget, &VLM_Widget::solverVariableUpdate, this, &uProbeX::solverVariableUpdate); - connect(widget, &VLM_Widget::cancelSolverVariableUpdate, this, &uProbeX::cancelSolverVariableUpdate); - */ SubWindow* w = nullptr; if (newWindow == true) { diff --git a/src/gstar/CoordinateWidget.h b/src/gstar/CoordinateWidget.h index 797b181..16a677f 100644 --- a/src/gstar/CoordinateWidget.h +++ b/src/gstar/CoordinateWidget.h @@ -101,6 +101,8 @@ namespace gstar */ void setnullptr(); + CoordinateModel* model() { return m_model; } + private: /** diff --git a/src/mvc/LiveMapsElementsWidget.cpp b/src/mvc/LiveMapsElementsWidget.cpp index 54ee6ba..058bb7c 100644 --- a/src/mvc/LiveMapsElementsWidget.cpp +++ b/src/mvc/LiveMapsElementsWidget.cpp @@ -142,6 +142,8 @@ void LiveMapsElementsWidget::createLayout() _vlm_widget = new VLM_Widget(); _vlm_widget->setAvailScans(&_avail_scans); + gstar::CoordinateModel *coord_model = new gstar::CoordinateModel(&_linear_trans); + _vlm_widget->setCoordinateModel(coord_model); connect(_vlm_widget, &VLM_Widget::onScanUpdated, this, &LiveMapsElementsWidget::callQueueScan); _scan_queue_widget = new ScanQueueWidget(); diff --git a/src/mvc/LiveMapsElementsWidget.h b/src/mvc/LiveMapsElementsWidget.h index 2fa1ecc..b801e18 100644 --- a/src/mvc/LiveMapsElementsWidget.h +++ b/src/mvc/LiveMapsElementsWidget.h @@ -132,6 +132,8 @@ public slots: zmq::context_t *_context; + LinearCoordTransformer _linear_trans; + int _num_images; }; diff --git a/src/mvc/ScanQueueWidget.cpp b/src/mvc/ScanQueueWidget.cpp index 35126a1..2527705 100644 --- a/src/mvc/ScanQueueWidget.cpp +++ b/src/mvc/ScanQueueWidget.cpp @@ -250,13 +250,6 @@ void ScanQueueWidget::on_remove_scan() //--------------------------------------------------------------------------- -void ScanQueueWidget::onQueueKeyPress(QKeyEvent* event) -{ - -} - -//--------------------------------------------------------------------------- - void ScanQueueWidget::updateQueuedItems(std::vector &finished_plans, std::vector &queued_plans, BlueskyPlan &running_plan) { _scan_queue_table_model->setAllData(finished_plans, queued_plans, running_plan); diff --git a/src/mvc/ScanQueueWidget.h b/src/mvc/ScanQueueWidget.h index 7fc6a56..9276681 100644 --- a/src/mvc/ScanQueueWidget.h +++ b/src/mvc/ScanQueueWidget.h @@ -78,8 +78,6 @@ public slots: void on_remove_scan(); - void onQueueKeyPress(QKeyEvent*); - protected: /** diff --git a/src/mvc/SolverProfileWidget.cpp b/src/mvc/SolverProfileWidget.cpp index b5446df..72b98b8 100644 --- a/src/mvc/SolverProfileWidget.cpp +++ b/src/mvc/SolverProfileWidget.cpp @@ -64,12 +64,10 @@ void SolverProfileWidget::addProfile(QString name, QString desc, QMap attr; QMapIterator i(coef); - while (i.hasNext()) { + while (i.hasNext()) + { i.next(); - attr.push_back(Attribute(i.key(), - QString::number(i.value()), - "", - true)); + attr.push_back(Attribute(i.key(), QString::number(i.value()), "", true)); } Profile profile; @@ -82,17 +80,11 @@ void SolverProfileWidget::addProfile(QString name, QString desc, QMapaddNewItem(name, desc); - connect(m_profileTable, - SIGNAL(addItem(QString, QString)), - this, - SLOT(addProfileItem(QString, QString))); + connect(m_profileTable, &ProfileTable::addItem2, this, &SolverProfileWidget::addProfileItem); } _solverParamWidget->removeCoefficientItems(); @@ -118,22 +110,10 @@ void SolverProfileWidget::createCompontent() m_profileTable = new ProfileTable(); - connect(m_profileTable, - SIGNAL(addItem(QString, QString)), - this, - SLOT(addProfileItem(QString, QString))); - connect(m_profileTable, - SIGNAL(removeItem(int)), - this, - SLOT(removeProfileItem(int))); - connect(m_profileTable, - SIGNAL(editItem(int, QString)), - this, - SLOT(editProfileItem(int, QString))); - connect(m_profileTable, - SIGNAL(switchItem(const QItemSelection&, const QItemSelection&)), - this, - SLOT(switchProfileItem(const QItemSelection&, const QItemSelection&))); + connect(m_profileTable, &ProfileTable::addItem2, this, &SolverProfileWidget::addProfileItem); + connect(m_profileTable, &ProfileTable::removeItem, this, &SolverProfileWidget::removeProfileItem); + connect(m_profileTable, &ProfileTable::editItem, this, &SolverProfileWidget::editProfileItem); + connect(m_profileTable, &ProfileTable::switchItem, this, &SolverProfileWidget::switchProfileItem); _solverParamWidget = new SolverParameterWidget(); connect(_solverParamWidget, @@ -203,23 +183,15 @@ void SolverProfileWidget::createLayOut() */ mainLayout->addRow(_solverParamWidget); m_btnRunSolver = new QPushButton("Run Solver"); - connect(m_btnRunSolver, - SIGNAL(pressed()), - this, - SLOT(runSolver())); + connect(m_btnRunSolver, &QPushButton::pressed, this, &SolverProfileWidget::runSolver); mainLayout->addRow(m_btnRunSolver); QHBoxLayout* hLayout2 = new QHBoxLayout(); m_btnSave = new QPushButton("Save"); - connect(m_btnSave, - SIGNAL(pressed()), - this, - SLOT(accept())); + /// connect(m_btnSave, &QPushButton::pressed, this, &SolverProfileWidget::saveSolverVariableUpdate); + m_btnCancel = new QPushButton("Cancel"); - connect(m_btnCancel, - SIGNAL(pressed()), - this, - SLOT(reject())); + /// connect(m_btnCancel, &QPushButton::pressed, this, &SolverProfileWidget::cancelSolverVariableUpdate); hLayout2->addWidget(m_btnSave); hLayout2->addWidget(m_btnCancel); @@ -653,15 +625,8 @@ void SolverProfileWidget::runSolver() m_solverWidget = nullptr; m_solverWidget = new SolverWidget(this); - connect(m_solverWidget, - SIGNAL(useUpdatedVariables(const QMap)), - this, - SLOT(useUpdatedSolverVariables(const QMap ))); - - connect(m_solverWidget, - SIGNAL(cancelUpdatedVariables()), - this, - SLOT(cancelUpdatedSolverVariables())); + connect(m_solverWidget, &SolverWidget::useUpdatedVariables, this, &SolverProfileWidget::useUpdatedSolverVariables); + connect(m_solverWidget, &SolverWidget::cancelUpdatedVariables, this, &SolverProfileWidget::cancelUpdatedSolverVariables); newMinCoefs = _solver->getMinCoef(); m_solverWidget->setCoefs(minCoefs, newMinCoefs); diff --git a/src/mvc/SolverProfileWidget.h b/src/mvc/SolverProfileWidget.h index 9f85a4d..040c101 100644 --- a/src/mvc/SolverProfileWidget.h +++ b/src/mvc/SolverProfileWidget.h @@ -141,17 +141,9 @@ class SolverProfileWidget */ void solverStart(); - /** - * @brief SolverVariableUpdate - * @param valX - * @param valY - */ - void solverVariableUpdate(double valX, double valY); - - /** - * @brief CancelSolverVariableUpdate - */ - void cancelSolverVariableUpdate(); + void useUpdatedSolverVariables(const QMap); + + void cancelUpdatedSolverVariables(); private: diff --git a/src/mvc/SolverWidget.cpp b/src/mvc/SolverWidget.cpp index e914772..9223926 100644 --- a/src/mvc/SolverWidget.cpp +++ b/src/mvc/SolverWidget.cpp @@ -39,22 +39,12 @@ SolverWidget::SolverWidget(QWidget *parent) : QDialog(parent) QLabel* lblStatus = new QLabel("Status: "); m_lblStatus = new QLabel(""); - //Create Prepend plus minus buttons m_btnCancel = new QPushButton("Cancel"); m_btnUse = new QPushButton("Use New Values"); - connect(m_btnCancel, - SIGNAL(clicked()), - this, - SLOT(cancel())); - - - connect(m_btnUse, - SIGNAL(clicked()), - this, - SLOT(useNewValues())); - + connect(m_btnCancel, &QPushButton::clicked, this, &SolverWidget::cancel); + connect(m_btnUse, &QPushButton::clicked, this, &SolverWidget::useNewValues); QHBoxLayout* buttonLayout = new QHBoxLayout(); buttonLayout->setSpacing(5); diff --git a/src/mvc/VLM_Widget.cpp b/src/mvc/VLM_Widget.cpp index 96834c0..6da23f8 100644 --- a/src/mvc/VLM_Widget.cpp +++ b/src/mvc/VLM_Widget.cpp @@ -375,13 +375,15 @@ void VLM_Widget::_createSolver() _createLightToMicroCoords(id); - - if (id == ID_LINEAR) +/* +if (id == ID_LINEAR) { LinearSolver* ls = new LinearSolver(); m_solver->setImpl(ls); } - else if (id == ID_NELDER_MEAD) + else +*/ + if (id == ID_LINEAR || id == ID_NELDER_MEAD) { NelderMeadSolver* nm = new NelderMeadSolver(); @@ -1036,7 +1038,7 @@ void VLM_Widget::linkRegionToDataset() void VLM_Widget::cancelUpdatedSolverVariables() { - emit cancelSolverVariableUpdate(); + //emit cancelSolverVariableUpdate(); } @@ -1047,10 +1049,7 @@ void VLM_Widget::createCalibrationTab() m_calTreeModel = new gstar::AnnotationTreeModel(); - connect(m_calTreeModel, - SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - this, - SLOT(calModelDataChanged(const QModelIndex &, const QModelIndex &))); + connect(m_calTreeModel, &gstar::AnnotationTreeModel::dataChanged, this, &VLM_Widget::calModelDataChanged); m_calSelectionModel = new QItemSelectionModel(m_calTreeModel); @@ -1065,70 +1064,27 @@ void VLM_Widget::createCalibrationTab() // m_calAnnoTreeView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); - connect(m_calAnnoTreeView, - SIGNAL(customContextMenuRequested(const QPoint &)), - this, - SLOT(treeContextMenu(const QPoint &))); + connect(m_calAnnoTreeView, &QTreeView::customContextMenuRequested, this, &VLM_Widget::treeContextMenu); - connect(m_calAnnoTreeView, - SIGNAL(doubleClicked(const QModelIndex &)), - this, - SLOT(treeDoubleClicked(const QModelIndex &))); + connect(m_calAnnoTreeView, &QTreeView::doubleClicked, this, &VLM_Widget::treeDoubleClicked); m_btnAddCalibration = new QPushButton("Add Calibration Point"); - connect(m_btnAddCalibration, - SIGNAL(clicked()), - this, - SLOT(addCalibration())); + connect(m_btnAddCalibration, &QPushButton::clicked, this, &VLM_Widget::addCalibration); m_btnAddTopWindowPoints = new QPushButton("Add Top Window Points"); - connect(m_btnAddTopWindowPoints, - SIGNAL(clicked()), - this, - SLOT(addTopWindowPoints())); + connect(m_btnAddTopWindowPoints, &QPushButton::clicked, this, &VLM_Widget::addTopWindowPoints); m_btnAddBottomWindowPoints = new QPushButton("Add Bottom Window Points"); - connect(m_btnAddBottomWindowPoints, - SIGNAL(clicked()), - this, - SLOT(addTopWindowPoints())); + connect(m_btnAddBottomWindowPoints, &QPushButton::clicked, this, &VLM_Widget::addTopWindowPoints); m_btnRunSolver = new QPushButton("Update Transform"); - connect(m_btnRunSolver, - SIGNAL(clicked()), - this, - SLOT(openSolver())); -/* - QLabel* lblXOffset = new QLabel("2xfm:X "); - m_xOffset = new QLineEdit(); - connect(m_xOffset, - SIGNAL(editingFinished()), - this, - SLOT(offsetReturnPressed())); - connect(m_xOffset, - SIGNAL(returnPressed()), - this, - SLOT(offsetReturnPressed())); + connect(m_btnRunSolver, &QPushButton::clicked, this, &VLM_Widget::openSolver); - QLabel* lblYOffset = new QLabel("2xfm:Y "); - m_yOffset = new QLineEdit(); - connect(m_yOffset, - SIGNAL(editingFinished()), - this, - SLOT(offsetReturnPressed())); - connect(m_xOffset, - SIGNAL(returnPressed()), - this, - SLOT(offsetReturnPressed())); -*/ QVBoxLayout* infoLayout = new QVBoxLayout(); QHBoxLayout* buttonLayout = new QHBoxLayout(); QHBoxLayout* buttonLayout2 = new QHBoxLayout(); QHBoxLayout* offsetLayout = new QHBoxLayout(); -// offsetLayout->addWidget(lblXOffset); -// offsetLayout->addWidget(m_xOffset); -// offsetLayout->addWidget(lblYOffset); -// offsetLayout->addWidget(m_yOffset); + buttonLayout->addWidget(m_btnAddCalibration); buttonLayout->addWidget(m_btnRunSolver); buttonLayout2->addWidget(m_btnAddTopWindowPoints); @@ -1847,67 +1803,6 @@ void VLM_Widget::microModelDataChanged(const QModelIndex& topLeft, //--------------------------------------------------------------------------- -void VLM_Widget::offsetReturnPressed() -{ - /* - bool ok; - double valX, valY; - - QString sxOff = m_xOffset->text(); - QString syOff = m_yOffset->text(); - - QMessageBox msgBox; - msgBox.setStandardButtons(QMessageBox::Ok); - - ok = false; - valX = sxOff.toDouble(&ok); - if(ok && m_lightToMicroCoordModel != nullptr) - { - - if(false == m_lightToMicroCoordModel->setTransformerVariable( - CoordinateTransformGlobals::keyToString( - CoordinateTransformGlobals::m2xfm_x), valX)) - { - msgBox.setText("Error setting value!"); - msgBox.exec(); - } - - } - else - { - m_xOffset->setText("0"); - } - - ok = false; - valY = syOff.toDouble(&ok); - if(ok && m_lightToMicroCoordModel != nullptr) - { - - if(false == m_lightToMicroCoordModel->setTransformerVariable( - CoordinateTransformGlobals::keyToString( - CoordinateTransformGlobals::m2xfm_y), valY)) - { - QMessageBox msgBox; - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText("Error setting value!"); - msgBox.exec(); - } - - } - else - { - m_yOffset->setText("0"); - } - - - emit solverVariableUpdate(valX, valY); - - updateTreeView(); -*/ -} - -//--------------------------------------------------------------------------- - void VLM_Widget::setModel(VLM_Model* model) { if (_model != model) @@ -1931,10 +1826,8 @@ void VLM_Widget::preferenceChanged() { // Set the precision - m_coordinateModel->setTransformerPrecision( - Preferences::inst()->getValue(STR_PRF_DecimalPrecision).toInt()); - m_lightToMicroCoordModel->setTransformerPrecision( - Preferences::inst()->getValue(STR_PRF_DecimalPrecision).toInt()); + m_coordinateModel->setTransformerPrecision( Preferences::inst()->getValue(STR_PRF_DecimalPrecision).toInt()); + m_lightToMicroCoordModel->setTransformerPrecision( Preferences::inst()->getValue(STR_PRF_DecimalPrecision).toInt()); /* // Set the value in the calibration text linedit box if(m_lightToMicroCoordModel != nullptr) @@ -2037,12 +1930,15 @@ void VLM_Widget::restoreMarkerLoaded() } //--------------------------------------------------------------------------- - +/* void VLM_Widget::openSolver() { QList< QMap > coordPoints; SolverProfileWidget solverWidget; + connect(&solverWidget, &SolverWidget::useUpdatedVariables, this, &VLM_Widget::useUpdatedSolverVariables ); + connect(&solverWidget, &SolverWidget::cancelUpdatedVariables, this, &VLM_Widget::cancelUpdatedSolverVariables ); + if (getMarkerCoordinatePoints(coordPoints)) { solverWidget.setCoordinatePoints(&coordPoints); @@ -2053,10 +1949,11 @@ void VLM_Widget::openSolver() } } +*/ //--------------------------------------------------------------------------- -void VLM_Widget::runSolver() +void VLM_Widget::openSolver() { emit solverStart(); @@ -2069,46 +1966,18 @@ void VLM_Widget::runSolver() } m_solver->setCoordPoints(coordPoints); - QMap minCoefs; + QMap newMinCoefs; - if(m_lightToMicroCoordModel != nullptr) - { - double val; - /* - QString fmx = CoordinateTransformGlobals::keyToString( - CoordinateTransformGlobals::m2xfm_x); - QString fmy = CoordinateTransformGlobals::keyToString( - CoordinateTransformGlobals::m2xfm_y); - - if(m_lightToMicroCoordModel->getTransformerVariable(fmx, &val)) - { - minCoefs.insert(fmx, val); - } - else - { - QMessageBox::critical(0, "uProbeX", "Error: Could not find m2xfm_x variable in transfomer!"); - return; - } - if(m_lightToMicroCoordModel->getTransformerVariable(fmy, &val)) - { - minCoefs.insert(fmy, val); - } - else - { - QMessageBox::critical(0, "uProbeX", "Error: Could not find m2xfm_y variable in transfomer!"); - return; - } - */ - } - else + if(m_lightToMicroCoordModel == nullptr) { QMessageBox::critical(0, "uProbeX", "Error: Light to Micro Transformation Model not set!"); return; } ITransformer *trans = m_lightToMicroCoordModel->getTransformer(); + QMap minCoefs = trans->getAllCoef(); m_solver->setTransformer(trans); - m_solver->setAllCoef(trans->getAllCoef()); + m_solver->setAllCoef(minCoefs); m_solver->setMinCoef(minCoefs); QApplication::setOverrideCursor(Qt::WaitCursor); @@ -2120,9 +1989,8 @@ void VLM_Widget::runSolver() m_solverWidget = nullptr; m_solverWidget = new SolverWidget(); - //connect(m_solverWidget, &SolverWidget::useUpdatedVariables, this, SLOT(useUpdatedSolverVariables) ); - - //connect(m_solverWidget, &SolverWidget::cancelUpdatedVariables), this, SLOT(cancelUpdatedSolverVariables) ); + connect(m_solverWidget, &SolverWidget::useUpdatedVariables, this, &VLM_Widget::useUpdatedSolverVariables ); + connect(m_solverWidget, &SolverWidget::cancelUpdatedVariables, this, &VLM_Widget::cancelUpdatedSolverVariables ); newMinCoefs = m_solver->getMinCoef(); m_solverWidget->setCoefs(minCoefs, newMinCoefs); @@ -2284,10 +2152,7 @@ void VLM_Widget::setCoordinateModel(gstar::CoordinateModel *model) if (m_coordinateModel != nullptr) { - disconnect(m_coordinateModel, - SIGNAL(transformOutput(double, double, double)), - this, - SLOT(updatedPixelToLight(double, double, double))); + disconnect(m_coordinateModel, &gstar::CoordinateModel::transformOutput, this, &VLM_Widget::updatedPixelToLight); } m_coordinateModel = model; @@ -2300,10 +2165,7 @@ void VLM_Widget::setCoordinateModel(gstar::CoordinateModel *model) { m_imageViewWidget->setCoordinateModel(model); - connect(m_coordinateModel, - SIGNAL(transformOutput(double, double, double)), - this, - SLOT(updatedPixelToLight(double,double,double))); + connect(m_coordinateModel, &gstar::CoordinateModel::transformOutput, this, &VLM_Widget::updatedPixelToLight); } } @@ -2565,22 +2427,9 @@ void VLM_Widget::updatedPixelToLight(double x, double y, double z) void VLM_Widget::useUpdatedSolverVariables(const QMap vars) { - /* - if(vars.contains(CoordinateTransformGlobals::keyToString( - CoordinateTransformGlobals::m2xfm_x)) - && vars.contains(CoordinateTransformGlobals::keyToString( - CoordinateTransformGlobals::m2xfm_y)) ) - { - double newX = vars[CoordinateTransformGlobals::keyToString( - CoordinateTransformGlobals::m2xfm_x)]; - double newY = vars[CoordinateTransformGlobals::keyToString( - CoordinateTransformGlobals::m2xfm_y)]; - - m_xOffset->setText(QString::number(newX)); - m_yOffset->setText(QString::number(newY)); - offsetReturnPressed(); - } - */ + + m_lightToMicroCoordModel->getTransformer()->Init(vars); + } /*--------------------------------------------------------------------------*/ @@ -2648,7 +2497,10 @@ void VLM_Widget::widgetChanged(bool enable) } /* -void solverVariableUpdate(double valX, double valY); +void VLM_Widget::solverVariableUpdate() +{ + +} void uProbeX::solverVariableUpdate(double valX, double valY) { diff --git a/src/mvc/VLM_Widget.h b/src/mvc/VLM_Widget.h index a934625..8d07ab1 100644 --- a/src/mvc/VLM_Widget.h +++ b/src/mvc/VLM_Widget.h @@ -250,11 +250,6 @@ protected slots: */ void microModelDataChanged(const QModelIndex &, const QModelIndex &); - /** - * @brief offsetReturnPressed - */ - void offsetReturnPressed(); - /** * @brief cancelUpdatedSolverVariables */ @@ -263,7 +258,7 @@ protected slots: /** * @brief runSolver */ - void runSolver(); + // void runSolver(); /** * @brief openSolver @@ -392,7 +387,7 @@ protected slots: * @param valX * @param valY */ - void solverVariableUpdate(double valX, double valY); + void solverVariableUpdate(); /** * @brief CancelSolverVariableUpdate @@ -642,16 +637,6 @@ protected slots: */ SolverWidget* m_solverWidget; - /** - * @brief m_xOffset - */ - //QLineEdit* m_xOffset; - - /** - * @brief m_xyffset - */ - //QLineEdit* m_yOffset; - /** * @brief m_pathFile */ diff --git a/src/preferences/ProfileTable.cpp b/src/preferences/ProfileTable.cpp index f5868f0..53acbbe 100644 --- a/src/preferences/ProfileTable.cpp +++ b/src/preferences/ProfileTable.cpp @@ -47,21 +47,18 @@ void ProfileTable::addNewItem(QString name, QString desc) // Check valid model if (m_solverModel == nullptr) return; - // Get row number for new item - int row = m_solverModel->rowCount(QModelIndex()) + 1; - // Add item m_solverModel->addSolverAttr(name, "0.0", desc, true); // Enable remove button if (m_solverModel->rowCount(QModelIndex()) > 0) m_btnRemove->setEnabled(true); - emit addItem(name, desc); + emit addItem2(name, desc); } //--------------------------------------------------------------------------- -void ProfileTable::addItem() +void ProfileTable::onAddItem() { addNewItem("Name", "Desc"); @@ -131,23 +128,15 @@ void ProfileTable::createComponents() m_solverTable->setSelectionModel(m_selectionModel); m_solverTable->setFixedHeight(100); - connect(m_solverModel, - SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), - this, - SLOT(editItem(const QModelIndex&, const QModelIndex&))); - - connect(m_selectionModel, - SIGNAL(selectionChanged(const QItemSelection &, - const QItemSelection &)), - this, - SIGNAL(switchItem(const QItemSelection &, - const QItemSelection &))); + connect(m_solverModel, &AttributeTableModel::dataChanged, this, &ProfileTable::onEditItem); + + connect(m_selectionModel, &QItemSelectionModel::selectionChanged, this, &ProfileTable::switchItem); // Add button m_btnAdd = new QPushButton; m_btnAdd -> setIcon(QIcon(":images/list-add.png")); m_btnAdd -> setFlat(true); m_btnAdd -> setFixedSize(32, 32); - connect(m_btnAdd, SIGNAL(clicked()), this, SLOT(addItem())); + connect(m_btnAdd, &QPushButton::clicked, this, &ProfileTable::onAddItem); // Remove button m_btnRemove = new QPushButton; @@ -157,7 +146,7 @@ void ProfileTable::createComponents() m_btnRemove->setEnabled(true); m_btnRemove -> setFixedSize(32, 32); - connect(m_btnRemove, SIGNAL(clicked()), this, SLOT(removeItem())); + connect(m_btnRemove, &QPushButton::clicked, this, &ProfileTable::onRemoveItem); // Layout for buttons QHBoxLayout* buttonLayout = new QHBoxLayout; @@ -177,7 +166,7 @@ void ProfileTable::createComponents() //--------------------------------------------------------------------------- -void ProfileTable::editItem(const QModelIndex& topLeft, const QModelIndex& bottomRight) +void ProfileTable::onEditItem(const QModelIndex& topLeft, const QModelIndex& bottomRight) { if(!topLeft.isValid()) @@ -232,7 +221,7 @@ QList ProfileTable::getSolverAttrs() //--------------------------------------------------------------------------- -void ProfileTable::removeItem() +void ProfileTable::onRemoveItem() { // Check valid model diff --git a/src/preferences/ProfileTable.h b/src/preferences/ProfileTable.h index 51984eb..030aa67 100644 --- a/src/preferences/ProfileTable.h +++ b/src/preferences/ProfileTable.h @@ -91,7 +91,7 @@ class ProfileTable * @param name * @param desc */ - void addItem(QString name, QString desc); + void addItem2(QString name, QString desc); /** * @brief deleteItem @@ -131,20 +131,20 @@ private slots: /** * @brief Internal slot to add an item. Called by the add item button. */ - void addItem(); + void onAddItem(); /** * @brief Internal slot to remove the selected item. Called by the remove * item button. */ - void removeItem(); + void onRemoveItem(); /** * @brief editItem * @param * @param */ - void editItem(const QModelIndex&, const QModelIndex&); + void onEditItem(const QModelIndex&, const QModelIndex&); private: diff --git a/src/solver/LinearCoordTransformer.cpp b/src/solver/LinearCoordTransformer.cpp index cd0e80c..9b2095c 100644 --- a/src/solver/LinearCoordTransformer.cpp +++ b/src/solver/LinearCoordTransformer.cpp @@ -40,7 +40,13 @@ QMap LinearCoordTransformer::getAllCoef() bool LinearCoordTransformer::Init(QMap globalVars) { - + for(auto &itr : _coefs.keys()) + { + if(globalVars.count(itr) > 0) + { + _coefs[itr] = globalVars.value(itr); + } + } return true; }