Skip to content

Commit

Permalink
Save and load live vlm coord transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Dec 3, 2024
1 parent 0736ce9 commit d7a7fdc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/mvc/LiveMapsElementsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ void LiveMapsElementsWidget::createLayout()
_vlm_widget->setAvailScans(&_avail_scans);
gstar::CoordinateModel *coord_model = new gstar::CoordinateModel(&_linear_trans);
_vlm_widget->setCoordinateModel(coord_model);
_vlm_widget->load_live_coord_settings();
connect(_vlm_widget, &VLM_Widget::onScanUpdated, this, &LiveMapsElementsWidget::callQueueScan);

_scan_queue_widget = new ScanQueueWidget();
Expand Down
30 changes: 29 additions & 1 deletion src/mvc/VLM_Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2423,13 +2423,41 @@ void VLM_Widget::updatedPixelToLight(double x, double y, double z)

}

/*--------------------------------------------------------------------------*/
//--------------------------------------------------------------------------

void VLM_Widget::load_live_coord_settings()
{
QMap<QString, double> vars;
QStringList names = Preferences::inst()->getValue(STR_PRF_LiveCoefficientNames).toStringList();
QStringList values = Preferences::inst()->getValue(STR_PRF_LiveCoefficientVals).toStringList();
if(names.size() == values.size())
{
for (int i = 0; i < names.size(); i++)
{
vars.insert(names.at(i), values.at(i).toDouble());
}
}
m_lightToMicroCoordModel->getTransformer()->Init(vars);

}

//--------------------------------------------------------------------------

void VLM_Widget::useUpdatedSolverVariables(const QMap<QString, double> vars)
{

m_lightToMicroCoordModel->getTransformer()->Init(vars);

QStringList names;
QStringList values;
for (auto name : vars.keys())
{
names.append(name);
values.append(QString::number(vars.value(name)));
}
Preferences::inst()->setValue(STR_PRF_LiveCoefficientNames, names);
Preferences::inst()->setValue(STR_PRF_LiveCoefficientVals, values);

}

/*--------------------------------------------------------------------------*/
Expand Down
2 changes: 1 addition & 1 deletion src/mvc/VLM_Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class VLM_Widget
// TODO: make sure to update all ScansRegionGraphicsItems with new pointer
void setAvailScans(std::map<QString, BlueskyPlan> * avail_scans) { _avail_scans = avail_scans;}


void load_live_coord_settings();

public slots:

Expand Down
2 changes: 2 additions & 0 deletions src/preferences/Preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ Preferences::Preferences()
{STR_PRF_SHOW_DATASET_ON_LOAD, QVariant()},
{STR_PREF_RADIO_LOAD_SELECTED_OPTION, QVariant()},
{STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION, QVariant()},
{STR_PRF_LiveCoefficientNames, QVariant()},
{STR_PRF_LiveCoefficientVals, QVariant()},
{STR_SAVE_QSERVER_HISTORY_LOCATION, QVariant()}
};
load();
Expand Down
2 changes: 2 additions & 0 deletions src/preferences/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
#define STR_PREF_RADIO_LOAD_SELECTED_OPTION "Load_Selected_Opt"
#define STR_PREF_SPRECTRA_CONTROLS_HORIZONTAL_OPTION "Spectra_Controls_Horizontal"
#define STR_SAVE_QSERVER_HISTORY_LOCATION "Save_Qserver_History_Location"
#define STR_PRF_LiveCoefficientNames "LiveCoefficientName"
#define STR_PRF_LiveCoefficientVals "LiveCoefficientVals"

/**
* @brief Read and save preferences between application restarts, the vaule key
Expand Down

0 comments on commit d7a7fdc

Please sign in to comment.