备份,完善大部分功能
This commit is contained in:
Binary file not shown.
@@ -68,7 +68,6 @@ FILE(GLOB UI_FILES "./*.ui")
|
||||
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAEK_CURRENT_BINARY_DIR})
|
||||
|
||||
if(ANDROID)
|
||||
add_library(${CURRENT_FOLDER} SHARED
|
||||
${HEAD_FILES}
|
||||
@@ -95,6 +94,8 @@ if(ANDROID)
|
||||
)
|
||||
else()
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
message( "/////////////DEBUG///////////////")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g")
|
||||
add_executable( ${CURRENT_FOLDER}
|
||||
${HEAD_FILES}
|
||||
${SRC_FILES}
|
||||
@@ -118,6 +119,8 @@ else()
|
||||
${ALGO_SRC_FILES}
|
||||
${UI_FILES} "ff.rc" "icon.qrc")
|
||||
else()
|
||||
message( "/////////////RELEASE///////////////")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")
|
||||
add_executable( ${CURRENT_FOLDER}
|
||||
|
||||
@@ -222,7 +222,7 @@ void ALGO_Inspection(std::shared_ptr <detData> data, handleAiModelManager* _hand
|
||||
if (detResult.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
//过滤结果,获取用于handleAi/HALCON检测的rect
|
||||
std::vector<handdleAI::Bbox> pinPos = getpinHandleAiEvaluateRect(data,src, detResult);
|
||||
|
||||
|
||||
@@ -12,9 +12,12 @@
|
||||
struct productDataStruct
|
||||
{
|
||||
std::string name;
|
||||
std::string customerPartNumber;
|
||||
std::string foxconnPartNumber;
|
||||
int indexOfArm = -1;
|
||||
cv::Vec3d basePos;
|
||||
cv::Vec3d baseRad;
|
||||
std::string imgPosPath;
|
||||
int halconAlgoIndex = -1;
|
||||
//int为步骤数 std::string为指令
|
||||
std::unordered_map <int, std::vector<std::string>>cameraSetting;
|
||||
@@ -79,10 +82,13 @@ public:
|
||||
{
|
||||
productDataStruct productData;
|
||||
productData.name = res["productName"];
|
||||
productData.customerPartNumber = res["customerPartNumber"];
|
||||
productData.foxconnPartNumber = res["foxconnPartNumber"];
|
||||
productData.indexOfArm = res["productIndex"];
|
||||
productData.basePos = { res["baseX"],res["baseY"],res["baseZ"] };
|
||||
productData.baseRad = { res["baseRx"],res["baseRy"],res["baseRz"] };
|
||||
productData.halconAlgoIndex = res["halconAlgoIndex"];
|
||||
productData.imgPosPath = res["imgPosPath"];
|
||||
productData.disableHandleAiConfig = res["disableHandleAiConfig"];
|
||||
productData.enableCodedAlgo = res["enableCodedAlgo"];
|
||||
productData.codedAlgoIndex = res["codedAlgoIndex"];
|
||||
@@ -105,7 +111,7 @@ public:
|
||||
detResultHandleStruct detResultHandle;
|
||||
detResultHandle.detResultIndex = std::vector<int>(data["detResultIndex"].begin(), data["detResultIndex"].end());
|
||||
detResultHandle.segModelName = data["segModelName"];
|
||||
detResultHandle.segNgIndex = std::vector<int>(data["segNgIndex"].begin(), data["segNgIndex"].end());
|
||||
detResultHandle.segNgIndex = std::vector<int>( data["segNgIndex"].begin(), data["segNgIndex"].end());
|
||||
detResultHandle.segGpuIndex = data["segGpuIndex"];
|
||||
|
||||
detResultHandle.clsModelName = data["clsModelName"];
|
||||
@@ -115,7 +121,7 @@ public:
|
||||
{
|
||||
std::vector<std::string> result = split(it.value(), ',');
|
||||
if (result.size() != 4)
|
||||
{
|
||||
{
|
||||
fancyWarnWindow* warn = new fancyWarnWindow
|
||||
(fancyWarnWindow::Warning, QString("在%1中的clsResultHandle发现格式错误").arg(QString::fromStdString(fileManager::getFileName(file))),
|
||||
QString("%1").arg(QString::fromStdString(it.value())));
|
||||
|
||||
@@ -21,7 +21,26 @@ static nlohmann::json readJsonFromPath(std::string path)
|
||||
inputFile.close();
|
||||
return jsonObj;
|
||||
}
|
||||
static bool saveJsonFromPath(std::string path, nlohmann::json& json)
|
||||
{
|
||||
std::ofstream saveFile(path);
|
||||
if (!saveFile.is_open()) {
|
||||
std::cerr << "Could not open the file - " << path << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
saveFile << json.dump(4);
|
||||
}
|
||||
catch (nlohmann::json::parse_error& e) {
|
||||
std::cerr << "JSON parse error: " << e.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 关闭文件
|
||||
saveFile.close();
|
||||
return true;
|
||||
}
|
||||
static void printNlohmannJson(nlohmann::json input, int depth = 0)
|
||||
{
|
||||
std::string indent_str(depth, ' ');
|
||||
|
||||
@@ -21,7 +21,7 @@ int jsonConfiguration::reParsing()
|
||||
|
||||
QJsonObject jsonObj = jsonDoc.object();
|
||||
imgSavePath = jsonObj.value("imgSavePath").toString();
|
||||
stationName = jsonObj.value("stationName").toString();
|
||||
stationName = jsonObj.value("stationName").toString( );
|
||||
////////////////////TABLE//LIST/////////////////////
|
||||
QJsonArray tableListArray = jsonObj["tablelist"].toArray();
|
||||
for (const QJsonValue& tableListValue : tableListArray) {
|
||||
|
||||
@@ -88,12 +88,13 @@ void backEndManager::startManualDetSlot(std::string path, int index)
|
||||
_manualDetThread->startDet(path, index);
|
||||
}
|
||||
|
||||
void backEndManager::writeArmStartSignal(int productTypeIn)
|
||||
void backEndManager::writeArmStartSignal(int productTypeIn,QString SN)
|
||||
{
|
||||
_appConfig->productDatasMutex.lock();
|
||||
productTypeStr = _appConfig->productDatas[productTypeIn].name;
|
||||
_appConfig->productDatasMutex.unlock();
|
||||
productType = productTypeIn;
|
||||
currentSn = SN.toStdString();
|
||||
_triggerManager->sendFinsMsg("write_short_350_"+QString::number(_appConfig->productDatas[productTypeIn].indexOfArm));
|
||||
_triggerManager->sendFinsMsg("write_short_351_1");
|
||||
}
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
manualDetThread* _manualDetThread = nullptr;
|
||||
//
|
||||
std::string productTypeStr;
|
||||
std::string currentSn;
|
||||
int productType = -1;
|
||||
int indexOfArm = -1;
|
||||
backEndManager(appConfig*);
|
||||
@@ -47,7 +48,7 @@ public slots:
|
||||
this->start();
|
||||
}
|
||||
void startManualDetSlot(std::string path, int index);
|
||||
void writeArmStartSignal(int productType);
|
||||
void writeArmStartSignal(int productType,QString SN);
|
||||
private:
|
||||
void run();
|
||||
signals:
|
||||
@@ -55,7 +56,7 @@ signals:
|
||||
void sendPixmapImageWidget(showImgPack*);
|
||||
void sendInitFinished(int);
|
||||
void sendInitString(QString);//初始化日志
|
||||
void addHistoryDataSignal(bool isOK, QString path, QPixmap img);
|
||||
void addHistoryDataSignal(bool isOK, historyPack);
|
||||
void addDashBoardData(int index, bool value);//增加一个OK/NG数据到dashboard
|
||||
void resetDashBoard();//reset dashBoard
|
||||
void switchStartBtnStatusSignal(int);
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
|
||||
int oriShowIndex = -1;//原图在第几个框展示
|
||||
int resShowIndex = -1;//结果图在第几个框展示
|
||||
std::vector <std::shared_ptr<std::string>> resImgSavePath;
|
||||
std::string snErrorsnError = std::string("snErrNoSn");
|
||||
std::vector<QString> writeBackData;
|
||||
void writeBack(QString type, int pos, QString value)
|
||||
|
||||
@@ -145,7 +145,11 @@ public:
|
||||
//结果图保存
|
||||
std::vector<std::string>resFileNames = genFileNmaes(data, resImg);
|
||||
for (int index = 0; index < resFileNames.size(); index++)
|
||||
{
|
||||
saveThread.addData(fileSavePath + resFileNames[index], data->resultImgs[index]);
|
||||
if (data->resImgSavePath.size() > index)
|
||||
*data->resImgSavePath[index] = fileSavePath + resFileNames[index];
|
||||
}
|
||||
|
||||
//seg
|
||||
std::vector<std::string>segFileNames = genFileNmaes(data, segImg);
|
||||
|
||||
@@ -105,7 +105,12 @@ void threadManager::resultHandle(std::shared_ptr <detData> data)
|
||||
pack->type = imgWidgetRes;
|
||||
pack->index = data->resShowIndex+ cnt;
|
||||
emit _backEndManager->sendPixmapImageWidget(pack);
|
||||
emit _backEndManager->addHistoryDataSignal((data->aiDetOK == true && data->halconOK == true), "", pixmap);
|
||||
|
||||
historyPack _historyPack;
|
||||
_historyPack.img = pixmap;
|
||||
_historyPack.filePath = std::shared_ptr<std::string>(new std::string);
|
||||
data->resImgSavePath.push_back(_historyPack.filePath);
|
||||
emit _backEndManager->addHistoryDataSignal((data->aiDetOK == true && data->halconOK == true),_historyPack);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
@@ -124,7 +129,7 @@ void threadManager::resultHandle(std::shared_ptr <detData> data)
|
||||
emit _backEndManager->addCtData(1, aiCt.count());
|
||||
if (halconCt.count() > 0)
|
||||
emit _backEndManager->addCtData(2, halconCt.count());
|
||||
//std::cout << "ct1" << totalCt.count() << "ct2" << aiCt.count() << "ct3" << halconCt.count() << std::endl;
|
||||
|
||||
//SQL
|
||||
std::vector<sqlData> sqlDatas;
|
||||
for (auto sqlData : data->sqlVec)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <qregularexpression.h>
|
||||
#include <qtimer.h>
|
||||
#include <appConfig/json/generalJsonParsing.hpp>
|
||||
#include <qspinbox.h>
|
||||
|
||||
/**************格式****************/
|
||||
//...
|
||||
@@ -42,15 +43,33 @@ public:
|
||||
bhdPath,
|
||||
IP,
|
||||
number,
|
||||
boolType
|
||||
boolType,
|
||||
path
|
||||
};
|
||||
struct aLineData
|
||||
{
|
||||
QString showName;
|
||||
QString valueName;
|
||||
QVariant value;
|
||||
QString formatPolicyStr;
|
||||
int acessLevel;
|
||||
std::string showName;
|
||||
std::string valueName;
|
||||
std::string value;
|
||||
std::string formatPolicyStr;
|
||||
formatPolicy _formatPolicy;
|
||||
QWidget* userInputWidget;
|
||||
std::string getValueFromQwidget()
|
||||
{
|
||||
switch (_formatPolicy)
|
||||
{
|
||||
case boolType:
|
||||
if (((QCheckBox*)userInputWidget)->isChecked() == true)
|
||||
return "true";
|
||||
else
|
||||
return "flase";
|
||||
break;
|
||||
default:
|
||||
return ((QLineEdit*)userInputWidget)->text().toStdString();
|
||||
}
|
||||
return "error";
|
||||
}
|
||||
};
|
||||
QVBoxLayout* Layout;
|
||||
QHBoxLayout* btnLayout;
|
||||
@@ -89,7 +108,7 @@ public:
|
||||
|
||||
Layout->addLayout(btnLayout);
|
||||
|
||||
addConfigWidget(u8"通用设置",".//config//modelConfig.json");
|
||||
addConfigWidget(u8"通用设置",".//config//basicSetting.json");
|
||||
addConfigWidget(u8"检测设置","");
|
||||
addConfigWidget(u8"通讯设置",".//config//communicateConfig");
|
||||
addConfigWidget(u8"算法设置","");
|
||||
@@ -104,6 +123,14 @@ public:
|
||||
{
|
||||
switch (_formatPolicy)
|
||||
{
|
||||
case path:
|
||||
if (!isNumeric(compareStr))
|
||||
{
|
||||
textOut = u8"格式错误,非数字";
|
||||
colorOut = "red";
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case number:
|
||||
if (!isNumeric(compareStr))
|
||||
{
|
||||
@@ -193,7 +220,6 @@ public:
|
||||
jsonWidget->setMaximumSize(9999 , 9999);
|
||||
QGridLayout* jsonLayout = new QGridLayout(jsonWidget);
|
||||
jsonLayout->setAlignment(Qt::AlignTop);
|
||||
jsonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
scrollArea->setWidget(jsonWidget);
|
||||
jsonLayouts.push_back(jsonLayout);
|
||||
|
||||
@@ -205,9 +231,10 @@ public:
|
||||
QWidget* tempWidget = new QWidget();
|
||||
QVBoxLayout* tempVLayout = new QVBoxLayout(tempWidget);
|
||||
tempVLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
tempWidget->setContentsMargins(0, 0, 0, 0);
|
||||
tempVLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QLabel* showLabel = new QLabel(data.showName);
|
||||
QLabel* showLabel = new QLabel(QString::fromStdString(data.showName));
|
||||
showLabel->setFont(font);
|
||||
showLabel->setPalette(palette);
|
||||
showLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
@@ -221,19 +248,43 @@ public:
|
||||
QCheckBox* checkBox = new QCheckBox();
|
||||
checkBox->setFont(font);
|
||||
checkBox->setPalette(palette);
|
||||
checkBox->setFixedWidth(500);
|
||||
//checkBox->setFixedSize(QSize(50,50));
|
||||
|
||||
QHBoxLayout* tempLayout = new QHBoxLayout();
|
||||
|
||||
tempLayout->addWidget(showLabel);
|
||||
tempLayout->addWidget(checkBox);
|
||||
tempVLayout->addLayout(tempLayout);
|
||||
|
||||
tempVLayout->addWidget(warningLabel);
|
||||
}
|
||||
if (!data.value.compare("true"))
|
||||
checkBox->setChecked(true);
|
||||
data.userInputWidget = checkBox;
|
||||
//修改时警告
|
||||
connect(checkBox, &QCheckBox::stateChanged, [=]()
|
||||
{
|
||||
if (checkBox->isChecked()==true && data.value =="false")//修改后的值不匹配
|
||||
{
|
||||
warningLabel->setText("此项被修改!");
|
||||
warningLabel->setStyleSheet("color:yellow");
|
||||
checkBox->setStyleSheet("border: 2px solid yellow;");
|
||||
}
|
||||
else if (checkBox->isChecked() == false && data.value == "true")//修改后的值不匹配
|
||||
{
|
||||
warningLabel->setText("此项被修改!");
|
||||
warningLabel->setStyleSheet("color:yellow");
|
||||
checkBox->setStyleSheet("border: 2px solid yellow;");
|
||||
}
|
||||
else
|
||||
{
|
||||
warningLabel->setText("");
|
||||
checkBox->setStyleSheet("");
|
||||
warningLabel->setText("");
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
QLineEdit* lineEdit = new QLineEdit(data.value.toString());
|
||||
QLineEdit* lineEdit = new QLineEdit(QString::fromStdString(data.value));
|
||||
lineEdit->setFont(font);
|
||||
lineEdit->setPalette(palette);
|
||||
lineEdit->setFixedWidth(500);
|
||||
@@ -241,10 +292,11 @@ public:
|
||||
tempVLayout->addWidget(showLabel);
|
||||
tempVLayout->addWidget(lineEdit);
|
||||
tempVLayout->addWidget(warningLabel);
|
||||
data.userInputWidget = lineEdit;
|
||||
//修改时警告
|
||||
connect(lineEdit, &QLineEdit::textChanged, [=]()
|
||||
{
|
||||
if (lineEdit->text().compare(data.value.toString()))//修改后的值不匹配
|
||||
if (lineEdit->text().toStdString().compare(data.value))//修改后的值不匹配
|
||||
{
|
||||
QString text, color;
|
||||
if (formatPolicyCompare(data._formatPolicy, lineEdit->text(), text, color))
|
||||
@@ -273,6 +325,7 @@ public:
|
||||
jsonLayout->addWidget(tempWidget);
|
||||
}
|
||||
privateWidgets.push_back(widgets);
|
||||
privateJsondatas.push_back(jsonData);
|
||||
//保存按钮
|
||||
fancyButtonText* saveBtn = new fancyButtonText(160, 50, u8"保存", u8"保存当前配置文件");
|
||||
connect(saveBtn, &QPushButton::clicked, this, [=]() {saveJson(jsonPath); });
|
||||
@@ -291,30 +344,33 @@ public:
|
||||
std::vector< aLineData> loadJson(const QString& fileName) {
|
||||
std::vector< aLineData> returnData;
|
||||
nlohmann::json json = readJsonFromPath(fileName.toStdString());
|
||||
for (auto data : json)
|
||||
try
|
||||
{
|
||||
aLineData lineData;
|
||||
std::string policyStr = data["policy"];
|
||||
std::string showName = data["showName"];
|
||||
std::string value = data["value"];
|
||||
std::string valueName = data["valueName"];
|
||||
formatPolicy _formatPolicy = formatPolicy::none;
|
||||
if (!policyStr.compare("filepath"))
|
||||
_formatPolicy = filePath;
|
||||
else if (!policyStr.compare("bhdpath"))
|
||||
_formatPolicy = bhdPath;
|
||||
else if (!policyStr.compare("ip"))
|
||||
_formatPolicy = IP;
|
||||
else if (!policyStr.compare("number"))
|
||||
_formatPolicy = number;
|
||||
else if (!policyStr.compare("bool"))
|
||||
_formatPolicy = boolType;
|
||||
for (auto data : json)
|
||||
{
|
||||
aLineData lineData;
|
||||
lineData.acessLevel = data["level"];
|
||||
lineData.showName = data["showName"];
|
||||
lineData.formatPolicyStr = data["policy"];
|
||||
lineData.value = data["value"];
|
||||
lineData.valueName = data["valueName"];
|
||||
if (!lineData.formatPolicyStr.compare("filepath"))
|
||||
lineData._formatPolicy = filePath;
|
||||
else if (!lineData.formatPolicyStr.compare("bhdpath"))
|
||||
lineData._formatPolicy = bhdPath;
|
||||
else if (!lineData.formatPolicyStr.compare("ip"))
|
||||
lineData._formatPolicy = IP;
|
||||
else if (!lineData.formatPolicyStr.compare("number"))
|
||||
lineData._formatPolicy = number;
|
||||
else if (!lineData.formatPolicyStr.compare("bool"))
|
||||
lineData._formatPolicy = boolType;
|
||||
|
||||
lineData.showName = QString::fromStdString(showName);
|
||||
lineData._formatPolicy = _formatPolicy;
|
||||
lineData.value = QString::fromStdString(value);
|
||||
lineData.valueName = QString::fromStdString(valueName);
|
||||
returnData.push_back(lineData);
|
||||
returnData.push_back(lineData);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
qDebug() << "read json failure" << fileName;
|
||||
}
|
||||
return returnData;
|
||||
}
|
||||
@@ -349,57 +405,20 @@ public:
|
||||
}
|
||||
void saveJson(QString path)
|
||||
{
|
||||
// 构建 JSON 对象
|
||||
//QJsonArray jsonArray;
|
||||
//for (auto& classData : privateJsondatas)
|
||||
//{
|
||||
// for(auto& jsonData: classData)
|
||||
// for (auto& data : jsonData.second)
|
||||
// {
|
||||
// QJsonObject obj1;
|
||||
// obj1["className"] = data.className;
|
||||
// obj1["showName"] = data.showName;
|
||||
// obj1["valueName"] = data.valueName;
|
||||
|
||||
// switch (data.value.type()) {
|
||||
// case QVariant::Bool:
|
||||
// obj1["value"] = data.value.toBool();
|
||||
// break;
|
||||
// case QVariant::Int:
|
||||
// obj1["value"] = data.value.toInt();
|
||||
// break;
|
||||
// case QVariant::Double:
|
||||
// obj1["value"] = data.value.toDouble();
|
||||
// break;
|
||||
// case QVariant::String:
|
||||
// obj1["value"] = data.value.toString();
|
||||
// break;
|
||||
// default:
|
||||
// obj1["value"] = "error";
|
||||
// break;
|
||||
// }
|
||||
|
||||
// obj1["policy"] = data.formatPolicyStr;
|
||||
// jsonArray.append(obj1);
|
||||
// }
|
||||
//}
|
||||
//std::string sss = path.toStdString();
|
||||
|
||||
//QJsonDocument jsonDocument(jsonArray);
|
||||
|
||||
//// 保存 JSON 文档到文件
|
||||
//QFile file(path);
|
||||
//if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
// QTextStream out(&file);
|
||||
// out.setCodec("UTF-8");
|
||||
// out << jsonDocument.toJson();
|
||||
// file.close();
|
||||
// QMessageBox::information(this, "成功", "");
|
||||
// qDebug() << "JSON 文件保存成功";
|
||||
//}
|
||||
//else {
|
||||
// qDebug() << "无法保存 JSON 文件";
|
||||
//}
|
||||
//
|
||||
nlohmann::json json;
|
||||
for (auto& data : privateJsondatas[currentPageIndex])
|
||||
{
|
||||
nlohmann::json eachJson;
|
||||
eachJson["level"] = data.acessLevel;
|
||||
eachJson["showName"] = data.showName;
|
||||
eachJson["valueName"] = data.showName;
|
||||
eachJson["value"] = data.getValueFromQwidget();
|
||||
eachJson["policy"] = data.formatPolicyStr;
|
||||
json.push_back(eachJson);
|
||||
}
|
||||
std::string sss = path.toStdString();
|
||||
saveJsonFromPath(sss, json);
|
||||
}
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) override {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <uiModule/uiModule_imageView.h>
|
||||
#include <uiModule/uiModule_historyListWidget.h>
|
||||
#include <uiModule/uiModule_menuListWdiget.h>
|
||||
#include <FrontendBackendBridge.h>
|
||||
#include <appConfig/appConfig.hpp>
|
||||
|
||||
class historyWidget :public QWidget
|
||||
{
|
||||
@@ -23,7 +25,9 @@ public:
|
||||
ImageWidget imageWidget;
|
||||
menuListWidget dirListWidget;
|
||||
historyShowListWidget _historyShowListWidget;
|
||||
historyWidget()
|
||||
QLabel* imgPosTip = new QLabel();
|
||||
std::unordered_map<std::string, QPixmap> namePairPixmap;//型号对应图片;
|
||||
historyWidget()
|
||||
{
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
@@ -53,28 +57,81 @@ public:
|
||||
Layout->addLayout(btnLayout);
|
||||
|
||||
mainWigetInit();
|
||||
loadProductNamePairPixmap();
|
||||
Layout->addWidget(widgets);
|
||||
QObject::connect(&_historyShowListWidget._historyShowListSubThread, &historyShowListSubThread::readImgSignal, &imageWidget, &ImageWidget::showImgOnGraphicsView);
|
||||
}
|
||||
void mainWigetInit()
|
||||
{
|
||||
imageWidget.setTitle("图片查看");
|
||||
mainWidgetLayout->addWidget(&imageWidget , 0, 0);
|
||||
mainWidgetLayout->setColumnStretch(0, 5);
|
||||
mainWidgetLayout->addWidget(&imageWidget , 0, 0,10,10);
|
||||
|
||||
mainWidgetLayout->addWidget(&dirListWidget, 0, 1);
|
||||
mainWidgetLayout->addWidget(&_historyShowListWidget, 0, 2);
|
||||
mainWidgetLayout->setColumnStretch(1, 1);
|
||||
mainWidgetLayout->setColumnStretch(2, 2);
|
||||
mainWidgetLayout->addWidget(&dirListWidget, 0, 10,10,2);
|
||||
|
||||
mainWidgetLayout->addWidget(imgPosTip, 0, 12, 2, 4);
|
||||
mainWidgetLayout->addWidget(&_historyShowListWidget, 2, 12,8,4);
|
||||
|
||||
dirListWidget.setStyleSheet("background: transparent;");
|
||||
QObject::connect(&dirListWidget, &menuListWidget::switchPathSignal, &_historyShowListWidget, &historyShowListWidget::addImgFromPath);
|
||||
QObject::connect(&dirListWidget, &menuListWidget::switchPathSignal, this, &historyWidget::switchPathProcessSlot);
|
||||
}
|
||||
void loadProductNamePairPixmap()
|
||||
{
|
||||
namePairPixmap.insert(std::make_pair("Manual", QPixmap("./imgPosTip/Test.jpg")));
|
||||
for (auto data : bridge._appConfig->productDatas)
|
||||
{
|
||||
namePairPixmap.insert(std::make_pair(data.name,QPixmap(data.imgPosPath.c_str())));
|
||||
}
|
||||
}
|
||||
bool showProductNamePairPixmap(std::string productName)
|
||||
{
|
||||
auto it = namePairPixmap.find(productName);
|
||||
if (it != namePairPixmap.end())
|
||||
{
|
||||
imgPosTip->setPixmap(it->second);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public slots:
|
||||
void switchPathProcessSlot(QString path)
|
||||
{
|
||||
//从文件夹名找型号
|
||||
{
|
||||
QString fileName = fileManager::getFileName(path);
|
||||
QStringList fileNameList = fileName.split("_");
|
||||
if (fileNameList.size() > 1)
|
||||
{
|
||||
std::string productName = fileNameList[0].toStdString();
|
||||
if(showProductNamePairPixmap(productName) == true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//从文件名找型号
|
||||
{
|
||||
std::vector<std::string>files;
|
||||
fileManager::getAllFiles(path.toStdString(), files, "",1);
|
||||
for (auto filePath : files)
|
||||
{
|
||||
filePath = fileManager::normalizePathStr(filePath);
|
||||
QString fileName = fileManager::normalizePathStr(fileManager::getFileName(QString::fromStdString(filePath)));
|
||||
std::string fileNameStr = fileName.toStdString();
|
||||
QStringList fileNameList = fileName.split("_");
|
||||
if (fileNameList.size() > 1)
|
||||
{
|
||||
std::string productName = fileNameList[0].toStdString();
|
||||
if (showProductNamePairPixmap(productName) == true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void widgetJumpWithPath(QString path)
|
||||
{
|
||||
dirListWidget.jumpWithPath(path);
|
||||
_historyShowListWidget._historyShowListSubThread.asyncReadImg(path.toStdString());
|
||||
|
||||
}
|
||||
};
|
||||
#pragma once
|
||||
#pragma once
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
leftMainLayout->setAlignment(Qt::AlignTop);
|
||||
mainLayout->addLayout(rightMainLayout);
|
||||
|
||||
connect(startEvaluateBtn, &QPushButton::clicked, this, [=]() {emit startManualDetSignal(imgPathEdit->text().toStdString(), algoSelect->currentIndex()); });
|
||||
connect(startEvaluateBtn, &QPushButton::clicked, this, [=]() {if (imgPathEdit->text().toStdString().compare("")) { emit startManualDetSignal(imgPathEdit->text().toStdString(), algoSelect->currentIndex()); } });
|
||||
connect(startEvaluateBtn, &QPushButton::clicked, this, [=]() {startEvaluateBtn->setDisabled(true); });
|
||||
//connect(_manualDetThread, &manualDetThread::finishImgReadSignal,this, &manualDetWidget::finishImgReadSlot);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <qpixmap.h>
|
||||
#include <opencv.hpp>
|
||||
#include <qdebug.h>
|
||||
#include <memory>
|
||||
|
||||
#pragma execution_character_set("utf-8")
|
||||
#define sColor_blue "51, 56, 69"
|
||||
#define sColor_blueWithWhite "64, 68, 81"
|
||||
@@ -17,8 +19,8 @@
|
||||
#define sColor_Black "22, 22, 22"
|
||||
#define sColor_BlackWithWhite "45, 45, 45"
|
||||
|
||||
#define enableHandleAiModel 1
|
||||
#define disableBackEndCheck 0
|
||||
#define enableHandleAiModel 0
|
||||
#define disableBackEndCheck 1
|
||||
#define disableeAlgo 0
|
||||
|
||||
//窗口设置
|
||||
@@ -50,6 +52,11 @@ struct showImgPack
|
||||
int index = -1;
|
||||
QString name = "";
|
||||
};
|
||||
struct historyPack
|
||||
{
|
||||
QPixmap img;
|
||||
std::shared_ptr<std::string>filePath;
|
||||
};
|
||||
static QImage cvMatToQImage(cv::Mat& src)
|
||||
{
|
||||
if (src.channels() == 1) { // if grayscale image
|
||||
@@ -105,4 +112,5 @@ Q_DECLARE_METATYPE(imgWidgetShowType)
|
||||
Q_DECLARE_METATYPE(cv::Mat*)
|
||||
Q_DECLARE_METATYPE(cv::Mat)
|
||||
Q_DECLARE_METATYPE(std::string)
|
||||
Q_DECLARE_METATYPE(historyPack)
|
||||
#pragma once
|
||||
@@ -7,15 +7,17 @@
|
||||
#include <qmessagebox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qlabel.h>
|
||||
#include <qlabel.h>
|
||||
|
||||
#include <qcombobox.h>
|
||||
#include <backEndManager.h>
|
||||
#include <QMetaType>
|
||||
#include <globalStruct.h>
|
||||
#include <back/logmsg.h>
|
||||
#include <FrontendBackendBridge.h>
|
||||
#include <mutex>
|
||||
#include <back/manualDetThread.h>
|
||||
#include <uiModule/uiModule_imageDoubleCheckQdialog.h>
|
||||
|
||||
void connectSignalAndSlots(MainWindow* front, backEndManager* back)
|
||||
{
|
||||
QObject::connect(back, &backEndManager::sendPixmapImageWidget, front, &MainWindow::recvPixmapImageWidget);
|
||||
@@ -49,7 +51,6 @@ int main(int argc, char* argv[])
|
||||
sema.release();
|
||||
//程序直接退出
|
||||
exit(0);
|
||||
|
||||
}
|
||||
sema.release();
|
||||
//////////
|
||||
@@ -58,6 +59,8 @@ int main(int argc, char* argv[])
|
||||
qRegisterMetaType<cv::Mat*>("matPtr");
|
||||
qRegisterMetaType<cv::Mat>("mat");
|
||||
qRegisterMetaType<std::string>("stdString");
|
||||
qRegisterMetaType<historyPack>("historyPack");
|
||||
|
||||
appConfig _appConfig;
|
||||
MainWindow w(&_appConfig);
|
||||
w.show();
|
||||
|
||||
@@ -228,9 +228,9 @@ public slots:
|
||||
_loadingWidget.initLog->append(strIn);
|
||||
}
|
||||
}
|
||||
void addDetHistoryData(bool isOK, QString path, QPixmap img)
|
||||
void addDetHistoryData(bool isOK, historyPack _historyPack)
|
||||
{
|
||||
_displayWidget->historyImgs->addData(isOK, path, img);
|
||||
_displayWidget->historyImgs->addData(isOK, _historyPack);
|
||||
}
|
||||
void addDashBoardData(int index, bool value)//增加一个OK/NG数据到dashboard
|
||||
{
|
||||
|
||||
@@ -284,6 +284,26 @@ public:
|
||||
return path.mid(lastSlashIndex + 1, lastDotIndex - lastSlashIndex - 1);
|
||||
}
|
||||
}
|
||||
//统一地址分隔符
|
||||
static QString normalizePathStr(const QString& address, QChar targetSeparator = '/') {
|
||||
QString normalizedAddress = address;
|
||||
for (int i = 0; i < normalizedAddress.size(); ++i) {
|
||||
if (normalizedAddress[i] == '\\' || normalizedAddress[i] == '/') {
|
||||
normalizedAddress[i] = targetSeparator;
|
||||
}
|
||||
}
|
||||
return normalizedAddress;
|
||||
}
|
||||
//统一地址分隔符
|
||||
static std::string normalizePathStr(const std::string& address, char targetSeparator = '/') {
|
||||
std::string normalizedAddress = address;
|
||||
for (char& ch : normalizedAddress) {
|
||||
if (ch == '\\' || ch == '/') {
|
||||
ch = targetSeparator;
|
||||
}
|
||||
}
|
||||
return normalizedAddress;
|
||||
}
|
||||
};
|
||||
/// <summary>
|
||||
/// 自动删除文件夹,支持按日期删除,按磁盘剩余容量删除,或者两者都是,请在主线程声明qtimer
|
||||
|
||||
@@ -15,38 +15,35 @@ class historyItemWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
|
||||
historyPack _historyPack;
|
||||
QLabel* resultLabel = new QLabel(this);
|
||||
QLabel* fileNameLabel = new QLabel(this);
|
||||
QLabel* filePathHide = new QLabel(this);
|
||||
|
||||
QLabel* imgShow = new QLabel();
|
||||
historyItemWidget(QString title,std::string filePath,QPixmap img , QSize parentSize)
|
||||
historyItemWidget(QString title, QSize parentSize, historyPack historyPackIn)
|
||||
{
|
||||
if (img.isNull())
|
||||
if (historyPackIn.img.isNull())
|
||||
return;
|
||||
_historyPack = historyPackIn;
|
||||
QFont font("΢ÈíÑźÚ", 12, QFont::Bold);
|
||||
this->setObjectName("historyItemWidget");
|
||||
|
||||
resultLabel->setText(title);
|
||||
resultLabel->setFont(font);
|
||||
resultLabel->setStyleSheet("QLabel { color: white; }");
|
||||
layout->addWidget(resultLabel,0,0);
|
||||
|
||||
filePathHide->setText(QString::fromStdString(filePath));
|
||||
filePathHide->hide();
|
||||
filePathHide->setObjectName("path");
|
||||
|
||||
fileNameLabel->setText(QString::fromStdString(fileManager::getFileName(filePath)));
|
||||
fileNameLabel->setText(QString::fromStdString(fileManager::getFileName(*historyPackIn.filePath)));
|
||||
fileNameLabel->setFont(font);
|
||||
fileNameLabel->setStyleSheet("QLabel { color: white; }");
|
||||
layout->addWidget(fileNameLabel, 1, 0);
|
||||
|
||||
int iHeight = img.size().height();
|
||||
int iHeight = historyPackIn.img.size().height();
|
||||
int pHeight = (parentSize.height() / 5);
|
||||
double widthScale = iHeight / pHeight;
|
||||
|
||||
img = img.scaled(img.size().width() * widthScale, parentSize.height() / 5, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
imgShow->setPixmap(img);
|
||||
historyPackIn.img = historyPackIn.img.scaled(historyPackIn.img.size().width() * widthScale, parentSize.height() / 5, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
imgShow->setPixmap(historyPackIn.img);
|
||||
layout->addWidget(imgShow,0,1);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
@@ -72,7 +69,10 @@ private:
|
||||
continue;
|
||||
QPixmap map;
|
||||
cvMatToQPixMap(mat, map);
|
||||
addDataSignal((data.second.find("OK") != std::string::npos), QString::fromStdString(data.second), map);
|
||||
historyPack _historyPack;
|
||||
_historyPack.filePath = std::shared_ptr<std::string>(new std::string(data.second));
|
||||
_historyPack.img = map;
|
||||
addDataSignal((data.second.find("OK") != std::string::npos), _historyPack);
|
||||
}
|
||||
else if (data.first == 1)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ public slots:
|
||||
this->start();
|
||||
}
|
||||
signals:
|
||||
void addDataSignal(bool isOk,QString, QPixmap img);
|
||||
void addDataSignal(bool isOk, historyPack _historyPack);
|
||||
void readImgSignal(QPixmap img);
|
||||
};
|
||||
class historyShowListWidget : public QWidget
|
||||
@@ -148,14 +148,14 @@ public slots:
|
||||
emit asyncReadIconsSignal(files);
|
||||
|
||||
}
|
||||
void addData(bool isOk, QString path, QPixmap img)
|
||||
void addData(bool isOk, historyPack _historyPack)
|
||||
{
|
||||
QString title;
|
||||
if (isOk == true)
|
||||
title = "OK";
|
||||
else
|
||||
title = "NG";
|
||||
QWidget* widget = new historyItemWidget(title, path.toStdString(), img, size());
|
||||
QWidget* widget = new historyItemWidget(title,size(), _historyPack);
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
showDataListWidget->addItem(item);
|
||||
showDataListWidget->setItemWidget(item, widget);
|
||||
@@ -169,17 +169,11 @@ public slots:
|
||||
private slots:
|
||||
void itemClick(QListWidgetItem* item)
|
||||
{
|
||||
QWidget* widget = showDataListWidget->itemWidget(item);
|
||||
const QList<QLabel*> labels = widget->findChildren<QLabel*>();
|
||||
for (const QLabel* label : labels)
|
||||
{
|
||||
if (label->objectName() == "path")
|
||||
{
|
||||
QString path = label->text();
|
||||
emit asyncReadImgSignal(path.toStdString());
|
||||
emit itemClickSignal(path);
|
||||
}
|
||||
}
|
||||
historyItemWidget* widget = (historyItemWidget*)showDataListWidget->itemWidget(item);
|
||||
std::string path = *widget->_historyPack.filePath;
|
||||
QString pathQ = QString::fromStdString(path);
|
||||
emit asyncReadImgSignal(path);
|
||||
emit itemClickSignal(pathQ);
|
||||
}
|
||||
signals:
|
||||
void asyncReadImgSignal(std::string);
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
#include <QDialog>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlayout.h>
|
||||
#include <globalStruct.h>
|
||||
#include <qtimer.h>
|
||||
#include <qlabel.h>
|
||||
#include <uiModule/components/fancyButton.h>
|
||||
#include <qdatetime.h>
|
||||
#include <uiModule/uiModule_imageView.h>
|
||||
|
||||
class imageDoubleCheckQdialog :public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ImageWidgetManager* _ImageWidgetManager = new ImageWidgetManager();
|
||||
QWidget* menuBarWidget = new QWidget();
|
||||
QPushButton* closeBtn = new QPushButton(this);
|
||||
fancyButtonText* okBtn = new fancyButtonText(120, 40, "OK", "继续");
|
||||
fancyButtonText* ngBtn = new fancyButtonText(120, 40, "NG", "继续");
|
||||
imageDoubleCheckQdialog(QPixmap img)
|
||||
{
|
||||
QPalette paletteWhite, paletteRed, paletteGreen;
|
||||
paletteWhite.setColor(QPalette::WindowText, Qt::white);
|
||||
paletteRed.setColor(QPalette::WindowText, Qt::red);
|
||||
paletteGreen.setColor(QPalette::WindowText, Qt::green);
|
||||
QFont font("微软雅黑", 16, QFont::Bold);
|
||||
QFont font2("微软雅黑", 18, QFont::Bold);
|
||||
QFont font3("微软雅黑", 12, QFont::Bold);
|
||||
|
||||
this->setObjectName("warnDialog");
|
||||
this->setStyleSheet(QString("QDialog#warnDialog {"
|
||||
"background-color: rgb(%1);"
|
||||
"border: 1px solid black;"
|
||||
"border-radius: 1px;}").arg(sColor_blue));
|
||||
this->setWindowFlags(Qt::FramelessWindowHint); // 设置无边框的样式
|
||||
this->setFixedSize(QSize(minWidth, minHeight));
|
||||
|
||||
QGridLayout* layout = new QGridLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
menuBarWidget->setStyleSheet(QString("QWidget { background-color: black;"
|
||||
"border: 0px solid red;" // 显式设置边框
|
||||
"border-radius: 0px;" // 设置边框半径为0,确保没有圆角
|
||||
"}"));
|
||||
menuBarWidget->setFixedHeight(35);
|
||||
menuBarWidget->setFixedWidth(minWidth);
|
||||
|
||||
QHBoxLayout* menuBarLayout = new QHBoxLayout(menuBarWidget);
|
||||
menuBarLayout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QHBoxLayout* menuBarLayoutLeft = new QHBoxLayout();
|
||||
menuBarLayoutLeft->setContentsMargins(0, 0, 0, 0);
|
||||
menuBarLayoutLeft->setAlignment(Qt::AlignLeft);
|
||||
|
||||
QHBoxLayout* menuBarLayoutRight = new QHBoxLayout();
|
||||
menuBarLayoutRight->setContentsMargins(0, 0, 0, 0);
|
||||
menuBarLayoutRight->setAlignment(Qt::AlignRight);
|
||||
|
||||
menuBarLayout->addLayout(menuBarLayoutLeft);
|
||||
menuBarLayout->addLayout(menuBarLayoutRight);
|
||||
|
||||
QLabel* warnLabel = new QLabel();
|
||||
warnLabel->setAlignment(Qt::AlignLeft);
|
||||
warnLabel->setFont(font);
|
||||
warnLabel->setText("请确认是否NG");
|
||||
warnLabel->setPalette(paletteWhite);
|
||||
menuBarLayoutLeft->addWidget(warnLabel);
|
||||
|
||||
closeBtn->setIcon(QPixmap(":/topBar/icon/close.png")); // 设置图标
|
||||
closeBtn->setFixedHeight(35);
|
||||
closeBtn->setStyleSheet(QString("QPushButton { background-color: transparent;"
|
||||
"border: 0px solid red;" // 显式设置边框
|
||||
"border-radius: 0px;" // 设置边框半径为0,确保没有圆角
|
||||
"}"
|
||||
"QPushButton:focus {"
|
||||
" outline: none;"
|
||||
"}"
|
||||
"QPushButton:hover { background-color: rgb(%1); }").arg(sColor_Red)); // 设置透明背景和悬停时的背景色
|
||||
closeBtn->setFixedHeight(35);
|
||||
closeBtn->setFixedWidth(50);
|
||||
menuBarLayoutRight->addWidget(closeBtn);
|
||||
|
||||
QObject::connect(closeBtn, &QPushButton::clicked, this, &QDialog::close);
|
||||
|
||||
QHBoxLayout* imageViewLayout = new QHBoxLayout();
|
||||
imageViewLayout->addWidget(_ImageWidgetManager);
|
||||
|
||||
_ImageWidgetManager->createViewer("");
|
||||
_ImageWidgetManager->disableAllSwitchBtn();
|
||||
_ImageWidgetManager->showImg(img, imgWidgetShowType::imgWidgetOri, 0);
|
||||
QHBoxLayout* okngBtnLayout = new QHBoxLayout();
|
||||
okngBtnLayout->addWidget(okBtn);
|
||||
okngBtnLayout->addWidget(ngBtn);
|
||||
|
||||
QObject::connect(okBtn, &QPushButton::clicked, this, &QDialog::close);
|
||||
QObject::connect(ngBtn, &QPushButton::clicked, this, &QDialog::close);
|
||||
QObject::connect(okBtn, &QPushButton::clicked, this, [=]() {emit okSignal(); });
|
||||
QObject::connect(ngBtn, &QPushButton::clicked, this, [=]() {emit ngSignal(); });
|
||||
|
||||
layout->addWidget(menuBarWidget, 0, 0);
|
||||
layout->addLayout(imageViewLayout, 1, 0);
|
||||
layout->addLayout(okngBtnLayout, 2, 0);
|
||||
this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);
|
||||
this->show();
|
||||
}
|
||||
signals:
|
||||
void okSignal();
|
||||
void ngSignal();
|
||||
private:
|
||||
bool isMoving = false;
|
||||
bool isResizing = false;
|
||||
int minWidth = 720, minHeight = 480;
|
||||
QSize originalSize;
|
||||
//窗口移动
|
||||
#pragma region 窗口移动变量
|
||||
QPoint startPos;
|
||||
QRect startFrameGeometry;
|
||||
QTime lastWindowMoveTime;
|
||||
int freshDelay = 1000 / windowMoveFreshRate;
|
||||
bool setNormalAndMove = false;//判断是否从最大化开始移动
|
||||
#pragma endregion
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent* event) override {
|
||||
QPoint pos = event->pos();
|
||||
std::cout << "y" << pos.y() << " x" << pos.x() << std::endl;
|
||||
if (pos.y() < 35)//标题栏
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
startPos = event->globalPos();
|
||||
startFrameGeometry = frameGeometry();
|
||||
isMoving = true;
|
||||
lastWindowMoveTime.start(); // 按下时开始计时
|
||||
}
|
||||
}
|
||||
else if (pos.x() < 10 || //左边框
|
||||
pos.x() > this->size().width()-10 || //下边框
|
||||
pos.y() > this->size().height() - 10)//右边框
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
isResizing = true;
|
||||
startPos = event->globalPos();
|
||||
originalSize = size();
|
||||
}
|
||||
}
|
||||
QDialog::mousePressEvent(event);
|
||||
}
|
||||
void mouseMoveEvent(QMouseEvent* event) override {
|
||||
if (event->buttons() == Qt::LeftButton)
|
||||
{
|
||||
if (isMoving) {
|
||||
QPoint pos = event->globalPos();
|
||||
if (std::max(std::abs(pos.x() - startPos.x()), std::abs(pos.y() - startPos.y())) > 10)
|
||||
if (lastWindowMoveTime.elapsed() > freshDelay)//每秒刷新100次
|
||||
{
|
||||
lastWindowMoveTime.restart();
|
||||
move(startFrameGeometry.topLeft() + (event->globalPos() - startPos));
|
||||
}
|
||||
}
|
||||
if (isResizing) {
|
||||
QPoint delta = event->globalPos() - startPos;
|
||||
QSize newSize = originalSize + QSize(delta.x(), delta.y());
|
||||
setFixedSize(std::max(minWidth ,newSize.width()), std::max(minHeight, newSize.height()));
|
||||
menuBarWidget->setFixedWidth(std::max(minWidth, newSize.width()));
|
||||
}
|
||||
}
|
||||
QDialog::mouseMoveEvent(event);
|
||||
}
|
||||
void mouseReleaseEvent(QMouseEvent* event) override {
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
isMoving = false;
|
||||
isResizing = false;
|
||||
}
|
||||
QDialog::mouseReleaseEvent(event);
|
||||
}
|
||||
};
|
||||
#pragma once
|
||||
@@ -175,6 +175,7 @@ private:
|
||||
class ImageWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
fancyButton* switchBtn;
|
||||
ImageWidget(QWidget* parent = nullptr) : QWidget(parent) {
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(5, 5, 5, 5);
|
||||
@@ -201,7 +202,7 @@ public:
|
||||
hLayout->addWidget(label);
|
||||
hLayout->addWidget(label2);
|
||||
hLayout->setContentsMargins(0, 0, 0, 0);
|
||||
fancyButton* switchBtn = new fancyButton(
|
||||
switchBtn = new fancyButton(
|
||||
30,
|
||||
30,
|
||||
QIcon(":/topBar/icon/switch.png"),
|
||||
@@ -352,6 +353,11 @@ public:
|
||||
QMutex mutex;
|
||||
QList< ImageWidget*>ImageWidgetList;
|
||||
std::unordered_map<QString, ImageWidget*>map;
|
||||
void disableAllSwitchBtn()
|
||||
{
|
||||
for (auto widget : ImageWidgetList)
|
||||
widget->switchBtn->hide();
|
||||
}
|
||||
|
||||
bool showImg(QPixmap img, imgWidgetShowType _type, int index)
|
||||
{
|
||||
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
pathList.append(basePath);
|
||||
refreshListWidget();
|
||||
targetDepth = pathList.size();
|
||||
depth = targetDepth;
|
||||
_toolItemWidget->returnBtn->setDisabled(true);
|
||||
_toolItemWidget->homeBtn->setDisabled(true);
|
||||
QObject::connect(this, &QListWidget::itemClicked, this, &menuListWidget::itemClick);
|
||||
@@ -97,7 +98,7 @@ public:
|
||||
}
|
||||
void toMenu()
|
||||
{
|
||||
jumpWithPath(basePath);
|
||||
jumpWithPath(basePath+"\\");
|
||||
}
|
||||
void jumpWithPath(QString path)
|
||||
{
|
||||
@@ -110,10 +111,10 @@ public:
|
||||
return;
|
||||
|
||||
//写入
|
||||
std::string fileName = fileManager::getFileName(path.toStdString());
|
||||
//std::string fileName = fileManager::getFileName(path.toStdString());
|
||||
pathList.clear();
|
||||
for (auto str : list)
|
||||
if (str.contains(QString::fromStdString(fileName)) == false)
|
||||
//if (str.contains(QString::fromStdString(fileName)) == false)
|
||||
pathList.append(str);
|
||||
|
||||
depth = pathList.size() - 1;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <qmutex.h>
|
||||
#include <FrontendBackendBridge.h>
|
||||
#include <appConfig/appConfig.hpp>
|
||||
#include <qlineedit.h>
|
||||
|
||||
class switchProductWidget : public QWidget
|
||||
{
|
||||
@@ -26,12 +27,16 @@ public:
|
||||
int* currentProductIndexPtr;
|
||||
//
|
||||
std::string fileDir = "./config/productConfig";
|
||||
QLabel* staticLabel = new QLabel(this);
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
fancyButtonText* switchBtn = new fancyButtonText(100, 60, "修改", "修改当前机型");
|
||||
QLabel* armHeartBeatSign = new QLabel();
|
||||
fancyButtonText* startBtn;
|
||||
QLineEdit* snIntputLine = new QLineEdit();
|
||||
//料号显示
|
||||
QComboBox* productSelect = new QComboBox(this);
|
||||
QLabel* currentProduct = new QLabel(this);
|
||||
//料号类型
|
||||
QComboBox* productNameTypeSwitch = new QComboBox(this);
|
||||
switchProductWidget()
|
||||
{
|
||||
currentProductIndexPtr = &bridge.currentProductIndex;
|
||||
@@ -41,10 +46,14 @@ public:
|
||||
this->setLayout(layout);
|
||||
{
|
||||
QHBoxLayout* switchLayout = new QHBoxLayout();
|
||||
staticLabel->setText("当前型号:");
|
||||
staticLabel->setFont(font);
|
||||
staticLabel->setPalette(palette);
|
||||
switchLayout->addWidget(staticLabel);
|
||||
productNameTypeSwitch->addItem("型号:");
|
||||
productNameTypeSwitch->addItem("客户料号:");
|
||||
productNameTypeSwitch->addItem("富士康料号:");
|
||||
|
||||
productNameTypeSwitch->setPalette(palette);
|
||||
productNameTypeSwitch->setFont(font);
|
||||
productNameTypeSwitch->setFixedWidth(150);
|
||||
switchLayout->addWidget(productNameTypeSwitch);
|
||||
|
||||
productSelect->setPalette(palette);
|
||||
productSelect->setFont(font);
|
||||
@@ -60,18 +69,27 @@ public:
|
||||
|
||||
layout->addLayout(switchLayout);
|
||||
}
|
||||
startBtn = new fancyButtonText(300, 60, "运行", "运行检测程序");
|
||||
layout->addWidget(startBtn);
|
||||
fresh();
|
||||
snIntputLine->setFixedHeight(50);
|
||||
snIntputLine->setFont(font);
|
||||
|
||||
QHBoxLayout* hBtnLayout = new QHBoxLayout();
|
||||
startBtn = new fancyButtonText(80, -1, "运行", "运行检测程序");
|
||||
hBtnLayout->addWidget(snIntputLine);
|
||||
hBtnLayout->addWidget(startBtn);
|
||||
|
||||
layout->addLayout(hBtnLayout);
|
||||
productSelectFresh(0);
|
||||
connect(startBtn, &QPushButton::clicked, this, [=]()
|
||||
{
|
||||
emit startArmProgramSignal(productSelect->currentIndex());
|
||||
emit startArmProgramSignal(productSelect->currentIndex(), snIntputLine->text());
|
||||
});
|
||||
connect(switchBtn, &QPushButton::clicked, this, &switchProductWidget::startSwitch);
|
||||
connect(productSelect, &QComboBox::currentTextChanged, this, &switchProductWidget::currentProductSwitch);
|
||||
connect(productNameTypeSwitch, &QComboBox::currentTextChanged, this, [=]() {productSelectFresh(productNameTypeSwitch->currentIndex()); });
|
||||
}
|
||||
void fresh()
|
||||
void productSelectFresh(int index)
|
||||
{
|
||||
int indexTemp = std::max(productSelect->currentIndex(), 0);
|
||||
productSelect->clear();
|
||||
if (bridge._appConfig->productDatas.size() == 0)
|
||||
{
|
||||
@@ -80,26 +98,48 @@ public:
|
||||
QString("请查看%1中是否正确存放配置文件").arg(QString::fromStdString(fileDir)));
|
||||
return;
|
||||
}
|
||||
for (auto data : bridge._appConfig->productDatas)
|
||||
productSelect->addItem(QString::fromStdString(data.name));
|
||||
currentProduct->setText(QString::fromStdString(bridge._appConfig->productDatas[0].name));
|
||||
switch(index)
|
||||
{
|
||||
case 0:
|
||||
for (auto data : bridge._appConfig->productDatas)
|
||||
productSelect->addItem(QString::fromStdString(data.name));
|
||||
currentProduct->setText(QString::fromStdString(bridge._appConfig->productDatas[indexTemp].name));
|
||||
break;
|
||||
case 1:
|
||||
for (auto data : bridge._appConfig->productDatas)
|
||||
productSelect->addItem(QString::fromStdString(data.customerPartNumber));
|
||||
currentProduct->setText(QString::fromStdString(bridge._appConfig->productDatas[indexTemp].customerPartNumber));
|
||||
break;
|
||||
case 2:
|
||||
for (auto data : bridge._appConfig->productDatas)
|
||||
productSelect->addItem(QString::fromStdString(data.foxconnPartNumber));
|
||||
currentProduct->setText(QString::fromStdString(bridge._appConfig->productDatas[indexTemp].foxconnPartNumber));
|
||||
break;
|
||||
}
|
||||
productSelect->setCurrentIndex(indexTemp);
|
||||
}
|
||||
public slots:
|
||||
void setHeatBeat()
|
||||
{
|
||||
|
||||
}
|
||||
void switchStartBtnStatus(bool status)
|
||||
{
|
||||
if (status == true)
|
||||
{
|
||||
startBtn->toDefault();
|
||||
startBtn->setText("运行");
|
||||
snIntputLine->setDisabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
startBtn->toRed();
|
||||
startBtn->setText("急停");
|
||||
snIntputLine->setDisabled(true);
|
||||
}
|
||||
}
|
||||
signals:
|
||||
void startArmProgramSignal(int);
|
||||
void startArmProgramSignal(int,QString);
|
||||
private:
|
||||
int siwtchBtnState = 0;
|
||||
private slots:
|
||||
@@ -129,7 +169,8 @@ private slots:
|
||||
*currentProductIndexPtr = index;
|
||||
|
||||
currentProduct->setText(input);
|
||||
|
||||
if (siwtchBtnState == 1)
|
||||
return;
|
||||
startSwitch();
|
||||
}
|
||||
};
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user