From f7afc54abbef4d9dc07b0ba95d22a511d4bbdff8 Mon Sep 17 00:00:00 2001 From: "15089880081@163.com" <15089880081@163.com> Date: Thu, 23 May 2024 16:47:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=89=8D=E7=AB=AF=E7=BB=93?= =?UTF-8?q?=E6=9E=84=EF=BC=8C=E5=88=A0=E9=99=A4=E8=80=81=E6=97=A7=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HandleAiUi-new/front/ExtendedGroupBox.cpp | 73 --- .../HandleAiUi-new/front/ExtendedGroupBox.h | 38 -- .../HandleAiUi-new/front/HMessageBox.cpp | 110 ---- HanddleAI/HandleAiUi-new/front/HMessageBox.h | 34 - HanddleAI/HandleAiUi-new/front/buttonmenu.cpp | 146 ----- HanddleAI/HandleAiUi-new/front/buttonmenu.h | 60 -- HanddleAI/HandleAiUi-new/front/cfgwindow.cpp | 608 ------------------ HanddleAI/HandleAiUi-new/front/cfgwindow.h | 204 ------ .../HandleAiUi-new/front/hpromptwidget.cpp | 40 -- .../HandleAiUi-new/front/hpromptwidget.h | 25 - .../HandleAiUi-new/front/imagereslistview.cpp | 312 --------- .../HandleAiUi-new/front/imagereslistview.h | 81 --- HanddleAI/HandleAiUi-new/front/m_toolbar.cpp | 183 ------ HanddleAI/HandleAiUi-new/front/m_toolbar.h | 48 -- .../HandleAiUi-new/front/myGroupWidget.cpp | 604 ----------------- .../HandleAiUi-new/front/myGroupWidget.h | 112 ---- HanddleAI/HandleAiUi-new/front/mywidget.cpp | 296 --------- HanddleAI/HandleAiUi-new/front/mywidget.h | 47 -- HanddleAI/HandleAiUi-new/front/qimageview.cpp | 47 -- HanddleAI/HandleAiUi-new/front/qimageview.h | 23 - .../HandleAiUi-new/front/qimagewidget.cpp | 145 ----- HanddleAI/HandleAiUi-new/front/qimagewidget.h | 62 -- HanddleAI/HandleAiUi-new/front/titlebar.cpp | 412 ------------ HanddleAI/HandleAiUi-new/front/titlebar.h | 87 --- HanddleAI/HandleAiUi-new/front/viewwidget.cpp | 124 ---- HanddleAI/HandleAiUi-new/front/viewwidget.h | 56 -- HanddleAI/HandleAiUi-new/front/waitwidget.cpp | 353 ---------- HanddleAI/HandleAiUi-new/front/waitwidget.h | 125 ---- HanddleAI/HandleAiUi-new/mainwindow.cpp | 5 - 29 files changed, 4460 deletions(-) delete mode 100644 HanddleAI/HandleAiUi-new/front/ExtendedGroupBox.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/ExtendedGroupBox.h delete mode 100644 HanddleAI/HandleAiUi-new/front/HMessageBox.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/HMessageBox.h delete mode 100644 HanddleAI/HandleAiUi-new/front/buttonmenu.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/buttonmenu.h delete mode 100644 HanddleAI/HandleAiUi-new/front/cfgwindow.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/cfgwindow.h delete mode 100644 HanddleAI/HandleAiUi-new/front/hpromptwidget.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/hpromptwidget.h delete mode 100644 HanddleAI/HandleAiUi-new/front/imagereslistview.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/imagereslistview.h delete mode 100644 HanddleAI/HandleAiUi-new/front/m_toolbar.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/m_toolbar.h delete mode 100644 HanddleAI/HandleAiUi-new/front/myGroupWidget.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/myGroupWidget.h delete mode 100644 HanddleAI/HandleAiUi-new/front/mywidget.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/mywidget.h delete mode 100644 HanddleAI/HandleAiUi-new/front/qimageview.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/qimageview.h delete mode 100644 HanddleAI/HandleAiUi-new/front/qimagewidget.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/qimagewidget.h delete mode 100644 HanddleAI/HandleAiUi-new/front/titlebar.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/titlebar.h delete mode 100644 HanddleAI/HandleAiUi-new/front/viewwidget.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/viewwidget.h delete mode 100644 HanddleAI/HandleAiUi-new/front/waitwidget.cpp delete mode 100644 HanddleAI/HandleAiUi-new/front/waitwidget.h diff --git a/HanddleAI/HandleAiUi-new/front/ExtendedGroupBox.cpp b/HanddleAI/HandleAiUi-new/front/ExtendedGroupBox.cpp deleted file mode 100644 index 6f4bef2e..00000000 --- a/HanddleAI/HandleAiUi-new/front/ExtendedGroupBox.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include "ExtendedGroupBox.h" - -ExtendedGroupBox::ExtendedGroupBox(QWidget* parent /*= nullptr*/, State state /*= STATE_NORMAL*/) - : QGroupBox(parent) -{ - setObjectName("ExtendedGroupBox"); - setCheckable(true); - state_ = state; - if (state_ == STATE_NORMAL) - { - //隐藏垂直边框 - setFlat(true); - setChecked(false); - } - connect(this, SIGNAL(clicked(bool)), this, SLOT(onChecked(bool))); -} - -ExtendedGroupBox::ExtendedGroupBox(const QString& title, QWidget* parent /*= nullptr*/, State state /*= STATE_NORMAL*/) - : QGroupBox(title, parent) -{ - m_tittle = title; - setObjectName("ExtendedGroupBox"); - setCheckable(true); - state_ = state; - if (state_ == STATE_NORMAL) - { - //隐藏垂直边框 - setFlat(true); - setChecked(false); - } - connect(this, SIGNAL(clicked(bool)), this, SLOT(onChecked(bool))); -} - -void ExtendedGroupBox::addWidget(QWidget* widget) -{ - if (widget != nullptr) - { - if (state_ == STATE_NORMAL) - { - widget->setVisible(false); - } - children_.push_back(widget); - } -} - -void ExtendedGroupBox::onChecked(bool checked) -{ - if (checked) - { - //显示垂直边框 - setFlat(false); - for (auto iter = children_.begin(); iter != children_.end(); ++iter) - { - (*iter)->setVisible(true); - } - state_ = STATE_EXPAND; - } - else - { - //隐藏垂直边框 - setFlat(true); - for (auto iter = children_.begin(); iter != children_.end(); ++iter) - { - (*iter)->setVisible(false); - } - state_ = STATE_NORMAL; - } -} - -ExtendedGroupBox::State ExtendedGroupBox::getState() const -{ - return state_; -} \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/front/ExtendedGroupBox.h b/HanddleAI/HandleAiUi-new/front/ExtendedGroupBox.h deleted file mode 100644 index 135b45b0..00000000 --- a/HanddleAI/HandleAiUi-new/front/ExtendedGroupBox.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef EXTENDED_GROUP_BOX_H_ -#define EXTENDED_GROUP_BOX_H_ - -#include -#include - -#pragma execution_character_set("utf-8") //能够正常显示中文字符串 - -class ExtendedGroupBox : public QGroupBox -{ - Q_OBJECT - -public: - enum State - { - STATE_NORMAL, - STATE_EXPAND - }; - -public: - ExtendedGroupBox(QWidget* parent = nullptr, State state = STATE_NORMAL); - ExtendedGroupBox(const QString& title, QWidget* parent = nullptr, State state = STATE_NORMAL); - -private Q_SLOTS: - void onChecked(bool checked); - -public: - void addWidget(QWidget* widget); - State getState() const; - QString m_tittle; - -private: - QVector children_; - State state_; -}; - - -#endif//EXTENDED_GROUP_BOX_H_ \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/front/HMessageBox.cpp b/HanddleAI/HandleAiUi-new/front/HMessageBox.cpp deleted file mode 100644 index 7a35c42a..00000000 --- a/HanddleAI/HandleAiUi-new/front/HMessageBox.cpp +++ /dev/null @@ -1,110 +0,0 @@ -#include "HMessageBox.h" -#include - -HMessageBox::HMessageBox(QWidget* parent) :QWidget(parent) -{ - setFixedSize(350, 200); - setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::MSWindowsFixedSizeDialogHint); - setStyleSheet("QWidget{background-color: rgb(30, 30, 30);}" - "QTextEdit{border-style: none;color:white; font-size:20px;}" - "QPushButton{color:white; font-size:20px;}"); - //initWidget(str); - okButton = new QPushButton("OK"); - noButton = new QPushButton("NO"); - connect(okButton, &QPushButton::clicked, this, &HMessageBox::clickOkButton); - connect(noButton, &QPushButton::clicked, this, &HMessageBox::clickNoButton); -} - -HMessageBox::~HMessageBox() -{ - if (okButton) { - delete okButton; - okButton = nullptr; - } - if (noButton) { - delete noButton; - noButton = nullptr; - } - if (infoLabel) { - delete infoLabel; - infoLabel = nullptr; - } - if (m_eventLoop) { - - delete m_eventLoop; - m_eventLoop = nullptr; - } - -} - -void HMessageBox::initWidget(QString info,int windowMode) -{ - infoLabel = new QTextEdit(); - //infoLabel->setWordWrap(true); - infoLabel->adjustSize(); - infoLabel->setText(info); - - okButton->setFixedSize(80, 40); - - QVBoxLayout* layout = new QVBoxLayout(); - layout->addWidget(infoLabel); - QHBoxLayout* layout1 = new QHBoxLayout(); - layout1->addWidget(okButton,Qt::AlignCenter); - if (windowMode == 1) - { - noButton->setFixedSize(80, 40); - layout1->addWidget(noButton, Qt::AlignCenter); - } - layout->addLayout(layout1); - setLayout(layout); - - -} - -void HMessageBox::clickOkButton() -{ - clickResult = 0; - close(); -} - -void HMessageBox::clickNoButton() -{ - clickResult = 1; - close(); -} - -int HMessageBox::showMyMessageBox(QWidget* parent, const QString& contentText, int windowMode, bool isModelWindow) -{ - QScopedPointer ptr; - HMessageBox* myMessageBox = new HMessageBox(parent); - myMessageBox->initWidget(contentText, windowMode); - ptr.reset(myMessageBox); - if (isModelWindow) - { - return myMessageBox->exec(); - } - else - { - myMessageBox->show(); - } - return 0; -} - -int HMessageBox::exec() -{ - this->setWindowModality(Qt::WindowModal); - show(); - m_eventLoop = new QEventLoop(this); - m_eventLoop->exec(); - - return clickResult; -} - -void HMessageBox::closeEvent(QCloseEvent* event) -{ - if (m_eventLoop != NULL) - { - m_eventLoop->exit(); - } - event->accept(); -} diff --git a/HanddleAI/HandleAiUi-new/front/HMessageBox.h b/HanddleAI/HandleAiUi-new/front/HMessageBox.h deleted file mode 100644 index 08e12a68..00000000 --- a/HanddleAI/HandleAiUi-new/front/HMessageBox.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma execution_character_set("utf-8") - - class HMessageBox : public QWidget -{ - Q_OBJECT -public: - HMessageBox(QWidget* parent = 0); - ~HMessageBox(); - - void initWidget(QString info, int windowMode); - int static showMyMessageBox(QWidget* parent, const QString& contentText, int windowMode, bool isModelWindow = false); -private slots: - void clickOkButton(); - void clickNoButton(); -private: - int exec(); - void closeEvent(QCloseEvent* event); - QTextEdit* infoLabel; - QPushButton* okButton; - QPushButton* noButton; - - QEventLoop* m_eventLoop; - int clickResult; -}; \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/front/buttonmenu.cpp b/HanddleAI/HandleAiUi-new/front/buttonmenu.cpp deleted file mode 100644 index e35fa16e..00000000 --- a/HanddleAI/HandleAiUi-new/front/buttonmenu.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "buttonmenu.h" - -ButtonMenu::ButtonMenu(QWidget *parent) : QPushButton(parent) -{ - m_Font.setPixelSize(13); - m_Font.setFamily("Microsoft YaHei"); - - setContextMenuPolicy(Qt::ActionsContextMenu); -} - -void ButtonMenu::FileTranslateBtn() -{ - m_openAct->setText(tr("&打开方案")); - m_openAct->setStatusTip(tr("打开方案")); - m_saveAct->setText(tr("&保存方案")); - m_saveAct->setStatusTip(tr("保存方案")); - /* m_exitAct->setText(tr("&关闭方案")); - m_exitAct->setStatusTip(tr("关闭方案"));*/ -} - -void ButtonMenu::SetTranslateBtn() -{ - m_statistical->setText(tr("检测结果界面")); - m_commAct->setText(tr("通信管理")); -} - -void ButtonMenu::AddFileAction() -{ - QMenu *m_FileMenu = new QMenu; - - m_FileMenu->setFont(m_Font); - - //m_newAct = new QAction(tr("&新建方案"), this); - //m_newAct->setShortcuts(QKeySequence::New); - //m_newAct->setStatusTip(tr("Create a new file")); - //m_FileMenu->addAction(m_newAct); - - m_openAct = new QAction; - m_openAct->setFont(m_Font); - m_openAct->setText(tr("&打开配方")); - m_openAct->setStatusTip(tr("打开配方")); - m_openAct->setShortcuts(QKeySequence::Open); - m_FileMenu->addAction(m_openAct); - - m_saveAct = new QAction; - m_saveAct->setFont(m_Font); - m_saveAct->setText(tr("&保存配方")); - m_saveAct->setStatusTip(tr("保存配方")); - m_saveAct->setShortcuts(QKeySequence::Save); - m_FileMenu->addAction(m_saveAct); - - /* m_exitAct = new QAction; - m_exitAct->setText(tr("&关闭方案")); - m_exitAct->setStatusTip(tr("关闭方案")); - m_exitAct->setShortcuts(QKeySequence::Quit); - m_FileMenu->addAction(m_exitAct);*/ - - /*connect(m_newAct, SIGNAL(triggered()), this, SLOT(NewFile()));*/ - connect(m_openAct, SIGNAL(triggered()), this, SLOT(OpenFile())); - connect(m_saveAct, SIGNAL(triggered()), this, SLOT(SaveFile())); - //connect(m_exitAct, SIGNAL(triggered()), this, SLOT(CloseWindow())); - - this->setMenu(m_FileMenu); -} - -void ButtonMenu::AddSetAction() -{ - QMenu *m_SetMenu = new QMenu; - m_SetMenu->setFont(m_Font); - m_statistical = new QAction(QIcon(":/Image/titlebar/paste.png"),tr("检测结果界面"),this); - m_statistical->setFont(m_Font); - m_statistical->setText(tr("检测结果界面")); - // m_statistical->setShortcut(QKeySequence::Cut); - m_SetMenu->addAction(m_statistical); - - m_commAct = new QAction(QIcon(":/Image/titlebar/communicate_n.png"),tr("通信管理"),this); - m_commAct->setFont(m_Font); - m_commAct->setText(tr("通信管理")); - // m_commAct->setShortcut(QKeySequence::Copy); - m_SetMenu->addAction(m_commAct); - - //m_cameraManage = new QAction(QIcon(":/Image/titlebar/camera_n.png"),tr("Camera management"),this); - //m_cameraManage->setShortcut(QKeySequence::Paste); - //m_SetMenu->addAction(m_cameraManage); - - - //deleteAct = new QAction(tr("Delete"), this); - ////deleteAct->setShortcut(QKeySequence::Delete); - //m_SetMenu->addAction(deleteAct); - - connect(m_statistical,SIGNAL(triggered()),this,SLOT(On_statisticalTable())); - connect(m_commAct,SIGNAL(triggered()),this,SLOT(On_CommAct())); - /* connect(m_cameraManage,SIGNAL(triggered()),this,SLOT(On_CameraManage())); - connect(deleteAct, SIGNAL(triggered()), this, SLOT(deleteItem()));*/ - - this->setMenu(m_SetMenu); -} - -void ButtonMenu::NewFile() -{ - // qDebug() << "new file"; -} - -void ButtonMenu::OpenFile() -{ - QDir currPath = QApplication::applicationDirPath()+QString::fromUtf8("/config/Parma"); - QString fileName = QFileDialog::getOpenFileName(0, QString::fromUtf8("打开配置"),currPath.path(),tr("file (*.json)")); - if(!fileName.isEmpty() ) - { - emit OpenProJectSignal(fileName); - } -} -void ButtonMenu::SaveFile() -{ - QDir currPath = QApplication::applicationDirPath(); - QString defaultName = currPath.path() + QString::fromUtf8("/config/Parma") +"/parma_1.json"; - QString saveFileName = QFileDialog::getSaveFileName(0, QString::fromUtf8("配置文件(*.json)"),defaultName,tr("*.json")); - if (!saveFileName.isEmpty()) - { - emit SaveProJectSignal(saveFileName); - } -} -void ButtonMenu::CloseWindow() -{ - emit CloseWindows(); -} - -void ButtonMenu::On_statisticalTable() -{ - emit showstatisticalTable(); -} - -void ButtonMenu::On_CommAct() -{ - emit commManage(); -} - -void ButtonMenu::On_CameraManage() -{ - emit CameraManage(); -} - -void ButtonMenu::deleteItem() -{ - -} diff --git a/HanddleAI/HandleAiUi-new/front/buttonmenu.h b/HanddleAI/HandleAiUi-new/front/buttonmenu.h deleted file mode 100644 index 0ea996cb..00000000 --- a/HanddleAI/HandleAiUi-new/front/buttonmenu.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef DRAWMENUBAR_H -#define DRAWMENUBAR_H - -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma execution_character_set("utf-8") //能够正常显示中文字符串 - -class ButtonMenu : public QPushButton -{ - Q_OBJECT -public: - explicit ButtonMenu(QWidget *parent = nullptr); - void FileTranslateBtn(); //文件菜单翻译 - void SetTranslateBtn(); //设置菜单翻译 -public: - //void MenuBarInit(); - void AddFileAction(); - void AddSetAction(); -private: - QAction *m_newAct = nullptr; - QAction *m_openAct = nullptr; - QAction *m_saveAct = nullptr; - QAction *m_exitAct = nullptr; - QFont m_Font; - // Set action - QAction * m_statistical = nullptr; - QAction * m_commAct = nullptr; - QAction * m_cameraManage= nullptr; - QAction * deleteAct = nullptr; - QAction * undoAct = nullptr; - QAction * redoAct = nullptr; - QAction * zoomInAct = nullptr; - QAction * zoomOutAct = nullptr; -public slots: - void NewFile(); - void OpenFile(); - void SaveFile(); - void CloseWindow(); - void On_statisticalTable(); - void On_CommAct(); - void On_CameraManage(); - void deleteItem(); - -signals: - void OpenProJectSignal(QString); //打开方案 - void SaveProJectSignal(QString); //保存方案 - void CloseWindows(); //关闭窗口 - void showstatisticalTable(); //显示结果统计 - void commManage(); //通讯管理 - void CameraManage(); //相机管理 -}; - -#endif // DRAWMENUBAR_H diff --git a/HanddleAI/HandleAiUi-new/front/cfgwindow.cpp b/HanddleAI/HandleAiUi-new/front/cfgwindow.cpp deleted file mode 100644 index 6d7d427f..00000000 --- a/HanddleAI/HandleAiUi-new/front/cfgwindow.cpp +++ /dev/null @@ -1,608 +0,0 @@ -#include "cfgwindow.h" -#include -#include -#include -#include -#include -#include -#include -#include //异步线程 -#include -#include -#include "ExtendedGroupBox.h" -#include "toolkit.h" -#include "myGroupWidget.h" -#include ; - -RightWidget::RightWidget(QWidget* parent) : QWidget(parent) -{ - setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::MSWindowsFixedSizeDialogHint - | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); - setStyleSheet("QWidget{background-color: rgb(75, 75, 75);}"); - - - QDir dir = QApplication::applicationDirPath(); - QString currPath = dir.path(); - Config_Save_path = QString("%1/%2").arg(currPath, QString::fromUtf8("config/软件加载配置.csv")); - Config_Det_path = QString("%1/%2").arg(currPath, QString::fromUtf8("config/缺陷配方表.csv")); - - init(); -} - -RightWidget::~RightWidget() -{ - - for (auto val = 0; val < btnlist.size(); val++) - { - if (btnlist.at(val)) - { - QToolButton* ptr = const_cast(btnlist.at(val)); - delete ptr; - ptr = nullptr; - } - } - - if (m_cfg) - { - delete m_cfg; - m_cfg = nullptr; - } -} - -void RightWidget::init() -{ - setMouseTracking(true); - QString btnStyle = "QToolButton{background:transparent;border:0px;} " - "QToolButton:hover{background-color:rgb(80, 80, 80);}" - "QToolTip{border:1px solid rgb(50,50,50); background-color: rgb(50,50,50); color:rgb(255,255,255); font-size:12px;}" - "QToolButton:pressed{color: rgb(219,219,219);background-color:transparent;}"; - - QDir currPath = QApplication::applicationDirPath(); - //dp->mainWidget->show(); - // 图像切换 - QPixmap map; - QToolButton* start_Ptr = new QToolButton; - start_Ptr->setFixedSize(50, 50); - map.load(currPath.path() + "/Icon/oncerun.png"); - start_Ptr->setIcon(map); - start_Ptr->setIconSize(QSize(35, 35)); - start_Ptr->setStyleSheet(btnStyle); - start_Ptr->setToolTip(QString::fromUtf8("图像切换")); - btnlist.append(start_Ptr); - connect(start_Ptr, &QToolButton::clicked, this, [=]() { - emit sendBtnSignal(1); - }); - - // 循环运行 - QToolButton* loop_Ptr = new QToolButton; - loop_Ptr->setFixedSize(50, 50); - map.load(currPath.path() + "/Icon/开始训练_n.png"); - loop_Ptr->setIcon(map); - loop_Ptr->setIconSize(QSize(35, 35)); - loop_Ptr->setStyleSheet(btnStyle); - loop_Ptr->setToolTip(QString::fromUtf8("开始执行")); - btnlist.append(loop_Ptr); - loop_Ptr->setDisabled(true); - - - // 停止 - QToolButton* stop_ptr = new QToolButton; - stop_ptr->setFixedSize(50, 50); - map.load(currPath.path() + "/Icon/停止训练_s.png"); - stop_ptr->setIcon(map); - stop_ptr->setIconSize(QSize(35, 35)); - stop_ptr->setStyleSheet(btnStyle); - stop_ptr->setToolTip(QString::fromUtf8("停止执行")); - btnlist.append(stop_ptr); - stop_ptr->setDisabled(true); - connect(loop_Ptr, &QToolButton::clicked, this, [=]() { - emit sendBtnSignal(2); - //loop_Ptr->setDisabled(true); - stop_ptr->setDisabled(false); - }); - connect(stop_ptr, &QToolButton::clicked, this, [=]() { - emit sendBtnSignal(3); - loop_Ptr->setDisabled(false); - stop_ptr->setDisabled(true); - }); - - // 刷新 - QToolButton* refresh_ptr = new QToolButton; - refresh_ptr->setFixedSize(50, 50); - map.load(currPath.path() + "/Icon/重置参数_s.png"); - refresh_ptr->setIcon(map); - refresh_ptr->setIconSize(QSize(35, 35)); - refresh_ptr->setStyleSheet(btnStyle); - refresh_ptr->setToolTip(QString::fromUtf8("清理数据")); - btnlist.append(refresh_ptr); - connect(refresh_ptr, &QToolButton::clicked, this, [=]() { - emit sendBtnSignal(4); - }); - - QHBoxLayout* m_HBox = new QHBoxLayout; - m_HBox->addWidget(start_Ptr); - m_HBox->addWidget(loop_Ptr); - m_HBox->addWidget(stop_ptr); - m_HBox->addWidget(refresh_ptr); - - m_cfg = new CfgWindow; - - QVBoxLayout* m_VBox = new QVBoxLayout; - m_VBox->addWidget(m_cfg); - m_VBox->addLayout(m_HBox); - m_VBox->addSpacing(3); - - - QHBoxLayout* mainWidgetLayout = new QHBoxLayout(this); - QWidget* mainWidget = new QWidget; - mainWidget->setMouseTracking(true); - mainWidgetLayout->addWidget(mainWidget); - mainWidgetLayout->setMargin(0); - mainWidget->setLayout(m_VBox); - - -} - -void RightWidget::mouseMoveEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - setCursor(Qt::ArrowCursor); -} - - -void RightWidget::SetSavePath(const QString path) -{ - -} - -void RightWidget::SetDetPath(const QString path) -{ -} - -void RightWidget::Load_Param_Config(const QString path) -{ - if (path.isEmpty())return; - emit m_cfg->Loadparam(path); -} - -void RightWidget::Save_Param_Config(const QString path) -{ - if (path.isEmpty())return; - emit m_cfg->Saveparam(path); -} - -CfgWindow::CfgWindow(QWidget* parent) : QTabWidget(parent) -{ - - setMouseTracking(true); - this->setAttribute(Qt::WA_StyledBackground); - this->tabBar()->setStyleSheet("QTabBar::tab{border:none;background-color:rgb(50,50,50);color:rgb(188, 188, 188);font:15px 'Microsoft YaHei'; min-width:97px ;min-height:26px;}" - "QTabBar::tab:hover{background-color:rgb(50,50,50);color:rgb(255, 255, 255);font:16px 'Microsoft YaHei'}" - "QTabBar::tab:selected{background-color:rgb(218,102,53);color:rgb(255, 255, 255);font:16px 'Microsoft YaHei'}"); - this->setDocumentMode(true); - - initwidget(); -} - -CfgWindow::~CfgWindow() -{ - if (m_param) { - delete m_param; - m_param = nullptr; - } - - if (m_runinfo) { - delete m_runinfo; - m_runinfo = nullptr; - } - - if (m_statist) { - delete m_statist; - m_statist = nullptr; - } -} - -void CfgWindow::initwidget() -{ - m_param = new MyParamSet; - m_runinfo = new RunInfo; - m_statist = new statisticsTab; - - addTab(m_runinfo, QString::fromUtf8("生产信息")); - addTab(m_param, QString::fromUtf8("参数设置")); - - //addTab(m_statist, QString::fromUtf8("统计报表")); - connect(this, &CfgWindow::Loadparam, m_param, &MyParamSet::UpParData); - connect(this, &CfgWindow::Saveparam, m_param, &MyParamSet::SaveParData); -} - -RunInfo::RunInfo(QWidget* parent) :QWidget(parent) -{ - setMouseTracking(true); - initwidget(); - -} - -RunInfo::~RunInfo() -{ - -} - -void RunInfo::initwidget() -{ - _OnceDataDisplay = new OnceDataDisplay(); - QVBoxLayout* layout = new QVBoxLayout(); - layout->addWidget(_OnceDataDisplay); - - cpkCalculatePanelPtr = new cpkCalculatePanel(); - layout->addWidget(cpkCalculatePanelPtr); - this->setLayout(layout); - - this->setLayout(layout); -} - -void RunInfo::mouseMoveEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - setCursor(Qt::ArrowCursor); -} - - -statisticsTab::statisticsTab(QWidget* parent) :QWidget(parent) -{ - setMouseTracking(true); -} - -void statisticsTab::mouseMoveEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - setCursor(Qt::ArrowCursor); -} - -statisticsTab::~statisticsTab() -{ - -} - -void statisticsTab::initwidget() -{ -} - - - -LogTable::LogTable(QWidget* parent) -{ - - setMouseTracking(true); - this->setAttribute(Qt::WA_StyledBackground); - this->setDocumentMode(true); - setStyleSheet("QTabBar::tab{border:none;background-color:rgb(50,50,50);color:rgb(188, 188, 188);font:15px 'Microsoft YaHei'; min-width:97px ;min-height:26px;}" - "QTabBar::tab:hover{background-color:rgb(50,50,50);color:rgb(255, 255, 255);font:16px 'Microsoft YaHei'}" - "QTabBar::tab:selected{background-color:rgb(218,102,53);color:rgb(255, 255, 255);font:16px 'Microsoft YaHei'}"); - initwidget(); - -} -LogTable::~LogTable() -{ - if (m_plclog) { - delete m_plclog; - m_plclog = nullptr; - } - - if (m_systemlog) { - delete m_systemlog; - m_systemlog = nullptr; - } -} - -void LogTable::initwidget() -{ - // 初始化界面 - - m_plclog = new LogWidget(this); - m_systemlog = new LogWidget(this); - - addTab(m_plclog, tr("PLC日志")); - addTab(m_systemlog, tr("运行日志")); - connect(this, &LogTable::GetPlcMsgShow, m_plclog, &LogWidget::GetMsgShow); - connect(this, &LogTable::GetSystemMsgShow, m_systemlog, &LogWidget::GetMsgShow); - -} - -LogWidget::LogWidget(QWidget* parent) -{ - setMouseTracking(true); - - this->setAttribute(Qt::WA_StyledBackground); - this->setStyleSheet("QTabBar::tab{border:none;background-color:rgb(50,50,50);color:rgb(188, 188, 188);font:15px 'Microsoft YaHei'; min-width:97px ;min-height:26px;}" - "QTabBar::tab:hover{background-color:rgb(50,50,50);color:rgb(255, 255, 255);font:16px 'Microsoft YaHei'}" - "QTabBar::tab:selected{background-color:rgb(218,102,53);color:rgb(255, 255, 255);font:16px 'Microsoft YaHei'}" - "QTextBrowser{background-color: rgb(56, 56, 56);}"); - initwidget(); -} - -LogWidget::~LogWidget() -{ - if (m_log) { - delete m_log; - m_log = nullptr; - } -} - -void LogWidget::initwidget() -{ - - - m_log = new QTextBrowser(); - m_log->document()->setMaximumBlockCount(100);//设置显示最大行数 - m_log->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//关闭滚动条 - m_log->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//关闭滚动条 - QVBoxLayout* m_VBox = new QVBoxLayout; - m_VBox->addWidget(m_log); - - setLayout(m_VBox); - - - - // - connect(this, &LogWidget::GetMsgShow, [this](QString msg) { - if (msg.indexOf("TCP") != -1) { - QString q_msg = msg; - if ((q_msg.indexOf("_3") != -1))q_msg.append(" [Error]"); - else if ((q_msg.indexOf("DM1001") != -1) || (q_msg.indexOf("DM1002") != -1) || (q_msg.indexOf("DM1003") != -1)) { - //14:01:04 831 周 - int qa = q_msg.indexOf(QString::fromUtf8("周")); - if (qa > 10) { - std::string app = q_msg.mid(qa - 24, qa - 1).toStdString(); - QDateTime dateTime1 = QDateTime::fromString(q_msg.mid(qa - 24, qa - 1), "yyyy-MM-dd hh:mm:ss zzz "); - qint64 now_1 = dateTime1.toMSecsSinceEpoch(); - if (old_time == "") { - q_msg = (QString::fromUtf8("TCP [心跳开始]")); - - } - else if (old_time.size() > 5) { - QDateTime dateTime2 = QDateTime::fromString(old_time, "yyyy-MM-dd hh:mm:ss zzz "); - qint64 old = dateTime2.toMSecsSinceEpoch(); - double de = (now_1 - old) / 1000.0; - if (de > 10) { - q_msg = (QString::fromUtf8("[ TCP Error ][心跳断联]") + QString::number(de) + "s : " + q_msg.mid(qa - 24, qa - 1) + " -- " + old_time); - qDebug() << q_msg << endl; - - } - else if (de > 3) { - q_msg = (QString::fromUtf8("[ TCP Error ][心跳超时]") + QString::number(de) + "s : " + q_msg.mid(qa - 24, qa - 1) + " -- " + old_time); - qDebug() << q_msg << endl; - } - else { - q_msg = (QString::fromUtf8("[ TCP ] [心跳间隔]") + QString::number(de) + "s"); - } - - } - old_time = dateTime1.toString("yyyy-MM-dd hh:mm:ss zzz "); - msg = q_msg; - - } - - } - - } - else if (msg.indexOf("IMAGETIME") != -1) { - QString q_msg = msg; - int qa = q_msg.indexOf(QString::fromUtf8("周")); - if (qa > 10) { - std::string app = q_msg.mid(qa - 24, qa - 1).toStdString(); - QDateTime dateTime1 = QDateTime::fromString(q_msg.mid(qa - 24, qa - 1), "yyyy-MM-dd hh:mm:ss zzz "); - //"D://2Dpic//" + dateTime + "_" + sn + "_" + QString::number(picIndex) + "_" + surfaceInfo + "_" + task_index + ".bmp" - int index = q_msg.split("_").at(4).toInt()+1; - QString SN = q_msg.split("_").at(1); - QString oldt = q_msg.mid( q_msg.lastIndexOf("\\")).mid(0,24); - QDateTime dateTime2 = QDateTime::fromString(oldt, "yyyy-MM-dd-hh-mm-ss-zzz"); - - qint64 now_1 = dateTime1.toMSecsSinceEpoch(); - qint64 old = dateTime2.toMSecsSinceEpoch(); - double de = (now_1 - old) / 1000.0; - if (de > index*2) { - q_msg = (QString::fromUtf8("[ 错图 ]") + QString::number(de) + "s : " + q_msg); - qDebug() << q_msg << endl; - - } - else { - return; - } - - - - - } - else { - return; - } - } - else { - return; - } - if (m_log) { - - QString app; - QString fontsize = ""+ msg+ ""+ "+ "); - } - else if ((msg.indexOf("Error") != -1)||(msg.indexOf("error") != -1)) { - app= app = QString(fontsize + " color=red>"+ msg+ "" + "+ "); - } - else { - app = app = QString(fontsize + " color=floralwhite>" + msg + "" + "+ "); - } - if (app.isEmpty())return; - m_log->append(app); - m_log->moveCursor(QTextCursor::End);//自动滚动到最后一行 - } - }); - //ui->tbMessage->append("xxx"); - - m_log->append("等待按下开始按钮..."); -} -void LogWidget::showMsg(QString) -{ - m_log->append("xxx"); -} - - -LeftWindow::LeftWindow(QWidget* parent) : QWidget(parent) -{ - setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::MSWindowsFixedSizeDialogHint - | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); - setStyleSheet("QWidget{background-color: rgb(75, 75, 75);}"); - init(); -} - -LeftWindow::~LeftWindow() -{ - if (m_datasheet) { - - delete m_datasheet; - m_datasheet = NULL; - } - if (m_logtable) { - - delete m_logtable; - m_logtable = NULL; - } - if (m_gifwidget) { - - delete m_gifwidget; - m_gifwidget = NULL; - } - for each (auto gif in m_gif_list) { - QMovie* ptr = const_cast(gif); - ptr->stop(); - delete ptr; - ptr = nullptr; - } - m_gif_list.clear(); -} - - - -void LeftWindow::init() -{ - try{ - //遍历gif - QDir currPath = QApplication::applicationDirPath(); - QString path = currPath.path(); - - //日志界面 - m_logtable = new LogTable(this); - m_logtable->hide();/////////// - connect(this, &LeftWindow::GetLogMsg, [this](QString msg, int plclog) { - if (plclog) { - emit m_logtable->GetPlcMsgShow(msg); - } - else { - emit m_logtable->GetSystemMsgShow(msg); - } - }); - - - QStringList giflist = addSubFolderDirectory(path, QStringList() << "*.png"); - for each (auto var in giflist) { - QMovie* gifs = new QMovie(var); - connect(gifs, &QMovie::frameChanged, [=]() { - if (gifs->currentFrameNumber() >= gifs->frameCount() - 1)gifs->stop();//判断当前gif是否为最后帧,关闭gif循环播放 - }); - m_gif_list.append(gifs); - } - QHBoxLayout* mainWidgetLayout = new QHBoxLayout(this); - mainWidgetLayout->setAlignment(Qt::AlignTop); - QWidget* mainWidget = new QWidget(this); - mainWidget->setMouseTracking(true); - mainWidgetLayout->addWidget(mainWidget); - mainWidgetLayout->setMargin(0); - - QVBoxLayout* m_hbox = new QVBoxLayout(); - m_datasheet = new DateSheetWidget(this); - QString json_cfg = currPath.path() + "/config/camera_cfg.json"; - QJsonObject cfg_obj = loadJsonCfg(json_cfg); - QJsonArray tablelist; - if (cfg_obj.isEmpty()) { - qCritical() << "[Error] " << " cfg_obj is null!"; - //return; - } - if (cfg_obj.contains("tablelist")) { - if(cfg_obj.value("tablelist").isArray()) - tablelist = cfg_obj.value("tablelist").toArray(); - } - - m_datasheet->initwidget(tablelist); - - m_gifwidget = new QLabel(this); - m_gifwidget->setScaledContents(true); - m_gifwidget->setAlignment(Qt::AlignCenter); - m_hbox->addWidget(m_datasheet, 2); - m_hbox->addWidget(m_gifwidget, 4); - m_hbox->addWidget(m_logtable, 4); - - mainWidget->setLayout(m_hbox); - - dumpToExcel* dp = new dumpToExcel(); - m_hbox->addWidget(dp->showMainWidgetBtn); - - tableViewPtr = new tableView({ u8"序列号",u8"尺寸(mm)",u8"面积",u8"缺陷序号" }); - bridge.front.tableViewPtr = tableViewPtr; - m_hbox->addWidget(tableViewPtr->tableWidget); - - connect(this, &LeftWindow::GetShowGif, this, &LeftWindow::ShowGif); - ShowGif(Index); - connect(this, &LeftWindow::GetMsgShow, m_datasheet, &DateSheetWidget::On_reciveData); - - ShowGif(Index); - - } - catch (QString ev) { - qCritical() << "[Error] " << " ev:" << ev; - return; - } - -} - -void LeftWindow::mouseMoveEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - setCursor(Qt::ArrowCursor); -} - - - -void LeftWindow::PausedGif() -{ - if (m_gif_list[Index]->state()==QMovie::Running) { - - - m_gif_list[Index]->setPaused(true); - } - else if(m_gif_list[Index]->state() == QMovie::Paused) { - - m_gif_list[Index]->setPaused(false); - } - else { - - } - -} - -void LeftWindow::ShowGif(int index) -{ - if (m_gif_list.count() < Index)return; - m_gif_list[Index]->stop(); - //m_gifwidget->setMovie(m_gif_list[index]); - m_gif_list[index]->setSpeed(100); - m_gif_list[index]->start(); - Index = index; - qApp->processEvents(); - -} - - - diff --git a/HanddleAI/HandleAiUi-new/front/cfgwindow.h b/HanddleAI/HandleAiUi-new/front/cfgwindow.h deleted file mode 100644 index 3827627f..00000000 --- a/HanddleAI/HandleAiUi-new/front/cfgwindow.h +++ /dev/null @@ -1,204 +0,0 @@ -#ifndef CFGWINDOW_H -#define CFGWINDOW_H - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma execution_character_set("utf-8") //能够正常显示中文字符串 - -class RunInfo; -class MyParamSet; -class statisticsTab; -class CfgWindow; -class LogTable; -class DateSheetWidget; -class ExtendedGroupBox;// 自动升缩Group -class MyGroupWidget;//自定义Group嵌套组件 - - -class RightWidget : public QWidget -{ - Q_OBJECT -public: - explicit RightWidget(QWidget* parent = nullptr); - ~RightWidget(); - void init(); - -protected: - void mouseMoveEvent(QMouseEvent* event)override; -private: - CfgWindow* m_cfg = nullptr; - QList btnlist; - -signals: - void sendBtnSignal(int); - -private: - QString Config_Save_path; - QString Config_Det_path; - - -public slots: - - void SetSavePath(const QString path); - - void SetDetPath(const QString path); - - //加载检测配置参数 - void Load_Param_Config(const QString path); - - //保存检测配置参数 - void Save_Param_Config(const QString path); - -}; -class LeftWindow : public QWidget -{ - Q_OBJECT -public: - explicit LeftWindow(QWidget* parent = nullptr); - ~LeftWindow(); - void init(); - -private: - tableView* tableViewPtr = nullptr; - DateSheetWidget* m_datasheet = nullptr; - LogTable* m_logtable = nullptr; - QLabel* m_gifwidget;//显示拍照gif - QListm_gif_list; - int Index = 0;//gif下标 - -protected: - void mouseMoveEvent(QMouseEvent* event)override; - -signals: - void GetMsgShow(const QString key,const QString msg);//更新界面标签数值 - void GetLogMsg(const QString msg,int plclog=0); - void GetShowGif(int index = 0); -public slots: - /// - /// 根据下标播放不同gif - /// - void ShowGif(int index = 0); - - /// - /// gif 播放暂停 - /// - void PausedGif(); -}; - -class CfgWindow : public QTabWidget -{ - Q_OBJECT -public: - explicit CfgWindow(QWidget* parent = nullptr); - ~CfgWindow(); - void initwidget(); -private: - MyParamSet* m_param; // 参数设置 - RunInfo* m_runinfo; - statisticsTab* m_statist; // 统计报表 - - - QStringList paramList; - QStringList runinfoList; - QStringList statistList; -signals: - void Loadparam(const QString path); - void Saveparam(const QString path); - void Loadruninfo(const QString path); - void Loadstatist(const QString path); - -}; - - - - -class RunInfo : public QWidget -{ - Q_OBJECT -public: - explicit RunInfo(QWidget* parent = nullptr); - ~RunInfo(); - void initwidget(); -private: - QStringList m_List; - OnceDataDisplay* _OnceDataDisplay; - cpkCalculatePanel* cpkCalculatePanelPtr = nullptr; -protected: - void mouseMoveEvent(QMouseEvent* event)override; -}; - - -class statisticsTab : public QWidget -{ - Q_OBJECT -public: - explicit statisticsTab(QWidget* parent = nullptr); - ~statisticsTab(); - void initwidget(); -private: - QStringList m_List; -protected: - void mouseMoveEvent(QMouseEvent* event)override; -}; - - - -//自定义日志窗口 -class LogWidget :public QWidget -{ - Q_OBJECT -public: - explicit LogWidget(QWidget* parent = nullptr); - ~LogWidget(); - void initwidget(); -private: - QTextBrowser* m_log; // PLC日志 - QString old_time = ""; -signals: - void GetMsgShow(const QString msg); -public slots: - void showMsg(QString); - -}; - -/// -/// Log Table -/// -class LogTable : public QTabWidget -{ - Q_OBJECT -public: - explicit LogTable(QWidget* parent = nullptr); - ~LogTable(); - void initwidget(); -private: - LogWidget* m_plclog; // PLC日志 - LogWidget* m_systemlog; // 软件日志 -signals: - void GetPlcMsgShow(const QString msg); - void GetSystemMsgShow(const QString msg); - - -}; - - - -#endif // CFGWINDOW_H diff --git a/HanddleAI/HandleAiUi-new/front/hpromptwidget.cpp b/HanddleAI/HandleAiUi-new/front/hpromptwidget.cpp deleted file mode 100644 index 4ac6b445..00000000 --- a/HanddleAI/HandleAiUi-new/front/hpromptwidget.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "hpromptwidget.h" -#include -#include - -HPromptWidget::HPromptWidget(QString info,QWidget *parent) : promptMessage(info),QWidget(parent) -{ - initWidget(); -} - -void HPromptWidget::initWidget() -{ - setFixedSize(350, 200); - setWindowFlags(Qt::Dialog | Qt::WindowSystemMenuHint | Qt::MSWindowsFixedSizeDialogHint); - setStyleSheet("QWidget{background-color: rgb(30, 30, 30);}" - "QTextEdit{border-style: none;color:white; font-size:20px;}" - "QPushButton{color:white; font-size:20px;}"); - - okButton = new QPushButton("OK"); - okButton->setFixedSize(80, 40); - - infoLabel = new QTextEdit(); - infoLabel->adjustSize(); - infoLabel->setText(promptMessage); - - QVBoxLayout* layout = new QVBoxLayout(); - layout->addWidget(infoLabel); - - QHBoxLayout* layout1 = new QHBoxLayout(); - layout1->addWidget(okButton,Qt::AlignCenter); - - layout->addLayout(layout1); - setLayout(layout); - - connect(okButton, &QPushButton::clicked, this, &HPromptWidget::closeWidget); -} - -void HPromptWidget::closeWidget() -{ - close(); -} diff --git a/HanddleAI/HandleAiUi-new/front/hpromptwidget.h b/HanddleAI/HandleAiUi-new/front/hpromptwidget.h deleted file mode 100644 index 4e6cad48..00000000 --- a/HanddleAI/HandleAiUi-new/front/hpromptwidget.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef HPROMPTWIDGET_H -#define HPROMPTWIDGET_H - -#include -#include -#include - -class HPromptWidget : public QWidget -{ - Q_OBJECT -public: - explicit HPromptWidget(QString info,QWidget *parent = nullptr); -protected: - void initWidget(); -protected slots: - void closeWidget(); -signals: - -private: - QString promptMessage; - QTextEdit* infoLabel; - QPushButton* okButton; -}; - -#endif // HPROMPTWIDGET_H diff --git a/HanddleAI/HandleAiUi-new/front/imagereslistview.cpp b/HanddleAI/HandleAiUi-new/front/imagereslistview.cpp deleted file mode 100644 index ee07385c..00000000 --- a/HanddleAI/HandleAiUi-new/front/imagereslistview.cpp +++ /dev/null @@ -1,312 +0,0 @@ -#include "imagereslistview.h" -#include "qimageview.h" -#include "qimagewidget.h" -#include -#include -#include -#include -#include -#include - -#include //异步线程 -#include -#include - -#include "toolkit.h" -ImageResListView::ImageResListView(QWidget* parent) : QWidget(parent) -{ - setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::MSWindowsFixedSizeDialogHint - | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); - - SavePath.append(QString::fromUtf8("\\192.168.1.120\\111"));//结果地址 工控机1 - SavePath.append(QString::fromUtf8("\\192.168.1.130\\111")); - SavePath.append(QString::fromUtf8("D:/111")); - - SavePath.append(QString::fromUtf8("\\192.168.1.120\\Ori"));//原图地址 工控机1 - SavePath.append(QString::fromUtf8("\\192.168.1.130\\Ori")); - SavePath.append(QString::fromUtf8("D:/Ori")); -} - -ImageResListView::~ImageResListView() -{ - - if (m_result_List) - { - delete m_result_List; - m_result_List = nullptr; - } - - if (m_view) - { - delete m_view; - m_view = nullptr; - } - -} - -void ImageResListView::initwidget() -{ - m_Font.setFamily("Microsoft YaHei"); - m_Font.setPixelSize(40); - QString m_style = "QLineEdit{border-with:0;border-style:outset;background:transparent;color:rgb(0,255,0);}"; - // 初始化控件 - - qgraphicsScene = new QGraphicsScene(this); - m_view = new QImageView(this); - m_view->setScene(qgraphicsScene);//Sets the current scene to scene. If scene is already being viewed, this function does nothing. - m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//关闭滑动条 - m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - up_label = new QLineEdit(this); - up_label->setStyleSheet(m_style); - up_label->setAttribute(Qt::WA_TranslucentBackground); - up_label->setFixedSize(100, 100); - up_label->setFont(m_Font); - up_label->setAlignment(Qt::AlignCenter); - up_label->setReadOnly(true); - up_label->setText(ok_str); - labptr.reset(up_label); - - down_label = new QLineEdit(this); - down_label->setStyleSheet(m_style); - down_label->setAttribute(Qt::WA_TranslucentBackground); - down_label->setText(QString::fromUtf8("SN: ")); - down_label->setFont(m_Font); - down_label->setReadOnly(true); - - label_ptr.reset(down_label); - - - m_Font.setPixelSize(20); - m_result_List = new QListWidget(this); - m_result_List->setFont(m_Font); - m_result_List->setSpacing(5);//设置单元项的间距 - m_result_List->setFlow(QListView::LeftToRight);//从左到右横向的排列,图片和文字也是从左到右排列 - m_result_List->setViewMode(QListView::IconMode);//左到右横向的排列,上图下文模式 - //m_result_List->setViewMode(QListView::ListMode);//子项就会从上到下排列,图片和文字是从左到右排列. - //m_result_List->setFlow(QListView::TopToBottom);//子项就会从上到下排列,图片和文字是从左到右排列. - m_result_List->setMovement(QListView::Static);//把列表设置为固定的(不能移动) - m_result_List->setSelectionBehavior(QAbstractItemView::SelectRows);//整行选中 - m_result_List->setSelectionMode(QAbstractItemView::SingleSelection);//单选 - m_result_List->setEditTriggers(QAbstractItemView::NoEditTriggers); //禁止编辑表格 - m_result_List->setIconSize(QSize(100, 80));//设置图片的大小 - m_result_List->setResizeMode(QListView::Adjust);//设置自动适应布局调整 - - - // 设置控件布局 - QHBoxLayout* mainWidgetLayout = new QHBoxLayout(this); - QWidget* mainWidget = new QWidget; - mainWidget->setMouseTracking(true); - mainWidgetLayout->addWidget(mainWidget); - mainWidgetLayout->setMargin(0); - QGridLayout* pLayout = new QGridLayout(); - pLayout->addWidget(m_view, 0, 0, 12, 16); - pLayout->addWidget(up_label, 0, 14, 2, 2); - pLayout->addWidget(down_label, 10, 0, 3, 16); - pLayout->addWidget(m_result_List, 12, 0, 4, 16); - mainWidget->setLayout(pLayout); - //QVBoxLayout* pvLayout = new QVBoxLayout(); - //pvLayout->addWidget(up_label); - //pvLayout->addWidget(m_view); - //pvLayout->addWidget(down_label); - //pvLayout->addWidget(m_result_List); - //pvLayout->setStretchFactor(up_label, 2); - //pvLayout->setStretchFactor(m_view, 12); - //pvLayout->setStretchFactor(down_label, 2); - //pvLayout->setStretchFactor(m_result_List, 4); - //pvLayout->setContentsMargins(3, 3, 3, 3); - //mainWidget->setLayout(pvLayout); - - connect(m_result_List, &QListWidget::currentRowChanged, this, &ImageResListView::changeRowList); - connect(this, &ImageResListView::GetShow, this, &ImageResListView::showText); - -} - - - -void ImageResListView::mouseMoveEvent(QMouseEvent* event) -{ - setCursor(Qt::ArrowCursor); -} - -void ImageResListView::addSN(const QString sn) -{ - SN = sn; - down_label->setText(SN); -} -void ImageResListView::changeRowList(int row) -{ - if (row != -1 && !search_start) - { - - QString path; - QImage* image = new QImage(); - image->load(str_resultList.at(row)); - if (image->isNull())return; - ShowImage(image); - show_index = row; - } -} - -void ImageResListView::getCodeSN(const QString res) { - - str_resultList.clear(); - QStringList pp = res.split(","); - addSN(pp.at(0)); - - QString SN = pp.at(0).split("_").at(1); - //time2会显示 invalid 数据无效,未根据设定的格式,设置日期 - QStringList times = pp.at(0).split("_").at(0).split("-"); - - QString day_time = QString("%1-%2-%3").arg(times.at(0), times.at(1), times.at(2)); - - QString h_time = times.at(3); - - for (int i = 0; i < 3; i++) { - auto var = SavePath.at(i); - QString resultDir = QString("%1/%2/%3H/%4").arg(var, day_time, h_time, pp.at(0)); - if (!isFileExist(resultDir)) { - qDebug() << "[Error] " << QString::fromUtf8("结果文件夹不存在 ") << resultDir << endl; - continue; - } - QStringList imageList = addSubFolderDirectory(resultDir);//日期下所有时间段 - str_resultList << imageList; - } - emit GetShow(pp.at(1)); - upListview(str_resultList); -} - -void ImageResListView::ShowImage(QImage* image) -{ - try - { - m_pImage = new QImageWidget(image); - qgraphicsScene->clear(); - int nwith = m_view->width();//获取界面控件Graphics View的宽度 - int nheight = m_view->height();//获取界面控件Graphics View的高度 - m_pImage->setQGraphicsViewWH(nwith, nheight);//将界面控件Graphics View的width和height传进类m_Image中 - qgraphicsScene->addItem(m_pImage);//将QGraphicsItem类对象放进QGraphicsScene中 - m_view->setSceneRect(QRectF(-(nwith / 2), -(nheight / 2), nwith, nheight)); - // ui->graphicsView->setScene(qgraphicsScene); - m_view->setFocus();//将界面的焦点设置到当前Graphics View控件 - if (image) - { - delete image; - image = nullptr; - } - } - catch (QString ev) - { - qDebug() << "[Error] " << " ev:" << ev; - } -} - -void ImageResListView::setSavePath(const QStringList& path) -{ - SavePath = path; -} - -void ImageResListView::clearAll() { - m_result_List->clear();//清理列表 - qgraphicsScene->clear(); - down_label->setText(QString::fromUtf8("SN: ")); - up_label->setText(ok_str); - qApp->processEvents(); - str_resultList.clear(); - -} - -void ImageResListView::upListview(const QStringList list) -{ - - emit waitSearch(); - m_result_List->clear();//清理列表 - qApp->processEvents(); - str_resultList.clear(); - QFutureWatcher* pwatcher = nullptr; - pwatcher = new QFutureWatcher; - - //把扫描到的信息输出 - QFuture future = QtConcurrent::run([=]() - { - search_start = 1; - for each (auto resultname in list) { - QStringList np = resultname.split("_"); - if (np.last().indexOf(".") != -1) { - QString imgpath = resultname; - QString result = np.last().mid(0, np.last().indexOf(".")); - QString station = np.at(np.size() - 5) + "-" + np.at(np.size() - 4); - if (isFileExist(imgpath)) { - - - QIcon icon(imgpath); - if (!icon.isNull()) { - //存 - QListWidgetItem* imgItem = new QListWidgetItem; - imgItem->setTextColor("black"); - imgItem->setText(station); - imgItem->setIcon(QIcon(imgpath));//图片路径 - imgItem->setSizeHint(QSize(100, 120)); - - if (result.indexOf(ok_str) == -1) { - imgItem->setBackground(ng_color); - } - else { - imgItem->setBackground(ok_color); - } - - - m_result_List->addItem(imgItem); - str_resultList.append(resultname); - - - } - - - } - } - - } - search_start = 0; - //耗时操作 - }); - - connect(pwatcher, &QFutureWatcher::finished, this, [=]() - { - //主线程操作 - if (list.size()) { - QString path; - QImage* image = new QImage(); - if (show_index >= list.size())show_index=0; - image->load(list.at(show_index)); - ShowImage(image); - } - - emit waitSearch(false); - qApp->processEvents(); - }); - - pwatcher->setFuture(future); -} - -void ImageResListView::showText(const QString result) -{ - if (result.indexOf(ok_str) == -1) { - up_label->setStyleSheet("QLineEdit{border-with:0;border-style:outset;background:transparent;color:rgb(255,0,0);}"); - } - else { - up_label->setStyleSheet("QLineEdit{border-with:0;border-style:outset;background:transparent;color:rgb(0,255,0);}"); - } - labptr->setText(result); -} - -int ImageResListView::getSearch() { - return search_start; -} - -void ImageResListView::stopSearch() -{ - search_start = 0; - QThread::msleep(10); -} - diff --git a/HanddleAI/HandleAiUi-new/front/imagereslistview.h b/HanddleAI/HandleAiUi-new/front/imagereslistview.h deleted file mode 100644 index 78ee1086..00000000 --- a/HanddleAI/HandleAiUi-new/front/imagereslistview.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef IMAGERESLISTVIEW_H -#define IMAGERESLISTVIEW_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma execution_character_set("utf-8") - -class QImageView; -class QImageWidget; -class ImageResListView :public QWidget { - Q_OBJECT -private: - - QStringList SavePath; //原图结果图路径 - QString currPath; - QFont m_Font; - QListWidget* m_result_List = nullptr; //检测数据列表 - - QLineEdit* up_label = nullptr; - QLineEdit* down_label = nullptr; - QString ok_str = QString::fromUtf8("OK"); - - QString SN; - QStringList str_resultList; //检索图片列表 - QColor ok_color = QColor(180, 165, 130); - QColor ng_color = QColor(202, 120, 83); - - int search_start = 0; - int show_index=0;//记录上次显示图片 -public: - explicit ImageResListView(QWidget* parent = nullptr); - ~ImageResListView(); - - void initwidget(); - void my_SetFont(const QFont& afont) { m_Font = afont; }; - void setPath(QString path) { currPath = path; initwidget(); } - void setSavePath(const QStringList& path);//设置检测结果存储路径 - void clearAll(); - int getSearch();// 获取检索状态 - void stopSearch();//设置检索状态 - - void upListview(const QStringList list); - void showText(const QString result); - -public slots: - void getCodeSN(const QString res); - - -private: - QPointF mainItemOriPos; - QGraphicsScene* qgraphicsScene = nullptr; - QImageWidget* m_pImage = nullptr; - QImageView* m_view = nullptr; - QScopedPointer labptr; - QScopedPointer label_ptr; - - -signals: - void waitSearch(bool isok = true);//搜索开始/结束 - void GetShow(const QString result); -protected: - - void addSN(const QString sn); - void changeRowList(int row); - void ShowImage(QImage* image); - void mouseMoveEvent(QMouseEvent* event)override; - -}; - - -#endif // IMAGERESLISTVIEW_H diff --git a/HanddleAI/HandleAiUi-new/front/m_toolbar.cpp b/HanddleAI/HandleAiUi-new/front/m_toolbar.cpp deleted file mode 100644 index 01016011..00000000 --- a/HanddleAI/HandleAiUi-new/front/m_toolbar.cpp +++ /dev/null @@ -1,183 +0,0 @@ -#include "m_toolbar.h" - -m_toolbar::m_toolbar(QWidget *parent) - :QToolBar(parent) -{ - setMouseTracking(true); -} - - -m_toolbar::~m_toolbar(void) -{ - for (auto val = 0; val < btnlist.size(); val++ ) - { - if(btnlist.at(val)) - { - QToolButton *ptr =const_cast(btnlist.at(val)); - delete ptr; - ptr = nullptr; - } - } - qDebug() << __FUNCTION__ << " line:" << __LINE__ << " ~m_toolbar success! " ; -} - -void m_toolbar::setShowFlag( bool flag ) -{ - if ( flag ) - initButtonList(); -} - -void m_toolbar::initButtonList() -{ - QString btnStyle = "QToolButton{background:transparent;border:0px;} " - "QToolButton:hover{background-color:rgb(27, 27, 27);}" - "QToolTip{border:1px solid rgb(50,50,50); background-color: rgb(50,50,50); color:rgb(255,255,255); font-size:12px;}" - "QToolButton:pressed{color: rgb(219,219,219);background-color:transparent;}"; - - QDir currPath = QApplication::applicationDirPath(); - - //单步执行 - QToolButton *start_Ptr = new QToolButton; - start_Ptr->setIcon( QIcon(currPath.path() + "/Icon/oncerun.png")); - start_Ptr->setStyleSheet(btnStyle); - start_Ptr->setToolTip("单步执行"); - start_Ptr->setFixedSize(25,25); - btnlist.append(start_Ptr); - //循环运行 - QToolButton *loop_Ptr = new QToolButton; - loop_Ptr->setIcon( QIcon(currPath.path() + "/Icon/cycleButton.png") ); - loop_Ptr->setStyleSheet(btnStyle); - loop_Ptr->setToolTip("循环执行"); - loop_Ptr->setFixedSize(25,25); - btnlist.append(loop_Ptr); - //停止 - QToolButton *stop_ptr = new QToolButton; - stop_ptr->setIcon(QIcon(currPath.path() + "/Icon/stop_n.png")); - stop_ptr->setStyleSheet(btnStyle); - stop_ptr->setToolTip("停止执行"); - stop_ptr->setFixedSize(25,25); - btnlist.append(stop_ptr); - - - - QWidget* m_spacer = new QWidget; - m_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - QHBoxLayout *hTopBox = new QHBoxLayout; - - hTopBox->addStretch(); - hTopBox->addWidget(start_Ptr); - hTopBox->addWidget(loop_Ptr); - hTopBox->addWidget(stop_ptr); - - hTopBox->setSpacing(10); - hTopBox->setContentsMargins(0,0,0,0); - - delete m_spacer->layout(); - m_spacer->setLayout(hTopBox); - - this->addWidget(m_spacer); - this->setContentsMargins(0,0,30,0); - - - connect(start_Ptr,SIGNAL(clicked(bool)),this,SLOT(select_state())); - connect(loop_Ptr,SIGNAL(clicked(bool)),this,SLOT(select_move())); - connect(stop_ptr,SIGNAL(clicked(bool)),this,SLOT(select_show_hide_mark())); - -} - -void m_toolbar::setDrawType(int type) -{ - switch (type) - { - case 1: - { - btnlist.at(0)->setEnabled(true); - btnlist.at(1)->setEnabled(true); - btnlist.at(2)->setEnabled(true); - break; - } - case 2: - { - btnlist.at(3)->setEnabled(true); - btnlist.at(4)->setEnabled(true); - btnlist.at(5)->setEnabled(true); - break; - } - case 3: - { - btnlist.at(5)->setEnabled(true); - break; - } - case 4: - { - btnlist.at(6)->setEnabled(true); - break; - } - default: - break; - } -} - -void m_toolbar::select_state() -{ - emit selectShapeSignal(1); -} - -void m_toolbar::select_move() -{ - emit selectShapeSignal(2); -} - -void m_toolbar::select_show_hide_mark() -{ - if(flag) - { - btnlist.at(2)->setIcon(QIcon(":/Image/src/mark_b.png")); - flag = false; - } - else - { - btnlist.at(2)->setIcon(QIcon(":/Image/src/mark_n.png")); - flag = true; - } - emit selectShapeSignal(2); -} - -void m_toolbar::select_rect() -{ - emit selectShapeSignal(3); -} - -void m_toolbar::select_polygon() -{ - emit selectShapeSignal(4); -} - - -void m_toolbar::select_circle() -{ - emit selectShapeSignal(5); -} - - -void m_toolbar::select_circle_fitting() -{ - emit selectShapeSignal(6); -} - -void m_toolbar::select_line_measurement() -{ - emit selectShapeSignal(7); -} - -void m_toolbar::select_spin_valueChanged(int value) -{ - emit changeVaule(value); - emit selectShapeSignal(8); -} - -void m_toolbar::mouseMoveEvent(QMouseEvent *event) -{ - emit Change_to_CannotDragResize(); -} diff --git a/HanddleAI/HandleAiUi-new/front/m_toolbar.h b/HanddleAI/HandleAiUi-new/front/m_toolbar.h deleted file mode 100644 index 5f579d9e..00000000 --- a/HanddleAI/HandleAiUi-new/front/m_toolbar.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef M_TOOLBAR_H -#define M_TOOLBAR_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma execution_character_set("utf-8") - -class m_toolbar : public QToolBar -{ - Q_OBJECT -public: - m_toolbar(QWidget *parent = 0); - ~m_toolbar(); - void initButtonList(); - void setShowFlag(bool flag); - void setDrawType(int type); //1: select 2:move 3:mark 4.rect 5.polygon 6.circle 7.circle_fitting 8.line_measurement -protected: - void mouseMoveEvent(QMouseEvent *event)Q_DECL_OVERRIDE; -private: - int SpinBoxValue = 4; //设置卡尺的数量,初始值为4 - bool flag = true; - QList btnlist; -signals: - void changeVaule(int); - void selectShapeSignal(int); - void Change_to_CannotDragResize(); -public slots: - void select_state(); - void select_move(); - void select_show_hide_mark(); - void select_rect(); - void select_polygon(); - void select_circle(); - void select_circle_fitting(); - void select_line_measurement(); - void select_spin_valueChanged(int); -}; -#endif // M_TOOLBAR_H diff --git a/HanddleAI/HandleAiUi-new/front/myGroupWidget.cpp b/HanddleAI/HandleAiUi-new/front/myGroupWidget.cpp deleted file mode 100644 index 406a87ee..00000000 --- a/HanddleAI/HandleAiUi-new/front/myGroupWidget.cpp +++ /dev/null @@ -1,604 +0,0 @@ -#include "myGroupWidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "ExtendedGroupBox.h" -#include "toolkit.h" -#include "waitwidget.h" -#include "FrontendBackendBridge.h" -MyParamSet::MyParamSet(QWidget* parent) :QWidget(parent) -{ - setMouseTracking(true); - setStyleSheet("QWidget{color: rgb(191, 191, 191);}"); - m_ScrollArea = new QScrollArea(this); - mainWidgetLayout = new QHBoxLayout; - gridPtr.reset(mainWidgetLayout); - initwidget(); -} - -MyParamSet::~MyParamSet() -{ - QStringList lists = m_labMap.keys(); - for each (auto var in lists) - { - if (m_labMap.contains(var)) - { - ExtendedGroupBox* ptr = const_cast(m_labMap[var]); - delete ptr; - ptr = nullptr; - - } - - } - m_labMap.clear(); - m_groupBoxlist.clear(); - - if (m_ScrollArea) { - delete m_ScrollArea; - m_ScrollArea = nullptr; - } - if (m_waitwidget) { - delete m_waitwidget; - m_waitwidget = nullptr; - } -} - -void MyParamSet::initwidget() -{ - QDir currPath = QApplication::applicationDirPath(); - QString json_cfg = currPath.path() + "/config/pram_set_init.json"; - UpParData(json_cfg); - m_waitwidget = new WaitProgressWidget(this); -} - -void MyParamSet::waitstart(int msec) -{ - if (m_waitwidget) { - m_waitwidget->start(msec); - } - qApp->processEvents(); - QThread::msleep(100); -} - -void MyParamSet::waitstop() -{ - if (m_waitwidget) { - m_waitwidget->stop(true); - } - qApp->processEvents(); - QThread::msleep(100); -} - - -void MyParamSet::fromJson2TXT( QJsonObject& obj) -{ - try { - - QStringList parmtxt1; - QStringList parmtxt2; - QStringList parmtxt3; - //QMap> configs; - QStringList keys = obj.keys(); - for each (auto var in keys) { - if (obj.value(var).isArray()) { - QJsonArray lists = obj.value(var).toArray(); - - //QMap config; - for each (auto var_2 in lists) { - if (var_2.isObject()) { - QJsonObject obj_2 = var_2.toObject(); - QStringList keys = obj_2.keys(); - for each (auto var_3 in keys) { - if (var.indexOf("外观缺陷参数") != -1) { - - if (obj_2.value(var_3).isArray()) { - QJsonArray lists_2 = obj_2.value(var_3).toArray(); - if (lists_2.size() == 7) { - QStringList parm{0,0,0,0,0,0,0}; - for each (auto var_4 in lists_2) { - if (var_4.isObject()) { - QJsonObject obj_3 = var_4.toObject(); - QStringList keys_2 = obj_3.keys(); - int index = -1; - if (obj_3.value("cName").toString().indexOf("最小值") != -1) { - index = 0; - } - else if (obj_3.value("cName").toString().indexOf("中间值") != -1) - { - index = 1; - } - else if (obj_3.value("cName").toString().indexOf("最大值") != -1) - { - index = 2; - } - else if (obj_3.value("cName").toString().indexOf("轻微计数") != -1) - { - index = 3; - } - else if (obj_3.value("cName").toString().indexOf("深度计数") != -1) - { - index = 4; - } - else if (obj_3.value("cName").toString().indexOf("深度阈值") != -1) - { - index = 5; - } - else if (obj_3.value("cName").toString().indexOf("缺陷矫正比例") != -1) - { - index = 6; - } - else { - - } - if(index>=0) - parm[index] = (obj_3.value("value").toString()); - } - - } - //config.insert(var_3, parm.join(",")); - parmtxt1.append(QString("%1=%2").arg(var_3, parm.join(","))); - } - - - } - - } - else if((var.indexOf("2D尺寸检测参数") != -1)|| (var.indexOf("基础配置参数") != -1)) { - - if (obj_2.value(var_3).isArray()) { - QJsonArray lists_2 = obj_2.value(var_3).toArray(); - for each (auto var_4 in lists_2) { - if (var_4.isObject()) { - QJsonObject obj_3 = var_4.toObject(); - QStringList keys_2 = obj_3.keys(); - //config.insert(obj_3.value("cName").toString(), obj_3.value("value").toString()); - parmtxt1.append(QString("%1=%2").arg(obj_3.value("cName").toString(), obj_3.value("value").toString())); - } - - } - } - } - else if ((var.indexOf("3D大面高度检测参数") != -1) ) { - - if (obj_2.value(var_3).isArray()) { - QJsonArray lists_2 = obj_2.value(var_3).toArray(); - for each (auto var_4 in lists_2) { - if (var_4.isObject()) { - QJsonObject obj_3 = var_4.toObject(); - QStringList keys_2 = obj_3.keys(); - //config.insert(obj_3.value("cName").toString(), obj_3.value("value").toString()); - parmtxt2.append(QString("%1=%2").arg(obj_3.value("cName").toString(), obj_3.value("value").toString())); - } - - } - } - } - else if ((var.indexOf("3D棱边高度检测参数") != -1)) { - - if (obj_2.value(var_3).isArray()) { - QJsonArray lists_2 = obj_2.value(var_3).toArray(); - for each (auto var_4 in lists_2) { - if (var_4.isObject()) { - QJsonObject obj_3 = var_4.toObject(); - QStringList keys_2 = obj_3.keys(); - //config.insert(obj_3.value("cName").toString(), obj_3.value("value").toString()); - parmtxt3.append(QString("%1=%2").arg(obj_3.value("cName").toString(), obj_3.value("value").toString())); - } - - } - } - } - - - } - } - - } - // configs.insert(var, config); - } - - } - if(!WriteTXTCfg(parmtxt1, "./000_Dllparam.txt"))qDebug()<<"WriteTXTCfg 000_Dllparam.txt fail "<(m_groupBoxlist[var]); - QJsonArray arr; - arr.append(ptr->GetDataMap()); - obj_vb.insert(var, arr); - } - - } - fromJson2TXT(obj_vb); - jsonDoc.setObject(obj_vb); - QString json_cfg = path; - QFile file(json_cfg); - if (!file.open(QIODevice::WriteOnly)) { - qDebug() << "[Error] " << file.fileName() << QString::fromUtf8("文件无法打开,参数修改失败"); - } - else { - qDebug() << "[INFO] " << file.fileName() << QString::fromUtf8("参数修改完成!"); - } - file.write(jsonDoc.toJson()); - file.close(); - waitstop(); - } - catch (QString ev) { - qCritical() << "[Error] " << " ev:" << ev; - return; - } - - -} - -void MyParamSet::UpParData(const QString path) -{ - try { - waitstart(); - //清理窗口 - QLayoutItem* child; - while ((child = mainWidgetLayout->layout()->takeAt(0)) != 0) { - if (child->widget()) { - child->widget()->setParent(NULL); - } - delete child; - } - QStringList lists = m_labMap.keys(); - for each (auto var in lists) - { - if (m_labMap.contains(var)) - { - ExtendedGroupBox* ptr = const_cast(m_labMap[var]); - delete ptr; - ptr = nullptr; - - } - - } - m_labMap.clear(); - m_groupBoxlist.clear(); - - QWidget* mainWidget = new QWidget(this); - mainWidget->setMouseTracking(true); - mainWidgetLayout->addWidget(mainWidget); - mainWidgetLayout->setMargin(0); - QVBoxLayout* m_VBox = new QVBoxLayout; - - QString json_cfg = path; - QJsonObject obj = loadJsonCfg(json_cfg); - QStringList keys = obj.keys(); - - - for each (auto var in keys) { - QVBoxLayout* advanced_setting_layout = new QVBoxLayout(); - ExtendedGroupBox* advanced_setting_group_box = new ExtendedGroupBox(var, this, ExtendedGroupBox::STATE_NORMAL); - MyGroupWidget* m_GroupBox = new MyGroupWidget(); - - QJsonArray tablelist = obj.value(var).toArray(); - m_GroupBox->initwidget(tablelist); - - m_groupBoxlist.insert(var, m_GroupBox); - m_labMap.insert(var, advanced_setting_group_box); - - advanced_setting_layout->addWidget(m_GroupBox); - advanced_setting_group_box->addWidget(m_GroupBox); - advanced_setting_group_box->setLayout(advanced_setting_layout); - - m_VBox->addWidget(advanced_setting_group_box); - } - - - m_VBox->addSpacing(3); - mainWidget->setLayout(m_VBox); - - m_ScrollArea->setWidget(mainWidget); - m_ScrollArea->setWidgetResizable(true); - waitstop(); - } - catch (QString ev) { - qCritical() << "[Error] " << " ev:" << ev; - return; - } - -} - -void MyParamSet::mouseMoveEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - setCursor(Qt::ArrowCursor); - -} - -void MyParamSet::resizeEvent(QResizeEvent* event) -{ - Q_UNUSED(event); - m_ScrollArea->resize(this->size()); -} - - - -MyGroupWidget::MyGroupWidget(QWidget* parent) : QWidget(parent) -{ - setObjectName("MyGroupWidget"); - setStyleSheet("QWidget{color: rgb(191, 191, 191);}"); - -} - -MyGroupWidget::~MyGroupWidget() -{ - QStringList lists = groupBoxlist.keys(); - for each (auto var in lists) - { - if (groupBoxlist.contains(var)) - { - ExtendedGroupBox* ptr = const_cast(groupBoxlist[var]); - delete ptr; - ptr = nullptr; - } - } - - groupBoxlist.clear(); - DateSheetlist.clear(); - -} - -void MyGroupWidget::initwidget(QJsonArray& pramjson) -{ - try { - QHBoxLayout* mainWidgetLayout = new QHBoxLayout(this); - QWidget* mainWidget = new QWidget(this); - mainWidget->setMouseTracking(true); - mainWidgetLayout->addWidget(mainWidget); - mainWidgetLayout->setMargin(0); - QVBoxLayout* m_VBox = new QVBoxLayout; - //判断加载成功 - if (pramjson.isEmpty()) - { - qCritical() << "[Error] " << QString::fromUtf8("参数文件无法打开!"); - return; - } - for (auto val = 0; val < pramjson.size(); val++) - { - if (pramjson.at(val).isObject()) { - QJsonObject obj = pramjson.at(val).toObject(); - if (!obj.isEmpty()) { - QStringList list = obj.keys(); - for each (auto var in list) { - QVBoxLayout* advanced_setting_layout = new QVBoxLayout(); - ExtendedGroupBox* advanced_setting_group_box = new ExtendedGroupBox(var, this, ExtendedGroupBox::STATE_NORMAL); - DateSheetWidget* m_datasheet = new DateSheetWidget(); - QJsonArray tablelist = obj.value(var).toArray(); - m_datasheet->initwidget(tablelist, false); - - groupBoxlist.insert(var, advanced_setting_group_box); - DateSheetlist.insert(var, m_datasheet); - advanced_setting_layout->addWidget(m_datasheet); - advanced_setting_group_box->addWidget(m_datasheet); - advanced_setting_group_box->setLayout(advanced_setting_layout); - m_VBox->addWidget(advanced_setting_group_box); - } - } - } - } - mainWidget->setLayout(m_VBox); - - } - catch (QString ev) { - qCritical() << "[Error] " << " ev:" << ev; - return; - } - -} - -QJsonObject MyGroupWidget::GetDataMap() -{ - - QStringList lists = DateSheetlist.keys(); - QJsonObject obj; - for each (auto var in lists) - { - - if (DateSheetlist.contains(var)) - { - - DateSheetWidget* ptr = const_cast(DateSheetlist[var]); - obj.insert(var, ptr->GetData()); - - } - } - - return obj; -} - -DateStateLabel::DateStateLabel(QWidget* parent) -{ - setObjectName("DateStateLabel"); -} - -DateStateLabel::~DateStateLabel() -{ -} - -void DateStateLabel::initwidget(const QString name, bool ReadOnly) -{ - QFont m_Font; - m_Font.setFamily("Microsoft YaHei"); - m_Font.setPixelSize(15); - - QString m_style = "QLabel{color:rgb(219,219,219);}"; - QString m_style1 = "QTextEdit{color:rgb(219,219,219);}"; - - QHBoxLayout* m_hbox = new QHBoxLayout; - QLabel* m_lab = new QLabel; - m_lab->setFont(m_Font); - m_lab->setStyleSheet(m_style); - m_lab->setFixedWidth(160); - m_lab->setFixedHeight(30); - m_lab->setText(name); - m_name = name; - label_ptr.reset(m_lab); - QTextEdit* m_edit = new QTextEdit; - m_edit->setFixedHeight(30); - m_edit->setFont(m_Font); - m_edit->setStyleSheet(m_style1); - m_edit->setFixedWidth(160); - m_edit->setFixedHeight(30); - m_edit->setAttribute(Qt::WA_TranslucentBackground); - m_edit->setAlignment(Qt::AlignCenter); - m_edit->setReadOnly(ReadOnly); - m_edit->setText(""); - text_ptr.reset(m_edit); - m_hbox->addWidget(m_lab); - m_hbox->addWidget(m_edit); - - setLayout(m_hbox); - - // connect - connect(m_edit, &QTextEdit::textChanged, [this]() { - if (m_value.isEmpty())return; - qDebug() << QString::fromUtf8("[%1] %2").arg(m_name, text_ptr->toPlainText()) << endl; - emit ValueChanged(QString::fromUtf8("[%1] %2").arg(m_name, text_ptr->toPlainText())); - }); - - -} - -QString DateStateLabel::get_value() -{ - m_value = text_ptr->toPlainText(); - return m_value; -} - -QString DateStateLabel::get_name() -{ - return m_name; -} - -void DateStateLabel::GetshowMag(const QString msg) -{ - text_ptr->setText(msg); - m_value = msg; -} - -DateSheetWidget::DateSheetWidget(QWidget* parent) -{ - setObjectName("DateSheetWidget"); - -} - -DateSheetWidget::~DateSheetWidget() -{ - - - QStringList lists = m_labMap.keys(); - for each (auto var in lists) - { - if (m_labMap.contains(var)) - { - DateStateLabel* ptr = const_cast(m_labMap[var]); - delete ptr; - ptr = nullptr; - } - } - m_labMap.clear(); - -} - -void DateSheetWidget::initwidget(QJsonArray& tablelist, bool ReadOnly) -{ - QHBoxLayout* mainWidgetLayout = new QHBoxLayout(this); - QWidget* mainWidget = new QWidget(this); - mainWidget->setMouseTracking(true); - mainWidgetLayout->addWidget(mainWidget); - mainWidgetLayout->setMargin(0); - - ////判断加载成功 - //if (tablelist.isEmpty()) - //{ - // qCritical() << "[Error] " << QString::fromUtf8("自定义界面无法打开,界面配置文件缺少tablelist属性!"); - // //return; - //} - QFont m_Font; - m_Font.setFamily("Microsoft YaHei"); - m_Font.setPixelSize(15); - - QString m_style = "QLabel{color:rgb(219,219,219);}"; - QString m_style1 = "QTextEdit{color:rgb(219,219,219);}"; - try - { - - QVBoxLayout* m_VBox = new QVBoxLayout; - for (auto val = 0; val < bridge.back.json.tableList.datas.size(); val++) - { - DateStateLabel* m_lab = new DateStateLabel(); - - QString name = bridge.back.json.tableList.datas[val].cName; - QString value = bridge.back.json.tableList.datas[val].value; - m_labMap.insert(name, m_lab); - m_lab->initwidget(name, ReadOnly); - m_lab->GetshowMag(value); - m_VBox->addWidget(m_lab); - } - m_VBox->addStretch(); - mainWidget->setLayout(m_VBox); - } - catch (QString ev) - { - qCritical() << "[Error] " << " ev:" << ev; - } - -} - -QJsonArray DateSheetWidget::GetData() -{ - QJsonArray arr; - QStringList keys = m_labMap.keys(); - for each (auto var in keys) { - QJsonObject obj; - obj.insert("cName", var); - obj.insert("value", m_labMap[var]->get_value()); - arr.append(obj); - } - return arr; -} - -void DateSheetWidget::On_reciveData(QString key, QString msg) -{ - if (m_labMap.count() > 0 && m_labMap.contains(key)) { - m_labMap.value(key)->GetshowMag(msg); - } -} - -void DateSheetWidget::mouseMoveEvent(QMouseEvent* event) -{ - Q_UNUSED(event); - setCursor(Qt::ArrowCursor); -} \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/front/myGroupWidget.h b/HanddleAI/HandleAiUi-new/front/myGroupWidget.h deleted file mode 100644 index e5f3bdcb..00000000 --- a/HanddleAI/HandleAiUi-new/front/myGroupWidget.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef MYGROUPWIDGET_H -#define MYGROUPWIDGET_H -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma execution_character_set("utf-8") - -class ExtendedGroupBox; -class WaitProgressWidget; -/// -/// 自定义标签输入框 -/// -class DateStateLabel : public QWidget -{ - Q_OBJECT -public: - explicit DateStateLabel(QWidget* parent = nullptr); - ~DateStateLabel(); - void initwidget(const QString name, bool ReadOnly = true); -private: - QScopedPointer label_ptr; - QScopedPointer text_ptr; - QString m_name = ""; - QString m_value = ""; -public: - QString get_value(); - QString get_name(); -signals: - void ValueChanged(const QString text); -public slots: - void GetshowMag(const QString msg); - -}; - -// 数据展示 -class DateSheetWidget :public QWidget { - Q_OBJECT -public: - explicit DateSheetWidget(QWidget* parent = nullptr); - ~DateSheetWidget(); - void initwidget(QJsonArray& tablelist, bool ReadOnly = true); - QJsonArray GetData(); - -private: - QMap m_labMap; - QScopedPointer widget_ptr; -public slots: - void On_reciveData(QString key, QString msg); // 传递数据 -protected: - void mouseMoveEvent(QMouseEvent* event)override; -}; - -/// -/// 自定义Group嵌套组件 -/// -class MyGroupWidget :public QWidget { - - Q_OBJECT -public: - - explicit MyGroupWidget(QWidget* parent = nullptr); - ~MyGroupWidget(); - void initwidget(QJsonArray& pramjson); -private: - QMap groupBoxlist; // 参数 - QMap DateSheetlist; - - -public: - QJsonObject GetDataMap(); - -}; - -class MyParamSet : public QWidget -{ - Q_OBJECT -public: - explicit MyParamSet(QWidget* parent = nullptr); - ~MyParamSet(); - void initwidget(); -private: - - QScopedPointer gridPtr; - QHBoxLayout* mainWidgetLayout = nullptr; - - QScrollArea* m_ScrollArea; - - QMap m_groupBoxlist; - - QMap m_labMap; - - WaitProgressWidget* m_waitwidget = nullptr; -protected: - void fromJson2TXT(QJsonObject&obj); - void waitstart(int msec = 60000); - void waitstop(); -public: - void SaveParData(const QString path); - void UpParData(const QString path); - -protected: - void mouseMoveEvent(QMouseEvent* event)override; - void resizeEvent(QResizeEvent* event)override; -}; -#endif \ No newline at end of file diff --git a/HanddleAI/HandleAiUi-new/front/mywidget.cpp b/HanddleAI/HandleAiUi-new/front/mywidget.cpp deleted file mode 100644 index 348eddb0..00000000 --- a/HanddleAI/HandleAiUi-new/front/mywidget.cpp +++ /dev/null @@ -1,296 +0,0 @@ -#include "MyWidget.h" -#include -#include -MyWidget::MyWidget(QWidget *parent) : QWidget(parent) -{ - - setWindowFlags(Qt::Window|Qt::FramelessWindowHint|Qt::WindowSystemMenuHint|Qt::MSWindowsFixedSizeDialogHint - |Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint); - - QString m_style = "QWidget{background-color: rgb(50, 50, 50);color:rgb(219,219,219);}"; - this->setStyleSheet(m_style); - - m_gridlayout = new QGridLayout; - gridPtr.reset(m_gridlayout); - m_type = MyWidgetType::RESULT; -} - -MyWidget::~MyWidget() -{ - for (int i = 0; i < m_list.size(); i++) - { - delete m_list.at(i); - } - m_list.clear(); - - qDebug() << " [INFO] " << " delete success!"; -} - - -bool MyWidget::layoutWindow(QJsonObject json_obj, MyWidgetType type) -{ - - qDebug() << " [INFO] " << " Change MyWidgetType:" << type; - try - { - // 清空布局 - QLayoutItem* child; - while ((child = m_gridlayout->takeAt(0)) != 0) { - if (child->widget()) { - child->widget()->setParent(NULL); - } - delete child; - } - // 清空显示窗口 - for (int i = 0; i < m_list.size(); i++) - { - delete m_list.at(i); - } - m_list.clear(); - - //加载配置文件 - QJsonArray array; - QJsonArray stationlist; - if (type == MyWidgetType::RESULT) { - stationlist = json_obj.value("showlist").toArray(); - - for (int i = 0; i < stationlist.size(); i++) - { - QJsonObject obj = stationlist.at(i).toObject(); - array.append(obj); - } - for (int i = 0; i < array.size(); i++) - { - QJsonObject obj = array.at(i).toObject(); - - QString key = obj.value("key").toString(); // key - QString cName = obj.value("cName").toString(); // 名称 - viewWidget* m_widget = new viewWidget; - m_widget->setKey(key); - m_widget->setName(cName); - - m_list.append(m_widget); - - } - } - else { - stationlist = json_obj.value("stationlist").toArray(); - - for (int i = 0; i < stationlist.size(); i++) - { - QJsonObject station_obj = stationlist.at(i).toObject(); - QString key = station_obj.value("key").toString(); - QJsonArray cameramodulelist = station_obj.value("cameramodulelist").toArray(); - - for (auto val = 0; val < cameramodulelist.size(); val++) - { - QJsonObject obj = cameramodulelist.at(val).toObject(); - array.append(obj); - } - } - for (int i = 0; i < array.size(); i++) - { - QJsonObject obj = array.at(i).toObject(); - - QString type = obj.value("type").toString(); - if (type.contains("camera")) - { - QString key = obj.value("key").toString(); // key 示例:camera1 - QString cName = obj.value("cName").toString(); // 相机名称 - viewWidget* m_widget = new viewWidget; - m_widget->setKey(key); - m_widget->setName(cName); - m_list.append(m_widget); - } - } - } - - if (array.isEmpty()) - return false; - - int m_row = 0; - if(m_list.size() < 4) - { - for (int iii = 0; iii < m_list.size(); iii++) - { - m_row = m_gridlayout->rowCount(); - if( m_list.size() - 1 > iii ) - { - m_gridlayout->addWidget(m_list.at(iii),m_row,0); - m_gridlayout->addWidget(m_list.at(iii+1),m_row,1); - iii += 1; - } - else if ( m_list.size()%2 != 0 && (m_list.size() -1 == iii)) - { - m_gridlayout->addWidget(m_list.at(iii),m_row,0); - } - } - } - else - { - int sqr = sqrt(m_list.size())+1; - for (int iii = 0; iii < sqr; iii++) { - for (int jjj = 0; jjj < sqr; jjj++) { - //qDebug() << __FUNCTION__ << " line:" << __LINE__ << " --- iii:" << iii; - if (iii * sqr + jjj < m_list.size()) { - m_gridlayout->addWidget(m_list.at(iii * sqr + jjj), iii, jjj); - } - else { - break; - } - } - } - - - } - m_gridlayout->setAlignment(Qt::AlignHCenter|Qt::AlignTop); - m_gridlayout->setSpacing(0); - m_gridlayout->setContentsMargins(0, 0, 0, 0); - setLayout(m_gridlayout); - m_type = type; - } catch (QString ev) { - qCritical() << " [Error] " << " ev:" << ev; - return false; - } - - return true; -} -bool MyWidget::layoutWindow_setting(QString type) -{ - - qDebug() << " [INFO] " << " Change MyWidgetType:" << type; - try - { - // 清空布局 - QLayoutItem* child; - while ((child = m_gridlayout->takeAt(0)) != 0) { - if (child->widget()) { - child->widget()->setParent(NULL); - } - delete child; - } - // 清空显示窗口 - for (int i = 0; i < m_list.size(); i++) - { - delete m_list.at(i); - } - m_list.clear(); - - //加载配置文件 - QJsonArray array; - QJsonArray stationlist; - QList list = bridge.back.json.showWidgets.getWidgets(type); - if (list.size() == 0) - return false; - for (auto widget : list) - { - QString key = type; // key - QString cName = widget.cName; - viewWidget* m_widget = new viewWidget; - m_widget->setKey(key); - m_widget->setName(cName); - m_list.append(m_widget); - } - - int m_row = 0; - if (m_list.size() < 4) - { - for (int iii = 0; iii < m_list.size(); iii++) - { - m_row = m_gridlayout->rowCount(); - if (m_list.size() - 1 > iii) - { - m_gridlayout->addWidget(m_list.at(iii), m_row, 0); - m_gridlayout->addWidget(m_list.at(iii + 1), m_row, 1); - iii += 1; - } - else if (m_list.size() % 2 != 0 && (m_list.size() - 1 == iii)) - { - m_gridlayout->addWidget(m_list.at(iii), m_row, 0); - } - } - } - else - { - int sqr = sqrt(m_list.size()) + 1; - for (int iii = 0; iii < sqr; iii++) { - for (int jjj = 0; jjj < sqr; jjj++) { - //qDebug() << __FUNCTION__ << " line:" << __LINE__ << " --- iii:" << iii; - if (iii * sqr + jjj < m_list.size()) { - m_gridlayout->addWidget(m_list.at(iii * sqr + jjj), iii, jjj); - } - else { - break; - } - } - } - - - } - m_gridlayout->setAlignment(Qt::AlignHCenter | Qt::AlignTop); - m_gridlayout->setSpacing(0); - m_gridlayout->setContentsMargins(0, 0, 0, 0); - setLayout(m_gridlayout); - if(type=="Camera") - m_type = MyWidgetType::CAMERA; - else - m_type = MyWidgetType::RESULT; - } - catch (QString ev) { - qCritical() << " [Error] " << " ev:" << ev; - return false; - } - - return true; -} -MyWidgetType MyWidget::GetMyWidgetType() -{ - return m_type; -} - -void MyWidget::On_reciveImage(QString key,QImage* Image,int index) -{ - //qDebug() << __FUNCTION__ << " line:" << __LINE__ << " --- key:" << key; - if(index!=-1&& index< m_list.size()&& index>=0) - { - QString m_name = m_list.at(index)->getKey(); - if(m_name ==key) - m_list.at(index)->reciveImage(key, Image); - } - else - for (int i = 0; i < m_list.size();i++) - { - QString m_name = m_list.at(i)->getKey(); - if (m_name.indexOf(key) != -1) - { - m_list.at(i)->reciveImage(key,Image); - return; - } - - } - if (Image) - { - delete Image; - Image = nullptr; - } -} - -// key 窗口名称 -void MyWidget::On_reciveData(QString key,QByteArray byte) -{ - //qDebug() << __FUNCTION__ << " line:" << __LINE__ << " ---- key:" << key << " byte len:" << byte; - for (int i = 0; i < m_list.size();i++) - { - QString m_name = m_list.at(i)->getKey(); - if ( m_name.indexOf( key )!=-1) - { - m_list.at(i)->reciveData(key,byte); - return; - } - } -} - -void MyWidget::mouseMoveEvent(QMouseEvent *event) -{ - emit mouseRecover(); -} diff --git a/HanddleAI/HandleAiUi-new/front/mywidget.h b/HanddleAI/HandleAiUi-new/front/mywidget.h deleted file mode 100644 index 51fc90b1..00000000 --- a/HanddleAI/HandleAiUi-new/front/mywidget.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef MYWIDGET_H -#define MYWIDGET_H - -#include -#include -#include -#include -#include -#include -#include - -#include "viewwidget.h" - -#pragma execution_character_set("utf-8") - -enum MyWidgetType { - - CAMERA=0, - RESULT, - OTHER - -}; - -class MyWidget : public QWidget -{ - Q_OBJECT -public: - explicit MyWidget( QWidget *parent = nullptr ); - ~MyWidget(); - bool layoutWindow( QJsonObject json_obj, MyWidgetType type= MyWidgetType::RESULT); - bool layoutWindow_setting( QString type = "Result"); - MyWidgetType GetMyWidgetType(); -protected: - void mouseMoveEvent(QMouseEvent *event)override; -private: - QGridLayout *m_gridlayout = nullptr; - QList m_list; - QScopedPointer gridPtr; - MyWidgetType m_type; -public slots: - void On_reciveImage(QString,QImage*,int); // 传递图片 - void On_reciveData(QString,QByteArray); // 传递数据 -signals: - void mouseRecover(); -}; - -#endif // MYWIDGET_H diff --git a/HanddleAI/HandleAiUi-new/front/qimageview.cpp b/HanddleAI/HandleAiUi-new/front/qimageview.cpp deleted file mode 100644 index cf9f5e16..00000000 --- a/HanddleAI/HandleAiUi-new/front/qimageview.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "qimageview.h" -#include -QImageView::QImageView(QWidget *parent): QGraphicsView(parent) -{ - // 隐藏水平/竖直滚动条 - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - //QPainter::Antialiasing //绘图抗锯齿 - //QPainter::TextAntialiasing //绘制的字体抗锯齿 - setRenderHints(QPainter::Antialiasing); - //设置背景笔刷 - setBackgroundBrush(BackgroundColor); - -} -void QImageView::drawBackground(QPainter *painter, const QRectF &r) -{ - QGraphicsView::drawBackground(painter, r); - auto drawGrid = [&](double gridStep) { - QRect windowRect = rect(); - QPointF tl = mapToScene(windowRect.topLeft()); - QPointF br = mapToScene(windowRect.bottomRight()); - double left = std::floor(tl.x() / gridStep - 0.5); - double right = std::floor(br.x() / gridStep + 1.0); - double bottom = std::floor(tl.y() / gridStep - 0.5); - double top = std::floor(br.y() / gridStep + 1.0); - // vertical lines - for (int xi = int(left); xi <= int(right); ++xi) - { - QLineF line(xi * gridStep, bottom * gridStep, xi * gridStep, top * gridStep); - painter->drawLine(line); - } - // horizontal lines - for (int yi = int(bottom); yi <= int(top); ++yi) - { - QLineF line(left * gridStep, yi * gridStep, right * gridStep, yi * gridStep); - painter->drawLine(line); - } - }; - - QPen pfine(FineGridColor, 1.0); - painter->setPen(pfine); - drawGrid(15); - QPen p(CoarseGridColor, 1.0); - painter->setPen(p); - drawGrid(150); -} - diff --git a/HanddleAI/HandleAiUi-new/front/qimageview.h b/HanddleAI/HandleAiUi-new/front/qimageview.h deleted file mode 100644 index 1f466583..00000000 --- a/HanddleAI/HandleAiUi-new/front/qimageview.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef QIMAGEVIEW_H -#define QIMAGEVIEW_H - -#include -#include -#include - -#pragma execution_character_set("utf-8") - -//QGraphics绘图 -//自定义QGraphicsView,添加网格背景 -class QImageView:public QGraphicsView -{ -public: - QImageView(QWidget *parent = nullptr); -public: - QColor BackgroundColor=QColor(53,53,53); - QColor FineGridColor=QColor(60,60,60); - QColor CoarseGridColor=QColor(25,25,25); -protected: - void drawBackground(QPainter *painter, const QRectF &r) override; -}; -#endif // QIMAGEVIEW_H diff --git a/HanddleAI/HandleAiUi-new/front/qimagewidget.cpp b/HanddleAI/HandleAiUi-new/front/qimagewidget.cpp deleted file mode 100644 index 8e10cae5..00000000 --- a/HanddleAI/HandleAiUi-new/front/qimagewidget.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include "qimagewidget.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -QImageWidget::QImageWidget(QImage* pixmap) -{ - m_pix = *pixmap; - //setAcceptDrops(true);//If enabled is true, this item will accept hover events; otherwise, it will ignore them. By default, items do not accept hover events. - m_scaleValue = 0; - m_scaleDafault = 0; - - m_isMove = false; -} -QRectF QImageWidget::boundingRect() const -{ - return QRectF(-m_pix.width() / 2, -m_pix.height() / 2, - m_pix.width(), m_pix.height()); -} -void QImageWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem*, - QWidget*) -{ - painter->setRenderHints(QPainter::SmoothPixmapTransform);//消锯齿 - painter->drawImage(-m_pix.width() / 2, -m_pix.height() / 2, m_pix); -} -void QImageWidget::mousePressEvent(QGraphicsSceneMouseEvent* event) -{ - if (event->button() == Qt::LeftButton) - { - m_startPos = event->pos();//鼠标左击时,获取当前鼠标在图片中的坐标, - m_isMove = true;//标记鼠标左键被按下 - GetImagepix(m_startPos); - } - else if (event->button() == Qt::RightButton) - { - ResetItemPos();//右击鼠标重置大小 - } -} -void QImageWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* event) -{ - if (m_isMove) - { - QPointF point = (event->pos() - m_startPos) * m_scaleValue; - moveBy(point.x(),point.y() ); - } -} -void QImageWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent*) -{ - m_isMove = false;//标记鼠标左键已经抬起 -} -void QImageWidget::wheelEvent(QGraphicsSceneWheelEvent* event)//鼠标滚轮事件 -{ - if ((event->delta() > 0) && (m_scaleValue >= m_max_zoomState))//最大放大到原始图像的50倍 - { - return; - } - else if ((event->delta() < 0) && (m_scaleValue <= m_scaleDafault))//图像缩小到自适应大小之后就不继续缩小 - { - ResetItemPos();//重置图片大小和位置,使之自适应控件窗口大小 - } - else - { - qreal qrealOriginScale = m_scaleValue; - if (event->delta() > 0)//鼠标滚轮向前滚动 - { - m_scaleValue *= 1+ m_zoom;//每次放大10% - } - else - { - m_scaleValue *= 1- m_zoom;//每次缩小10% - } - setScale(m_scaleValue);//缩放基准是固定的,即对原图元缩放,无累加 - if (event->delta() > 0) - { - moveBy(-event->pos().x() * qrealOriginScale * m_zoom, -event->pos().y() * qrealOriginScale * 0.1);//使图片缩放的效果看起来像是以鼠标所在点为中心进行缩放的 - } - else - { - moveBy(event->pos().x() * qrealOriginScale * m_zoom, event->pos().y() * qrealOriginScale * 0.1);//使图片缩放的效果看起来像是以鼠标所在点为中心进行缩放的 - - } - } -} -//将主界面的控件QGraphicsView的width和height传进本类中,并根据图像的长宽和控件的长宽的比例来使图片缩放到适合控件的大小 -void QImageWidget::setQGraphicsViewWH(int nwidth, int nheight) -{ - int nImgWidth = m_pix.width(); - int nImgHeight = m_pix.height(); - qreal temp1 = nwidth * 1.0 / nImgWidth; - qreal temp2 = nheight * 1.0 / nImgHeight; - if (temp1 > temp2) - { - m_scaleDafault = temp2; - } - else - { - m_scaleDafault = temp1; - } - setScale(m_scaleDafault); - m_scaleValue = m_scaleDafault; -} - -void QImageWidget::GetImagepix(QPointF pos) -{ - - int a=pos.x()+m_pix.width()/2; - int b=pos.y()+m_pix.height()/2; - if(m_pix.isNull())return; - if(m_pix.valid(a, b)){ - QColor color = m_pix.pixel(a, b); - QString clo=QString("RGB: %1, %2, %3").arg(color.red()).arg(color.green()).arg(color.blue()); - QString ps=QString("XY:(%1,%2) %3").arg(a).arg(b).arg(clo); - emit SetImagepix(ps); - } - -// QMenu* menu = new QMenu(); -// menu->setStyleSheet("QMenu { background-color:rgb(3,101,100); border: 5px solid rgb(3,54,73); }"); -// QLabel* label=new QLabel(menu); -// label->setText(ps); -// QWidgetAction* another_widgetAction = new QWidgetAction(menu); -// another_widgetAction->setDefaultWidget(label); -// menu->addAction(another_widgetAction); - -// menu->exec(QCursor::pos()); -// delete menu; -} -//重置图片位置 -void QImageWidget::ResetItemPos() -{ - m_scaleValue = m_scaleDafault;//缩放比例回到一开始的自适应比例 - - setScale(m_scaleDafault);//缩放到一开始的自适应大小 - setPos(0, 0); -} -qreal QImageWidget::getScaleValue() const -{ - return m_scaleValue; -} - - diff --git a/HanddleAI/HandleAiUi-new/front/qimagewidget.h b/HanddleAI/HandleAiUi-new/front/qimagewidget.h deleted file mode 100644 index 7f3d7bb7..00000000 --- a/HanddleAI/HandleAiUi-new/front/qimagewidget.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef QIMAGEWIDGET_H -#define QIMAGEWIDGET_H -#pragma once -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#pragma execution_character_set("utf-8") - -enum Enum_ZoomState { - NO_STATE, - RESET, - ZOOM_IN, - ZOOM_OUT -}; - - -class QImageWidget:public QObject, - public QGraphicsItem - -{ - Q_OBJECT - Q_INTERFACES(QGraphicsItem) - //Warning: Class Node implements the interface QGraphicsItem but does not list it in Q_INTERFACES. - //qobject_cast to QGraphicsItem will not work! -public: - QImageWidget(QImage* pixmap); - QRectF boundingRect() const; - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget); - void ResetItemPos(); - - qreal getScaleValue() const; - void setQGraphicsViewWH(int nwidth, int nheight); - void GetImagepix(QPointF pos); -private: - int m_max_zoomState=5;//最大放大倍数 - qreal m_scaleValue; - qreal m_scaleDafault; - QImage m_pix; - int m_zoomState; - bool m_isMove; - QPointF m_startPos; - double m_zoom = 0.1;//缩放比例 -protected: - void wheelEvent(QGraphicsSceneWheelEvent* event); - void mousePressEvent(QGraphicsSceneMouseEvent* event); - void mouseMoveEvent(QGraphicsSceneMouseEvent* event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent* event); -signals: - void SetImagepix(QString msg); - -}; - -#endif // QIMAGEWIDGET_H diff --git a/HanddleAI/HandleAiUi-new/front/titlebar.cpp b/HanddleAI/HandleAiUi-new/front/titlebar.cpp deleted file mode 100644 index 33ae9d2a..00000000 --- a/HanddleAI/HandleAiUi-new/front/titlebar.cpp +++ /dev/null @@ -1,412 +0,0 @@ -#include "titlebar.h" - - -#include -#include -#include -#include -#include -#include - - -TitleBar::TitleBar(QWidget *parent):QWidget(parent) -{ - setMouseTracking(true); - - QString m_style = "QWidget{background-color: rgb(70, 70, 70)color:rgb(219,219,219);}"; - this->setStyleSheet(m_style); - - TitleBarInit(); - SignalSlotsInit(); -} - -TitleBar::~TitleBar() -{ - if(m_ZhButton) - { - delete m_ZhButton; - m_ZhButton = nullptr; - } - if(m_pIconLabel) - { - delete m_pIconLabel; - m_pIconLabel = nullptr; - } - if(m_FileButton) - { - delete m_FileButton; - m_FileButton = nullptr; - } - qDebug() << " [INFO] " << " ~TitleBar success! "; -} - -void TitleBar::TitleBarInit() -{ - QDir currPath = QApplication::applicationDirPath(); - - m_pIconLabel = new QLabel(this); - m_FileButton = new ButtonMenu(this); - m_SetButton = new ButtonMenu(this); - m_ZhButton = new QToolButton(this); - m_EnButton = new QToolButton(this); - m_UserButton = new QToolButton(this); - m_pMinimizeButton = new QToolButton(this); - m_pMaximizeButton = new QToolButton(this); - m_pCloseButton = new QToolButton(this); - - QString tip_style = "QToolTip{border:1px solid rgb(50,50,50); background-color: rgb(50,50,50); color:rgb(255,255,255); font-size:12px;}"; - QString menu_style = "ButtonMenu::menu-indicator{image: none;}"\ - "ButtonMenu{font-family:Microsoft YaHei;font-size:15px;color:rgb(219,219,219);background-color: rgb(80, 80, 80);border:0px}"\ - "ButtonMenu:hover{background-color: rgb(30,30,30);border:0px}"+tip_style; - - m_pIconLabel->setFixedSize(70,38); - m_pIconLabel->setMouseTracking(true); - m_pIconLabel->setAlignment(Qt::AlignVCenter|Qt::AlignHCenter); - m_pIconLabel->setContentsMargins(0,0,10,0); - m_pIconLabel->setStyleSheet("QLabel{border-right:5px solid qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop:0 rgb(155,155,155),stop: 0.2 rgb(100,100,100),stop: 1 rgb(10,10,10));}"); - - /// LOGO - QIcon icon(currPath.path() + "/Icon/logo_Dongsheng.png"); - m_pIconLabel->setPixmap(icon.pixmap(QSize(42,34))); - m_pIconLabel->hide();//隐藏logo - - - QToolBar * window_left_toolbar = new QToolBar(this); - window_left_toolbar->setMouseTracking(true); - window_left_toolbar->setOrientation(Qt::Horizontal); - window_left_toolbar->setMinimumHeight(38); - window_left_toolbar->layout()->setContentsMargins(5,5,5,5); - window_left_toolbar->setStyleSheet( "QToolBar{spacing: 12px;}"); - - QToolBar * window_right_toolbar = new QToolBar(this); - window_right_toolbar->setMouseTracking(true); - window_right_toolbar->setOrientation(Qt::Horizontal); - window_right_toolbar->setMinimumHeight(38); - window_right_toolbar->setStyleSheet( "QToolBar{spacing: 12px;}QToolBar::separator{background:qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop:0 rgb(155,155,155),stop: 0.2 rgb(100,100,100),stop: 1 rgb(10,10,10));width:5px;}"); - - QToolBar* window_mid_toolbar = new QToolBar(this); - window_mid_toolbar->setMouseTracking(true); - window_mid_toolbar->setOrientation(Qt::Horizontal); - window_mid_toolbar->setMinimumHeight(38); - - m_FileButton->setFixedSize(45, 30); - m_SetButton->setFixedSize(45, 30); - - m_ZhButton->setFixedSize(25, 25); - m_EnButton->setFixedSize(25, 25); - m_UserButton->setFixedSize(25, 25); - m_pMinimizeButton->setFixedSize(25, 25); - m_pMaximizeButton->setFixedSize(25, 25); - m_pCloseButton->setFixedSize(25, 25); - - translateBtn(); - - - QString QToolbutton_style_sheet ="QToolButton{font-size: 20px;color:rgb(147,147,147);background-color: rgb(80, 80, 80);border:0px}" - "QToolButton:hover{color:rgb(147,147,147);background-color: rgb(53, 53, 53);border:0px}"+tip_style; - m_ZhButton->setStyleSheet(QToolbutton_style_sheet); - m_EnButton->setStyleSheet(QToolbutton_style_sheet); - m_UserButton->setStyleSheet(QToolbutton_style_sheet); - m_pMinimizeButton->setStyleSheet(QToolbutton_style_sheet); - m_pMaximizeButton->setStyleSheet(QToolbutton_style_sheet); - m_pCloseButton->setStyleSheet(QToolbutton_style_sheet); - - QPixmap m_map; - m_map.load(currPath.path() + "/Icon/user_n.png"); - m_map = m_map.scaled(25,25,Qt::KeepAspectRatio); - m_UserButton->setIcon(m_map); - - - m_map.load(currPath.path() + "/Icon/min_n.png"); - m_map = m_map.scaled(25,25,Qt::KeepAspectRatio); - m_pMinimizeButton->setIcon(m_map); - - m_map.load( currPath.path() + "/Icon/Max_n.png"); - m_map = m_map.scaled(25,25,Qt::KeepAspectRatio); - m_pMaximizeButton->setIcon(m_map); - - m_map.load(currPath.path() + "/Icon/close_n.png"); - m_map = m_map.scaled(25,25,Qt::KeepAspectRatio); - m_pCloseButton->setIcon(m_map); - - QHBoxLayout *mainWidgetLayout = new QHBoxLayout(this); - QWidget *mainWidget = new QWidget; - mainWidget->setMouseTracking(true); - QHBoxLayout *pLayout = new QHBoxLayout; - - //添加Act - m_FileButton->AddFileAction(); - m_FileButton->setStyleSheet(menu_style); - - m_SetButton->AddSetAction(); - m_SetButton->setStyleSheet(menu_style); - - - mainWidgetLayout->addWidget(mainWidget); - mainWidget->setLayout(pLayout); - mainWidgetLayout->setMargin(0); - pLayout->setContentsMargins(7,0,7,0); - pLayout->setSpacing(12); - mainWidget->setStyleSheet("QWidget{background-color:rgb(80,80,80);}"); - - //添加到左侧工具栏 - window_left_toolbar->addWidget(m_FileButton); - window_left_toolbar->addWidget(m_SetButton); - - QLabel* label = new QLabel(u8"绿保双极板检测"); - label->setStyleSheet("color: white;"); - QFont font("微软雅黑", 16, QFont::Bold); - QPalette palette; - palette.setColor(QPalette::WindowText, Qt::white); - - label->setFont(font); - label->setPalette(palette); - //label->setFixedWidth(1500); - label->setAlignment(Qt::AlignHCenter); - window_mid_toolbar->addWidget(label); - - window_right_toolbar->addWidget(m_EnButton); - window_right_toolbar->addWidget(m_ZhButton); - window_right_toolbar->addWidget(m_UserButton); - window_right_toolbar->addWidget(m_pMinimizeButton); - window_right_toolbar->addWidget(m_pMaximizeButton); - window_right_toolbar->addWidget(m_pCloseButton); - - - pLayout->addWidget(m_pIconLabel); - pLayout->addWidget(window_left_toolbar); - pLayout->addStretch(); - pLayout->addWidget(window_mid_toolbar); - pLayout->addStretch(); - pLayout->addWidget(window_right_toolbar); -} -/** -* @ProjectName QtHanddleAI -* @Function 中英文翻译时分开部署 -* @Author ZhouHongDe -* @Datetime 2022-02-15 14:42:55 -*/ -void TitleBar::translateBtn() -{ - m_FileButton->setToolTip(tr("文件")); - m_SetButton->setToolTip(tr("设置")); - m_ZhButton->setToolTip(tr("中文")); - m_EnButton->setToolTip(tr("英文")); - m_UserButton->setToolTip(tr("用户")); - m_pMinimizeButton->setToolTip(tr("最小化")); - m_pMaximizeButton->setToolTip(tr("最大化")); - m_pCloseButton->setToolTip(tr("关闭")); - - m_EnButton->setText("En"); - m_ZhButton->setText("中"); - - m_FileButton->setText(tr("文件")); - m_SetButton->setText(tr("设置")); - m_pMinimizeButton->setObjectName(tr("最小化")); - m_pMaximizeButton->setObjectName(tr("最大化")); - m_pCloseButton->setObjectName(tr("关闭")); -} - -void TitleBar::SignalSlotsInit() -{ - connect(m_pMinimizeButton, SIGNAL(clicked(bool)), this, SLOT(onClicked())); - connect(m_pMaximizeButton, SIGNAL(clicked(bool)), this, SLOT(onClicked())); - connect(m_pCloseButton, SIGNAL(clicked(bool)), this, SLOT(onClicked())); - - connect(m_FileButton,SIGNAL(OpenProJectSignal(QString)),this,SLOT(OnOpenProject(QString))); //打开配方 - connect(m_FileButton,SIGNAL(SaveProJectSignal(QString)),this,SLOT(OnSaveProject(QString))); //保存配方 - connect(m_FileButton,SIGNAL(CloseWindows()),this,SLOT(OnCloseProject())); //关闭 - - //设置按钮 - connect(m_SetButton,SIGNAL(showstatisticalTable()),this,SLOT(OnShowResultTable())); //显示统计报表 - - //中英文切换 - connect(m_EnButton,SIGNAL(clicked(bool)),this,SLOT(On_SwitchToEnglish())); //切换成英文 - connect(m_ZhButton,SIGNAL(clicked(bool)),this,SLOT(On_SwitchToChinese())); //切换成英文 -} - -void TitleBar::mouseDoubleClickEvent(QMouseEvent *event) -{ - Q_UNUSED(event); - -// window()->isMaximized() ? window()->showNormal() : window()->showMaximized(); -} - -bool TitleBar::eventFilter(QObject *obj, QEvent *event) -{ - switch (event->type()) - { - case QEvent::Resize: - { - updateMaximize(); - return true; - } - default: - return QWidget::eventFilter(obj, event); - } - return true; -} - -void TitleBar::onClicked() -{ - QToolButton *pButton = qobject_cast(sender()); - if (window()->isTopLevel()) - { - if (pButton == m_pMinimizeButton) - { - window()->showMinimized(); - } - else if (pButton == m_pMaximizeButton) - { - window()->isMaximized() ? window()->showNormal() : window()->showMaximized(); - } - else if (pButton == m_pCloseButton) - { - emit close_mainwidget(); - window()->close(); - } - } -} - - -void TitleBar::OnOpenProject(QString openProjectName) -{ - emit OpenProjectSignal(openProjectName); -} - - -void TitleBar::OnSaveProject(QString saveProjectName) -{ - emit SaveProjectSignal(saveProjectName); -} - -void TitleBar::updateMaximize() -{ - QWidget *pWindow = this->window(); - if (pWindow->isTopLevel()) - { - bool bMaximize = pWindow->isMaximized(); - if (bMaximize) - { - m_pMaximizeButton->setToolTip(tr("恢复")); - m_pMaximizeButton->setProperty("maximizeProperty", "restore"); - } - else - { - m_pMaximizeButton->setProperty("maximizeProperty", "maximize"); - m_pMaximizeButton->setToolTip(tr("最大化")); - QPoint widgetPos = this->parentWidget()->pos(); - this->parentWidget()->move(widgetPos.x() + 0, widgetPos.y() + 0); - } - m_pMaximizeButton->setStyle(QApplication::style()); - } -} - -void TitleBar::OnCloseProject() -{ - emit close_mainwidget(); - window()->close(); -} - - -void TitleBar::OnShowResultTable() -{ - emit showStatisticalTableSignal(); -} - -void TitleBar::mousePressEvent( QMouseEvent *event ) -{ - if ( m_buttonType == MIN_MAX_BUTTON ) - { - if (m_pButtonMax->isVisible() ) - { - m_isPressed = true; - m_startMovePos = event->globalPos(); - } - } - else if ( event->button() == Qt::LeftButton ) - { - m_isPressed = true; - m_startMovePos = event->globalPos(); - } - return QWidget::mousePressEvent(event); -} - -void TitleBar::mouseMoveEvent(QMouseEvent *event) -{ - setCursor(Qt::ArrowCursor); - emit mouseRecover(); - if (m_isPressed) - { - QWidget *pWindow = this->window(); - if(pWindow->isMaximized()) - { -// QRect rect = parentWidget()->normalGeometry(); -// int desX = m_startMovePos.x()*rect.width()/parentWidget()->geometry().width(); -// int desY = m_startMovePos.y(); -// rect.moveTopLeft(event->globalPos() - QPoint(desX,desY)); - -// parentWidget()->showNormal(); -// parentWidget()->setGeometry(rect); -// m_startMovePos = QPoint(desX,desY); - } - else - { - m_mouse_move = event->globalPos(); - window()->move(window()->pos()+m_mouse_move-m_startMovePos); - m_startMovePos = m_mouse_move; - } - } - return QWidget::mouseMoveEvent(event); -} - -void TitleBar::mouseReleaseEvent(QMouseEvent *event) -{ - m_isPressed = false; - return QWidget::mouseReleaseEvent(event); -} - - - -void TitleBar::On_ConnectToHost(QString ip,QString port,bool flag) -{ - if(flag) - { - if ( !ip.isEmpty() || !port.isEmpty() ) - emit ConnectToHostSignal(ip,port); - } -} - - -/** -* @ProjectName QtHanddleAI -* @Function 切换成英文 -* @Author ZhouHongDe -* @Datetime 2022-01-14 13:31:58 -*/ -void TitleBar::On_SwitchToEnglish() -{ - emit switchLanguageSignal("language_en"); -} - -/** -* @ProjectName QtHanddleAI -* @Function 切换成中文 -* @Author ZhouHongDe -* @Datetime 2022-01-14 13:45:23 -*/ -void TitleBar::On_SwitchToChinese() -{ - emit switchLanguageSignal("language_ch"); -} - -void TitleBar::switchMenu() -{ - m_FileButton->FileTranslateBtn(); - m_SetButton->SetTranslateBtn(); -} - -void TitleBar::setScreenSize() -{ - -} diff --git a/HanddleAI/HandleAiUi-new/front/titlebar.h b/HanddleAI/HandleAiUi-new/front/titlebar.h deleted file mode 100644 index fcc9e61a..00000000 --- a/HanddleAI/HandleAiUi-new/front/titlebar.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef TITLEBAR_H -#define TITLEBAR_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "buttonmenu.h" - -#pragma execution_character_set("utf-8") - -enum ButtonType -{ - MIN_BUTTON = 0, // 最小化和关闭按钮; - MIN_MAX_BUTTON , // 最小化、最大化和关闭按钮; - ONLY_CLOSE_BUTTON // 只有关闭按钮; -}; - -class TitleBar : public QWidget -{ - Q_OBJECT -public: - explicit TitleBar(QWidget *parent = nullptr); - ~TitleBar(); -public: - void setPath(QString path){ m_path = path;} - void TitleBarInit(); - void translateBtn(); - void SignalSlotsInit(); - void CreateActions(); - void switchMenu(); - void setScreenSize(); -protected: - void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; //拖动界面 - void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE; // 双击标题栏进行界面的最大化/还原 - bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE; // 设置界面标题与图标 -private: - void updateMaximize(); //最大化/还原 -private: - QString m_path; - int m_oldIndex = 0; - // 移动窗口的变量; - bool m_isPressed = false; - QPoint m_startMovePos; - QPoint m_mouse_move; - // 按钮类型; - ButtonType m_buttonType; - QPushButton* m_pButtonMax; // 最大化按钮; - QLabel *m_pIconLabel = nullptr; - ButtonMenu *m_FileButton = nullptr; - ButtonMenu *m_SetButton = nullptr; - QToolButton *m_ZhButton = nullptr; - QToolButton *m_EnButton = nullptr; - QToolButton *m_UserButton = nullptr; - QToolButton *m_pMinimizeButton = nullptr; - QToolButton *m_pMaximizeButton = nullptr; - QToolButton *m_pCloseButton = nullptr; -private slots: - void onClicked(); // 进行最小化、最大化/还原、关闭操作 - void OnOpenProject(QString); // 打开方案 - void OnSaveProject(QString); // 保存方案 - void OnCloseProject(); - void OnShowResultTable(); //显示结果统计表 - //中英文切换按钮 - void On_SwitchToEnglish(); //切换成英文 - void On_SwitchToChinese(); //切换成中文 - - void On_ConnectToHost(QString,QString,bool); -signals: - void mouseRecover(); - void switchLanguageSignal(QString language); //切换语言信号 - void close_mainwidget(); - void OpenProjectSignal(QString); - void SaveProjectSignal(QString); - void showStatisticalTableSignal(); - void ConnectToHostSignal(QString,QString); -}; - -#endif // TITLEBAR_H diff --git a/HanddleAI/HandleAiUi-new/front/viewwidget.cpp b/HanddleAI/HandleAiUi-new/front/viewwidget.cpp deleted file mode 100644 index f311001a..00000000 --- a/HanddleAI/HandleAiUi-new/front/viewwidget.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "viewwidget.h" -#include "qimageview.h" -#include "qimagewidget.h" -#include -#include -viewWidget::viewWidget(QWidget *parent) : QWidget(parent) -{ - setWindowFlags(Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::MSWindowsFixedSizeDialogHint - | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint); - - init(); -} - -viewWidget::~viewWidget() -{ - if (qgraphicsScene) { - delete qgraphicsScene; - qgraphicsScene = nullptr; - } - /* if (m_pImage) { - delete m_pImage; - m_pImage = nullptr; - }*/ - qDebug() << " [INFO] " << " m_key:" << m_key << " delete success!" ; -} - -void viewWidget::init() -{ - - m_Font.setFamily("Microsoft YaHei"); - m_Font.setPixelSize(20); - - //QString m_style = "QLabel{border-with:0; border-style:outset; background:transparent; color:rgb(255,255,255);}"; //报警 Unknown property border-with - QString m_style = "QLabel{ border-style:outset; background:transparent; color:rgb(255,255,255);}"; - QLabel* m_lab = new QLabel; - m_lab->setFont(m_Font); - m_lab->setStyleSheet(m_style); - m_lab->setAlignment(Qt::AlignCenter); - labptr.reset(m_lab); - - - //显示窗口 - qgraphicsScene = new QGraphicsScene; - m_view = new QImageView(this); - m_view->setScene(qgraphicsScene);//Sets the current scene to scene. If scene is already being viewed, this function does nothing. - m_view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);//关闭滑动条 - m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - //label - QLabel* m_pos = new QLabel; - m_pos->setFont(m_Font); - m_pos->setStyleSheet(m_style); - m_pos->setAlignment(Qt::AlignCenter); - label_ptr.reset(m_pos); - - QVBoxLayout* vBox = new QVBoxLayout; - layout_ptr.reset(vBox); - //vBox->addWidget(m_lab); - //vBox->addWidget(m_view); - //vBox->addWidget(m_pos); - //vBox->setContentsMargins(0, 0, 0, 0); - - QGridLayout* vBox1 = new QGridLayout; - layout2_ptr.reset(vBox1); - vBox1->addWidget(m_lab, 0, 0, 1, -1); - vBox1->addWidget(m_view, 0, 0, 20, -1); - vBox1->addWidget(m_pos, 19, 0, 1, -1); - vBox->addLayout(vBox1, -1); - - delete this->layout(); - this->setLayout(vBox); - setSizePolicy(QSizePolicy (QSizePolicy::Preferred, QSizePolicy::Expanding)); - -} - -void viewWidget::resizeEvent(QResizeEvent *event) -{ - Q_UNUSED(event); - -} - -void viewWidget::setName(QString name) -{ - m_Name = name; - - labptr->setText(m_Name); -} - - - -void viewWidget::reciveImage(QString key,QImage* image) -{ - //qDebug() << __FUNCTION__ << "line:" << __LINE__ << " key:" << key; - try - { - /*foreach (QGraphicsItem *item, view_ptr->scene()->items()) - { - view_ptr->scene()->removeItem(item); - }*/ - - m_pImage = new QImageWidget(image); - qgraphicsScene->clear(); - int nwith = m_view->width();//获取界面控件Graphics View的宽度 - int nheight = m_view->height();//获取界面控件Graphics View的高度 - m_pImage->setQGraphicsViewWH(nwith, nheight);//将界面控件Graphics View的width和height传进类m_Image中 - qgraphicsScene->addItem(m_pImage);//将QGraphicsItem类对象放进QGraphicsScene中 - m_view->setSceneRect(QRectF(-(nwith / 2), -(nheight / 2), nwith, nheight)); - // ui->graphicsView->setScene(qgraphicsScene); - m_view->setFocus();//将界面的焦点设置到当前Graphics View控件 - } - catch (QString ev) - { - qDebug() << " [Error] " << " ev:" << ev; - } - //qDebug() << __FUNCTION__ << " line:" << __LINE__ << " reciveData success!"; -} - -void viewWidget::reciveData(QString cameraName,QByteArray byte) -{ - //qDebug() << __FUNCTION__ << " line:" << __LINE__ << " byte len:" << byte.length(); - label_ptr->setText(byte); -} - - diff --git a/HanddleAI/HandleAiUi-new/front/viewwidget.h b/HanddleAI/HandleAiUi-new/front/viewwidget.h deleted file mode 100644 index c160963f..00000000 --- a/HanddleAI/HandleAiUi-new/front/viewwidget.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef VIEWWIDGET_H -#define VIEWWIDGET_H - -#include -#include -#include -#include -#include -#include -#include -#include - - -class QImageView; -class QImageWidget; -#pragma execution_character_set("utf-8") - -class viewWidget : public QWidget -{ - Q_OBJECT -public: - explicit viewWidget(QWidget *parent = nullptr); - ~viewWidget(); - void init(); - void setName(QString name); - void setKey(QString key){ m_key = key;} - - void reciveImage(QString key,QImage*); // 传递图片 - void reciveData(QString cameraName,QByteArray byte); // 传递数据 - - QString getName(){return m_Name;} - QString getKey(){return m_key;} - -protected: - void resizeEvent(QResizeEvent *event)override; -private: - QFont m_Font; - QString m_key; - QString m_Name; - QJsonArray m_algorithm_array; - QPointF mainItemOriPos; - QGraphicsScene* qgraphicsScene = nullptr; - QImageWidget* m_pImage = nullptr; - QImageView* m_view = nullptr; - - QScopedPointer labptr; - QScopedPointer label_ptr; - QScopedPointer layout_ptr; - QScopedPointer layout2_ptr; - QScopedPointer view_ptr; - -signals: - -}; - -#endif // VIEWWIDGET_H diff --git a/HanddleAI/HandleAiUi-new/front/waitwidget.cpp b/HanddleAI/HandleAiUi-new/front/waitwidget.cpp deleted file mode 100644 index 344c710a..00000000 --- a/HanddleAI/HandleAiUi-new/front/waitwidget.cpp +++ /dev/null @@ -1,353 +0,0 @@ -#include -#include -#include -#include -#include -#include "waitwidget.h" -CircularProgress::CircularProgress(QWidget* parent) - : QProgressBar(parent) -{ - init(); -} - -CircularProgress::~CircularProgress() -{ -} - -void CircularProgress::setProgressType(ProgressType type) -{ - m_progressType = type; - update(); -} - -CircularProgress::ProgressType CircularProgress::progressType() const -{ - return m_progressType; -} - -void CircularProgress::setUseThemeColors(bool value) -{ - if (m_useThemeColors == value) { - return; - } - - m_useThemeColors = value; - update(); -} - -bool CircularProgress::useThemeColors() const -{ - return m_useThemeColors; -} - -void CircularProgress::setLineWidth(qreal width) -{ - m_penWidth = width; - update(); - updateGeometry(); -} - -qreal CircularProgress::lineWidth() const -{ - return m_penWidth; -} - -void CircularProgress::setSize(int size) -{ - m_size = size; - update(); - updateGeometry(); -} - -int CircularProgress::size() const -{ - return m_size; -} - -void CircularProgress::setColor(const QColor& color) -{ - m_color = color; - update(); -} - -QColor CircularProgress::color() const -{ - if (m_useThemeColors || !m_color.isValid()) { - return QColor(37, 177, 218); - } - else { - return m_color; - } -} - -QSize CircularProgress::sizeHint() const -{ - const qreal s = m_size + m_penWidth + 8; - return QSize(s, s); -} - -void CircularProgress::paintEvent(QPaintEvent* event) -{ - Q_UNUSED(event) - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing); - - if (!isEnabled()) { - QPen pen; - pen.setCapStyle(Qt::RoundCap); - pen.setWidthF(m_penWidth); - pen.setColor(QColor(186, 186, 186)); - painter.setPen(pen); - painter.drawLine(rect().center() - QPointF(20, 20), rect().center() + QPointF(20, 20)); - painter.drawLine(rect().center() + QPointF(20, -20), rect().center() - QPointF(20, -20)); - return; - } - - if (IndeterminateProgress == m_progressType) { - painter.translate(width() / 2, height() / 2); - painter.rotate(m_delegate->angle()); - } - - QPen pen; - pen.setCapStyle(Qt::RoundCap); - pen.setWidthF(m_penWidth); - - // 绘制底部环 - pen.setColor(QColor(165, 165, 165)); - painter.setPen(pen); - painter.drawEllipse(QPoint(0, 0), m_size / 2, m_size / 2); - - pen.setColor(color()); - - if (IndeterminateProgress == m_progressType) { - QVector pattern; - pattern << m_delegate->dashLength() * m_size / 50 << 30 * m_size / 50; - - pen.setDashOffset(m_delegate->dashOffset() * m_size / 50); - pen.setDashPattern(pattern); - - painter.setPen(pen); - - painter.drawEllipse(QPoint(0, 0), m_size / 2, m_size / 2); - } - else - { - painter.setPen(pen); - - const qreal x = (width() - m_size) / 2; - const qreal y = (height() - m_size) / 2; - - const qreal a = 360 * (value() - minimum()) / (maximum() - minimum()); - - QPainterPath path; - path.arcMoveTo(x, y, m_size, m_size, 0); - path.arcTo(x, y, m_size, m_size, 0, a); - - painter.drawPath(path); - } -} - -void CircularProgress::init() -{ - m_delegate = new CircularProgressDelegate(this); - m_progressType = IndeterminateProgress; - m_penWidth = 6.25; - m_size = 64; - m_useThemeColors = true; - - setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, - QSizePolicy::MinimumExpanding)); - - QParallelAnimationGroup* group = new QParallelAnimationGroup(this); - group->setLoopCount(-1); - - QPropertyAnimation* animation; - animation = new QPropertyAnimation(this); - animation->setPropertyName("dashLength"); - animation->setTargetObject(m_delegate); - animation->setEasingCurve(QEasingCurve::InOutQuad); - animation->setStartValue(0.1); - animation->setKeyValueAt(0.15, 0.2); - animation->setKeyValueAt(0.6, 20); - animation->setKeyValueAt(0.7, 20); - animation->setEndValue(20); - animation->setDuration(2050); - - group->addAnimation(animation); - - animation = new QPropertyAnimation(this); - animation->setPropertyName("dashOffset"); - animation->setTargetObject(m_delegate); - animation->setEasingCurve(QEasingCurve::InOutSine); - animation->setStartValue(0); - animation->setKeyValueAt(0.15, 0); - animation->setKeyValueAt(0.6, -7); - animation->setKeyValueAt(0.7, -7); - animation->setEndValue(-25); - animation->setDuration(2050); - - group->addAnimation(animation); - - animation = new QPropertyAnimation(this); - animation->setPropertyName("angle"); - animation->setTargetObject(m_delegate); - animation->setStartValue(0); - animation->setEndValue(719); - animation->setDuration(2050); - - group->addAnimation(animation); - - group->start(); -} - - -CircularProgressDelegate::CircularProgressDelegate(CircularProgress* parent) - : QObject(parent), - m_progress(parent), - m_dashOffset(0), - m_dashLength(89), - m_angle(0) -{ - Q_ASSERT(parent); -} - -CircularProgressDelegate::~CircularProgressDelegate() -{ -} - -void CircularProgressDelegate::setDashOffset(qreal offset) -{ - m_dashOffset = offset; - m_progress->update(); -} - -qreal CircularProgressDelegate::dashOffset() const -{ - return m_dashOffset; -} - -void CircularProgressDelegate::setDashLength(qreal length) -{ - m_dashLength = length; - m_progress->update(); -} - -qreal CircularProgressDelegate::dashLength() const -{ - return m_dashLength; -} - -void CircularProgressDelegate::setAngle(int angle) -{ - m_angle = angle; - m_progress->update(); -} - -int CircularProgressDelegate::angle() const -{ - return m_angle; -} - - - -WaitProgressWidget::WaitProgressWidget(QWidget* parent) - : QWidget(parent) - , m_parentWidget(parent) -{ - m_progress = new CircularProgress(this); - - this->setAutoFillBackground(true); - this->hide(); - - QColor color(165, 165, 165); - color.setAlphaF(0.6); - this->setBgColor(color); - - auto waitBgLayout = new QHBoxLayout(this); - waitBgLayout->addWidget(m_progress); - waitBgLayout->setAlignment(m_progress, Qt::AlignCenter); - - parent->installEventFilter(this); - - m_timer = new QTimer(this); - connect(m_timer, &QTimer::timeout, this, [this]() { - if (!this->isHidden()) { - stop(false); - } - }); - connect(this, &WaitProgressWidget::sig_finished, [this](bool isok) { - if (isok) { - if (!this->isHidden()) { - stop(false); - } - } - else { - if (this->isHidden()) { - start(); - } - } - - }); -} - -WaitProgressWidget::~WaitProgressWidget() -{ - stop(true); - - if (m_timer) { - - delete m_timer; - m_timer = NULL; - } -} - -void WaitProgressWidget::setBgColor(QColor color) -{ - QPalette palette; - palette.setColor(QPalette::Background, color); - this->setPalette(palette); - update(); -} - -bool WaitProgressWidget::eventFilter(QObject* obj, QEvent* ev) -{ - if (obj == m_parentWidget && ev->type() == QEvent::Resize) { - if (!this->isHidden()) { - this->setFixedSize(m_parentWidget->size()); - this->raise(); - } - } - return QWidget::eventFilter(obj, ev); -} - -void WaitProgressWidget::showEvent(QShowEvent* ev) -{ - Q_UNUSED(ev);// 屏蔽鼠标事件 - - this->setFixedSize(m_parentWidget->size()); - this->raise(); -} - -void WaitProgressWidget::start(int msecs) -{ - m_timer->start(msecs); - this->show(); -} - -void WaitProgressWidget::stop(bool isOk) -{ - m_timer->stop(); - this->hide(); - emit sig_finished(isOk); -} - -void WaitProgressWidget::show() -{ - QWidget::show(); -} - -void WaitProgressWidget::hide() -{ - QWidget::hide(); -} diff --git a/HanddleAI/HandleAiUi-new/front/waitwidget.h b/HanddleAI/HandleAiUi-new/front/waitwidget.h deleted file mode 100644 index 5ab318fb..00000000 --- a/HanddleAI/HandleAiUi-new/front/waitwidget.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef WAITWIDGET_H - -#define WAITWIDGET_H -#include -#include -#pragma execution_character_set("utf-8") - -/// -/// 环形进度条 -/// -class CircularProgressDelegate; -class CircularProgress : public QProgressBar -{ - Q_OBJECT - - Q_PROPERTY(qreal lineWidth WRITE setLineWidth READ lineWidth) - Q_PROPERTY(qreal size WRITE setSize READ size) - Q_PROPERTY(QColor color WRITE setColor READ color) - -public: - explicit CircularProgress(QWidget* parent = nullptr); - ~CircularProgress(); - - enum ProgressType { - DeterminateProgress, // 普通进度条 - IndeterminateProgress // 等待进度条 - }; - - void setProgressType(ProgressType type); - CircularProgress::ProgressType progressType() const; - - void setUseThemeColors(bool value); - bool useThemeColors() const; - - void setLineWidth(qreal width); - qreal lineWidth() const; - - void setSize(int size); - int size() const; - - void setColor(const QColor& color); - QColor color() const; - - QSize sizeHint() const Q_DECL_OVERRIDE; - -protected: - void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE; - -private: - void init(); - -private: - CircularProgressDelegate* m_delegate; - ProgressType m_progressType; - QColor m_color; - qreal m_penWidth; - int m_size; - bool m_useThemeColors; -}; - -class CircularProgressDelegate : public QObject -{ - Q_OBJECT - - Q_PROPERTY(qreal dashOffset WRITE setDashOffset READ dashOffset) - Q_PROPERTY(qreal dashLength WRITE setDashLength READ dashLength) - Q_PROPERTY(int angle WRITE setAngle READ angle) - -public: - CircularProgressDelegate(CircularProgress* parent); - ~CircularProgressDelegate(); - - void setDashOffset(qreal offset); - qreal dashOffset() const; - - void setDashLength(qreal length); - qreal dashLength() const; - - void setAngle(int angle); - int angle() const; - -private: - Q_DISABLE_COPY(CircularProgressDelegate) - - CircularProgress* const m_progress; - qreal m_dashOffset; - qreal m_dashLength; - int m_angle; -}; - - -/// -/// 掩膜等待页面 -/// -class WaitProgressWidget : public QWidget -{ - Q_OBJECT - -public: - WaitProgressWidget(QWidget* parent); - ~WaitProgressWidget(); - void setBgColor(QColor color); - - void start(int msec = 60000); - void stop(bool isOk); - -signals: - void sig_finished(bool isOk); - -private: - void show();// 限制外部调用show hide - void hide(); - -protected: - bool eventFilter(QObject* obj, QEvent* ev); - void showEvent(QShowEvent* ev); - -private: - CircularProgress* m_progress; - QWidget* m_parentWidget; - QTimer* m_timer; -}; - - -#endif //WAITWIDGET_H diff --git a/HanddleAI/HandleAiUi-new/mainwindow.cpp b/HanddleAI/HandleAiUi-new/mainwindow.cpp index 3435f850..d1cffa23 100644 --- a/HanddleAI/HandleAiUi-new/mainwindow.cpp +++ b/HanddleAI/HandleAiUi-new/mainwindow.cpp @@ -1,10 +1,5 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "titlebar.h" -#include "mywidget.h" -#include "cfgwindow.h" -#include "hpromptwidget.h" -#include "HMessageBox.h" #include #include #include