diff --git a/src/mvc/BlueskyComm.h b/src/mvc/BlueskyComm.h index f841208..011eac4 100644 --- a/src/mvc/BlueskyComm.h +++ b/src/mvc/BlueskyComm.h @@ -527,7 +527,7 @@ class BlueskyComm : public QThread { return ret; } - running_plan.name = ""; + running_plan.type = ""; running_plan.uuid = ""; zmq::message_t message; QByteArray msg_arr = gen_send_mesg("queue_get", nullptr); @@ -658,11 +658,29 @@ class BlueskyComm : public QThread QJsonObject running_item = reply["running_item"].toObject(); if(running_item.contains("name")) { - running_plan.name = running_item["name"].toString(); + running_plan.type = running_item["name"].toString(); } if(running_item.contains("args")) { - //running_plan.name = running_item["args"].toString(); + QJsonObject kwargs = running_item["args"].toObject(); + for(auto pitr : kwargs.keys()) + { + BlueskyParam bsp; + bsp.name = pitr; + + if(kwargs.value(pitr).isDouble()) + { + double p = kwargs.value(pitr).toDouble(); + bsp.default_val = QString::number(p); + bsp.kind = BlueskyParamType::Numeral; + } + else if( kwargs.value(pitr).isString() ) + { + bsp.default_val = kwargs.value(pitr).toString(); + bsp.kind = BlueskyParamType::String; + } + running_plan.parameters[pitr] = bsp; + } } if(running_item.contains("kwargs")) { @@ -671,7 +689,18 @@ class BlueskyComm : public QThread { BlueskyParam bsp; bsp.name = pitr; - bsp.default_val = kwargs[pitr].toString(); + + if(kwargs.value(pitr).isDouble()) + { + double p = kwargs.value(pitr).toDouble(); + bsp.default_val = QString::number(p); + bsp.kind = BlueskyParamType::Numeral; + } + else if( kwargs.value(pitr).isString() ) + { + bsp.default_val = kwargs.value(pitr).toString(); + bsp.kind = BlueskyParamType::String; + } running_plan.parameters[pitr] = bsp; } } @@ -683,6 +712,14 @@ class BlueskyComm : public QThread { running_plan.uuid = running_item["item_uid"].toString(); } + if(running_item.contains("properties")) + { + QJsonObject props = running_item["properties"].toObject(); + if(props.contains("time_start")) + { + running_plan.result.time_start = props["time_start"].toDouble(); + } + } } /* if(reply.contains("plan_queue_uid")) @@ -695,6 +732,162 @@ class BlueskyComm : public QThread //--------------------------------------------------------------------------- + bool get_scan_history(QString &msg, std::vector &finished_plans) + { + bool ret = false; + if(_zmq_comm_socket == nullptr) + { + return ret; + } + zmq::message_t message; + QByteArray msg_arr = gen_send_mesg("history_get", nullptr); + _zmq_comm_socket->send(msg_arr.data(), msg_arr.length()); + + _zmq_comm_socket->recv(&message); + + QJsonObject reply = QJsonDocument::fromJson(QString::fromUtf8((char*)message.data(), message.size()).toUtf8()).object(); + if(reply.contains("success")) + { + QString strReply = reply["success"].toString(); + if(strReply.length() > 0) + { + if(strReply == "true") + { + ret = true; + } + } + else + { + ret = reply["success"].toBool(); + } + } + if(reply.contains("items")) + { + /* + {'name': 'count', + 'args': [['det1', 'det2']], + 'kwargs': {'num': 10, 'delay': 1}, + 'item_type': 'plan', + 'user': 'qserver-cli', + 'user_group': 'primary', + 'item_uid': 'f66d959f-12e2-43a5-a67d-01b3d40b4f43'} + */ + finished_plans.clear(); + QJsonArray items = reply["items"].toArray(); + for( auto itr2 : items) + { + BlueskyPlan plan; + QJsonObject param = itr2.toObject(); + if(param.contains("name")) + { + plan.type = param["name"].toString(); + } + if(param.contains("args")) + { + QJsonObject kwargs = param["args"].toObject(); + for(auto pitr : kwargs.keys()) + { + BlueskyParam bsp; + bsp.name = pitr; + if(kwargs.value(pitr).isDouble()) + { + double p = kwargs.value(pitr).toDouble(); + bsp.default_val = QString::number(p); + } + else if( kwargs.value(pitr).isString() ) + { + bsp.default_val = kwargs.value(pitr).toString(); + } + plan.parameters[pitr] = bsp; + } + } + if(param.contains("kwargs")) + { + QJsonObject kwargs = param["kwargs"].toObject(); + for(auto pitr : kwargs.keys()) + { + BlueskyParam bsp; + bsp.name = pitr; + + if(kwargs.value(pitr).isDouble()) + { + double p = kwargs.value(pitr).toDouble(); + bsp.default_val = QString::number(p); + bsp.kind = BlueskyParamType::Numeral; + } + else if( kwargs.value(pitr).isString() ) + { + bsp.default_val = kwargs.value(pitr).toString(); + bsp.kind = BlueskyParamType::String; + } + plan.parameters[pitr] = bsp; + } + } + if(param.contains("result")) + { + /* + {'exit_status': 'completed', + 'run_uids': ['ab6e2ebc-effb-4385-8988-fff128e592c1'], + 'scan_ids': [5], + 'time_start': 1729088124.896845, + 'time_stop': 1729088129.916682, + 'msg': '', + 'traceback': ''}}], + */ + QJsonObject result = param["result"].toObject(); + if(result.contains("exit_status")) + { + plan.result.exit_status = result["exit_status"].toString(); + } + if(result.contains("msg")) + { + plan.result.msg = result["msg"].toString(); + } + if(result.contains("traceback")) + { + plan.result.traceback = result["traceback"].toString(); + } + if(result.contains("time_start")) + { + plan.result.time_start = result["time_start"].toDouble(); + } + if(result.contains("time_stop")) + { + plan.result.time_stop = result["time_stop"].toDouble(); + } + if(result.contains("run_uids")) + { + QJsonArray runs = result["run_uids"].toArray(); + if(runs.size() > 0) + { + plan.result.run_uids = runs.at(0).toString(); + } + } + } + if(param.contains("user")) + { + plan.user = param["user"].toString(); + } + if(param.contains("meta")) + { + QJsonObject meta = param["meta"].toObject(); + if(meta.contains("name")) + { + plan.name = meta["name"].toString(); + } + } + if(param.contains("item_uid")) + { + plan.uuid = param["item_uid"].toString(); + } + finished_plans.push_back(plan); + } + } + return ret; + } + + //--------------------------------------------------------------------------- + public slots: void run() override { diff --git a/src/mvc/BlueskyPlan.h b/src/mvc/BlueskyPlan.h index e367aa9..909c935 100644 --- a/src/mvc/BlueskyPlan.h +++ b/src/mvc/BlueskyPlan.h @@ -12,6 +12,24 @@ enum class BlueskyParamType { Numeral = 1, String = 3 }; +//--------------------------------------------------------------------------- + +struct BlueskyResult +{ + BlueskyResult() + { + time_start = 0.0; + time_stop = 0.0; + msg = ""; + } + QString exit_status; + QString run_uids; + // 'scan_ids': [2], + double time_start; + double time_stop; + QString msg; + QString traceback; +}; //--------------------------------------------------------------------------- struct BlueskyParam @@ -41,6 +59,7 @@ struct BlueskyPlan QString description; QString module; std::unordered_map parameters; + BlueskyResult result; QString uuid; QString user; }; diff --git a/src/mvc/LiveMapsElementsWidget.cpp b/src/mvc/LiveMapsElementsWidget.cpp index e2d066e..3dab8cd 100644 --- a/src/mvc/LiveMapsElementsWidget.cpp +++ b/src/mvc/LiveMapsElementsWidget.cpp @@ -127,9 +127,10 @@ void LiveMapsElementsWidget::createLayout() _vlm_widget = new VLM_Widget(); _vlm_widget->setAvailScans(&_avail_scans); - connect(_vlm_widget, &VLM_Widget::onScanUpdated, this, &LiveMapsElementsWidget::queueScan); + connect(_vlm_widget, &VLM_Widget::onScanUpdated, this, &LiveMapsElementsWidget::callQueueScan); _scan_queue_widget = new ScanQueueWidget(); + _scan_queue_widget->setAvailScans(&_avail_scans); connect(_scan_queue_widget, &ScanQueueWidget::queueNeedsToBeUpdated, this, &LiveMapsElementsWidget::getQueuedScans); connect(_scan_queue_widget, &ScanQueueWidget::onOpenEnv, this, &LiveMapsElementsWidget::callOpenEnv); connect(_scan_queue_widget, &ScanQueueWidget::onCloseEnv, this, &LiveMapsElementsWidget::callCloseEnv); @@ -140,6 +141,7 @@ void LiveMapsElementsWidget::createLayout() connect(_scan_queue_widget, &ScanQueueWidget::onMoveScanDown, this, &LiveMapsElementsWidget::callMoveScanDown); connect(_scan_queue_widget, &ScanQueueWidget::onRemoveScan, this, &LiveMapsElementsWidget::callRemoveScan); connect(_scan_queue_widget, &ScanQueueWidget::onPlanChanged, this, &LiveMapsElementsWidget::callUpdatePlan); + connect(_scan_queue_widget, &ScanQueueWidget::onAddScan, this, &LiveMapsElementsWidget::callQueueScan); _tab_widget = new QTabWidget(); _tab_widget->addTab(_mapsElementsWidget, "Counts"); @@ -301,7 +303,11 @@ void LiveMapsElementsWidget::updateScansAvailable() { _scan_queue_widget->newDataArrived( msg ); } - + else + { + _scan_queue_widget->setAvailScans(&_avail_scans); + _vlm_widget->setAvailScans(&_avail_scans); + } } //--------------------------------------------------------------------------- @@ -313,14 +319,16 @@ void LiveMapsElementsWidget::getQueuedScans() { updateIp(); } - if (false == _qserverComm->get_queued_scans(msg, _queued_scans, _running_scan)) + if (false == _qserverComm->get_scan_history(msg, _finished_scans)) { _scan_queue_widget->newDataArrived( msg ); } - else + + if (false == _qserverComm->get_queued_scans(msg, _queued_scans, _running_scan)) { - _scan_queue_widget->updateQueuedItems(_queued_scans, _running_scan); + _scan_queue_widget->newDataArrived( msg ); } + _scan_queue_widget->updateQueuedItems(_finished_scans, _queued_scans, _running_scan); } //--------------------------------------------------------------------------- @@ -409,7 +417,7 @@ void LiveMapsElementsWidget::callStopQueue() //--------------------------------------------------------------------------- -void LiveMapsElementsWidget::queueScan(const BlueskyPlan& plan) +void LiveMapsElementsWidget::callQueueScan(const BlueskyPlan& plan) { QString msg; if(_qserverComm == nullptr) @@ -515,4 +523,4 @@ void LiveMapsElementsWidget::callUpdatePlan(const BlueskyPlan& plan) getQueuedScans(); } -//--------------------------------------------------------------------------- \ No newline at end of file +//--------------------------------------------------------------------------- diff --git a/src/mvc/LiveMapsElementsWidget.h b/src/mvc/LiveMapsElementsWidget.h index 8772f01..28207d7 100644 --- a/src/mvc/LiveMapsElementsWidget.h +++ b/src/mvc/LiveMapsElementsWidget.h @@ -75,7 +75,7 @@ public slots: void callUpdatePlan(const BlueskyPlan& plan); - void queueScan(const BlueskyPlan& plan); + void callQueueScan(const BlueskyPlan& plan); protected: @@ -116,6 +116,8 @@ public slots: std::vector _queued_scans; + std::vector _finished_scans; + BlueskyPlan _running_scan; data_struct::Stream_Block* _last_packet; diff --git a/src/mvc/ScanQueueTableModel.h b/src/mvc/ScanQueueTableModel.h index 42d3628..c5c8f3c 100644 --- a/src/mvc/ScanQueueTableModel.h +++ b/src/mvc/ScanQueueTableModel.h @@ -12,6 +12,8 @@ #include "mvc/BlueskyPlan.h" #include #include +#include +#include //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- @@ -25,6 +27,7 @@ class ScanQueueTableModel : public QAbstractTableModel ScanQueueTableModel(QObject* parent = nullptr) : QAbstractTableModel(parent) { _headers[0] = "Type"; + _last_finished_idx = 0; } //--------------------------------------------------------------------------- int rowCount(const QModelIndex& parent = QModelIndex()) const override @@ -34,23 +37,13 @@ class ScanQueueTableModel : public QAbstractTableModel int columnCount(const QModelIndex& parent = QModelIndex()) const override { - if(_data.size() > 0) { - return _data.at(0).parameters.size() + 1; + return _data.at(0).parameters.size() + 5; // +1 for scan type, + 4 for results } return 10; } - //--------------------------------------------------------------------------- - void appendRow(const BlueskyPlan& row) - { - int rown = _data.size(); - QModelIndex gIndex = index(rown, 0, QModelIndex()); - beginInsertRows(gIndex, rown, rown); - _data.append(row); - endInsertRows(); - } - + //--------------------------------------------------------------------------- void clear() @@ -67,17 +60,6 @@ class ScanQueueTableModel : public QAbstractTableModel //--------------------------------------------------------------------------- - const QString& getNameAtRow(int row) - { - if(_data.size() > row) - { - return _data.at(row).name; - } - return ""; - } - - //--------------------------------------------------------------------------- - Qt::DropActions supportedDropActions() const override { return Qt::MoveAction; @@ -100,7 +82,7 @@ class ScanQueueTableModel : public QAbstractTableModel int srow, scol; QMap roleDataMap; stream >> srow >> scol >> roleDataMap; - emit moveScanRow(srow, parent.row()); + emit moveScanRow(srow - _last_finished_idx, parent.row() - _last_finished_idx); } } @@ -120,7 +102,7 @@ class ScanQueueTableModel : public QAbstractTableModel } endMoveRows(); */ - emit moveScanRow(srcParent.row(), dstParent.row()); + emit moveScanRow(srcParent.row() - _last_finished_idx, dstParent.row() - _last_finished_idx); return true; } @@ -135,22 +117,50 @@ class ScanQueueTableModel : public QAbstractTableModel const BlueskyPlan& rowData = _data[index.row()]; - if(index.column() > rowData.parameters.size() + 1) + int section = index.column(); + int parms_size = rowData.parameters.size(); + if(section > parms_size + 5) { return QVariant(); } if (role == Qt::DisplayRole) { - if(index.column() == 0) + if(section == 0) { return rowData.type; } - + else if(section == (parms_size + 1)) + { + return rowData.result.exit_status; + } + else if(section == (parms_size + 2)) + { + if(rowData.result.time_start == 0.0) + { + return " "; + } + QDateTime dateTime = QDateTime::fromSecsSinceEpoch(rowData.result.time_start, Qt::UTC); + return dateTime.toString("yyyy-MM-dd hh:mm:ss"); + } + else if(section == (parms_size + 3)) + { + if(rowData.result.time_stop == 0.0) + { + return " "; + } + QDateTime dateTime = QDateTime::fromSecsSinceEpoch(rowData.result.time_stop, Qt::UTC); + return dateTime.toString("yyyy-MM-dd hh:mm:ss"); + } + else if(section == (parms_size + 4)) + { + return rowData.result.msg; + } + int idx = 0; for( auto itr: rowData.parameters) { - if(idx == index.column() -1 ) + if(idx == section -1 ) { return itr.second.default_val; } @@ -158,6 +168,17 @@ class ScanQueueTableModel : public QAbstractTableModel } } + else if (role == Qt::BackgroundRole) + { + if(_data.at(index.row()).result.exit_status.length() > 0) + { + return QColor(Qt::darkGray); + } + else if(_data.at(index.row()).result.time_start > 0.0) + { + return QColor(Qt::darkGreen); + } + } return QVariant(); } //--------------------------------------------------------------------------- @@ -178,7 +199,24 @@ class ScanQueueTableModel : public QAbstractTableModel if(_data.size() > 0) { const BlueskyPlan& rowData = _data[0]; - + int parms_size = rowData.parameters.size(); + + if(section == (parms_size + 1)) + { + return "exit_status"; + } + else if(section == (parms_size + 2)) + { + return "time_start"; + } + else if(section == (parms_size + 3)) + { + return "time_stop"; + } + else if(section == (parms_size + 4)) + { + return "msg"; + } int idx = 0; for( auto itr: rowData.parameters) { @@ -205,6 +243,14 @@ class ScanQueueTableModel : public QAbstractTableModel { return Qt::NoItemFlags; } + + if(index.row() < _data.size()) + { + if(_data.at(index.row()).result.exit_status.length() > 0) + { + return Qt::ItemIsSelectable; + } + } if(index.column() == 0) { @@ -215,11 +261,20 @@ class ScanQueueTableModel : public QAbstractTableModel //--------------------------------------------------------------------------- - void setAllData(std::vector& scans) + void setAllData(std::vector &finished_plans, std::vector &queued_plans, BlueskyPlan &running_plan) { + _last_finished_idx = finished_plans.size(); beginResetModel(); _data.clear(); - for(auto itr : scans) + for(auto itr : finished_plans) + { + _data.append(itr); + } + if(running_plan.type.length() > 0) + { + _data.append(running_plan); + } + for(auto itr : queued_plans) { _data.append(itr); } @@ -237,12 +292,12 @@ class ScanQueueTableModel : public QAbstractTableModel int idx = 1; for (auto &itr : _data[index.row()].parameters) { - if(idx == index.column()) + if(idx == index.column() && value.toString().length() >0) { // this will be refreshed from qserver itr.second.default_val = value.toString(); emit planChanged(_data.at(index.row())); - return true; + return false; // return false to make sure we get this value from qserver } idx ++; } @@ -251,13 +306,18 @@ class ScanQueueTableModel : public QAbstractTableModel return false; } + //--------------------------------------------------------------------------- + const int get_finished_idx() {return _last_finished_idx;} + + //--------------------------------------------------------------------------- signals: void moveScanRow(int, int); void planChanged(const BlueskyPlan&); private: + int _last_finished_idx; QList _data; QString _headers[4]; diff --git a/src/mvc/ScanQueueWidget.cpp b/src/mvc/ScanQueueWidget.cpp index 2260481..f537127 100644 --- a/src/mvc/ScanQueueWidget.cpp +++ b/src/mvc/ScanQueueWidget.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include "core/defines.h" //--------------------------------------------------------------------------- @@ -19,6 +20,7 @@ ScanQueueWidget::ScanQueueWidget(QWidget *parent) : QWidget(parent) { + _avail_scans = nullptr; _createLayout(); } @@ -36,13 +38,6 @@ void ScanQueueWidget::_createLayout() { QVBoxLayout* layout = new QVBoxLayout(); - - _scan_running_table_model = new ScanQueueTableModel(); - _scan_running_table_view = new QTableView(); - _scan_running_table_view->setFixedHeight(100); - _scan_running_table_view->setModel(_scan_running_table_model); - _scan_running_table_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); - // _scan_running_table_view->horizontalHeader()->resizeSections(QHeaderView::Interactive); _scan_queue_table_model = new ScanQueueTableModel(); connect(_scan_queue_table_model, &ScanQueueTableModel::moveScanRow, this, &ScanQueueWidget::onMoveScanRow); @@ -95,6 +90,11 @@ void ScanQueueWidget::_createLayout() _btn_close_env->setToolTip("Close Environment"); connect(_btn_close_env, &QPushButton::pressed, this, &ScanQueueWidget::onCloseEnv); + _btn_add_scan = new QPushButton("Add Scan"); + connect(_btn_add_scan, &QPushButton::pressed, &_scan_dialog, &ScanRegionDialog::show); + + _scan_dialog.setRegionNameVisible(false); + connect(&_scan_dialog, &ScanRegionDialog::ScanUpdated, this, &ScanQueueWidget::onAddScan); _move_scan_up = new QAction("Move Scan Up", this); connect(_move_scan_up, @@ -122,25 +122,27 @@ void ScanQueueWidget::_createLayout() grid->addWidget(_btn_refresh,0,2); grid->addWidget(_btn_open_env,0,3); grid->addWidget(_btn_close_env,0,4); - grid->addItem(new QSpacerItem(999,10), 0,6); + grid->addWidget(_btn_add_scan,0,6); + //grid->addWidget(_btn_export_history,0,8); + grid->addItem(new QSpacerItem(999,10), 0,9); layout->addItem(grid); _te_qs_console = new QTextEdit(this); _te_qs_console->scrollBarWidgets(Qt::AlignRight); _te_qs_console->setReadOnly(true); - - QDockWidget *dock_running = new QDockWidget("Running Scan", this); - dock_running->setWidget(_scan_running_table_view); - layout->addWidget(dock_running); + + QTabWidget* tabWidget = new QTabWidget(); QDockWidget *dock_queue = new QDockWidget("Scan Queue", this); dock_queue->setWidget(_scan_queue_table_view); - layout->addWidget(dock_queue); + tabWidget->addTab(dock_queue, "Scan Queue"); QDockWidget *dock_log = new QDockWidget("QServer Log", this); dock_log->setWidget(_te_qs_console); - layout->addWidget(dock_log); + tabWidget->addTab(dock_log, "Scan Log"); + + layout->addWidget(tabWidget); setLayout(layout); @@ -176,7 +178,7 @@ void ScanQueueWidget::on_move_scan_up() for (int i = selectedIndexes.count() - 1; i >= 0; i--) { QModelIndex index = selectedIndexes[i]; - emit onMoveScanUp(index.row()); + emit onMoveScanUp(index.row() - _scan_queue_table_model->get_finished_idx()); } } } @@ -191,7 +193,7 @@ void ScanQueueWidget::on_move_scan_down() for (int i = selectedIndexes.count() - 1; i >= 0; i--) { QModelIndex index = selectedIndexes[i]; - emit onMoveScanDown(index.row()); + emit onMoveScanDown(index.row() - _scan_queue_table_model->get_finished_idx()); } } } @@ -215,7 +217,7 @@ void ScanQueueWidget::on_remove_scan() for (int i = selectedIndexes.count() - 1; i >= 0; i--) { QModelIndex index = selectedIndexes[i]; - emit onRemoveScan(index.row()); + emit onRemoveScan(index.row() - _scan_queue_table_model->get_finished_idx()); } } @@ -224,17 +226,10 @@ void ScanQueueWidget::on_remove_scan() //--------------------------------------------------------------------------- -void ScanQueueWidget::updateQueuedItems( std::vector &queued_plans, BlueskyPlan &running_plan) +void ScanQueueWidget::updateQueuedItems(std::vector &finished_plans, std::vector &queued_plans, BlueskyPlan &running_plan) { - _scan_queue_table_model->setAllData(queued_plans); + _scan_queue_table_model->setAllData(finished_plans, queued_plans, running_plan); _scan_queue_table_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); - std::vector runlist; - if(running_plan.uuid.length() > 0) - { - runlist.push_back(running_plan); - } - _scan_running_table_model->setAllData(runlist); - _scan_running_table_view->horizontalHeader()->resizeSections(QHeaderView::ResizeToContents); } //--------------------------------------------------------------------------- diff --git a/src/mvc/ScanQueueWidget.h b/src/mvc/ScanQueueWidget.h index d824a44..20bb801 100644 --- a/src/mvc/ScanQueueWidget.h +++ b/src/mvc/ScanQueueWidget.h @@ -14,7 +14,7 @@ #include #include "mvc/BlueskyPlan.h" #include "mvc/ScanQueueTableModel.h" -//#include "mvc/DragDropTableView.h" +#include "mvc/ScanRegionDialog.h" //--------------------------------------------------------------------------- @@ -36,7 +36,9 @@ class ScanQueueWidget : public QWidget */ ~ScanQueueWidget(); - void updateQueuedItems( std::vector &queued_plans, BlueskyPlan &running_plan); + void updateQueuedItems( std::vector &finished_plans, std::vector &queued_plans, BlueskyPlan &running_plan); + + void setAvailScans(std::map * avail_scans) { _avail_scans = avail_scans; _scan_dialog.setAvailScans(avail_scans);} signals: void queueNeedsToBeUpdated(); @@ -59,6 +61,8 @@ class ScanQueueWidget : public QWidget void onPlanChanged(const BlueskyPlan&); + void onAddScan(const BlueskyPlan&); + public slots: void newDataArrived(const QString &); @@ -83,10 +87,6 @@ public slots: ScanQueueTableModel* _scan_queue_table_model; - QTableView* _scan_running_table_view; - - ScanQueueTableModel* _scan_running_table_model; - QPushButton* _btn_play; QPushButton* _btn_stop; @@ -96,12 +96,20 @@ public slots: QPushButton* _btn_open_env; QPushButton* _btn_close_env; + + QPushButton* _btn_export_and_clear_history; + QPushButton* _btn_add_scan; + QAction* _move_scan_up; QAction* _move_scan_down; QAction* _remove_scan; + + ScanRegionDialog _scan_dialog; + + std::map *_avail_scans; }; diff --git a/src/mvc/ScanRegionDialog.cpp b/src/mvc/ScanRegionDialog.cpp index 9e22d5c..be5b386 100644 --- a/src/mvc/ScanRegionDialog.cpp +++ b/src/mvc/ScanRegionDialog.cpp @@ -34,7 +34,7 @@ void ScanRegionDialog::_createLayout() { _scan_name = new QLineEdit(" "); - + _lbl_region_name = new QLabel("Region Name: "); _scan_type = new QComboBox(); connect(_scan_type, &QComboBox::currentTextChanged, this, &ScanRegionDialog::scanChanged); @@ -43,7 +43,7 @@ void ScanRegionDialog::_createLayout() _scan_options->setModel(_scan_table_model); _btn_update = new QPushButton("Update"); - _btn_update_and_queue = new QPushButton("Update and Queue"); + _btn_update_and_queue = new QPushButton("Add To Queue"); _btn_cancel = new QPushButton("Cancel"); connect(_btn_update, &QPushButton::pressed, this, &ScanRegionDialog::onUpdate); connect(_btn_update_and_queue, &QPushButton::pressed, this, &ScanRegionDialog::onUpdateAndQueue); @@ -51,8 +51,8 @@ void ScanRegionDialog::_createLayout() QVBoxLayout* main_layout = new QVBoxLayout(); - QHBoxLayout* name_layout = new QHBoxLayout(); - name_layout->addWidget(new QLabel("Scan Name: ")); + QHBoxLayout *name_layout = new QHBoxLayout(); + name_layout->addWidget(_lbl_region_name); name_layout->addWidget(_scan_name); QHBoxLayout* type_layout = new QHBoxLayout(); diff --git a/src/mvc/ScanRegionDialog.h b/src/mvc/ScanRegionDialog.h index 84499c1..c5b4b0e 100644 --- a/src/mvc/ScanRegionDialog.h +++ b/src/mvc/ScanRegionDialog.h @@ -44,6 +44,9 @@ class ScanRegionDialog : public QDialog QString getScanName() { return _scan_name->text(); } void setAvailScans(std::map * avail_scans); + + void setRegionNameVisible(bool val) { _lbl_region_name->setVisible(val); _scan_name->setVisible(false);} + signals: void ScanUpdated(const BlueskyPlan& plan); @@ -75,7 +78,10 @@ public slots: ScanTableModel *_scan_table_model; + QLabel* _lbl_region_name; + std::map *_avail_scans; + }; diff --git a/src/mvc/ScanTableModel.h b/src/mvc/ScanTableModel.h index c1f5e12..91ada04 100644 --- a/src/mvc/ScanTableModel.h +++ b/src/mvc/ScanTableModel.h @@ -56,17 +56,6 @@ class ScanTableModel : public QAbstractTableModel return _data.at(row); } - //--------------------------------------------------------------------------- - - const QString& getNameAtRow(int row) - { - if(_data.size() > row) - { - return _data.at(row).name; - } - return ""; - } - //--------------------------------------------------------------------------- void getCurrentParams(BlueskyPlan& plan)