diff --git a/bin/0.json b/bin/0.json new file mode 100644 index 0000000..bdda29f --- /dev/null +++ b/bin/0.json @@ -0,0 +1,86 @@ +{ + "A1": { + "x": 2, + "y": 410 + }, + "A2": { + "x": 781, + "y": 414 + }, + "C3": { + "x": 263, + "y": 411 + }, + "C4": { + "x": 523, + "y": 412 + }, + "Cz": { + "x": 392, + "y": 411 + }, + "F3": { + "x": 293, + "y": 253 + }, + "F4": { + "x": 489, + "y": 252 + }, + "F7": { + "x": 197, + "y": 224 + }, + "F8": { + "x": 590, + "y": 223 + }, + "Fp1": { + "x": 306, + "y": 150 + }, + "Fp2": { + "x": 481, + "y": 151 + }, + "Fz": { + "x": 389, + "y": 263 + }, + "O1": { + "x": 307, + "y": 679 + }, + "O2": { + "x": 481, + "y": 682 + }, + "P3": { + "x": 293, + "y": 582 + }, + "P4": { + "x": 490, + "y": 580 + }, + "Pz": { + "x": 392, + "y": 572 + }, + "T3": { + "x": 133, + "y": 410 + }, + "T4": { + "x": 651, + "y": 413 + }, + "T5": { + "x": 195, + "y": 608 + }, + "T6": { + "x": 585, + "y": 609 + } +} diff --git a/bin/xyylMCWEACSystem.exe b/bin/xyylMCWEACSystem.exe index 25d4d2b..01beb2a 100644 Binary files a/bin/xyylMCWEACSystem.exe and b/bin/xyylMCWEACSystem.exe differ diff --git a/xyylMCWEACSystem/leadscheme.cpp b/xyylMCWEACSystem/leadscheme.cpp index 5336493..c39be43 100644 --- a/xyylMCWEACSystem/leadscheme.cpp +++ b/xyylMCWEACSystem/leadscheme.cpp @@ -3,6 +3,8 @@ #include #include #include +#include "operatorjson.h" +#include LeadScheme::LeadScheme(QWidget * parent ):QWidget (parent) { init(); @@ -409,104 +411,19 @@ void LeadScheme::initLay() <<"O1"<<"O2"; QJsonObject json; - -#if 0 - // "名称:Fp1\tx:306\ty:150" - json.insert("Fp1",QJsonValue::fromVariant(QPoint(306,150))); - //"名称:Fp2\tx:481\ty:151" - json.insert("Fp2",QJsonValue::fromVariant(QPoint(481,151))); - //"名称:F7\tx:197\ty:224" - json.insert("F7",QJsonValue::fromVariant(QPoint(197,224))); - // "名称:F3\tx:293\ty:253" - json.insert("F3",QJsonValue::fromVariant(QPoint(293,253))); - // "名称:Fz\tx:389\ty:263" - json.insert("Fz",QJsonValue::fromVariant(QPoint(389,263))); - //"名称:F4\tx:489\ty:252" - json.insert("F4",QJsonValue::fromVariant(QPoint(489,252))); - //"名称:F8\tx:590\ty:223" - json.insert("F8",QJsonValue::fromVariant(QPoint(590,223))); - // "名称:A1\tx:2\ty:410" - json.insert("A1",QJsonValue::fromVariant(QPoint(2,410))); - //"名称:T3\tx:133\ty:410" - json.insert("T3",QJsonValue::fromVariant(QPoint(133,410))); - //"名称:C3\tx:263\ty:411" - json.insert("C3",QJsonValue::fromVariant(QPoint(263,411))); - //"名称:Cz\tx:392\ty:411" - json.insert("Cz",QJsonValue::fromVariant(QPoint(392,411))); - //"名称:C4\tx:523\ty:412" - json.insert("C4",QJsonValue::fromVariant(QPoint(523,412))); - // "名称:T4\tx:651\ty:413" - json.insert("T4",QJsonValue::fromVariant(QPoint(651,413))); - //"名称:A2\tx:781\ty:414" - json.insert("A2",QJsonValue::fromVariant(QPoint(781,414))); - // "名称:T5\tx:195\ty:608" - json.insert("T5",QJsonValue::fromVariant(QPoint(195,608))); - //"名称:P3\tx:293\ty:582" - json.insert("P3",QJsonValue::fromVariant(QPoint(293,582))); - //"名称:Pz\tx:392\ty:572" - json.insert("Pz",QJsonValue::fromVariant(QPoint(392,572))); - //"名称:P4\tx:490\ty:580" - json.insert("P4",QJsonValue::fromVariant(QPoint(490,580))); - //"名称:T6\tx:585\ty:609" - json.insert("T6",QJsonValue::fromVariant(QPoint(585,609))); - //"名称:O1\tx:307\ty:679" - json.insert("O1",QJsonValue::fromVariant(QPoint(307,679))); - // "名称:O2\tx:481\ty:682" - json.insert("O2",QJsonValue::fromVariant(QPoint(481,682))); -#endif - QList listPoints; - listPoints.append(QPoint(306,150)); - - //"名称:Fp2\tx:481\ty:151" - listPoints.append(QPoint(481,151)); - //"名称:F7\tx:197\ty:224" - listPoints.append(QPoint(197,224)); - // "名称:F3\tx:293\ty:253" - listPoints.append(QPoint(293,253)); - // "名称:Fz\tx:389\ty:263" - listPoints.append(QPoint(389,263)); - //"名称:F4\tx:489\ty:252" - listPoints.append(QPoint(489,252)); - //"名称:F8\tx:590\ty:223" - listPoints.append(QPoint(590,223)); - // "名称:A1\tx:2\ty:410" - listPoints.append(QPoint(2,410)); - //"名称:T3\tx:133\ty:410" - listPoints.append(QPoint(133,410)); - //"名称:C3\tx:263\ty:411" - listPoints.append(QPoint(263,411)); - //"名称:Cz\tx:392\ty:411" - listPoints.append(QPoint(392,411)); - //"名称:C4\tx:523\ty:412" - listPoints.append(QPoint(523,412)); - // "名称:T4\tx:651\ty:413" - listPoints.append(QPoint(651,413)); - //"名称:A2\tx:781\ty:414" - listPoints.append(QPoint(781,414)); - // "名称:T5\tx:195\ty:608" - listPoints.append(QPoint(195,608)); - //"名称:P3\tx:293\ty:582" - listPoints.append(QPoint(293,582)); - //"名称:Pz\tx:392\ty:572" - listPoints.append(QPoint(392,572)); - //"名称:P4\tx:490\ty:580" - listPoints.append(QPoint(490,580)); - //"名称:T6\tx:585\ty:609" - listPoints.append(QPoint(585,609)); - //"名称:O1\tx:307\ty:679" -listPoints.append(QPoint(307,679)); - // "名称:O2\tx:481\ty:682" - listPoints.append(QPoint(481,682)); + OperatorJson Ojson; + Ojson.readJson(QApplication::applicationDirPath()+"/0.json",json); + qDebug()<<"hahaha"<setParent(wClickedPints); + int x =json[listNames.at(i)].toObject()["x"].toInt(); + int y = json[listNames.at(i)].toObject()["y"].toInt(); - QPoint tempPoint = listPoints.at(i);//json.value(listNames.at(i)).toVariant().toPoint(); - - btn->setGeometry(tempPoint.x(), tempPoint.y(), radius, radius); + btn->setGeometry(x,y, radius, radius); //x = x + radius; btn->setText(listNames.at(i)); btn->setCanMove(true); @@ -539,15 +456,25 @@ listPoints.append(QPoint(307,679)); vlayAll->addLayout(hbtn); setLayout(vlayAll); } - + #include "operatorjson.h" +#include void LeadScheme::slotSave() { + QJsonObject jsonSave; + for(int i = 0;i< m_listMoveBtns.size();i++ ) { auto btn = m_listMoveBtns.at(i); QString text = btn->getText(); int x = btn->x(); int y = btn->y(); + QJsonObject perJson; + perJson.insert("x",x); + perJson.insert("y",y); + jsonSave.insert(text,perJson); qDebug()< #include "MoveButton.h" +#include "operatorjson.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); @@ -55,7 +56,6 @@ int main(int argc, char *argv[]) globalFont.setFamily("黑体"); QApplication::setFont(globalFont); - QString qss1=R"( QLineEdit{ border: 1px solid #ABCDA0; /* 边框宽度为1px,颜色为#A0A0A0 */ diff --git a/xyylMCWEACSystem/operatorjson.cpp b/xyylMCWEACSystem/operatorjson.cpp new file mode 100644 index 0000000..8744078 --- /dev/null +++ b/xyylMCWEACSystem/operatorjson.cpp @@ -0,0 +1,64 @@ +#include "operatorjson.h" +#include +#include +#include +#include +#include +OperatorJson::OperatorJson(QObject * parent ):QObject (parent) +{ + +} +OperatorJson::~OperatorJson() +{ + +} + +bool OperatorJson::savaJson(QJsonObject obj, QString sPathFile) +{ + { + + QJsonDocument doc(obj); + QByteArray data = doc.toJson(); + QFile file(sPathFile);//json文件 + bool ok = file.open(QIODevice::WriteOnly); + if (ok) + { + file.write(data); + file.close(); + } + return ok; + + } +} + +bool OperatorJson::readJson(QString sPathFile, QJsonObject & json) +{ + //读入所有内容 + QFile file(sPathFile); + + file.open(QIODevice::ReadOnly); + QByteArray data = file.readAll(); + file.close(); + //解析 + QJsonParseError jsonError; + QJsonArray jsonAarray; + + QByteArray array(data.toStdString().c_str()); + QJsonDocument document = QJsonDocument::fromJson(array, &jsonError); + + if (jsonError.error == QJsonParseError::NoError) + { + //logInfo() << array << endl; + //jsonAarray = document.array(); + json = document.object(); + + } + else + { + return false; + } + + + return true; + +} diff --git a/xyylMCWEACSystem/operatorjson.h b/xyylMCWEACSystem/operatorjson.h new file mode 100644 index 0000000..7fd408b --- /dev/null +++ b/xyylMCWEACSystem/operatorjson.h @@ -0,0 +1,15 @@ +#ifndef OPERATORJSON_H +#define OPERATORJSON_H + +#include +#include +class OperatorJson:public QObject +{ + Q_OBJECT +public: + OperatorJson(QObject * parent = NULL ); + ~OperatorJson(); + bool savaJson(QJsonObject obj, QString sPathFile); + bool readJson(QString sPathFile, QJsonObject & json); +}; +#endif // OPERATORJSON_H diff --git a/xyylMCWEACSystem/xyylMCWEACSystem.pro b/xyylMCWEACSystem/xyylMCWEACSystem.pro index b15daff..db7eadb 100644 --- a/xyylMCWEACSystem/xyylMCWEACSystem.pro +++ b/xyylMCWEACSystem/xyylMCWEACSystem.pro @@ -46,6 +46,7 @@ SOURCES += \ medicalrecordmanager.cpp \ medicalrecordwidget.cpp \ navlistwidget.cpp \ + operatorjson.cpp \ parametersettingswidget.cpp \ regwidget.cpp \ systemsettingwidget.cpp \ @@ -73,6 +74,7 @@ HEADERS += \ medicalrecordwidget.h \ mrmanagement.h \ navlistwidget.h \ + operatorjson.h \ parametersettingswidget.h \ regwidget.h \ systemsettingwidget.h \ diff --git a/xyylMCWEACSystem/xyylMCWEACSystem.pro.user b/xyylMCWEACSystem/xyylMCWEACSystem.pro.user index d98fd99..d84c3c8 100644 --- a/xyylMCWEACSystem/xyylMCWEACSystem.pro.user +++ b/xyylMCWEACSystem/xyylMCWEACSystem.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId