增加版本号和字体
This commit is contained in:
parent
d76ec6e50b
commit
39de80586d
1
.gitignore
vendored
1
.gitignore
vendored
@ -55,3 +55,4 @@ deploy/
|
||||
|
||||
|
||||
realtimeform - 副本.cpp
|
||||
realtimeform22.cpp
|
||||
|
||||
@ -30,7 +30,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
QDate buildDate = QLocale( QLocale::English ).toDate( QString(__DATE__).replace(" ", " 0"), "MMM dd yyyy");
|
||||
QTime buildTime = QTime::fromString(__TIME__, "hh:mm:ss");
|
||||
|
||||
g_strVersion = "SJ90C V1.1.0_" + buildDate.toString("yyyyMMdd");
|
||||
g_strVersion = "SJ90C V1.1.0_" + buildDate.toString("yyyyMMdd") + "_FCJ";
|
||||
customLogMessageHandler(QtDebugMsg,g_strVersion + " " + buildTime.toString());
|
||||
g_strProject = settingsread.value("main/Project").toString();
|
||||
g_strFre = settingsread.value("main/Fre").toString();
|
||||
|
||||
107
realtimeform.cpp
107
realtimeform.cpp
@ -104,10 +104,7 @@ void CRealTimeForm::timerEvent(QTimerEvent *ev) {
|
||||
m_pSocket->connectToHost(IP, m_nServerPort);
|
||||
// 设置超时连接时间
|
||||
m_bConnected = m_pSocket->waitForConnected(1 * 1000);
|
||||
// QNetworkRequest req;
|
||||
// QString sUrl = QString("http://%1/cgi-bin/General.cgi/").arg(IP);
|
||||
// req.setUrl(sUrl);
|
||||
// g_NetMgr->PostJson(req,allObj);
|
||||
|
||||
QJsonDocument doc(allObj);
|
||||
QString strData = QString(doc.toJson(QJsonDocument::Indented));
|
||||
int nRet = m_pSocket->write(strData.toStdString().c_str(), strlen(strData.toStdString().c_str()));
|
||||
@ -146,8 +143,6 @@ void CRealTimeForm::InitChannelInfo() {
|
||||
|
||||
void CRealTimeForm::on_graphView_customContextMenuRequested(const QPoint &pos) {
|
||||
qDebug() << " custom menu!!!!!!!!!" << "##" << pos.x() << " ; " << pos.y();
|
||||
// if(ui->graphicsView->itemAt(pos) || ui->graphicsView_2->itemAt(pos))
|
||||
// return;
|
||||
QMenu menu(this);
|
||||
pActionVerticalLine = menu.addAction("添加竖线");
|
||||
pActionHorizontalLine = menu.addAction("添加横线");
|
||||
@ -180,14 +175,6 @@ void CRealTimeForm::on_graphView_customContextMenuRequested(const QPoint &pos) {
|
||||
connect(pActionAlignmentX, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||
connect(pActionAlignmentY, SIGNAL(triggered()), this, SLOT(onTaskBoxContextMenuEvent()));
|
||||
menu.exec(QCursor::pos());
|
||||
//menu.exec(ui->graphicsView->mapToGlobal(pos));
|
||||
// if(pActionLine == menu.exec(ui->graphicsView->mapToGlobal(pos))){
|
||||
// qDebug() << " Line!!!!!!!!!"<< "##"<< pos.x() << " ; "<< pos.y();
|
||||
// SetCurDrawType("Line",pos);
|
||||
// }else if(pActionRect == menu.exec(ui->graphicsView->mapToGlobal(pos))){
|
||||
// qDebug() << " Rect!!!!!!!!!"<< "##"<< pos.x() << " ; "<< pos.y();
|
||||
// SetCurDrawType("Rect",pos);
|
||||
// }
|
||||
}
|
||||
void CRealTimeForm::onTaskBoxContextMenuEvent() {
|
||||
QAction *pEven = qobject_cast<QAction *>(this->sender());
|
||||
@ -257,7 +244,6 @@ void CRealTimeForm::SetAlignmentX() {
|
||||
QList<float> list = channleAxisX.values();
|
||||
qSort(list);
|
||||
float minValue = list.first();
|
||||
qDebug() << "minValue" << minValue << endl;
|
||||
QMap<QGraphicsItem *, float>::iterator iter = channleAxisX.begin();
|
||||
for (; iter != channleAxisX.end(); iter++) {
|
||||
iter.key()->setPos(minValue, iter.key()->y());
|
||||
@ -309,7 +295,7 @@ void CRealTimeForm::on_addchannel(channelBaseInfo channelbaseInfo, QString str)
|
||||
pen.setColor(QColor(0, 0, 0, 0));
|
||||
pen.setWidth(1);
|
||||
CMyCustomGraphicsItem *pItemGroup = new CMyCustomGraphicsItem();
|
||||
QGraphicsRectItem *pRect = new QGraphicsRectItem(0, 0, 290, 30);
|
||||
QGraphicsRectItem *pRect = new QGraphicsRectItem(0, 0, 430, 40);
|
||||
pRect->setBrush(QBrush(QColor(255, 255, 255)));
|
||||
pRect->setPen(pen);
|
||||
pRect->setPos(0, 0);
|
||||
@ -378,18 +364,18 @@ void CRealTimeForm::on_addchannel(channelBaseInfo channelbaseInfo, QString str)
|
||||
pTextValue->setData(3, "value");
|
||||
pTextValue->setData(4, str); //特征值
|
||||
QFont font;
|
||||
font.setPixelSize(16);
|
||||
QFont font2("黑体", 18, 50);
|
||||
font.setPixelSize(22);
|
||||
QFont font2("黑体", 24, 50);
|
||||
font.setFamily(QStringLiteral("黑体"));
|
||||
pTextUnits->setFont(font);
|
||||
pTextUnits->setDefaultTextColor(QColor(27, 30, 35));
|
||||
pTextChannel->setFont(font);
|
||||
pTextValue->setFont(font2);
|
||||
pTextValue->setPos(160, -2);
|
||||
pTextValue->setPos(280, -2);
|
||||
pTextValue->setDefaultTextColor(QColor(31, 81, 136));
|
||||
pTextChannel->setPos(0, 2);
|
||||
pTextChannel->setPos(0, 5);
|
||||
pTextChannel->setDefaultTextColor(QColor(27, 30, 35));
|
||||
pTextUnits->setPos(240, 5);
|
||||
pTextUnits->setPos(380, 5);
|
||||
// 设置可移动、可选择
|
||||
pItemGroup->addToGroup(pTextChannel);
|
||||
pItemGroup->addToGroup(pTextValue);
|
||||
@ -542,7 +528,6 @@ void CRealTimeForm::SaveGraphicsConfig() {
|
||||
case 6: { //Line
|
||||
QPointF pos = graphicsItem->pos();
|
||||
QRectF rect = graphicsItem->boundingRect();
|
||||
//qDebug() << "Line" << pos << rect;
|
||||
QJsonObject LinejsonObject;
|
||||
LinejsonObject.insert("x", pos.x());
|
||||
LinejsonObject.insert("y", pos.y());
|
||||
@ -555,7 +540,6 @@ void CRealTimeForm::SaveGraphicsConfig() {
|
||||
case 7: { //Pixmap
|
||||
QPointF pos = graphicsItem->pos();
|
||||
QRectF rect = graphicsItem->boundingRect();
|
||||
//qDebug() << "Pixmap" << pos << rect;
|
||||
QJsonObject PixmapjsonObject;
|
||||
PixmapjsonObject.insert("x", pos.x());
|
||||
PixmapjsonObject.insert("y", pos.y());
|
||||
@ -584,9 +568,7 @@ void CRealTimeForm::SaveGraphicsConfig() {
|
||||
QPointF pos = pGraphicGroupItem->pos();
|
||||
QRectF rect = pGraphicGroupItem->boundingRect();
|
||||
channelBaseInfo temp;
|
||||
//qDebug() << "Group" << pos << rect;
|
||||
QString strChannelID = pGraphicGroupItem->data(0).toString();
|
||||
//qDebug() << "pGraphicGroupItem data" << strChannelID << endl;
|
||||
QJsonArray GroupRectjsonArray, GroupTextjsonArray;
|
||||
QJsonObject itemjsonObject;
|
||||
QList<QGraphicsItem *> items = pGraphicGroupItem->childItems();
|
||||
@ -596,13 +578,10 @@ void CRealTimeForm::SaveGraphicsConfig() {
|
||||
itemData = item->data(i).toString();
|
||||
if (itemData == "value") {
|
||||
itemData2 = item->data(i + 1).toString();
|
||||
//qDebug() << "item va data" << itemData << itemData2 << i << endl;
|
||||
break;
|
||||
} else if (itemData == "channel") {
|
||||
//qDebug() << "item ch data" << itemData << i << endl;
|
||||
break;
|
||||
} else if (itemData == "units") {
|
||||
//qDebug() << "item un data" << itemData << i << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -686,18 +665,13 @@ void CRealTimeForm::SaveGraphicsConfig() {
|
||||
}
|
||||
QJsonDocument jsonDoc;
|
||||
jsonDoc.setObject(jsonObject);
|
||||
//QString fileName = QFileDialog::getSaveFileName(this,"另存为 ","xxx.json");
|
||||
//if(!fileName.isEmpty())
|
||||
{
|
||||
qDebug() << "另存为" << fileName;
|
||||
QFile file(fileName);
|
||||
//if(!file.exists())
|
||||
{
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(jsonDoc.toJson());
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
qDebug() << "另存为" << fileName;
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(jsonDoc.toJson());
|
||||
file.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CRealTimeForm::slotDoubleClick(QGraphicsSceneMouseEvent *event) {
|
||||
@ -714,7 +688,6 @@ void CRealTimeForm::LoadGraphicsConfig(int type) {
|
||||
QPen pen; // 定义一个画笔,设置画笔颜色和宽度
|
||||
pen.setColor(QColor(0, 0, 0, 0));
|
||||
pen.setWidth(1);
|
||||
//QString fileName =QFileDialog::getOpenFileName(this,"打开文件",QDir::currentPath(), "*.json");
|
||||
for (int ii = 0; ii < ui->tabWidget->count(); ii++) {
|
||||
QString strFileName = QString("Graph%1.json").arg(ii + 1);
|
||||
#ifdef Q_OS_WIN32
|
||||
@ -833,14 +806,12 @@ void CRealTimeForm::LoadGraphicsConfig(int type) {
|
||||
} else {
|
||||
movie = new QMovie(QCoreApplication::applicationDirPath() + "/image/unit/zhouliushi.gif");
|
||||
}
|
||||
//pPixmap = new QGraphicsPixmapItem(QPixmap(QCoreApplication::applicationDirPath() + "/image/unit/zhouliushi.png"));
|
||||
} else if (strContent == "可逆式机组") {
|
||||
if (type == 1 || type == 2) {
|
||||
pPixmap = new QGraphicsPixmapItem(QPixmap(QCoreApplication::applicationDirPath() + "/image/unit/kenishi.png"));
|
||||
} else {
|
||||
movie = new QMovie(QCoreApplication::applicationDirPath() + "/image/unit/kenishi.gif");
|
||||
}
|
||||
//pPixmap = new QGraphicsPixmapItem(QPixmap(QCoreApplication::applicationDirPath() + "/image/unit/kenishi.png"));
|
||||
} else if (strContent == "灯泡式机组") {
|
||||
if (type == 1 || type == 2) {
|
||||
pPixmap = new QGraphicsPixmapItem(QPixmap(QCoreApplication::applicationDirPath() + "/image/unit/dengpaoshi.png"));
|
||||
@ -873,25 +844,6 @@ void CRealTimeForm::LoadGraphicsConfig(int type) {
|
||||
proxy->setGeometry(QRectF(key["x"].toInt(), key["y"].toInt(), 0, 0));
|
||||
}
|
||||
}
|
||||
// QGraphicsPixmapItem *pPixmap = new QGraphicsPixmapItem(QPixmap(":/image/1.png"));
|
||||
// pPixmap->setPos(key["x"].toInt(), key["y"].toInt());
|
||||
// pPixmap->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
// if(ii == 0){
|
||||
// m_pGraphicsScene->addItem(pPixmap);
|
||||
// }else if(ii == 1){
|
||||
// m_pGraphicsScene_2->addItem(pPixmap);
|
||||
// }
|
||||
// QLabel *gif_anim = new QLabel();
|
||||
// QMovie *movie = new QMovie(":/image/1.gif");
|
||||
// gif_anim->setMovie(movie);
|
||||
// movie->start();
|
||||
// QGraphicsProxyWidget *proxy = m_pGraphicsScene->addWidget(gif_anim);
|
||||
// QGraphicsMovieItem *pPixmap = new QGraphicsMovieItem();
|
||||
// pPixmap->setPos(key["x"].toInt(), key["y"].toInt());
|
||||
// QMovie movie(":/image/1.png");
|
||||
// pPixmap->setMovie(&movie);
|
||||
// movie.start();
|
||||
// m_pGraphicsScene->addItem(pPixmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -944,7 +896,6 @@ void CRealTimeForm::LoadGraphicsConfig(int type) {
|
||||
pItemGroup->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
}
|
||||
connect(pItemGroup, SIGNAL(doubleclick(QGraphicsSceneMouseEvent *)), this, SLOT(slotDoubleClick(QGraphicsSceneMouseEvent *)));
|
||||
//qDebug() << array.at(i)["x"].toDouble() << array.at(i)["y"].toDouble() << endl;
|
||||
QJsonObject jsonObject = array.at(i).toObject();
|
||||
if (jsonObject.contains(QStringLiteral("Rect"))) {
|
||||
QJsonValue arrayValue = jsonObject.value(QStringLiteral("Rect"));
|
||||
@ -956,7 +907,7 @@ void CRealTimeForm::LoadGraphicsConfig(int type) {
|
||||
QGraphicsRectItem *pRect = new QGraphicsRectItem(
|
||||
0,
|
||||
0,
|
||||
290, 30);
|
||||
430, 40);
|
||||
pRect->setPos(key["x"].toDouble(), key["y"].toDouble());
|
||||
if (type == 1) {
|
||||
pRect->setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
@ -981,8 +932,8 @@ void CRealTimeForm::LoadGraphicsConfig(int type) {
|
||||
pText->setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
}
|
||||
QFont font;
|
||||
QFont font2("黑体", 18, 50);
|
||||
font.setPixelSize(16);
|
||||
QFont font2("黑体", 24, 50);
|
||||
font.setPixelSize(22);
|
||||
font.setFamily(QStringLiteral("黑体"));
|
||||
pText->setFont(font);
|
||||
if (key["data"].toString() == "units") {
|
||||
@ -1019,7 +970,6 @@ void CRealTimeForm::LoadGraphicsConfig(int type) {
|
||||
}
|
||||
}
|
||||
void CRealTimeForm::keyPressEvent(QKeyEvent *event) {
|
||||
//QGraphicsItem::keyPressEvent(event);
|
||||
qDebug() << "键盘按下";
|
||||
if (event->key() == Qt::Key_Delete) {
|
||||
qDebug() << "press Key_Delete";
|
||||
@ -1223,26 +1173,6 @@ void CRealTimeForm::ParseCharacteristic(QJsonArray &arrayValue) {
|
||||
void CRealTimeForm::slotRecieve() {
|
||||
QByteArray arrayReady = m_pSocket->readAll();
|
||||
m_arrayReady += arrayReady;
|
||||
// customLogMessageHandler(QtDebugMsg,m_arrayReady);
|
||||
// qDebug() << "arrayReady" << arrayReady << endl;
|
||||
// QJsonDocument doc = QJsonDocument::fromJson(arrayReady);
|
||||
// QJsonObject objec = doc.object();
|
||||
// if(objec.contains("cmd"))
|
||||
// {
|
||||
// QJsonValue arrays_value = objec.take("cmd");
|
||||
// qDebug()<<"cmd ="<<arrays_value.toString();
|
||||
// if(arrays_value.toString() == "09"){
|
||||
// QJsonArray arrayValue = objec["content"].toArray();
|
||||
// QJsonArray arrayValueDIs = objec["DIO_Board_DIs"].toArray();
|
||||
// QJsonArray arrayValueDOs = objec["DIO_Board_DOs"].toArray();
|
||||
// ParseCharacteristic(arrayValue);
|
||||
// QString strTrgStatus = objec["currentTriggerStatus"].toString();
|
||||
// QString strWCStatus = objec["currentWorkCondition"].toString();
|
||||
// QString str = strTrgStatus + "," + strWCStatus;
|
||||
// sigWCStatus(str);
|
||||
// sigDOStatus(arrayValueDIs,arrayValueDOs);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void CRealTimeForm::disConnect() {
|
||||
@ -1253,9 +1183,7 @@ void CRealTimeForm::disConnect() {
|
||||
}
|
||||
if (objec.contains("cmd")) {
|
||||
QJsonValue arrays_value = objec.take("cmd");
|
||||
//qDebug()<<"cmd ="<<arrays_value.toString();
|
||||
if (arrays_value.toString() == "09") {
|
||||
//qDebug()<<"cmd ="<<arrays_value.toString();
|
||||
QJsonArray arrayValue = objec["content"].toArray();
|
||||
QJsonArray arrayValueDIs = objec["DIO_Board_DIs"].toArray();
|
||||
QJsonArray arrayValueDOs = objec["DIO_Board_DOs"].toArray();
|
||||
@ -1287,7 +1215,6 @@ void CRealTimeForm::slotNetMgr(QString sAddr, const QVariant &msg) {
|
||||
QJsonObject objec = msg.value<QJsonObject>();
|
||||
if (objec.contains("cmd")) {
|
||||
QJsonValue arrays_value = objec.take("cmd");
|
||||
//qDebug()<<"cmd ="<<arrays_value.toString();
|
||||
if (arrays_value.toString() == "09") {
|
||||
QJsonArray arrayValue = objec["content"].toArray();
|
||||
QJsonArray arrayValueDIs = objec["DIO_Board_DIs"].toArray();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user