Change UI logic, add message prompt, add scan logic and preivewing rendering logic.
This commit is contained in:
@@ -11,13 +11,16 @@
|
|||||||
#include "patientinformationform.h"
|
#include "patientinformationform.h"
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include "event/EventCenter.h"
|
#include "event/EventCenter.h"
|
||||||
|
#include <QImage>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
ScanFormWidget::ScanFormWidget(QWidget *parent) : TabFormWidget(parent) {
|
ScanFormWidget::ScanFormWidget(QWidget *parent) : TabFormWidget(parent) {
|
||||||
const char* style="QWidget#PatientInformationForm{min-width:300px;max-width:300px; margin-right:10}"
|
const char* style="QWidget#PatientInformationForm{min-width:300px;max-width:300px; margin-right:10}"
|
||||||
"QWidget#patientinformation_panel{ border-right:1px solid #0078d8}"
|
"QWidget#patientinformation_panel{ border-right:1px solid #0078d8}"
|
||||||
"QWidget#patientinformation_panel QLabel{font-size:20px; }"
|
"QWidget#patientinformation_panel QLabel{font-size:20px; }"
|
||||||
"QWidget#param_widget{min-width:300px;max-width:300px;border-left:1px solid #0078d8}"
|
"QWidget#param_widget{min-width:300px;max-width:300px;border-left:1px solid #0078d8}"
|
||||||
"QWidget#broadcast_widget{border:2px solid #515151; border-radius: 20px}"
|
"QWidget#broadcast_widget{border:2px solid #515151; border-radius: 20px; background-color:black}"
|
||||||
|
"QWidget#broadcast_widget QLabel{background-color:black}"
|
||||||
"QLabel#lbl_protocol{font-size:32px; margin:0; color:silver}"
|
"QLabel#lbl_protocol{font-size:32px; margin:0; color:silver}"
|
||||||
"QLabel#lbl_title,QLabel#lbl_ptitle{font-size:20px;margin:0; border-bottom:1px solid silver}"
|
"QLabel#lbl_title,QLabel#lbl_ptitle{font-size:20px;margin:0; border-bottom:1px solid silver}"
|
||||||
"QLabel#lbl_end{font-size:20px;margin:0; border-top:1px solid #0078d8}"
|
"QLabel#lbl_end{font-size:20px;margin:0; border-top:1px solid #0078d8}"
|
||||||
@@ -123,17 +126,57 @@ ScanFormWidget::ScanFormWidget(QWidget *parent) : TabFormWidget(parent) {
|
|||||||
connect(EventCenter::Default(),&EventCenter::ResponsePreview,[=](QObject* sender,QObject* data){
|
connect(EventCenter::Default(),&EventCenter::ResponsePreview,[=](QObject* sender,QObject* data){
|
||||||
setPreviewing(true);
|
setPreviewing(true);
|
||||||
});
|
});
|
||||||
|
connect(EventCenter::Default(),&EventCenter::ResponsePreviewData,[=](QObject* sender,QObject* data){
|
||||||
|
if (!data)return;
|
||||||
|
QByteArray* array = (QByteArray*)data;
|
||||||
|
uchar* raw_dataptr = (uchar*)array->data();
|
||||||
|
uchar c_data[200][200];
|
||||||
|
uchar* data_ptr = c_data[0];
|
||||||
|
for(int i=0;i<200;i++){
|
||||||
|
data_ptr = c_data[i];
|
||||||
|
memcpy(data_ptr,raw_dataptr,200);
|
||||||
|
raw_dataptr += 200;
|
||||||
|
|
||||||
|
}
|
||||||
|
raw_dataptr = (uchar*)array->data();
|
||||||
|
QImage img(c_data[0] , 200, 200, QImage::Format_Grayscale8);
|
||||||
|
viewer->setFixedSize(800,800);
|
||||||
|
QPixmap pic = QPixmap::fromImage(img).scaledToHeight(800,Qt::SmoothTransformation);
|
||||||
|
QPainter painter(&pic);
|
||||||
|
QPen pen;
|
||||||
|
pen.setColor(QColor(255,255,0,100));
|
||||||
|
pen.setStyle(Qt::DashLine);
|
||||||
|
pen.setWidth(3);
|
||||||
|
QFont font("Futura");
|
||||||
|
font.setPixelSize(26);
|
||||||
|
font.setBold(true);
|
||||||
|
painter.setFont(font);
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawLine(29*4,29*4,29*4,171*4);
|
||||||
|
painter.drawLine(29*4+1,29*4,171*4,29*4);
|
||||||
|
painter.drawLine(29*4+1,171*4,171*4,171*4);
|
||||||
|
painter.drawLine(171*4,29*4+1,171*4,171*4-1);
|
||||||
|
pen.setColor(QColor(255,255,0));
|
||||||
|
painter.setPen(pen);
|
||||||
|
painter.drawText(335,80,"Previewing");
|
||||||
|
painter.drawText(29*4,29*4-2,"ROI");
|
||||||
|
viewer->setPixmap(pic);
|
||||||
|
});
|
||||||
connect(EventCenter::Default(),&EventCenter::PatientSelected,[=](QObject* sender,QObject* data){
|
connect(EventCenter::Default(),&EventCenter::PatientSelected,[=](QObject* sender,QObject* data){
|
||||||
patient_information->setPatientInformation((PatientInformation*)data);
|
patient_information->setPatientInformation((PatientInformation*)data);
|
||||||
});
|
});
|
||||||
connect(btnRefresh,&QToolButton::clicked,[=](){
|
connect(btnRefresh,&QToolButton::clicked,[=](){
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestEmptyScan, nullptr, nullptr);
|
QString patientInf(patient_information->getCurrentPatientJsonString(true));
|
||||||
|
printf("%s\r\n",patientInf.toStdString().data());
|
||||||
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestEmptyScan, nullptr, (QObject*)(&patientInf));
|
||||||
});
|
});
|
||||||
connect(btnPreview,&QToolButton::clicked,[=](){
|
connect(btnPreview,&QToolButton::clicked,[=](){
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestPreviewScan, nullptr, nullptr);
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestPreviewScan, nullptr, nullptr);
|
||||||
});
|
});
|
||||||
connect(btnScan,&QToolButton::clicked,[=](){
|
connect(btnScan,&QToolButton::clicked,[=](){
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestPatientScan, nullptr, nullptr);
|
QString patientInf(patient_information->getCurrentPatientJsonString(false));
|
||||||
|
printf("%s\r\n",patientInf.toStdString().data());
|
||||||
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestPatientScan, nullptr, (QObject*)(&patientInf));
|
||||||
});
|
});
|
||||||
connect(btnStop,&QToolButton::clicked,[=](){
|
connect(btnStop,&QToolButton::clicked,[=](){
|
||||||
EventCenter::Default()->triggerEvent(GUIEvents::RequestStop, nullptr, nullptr);
|
EventCenter::Default()->triggerEvent(GUIEvents::RequestStop, nullptr, nullptr);
|
||||||
|
|||||||
@@ -6,50 +6,54 @@
|
|||||||
#include "../event/EventCenter.h"
|
#include "../event/EventCenter.h"
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#define triggerEvent EventCenter::Default()->triggerEvent
|
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent
|
||||||
|
|
||||||
const char * getJsonFromPatInf(QObject* obj)
|
#define THROW_ERROR(errormsg)\
|
||||||
|
TRIGGER_EVENT(GUIEvents::GUIErrorRaise, nullptr, (QObject*)&errormsg);
|
||||||
|
|
||||||
|
std::string getJsonFromPatInf(QObject* obj)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return ((QString*)obj)->toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::initDevice() {
|
void DeviceManager::initDevice() {
|
||||||
// empty scan
|
// empty scan
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestEmptyScan,[=](){
|
connect(EventCenter::Default(),&EventCenter::RequestEmptyScan,[=](QObject* sender, QObject* detail){
|
||||||
const char * json = "";
|
std::string json= getJsonFromPatInf(detail);
|
||||||
processScan(json);
|
printf("%s\r\n",json.c_str());
|
||||||
|
processScan(json.c_str());
|
||||||
});
|
});
|
||||||
// Patient scan
|
// Patient scan
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestPatientScan,[=](QObject* sender, QObject* detail){
|
connect(EventCenter::Default(),&EventCenter::RequestPatientScan,[=](QObject* sender, QObject* detail){
|
||||||
const char * json = getJsonFromPatInf(detail);
|
std::string json= getJsonFromPatInf(detail);
|
||||||
if (json)
|
printf("%s\r\n",json.c_str());
|
||||||
|
if (!json.empty())
|
||||||
{
|
{
|
||||||
processScan(json);
|
processScan(json.c_str());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// stop
|
// stop
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestStop,[=]() {
|
connect(EventCenter::Default(),&EventCenter::RequestStop,[=]() {
|
||||||
triggerEvent(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
||||||
StatusInfo inf = GetStatus();
|
StatusInfo inf = GetStatus();
|
||||||
if (inf.status==SCANING)
|
if (inf.status == SCANING) {
|
||||||
{
|
|
||||||
//ScanControl fail
|
//ScanControl fail
|
||||||
if(ScanControl(STOP))
|
if (ScanControl(STOP)) {
|
||||||
{
|
QString msg("Stop operation fail!");
|
||||||
triggerEvent(GUIEvents::GUIErrorRaise, nullptr, nullptr);
|
THROW_ERROR(msg);
|
||||||
lastStatus = -1;
|
lastStatus = -1;
|
||||||
previewing = false;
|
previewing = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastStatus = -1;
|
lastStatus = -1;
|
||||||
previewing = false;
|
previewing = false;
|
||||||
triggerEvent(GUIEvents::InvokeOperationEnd, nullptr, nullptr);
|
|
||||||
triggerEvent(GUIEvents::ResponseStop, nullptr, nullptr);
|
|
||||||
}
|
}
|
||||||
|
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, nullptr);
|
||||||
|
TRIGGER_EVENT(GUIEvents::ResponseStop, nullptr, nullptr);
|
||||||
});
|
});
|
||||||
// preview
|
// preview
|
||||||
connect(EventCenter::Default(),&EventCenter::RequestPreviewScan,[=](){
|
connect(EventCenter::Default(),&EventCenter::RequestPreviewScan,[=](){
|
||||||
triggerEvent(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
||||||
StatusInfo inf = GetStatus();
|
StatusInfo inf = GetStatus();
|
||||||
if (inf.status==READY)
|
if (inf.status==READY)
|
||||||
{
|
{
|
||||||
@@ -59,12 +63,13 @@ void DeviceManager::initDevice() {
|
|||||||
lastStatus = SCANING;
|
lastStatus = SCANING;
|
||||||
previewing = true;
|
previewing = true;
|
||||||
timerID = startTimer(500);
|
timerID = startTimer(500);
|
||||||
triggerEvent(GUIEvents::ResponsePreview, nullptr, nullptr);
|
TRIGGER_EVENT(GUIEvents::ResponsePreview, nullptr, nullptr);
|
||||||
triggerEvent(GUIEvents::InvokeOperationEnd, nullptr, nullptr);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
triggerEvent(GUIEvents::GUIErrorRaise, nullptr, nullptr);
|
QString msg(inf.status!=READY?"Can't start preview,Device is not ready!":"Start preview operation fail!");
|
||||||
|
THROW_ERROR(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,20 +82,21 @@ void DeviceManager::timerEvent(QTimerEvent *event) {
|
|||||||
if(!previewing)
|
if(!previewing)
|
||||||
{
|
{
|
||||||
QVariant var(inf.progress);
|
QVariant var(inf.progress);
|
||||||
triggerEvent(GUIEvents::InvokeOperationProgress, nullptr, (QObject*)&var);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationProgress, nullptr, (QObject*)&var);
|
||||||
}
|
}
|
||||||
//preview scan
|
//preview scan
|
||||||
else{
|
else{
|
||||||
const char * data = GetPreviewData();
|
const char * data = GetPreviewData();
|
||||||
QByteArray* bytes = new QByteArray(data);
|
QByteArray bytes =QByteArray::fromRawData(data,40000);
|
||||||
triggerEvent(GUIEvents::ResponsePreviewData, nullptr, (QObject*)bytes);
|
TRIGGER_EVENT(GUIEvents::ResponsePreviewData, nullptr, (QObject*)(&bytes));
|
||||||
|
delete [] data;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
if (lastStatus == SCANING && !errorOccured)
|
if (lastStatus == SCANING && !errorOccured)
|
||||||
{
|
{
|
||||||
QVariant var(true);
|
QVariant var(true);
|
||||||
triggerEvent(GUIEvents::InvokeOperationEnd, nullptr, (QObject*)&var);
|
TRIGGER_EVENT(GUIEvents::InvokeOperationEnd, nullptr, (QObject*)&var);
|
||||||
lastStatus = -1;
|
lastStatus = -1;
|
||||||
previewing = false;
|
previewing = false;
|
||||||
}
|
}
|
||||||
@@ -106,10 +112,12 @@ void DeviceManager::timerEvent(QTimerEvent *event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceManager::processScan(const char *json) {
|
void DeviceManager::processScan(const char *json) {
|
||||||
triggerEvent(GUIEvents::InvokeOperationStart, nullptr, nullptr);
|
static QString msg = "Start scan...";
|
||||||
|
TRIGGER_EVENT(GUIEvents::InvokeOperationStart, nullptr, (QObject*)&msg);
|
||||||
int ret = SetScanInf(json);
|
int ret = SetScanInf(json);
|
||||||
if (ret){
|
if (ret){
|
||||||
triggerEvent(GUIEvents::GUIErrorRaise, nullptr, nullptr);
|
QString errmsg("Transfer patient information fail!");
|
||||||
|
THROW_ERROR(errmsg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
StatusInfo inf = GetStatus();
|
StatusInfo inf = GetStatus();
|
||||||
@@ -122,5 +130,6 @@ void DeviceManager::processScan(const char *json) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
triggerEvent(GUIEvents::GUIErrorRaise, nullptr, nullptr);
|
QString errmsg("Start scan operation fail!");
|
||||||
|
THROW_ERROR(errmsg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,13 +30,6 @@ GUIMessageDialog::GUIMessageDialog(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
frame.append(str);
|
frame.append(str);
|
||||||
}
|
}
|
||||||
connect(EventCenter::Default(),&EventCenter::InvokeOperationEnd,[=](){
|
|
||||||
if (timerID != -1){
|
|
||||||
killTimer(timerID);
|
|
||||||
timerID = -1;
|
|
||||||
}
|
|
||||||
accept();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIMessageDialog::~GUIMessageDialog()
|
GUIMessageDialog::~GUIMessageDialog()
|
||||||
@@ -63,6 +56,7 @@ void GUIMessageDialog::startLoading() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GUIMessageDialog::showMessage(QString msg) {
|
void GUIMessageDialog::showMessage(QString msg) {
|
||||||
|
ui->lbl_msg->setVisible(true);
|
||||||
ui->lbl_msg->setText(msg);
|
ui->lbl_msg->setText(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +64,20 @@ void GUIMessageDialog::showExitButton() {
|
|||||||
ui->btn_main->setVisible(true);
|
ui->btn_main->setVisible(true);
|
||||||
disconnect(ui->btn_main);
|
disconnect(ui->btn_main);
|
||||||
connect(ui->btn_main,&QToolButton::clicked,[=](){
|
connect(ui->btn_main,&QToolButton::clicked,[=](){
|
||||||
|
if (timerID != -1){
|
||||||
|
killTimer(timerID);
|
||||||
|
timerID = -1;
|
||||||
|
}
|
||||||
accept();
|
accept();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GUIMessageDialog::hideMessage() {
|
||||||
|
ui->lbl_msg->setVisible(false);
|
||||||
|
ui->lbl_msg->setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GUIMessageDialog::hideExitButton() {
|
||||||
|
ui->btn_main->setVisible(false);
|
||||||
|
disconnect(ui->btn_main);
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ public:
|
|||||||
explicit GUIMessageDialog(QWidget *parent = nullptr);
|
explicit GUIMessageDialog(QWidget *parent = nullptr);
|
||||||
~GUIMessageDialog();
|
~GUIMessageDialog();
|
||||||
void showMessage(QString msg);
|
void showMessage(QString msg);
|
||||||
|
void hideMessage();
|
||||||
void showExitButton();
|
void showExitButton();
|
||||||
|
void hideExitButton();
|
||||||
void startLoading();
|
void startLoading();
|
||||||
void stopLoading();
|
void stopLoading();
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
"stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);"
|
"stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);"
|
||||||
"border-radius:20px;border:5px solid #0078d8; }"
|
"border-radius:20px;border:5px solid #0078d8; }"
|
||||||
"QDialog QWidget QWidget{ background:transparent;color:#3078d8}"
|
"QDialog QWidget QWidget{ background:transparent;color:#3078d8}"
|
||||||
"QDialog QWidget QWidget QLabel{ border:1px solid black}"
|
"QDialog QWidget QWidget QLabel{ font-size:30px}"
|
||||||
"QLabel#lbl_progressicon{min-width:75px;max-width:75px;font-size:30px}"
|
"QLabel#lbl_progressicon{min-width:75px;max-width:75px;}"
|
||||||
"#spacer_1, #spacer_2{min-width:2px;max-width:2px;margin-top:6px;margin-bottom:6px;border-right:1px solid #0078d8;}"//green with 2
|
"#spacer_1, #spacer_2{min-width:2px;max-width:2px;margin-top:6px;margin-bottom:6px;border-right:1px solid #0078d8;}"//green with 2
|
||||||
;
|
;
|
||||||
this->setStyleSheet(style);
|
this->setStyleSheet(style);
|
||||||
@@ -90,15 +90,42 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
this->showFullScreen ();
|
this->showFullScreen ();
|
||||||
connect(EventCenter::Default(),&EventCenter::GUIErrorRaise,[=](){
|
connect(EventCenter::Default(),&EventCenter::GUIErrorRaise,[=](){
|
||||||
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
||||||
|
msgDialog->showMessage("Something went error!");
|
||||||
|
msgDialog->showExitButton();
|
||||||
|
msgDialog->stopLoading();
|
||||||
msgDialog->show();
|
msgDialog->show();
|
||||||
});
|
});
|
||||||
connect(EventCenter::Default(),&EventCenter::InvokeOperationStart,[=](){
|
connect(EventCenter::Default(),&EventCenter::InvokeOperationStart,[=](QObject*,QObject* msg){
|
||||||
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
||||||
|
if (msg)
|
||||||
|
{
|
||||||
|
QString* str = (QString*)msg;
|
||||||
|
msgDialog->showMessage(*str);
|
||||||
|
} else{
|
||||||
|
msgDialog->hideMessage();
|
||||||
|
}
|
||||||
|
msgDialog->hideExitButton();
|
||||||
|
msgDialog->startLoading();
|
||||||
msgDialog->show();
|
msgDialog->show();
|
||||||
});
|
});
|
||||||
|
connect(EventCenter::Default(),&EventCenter::InvokeOperationProgress,[=](QObject*,QObject* msg){
|
||||||
|
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
|
||||||
|
if (msg)
|
||||||
|
{
|
||||||
|
QVariant* var = (QVariant*)msg;
|
||||||
|
msgDialog->showMessage(QString("Scanning %1%").arg((int)(var->toFloat()*100.0f)));
|
||||||
|
} else{
|
||||||
|
msgDialog->hideMessage();
|
||||||
|
}
|
||||||
|
msgDialog->hideExitButton();
|
||||||
|
msgDialog->show();
|
||||||
|
});
|
||||||
|
connect(EventCenter::Default(),&EventCenter::InvokeOperationEnd,[=](){
|
||||||
|
if (!msgDialog) return;
|
||||||
|
msgDialog->stopLoading();
|
||||||
|
msgDialog->hide();
|
||||||
|
});
|
||||||
DeviceManager::Default()->initDevice();
|
DeviceManager::Default()->initDevice();
|
||||||
// GUIMessageDialog* dialog = new GUIMessageDialog(this);
|
|
||||||
// dialog->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
|||||||
Reference in New Issue
Block a user