diff --git a/ledset/capthread - 副本.cpp b/ledset/capthread - 副本.cpp deleted file mode 100644 index 99fe66a..0000000 --- a/ledset/capthread - 副本.cpp +++ /dev/null @@ -1,324 +0,0 @@ -#include "capthread.h" -#include -#include - -CapThread::CapThread(struct pcap *pcap, QObject *parent) : QThread(parent), pcap(pcap) { - connect(this, &QThread::finished, this, &QThread::deleteLater); -} - -void CapThread::run() { - pcap_pkthdr *header; - const u_char *pkt_data; - -// qDebug("The program is working......\n"); -// qDebug("The capture file is saving as 'data.txt'\n"); -// qDebug("You can input 'ctrl + C' to stop the program\n"); - int res; - while((res = pcap_next_ex(pcap, &header, &pkt_data)) >= 0) { - if (res == 0) continue; //超时 - packet.time = QDateTime::fromSecsSinceEpoch(header->ts.tv_sec).toString("yy-MM-dd HH:mm:ss.")+QString::number(header->ts.tv_usec); - packet.len = header->len; - //输出编号、时间戳和包长度 - qDebug("=======================\n"); - qDebug()<caplen<<"/"<len; - QString data_str; - char line[LINE_LEN + 1]; - int l = 0; - for(uint i=0; i < header->caplen; i++) { - data_str.append(QString::asprintf("%.2x ", pkt_data[i])); - if(i > 13) { - if(isgraph(pkt_data[i]) || pkt_data[i] == ' ') line[l] = pkt_data[i]; - else line[l] = '.'; - if(l==15) { - line[16] = '\0'; - data_str.append(" "); - data_str.append(line); - data_str.append("\n"); - memset(line, 0, LINE_LEN); - l = 0; - } else l++; - } else if(i == 13) { - data_str.append("\n"); - } - } - packet.data = data_str; - qDebug()<append(packet); - //emit newPacket(); - } - qDebug("Error reading the packets: %s\n", pcap_geterr(pcap)); - -} - -// TCP协议处理 -//u_short sport; -//u_short dport; -//u_int sequence; // 序列码 -//u_int ack; // 回复码 -//u_char hdrLen; // 首部长度保留字 -//u_char flags; // 标志 -//u_short windows; // 窗口大小 -//u_short checksum; // 校验和 -//u_short urgent_pointer; // 紧急指针 -void CapThread::tcp_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content) { - packet.tcp_header = *(TcpHeader*) (pkt_content + 14 + 20); -// qDebug("===================TCP Protocol=================\n"); - -// qDebug("Source Port: %i\n", ntohs(tcp_protocol->sport)); -// qDebug("Destination Port: %i\n", ntohs(tcp_protocol->dport)); -// qDebug("Sequence number: %d\n", ntohl(tcp_protocol->sequence)); -// qDebug("Acknowledgment number: %d\n", ntohl(tcp_protocol->ack)); -// qDebug("Header Length: %d\n", (tcp_protocol->hdrLen >> 4) * 4); -// qDebug("Flags: 0x%.3x ", tcp_protocol->flags); -// if (tcp_protocol->flags & 0x08) qDebug("(PSH)"); -// if (tcp_protocol->flags & 0x10) qDebug("(ACK)"); -// if (tcp_protocol->flags & 0x02) qDebug("(SYN)"); -// if (tcp_protocol->flags & 0x20) qDebug("(URG)"); -// if (tcp_protocol->flags & 0x01) qDebug("(FIN)"); -// if (tcp_protocol->flags & 0x04) qDebug("(RST)"); -// qDebug("\n"); -// qDebug("Windows Size: %i\n", ntohs(tcp_protocol->windows)); -// qDebug("Checksum: 0x%.4x\n", ntohs(tcp_protocol->checksum)); -// qDebug("Urgent Pointer: %i\n", ntohs(tcp_protocol->urgent_pointer)); -} - -// UDP协议处理 -//u_short sport; // 源端口 -//u_short dport; // 目标端口 -//u_short datalen; // UDP数据长度 -//u_short checksum; // 校验和 -void CapThread::udp_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content) { - packet.udp_header = *(UdpHeader*)(pkt_content + 14 + 20); -// qDebug("===================UDP Protocol=================\n"); -// qDebug("Source Port: %i\n", ntohs(udp_protocol->sport)); -// qDebug("Destination Port: %i\n", ntohs(udp_protocol->dport)); -// qDebug("Datalen: %i\n", ntohs(udp_protocol->datalen)); -// qDebug("Checksum: 0x%.4x\n", ntohs(udp_protocol->checksum)); -} - -// ICMP协议处理 -//u_char type; // ICMP类型 -//u_char code; // 代码 -//u_short checksum; // 校验和 -//u_short identification; // 标识 -//u_short sequence; // 序列号 -//u_long timestamp; // 时间戳 -void CapThread::icmp_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content) { - packet.icmp_header = *(IcmpHeader*)(pkt_content + 14 + 20); -// qDebug("==================ICMP Protocol=================\n"); -// qDebug("Type: %d ", icmp_protocol->type); -// switch (icmp_protocol->type) -// { -// case 8: -// qDebug("(request)\n"); -// break; -// case 0: -// qDebug("(reply)\n"); -// break; -// default: -// qDebug("\n"); -// break; -// } -// qDebug("Code: %d\n", icmp_protocol->code); -// qDebug("CheckSum: 0x%.4x\n", ntohs(icmp_protocol->checksum)); -// qDebug("Identification: 0x%.4x\n", ntohs(icmp_protocol->identification)); -// qDebug("Sequence: 0x%.4x\n", ntohs(icmp_protocol->sequence)); -} - -// ARP协议处理 -//u_short hardware_type; // 格式化的硬件地址 -//u_short protocol_type; // 协议地址格式 -//u_char hardware_length; // 硬件地址长度 -//u_char protocol_length; // 协议地址长度 -//u_short operation_code; // 操作码 -//u_char source_ethernet_address[6]; // 发送者硬件地址 -//u_char source_ip_address[4]; // 发送者协议地址 -//u_char destination_ethernet_address[6]; // 目的方硬件地址 -//u_char destination_ip_address[4]; // 目的方协议地址 -void CapThread::arp_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content) { - packet.arp_header = *(ArpHeader*)(pkt_content + 14); -// qDebug("==================ARP Protocol==================\n"); -// qDebug("Hardware Type: "); -// switch (ntohs(arp_protocol->hardware_type)) -// { -// case 1: -// qDebug("Ethernet"); -// break; -// default: -// break; -// } -// qDebug(" (%d)\n", ntohs(arp_protocol->hardware_type)); -// qDebug("Protocol Type: \n"); -// switch (ntohs(arp_protocol->protocol_type)) -// { -// case 0x0800: -// qDebug("%s", "IP"); -// break; -// case 0x0806: -// qDebug("%s", "ARP"); -// break; -// case 0x0835: -// qDebug("%s", "RARP"); -// break; -// default: -// qDebug("%s", "Unknown Protocol"); -// break; -// } -// qDebug(" (0x%04x)\n", ntohs(arp_protocol->protocol_type)); -// qDebug("Hardware Length: %d\n", arp_protocol->hardware_length); -// qDebug("Protocol Length: %d\n", arp_protocol->protocol_length); -// qDebug("Operation Code: "); -// switch (ntohs(arp_protocol->operation_code)) -// { -// case 1: -// qDebug("request"); -// break; -// case 2: -// qDebug("reply"); -// break; -// default: -// break; -// } -// qDebug(" (%i)\n", ntohs(arp_protocol->operation_code)); -} - -// IP协议处理 -//u_char version_hlen; // 首部长度 版本 -//u_char tos; // 服务质量 -//u_short tlen; // 总长度 -//u_short identification; // 身份识别 -//u_short flags_offset; // 标识 分组偏移 -//u_char ttl; // 生命周期 -//u_char proto; // 协议类型 -//u_short checksum; // 包头测验码 -//u_int saddr; // 源IP地址 -//u_int daddr; // 目的IP地址 -void CapThread::ip_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content) { - sockaddr_in source, dest; - char sourceIP[MAX_ADDR_LEN], destIP[MAX_ADDR_LEN]; - - auto ip_protocol = (IpHeader*)(pkt_content + 14); - source.sin_addr.s_addr = ip_protocol->saddr; - dest.sin_addr.s_addr = ip_protocol->daddr; - strncpy(sourceIP, inet_ntoa(source.sin_addr), MAX_ADDR_LEN); - strncpy(destIP, inet_ntoa(dest.sin_addr), MAX_ADDR_LEN); - - packet.ip_header = *ip_protocol; - -// qDebug("===================IP Protocol==================\n"); -// qDebug("Version: %d\n", ip_protocol->version_hlen >> 4); -// qDebug("Header Length: %d bytes\n", (ip_protocol->version_hlen & 0x0f) * 4); -// qDebug("Tos: %d\n", ip_protocol->tos); -// qDebug("Total Length: %d\n", ntohs(ip_protocol->tlen)); -// qDebug("Identification: 0x%.4x (%i)\n", ntohs(ip_protocol->identification), ntohs(ip_protocol->identification)); -// qDebug("Flags: %d\n", ntohs(ip_protocol->flags_offset) >> 13); -// qDebug("---Reserved bit: %d\n", (ntohs(ip_protocol->flags_offset) & 0x8000) >> 15); -// qDebug("---Don't fragment: %d\n", (ntohs(ip_protocol->flags_offset) & 0x4000) >> 14); -// qDebug("---More fragment: %d\n", (ntohs(ip_protocol->flags_offset) & 0x2000) >> 13); -// qDebug("Fragment offset: %d\n", ntohs(ip_protocol->flags_offset) & 0x1fff); -// qDebug("Time to live: %d\n", ip_protocol->ttl); -// qDebug("Protocol Type: "); - switch (ip_protocol->proto) - { - case 1: -// qDebug("ICMP"); - packet.protocol = "ICMP"; - break; - case 6: -// qDebug("TCP"); - packet.protocol = "TCP"; - break; - case 17: -// qDebug("UDP"); - packet.protocol = "UDP"; - break; - default: - break; - } -// qDebug(" (%d)\n", ip_protocol->proto); -// qDebug("Header checkSum: 0x%.4x\n", ntohs(ip_protocol->checksum)); -// qDebug("Source: %s\n", sourceIP); -// qDebug("Destination: %s\n", destIP); - - if (ip_protocol->proto == htons(0x0600)) - tcp_protocol_packet_handle(arg, pkt_header, pkt_content); - else if (ip_protocol->proto == htons(0x1100)) - udp_protocol_packet_handle(arg, pkt_header, pkt_content); - else if (ip_protocol->proto == htons(0x0100)) - icmp_protocol_packet_handle(arg, pkt_header, pkt_content); -} -// Ethernet协议处理 -void CapThread::ethernet_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content) { - packet.ether_header = *(EtherHeader*)pkt_content; - u_short ethernet_type; //以太网类型 - u_char *mac_string; //以太网地址 - //获取以太网数据内容 - ethernet_type = ntohs(packet.ether_header.ether_type); - -// qDebug("==============Ethernet Protocol=================\n"); - -// //以太网目标地址 -// mac_string = ethernet_protocol->ether_dhost; - -// qDebug("Destination Mac Address: %02x:%02x:%02x:%02x:%02x:%02x\n", -// *mac_string, -// *(mac_string + 1), -// *(mac_string + 2), -// *(mac_string + 3), -// *(mac_string + 4), -// *(mac_string + 5)); - -// //以太网源地址 -// mac_string = ethernet_protocol->ether_shost; - -// qDebug("Source Mac Address: %02x:%02x:%02x:%02x:%02x:%02x\n", -// *mac_string, -// *(mac_string + 1), -// *(mac_string + 2), -// *(mac_string + 3), -// *(mac_string + 4), -// *(mac_string + 5)); - -// qDebug("Ethernet type: "); - switch (ethernet_type) - { - case 0x0800: -// qDebug("%s", "IP"); - break; - case 0x0806: -// qDebug("%s", "ARP"); - packet.protocol = "ARP"; - break; - case 0x0835: -// qDebug("%s", "RARP"); -// packet_data.setRarp_flag(true); - break; - default: -// qDebug("%s", "Unknown Protocol"); - packet.protocol = "Unknown Protocol"; - break; - } -// qDebug(" (0x%04x)\n", ethernet_type); - - switch (ethernet_type) - { - case 0x0800: - ip_protocol_packet_handle(arg, pkt_header, pkt_content); - break; - case 0x0806: - arp_protocol_packet_handle(arg, pkt_header, pkt_content); - break; -// case 0x0835: -// qDebug("==============RARP Protocol=================\n"); -// qDebug("RARP\n"); -// break; -// default: -// qDebug("==============Unknown Protocol==============\n"); -// qDebug("Unknown Protocol\n"); -// break; - } -} diff --git a/ledset/capthread - 副本.h b/ledset/capthread - 副本.h deleted file mode 100644 index 2d7f19b..0000000 --- a/ledset/capthread - 副本.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef CAPTHREAD_H -#define CAPTHREAD_H - -#include -#include -#include "pcap.h" -#include - -#pragma comment(lib, "wpcap.lib") -#pragma comment(lib, "Ws2_32.lib") - -#define LINE_LEN 16 -#define MAX_ADDR_LEN 16 - -struct EtherHeader { - u_char ether_dhost[6]; // 目标MAC地址 - u_char ether_shost[6]; // 源MAC地址 - u_short ether_type; // 以太网类型 -}; -struct IpAddress { - u_char byte1; - u_char byte2; - u_char byte3; - u_char byte4; -}; -struct IpHeader { - u_char version_hlen; // 首部长度 版本 - u_char tos; // 服务质量 - u_short tlen; // 总长度 - u_short identification; // 身份识别 - u_short flags_offset; // 标识 分组偏移 - u_char ttl; // 生命周期 - u_char proto; // 协议类型 - u_short checksum; // 包头测验码 - u_int saddr; // 源IP地址 - u_int daddr; // 目的IP地址 -}; -struct TcpHeader { - u_short sport; - u_short dport; - u_int sequence; // 序列码 - u_int ack; // 回复码 - u_char hdrLen; // 首部长度保留字 - u_char flags; // 标志 - u_short windows; // 窗口大小 - u_short checksum; // 校验和 - u_short urgent_pointer; // 紧急指针 -}; -struct UdpHeader { - u_short sport; // 源端口 - u_short dport; // 目标端口 - u_short datalen; // UDP数据长度 - u_short checksum; // 校验和 -}; -struct IcmpHeader { - u_char type; // ICMP类型 - u_char code; // 代码 - u_short checksum; // 校验和 - u_short identification; // 标识 - u_short sequence; // 序列号 - u_long timestamp; // 时间戳 -}; -struct ArpHeader { - u_short hardware_type; // 格式化的硬件地址 - u_short protocol_type; // 协议地址格式 - u_char hardware_length; // 硬件地址长度 - u_char protocol_length; // 协议地址长度 - u_short operation_code; // 操作码 - u_char source_ethernet_address[6]; // 发送者硬件地址 - u_char source_ip_address[4]; // 发送者协议地址 - u_char destination_ethernet_address[6]; // 目的方硬件地址 - u_char destination_ip_address[4]; // 目的方协议地址 -}; - -struct Packet { - QString time; - QString data; - u_int len; - EtherHeader ether_header; - IpHeader ip_header; - TcpHeader tcp_header; - UdpHeader udp_header; - IcmpHeader icmp_header; - ArpHeader arp_header; - QString protocol; -}; - -class CapThread : public QThread { - Q_OBJECT -public: - explicit CapThread(pcap *pcap, QObject *parent = nullptr); - void setPacketList(QList *p){p->clear();packet_list=p;} - pcap *pcap{0}; - QList *packet_list; - Packet packet; - -private: - void tcp_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content); - void udp_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content); - void icmp_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content); - void arp_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content); - void ip_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content); - void ethernet_protocol_packet_handle(u_char *arg, const struct pcap_pkthdr *pkt_header, const u_char *pkt_content); - -protected: - void run(); - -signals: - void newPacket(); - -public slots: -}; - -#endif // CAPTHREAD_H diff --git a/ledset/expertboxlayoutwin.cpp b/ledset/expertboxlayoutwin.cpp index 455b383..135f19f 100644 --- a/ledset/expertboxlayoutwin.cpp +++ b/ledset/expertboxlayoutwin.cpp @@ -557,6 +557,13 @@ void ModuleUnit::drawed() { auto btn = box->boxWin->grpGrp->checkedButton(); if(btn==0) return; auto mods = btn->property("mods").toList(); + if(! mods.isEmpty() && ((ExpertWin*)box->boxWin->parentWidget())->m_iRcvCardType==enum_zrf) { + auto last = (ModuleUnit*) mods.last().value(); + if(last->mY!=mY || last->mX+last->mW!=mX) { + QMessageBox::warning(this, "注意", "模组要紧跟着前一个"); + return; + } + } mods.append(QVariant::fromValue((void*)this)); btn->setProperty("mods", mods); name = "G"+QString::number(box->boxWin->grpGrp->id(btn)+1)+"-"+QString::number(mods.size()); diff --git a/ledset/expertscreenconnwin.cpp b/ledset/expertscreenconnwin.cpp index 05c9737..47486c2 100644 --- a/ledset/expertscreenconnwin.cpp +++ b/ledset/expertscreenconnwin.cpp @@ -89,7 +89,7 @@ ExpertScreenConnWin::ExpertScreenConnWin(QWidget *parent) : QSplitter{parent} { auto pal = palette(); fdNet = new QButtonGroup(gBox); - for(int i=0; isetMaximumWidth(30); bn->setMinimumHeight(30); @@ -156,7 +156,7 @@ ExpertScreenConnWin::ExpertScreenConnWin(QWidget *parent) : QSplitter{parent} { auto bnRefresh = new QPushButton(tr("重新开始")); connect(bnRefresh, &QPushButton::clicked, this, [this] { table->clearContents(); - for(int i=0; iaddWidget(bnRefresh); @@ -172,10 +172,8 @@ ExpertScreenConnWin::ExpertScreenConnWin(QWidget *parent) : QSplitter{parent} { table = new CardTable(fdCardRowNum->value(), fdCardColNum->value()); table->win = this; table->setEditTriggers(QAbstractItemView::NoEditTriggers); - table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter); table->horizontalHeader()->setDefaultSectionSize(90); table->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); - table->verticalHeader()->setDefaultAlignment(Qt::AlignCenter); table->verticalHeader()->setDefaultSectionSize(90); table->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); table->verticalHeader()->setMinimumWidth(30); @@ -195,7 +193,7 @@ void ExpertScreenConnWin::conn(int row, int column) { auto item = table->item(row, column); if(item) return; auto netIdx = fdNet->checkedId(); - netss[netIdx].append(QPoint(column, row)); + netss[netIdx].emplace_back(QPoint(column, row)); item = new QTableWidgetItem("网口: "+QString::number(netIdx+1)+"\n"+tr("接收卡: ")+QString::number(netss[netIdx].size())+"\n"+tr("宽度: ")+QString::number(fdCardWidth->value())+"\n高度: "+QString::number(fdCardHeight->value())); auto color = cardColors[netIdx % (sizeof(cardColors)/sizeof(cardColors[0]))]; item->setForeground(QColor(255,255,255)); @@ -207,9 +205,10 @@ void ExpertScreenConnWin::conn(int row, int column) { } void ExpertScreenConnWin::connBack() { auto netIdx = fdNet->checkedId(); - if(netss[netIdx].isEmpty()) return; + if(netss[netIdx].empty()) return; table->selectionModel()->clearCurrentIndex(); - auto point = netss[netIdx].takeLast(); + auto point = netss[netIdx].back(); + netss[netIdx].pop_back(); table->setItem(point.y(), point.x(), 0); table->update(); } @@ -217,7 +216,7 @@ void ExpertScreenConnWin::connBack() { void CardTable::paintEvent(QPaintEvent *event) { QTableWidget::paintEvent(event); QPainter painter(viewport()); - for(int i=0; inetss.size(); i++) { + for(int i=0; inetss)/sizeof(win->netss[0]); i++) { auto size = win->netss[i].size(); if(size < 2) continue; QColor a=cardColors[i % (sizeof(cardColors)/sizeof(cardColors[0]))]; diff --git a/ledset/expertscreenconnwin.h b/ledset/expertscreenconnwin.h index 74579ec..2ff6b0b 100644 --- a/ledset/expertscreenconnwin.h +++ b/ledset/expertscreenconnwin.h @@ -17,7 +17,7 @@ public: QSpinBox *fdCardWidth; QSpinBox *fdCardHeight; CardTable *table; - QList> netss{QList{}, QList{}, QList{}, QList{}}; + std::vector netss[4]{}; }; class CardTable : public QTableWidget { diff --git a/ledset/screenunit.cpp b/ledset/expertsendpanel.cpp similarity index 73% rename from ledset/screenunit.cpp rename to ledset/expertsendpanel.cpp index 5e6af81..1a0dcc9 100644 --- a/ledset/screenunit.cpp +++ b/ledset/expertsendpanel.cpp @@ -1,17 +1,133 @@ -#include "screenunit.h" -#include "expertwin.h" -#include -#include -#include -#include -#include -#include -#include -#include - +#include "expertsendpanel.h" +#include "gutil/qgui.h" +#include #include +#include -ScreenUnit::ScreenUnit(ExpertWin *expertWin, const QString &name, int x, int y, int w, int h, QWidget *parent) : QWidget{parent}, expertWin{expertWin}, name{name}, mX{x}, mY{y}, mW{w}, mH{h} { +QColor colors[] {QColor(0xdd0000), QColor(0xdd6600), QColor(0x008800), QColor(0x008888), QColor(0x0000ff), QColor(0x777777), QColor(0xaaaaaa)}; + +ExpertSendPanel::ExpertSendPanel(QWidget *parent) : QWidget{parent} { + auto vBox = new VBox(this); + vBox->setContentsMargins(4, 4, 4, 4); + + auto splitter = new QSplitter; + vBox->addWidget(splitter); + auto vLeft = new VBox(splitter); + + auto hBox = new HBox(vLeft); + hBox->addWidget(new QLabel("分辨率: ")); + + auto fdW = new QLineEdit(QString::number(screenWidth)); + hBox->addWidget(fdW); + + hBox->addWidget(new QLabel("X")); + + auto fdH = new QLineEdit(QString::number(screenHeight)); + hBox->addWidget(fdH); + + + hBox = new HBox(vLeft); + hBox->addStretch(); + + auto btnGet = new QPushButton("刷新"); + btnGet->setMinimumWidth(80); + hBox->addWidget(btnGet); + + hBox->addSpacing(40); + + auto btnSet = new QPushButton("设置"); + btnSet->setMinimumWidth(80); + hBox->addWidget(btnSet); + + hBox->addStretch(); + + auto table = new TreeWidget{ + {"face", "网口", 32}, + {"x", "X", 32}, + {"y", "Y", 32}, + {"w", "宽度", 32}, + {"h", "高度", 32}, + {"audio", "音频开关", QHeaderView::Stretch}, + {"backup", "备份开关", QHeaderView::Stretch} + }; + table->setDefs(); + table->setStyleSheet("TreeWidget::item{height: 24px;}"); + vLeft->addWidget(table); + + auto canvas = new ResizeEmitedWgt; + auto screen = new QWidget(canvas); + screen->setGeometry(0, 0, screenWidth, screenHeight); + screen->setAutoFillBackground(true); + auto pal = palette(); + pal.setColor(QPalette::Window, QColor(0, 0, 0)); + screen->setPalette(pal); + connect(canvas, &ResizeEmitedWgt::resized, this, [this, canvas, screen] { + rate = qMin(canvas->width()/(double)screenWidth, canvas->height()/(double)screenHeight); + if(rate==0) return; + screen->resize(qRound(screenWidth*rate), qRound(screenHeight*rate)); + auto children = screen->children(); + foreach(auto childObj, children) { + auto unit = static_cast(childObj); + unit->setGeometry(qRound(unit->mX*rate), qRound(unit->mY*rate), qRound(unit->mW*rate), qRound(unit->mH*rate)); + } + }); + splitter->addWidget(canvas); + + splitter->setStretchFactor(0,0); + splitter->setStretchFactor(1,1); + splitter->setSizes({280, 1}); + + hBox = new HBox(vBox); + auto btn = new QPushButton(tr("保存到文件")); + btn->setProperty("ss","blue"); + connect(btn, &QPushButton::clicked, this, [=] { + + }); + hBox->addWidget(btn); + + hBox->addStretch(); + + btn = new QPushButton(tr("发送发送卡参数")); + btn->setProperty("ss","blue"); + connect(btn, &QPushButton::clicked, this, [=] { + + }); + hBox->addWidget(btn); + + btn = new QPushButton(tr("固化发送卡参数")); + btn->setProperty("ss","blue"); + connect(btn, &QPushButton::clicked, this, [=] { + + }); + hBox->addWidget(btn); + + btnSendReadBack = new QPushButton(tr("回读发送卡参数")); + btnSendReadBack->setProperty("ss","blue"); + connect(btnSendReadBack, &QPushButton::clicked, this, [=] { + + }); + hBox->addWidget(btnSendReadBack); + + for(int rr=0; rr<4; rr++) { + auto item = new TreeWidgetItem(table); + QString name = "P"+QString::number(rr+1); + item->setText("face", name); + item->setText("x", QString::number(rr*128)); + item->setText("y", "0"); + item->setText("w", "128"); + item->setText("h", "128"); + item->setText("audio", "0"); + item->setText("backup", "0"); + + auto unit = new ScreenUnit(this, name, rr*128, 0, 128, 128, screen); + unit->setAutoFillBackground(true); + pal.setColor(QPalette::Window, colors[rr]); + unit->setPalette(pal); + } +} + + +ScreenUnit::ScreenUnit(ExpertSendPanel *expertWin, const QString &name, int x, int y, int w, int h, QWidget *parent) : QWidget{parent}, expertWin{expertWin}, name{name}, mX{x}, mY{y}, mW{w}, mH{h} { setGeometry(x, y, w, h); setMouseTracking(true); auto font = this->font(); @@ -77,7 +193,7 @@ void ScreenUnit::mousePressEvent(QMouseEvent *e) { foreach(auto item, items) { if(item==this) continue; auto ele = static_cast(item); - mOtherEles.append(ele); + mOtherEles.emplace_back(ele); } } } @@ -109,7 +225,7 @@ void ScreenUnit::mouseMoveEvent(QMouseEvent *e){ else if(dstHor==expertWin->screenWidth - width()) mLRSnap = 2; if(dstVer==0) mTBSnap = 1; else if(dstVer==expertWin->screenHeight - height()) mTBSnap = 2; - if(mLRSnap==0) foreach(ScreenUnit *ele, mOtherEles) {//左右 + if(mLRSnap==0) for(ScreenUnit *ele : mOtherEles) {//左右 if(abs(dstHor - ele->x()) < SnapSpace && ele->x() <= expertWin->screenWidth - width()) { dstHor = ele->x(); mLRSnap = 1; @@ -141,7 +257,7 @@ void ScreenUnit::mouseMoveEvent(QMouseEvent *e){ break; } } - if(mTBSnap==0) foreach(ScreenUnit *ele, mOtherEles) {//上下 + if(mTBSnap==0) for(ScreenUnit *ele : mOtherEles) {//上下 if(abs(dstVer-ele->y()) < SnapSpace && ele->y() <= expertWin->screenHeight - height()) { dstVer = ele->y(); mTBSnap = 1; @@ -191,7 +307,7 @@ void ScreenUnit::mouseMoveEvent(QMouseEvent *e){ if(dstHor < m_handleLen) dstHor = m_handleLen; if(expertWin->screenWidth>0 && expertWin->screenHeight>0) dstHor = qMin(dstHor, expertWin->screenWidth - x()); auto right = x() + dstHor; - if(right < expertWin->screenWidth-8) foreach(ScreenUnit *ele, mOtherEles) {//左右 + if(right < expertWin->screenWidth-8) for(ScreenUnit *ele : mOtherEles) {//左右 if(abs(right - ele->x()) < SnapSpace) { dstHor = ele->x() - x(); mLRSnap = 2; @@ -214,7 +330,7 @@ void ScreenUnit::mouseMoveEvent(QMouseEvent *e){ if(dstVer < m_handleLen) dstVer = m_handleLen; if(expertWin->screenWidth>0 && expertWin->screenHeight>0) dstVer = qMin(dstVer, expertWin->screenHeight - y()); auto btm = y() + dstVer; - if(btm < expertWin->screenHeight-8) foreach(ScreenUnit *ele, mOtherEles) {//上下 + if(btm < expertWin->screenHeight-8) for(ScreenUnit *ele : mOtherEles) {//上下 auto eleBtm = ele->y() + ele->height(); if(abs(btm - ele->y()) < SnapSpace) { dstVer = ele->y() - y(); @@ -238,7 +354,7 @@ void ScreenUnit::mouseMoveEvent(QMouseEvent *e){ if(mFrmSec==Qt::LeftSection) { dstHor = qMin(dstHor, geo.right() - m_handleLen); if(dstHor < 0) dstHor = 0; - if(dstHor > 8) foreach(ScreenUnit *ele, mOtherEles) {//左右 + if(dstHor > 8) for(ScreenUnit *ele : mOtherEles) {//左右 if(abs(dstHor - ele->x()) < SnapSpace) { dstHor = ele->x(); mLRSnap = 1; @@ -259,7 +375,7 @@ void ScreenUnit::mouseMoveEvent(QMouseEvent *e){ } else if(mFrmSec==Qt::TopSection) { dstVer = qMin(dstVer, geo.bottom() - m_handleLen); if(dstVer < 0) dstVer = 0; - if(dstVer > 8) foreach(ScreenUnit *ele, mOtherEles) {//上下 + if(dstVer > 8) for(ScreenUnit *ele : mOtherEles) {//上下 if(abs(dstVer - ele->y()) < SnapSpace) { dstVer = ele->y(); mTBSnap = 1; diff --git a/ledset/expertsendpanel.h b/ledset/expertsendpanel.h new file mode 100644 index 0000000..46ce429 --- /dev/null +++ b/ledset/expertsendpanel.h @@ -0,0 +1,56 @@ +#ifndef EXPERTSENDPANEL_H +#define EXPERTSENDPANEL_H + +#include +#include + +class ExpertSendPanel : public QWidget { + Q_OBJECT +public: + explicit ExpertSendPanel(QWidget *parent = nullptr); + + int screenWidth{1280}, screenHeight{720}; + double rate{1}; + QPushButton *btnSendReadBack; +}; + +class ResizeEmitedWgt : public QWidget { + Q_OBJECT +public: + using QWidget::QWidget; +protected: + void resizeEvent(QResizeEvent *) override {emit resized();} +signals: + void resized(); +}; + +#define m_handleLen 10 + +class ScreenUnit : public QWidget { + Q_OBJECT +public: + explicit ScreenUnit(ExpertSendPanel *, const QString &name, int x, int y, int w, int h, QWidget *parent = nullptr); + + ExpertSendPanel *expertWin{0}; + QString name; + int mX, mY, mW, mH; +protected: + void paintEvent(QPaintEvent *) override; + void mousePressEvent(QMouseEvent *) override; + void mouseReleaseEvent(QMouseEvent *) override; + void mouseMoveEvent(QMouseEvent *) override; + void leaveEvent(QEvent *) override; + + void setFrmSec(const QPoint &); + void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor); + void clearSnap(); + QPen mSidePen{Qt::white}; + + QPoint mPressRel{INT_MIN, INT_MIN}; + Qt::WindowFrameSection mFrmSec{Qt::NoSection}; + char mLRSnap{0}, mTBSnap{0}; + std::vector mOtherEles; + +}; + +#endif // EXPERTSENDPANEL_H diff --git a/ledset/expertsmartpointsetwin.cpp b/ledset/expertsmartpointsetwin.cpp index 9f98b39..a202146 100644 --- a/ledset/expertsmartpointsetwin.cpp +++ b/ledset/expertsmartpointsetwin.cpp @@ -698,7 +698,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e table->clearContents(); tableRow->setColumnCount(0); virtualCnt = 0; - scans.clear(); + rows.clear(); }); hhh->addWidget(btnReset); @@ -713,32 +713,28 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e table = new Table; table->setEditTriggers(Table::NoEditTriggers); table->setSelectionMode(QTableWidget::SingleSelection); - table->setColWidth(35)->setRowHeight(24, QHeaderView::Fixed); - table->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter); - table->verticalHeader()->setMinimumWidth(35); - table->verticalHeader()->setDefaultAlignment(Qt::AlignCenter); + table->setColWidth(32)->setRowHeight(24)->setRowResize(QHeaderView::Fixed); connect(table, &QTableWidget::currentCellChanged, this, [=](int row, int col) { if(row < 0) return; auto text = table->text(row, col); if(! text.isEmpty()) return; - if(scans.isEmpty()) { + if(rows.empty()) { auto cnt = tableRow->columnCount() + 1; tableRow->setColumnCount(cnt); tableRow->setText(0, cnt-1, QString::number(cnt))->setTextAlignment(Qt::AlignCenter); - tableRow->setText(1, cnt-1, "√")->setTextAlignment(Qt::AlignCenter); - tableRow->setData(1, cnt-1, QPoint{col, row}); + tableRow->setText(1, cnt-1, "√", QPoint{col, row})->setTextAlignment(Qt::AlignCenter); auto realCnt = cnt - virtualCnt; table->setText(row, col, QString::number(realCnt))->setTextAlignment(Qt::AlignCenter); - if(realCnt!=ModuleWidth) { + if(realCnt < ModuleWidth*RowPerScan) { if(send(0x11, {0x01400000u | cnt}) == 0) qDebug()<<"resp back. col:"<data(1, 1).toPoint()); send(0x11, {0x01400000u | (1<<10)}); } - } else if(scans.size() < ScanNum) { - scans.append({col, row}); - auto size = scans.size(); + } else if((int)rows.size() < ScanNum) { + rows.emplace_back(QPoint{col, row}); + auto size = rows.size(); table->setText(row, col, "S"+QString::number(size))->setTextAlignment(Qt::AlignCenter); if(size!=ScanNum) { if(send(0x11, {0x01400000u | (size<<10)}) == 0) qDebug()<<"resp back. row:"<setEditTriggers(Table::NoEditTriggers); tableRow->setSelectionMode(QTableWidget::NoSelection); - tableRow->setColWidth(35); - tableRow->setRowHeight(24); + tableRow->setColWidth(32)->setRowHeight(24)->setRowResize(QHeaderView::Fixed); tableRow->horizontalHeader()->setVisible(false); - tableRow->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); tableRow->verticalHeader()->setMinimumWidth(120); tableRow->setMaximumHeight(50); tableRow->setVHeaderText(0, tr("第一扫灯数:")); @@ -789,7 +783,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e ModuleWidth = fdModuleWidth->value(); ModuleHeight = fdModuleHeight->value(); GroupNum = fdGroupNum->value(); - ScanNum = (ModuleHeight + 1) / GroupNum; + ScanNum = (ModuleHeight + GroupNum - 1) / GroupNum; ChipType = fdChipType->text(); DecodeMode = fdDecodeMode->text(); GroupMode = fdGroupMode->currentText(); @@ -813,7 +807,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e auto groupNum = unitptr+modUnitMap.smartsetRes + 1; *groupNum = GroupNum; auto scanNum = unitptr+modUnitMap.smartsetRes + 3; - *scanNum = ModuleHeight / GroupNum; + *scanNum = ScanNum; auto 走点len = (quint32_be*)(unitptr+modUnitMap.走点len); *走点len = (ModuleWidth+15) / 16 * 16; auto check = (quint32_be*)(msg.data()+headMap.end+modMap.check); @@ -839,9 +833,10 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(ExpertWin *expertWin) : BaseWin{e if(send(0x11, {0x01300000u, res12})) return; } else if(idx==3) { RowPerScan = fdLightNum->value(); + ScanNum = (ScanNum + RowPerScan - 1) / RowPerScan; res12 &= ~0xffffu; res12 |= (uint)(RowPerScan - 1)<<8; //折返次数 - res12 |= (uint)(ModuleHeight / (RowPerScan*GroupNum)); //扫描类型 + res12 |= (uint)ScanNum; //扫描类型 if(send(0x11, {0x01200000u | fdRGBStat->checkedId(), res12, ((uint)ModuleWidth+15) / 16 * 16 * RowPerScan})) return; } else if(idx==4) { bool hases[4]{true,true,true,true}; @@ -886,9 +881,9 @@ int ExpertSmartPointSetWin::send(uint ptr, const std::initializer_list &da auto msg = QByteArray::fromHex("5555 01AD 0000 FFFFFFFF 0000ABCD B1000000 0000 00000000 AD000000 0000"); msg.append((data.size()+1)<<2, 0); auto plen = (quint16_be*)(msg.data()+headMap.len); - *plen |= (data.size()<<2)+6; + *plen |= (quint16) (data.size()<<2)+6; plen = (quint16_be*)(msg.data()+headMap.bodylen); - *plen |= data.size()<<2; + *plen |= (quint16) data.size()<<2; auto pptr = (quint32_be*)(msg.data()+headMap.ptr); *pptr |= ptr; pptr = (quint32_be*)(msg.data()+headMap.body); @@ -922,28 +917,49 @@ void ExpertSmartPointSetWin::save() { obj.insert("ModuleWidth", ModuleWidth); obj.insert("ModuleHeight", ModuleHeight); obj.insert("GroupNum", GroupNum); - obj.insert("ScanNum", ScanNum); obj.insert("ChipType", ChipType); obj.insert("DecodeMode", DecodeMode); obj.insert("GroupMode", GroupMode); + obj.insert("ReverseGroup", ReverseGroup); obj.insert("DataPolarity", DataPolarity); obj.insert("OePolarity", OePolarity); + obj.insert("ScanNum", ScanNum); obj.insert("ColorMap", ColorMap); obj.insert("RowPerScan", RowPerScan); - JArray points; + JArray RowMap; + for(QPoint row : rows) RowMap.append(row.y()); + obj.insert("RowMap", RowMap); + JArray ColumnMap; auto cnt = tableRow->columnCount(); - if(cnt > ModuleWidth) { - auto add = (cnt+ModuleWidth-1) / ModuleWidth * ModuleWidth - cnt; - for(int i=0; i ModuleWidth*RowPerScan) { + auto add = cnt % ModuleWidth; + if(add) add = ModuleWidth - add; + for(int i=0; i=0; i--) { auto data = tableRow->data(1, i); - points.append(data.isValid() ? data.toPoint().x() : -1); + int col = -1; + if(data.isValid()) { + col = data.toPoint().x(); + cols[col]++; + col += (RowPerScan-cols[col])*ModuleWidth; + } + ColumnMap.append(col); } - obj.insert("Points", points); - JArray Scans; - for(QPoint scan : scans) Scans.append(scan.y()); - obj.insert("Scans", Scans); + delete [] cols; + JArray pos_item_info; + for(int i=cnt-1; i>=0; i--) { + auto data = tableRow->data(1, i); + auto pos = data.isValid() ? data.toPoint() : QPoint{-1, -1}; + pos_item_info.append(JObj{ + {"col", pos_item_info.size()}, + {"x", pos.x()}, + {"y", pos.y()} + }); + } + obj.insert("ColumnMap", ColumnMap); + obj.insert("pos_item_info", pos_item_info); auto data = JToBytes(obj, " "); auto res = qFile.write(data); qFile.close(); diff --git a/ledset/expertsmartpointsetwin.h b/ledset/expertsmartpointsetwin.h index 7ce5ccd..021e009 100644 --- a/ledset/expertsmartpointsetwin.h +++ b/ledset/expertsmartpointsetwin.h @@ -20,7 +20,7 @@ public: Table *table, *tableRow; int virtualCnt = 0; - QList scans; + std::vector rows; QRadioButton *fdRow, *fdCol; QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGroupNum; @@ -29,7 +29,7 @@ public: QComboBox *fdGroupMode; int ModuleWidth{32}, ModuleHeight{16}, GroupNum{2}, ScanNum{4}; int ChipTypeCode, DecodeModeCode; - bool DataPolarity{true}, OePolarity{false}; + bool ReverseGroup = false, DataPolarity = true, OePolarity = false; int ColorMap; QString ChipType, DecodeMode, GroupMode; diff --git a/ledset/expertwin.cpp b/ledset/expertwin.cpp index d34e9ad..b213d4b 100644 --- a/ledset/expertwin.cpp +++ b/ledset/expertwin.cpp @@ -1,8 +1,8 @@ #include "expertwin.h" #include "gutil/qgui.h" -#include "screenunit.h" #include "expertboxlayoutwin.h" #include "expertsmartpointsetwin.h" +#include "expertsendpanel.h" #include "expertscreenconnwin.h" #include "globalfunc.h" #include @@ -14,27 +14,47 @@ #include #include #include -#include -#include #include #include #include +#include "efffrefr.h" +#include "globalfunc.h" -auto zrf_param_msg = QByteArray::fromHex( "00 00 06 20 10 10 00 E4 06 FF FF FF FF 00 00 80 80 80 00 00 00 1F 00 00 00 3C 01 33 00 00 00 80 00 00 12 05 00 00 00 01 02 " - "03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 01 00 00 00 00 10 00 00 20 00 00 30 " - "00 00 40 00 00 50 00 00 60 00 00 70 00 00 80 00 00 90 00 00 A0 00 00 B0 00 00 C0 00 00 D0 00 00 F0 00 00 00 01 00 10 01 00 " - "20 01 00 30 01 00 40 01 00 50 01 00 60 01 00 70 01 00 80 01 00 90 01 00 A0 01 00 B0 01 00 C0 01 00 D0 01 00 F0 01 00 00 02 " - "00 10 02 05 00 1F F8 7F 01 40 07 1F F8 73 01 40 07 1F F8 5F 01 40 07 40 10 40 10 40 10 00 00 00 00 00 00 00 00 00 00 00 00 " - "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " - "00 00 00 00 00 00 00 00 00 00 ");//297 +auto zrf_param_msg = QByteArray::fromHex( "20 00 06 20 10 10 00 E4 06 FF FF FF FF 00 00 80 80 80 00 00 00 1F 00 00 00 3C 01 33 00 00 00 80 00 00 12 05 00 00 00 01 " + "02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 01 00 00 00 00 10 00 00 20 00 " + "00 30 00 00 40 00 00 50 00 00 60 00 00 70 00 00 80 00 00 90 00 00 A0 00 00 B0 00 00 C0 00 00 D0 00 00 F0 00 00 00 01 00 " + "10 01 00 20 01 00 30 01 00 40 01 00 50 01 00 60 01 00 70 01 00 80 01 00 90 01 00 A0 01 00 B0 01 00 C0 01 00 D0 01 00 F0 " + "01 00 00 02 00 10 02 05 00 1F F8 7F 01 40 07 1F F8 73 01 40 07 1F F8 5F 01 40 07 40 10 40 10 40 10 00 00 00 00 00 00 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");//256个 //modified by alahover -o 20230823 -QColor colors[] {QColor(0xdd0000), QColor(0xdd6600), QColor(0x008800), QColor(0x008888), QColor(0x0000ff), QColor(0x777777), QColor(0xaaaaaa)}; ExpertWin::ExpertWin(QWidget *parent, int rcvCardType) : BaseWin{parent}, m_iRcvCardType{rcvCardType} { setAttribute(Qt::WA_DeleteOnClose); setWindowTitle("专家调屏"); resize(900, 720); - +qDebug()<<"rcvCardType"<setContentsMargins(0,0,0,0); vBox->setSpacing(3); @@ -48,94 +68,8 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou )rrr"); vBox->addWidget(tab); - auto splitter = new QSplitter; - tab->addTab(splitter, "发送设备"); - { - auto vLeft = new VBox(splitter); - - auto hBox = new HBox(vLeft); - hBox->addWidget(new QLabel("分辨率: ")); - - auto fdW = new QLineEdit(QString::number(screenWidth)); - hBox->addWidget(fdW); - - hBox->addWidget(new QLabel("X")); - - auto fdH = new QLineEdit(QString::number(screenHeight)); - hBox->addWidget(fdH); - - - hBox = new HBox(vLeft); - hBox->addStretch(); - - auto btnGet = new QPushButton("刷新"); - btnGet->setMinimumWidth(80); - hBox->addWidget(btnGet); - - hBox->addSpacing(40); - - auto btnSet = new QPushButton("设置"); - btnSet->setMinimumWidth(80); - hBox->addWidget(btnSet); - - hBox->addStretch(); - - auto table = new Table{ - {"face", "网口", 40}, - {"x", "X", 0, QHeaderView::Stretch}, - {"y", "Y", 0, QHeaderView::Stretch}, - {"w", "宽度", 0, QHeaderView::Stretch}, - {"h", "高度", 0, QHeaderView::Stretch}, - {"audio", "音频开关", 0, QHeaderView::Stretch}, - {"backup", "备份开关", 0, QHeaderView::Stretch} - }; - table->verticalHeader()->setMinimumWidth(20);//added by alahover 20230822 - table->setDefs(); - vLeft->addWidget(table); - table->setRowCount(4); - - auto canvas = new ResizeEmitedWgt; - auto screen = new QWidget(canvas); - screen->setGeometry(0, 0, screenWidth, screenHeight); - screen->setAutoFillBackground(true); - auto pal = palette(); - pal.setColor(QPalette::Window, QColor(0, 0, 0)); - screen->setPalette(pal); - connect(canvas, &ResizeEmitedWgt::resized, this, [this, canvas, screen] { - rate = qMin(canvas->width()/(double)screenWidth, canvas->height()/(double)screenHeight); - if(rate==0) return; - screen->resize(qRound(screenWidth*rate), qRound(screenHeight*rate)); - auto children = screen->children(); - foreach(auto childObj, children) { - auto unit = static_cast(childObj); - unit->setGeometry(qRound(unit->mX*rate), qRound(unit->mY*rate), qRound(unit->mW*rate), qRound(unit->mH*rate)); - } - }); - splitter->addWidget(canvas); - - splitter->setStretchFactor(0,0); - splitter->setStretchFactor(1,1); - splitter->setSizes({320, 1}); - - - int idx = 0; - for(int rr=0; rr<4; rr++) { - QString name = "P"+QString::number(rr+1); - table->setText(rr, "name", name); - table->setText(rr, "x", QString::number(idx)); - table->setText(rr, "y", "0"); - table->setText(rr, "w", "128"); - table->setText(rr, "h", "128"); - table->setText(rr, "audio", "0"); - table->setText(rr, "backup", "0"); - - auto unit = new ScreenUnit(this, name, idx, 0, 128, 128, screen); - unit->setAutoFillBackground(true); - pal.setColor(QPalette::Window, colors[rr]); - unit->setPalette(pal); - idx += 128; - } - } + auto sendPanel = new ExpertSendPanel; + tab->addTab(sendPanel, "发送设备"); { auto file = QApplication::applicationDirPath()+"/temp.screen"; QFile qFile(file); @@ -164,6 +98,7 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou tab->addTab(receivePanel, "接收卡"); { auto vBox = new VBox(receivePanel); + vBox->setContentsMargins(4, 4, 4, 4); auto gBox = new QGroupBox("模组信息"); vBox->addWidget(gBox); { @@ -230,6 +165,14 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou btn->setStyleSheet("QPushButton {border: none; }"); vvv->addWidget(btn); + vvv = new VBox(hh); + + fdDataGroupColor = new QLabel("红,绿,蓝"); + vvv->addWidget(fdDataGroupColor); + + fdChouDian = new QLabel(""); + vvv->addWidget(fdChouDian); + hh->addStretch(); vvv = new VBox(hh); @@ -312,20 +255,20 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou fdSectorCount = new QComboBox; fdSectorCount->addItem(tr("无"), 1); - fdSectorCount->addItem(tr("双开"), 2); - fdSectorCount->addItem(tr("三开"), 3); - fdSectorCount->addItem(tr("四开"), 4); - fdSectorCount->addItem(tr("五开"), 5); - fdSectorCount->addItem(tr("六开"), 6); - fdSectorCount->addItem(tr("七开"), 7); - fdSectorCount->addItem(tr("八开"), 8); + fdSectorCount->addItem(tr("2开"), 2); + fdSectorCount->addItem(tr("3开"), 3); + fdSectorCount->addItem(tr("4开"), 4); + fdSectorCount->addItem(tr("5开"), 5); + fdSectorCount->addItem(tr("6开"), 6); + fdSectorCount->addItem(tr("8开"), 7); + fdSectorCount->addItem(tr("12开"), 7); SetCurData(fdSectorCount, mBox["SectorCount"].toInt()); vvv->addWidget(fdSectorCount); - fdDirection = new QComboBox(); - fdDirection->addItem(tr("从左到右")); + fdDirection = new QComboBox; fdDirection->addItem(tr("从右到左")); fdDirection->addItem(tr("从上到下")); + fdDirection->addItem(tr("从左到右")); fdDirection->addItem(tr("从下到上")); fdDirection->setCurrentIndex(mBox["ModuleDirection"].toInt()); vvv->addWidget(fdDirection); @@ -367,131 +310,293 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou } gBox = new QGroupBox(tr("效果测试")); + //modified by alahover -s 20230830 vBox->addWidget(gBox); { - auto hh = new HBox(gBox); - hh->addSpacing(20); + if(m_iRcvCardType == enum_zrf) { + auto vBox1=new VBox(gBox); + auto hh = new HBox(vBox1); + hh->addSpacing(20); + //第一列区域 + auto vvv = new VBox(hh); + //1.1.移位时钟频率 + auto hhh = new HBox(vvv); + auto lb = new QLabel(tr("DCLK频率:")); + hhh->addWidget(lb); + cbDCLKf = new QComboBox(); cbDCLKf->addItem("31.2M");cbDCLKf->addItem("25M");cbDCLKf->addItem("20.83M");cbDCLKf->addItem("17.86M");cbDCLKf->addItem("15.63M");cbDCLKf->addItem("12.5M");cbDCLKf->addItem("10.42M");cbDCLKf->addItem("8.9M"); + cbDCLKf->addItem("7.8M");cbDCLKf->addItem("6.25M");;cbDCLKf->addItem("5.2M");;cbDCLKf->addItem("4.5M");;cbDCLKf->addItem("3.9M");;cbDCLKf->addItem("3.125M"); ;cbDCLKf->addItem("1.9M"); ;cbDCLKf->addItem("1M"); hhh->addWidget(cbDCLKf); + //1.2.灰度级别 + hhh = new HBox(vvv); + lb = new QLabel(tr("灰度级数:")); hhh->addWidget(lb); + cbGryLevel = new QComboBox(); cbGryLevel->addItem("无灰度"); cbGryLevel->addItem("无OE8级");cbGryLevel->addItem("无OE16级");cbGryLevel->addItem("无OE32级");cbGryLevel->addItem("无OE64级");cbGryLevel->addItem("正常16级"); cbGryLevel->addItem("高亮16级");cbGryLevel->addItem("正常32级"); + cbGryLevel->addItem("高亮32级");cbGryLevel->addItem("正常64级");cbGryLevel->addItem("高亮64级");cbGryLevel->addItem("正常128级");cbGryLevel->addItem("高亮128级");cbGryLevel->addItem("正常256级");cbGryLevel->addItem("高亮256级");cbGryLevel->addItem("正常512级"); + cbGryLevel->addItem("高亮512级");cbGryLevel->addItem("正常1024级");cbGryLevel->addItem("高亮1024级");cbGryLevel->addItem("低亮2048级");cbGryLevel->addItem("正常2048级");cbGryLevel->addItem("高亮2048级");cbGryLevel->addItem("低亮4096级");cbGryLevel->addItem("正常4096级"); + cbGryLevel->addItem("高亮4096级");cbGryLevel->addItem("低亮8192级");cbGryLevel->addItem("正常8192级");cbGryLevel->addItem("高亮8192级");cbGryLevel->addItem("低亮16384级");cbGryLevel->addItem("正常16384");cbGryLevel->addItem("正常32768级");cbGryLevel->addItem("正常65535级"); hhh->addWidget(cbGryLevel); + //1.3.刷新倍率 + hhh = new HBox(vvv); + lb = new QLabel(tr("刷新倍率:")); hhh->addWidget(lb); + freshBeiLv = new QComboBox(); freshBeiLv->addItem("20");freshBeiLv->addItem("24");freshBeiLv->addItem("28");freshBeiLv->addItem("32");freshBeiLv->addItem("36");freshBeiLv->addItem("40");freshBeiLv->addItem("44");freshBeiLv->addItem("48");freshBeiLv->addItem("64M"); hhh->addWidget(freshBeiLv); + //1.4.换行时间 + hhh = new HBox(vvv); + lb = new QLabel(tr("换行时间(ns):")); hhh->addWidget(lb); + spinLineNs = new QSpinBox; spinLineNs->setRange(2, 9999); hhh->addWidget(spinLineNs); + //1.5.换行位置 + hhh = new HBox(vvv); + lb = new QLabel(tr("换行位置(ns):")); hhh->addWidget(lb); + spinLineWz = new QSpinBox; spinLineWz->setRange(2, 9999); hhh->addWidget(spinLineWz); + //1.6.行消隐时间 + hhh = new HBox(vvv); + lb = new QLabel(tr("行消隐时间(ns):")); hhh->addWidget(lb); + spinLineXy = new QSpinBox; spinLineWz->setRange(2, 9999); hhh->addWidget(spinLineXy); - auto vvv = new VBox(hh); - auto hhh = new HBox(vvv); - auto lb = new QLabel(tr("视觉刷新率:")); - hhh->addWidget(lb); + //第二列区域 + hh->addSpacing(20); + vvv = new VBox(hh); + //2.1.无信号数据 + hhh = new HBox(vvv); + lb = new QLabel(tr("无信号数据:")); hhh->addWidget(lb); + cbNoSign = new QComboBox(); + cbNoSign->addItem("最后一帧画面"); + cbNoSign->addItem("黑屏"); + hhh->addWidget(cbNoSign); + //2.2.显卡同步 + hhh = new HBox(vvv); + lb = new QLabel(tr("显卡同步")); hhh->addWidget(lb); + checkSyncXianKa = new QCheckBox; checkSyncXianKa->setChecked(true); hhh->addWidget(checkSyncXianKa); + //2.3.开屏渐亮 + hhh = new HBox(vvv); + lb = new QLabel(tr("双卡备份")); hhh->addWidget(lb); + checkDoubleCopy = new QCheckBox; checkDoubleCopy->setChecked(false); hhh->addWidget(checkDoubleCopy); + //2.4.开屏渐亮 + hhh = new HBox(vvv); + lb = new QLabel(tr("开屏渐亮")); hhh->addWidget(lb); + checkJianLiang = new QCheckBox; checkSyncXianKa->setChecked(false); hhh->addWidget(checkJianLiang); + //2.5.D信号为第二组时钟 + hhh = new HBox(vvv); + lb = new QLabel(tr("信号为第二组时钟")); hhh->addWidget(lb); + checkDsignalAsCLk = new QCheckBox; checkDsignalAsCLk->setChecked(false); hhh->addWidget(checkDsignalAsCLk); - auto cbFresh = new QComboBox(); - cbFresh->addItem("960"); - cbFresh->addItem("1920"); - cbFresh->addItem("2880"); - cbFresh->addItem("3840"); - hhh->addWidget(cbFresh); + //更多设置 + hh->addStretch(); + vvv = new VBox(hh); + vvv->addStretch(); + hhh = new HBox(vvv); + auto btn = new QPushButton(tr("更多设置")); + btn->setProperty("ss","blue"); + hhh->addWidget(btn); + btn = new QPushButton(tr("亮度设置")); + btn->setProperty("ss","blue"); + vvv->addWidget(btn); + btn = new QPushButton(tr("Gamma设置")); + btn->setProperty("ss","blue"); + vvv->addWidget(btn); + btn = new QPushButton(tr("电流增益设置")); + btn->setProperty("ss","blue"); + vvv->addWidget(btn); - hhh = new HBox(vvv); - lb = new QLabel(tr("DCLK频率:")); - hhh->addWidget(lb); - auto cbDCLKf = new QComboBox(); - cbDCLKf->addItem("25M"); - cbDCLKf->addItem("20.83M"); - cbDCLKf->addItem("17.86M"); - cbDCLKf->addItem("15.63M"); - cbDCLKf->addItem("13.89M"); - cbDCLKf->addItem("12.5M"); - cbDCLKf->addItem("11.36M"); - cbDCLKf->addItem("10.42M"); - cbDCLKf->addItem("9.62M"); - hhh->addWidget(cbDCLKf); - hhh = new HBox(vvv); - lb = new QLabel(tr("DCLK相位:")); - hhh->addWidget(lb); - auto spinDclkXw = new QSpinBox; - spinDclkXw->setRange(0, 99999); - hhh->addWidget(spinDclkXw); + vvv->addStretch(); + hh->addStretch(); - hhh = new HBox(vvv); - lb = new QLabel(tr("DCLK占空比:")); - hhh->addWidget(lb); - auto spinDclkZkb = new QSpinBox; - spinDclkZkb->setRange(20, 80); - hhh->addWidget(spinDclkZkb); + vvv = new VBox(hh); + //分割线 + auto hh3 = new HBox(vvv); + QFrame * line2 = new QFrame(); + line2->setFrameShape(QFrame::VLine); + line2->setFrameShadow(QFrame::Sunken); + line2->setStyleSheet("background-color:#222;"); + hh3->addWidget(line2); - hhh = new HBox(vvv); - lb = new QLabel(tr("换行时间(ns):")); - hhh->addWidget(lb); - auto spinLineNs = new QSpinBox; - spinLineNs->setRange(2, 9999); - hhh->addWidget(spinLineNs); + //第三列区域 + vvv = new VBox(hh); + //3.1.DCLK相位 + hhh = new HBox(vvv); + lb = new QLabel(tr("DCLK相位:")); hhh->addWidget(lb); + cbDclkXw = new QComboBox(); cbDclkXw->addItem("0度");cbDclkXw->addItem("+90度");cbDclkXw->addItem("-90度"); hhh->addWidget(cbDclkXw); + //3.2.DCLK占空比 + hhh = new HBox(vvv); + lb = new QLabel(tr("DCLK占空比:")); hhh->addWidget(lb); + cbDclkZkb = new QComboBox(); cbDclkZkb->addItem("50%");cbDclkZkb->addItem("25%");cbDclkZkb->addItem("75%"); hhh->addWidget(cbDclkZkb); + //3.3.锁存STB相位微调 + hhh = new HBox(vvv); + lb = new QLabel(tr("锁存STB相位微调:")); hhh->addWidget(lb); + cbStb = new QComboBox(); cbStb->addItem("不调整");cbStb->addItem("前移1个时钟");cbStb->addItem("前移2个时钟");cbStb->addItem("前移3个时钟");cbStb->addItem("后移1个时钟");cbStb->addItem("后移2个时钟");cbStb->addItem("后移3个时钟"); hhh->addWidget(cbStb); + //3.4.行信号DE相位微调 + hhh = new HBox(vvv); + lb = new QLabel(tr("行信号DE相位微调:")); hhh->addWidget(lb); + cbDE = new QComboBox(); cbDE->addItem("不调整");cbDE->addItem("前移1个时钟");cbDE->addItem("前移2个时钟");cbDE->addItem("前移3个时钟");cbDE->addItem("后移1个时钟");cbDE->addItem("后移2个时钟");cbDE->addItem("后移3个时钟"); hhh->addWidget(cbDE); + //3.5.行信号ABC相位微调 + hhh = new HBox(vvv); + lb = new QLabel(tr("行信号ABC相位微调:")); hhh->addWidget(lb); + cbABC = new QComboBox(); cbABC->addItem("不调整");cbABC->addItem("前移1个时钟");cbABC->addItem("前移2个时钟");cbABC->addItem("前移3个时钟");cbABC->addItem("后移1个时钟");cbABC->addItem("后移2个时钟");cbABC->addItem("后移3个时钟"); hhh->addWidget(cbABC); + //3.6.单口带载点数 + hhh = new HBox(vvv); + lb = new QLabel(tr("单口带载点数:")); hhh->addWidget(lb); + spinPointsOnePort = new QSpinBox; spinPointsOnePort->setRange(1, 999); hhh->addWidget(spinPointsOnePort); + hh->addSpacing(20); + //第四列区域 + vvv = new VBox(hh); + //4.1.消隐电平 + hhh = new HBox(vvv); + lb = new QLabel(tr("消隐电平:")); hhh->addWidget(lb); + cbXiaoYinDianPing= new QComboBox(); cbXiaoYinDianPing->addItem("高有效");cbXiaoYinDianPing->addItem("低有效"); hhh->addWidget(cbXiaoYinDianPing); + //4.2.锁存信号 + hhh = new HBox(vvv); + lb = new QLabel(tr("锁存信号:")); hhh->addWidget(lb); + cbSTB = new QComboBox(); cbSTB->addItem("正向");cbSTB->addItem("反向"); hhh->addWidget(cbSTB); + //4.3.行输出 + hhh = new HBox(vvv); + lb = new QLabel(tr("行输出:")); hhh->addWidget(lb); + cbSRowOut = new QComboBox(); cbSRowOut->addItem("低有效");cbSRowOut->addItem("高有效"); hhh->addWidget(cbSRowOut); + //4.4.GCLK频率 + hhh = new HBox(vvv); + lb = new QLabel(tr("GCLK频率:")); + hhh->addWidget(lb); + cbGCLKf = new QComboBox(); + cbGCLKf->addItem("25M");cbGCLKf->addItem("20.83M");cbGCLKf->addItem("17.86M");cbGCLKf->addItem("15.63M");cbGCLKf->addItem("13.89M");cbGCLKf->addItem("12.5M");cbGCLKf->addItem("11.36M");cbGCLKf->addItem("10.42M");cbGCLKf->addItem("9.62M"); + hhh->addWidget(cbGCLKf); + //4.5.GCLK相位 + hhh = new HBox(vvv); + lb = new QLabel(tr("GCLK相位:")); hhh->addWidget(lb); + spinGclkXw = new QSpinBox; spinGclkXw->setRange(20, 80); hhh->addWidget(spinGclkXw); + //4.6.GCLK占空比 + hhh = new HBox(vvv); + lb = new QLabel(tr("GCLK占空比:")); hhh->addWidget(lb); + spinGclkZkb = new QSpinBox; spinGclkZkb->setRange(20, 80); hhh->addWidget(spinGclkZkb); - hh->addSpacing(20); - vvv = new VBox(hh); - hhh = new HBox(vvv); - lb = new QLabel(tr("亮度有效率:")); - hhh->addWidget(lb); - lb = new QLabel(tr("100%")); - hhh->addWidget(lb); + //分割线 + auto hh1 = new HBox(vBox1); + QFrame * line = new QFrame(); + line->setFrameShape(QFrame::HLine); + line->setFrameShadow(QFrame::Sunken); + line->setStyleSheet("background-color:#222;"); + hh1->addWidget(line); - hhh = new HBox(vvv); - lb = new QLabel(tr("GCLK频率:")); - hhh->addWidget(lb); - auto cbGCLKf = new QComboBox(); - cbGCLKf->addItem("25M"); - cbGCLKf->addItem("20.83M"); - cbGCLKf->addItem("17.86M"); - cbGCLKf->addItem("15.63M"); - cbGCLKf->addItem("13.89M"); - cbGCLKf->addItem("12.5M"); - cbGCLKf->addItem("11.36M"); - cbGCLKf->addItem("10.42M"); - cbGCLKf->addItem("9.62M"); - hhh->addWidget(cbGCLKf); + auto hh2=new HBox(vBox1); + //计算结果竖直信息区 + auto resultInfo = new HBox(hh2); + lb = new QLabel(tr("视觉刷新率:")); resultInfo->addWidget(lb); + float freshLv1=Get_Frefr(7/*小数权值*/ , 12/*灰度位宽*/ , 12500000/*移位时钟频率*/ , 240/*扫描长度*/ , 16/*扫描类型*/ , 4/*倍频*/ ); m_ctrlFreshRate = new QLabel(QString::number(freshLv1)); resultInfo->addWidget(m_ctrlFreshRate); + resultInfo->addStretch(); + lb = new QLabel(tr("亮度有效率:")); resultInfo->addWidget(lb); + float BrightYouXiaoLv1=Get_Eff(8,16); m_ctrlBrightEff = new QLabel(QString::number(BrightYouXiaoLv1)); resultInfo->addWidget(m_ctrlBrightEff); + resultInfo->addStretch(); + lb = new QLabel(tr("最小OE:")); resultInfo->addWidget(lb); + float minOe=Get_Eff(8,16); m_ctrlMinOE = new QLabel(QString::number(minOe)); resultInfo->addWidget(m_ctrlMinOE); + resultInfo->addStretch(); + } + else if(m_iRcvCardType == enum_xixun_sync) + { + auto hh = new HBox(gBox); + hh->addSpacing(20); - hhh = new HBox(vvv); - lb = new QLabel(tr("灰度级数:")); - hhh->addWidget(lb); - auto cbGryLevel = new QComboBox(); - cbGryLevel->addItem("256"); - cbGryLevel->addItem("1024"); - cbGryLevel->addItem("4096"); - cbGryLevel->addItem("8192"); - cbGryLevel->addItem("16384"); - cbGryLevel->addItem("32768"); - cbGryLevel->addItem("65536"); - hhh->addWidget(cbGryLevel); + auto vvv = new VBox(hh); - hhh = new HBox(vvv); - lb = new QLabel(tr("GCLK占空比:")); - hhh->addWidget(lb); - auto spinGclkZkb = new QSpinBox; - spinGclkZkb->setRange(20, 80); - hhh->addWidget(spinGclkZkb); + auto hhh = new HBox(vvv); + auto lb = new QLabel(tr("DCLK频率:")); + hhh->addWidget(lb); + auto cbDCLKf = new QComboBox(); + cbDCLKf->addItem("31.2M");cbDCLKf->addItem("25M");cbDCLKf->addItem("20.83M");cbDCLKf->addItem("17.86M");cbDCLKf->addItem("15.63M");cbDCLKf->addItem("13.89M");cbDCLKf->addItem("12.5M"); + cbDCLKf->addItem("11.36M");cbDCLKf->addItem("10.42M");cbDCLKf->addItem("9.62M");cbDCLKf->addItem("8.9M");cbDCLKf->addItem("7.8M");cbDCLKf->addItem("6.25M"); + hhh->addWidget(cbDCLKf); - hhh = new HBox(vvv); - lb = new QLabel(tr("换行位置(ns):")); - hhh->addWidget(lb); - auto spinLineWz = new QSpinBox; - spinLineWz->setRange(2, 9999); - hhh->addWidget(spinLineWz); + hhh = new HBox(vvv); + lb = new QLabel(tr("DCLK相位:")); + hhh->addWidget(lb); + auto spinDclkXw = new QSpinBox; + spinDclkXw->setRange(0, 99999); + hhh->addWidget(spinDclkXw); - hh->addStretch(); + hhh = new HBox(vvv); + lb = new QLabel(tr("DCLK占空比:")); + hhh->addWidget(lb); + auto spinDclkZkb = new QSpinBox; + spinDclkZkb->setRange(20, 80); + hhh->addWidget(spinDclkZkb); - vvv = new VBox(hh); - hhh = new HBox(vvv); + hhh = new HBox(vvv); + lb = new QLabel(tr("换行时间(ns):")); + hhh->addWidget(lb); + auto spinLineNs = new QSpinBox; + spinLineNs->setRange(2, 9999); + hhh->addWidget(spinLineNs); + hhh = new HBox(vvv); + lb = new QLabel(tr("视觉刷新率:")); + hhh->addWidget(lb); + float freshLv=Get_Frefr(7/*小数权值*/ , 12/*灰度位宽*/ , 12500000/*移位时钟频率*/ , 240/*扫描长度*/ , 16/*扫描类型*/ , 4/*倍频*/ ); + qDebug()<<"get_eff="<addWidget(lb); - auto btn = new QPushButton(tr("更多设置")); - btn->setProperty("ss","blue"); - hhh->addWidget(btn); + + hh->addSpacing(20); + vvv = new VBox(hh); + hhh = new HBox(vvv); + lb = new QLabel(tr("亮度有效率:")); + hhh->addWidget(lb); + float BrightYouXiaoLv=Get_Eff(8,16); + qDebug()<<"get_eff="<addWidget(lb); + + hhh = new HBox(vvv); + lb = new QLabel(tr("GCLK频率:")); + hhh->addWidget(lb); + auto cbGCLKf = new QComboBox(); + cbGCLKf->addItem("25M"); + cbGCLKf->addItem("20.83M"); + cbGCLKf->addItem("17.86M"); + cbGCLKf->addItem("15.63M"); + cbGCLKf->addItem("13.89M"); + cbGCLKf->addItem("12.5M"); + cbGCLKf->addItem("11.36M"); + cbGCLKf->addItem("10.42M"); + cbGCLKf->addItem("9.62M"); + hhh->addWidget(cbGCLKf); + + hhh = new HBox(vvv); + lb = new QLabel(tr("灰度级数:")); + hhh->addWidget(lb); + auto cbGryLevel = new QComboBox(); + cbGryLevel->addItem("256"); + cbGryLevel->addItem("1024"); + cbGryLevel->addItem("4096"); + cbGryLevel->addItem("8192"); + cbGryLevel->addItem("16384"); + cbGryLevel->addItem("32768"); + cbGryLevel->addItem("65536"); + hhh->addWidget(cbGryLevel); + + hhh = new HBox(vvv); + lb = new QLabel(tr("GCLK占空比:")); + hhh->addWidget(lb); + auto spinGclkZkb = new QSpinBox; + spinGclkZkb->setRange(20, 80); + hhh->addWidget(spinGclkZkb); + + hhh = new HBox(vvv); + lb = new QLabel(tr("换行位置(ns):")); + hhh->addWidget(lb); + auto spinLineWz = new QSpinBox; + spinLineWz->setRange(2, 9999); + hhh->addWidget(spinLineWz); + + hh->addStretch(); + + vvv = new VBox(hh); + hhh = new HBox(vvv); + + auto btn = new QPushButton(tr("更多设置")); + btn->setProperty("ss","blue"); + hhh->addWidget(btn); + } } vBox->addStretch(); -//保存,发送,固话,回读区 auto hBox = new HBox(vBox); - hBox->addSpacing(20); - auto btn = new QPushButton(tr("打开配置")); - btn->setProperty("ss","blue"); - hBox->addWidget(btn); - hBox->addSpacing(20); - - btn = new QPushButton(tr("保存配置")); + auto btn = new QPushButton(tr("保存接收卡配置")); btn->setProperty("ss","blue"); connect(btn, &QPushButton::clicked, this, [=] { auto dir = QApplication::applicationDirPath()+"/BoxFiles"; @@ -512,14 +617,14 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou QMessageBox::information(this, tr("保存成功"), tr("保存成功")); }); hBox->addWidget(btn); - hBox->addStretch(); btn = new QPushButton(tr("保存Map")); + if(m_iRcvCardType != enum_xixun_sync) btn->hide(); btn->setProperty("ss","blue"); connect(btn, &QPushButton::clicked, this, [=] { - auto dir = QApplication::applicationDirPath(); - auto file = QFileDialog::getSaveFileName(this, tr("保存文件"), dir); + auto file = QFileDialog::getSaveFileName(this, tr("保存文件"), gFileHome); if(file.isEmpty()) return; + gFileHome = QFileInfo(file).absolutePath(); QFile qFile(file); if(! qFile.open(QFile::WriteOnly)) { QMessageBox::critical(this, tr("失败"), QString(tr("准备写入 %1 文件失败")).arg(file)); @@ -529,149 +634,258 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou addMapData(data); auto res = qFile.write(data); qFile.close(); - if(res < 0) { - QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file)); - return; - } - QMessageBox::information(this, tr("保存成功"), tr("保存成功")); - + if(res < 0) QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file)); + else QMessageBox::information(this, tr("成功"), tr("保存成功")); }); hBox->addWidget(btn); - hBox->addSpacing(20); - btn = new QPushButton(tr("发送数据")); + hBox->addStretch(); + + btn = new QPushButton(tr("发送接收参数")); btn->setProperty("ss","blue"); connect(btn, &QPushButton::clicked, this, [=] { - //modified by alahover -s 20230817 - if(m_iRcvCardType == enum_xixun_sync) { - QByteArray data; - addMapData(data); - QMessageBox::information(this, tr("提示"), tr("发送成功")); - } else if(m_iRcvCardType == enum_zrf) { + if(m_iRcvCardType == enum_zrf) { //发送基本参数 - classToBaseMsg(); - auto waitingDlg = new WaitingDlg(this, tr("Setting")+" ..."); - auto res = sendMsgSync(zrf_param_msg, 0x105B14, 10000, waitingDlg); - if(res==5) QMessageBox::critical(this, "Error", tr("请求超时")); - else if(res) QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); - else { - waitingDlg->close(); - QMessageBox::information(this, tr("提示"), tr("发送成功")); - } - } - else if(m_iRcvCardType == enum_xixun_async) QMessageBox::information(this, tr("提示"), tr("异步卡发送成功")); - else QMessageBox::information(this, tr("提示"), tr("未能识别的控制卡类型")); + auto zrf_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 ff ff 00 f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00 00"); + auto zrf_cmd_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); + int res1=0; + //发送基本参数 + MACRO_FUNC_SEND_PARAM("读取基本参数",classToBaseMsg(),1,0x00) + //发送gamma参数 + MACRO_FUNC_SEND_PARAM("读取gamma参数",classToGammaMsg(0,flashPage),2,0x10) + //发送描点参数 + MACRO_FUNC_SEND_PARAM("读取描点参数",classToMiaoDianMsg(flashPage),16,0x30) + QMessageBox::information(this, tr("提示"), tr("发送接收卡参数成功")); + } else QMessageBox::information(this, tr("提示"), tr("未能识别的控制卡类型")); }); hBox->addWidget(btn); - hBox->addSpacing(20); - btn = new QPushButton(tr("固化数据")); + btn = new QPushButton(tr("固化接收参数")); btn->setProperty("ss","blue"); - hBox->addWidget(btn); - hBox->addSpacing(20); - - btn = new QPushButton(tr("回读数据")); - btn->setProperty("ss","blue"); - //added by alahover -s 20230823 connect(btn, &QPushButton::clicked, this, [=] { - if(m_iRcvCardType == enum_rcvCardType::enum_xixun_sync) - { - QByteArray data; - addMapData(data); - QMessageBox::information(this, tr("提示"), tr("回读成功")); + if(m_iRcvCardType == enum_zrf) { + int iReSendCount=3; + int iTimeout=2000; + //发送基本参数 + auto zrf_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 ff ff 00 f0 f0 f0 f0 00 00 00 00 00 00 00 00 00 00 00 00"); + auto zrf_cmd_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); + int res1=0; + //发送基本参数 + MACRO_FUNC_GUHUA_PARAM("发送基本参数",classToBaseMsg(),1,0x00) + //发送gamma参数 + MACRO_FUNC_GUHUA_PARAM("发送gamma参数",classToGammaMsg(0,flashPage),2,0x10) + //发送描点参数 + MACRO_FUNC_GUHUA_PARAM("发送描点参数",classToMiaoDianMsg(flashPage),16,0x30) + QMessageBox::information(this, tr("提示"), tr("固化接收卡参数成功")); + } else QMessageBox::information(this, tr("提示"), tr("未能识别的控制卡类型")); + }); + hBox->addWidget(btn); - } - else if(m_iRcvCardType == enum_rcvCardType::enum_zrf) + btnReceiveReadBack = new QPushButton(tr("回读接收卡参数")); + btnReceiveReadBack->setProperty("ss","blue"); + connect(btnReceiveReadBack, &QPushButton::clicked, this, [=] { + if(m_iRcvCardType == enum_rcvCardType::enum_zrf) { - //回读基本参数 - auto zrf_cmd_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 ff ff 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); + int iReSendCount=3; + int iTimeout=10000; + quint8 flashAddr=0x00; + auto zrf_cmd_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); + auto waitingDlg = new WaitingDlg(this, tr("读取基本参数")+" ..."); + for(int i=0;i=2) {QMessageBox::critical(this, "Error", tr("读取基本参数请求超时")); return;} } + else if(res.code) {if(i>=2) {QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); return;} } + else { + int ioffset=headMap_zrf.paramStart+st_zrf_rb_param.param; + QByteArray return_msg=res.msg.mid(ioffset,256); + waitingDlg->close(); baseMsgToClass((quint8 *)return_msg.data()); qDebug()<=2) {QMessageBox::critical(this, "Error", tr("读取GAMMA参数请求超时")); return;} } + else if(res.code) {if(i>=2) {QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); return;} } + else { + int ioffset=headMap_zrf.paramStart+st_zrf_rb_param.param; + QByteArray return_msg=res.msg.mid(ioffset,256); + waitingDlg->close(); gammaMsgToClass((quint8 *)return_msg.data(),flashPage); qDebug()<close(); - - if(res==5) QMessageBox::critical(this, "Error", tr("请求超时")); - else if(res) QMessageBox::critical(this, "Error", QString(tr("回读描点参数失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); - else { - waitingDlg->close(); - QMessageBox::information(this, tr("提示"), tr("回读描点参数成功")); + flashAddr=0x30; + for(int m=0;m<16;m++){ + int flashPage=flashAddr+m; + for(int n=0;n<4;n++) + *(quint8 *)(zrf_cmd_msg.data()+headMap_zrf.paramStart+st_zrf_cmd_param.flashPage+n)=flashPage; + waitingDlg = new WaitingDlg(this, tr("读取描点参数")+" ..."); + for(int i=0;i=2) {QMessageBox::critical(this, "Error", tr("读取描点参数请求超时")); return;} } + else if(res.code) {if(i>=2) {QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); return;} } + else { + int ioffset=headMap_zrf.paramStart+st_zrf_rb_param.param; + QByteArray return_msg=res.msg.mid(ioffset,256); + waitingDlg->close(); miaoDianMsgToClass((quint8 *)return_msg.data(),flashPage); qDebug()<addWidget(btn); - - vBox->addStretch(); - -//状态栏 - auto statusWgt = new QWidget; - statusWgt->setStyleSheet("QWidget{background-color:#222;}"); - vBox->addWidget(statusWgt); - { - auto hh = new HBox(statusWgt); - auto lb = new QLabel(tr("状态:")); - hh->addWidget(lb); - } + hBox->addWidget(btnReceiveReadBack); } auto connPanel = new QWidget; tab->addTab(connPanel, tr("显示屏连接(正面看屏)")); { - auto vBox = new QVBoxLayout(connPanel); + auto vBox = new VBox(connPanel); vBox->setContentsMargins(4, 4, 4, 4); - auto hhh = new QHBoxLayout; - vBox->addLayout(hhh); + auto hBox = new HBox(vBox); auto bnScreen = new QPushButton("屏1"); - hhh->addWidget(bnScreen); + hBox->addWidget(bnScreen); - hhh->addStretch(); + hBox->addStretch(); auto lb = new QLabel("显示屏数目:"); - hhh->addWidget(lb); + hBox->addWidget(lb); auto fdScreenCnt = new QSpinBox; fdScreenCnt->setRange(1, 99); fdScreenCnt->setValue(1); - hhh->addWidget(fdScreenCnt); + hBox->addWidget(fdScreenCnt); - auto stack = new QStackedLayout; - vBox->addLayout(stack); + vBox->addLayout(connStack = new QStackedLayout); + connStack->addWidget(new ExpertScreenConnWin); - stack->addWidget(new ExpertScreenConnWin()); + hBox = new HBox(vBox); + auto btn = new QPushButton(tr("保存到文件")); + btn->setProperty("ss","blue"); + connect(btn, &QPushButton::clicked, this, [=] { + auto file = QFileDialog::getSaveFileName(this, tr("保存级联文件"), gFileHome, "Kcon文件 (*.kcon)"); + if(file.isEmpty()) return; + gFileHome = QFileInfo(file).absolutePath(); + QFile qFile(file); + if(! qFile.open(QFile::WriteOnly)) { + QMessageBox::critical(this, tr("失败"), QString(tr("准备写入 %1 文件失败")).arg(file)); + return; + } + auto res = qFile.write(JToBytes(connSavedData(), " ")); + qFile.close(); + if(res < 0) QMessageBox::critical(this, tr("失败"), QString(tr("写入 %1 文件失败")).arg(file)); + else QMessageBox::information(this, tr("成功"), tr("保存成功")); + }); + hBox->addWidget(btn); + + hBox->addStretch(); + + btn = new QPushButton(tr("发送级联参数")); + btn->setProperty("ss","blue"); + connect(btn, &QPushButton::clicked, this, [=] { + if(m_iRcvCardType == enum_zrf) { + //发送基本参数 + auto zrf_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 ff ff 00 f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00 00"); + auto zrf_cmd_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); + int res1=0; + //发送排序参数 + MACRO_FUNC_SEND_PARAM("读取排序参数",classToPaiXuSMsg(flashPage),8,0x20) + QMessageBox::information(this, tr("提示"), tr("发送级联参数成功")); + } else QMessageBox::information(this, tr("提示"), tr("未能识别的控制卡类型")); + }); + hBox->addWidget(btn); + + btn = new QPushButton(tr("固化级联参数")); + btn->setProperty("ss","blue"); + connect(btn, &QPushButton::clicked, this, [=] { + if(m_iRcvCardType == enum_zrf) { + int iReSendCount=3; + int iTimeout=2000; + //发送基本参数 + auto zrf_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 ff ff 00 f0 f0 f0 f0 00 00 00 00 00 00 00 00 00 00 00 00"); + auto zrf_cmd_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); + int res1=0; + //发送排序参数 + MACRO_FUNC_GUHUA_PARAM("发送排序参数",classToPaiXuSMsg(flashPage),8,0x20) + QMessageBox::information(this, tr("提示"), tr("固化级联参数成功")); + } else QMessageBox::information(this, tr("提示"), tr("未能识别的控制卡类型")); + }); + hBox->addWidget(btn); + + btnConnReadBack = new QPushButton(tr("回读级联参数")); + btnConnReadBack->setProperty("ss","blue"); + connect(btnConnReadBack, &QPushButton::clicked, this, [=] { + if(m_iRcvCardType == enum_rcvCardType::enum_zrf) + { + int iReSendCount=3; + int iTimeout=10000; + quint8 flashAddr=0x00; + auto zrf_cmd_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); + auto waitingDlg = new WaitingDlg(this, tr("读取基本参数")+" ..."); + //回读排序参数 + flashAddr=0x20; + for(int m=0;m<8;m++){ + int flashPage=flashAddr+m; + for(int n=0;n<4;n++) + *(quint8 *)(zrf_cmd_msg.data()+headMap_zrf.paramStart+st_zrf_cmd_param.flashPage+n)=flashPage; + waitingDlg = new WaitingDlg(this, tr("读取排序参数")+" ..."); + for(int i=0;i=2) {QMessageBox::critical(this, "Error", tr("读取排序参数请求超时")); return;} } + else if(res.code) {if(i>=2) {QMessageBox::critical(this, "Error", QString(tr("发送失败: "))+QString::fromLocal8Bit(pcap_geterr(pcapSend))); return;} } + else { + int ioffset=headMap_zrf.paramStart+st_zrf_rb_param.param; + QByteArray return_msg=res.msg.mid(ioffset,256); + waitingDlg->close(); paiXuMsgToClass((quint8 *)return_msg.data(),flashPage); qDebug()<addWidget(btnConnReadBack); + } + connect(tab, &QTabWidget::currentChanged, [=](int value) { + if(value==1) { + if(needInit1) { + needInit1 = false; + emit btnReceiveReadBack->clicked(); + } + } else if(value==2) { + if(needInit2) { + needInit2 = false; + emit btnConnReadBack->clicked(); + } + } + }); + + changeValueByEffectControler(); + //状态栏 + auto statusWgt = new QWidget; + statusWgt->setStyleSheet("QWidget{background-color:#222;}"); + vBox->addWidget(statusWgt); + { + auto hh = new HBox(statusWgt); + auto lb = new QLabel(tr("状态:")); + hh->addWidget(lb); } } void ExpertWin::closeEvent(QCloseEvent *event) { @@ -685,8 +899,8 @@ QByteArray ExpertWin::savedData() { mBox.insert("ModuleInfo", mModule); auto ModuleWidth = mModule["ModuleWidth"].toInt(); auto ModuleHeight = mModule["ModuleHeight"].toInt(); - mBox.insert("ModuleRow", (fdCardWidth->value() + ModuleWidth - 1) / ModuleWidth); - mBox.insert("ModuleCol", (fdCardHeight->value() + ModuleHeight - 1) / ModuleHeight); + mBox.insert("ModuleRow", ModuleWidth==0 ? 0 : (fdCardWidth->value() + ModuleWidth - 1) / ModuleWidth); + mBox.insert("ModuleCol", ModuleHeight==0 ? 0 : (fdCardHeight->value() + ModuleHeight - 1) / ModuleHeight); mBox.insert("ModuleDirection", fdDirection->currentIndex()); mBox.insert("SectorCount", fdSectorCount->currentData().toInt()); JObj obj{ @@ -695,6 +909,38 @@ QByteArray ExpertWin::savedData() { }; return JToBytes(obj, " "); } +JObj ExpertWin::connSavedData() { + JArray values; + qDebug()<<"connStack->count()"<count(); + for(int ss=0; sscount(); ss++) { + auto connWin = (ExpertScreenConnWin*) connStack->widget(ss); + JArray boxList; + for(int nn=0; nnnetss)/sizeof(connWin->netss[0]); nn++) for(int bb=0; bb<(int)connWin->netss[nn].size(); bb++) { + auto pos = connWin->netss[nn][bb]; + boxList.append(JObj{ + {"X", pos.x()*connWin->fdCardWidth->value()}, + {"Y", pos.y()*connWin->fdCardHeight->value()}, + {"ModuleWidth", connWin->fdCardWidth->value()}, + {"ModuleHeight", connWin->fdCardHeight->value()}, + {"PortId", nn}, + {"SubId", bb+1}, + {"ScreenPosRow", pos.x()}, + {"ScreenPosCol", pos.y()}, + {"ScreenRow", connWin->table->rowCount()}, + {"ScreenCol", connWin->table->columnCount()}, + {"SettingWidth", connWin->fdCardWidth->value()}, + {"SettingHeight", connWin->fdCardHeight->value()}, + {"ScreenIndex", ss} + }); + } + values.append(JObj{ + {"isCompScreen", false}, + {"boxList", boxList}, + }); + } + return {{"values", values}}; +} + void ExpertWin::addMapData(QByteArray &data) { auto ModuleWidth = mModule["ModuleWidth"].toInt(); auto ModuleHeight = mModule["ModuleHeight"].toInt(); @@ -719,8 +965,8 @@ void ExpertWin::addMapData(QByteArray &data) { memY++; } - auto points = mModule["Points"].toArray(); - auto scans = mModule["Scans"].toArray(); + auto points = mModule["ColumnMap"].toArray(); + auto scans = mModule["RowMap"].toArray(); auto GroupNum = mModule["GroupNum"].toInt(); auto jCnt = ModuleCol * GroupNum; @@ -806,12 +1052,11 @@ void ExpertWin::addMapData(QByteArray &data) { data[start-2] = len>>8; } } -//added by alahover -s 02030823 +//added by alahover -s 02030829 void ExpertWin::classToBaseMsg() { - - auto unitptr = (unsigned char *)zrf_param_msg.data(); - unsigned char * bytePrt = (unsigned char*)(unitptr); + byte * unitptr = (byte *)zrf_param_msg.data(); + byte * bytePrt = (byte *)zrf_param_msg.data(); *bytePrt= (zrf_rcv_obj.b0_7 << 7 & 0b10000000)| (zrf_rcv_obj.b0_6 << 6 & 0b01000000)| (zrf_rcv_obj.b0_5 << 5 & 0b00100000)| (zrf_rcv_obj.b0_4 << 4 & 0b00010000)| (zrf_rcv_obj.b0_3_1 << 1 & 0b00001110) | (zrf_rcv_obj.b0_0 & 0b00000001);; bytePrt =unitptr + st_zrf_base_param.b1_xiaoyingTime; @@ -948,97 +1193,90 @@ void ExpertWin::classToBaseMsg() bytePrt =unitptr + st_zrf_base_param.b169_redIcParam1; memcpy(bytePrt,(unsigned char *)& zrf_rcv_obj.b169_192[0],24); - bytePrt =unitptr + st_zrf_base_param.b193_reserve; - *bytePrt= zrf_rcv_obj.b193; } void ExpertWin::classToGammaMsg(int iColorType,quint8 flashPage) { auto unitptr = (unsigned char *)zrf_param_msg.data(); unsigned char * bytePrt = (unsigned char*)(unitptr); + int iCount=flashPage&0x0F; + if(iCount > 1) + QMessageBox::critical(this, "提示", tr("gamma数据越界")); switch(iColorType) { case 0://all - if(flashPage == 0x10) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_all[0],256); - else if(flashPage == 0x11) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_all[128],256); + for (int i = 0; i < 128; i++) { + bytePrt[i*2]=(zrf_rcv_obj.g_all[i+iCount*128]&0XFF00)>>8; + bytePrt[i*2+1]=zrf_rcv_obj.g_all[i+iCount*128]&0X00FF; + } break; case 1://red - if(flashPage == 0x10) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_red[0],256); - else if(flashPage == 0x11) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_red[128],256); - + for (int i = 0; i < 128; i++) { + bytePrt[i*2]=(zrf_rcv_obj.g_red[i+iCount*128]&0XFF00)>>8; + bytePrt[i*2+1]=zrf_rcv_obj.g_red[i+iCount*128]&0X00FF; + } break; case 2://green - if(flashPage == 0x10) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_green[0],256); - else if(flashPage == 0x11) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_green[128],256); + for (int i = 0; i < 128; i++) { + bytePrt[i*2]=(zrf_rcv_obj.g_green[i+iCount*128]&0XFF00)>>8; + bytePrt[i*2+1]=zrf_rcv_obj.g_green[i+iCount*128]&0X00FF; + } break; case 3://blue - if(flashPage == 0x10) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_blue[0],256); - else if(flashPage == 0x11) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_blue[128],256); + for (int i = 0; i < 128; i++) { + bytePrt[i*2]=(zrf_rcv_obj.g_blue[i+iCount*128]&0XFF00)>>8; + bytePrt[i*2+1]=zrf_rcv_obj.g_blue[i+iCount*128]&0X00FF; + } break; default: - if(flashPage == 0x10) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_all[0],256); - else if(flashPage == 0x11) - memcpy(bytePrt ,(unsigned char*)&zrf_rcv_obj.g_all[128],256); + for (int i = 0; i < 128; i++) { + bytePrt[i*2]=(zrf_rcv_obj.g_all[i+iCount*128]&0XFF00)>>8; + bytePrt[i*2+1]=zrf_rcv_obj.g_all[i+iCount*128]&0X00FF; + } break; } } - -void ExpertWin::classToPaiXuSMsg(quint8 flashPage,bool bInitP8_st_rcv_pos) +void ExpertWin::classToPaiXuSMsg(quint8 flashPage) { - if(bInitP8_st_rcv_pos) - { - for(int i=0;i<256;i++) - { - zrf_rcv_obj.p8_st_rcv_pos[i].imgXL8 = zrf_rcv_obj.p_x[i] & 0x00FF; - zrf_rcv_obj.p8_st_rcv_pos[i].imgXH4_YH4 = ((zrf_rcv_obj.p_x[i] & 0x0F00) >>4 )| ((zrf_rcv_obj.p_y[i] & 0x0F00) >>8); - zrf_rcv_obj.p8_st_rcv_pos[i].imgYL8 = zrf_rcv_obj.p_y[i] & 0x00FF; - zrf_rcv_obj.p8_st_rcv_pos[i].imgWidthL8 = zrf_rcv_obj.p_w[i] & 0x00FF; - zrf_rcv_obj.p8_st_rcv_pos[i].imgWidthH4_HeightH4 = ((zrf_rcv_obj.p_w[i] & 0x0F00) >>4 )| ((zrf_rcv_obj.p_h[i] & 0x0F00) >>8); - zrf_rcv_obj.p8_st_rcv_pos[i].imgHeightL8 = zrf_rcv_obj.p_h[i] & 0x00FF; - zrf_rcv_obj.p8_st_rcv_pos[i].imgPosNumInScreenH8 = (zrf_rcv_obj.p_posNum[i] & 0xFF00) >>8; - zrf_rcv_obj.p8_st_rcv_pos[i].imgPosNumInScreenL8 = zrf_rcv_obj.p_posNum[i] & 0x00FF; - } - - } - else - { - auto unitptr = (unsigned char *)zrf_param_msg.data(); - unsigned char * bytePrt = (unsigned char*)(unitptr); - if(flashPage == 0x20) - { - *bytePrt = zrf_rcv_obj.p0_cardIndexInNet ;//当前卡在网线内的序号 - bytePrt++; - *bytePrt = zrf_rcv_obj.p1_SendCardCode ;//当前网线所在的发送卡编号 - bytePrt++; - *bytePrt = zrf_rcv_obj.p2_netIndexInSendCard ;//当前网线所在发送卡输出口编号 - bytePrt++; - *bytePrt = zrf_rcv_obj.p3_fenXianNum ;//当前分线号 - bytePrt++; - *bytePrt = zrf_rcv_obj.p4_rcvCardsNumInNet ;//当前网线内接收卡总数 - bytePrt++; - *bytePrt = zrf_rcv_obj.p5_netScreenIndex ; //当前网线所在屏号 - bytePrt++; - *bytePrt = zrf_rcv_obj.p6_reserve ;//保留 - bytePrt++; - *bytePrt = zrf_rcv_obj.p7_reserve1 ;//保留 - bytePrt++; - memcpy(bytePrt,&zrf_rcv_obj.p8_st_rcv_pos[0],256-8); - } - else - { - int itemp=flashPage&0x0F -1;//flashpage 0x21~0x27, - memcpy(bytePrt,&zrf_rcv_obj.p8_st_rcv_pos[itemp * 32 + (256-8)/8],256); - } - } + auto unitptr = (unsigned char *)zrf_param_msg.data(); + unsigned char * bytePrt = (unsigned char*)(unitptr); + if(flashPage == 0x20) + { + for(int i=0;i<256;i++) + { + zrf_rcv_obj.p8_st_rcv_pos[i].imgXL8 = zrf_rcv_obj.p_x[i] & 0x00FF; + zrf_rcv_obj.p8_st_rcv_pos[i].imgXH4_YH4 = ((zrf_rcv_obj.p_x[i] & 0x0F00) >>4 )| ((zrf_rcv_obj.p_y[i] & 0x0F00) >>8); + zrf_rcv_obj.p8_st_rcv_pos[i].imgYL8 = zrf_rcv_obj.p_y[i] & 0x00FF; + zrf_rcv_obj.p8_st_rcv_pos[i].imgWidthL8 = zrf_rcv_obj.p_w[i] & 0x00FF; + zrf_rcv_obj.p8_st_rcv_pos[i].imgWidthH4_HeightH4 = ((zrf_rcv_obj.p_w[i] & 0x0F00) >>4 )| ((zrf_rcv_obj.p_h[i] & 0x0F00) >>8); + zrf_rcv_obj.p8_st_rcv_pos[i].imgHeightL8 = zrf_rcv_obj.p_h[i] & 0x00FF; + zrf_rcv_obj.p8_st_rcv_pos[i].imgPosNumInScreenH8 = (zrf_rcv_obj.p_posNum[i] & 0xFF00) >>8; + zrf_rcv_obj.p8_st_rcv_pos[i].imgPosNumInScreenL8 = zrf_rcv_obj.p_posNum[i] & 0x00FF; + } + *bytePrt = zrf_rcv_obj.p0_cardIndexInNet ;//当前卡在网线内的序号 + bytePrt++; + *bytePrt = zrf_rcv_obj.p1_SendCardCode ;//当前网线所在的发送卡编号 + bytePrt++; + *bytePrt = zrf_rcv_obj.p2_netIndexInSendCard ;//当前网线所在发送卡输出口编号 + bytePrt++; + *bytePrt = zrf_rcv_obj.p3_fenXianNum ;//当前分线号 + bytePrt++; + *bytePrt = zrf_rcv_obj.p4_rcvCardsNumInNet ;//当前网线内接收卡总数 + bytePrt++; + *bytePrt = zrf_rcv_obj.p5_netScreenIndex ; //当前网线所在屏号 + bytePrt++; + *bytePrt = zrf_rcv_obj.p6_reserve ;//保留 + bytePrt++; + *bytePrt = zrf_rcv_obj.p7_reserve1 ;//保留 + bytePrt++; + memcpy(bytePrt,&zrf_rcv_obj.p8_st_rcv_pos[0],256-8); + } + else + { + int itemp=(flashPage&0x0F) -1;//flashpage 0x21~0x27, + memcpy(bytePrt,&zrf_rcv_obj.p8_st_rcv_pos[itemp * 32 + (256-8)/8],256); + } + //qDebug()<<"zrf_param_msg = "<>7;//DAT信号 方式 0:高有效(共阴) 1:低有效(共阳); + zrf_rcv_obj.b0_6 = (data[st_zrf_base_param.b0_RP] & 0b01000000) >>6;//STB信号有效方式 0:正向 1:反向; + zrf_rcv_obj.b0_5 = (data[st_zrf_base_param.b0_RP] & 0b00100000) >>5;//OE信号有效0 :低有 效1 :高有效; + zrf_rcv_obj.b0_4 = (data[st_zrf_base_param.b0_RP] & 0b00010000) >>4;//行有效方式:0 :低有效1 :高有效; + zrf_rcv_obj.b0_3_1 = (data[st_zrf_base_param.b0_RP] & 0b00001110) >>1;//行译码方式bit2~bit0与地址0x01 bit7~bit6 表示 bit4~bit3。0:普通,常规138译码;00001:SM5266;00010:SM5366;01000::ICN2013;00100:无译码;00101:595译码;0110::5958译码;01110:ICND2018;其他:保留; + zrf_rcv_obj.b0_0 = (data[st_zrf_base_param.b0_RP] & 0b00000001) >>0;//0 :全色;1 :单双色; + zrf_rcv_obj.b1_7_6 = (data[st_zrf_base_param.b1_xiaoyingTime] & 0b11000000)>>6; //行译码方式 bit4~bit3 + zrf_rcv_obj.b1_5 = (data[st_zrf_base_param.b1_xiaoyingTime] & 0b00100000)>>5; //消影控制电平0:高有效;1:低有效 + zrf_rcv_obj.b1_4 = (data[st_zrf_base_param.b1_xiaoyingTime] & 0b00010000)>>4; //双卡备份0:关闭;1:启用 + zrf_rcv_obj.b1_3_2 = (data[st_zrf_base_param.b1_xiaoyingTime] & 0b00001100)>>2; //颜色深度00:8bit;01:10bit;10:12bit + zrf_rcv_obj.b1_1 = (data[st_zrf_base_param.b1_xiaoyingTime] & 0b00000010)>>1; //D信号扩展为第二时钟0:关闭;1:启用 + zrf_rcv_obj.b1_0 = (data[st_zrf_base_param.b1_xiaoyingTime] & 0b00000001)>>0; //上电渐亮0:启用;1:关闭 zrf_rcv_obj.b2 = data[st_zrf_base_param.b2_line_xytime]; //实际消影时间为:(输入值 * 2 + 1) * 48ns zrf_rcv_obj.b3 = data[st_zrf_base_param.b3_rows1Group]; //一组数据控制模组的行数:1~64;其他无效; zrf_rcv_obj.b4 = data[st_zrf_base_param.b4_cols1Group]; //一组数据控制的模组列数:1~128,其他无效; zrf_rcv_obj.b5 = data[st_zrf_base_param.b5_scanNum]; //模组扫描方式:1~64,其他无效; zrf_rcv_obj.b6 = data[st_zrf_base_param.b6_emptyPointNum]; //模组每行空点数,详见说明2; - zrf_rcv_obj.b7_7_6 = data[st_zrf_base_param.b7_colorIndex] & 0b11000000; //输出数据线4,00:红;01:绿;10:蓝;11:黑; - zrf_rcv_obj.b7_5_4 = data[st_zrf_base_param.b7_colorIndex] & 0b00110000; //输出数据线3,00:红;01:绿;10:蓝;11:黑; - zrf_rcv_obj.b7_3_2 = data[st_zrf_base_param.b7_colorIndex] & 0b00001100; //输出数据线2,00:红;01:绿;10:蓝;11:黑; - zrf_rcv_obj.b7_1_0 = data[st_zrf_base_param.b7_colorIndex] & 0b00000011; //输出数据线1,00:红;01:绿;10:蓝;11:黑; - zrf_rcv_obj.b8_7 = data[st_zrf_base_param.b8_dataOutModle] & 0b10000000; //多种描点数据 :0,关闭;1,启用 - zrf_rcv_obj.b8_6 = data[st_zrf_base_param.b8_dataOutModle] & 0b01000000; //扫描复用模式:0,行扫;1,列扫; - zrf_rcv_obj.b8_5_4 = data[st_zrf_base_param.b8_dataOutModle] & 0b00110000; //模组级联方向:00:从右往左;01:从上往下;10:从左往右;11:从下往上; - zrf_rcv_obj.b8_3_0 = data[st_zrf_base_param.b8_dataOutModle] & 0b00001111; //数据输出模式:0000:标准16组并行数据输出,0001:增强20组并行数据输出,0010:增强24组并行数据输出,0101:串行16组数据输出,0100:串行32组数据输出,0011:串行 64 组数据输出,0110:增强32组并行数据输出,0111:串行 128 组数据,1000:串行 96 组数据,1001~1111:保留 + zrf_rcv_obj.b7_7_6 = (data[st_zrf_base_param.b7_colorIndex] & 0b11000000) >> 6; //输出数据线4,00:红;01:绿;10:蓝;11:黑; + zrf_rcv_obj.b7_5_4 = (data[st_zrf_base_param.b7_colorIndex] & 0b00110000) >> 4; //输出数据线3,00:红;01:绿;10:蓝;11:黑; + zrf_rcv_obj.b7_3_2 = (data[st_zrf_base_param.b7_colorIndex] & 0b00001100) >> 2; //输出数据线2,00:红;01:绿;10:蓝;11:黑; + zrf_rcv_obj.b7_1_0 = (data[st_zrf_base_param.b7_colorIndex] & 0b00000011) >> 0; //输出数据线1,00:红;01:绿;10:蓝;11:黑; + + qDebug()<<"***zrf_rcv_obj.b7_7_6="<> 3; + if(mModule["DataPolarity"].toBool()) + zrf_rcv_obj.b0_7 = 0; + else + zrf_rcv_obj.b0_7 = 1; + if(mModule["OePolarity"].toBool()) + zrf_rcv_obj.b0_5 = 0; + else + zrf_rcv_obj.b0_5 = 1; +//颜色 + quint8 ColorMap=mModule["ColorMap"].toInt(); + int iLine_1=(ColorMap & 0b11000000) >> 6; + int iLine_2=(ColorMap & 0b00110000) >> 4; + int iLine_3=(ColorMap & 0b00001100) >> 2; + int iLine_4=(ColorMap & 0b00000011) >> 0; + switch(iLine_1) { + case 0b00://黑色 + zrf_rcv_obj.b7_1_0=0b11; break; + case 0b01: + zrf_rcv_obj.b7_1_0=0b00; break; + case 0b10: + zrf_rcv_obj.b7_1_0=0b01; break; + case 0b11: + zrf_rcv_obj.b7_1_0=0b10; break; + } + switch(iLine_2) { + case 0b00://黑色 + zrf_rcv_obj.b7_3_2=0b11; break; + case 0b01: + zrf_rcv_obj.b7_3_2=0b00; break; + case 0b10: + zrf_rcv_obj.b7_3_2=0b01; break; + case 0b11: + zrf_rcv_obj.b7_3_2=0b10; break; + } + switch(iLine_3) { + case 0b00://黑色 + zrf_rcv_obj.b7_5_4=0b11; break; + case 0b01: + zrf_rcv_obj.b7_5_4=0b00; break; + case 0b10: + zrf_rcv_obj.b7_5_4=0b01; break; + case 0b11: + zrf_rcv_obj.b7_5_4=0b10; break; + } + switch(iLine_4) { + case 0b00://黑色 + zrf_rcv_obj.b7_7_6=0b11; break; + case 0b01: + zrf_rcv_obj.b7_7_6=0b00; break; + case 0b10: + zrf_rcv_obj.b7_7_6=0b01; break; + case 0b11: + zrf_rcv_obj.b7_7_6=0b10; break; + } + //alahover ? + if(mModule["GroupMode"].toStr()==tr("三线并行")) + zrf_rcv_obj.b8_3_0=0b0110; + else + zrf_rcv_obj.b8_3_0=0b0111; + zrf_rcv_obj.b8_3_0=0b0111; + zrf_rcv_obj.ucZheHuiCiShu=mModule["RowPerScan"].toInt(); +//描点参数 + int iScanIndex=0; + auto scans = mModule["RowMap"].toArray(); + for(auto scan : scans) { + + zrf_rcv_obj.m_scanIndex[iScanIndex]=scan.toInt(); + iScanIndex++; + } + auto points = mModule["ColumnMap"].toArray(); + int iPointIndex=0; + for(auto point : points) { + zrf_rcv_obj.m_pixelPos[iPointIndex][0]=point.toInt() & 0x000000ff;//列 + zrf_rcv_obj.m_pixelPos[iPointIndex][1]=(point.toInt() & 0x0000ff00) >>8;//行 + iPointIndex++; + } + } -//added by alahover -o 20230823 +int ExpertWin::GetIcTypeIndexFromName(QString strName) +{ + auto file = QApplication::applicationDirPath()+"/driver.ic"; + QFile qFile(file); + if(qFile.open(QFile::ReadOnly)) { + auto data = qFile.readAll(); + qFile.close(); + auto json = JFrom(data).toObj(); + if(! json.empty()) + { + if(!json[strName].isNull()){ + return json[strName].toInt(); + } + else{ + QMessageBox::information(this, tr("提示"), tr("未能识别的驱动IC类型")); + return -1; + } + } + else{ + QMessageBox::information(this, tr("提示"), tr("未能识别的驱动IC类型")); + return -1; + } + } + QMessageBox::information(this, tr("提示"), tr("缺失driver.ic配置文件")); + return -1; +} +int ExpertWin::GetRowYiMaIndexFromName(QString strName) +{ + auto file = QApplication::applicationDirPath()+"/decoder.ic"; + QFile qFile(file); + if(qFile.open(QFile::ReadOnly)) { + auto data = qFile.readAll(); + qFile.close(); + auto json = JFrom(data).toObj(); + if(! json.empty()) + { + if(!json[strName].isNull()){ + return json[strName].toInt(); + } + else{ + QMessageBox::information(this, tr("提示"), tr("未能识别的行译码IC类型")); + return -1; + } + } + else{ + QMessageBox::information(this, tr("提示"), tr("未能识别的行译码IC类型")); + return -1; + } + } + QMessageBox::information(this, tr("提示"), tr("缺失driver.ic配置文件")); + return -1; +} +void ExpertWin::changeValueByEffectControler() { + //spinbox + if(m_iRcvCardType!=enum_zrf) return; + QObject::connect(fdCardWidth, static_cast(&QSpinBox::valueChanged), [=](int value){ qDebug() << "箱体宽度当前值:" << value; + zrf_rcv_obj.b31=value&0x00ff; zrf_rcv_obj.b32=(value&0xff00) >> 8; });// + QObject::connect(spinGclkXw, static_cast(&QSpinBox::valueChanged), [=](int value){ qDebug() << "GCLK相位当前值:" << value; + zrf_rcv_obj.b193=value; }); + QObject::connect(spinGclkZkb, static_cast(&QSpinBox::valueChanged), [=](int value){ qDebug() << "GCLK占空比当前值:" << value; + zrf_rcv_obj.b193=value; }); + QObject::connect(spinLineNs, static_cast(&QSpinBox::valueChanged), [=](int value){ qDebug() << "换行时间当前值:" << value; + zrf_rcv_obj.b193=value; }); + QObject::connect(spinLineWz, static_cast(&QSpinBox::valueChanged), [=](int value){ qDebug() << "行位置当前值:" << value; + zrf_rcv_obj.b193=value; }); + QObject::connect(spinLineXy, static_cast(&QSpinBox::valueChanged), [=](int value){ qDebug() << "消隐时间当前值:" << value; + zrf_rcv_obj.b2=value; });// + QObject::connect(spinPointsOnePort, static_cast(&QSpinBox::valueChanged), [=](int value){ qDebug() << "单口带载点数当前值:" << value; + zrf_rcv_obj.b193=value; }); + + //combox + QObject::connect(cbDCLKf, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "DLC频率当前值:" << value; + zrf_rcv_obj.b18_3_0=value; });// + QObject::connect(cbDclkXw, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "DCLK相位当前值:" << value; + zrf_rcv_obj.b19_7_4=value; });// + QObject::connect(cbDclkZkb, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "DCLK占空比当前值:" << value; + zrf_rcv_obj.b19_3_0=value; });// + QObject::connect(fdDirection, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "模组级联方向出当前值:" << value; + zrf_rcv_obj.b8_5_4=value; });// + QObject::connect(fdSectorCount, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "多开设置出当前值:" << value; + zrf_rcv_obj.b70_5_2=value; + if(zrf_rcv_obj.b70_5_2!=0) + zrf_rcv_obj.b70_6=1; + else zrf_rcv_obj.b70_6=0; });// + QObject::connect(freshBeiLv, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "刷新倍率出当前值:" << value; + zrf_rcv_obj.b21_7_5=value; });// + QObject::connect(cbGCLKf, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "GCLK周期出当前值:" << value; + zrf_rcv_obj.b193=value; }); + QObject::connect(cbGryLevel, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "灰度等级出当前值:" << value; + if(zrf_rcv_obj.m_pwmFlag==1){ + switch(value){ + case 0: zrf_rcv_obj.b21_4_0=23; break;//正常4096 + case 1: zrf_rcv_obj.b21_4_0=26; break;//正常8192 + case 2: zrf_rcv_obj.b21_4_0=29; break;//正常16384 + case 3: zrf_rcv_obj.b21_4_0=30; break;//正常32768 + case 4: zrf_rcv_obj.b21_4_0=31; break;//正常65535 + default: zrf_rcv_obj.b21_4_0=31; break;//正常65535 + } + + } + else + zrf_rcv_obj.b21_4_0=value; });// + QObject::connect(cbNoSign, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "无信号输出出当前值:" << value; + zrf_rcv_obj.b29_1_0=value; });// + QObject::connect(cbStb, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "行信号STB微调出当前值:" << value; + zrf_rcv_obj.b193=value; }); + QObject::connect(cbDE, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "行信号DE微调出当前值:" << value; + zrf_rcv_obj.b193=value; }); + QObject::connect(cbABC, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "行信号ABC微调出当前值:" << value; + zrf_rcv_obj.b193=value; }); + QObject::connect(cbXiaoYinDianPing, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "消隐电平出当前值:" << value; + zrf_rcv_obj.b1_5=value; });// + QObject::connect(cbSTB, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "锁存STB电平方向出当前值:" << value; + zrf_rcv_obj.b0_6=value; });// + QObject::connect(cbSRowOut, static_cast(&QComboBox::currentIndexChanged), [=](int value){ qDebug() << "行输出电平出当前值:" << value; + zrf_rcv_obj.b0_4=value; });// + //checkbox + QObject::connect(checkSyncXianKa, static_cast(&QCheckBox::stateChanged), [=](int value){ qDebug() << "同步显卡出当前值:" << value; + if(value==0) zrf_rcv_obj.b26_7=value ; + else zrf_rcv_obj.b26_7=0b1; });// + QObject::connect(checkJianLiang, static_cast(&QCheckBox::stateChanged), [=](int value){ qDebug() << "开屏渐亮出当前值:" << value; + if(value==0) zrf_rcv_obj.b1_0=value ; + else zrf_rcv_obj.b1_0=0b1; });// + QObject::connect(checkDoubleCopy, static_cast(&QCheckBox::stateChanged), [=](int value){ qDebug() << "双备份出当前值:" << value; + if(value==0) zrf_rcv_obj.b1_4=value ; + else zrf_rcv_obj.b1_4=0b1; });// + QObject::connect(checkDsignalAsCLk, static_cast(&QCheckBox::stateChanged), [=](int value){ qDebug() << "D信号作为第二组CLK出当前值:" << value; + if(value==0) zrf_rcv_obj.b1_1=value ; + else zrf_rcv_obj.b1_1=0b1; });// + +} +void ExpertWin::SetEffectControlerValueByClass() +{ + //spinbox + fdCardWidth->setValue(( zrf_rcv_obj.b32<<8)|zrf_rcv_obj.b31); qDebug() << "箱体宽度当前值:" << fdCardWidth->value();// + spinGclkXw->setValue(zrf_rcv_obj.b193); qDebug() << "GCLK相位当前值:" << spinGclkXw->value(); + spinGclkZkb->setValue(zrf_rcv_obj.b193); qDebug() << "GCLK占空比当前值:" << spinGclkZkb->value(); + spinLineNs->setValue(zrf_rcv_obj.b193); qDebug() << "换行时间当前值:" << spinLineNs->value(); + spinLineWz->setValue(zrf_rcv_obj.b193); qDebug() << "行位置当前值:" << spinLineWz->value(); + spinLineXy->setValue(zrf_rcv_obj.b2); qDebug() << "消隐时间当前值:" << spinLineXy->value();// + spinPointsOnePort->setValue(zrf_rcv_obj.b193); qDebug() << "单口带载点数当前值:" << spinPointsOnePort->value(); + + //combox + cbDCLKf->setCurrentIndex(zrf_rcv_obj.b18_3_0); qDebug() << "DLC频率当前值:" << cbDCLKf->currentIndex(); + cbDclkXw->setCurrentIndex(zrf_rcv_obj.b19_7_4); qDebug() << "DCLK相位当前值:" << cbDclkXw->currentIndex(); + cbDclkZkb->setCurrentIndex(zrf_rcv_obj.b19_3_0); qDebug() << "DCLK占空比当前值:" << cbDclkZkb->currentIndex(); + fdDirection->setCurrentIndex(zrf_rcv_obj.b8_5_4); qDebug() << "模组级联方向出当前值:" << fdDirection->currentIndex(); + fdSectorCount->setCurrentIndex(zrf_rcv_obj.b70_5_2); qDebug() << "多开设置出当前值:" << fdSectorCount->currentIndex(); + freshBeiLv->setCurrentIndex(zrf_rcv_obj.b21_7_5); qDebug() << "刷新倍率出当前值:" << freshBeiLv->currentIndex(); + cbGCLKf->setCurrentIndex(zrf_rcv_obj.b193); qDebug() << "GCLK周期出当前值:" << cbGCLKf->currentIndex(); + + int index=31; + if(zrf_rcv_obj.m_pwmFlag==1) + switch(zrf_rcv_obj.b21_4_0){ + case 23: index=0; break;//正常4096 + case 26: index=1; break;//正常8192 + case 29: index=2; break;//正常16384 + case 30: index=3; break;//正常32768 + case 31: index=4; break;//正常65535 + default: index=4; break;//正常65535 + } + else + index=zrf_rcv_obj.b21_4_0; + cbGryLevel->setCurrentIndex(index); qDebug() << "灰度等级出当前值:" << cbGryLevel->currentIndex(); + cbNoSign->setCurrentIndex(zrf_rcv_obj.b29_1_0); qDebug() << "无信号输出出当前值:" << cbNoSign->currentIndex(); + cbStb->setCurrentIndex(zrf_rcv_obj.b193); qDebug() << "行信号STB微调出当前值:" << cbStb->currentIndex(); + cbDE->setCurrentIndex(zrf_rcv_obj.b193); qDebug() << "行信号DE微调出当前值:" << cbDE->currentIndex(); + cbABC->setCurrentIndex(zrf_rcv_obj.b193); qDebug() << "行信号ABC微调出当前值:" << cbABC->currentIndex(); + cbXiaoYinDianPing->setCurrentIndex(zrf_rcv_obj.b1_5); qDebug() << "消隐电平出当前值:" << cbXiaoYinDianPing->currentIndex(); + cbSTB->setCurrentIndex(zrf_rcv_obj.b0_6); qDebug() << "锁存STB电平方向出当前值:" << cbSTB->currentIndex(); + cbSRowOut->setCurrentIndex(zrf_rcv_obj.b0_4); qDebug() << "行输出电平出当前值:" << cbSRowOut->currentIndex(); + //checkbox + checkSyncXianKa->setChecked(zrf_rcv_obj.b26_7); qDebug() << "同步显卡出当前值:" << checkSyncXianKa->isChecked(); + checkJianLiang->setChecked(zrf_rcv_obj.b1_0); qDebug() << "开屏渐亮出当前值:" << checkJianLiang->isChecked(); + checkDoubleCopy->setChecked(zrf_rcv_obj.b1_4); qDebug() << "双备份出当前值:" << checkDoubleCopy->isChecked(); + checkDsignalAsCLk->setChecked(zrf_rcv_obj.b1_1); qDebug() << "D信号作为第二组CLK出当前值:" << checkDsignalAsCLk->isChecked(); + if(m_iRcvCardType == enum_zrf) { + //发送基本参数 + auto zrf_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 ff ff 00 f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00 00"); + auto zrf_cmd_msg = QByteArray::fromHex("55 55 00 11 22 33 44 55 00 11 22 33 44 55 10 5a 13 00 00 00 00 e0 00 00 00 f2 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00 00"); + int res1=0; + //发送基本参数 + MACRO_FUNC_SEND_PARAM("读取基本参数",classToBaseMsg(),1,0x00) + } +} +//added by alahover -o 20230830 diff --git a/ledset/expertwin.h b/ledset/expertwin.h index a39bb7f..6541e66 100644 --- a/ledset/expertwin.h +++ b/ledset/expertwin.h @@ -8,6 +8,7 @@ #include #include #include +#include class ExpertWin : public BaseWin { Q_OBJECT @@ -15,11 +16,9 @@ public: explicit ExpertWin(QWidget *parent, int); QByteArray savedData(); + JObj connSavedData(); void addMapData(QByteArray &); - int screenWidth{1280}, screenHeight{720}; - double rate{1}; - QLabel *fdModuleWidth, *fdModuleHeight, *fdGroupNum, *fdScanNum, *fdDataGroupColor ,*fdChouDian; QLabel *fdChipType, *fdDecodeMode; JObj cfg; @@ -39,13 +38,12 @@ public: {"GroupMode", "三线并行"} }; + QStackedLayout *connStack; QSpinBox *fdCardWidth, *fdCardHeight; QComboBox *fdDirection, *fdSectorCount; QRadioButton *fdAdvacned; - //added by alahover -s 20230830 - QPushButton *btnReadBack,*btn_OpenCfg,*btn_SaveCfg,*btn_SaveMap,*btn_SendData,*btn_GuhuaData; - QTabWidget * m_tab; + QPushButton *btnConnReadBack, *btnReceiveReadBack; QSpinBox *spinGclkXw,*spinGclkZkb,*spinLineNs,*spinLineWz,*spinLineXy,*spinPointsOnePort; QComboBox *cbDCLKf,*cbDclkXw, *cbDclkZkb,*freshBeiLv,*cbGCLKf,*cbGryLevel,*cbNoSign,*cbStb,*cbDE,*cbABC,*cbXiaoYinDianPing,*cbSTB,*cbSRowOut; QLabel * m_ctrlFreshRate,*m_ctrlBrightEff,*m_ctrlMinOE; @@ -55,8 +53,8 @@ public: //added by alahover -o 20230830 //added by alahover -s 20230817 int m_iRcvCardType; - int m_tab1firstClick=0; - int m_tab2firstClick=0; + bool needInit1 = true; + bool needInit2 = true; struct St_Rcv_Pos{ unsigned char imgXL8 = 0;//接收卡图像列起始低八位 @@ -288,8 +286,6 @@ protected: void closeEvent(QCloseEvent *) override; }; - - #define MACRO_FUNC_SEND_PARAM(TIP_MESSAGE,FUNC,SEND_FLASHPAGE_NUM,FLASH_ADDR) \ for(int iSendCount=0;iSendCount #include const int AlignRight = Qt::AlignRight | Qt::AlignVCenter; -Table::Table(std::initializer_list colAttrs, int rows, QWidget *parent) : QTableWidget{rows, (int)colAttrs.size(), parent} { - int i = 0; - for(typename std::initializer_list::const_iterator it = colAttrs.begin(); it != colAttrs.end(); ++it) { - auto item = horizontalHeaderItem(i); - if(item==0) setHorizontalHeaderItem(i, item = new QTableWidgetItem()); - item->setText(it->text); - if(it->width > 0) horizontalHeader()->resizeSection(i, it->width); - if(it->resizeMode != QHeaderView::Interactive) { - if(it->resizeMode==QHeaderView::Stretch && it->width>0) { - item->setData(0x99, it->width > 0 ? it->width : 100); - noStretch = false; - } else horizontalHeader()->setSectionResizeMode(i, (QHeaderView::ResizeMode)it->resizeMode); - } - mFieldMap.emplace(it->field, i++); - } +int operator*(const QString& key, QTreeView &table) { + return ((TreeWidget&)table).fdmap.at(key); +} +int operator*(const char *key, QTreeView &table) { + return ((TreeWidget&)table).fdmap.at(key); } +TreeWidget::TreeWidget(std::initializer_list colAttrs, QWidget *parent) : QTreeWidget{parent} { + header()->setMinimumSectionSize(16); + int i = 0; + auto item = headerItem(); + for(auto attr = colAttrs.begin(); attr < colAttrs.end(); ++attr) { + item->setText(i, attr->text); + item->setData(i, FieldRole, attr->field); + if(attr->width > 0) header()->resizeSection(i, attr->width); + if(attr->resizeMode != QHeaderView::Interactive) { + if(attr->resizeMode==QHeaderView::Stretch && attr->width > 0) { + item->setData(i, WidthRole, attr->width); + noStretch = false; + } else header()->setSectionResizeMode(i, attr->resizeMode); + } + fdmap.emplace(attr->field, i++); + } + hasRowNum = i && colAttrs.begin()->field=="_num_"; + connect(header(), &QHeaderView::sectionResized, this, &TreeWidget::onSectionResized); + header()->installEventFilter(this); +} +bool TreeWidget::eventFilter(QObject *watched, QEvent *event) { + if(isSectionResized && event->type()==QEvent::Leave && watched==header()) { + isSectionResized = false; + auto item = headerItem(); + for(int cc=0; ccdata(cc, WidthRole).isValid()) item->setData(cc, WidthRole, header()->sectionSize(cc)); + } + return QTreeWidget::eventFilter(watched, event); +} +void TreeWidget::resizeEvent(QResizeEvent *event) { + QTreeWidget::resizeEvent(event); + if(noStretch || event->size().width() == event->oldSize().width()) return; + adjSections(-1, 0); +} +void TreeWidget::drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const { + QTreeWidget::drawRow(painter, options, index); + if(columnWidth(0)>40) return; + if(hasRowNum) { + QRect rect(options.rect.left(), options.rect.top(), columnWidth(0), options.rect.height()); + painter->fillRect(rect, QColor(128, 128, 128, 32)); + painter->drawText(rect, Qt::AlignCenter, QString::number(index.row()+1)); + } + if(hasGrid) { + QBrush color({128, 128, 128, 128}); + painter->fillRect(options.rect.left(), options.rect.bottom(), options.rect.width(), 1, color); + QRect rec(options.rect.left()-1, options.rect.top(), 1, options.rect.height()); + auto end = columnCount() - 1; + for(int i=0; ifillRect(rec, color); + } + } +} +void TreeWidget::onSectionResized(int logicalIndex, int oldSize, int newSize) { + if(blocked || noStretch || newSize==0 || oldSize==0) return; + if(! headerItem()->data(logicalIndex, WidthRole).isValid()) return; + if(adjSections(logicalIndex, newSize)) isSectionResized = true; +} +bool TreeWidget::adjSections(int index, int size) { + auto item = headerItem(); + int remain = header()->width() - size, stretchWidth = 0, width; + for(int cc=0; ccdata(cc, WidthRole).toInt()) > 0) stretchWidth += width; + else remain -= header()->sectionSize(cc); + } + if(remain<=0 || stretchWidth==0) return false; + auto min = header()->minimumSectionSize(); + blocked = true; + for(int cc=0; ccdata(cc, WidthRole).toInt()) > 0) header()->resizeSection(cc, qMax(min, width * remain / stretchWidth)); + blocked = false; + return true; +} + +Table::Table(std::initializer_list colAttrs, int rows, QWidget *parent) : QTableWidget{rows, (int)colAttrs.size(), parent} { + int i = 0; + for(auto attr = colAttrs.begin(); attr < colAttrs.end(); ++attr) { + auto item = horizontalHeaderItem(i); + if(item==0) setHorizontalHeaderItem(i, item = new QTableWidgetItem); + item->setText(attr->text); + item->setData(FieldRole, attr->field); + if(attr->width > 0) horizontalHeader()->resizeSection(i, attr->width); + if(attr->resizeMode != QHeaderView::Interactive) { + if(attr->resizeMode==QHeaderView::Stretch && attr->width > 0) { + item->setData(WidthRole, attr->width); + noStretch = false; + } else horizontalHeader()->setSectionResizeMode(i, attr->resizeMode); + } + fdmap.emplace(attr->field, i++); + } + connect(horizontalHeader(), &QHeaderView::sectionResized, this, &Table::onSectionResized); + horizontalHeader()->installEventFilter(this); +} +bool Table::eventFilter(QObject *watched, QEvent *event) { + if(isSectionResized && event->type()==QEvent::Leave && watched==horizontalHeader()) { + isSectionResized = false; + QTableWidgetItem *item; + for(int cc=0; ccdata(WidthRole).isValid()) item->setData(WidthRole, horizontalHeader()->sectionSize(cc)); + } + return QTableWidget::eventFilter(watched, event); +} void Table::resizeEvent(QResizeEvent *event) { QTableWidget::resizeEvent(event); if(noStretch || event->size().width() == event->oldSize().width()) return; - resizeSec(); + adjSections(-1, 0); } - -void Table::resizeSec() { - auto header = horizontalHeader(); - int colCnt = columnCount(), remainWidth = header->width(), stretchWidth = 0, secWidth; +void Table::onSectionResized(int logicalIndex, int oldSize, int newSize) { + if(blocked || noStretch || newSize==0 || oldSize==0) return; + if(! horizontalHeaderItem(logicalIndex)->data(WidthRole).isValid()) return; + if(adjSections(logicalIndex, newSize)) isSectionResized = true; +} +bool Table::adjSections(int index, int size) { QTableWidgetItem *item; - for(int cc=0; ccdata(0x99).toInt()) > 0) stretchWidth += secWidth; - else remainWidth -= header->sectionSize(cc); + int remain = horizontalHeader()->width() - size, stretchWidth = 0, width; + for(int cc=0; ccdata(WidthRole).toInt()) > 0) stretchWidth += width; + else remain -= horizontalHeader()->sectionSize(cc); } - if(remainWidth<=0 || stretchWidth==0) return; - for(int cc=0; ccdata(0x99).toInt()) > 0) header->resizeSection(cc, secWidth * remainWidth / stretchWidth); -} - -void Table::updateGeometries() { - QTableWidget::updateGeometries(); - emit updGeos(); + if(remain<=0 || stretchWidth==0) return false; + auto min = horizontalHeader()->minimumSectionSize(); + blocked = true; + for(int cc=0; ccdata(WidthRole).toInt()) > 0) horizontalHeader()->resizeSection(cc, qMax(min, width * remain / stretchWidth)); + blocked = false; + return true; } diff --git a/ledset/gutil/qgui.h b/ledset/gutil/qgui.h index 2ee4a52..1e05d41 100644 --- a/ledset/gutil/qgui.h +++ b/ledset/gutil/qgui.h @@ -11,6 +11,7 @@ #include #include #include +#include #define MainMust \ #if(QT_VERSION_MAJOR > 5) \ @@ -41,7 +42,7 @@ inline int SetCurData(QComboBox *combo, const QVariant &data) { if(idx>-1) combo->setCurrentIndex(idx); return idx; } -inline int SetCurText(QComboBox *combo, const QString &text) { +inline int SetCurText(QComboBox *combo, const QString& text) { auto idx = combo->findText(text); if(idx>-1) combo->setCurrentIndex(idx); return idx; @@ -53,7 +54,7 @@ inline void gFont(QWidget *wgt, int size, bool bold = false, bool italic = false if(italic) ft.setItalic(true); wgt->setFont(ft); } -inline void gFont(QWidget *wgt, const QString &family, int size = 0, bool bold = false, bool italic = false) { +inline void gFont(QWidget *wgt, const QString& family, int size = 0, bool bold = false, bool italic = false) { auto ft = wgt->font(); ft.setFamily(family); if(size) ft.setPixelSize(size); @@ -61,14 +62,14 @@ inline void gFont(QWidget *wgt, const QString &family, int size = 0, bool bold = if(italic) ft.setItalic(true); wgt->setFont(ft); } -inline QFont qfont(const QString &family, int pixelSize, bool bold = false, bool italic = false) { +inline QFont qfont(const QString& family, int pixelSize, bool bold = false, bool italic = false) { QFont ft(family); ft.setPixelSize(pixelSize); if(bold) ft.setBold(true); if(italic) ft.setItalic(true); return ft; } -inline void gAppendText(QTextEdit *wgt, const QString &text, const QColor &color) { +inline void gAppendText(QTextEdit *wgt, const QString& text, const QColor &color) { auto c0 = wgt->textColor(); wgt->setTextColor(color); wgt->append(text); @@ -77,29 +78,29 @@ inline void gAppendText(QTextEdit *wgt, const QString &text, const QColor &color class VBox : public QBoxLayout { public: - inline VBox(QWidget *parent=nullptr) : QBoxLayout(TopToBottom, parent) {} - inline VBox(QBoxLayout *parent) : QBoxLayout(TopToBottom) { + VBox(QWidget *parent=nullptr) : QBoxLayout(TopToBottom, parent) {} + VBox(QBoxLayout *parent) : QBoxLayout(TopToBottom) { parent->addLayout(this); }; - inline VBox(QStackedLayout *stack) : QBoxLayout(TopToBottom, new QWidget) { + VBox(QStackedLayout *stack) : QBoxLayout(TopToBottom, new QWidget) { stack->addWidget(parentWidget()); setContentsMargins(0,0,0,0); }; - inline VBox(QSplitter *splitter) : QBoxLayout(TopToBottom, new QWidget) { + VBox(QSplitter *splitter) : QBoxLayout(TopToBottom, new QWidget) { splitter->addWidget(parentWidget()); setContentsMargins(0,0,0,0); }; - inline QLabel *addLabel() { + QLabel *addLabel() { auto lb = new QLabel; addWidget(lb); return lb; } - inline QLabel *addLabel(const QString &text) { + QLabel *addLabel(const QString& text) { auto lb = new QLabel(text); addWidget(lb); return lb; } - inline QDialogButtonBox *addBtnBox(QDialog *dlg = 0) { + QDialogButtonBox *addBtnBox(QDialog *dlg = 0) { auto btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); if(dlg) connect(btnBox, &QDialogButtonBox::rejected, dlg, &QDialog::reject); addWidget(btnBox); @@ -108,24 +109,24 @@ public: }; class HBox : public QBoxLayout { public: - inline HBox(QWidget *parent=nullptr) : QBoxLayout(LeftToRight, parent) {} - inline HBox(QBoxLayout *parent) : QBoxLayout(LeftToRight) { + HBox(QWidget *parent=nullptr) : QBoxLayout(LeftToRight, parent) {} + HBox(QBoxLayout *parent) : QBoxLayout(LeftToRight) { parent->addLayout(this); }; - inline HBox(QStackedLayout *stack) : QBoxLayout(LeftToRight, new QWidget) { + HBox(QStackedLayout *stack) : QBoxLayout(LeftToRight, new QWidget) { stack->addWidget(parentWidget()); setContentsMargins(0,0,0,0); }; - inline HBox(QSplitter *splitter) : QBoxLayout(LeftToRight, new QWidget) { + HBox(QSplitter *splitter) : QBoxLayout(LeftToRight, new QWidget) { splitter->addWidget(parentWidget()); setContentsMargins(0,0,0,0); }; - inline QLabel *addLabel() { + QLabel *addLabel() { auto lb = new QLabel; addWidget(lb); return lb; } - inline QLabel *addLabel(const QString &text) { + QLabel *addLabel(const QString& text) { auto lb = new QLabel(text); addWidget(lb); return lb; @@ -134,16 +135,16 @@ public: class Grid : public QGridLayout { public: using QGridLayout::QGridLayout; - inline Grid(QBoxLayout *parent) { + Grid(QBoxLayout *parent) { parent->addLayout(this); }; - inline Grid(QStackedLayout *stack) : QGridLayout(new QWidget) { + Grid(QStackedLayout *stack) : QGridLayout(new QWidget) { stack->addWidget(parentWidget()); }; - inline Grid(QSplitter *splitter) : QGridLayout(new QWidget) { + Grid(QSplitter *splitter) : QGridLayout(new QWidget) { splitter->addWidget(parentWidget()); }; - inline QLabel *addLabel(const QString &text) { + QLabel *addLabel(const QString& text) { auto lb = new QLabel(text); addWidget(lb); return lb; @@ -155,7 +156,7 @@ public: using QListWidget::QListWidget; using QListWidget::addItem; - inline auto addItem(const QString &text, const QVariant &value) { + auto addItem(const QString& text, const QVariant &value) { auto item = new QListWidgetItem(text); item->setData(Qt::UserRole, value); insertItem(count(), item); @@ -164,13 +165,198 @@ public: }; struct ColAttr { - ColAttr(QString field, QString text, int width=0, QHeaderView::ResizeMode resizeMode = QHeaderView::Interactive) : field(field), text(text), width(width), resizeMode(resizeMode) {} - ColAttr(QString field, QString text, QHeaderView::ResizeMode resizeMode) : field(field), text(text), resizeMode(resizeMode) {} + ColAttr(const QString& field, const QString& text, int width=0, QHeaderView::ResizeMode resizeMode = QHeaderView::Interactive) : field(field), text(text), width(width), resizeMode(resizeMode) {} + ColAttr(const QString& field, const QString& text, QHeaderView::ResizeMode resizeMode) : field(field), text(text), resizeMode(resizeMode) {} QString field; QString text; int width{0}; QHeaderView::ResizeMode resizeMode; }; +enum TableItemDataRole { + FieldRole = 0xfe, + WidthRole +}; + +int operator*(const QString& key, QTreeView &table); +int operator*(const char *key, QTreeView &table); + +class TreeWidgetItem : public QTreeWidgetItem { +public: + using QTreeWidgetItem::QTreeWidgetItem; + + using QTreeWidgetItem::checkState; + auto checkState(const QString& column) { + return checkState(column**treeWidget()); + } + using QTreeWidgetItem::setCheckState; + auto setCheckState(const QString& column, Qt::CheckState state) { + setCheckState(column**treeWidget(), state); + return this; + } + + using QTreeWidgetItem::text; + auto text(const QString& column) { + return text(column**treeWidget()); + } + using QTreeWidgetItem::setText; + auto setText(const QString& column, const QString& text) { + setText(column**treeWidget(), text); + return this; + } + auto setText(const QString& column, const QString& text, const QVariant &value) { + auto idx = column**treeWidget(); + setText(idx, text); + setData(idx, Qt::UserRole, value); + return this; + } + + using QTreeWidgetItem::background; + auto background(const QString& column) { + return background(column**treeWidget()); + } + using QTreeWidgetItem::setBackground; + auto setBackground(const QString& column, const QBrush &brush) { + setBackground(column**treeWidget(), brush); + return this; + } + using QTreeWidgetItem::foreground; + auto foreground(const QString& column) { + return foreground(column**treeWidget()); + } + using QTreeWidgetItem::setForeground; + auto setForeground(const QString& column, const QBrush &brush) { + setForeground(column**treeWidget(), brush); + return this; + } + + using QTreeWidgetItem::data; + auto data(int col) { + return data(col, Qt::UserRole); + } + auto data(const QString& column, int role = Qt::UserRole) { + return data(column**treeWidget(), role); + } + using QTreeWidgetItem::setData; + auto setData(int col, const QVariant &value) { + setData(col, Qt::UserRole, value); + return this; + } + auto setData(const QString& column, const QVariant &value) { + setData(column**treeWidget(), Qt::UserRole, value); + return this; + } + auto setData(const QString& column, int role, const QVariant &value) { + setData(column**treeWidget(), role, value); + return this; + } + + auto itemWidget(int column) { + return treeWidget()->itemWidget(this, column); + } + auto itemWidget(const QString& column) { + return treeWidget()->itemWidget(this, column**treeWidget()); + } + auto setItemWidget(int column, QWidget *widget) { + treeWidget()->setItemWidget(this, column, widget); + return this; + } + auto setItemWidget(const QString& column, QWidget *widget) { + treeWidget()->setItemWidget(this, column**treeWidget(), widget); + return this; + } +}; + +class TreeWidget : public QTreeWidget { + Q_OBJECT +public: + using QTreeWidget::QTreeWidget; + TreeWidget(std::initializer_list colAttrs, QWidget *parent = 0); + + auto setDefs() { + setIndentation(0); + setAlternatingRowColors(true); + header()->setStretchLastSection(false); + return this; + } + + auto setColFit() { + header()->setSectionResizeMode(QHeaderView::ResizeToContents); + return this; + } + auto setColWidth(int value, QHeaderView::ResizeMode mode = QHeaderView::Interactive) { + header()->setDefaultSectionSize(value); + if(mode!=QHeaderView::Interactive) header()->setSectionResizeMode(mode); + return this; + } + + auto setHeaderText(const QString& column, const QString& text) { + headerItem()->setText(fdmap.at(column), text); + return this; + } + + using QTreeWidget::showColumn; + auto showColumn(const QString& column) { + showColumn(fdmap.at(column)); + return this; + } + using QTreeWidget::hideColumn; + auto hideColumn(const QString& column) { + hideColumn(fdmap.at(column)); + return this; + } + + TreeWidgetItem *item(int idx) const { + return (TreeWidgetItem*) topLevelItem(idx); + } + TreeWidgetItem *selectedItem() const { + auto is = selectedItems(); + return is.isEmpty() ? 0 : (TreeWidgetItem*) is.at(0); + } + TreeWidgetItem *curItem() const { + return (TreeWidgetItem*) currentItem(); + } + + using QTreeWidget::itemWidget; + auto itemWidget(QTreeWidgetItem *item, const QString& column) { + return itemWidget(item, fdmap.at(column)); + } + using QTreeWidget::setItemWidget; + auto setItemWidget(QTreeWidgetItem *item, const QString& column, QWidget *widget) { + setItemWidget(item, fdmap.at(column), widget); + return this; + } + + QString field(int column) const { + return headerItem()->data(column, FieldRole).toString(); + } + QString sortField() const { + return field(sortColumn()); + } + using QTreeWidget::sortItems; + void sortItems(const QString& column, Qt::SortOrder order = Qt::AscendingOrder) { + sortItems(fdmap.at(column), order); + } + + std::unordered_map fdmap; + bool hasRowNum = false; + bool hasGrid = true; +signals: + void updGeos(); +protected: + bool eventFilter(QObject *watched, QEvent *event) override; + void resizeEvent(QResizeEvent *event) override; + void updateGeometries() override { + QTreeWidget::updateGeometries(); + emit updGeos(); + }; + void drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const override; + void onSectionResized(int logicalIndex, int oldSize, int newSize); + bool adjSections(int index, int size); + bool noStretch = true; + bool isSectionResized = false; + bool blocked = false; +}; + class Table : public QTableWidget { Q_OBJECT public: @@ -178,158 +364,166 @@ public: Table() {} Table(std::initializer_list colAttrs, int rows = 0, QWidget *parent = 0); - inline auto setDefs() { + auto setDefs() { setSelectionBehavior(QTableWidget::SelectRows); setEditTriggers(QAbstractItemView::NoEditTriggers); setAlternatingRowColors(true); return this; } - inline auto setColStretch() { + auto setColStretch() { horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); return this; } - inline auto setRowStretch() { + auto setRowStretch() { verticalHeader()->setSectionResizeMode(QHeaderView::Stretch); return this; } - inline auto setColFit() { + auto setColFit() { horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); return this; } - inline auto setRowFit() { + auto setRowFit() { verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); return this; } - inline auto setColWidth(int value, QHeaderView::ResizeMode mode = QHeaderView::Interactive) { - auto header = horizontalHeader(); - header->setDefaultSectionSize(value); - if(mode!=QHeaderView::Interactive) header->setSectionResizeMode(mode); + auto setColWidth(int value) { + if(horizontalHeader()->minimumSectionSize() > value) horizontalHeader()->setMinimumSectionSize(value); + horizontalHeader()->setDefaultSectionSize(value); return this; } - inline auto setRowHeight(int value, QHeaderView::ResizeMode mode = QHeaderView::Interactive) { - auto header = verticalHeader(); - header->setDefaultSectionSize(value); - if(mode!=QHeaderView::Interactive) header->setSectionResizeMode(mode); + auto setColResize(QHeaderView::ResizeMode mode) { + horizontalHeader()->setSectionResizeMode(mode); + return this; + } + auto setRowHeight(int value) { + if(verticalHeader()->minimumSectionSize() > value) verticalHeader()->setMinimumSectionSize(value); + verticalHeader()->setDefaultSectionSize(value); + return this; + } + auto setRowResize(QHeaderView::ResizeMode mode) { + verticalHeader()->setSectionResizeMode(mode); return this; } - inline auto setHeaderText(int col, QString text) { + auto setHeaderText(int col, const QString& text) { auto item = horizontalHeaderItem(col); if(item==0) setHorizontalHeaderItem(col, item = new QTableWidgetItem()); item->setText(text); return item; } - inline auto setHeaderText(QString column, QString text) { - auto col = mFieldMap[column]; - return setHeaderText(col, text); + auto setHeaderText(const QString& column, const QString& text) { + return setHeaderText(fdmap.at(column), text); } - inline auto setVHeaderText(int row, QString text) { + auto setVHeaderText(int row, const QString& text) { auto item = verticalHeaderItem(row); if(item==0) setVerticalHeaderItem(row, item = new QTableWidgetItem()); item->setText(text); return item; } - inline auto appendRow() { + auto appendRow() { auto value = rowCount(); setRowCount(value + 1); return value; } using QTableWidget::item; - inline auto item(int row, QString column) { - auto col = mFieldMap[column]; - return item(row, col); + auto item(int row, const QString& column) { + return item(row, fdmap.at(column)); } - inline auto itemValid(int row, int col) { - auto anitem = item(row, col); - if(anitem==0) setItem(row, col, anitem = new QTableWidgetItem); - return anitem; + auto itemValid(int row, int col) { + auto itm = item(row, col); + if(itm==0) setItem(row, col, itm = new QTableWidgetItem); + return itm; } - inline auto itemValid(int row, QString column) { - auto col = mFieldMap[column]; - return itemValid(row, col); + auto itemValid(int row, const QString& column) { + return itemValid(row, fdmap.at(column)); } using QTableWidget::setItem; - inline void setItem(int row, QString column, QTableWidgetItem *item) { - auto col = mFieldMap[column]; - setItem(row, col, item); + void setItem(int row, const QString& column, QTableWidgetItem *item) { + setItem(row, fdmap.at(column), item); } - inline auto text(int row, int col) { + auto text(int row, int col) { auto itm = item(row, col); if(itm==0) return QString(); return itm->text(); } - inline auto text(int row, QString column) { - auto col = mFieldMap[column]; - return text(row, col); + auto text(int row, const QString& column) { + return text(row, fdmap.at(column)); } - inline auto setText(int row, int col, const QString &text) { + auto setText(int row, int col, const QString& text) { auto itm = item(row, col); if(itm) itm->setText(text); else setItem(row, col, itm = new QTableWidgetItem(text)); return itm; } - inline auto setText(int row, QString column, const QString &text) { - auto col = mFieldMap[column]; - return setText(row, col, text); + auto setText(int row, const QString& column, const QString& text) { + return setText(row, fdmap.at(column), text); + } + auto setText(int row, int col, const QString& text, const QVariant &value) { + auto itm = item(row, col); + if(itm) itm->setText(text); + else setItem(row, col, itm = new QTableWidgetItem(text)); + itm->setData(Qt::UserRole, value); + return itm; + } + auto setText(int row, const QString& column, const QString& text, const QVariant &value) { + return setText(row, fdmap.at(column), text, value); } - inline auto data(int row, int col) { + auto data(int row, int col) { auto itm = item(row, col); if(itm==0) return QVariant(); return itm->data(Qt::UserRole); } - inline auto data(int row, QString column) { - auto col = mFieldMap[column]; - return data(row, col); + auto data(int row, const QString& column) { + return data(row, fdmap.at(column)); } - inline auto setData(int row, int col, const QVariant &value) { + auto setData(int row, int col, const QVariant &value) { auto itm = item(row, col); if(itm==0) setItem(row, col, itm = new QTableWidgetItem); itm->setData(Qt::UserRole, value); return itm; } - inline auto setData(int row, QString column, const QVariant &value) { - auto col = mFieldMap[column]; - return setData(row, col, value); + auto setData(int row, const QString& column, const QVariant &value) { + return setData(row, fdmap.at(column), value); } using QTableWidget::cellWidget; - inline auto cellWidget(int row, QString column) { - auto col = mFieldMap[column]; - return cellWidget(row, col); + auto cellWidget(int row, const QString& column) { + return cellWidget(row, fdmap.at(column)); } using QTableWidget::setCellWidget; - inline void setCellWidget(int row, QString column, QWidget *widget) { - auto col = mFieldMap[column]; - setCellWidget(row, col, widget); + void setCellWidget(int row, const QString& column, QWidget *widget) { + setCellWidget(row, fdmap.at(column), widget); } - std::map mFieldMap; + using QTableWidget::sortItems; + void sortItems(const QString& column, Qt::SortOrder order) { + sortItems(fdmap.at(column), order); + } + + std::unordered_map fdmap; public Q_SLOTS: - inline void clearRows() {setRowCount(0);} + void clearRows() {setRowCount(0);} signals: void updGeos(); protected: + bool eventFilter(QObject *watched, QEvent *event) override; void resizeEvent(QResizeEvent *event) override; - void updateGeometries() override; - void resizeSec(); - bool noStretch{true}; -}; - -class ResizeEmitedWgt : public QWidget { - Q_OBJECT -public: - using QWidget::QWidget; -protected: - void resizeEvent(QResizeEvent *) override {emit resized();} -signals: - void resized(); + void updateGeometries() override { + QTableWidget::updateGeometries(); + emit updGeos(); + }; + void onSectionResized(int logicalIndex, int oldSize, int newSize); + bool adjSections(int index, int size); + bool noStretch = true; + bool isSectionResized = false; + bool blocked = false; }; @@ -340,43 +534,43 @@ public: Wrp(T *obj = nullptr){ this->obj = obj; }; - inline Wrp& operator()(T *obj){ + Wrp& operator()(T *obj){ this->obj = obj; return *this; } - inline Wrp& operator()(T *obj, QLayout *layout){ + Wrp& operator()(T *obj, QLayout *layout){ this->obj = obj; layout->addWidget(obj); return *this; } - inline Wrp& addTo(QLayout *layout){ + Wrp& addTo(QLayout *layout){ layout->addWidget(obj); return *this; } - inline Wrp& margin(int a){ + Wrp& margin(int a){ obj->setMargin(a); return *this; } - inline Wrp& font(const QFont &font){ + Wrp& font(const QFont &font){ obj->setFont(font); return *this; } - inline Wrp& font(int size){ + Wrp& font(int size){ auto font = obj->font(); font.setPixelSize(size); obj->setFont(font); return *this; } - inline Wrp& width(int w){ + Wrp& width(int w){ obj->setFixedWidth(w); return *this; } - inline Wrp& height(int h){ + Wrp& height(int h){ obj->setFixedHeight(h); return *this; } - inline Wrp& padding(int wAdd, int hAdd, int minW = 32, int minH = 16){ + Wrp& padding(int wAdd, int hAdd, int minW = 32, int minH = 16){ wAdd+=8; hAdd+=8; QSize size = obj->fontMetrics().size(Qt::TextShowMnemonic, obj->text()); @@ -390,11 +584,11 @@ public: return *this; } - inline Wrp& alignC(){ + Wrp& alignC(){ obj->setAlignment(Qt::AlignCenter); return *this; } - inline Wrp& alignR(){ + Wrp& alignR(){ obj->setAlignment(Qt::AlignRight); return *this; } diff --git a/ledset/gutil/qjson.h b/ledset/gutil/qjson.h index 48f1662..10f822e 100644 --- a/ledset/gutil/qjson.h +++ b/ledset/gutil/qjson.h @@ -13,7 +13,7 @@ class JValue { public: int data[2]{0}; enum Type { - Null, Bool, Int, Long, Double, Obj, Array, Str + Null, Bool, Int, Long, Ulong, Double, Obj, Array, Str }; Type type{Null}; @@ -21,6 +21,7 @@ public: JValue(bool b) : type(Bool) {data[0] = b;} JValue(int n) : type(Int) {data[0] = n;} JValue(qint64 n) : type(Long) {*(qint64*) data = n;} + JValue(quint64 n) : type(Ulong) {*(quint64*) data = n;} JValue(double d) : type(Double) {*(double*) data = d;} JValue(const JObj &o) : type(Obj) {new (data) JObj(o);} JValue(const JArray &a) : type(Array) {new (data) JArray(a);} @@ -61,29 +62,33 @@ public: return type==Null ? def : data[0] || data[1]; } int toInt(int def = 0) const { - if(type==Bool || type==Int) return data[0]; - if(type==Long) return *(qint64*) data; + if(type==Int || type==Bool) return data[0]; if(type==Double) return *(double*) data; + if(type==Long) return *(qint64*) data; + if(type==Ulong) return *(quint64*) data; return def; } qint64 toLong(qint64 def = 0) const { - if(type==Bool || type==Int) return data[0]; if(type==Long) return *(qint64*) data; + if(type==Ulong) return *(quint64*) data; + if(type==Int || type==Bool) return data[0]; if(type==Double) return *(double*) data; return def; } double toDouble(double def = 0) const { - if(type==Bool || type==Int) return data[0]; - if(type==Long) return *(qint64*) data; if(type==Double) return *(double*) data; + if(type==Int || type==Bool) return data[0]; + if(type==Long) return *(qint64*) data; + if(type==Ulong) return *(quint64*) data; return def; } QString toStr(const QString &def = "") const { - if(type==Bool) return data[0] ? "true" : "false"; - if(type==Int) return QString::number(data[0]); - if(type==Long) return QString::number(*(qint64*) data); - if(type==Double) return QString::number(*(double*) data); if(type==Str) return (*(SharedData**) data)->data; + if(type==Int) return QString::number(data[0]); + if(type==Double) return QString::number(*(double*) data); + if(type==Bool) return data[0] ? "true" : "false"; + if(type==Long) return QString::number(*(qint64*) data); + if(type==Ulong) return QString::number(*(quint64*) data); return def; } JObj toObj() const { diff --git a/ledset/ledset.pro b/ledset/ledset.pro index 830cedb..41ed87f 100644 --- a/ledset/ledset.pro +++ b/ledset/ledset.pro @@ -32,11 +32,14 @@ win32 { copydir.files += translations +copy.files += $$files(files/*.ic) win32 { EXE_SUFFIX = .exe + copy.path = $$OUT_PWD copydir.path = $$OUT_PWD CONFIG += file_copies + COPIES += copy COPIES += copydir } osx { @@ -61,6 +64,7 @@ SOURCES += \ crc.c \ expertboxlayoutwin.cpp \ expertscreenconnwin.cpp \ + expertsendpanel.cpp \ expertsmartpointsetwin.cpp \ expertwin.cpp \ fast.cpp \ @@ -71,7 +75,6 @@ SOURCES += \ main.cpp \ mainwin.cpp \ pcaprethread.cpp \ - screenunit.cpp \ testwin.cpp \ videowin.cpp \ waitingdlg.cpp @@ -83,6 +86,7 @@ HEADERS += \ efffrefr.h \ expertboxlayoutwin.h \ expertscreenconnwin.h \ + expertsendpanel.h \ expertsmartpointsetwin.h \ expertwin.h \ fast.h \ @@ -92,7 +96,6 @@ HEADERS += \ gutil/qjson.h \ mainwin.h \ pcaprethread.h \ - screenunit.h \ testwin.h \ videowin.h \ waitingdlg.h diff --git a/ledset/mainwin.cpp b/ledset/mainwin.cpp index b93ce7e..e928e95 100644 --- a/ledset/mainwin.cpp +++ b/ledset/mainwin.cpp @@ -93,7 +93,9 @@ MainWin::MainWin() { }); btnImg = addImg(imgsBar, QPixmap(":/imgs/expert.png").scaledToWidth(128, Qt::SmoothTransformation), tr("专家调屏")); connect(btnImg, &ImgBtn::clicked, this, [=] { - (new ExpertWin(this, (enum_rcvCardType) table->data(table->currentRow(), "type").toInt()))->show(); + auto item = table->selectedItem(); + if(item) (new ExpertWin(this, (enum_rcvCardType) item->data("type").toInt()))->show(); + else if(QMessageBox::question(this, "Info", tr("未选择卡, 是否继续?"))==QMessageBox::Yes) (new ExpertWin(this, NoCard))->show(); }); btnImg = addImg(imgsBar, QPixmap(":/imgs/bright.png").scaledToWidth(128, Qt::SmoothTransformation), tr("亮度控制")); connect(btnImg, &ImgBtn::clicked, this, [=] { @@ -125,7 +127,8 @@ MainWin::MainWin() { vBox->addSpacing(9); vBox->addWidget(new QLabel(" 硬件信息")); - table = new Table{ + table = new TreeWidget{ + {"_num_", "", 20}, {"type", "控制系统类型"}, {"name", "名称"}, {"link", "连接方式"}, @@ -133,8 +136,10 @@ MainWin::MainWin() { {"netPorts", "网口统计P1~Pn"}, {"info", "其他信息", QHeaderView::Stretch}, }; - table->verticalHeader()->setMinimumWidth(20);//added by alahover 20230822 table->setDefs(); + table->setSortingEnabled(true); + table->sortItems("name"); + table->setStyleSheet("TreeWidget::item{height: 26px;}"); vBox->addWidget(table); auto hBox = new HBox(vBox); @@ -201,7 +206,6 @@ MainWin::MainWin() { bool ok = true; if(senderAddress.protocol()==QUdpSocket::IPv6Protocol) senderAddress.setAddress(senderAddress.toIPv4Address(&ok)); auto addr = ok ? senderAddress.toString() : ""; - int cnt = table->rowCount(); if(data.startsWith("{\"")) { QString error; auto json = JFrom(gram.data(), &error); @@ -210,56 +214,50 @@ MainWin::MainWin() { continue; } auto cardId = json["cardId"].toStr(); - for(int rr=0; rrtext(rr, "name")==cardId) { - table->setText(rr, "link", addr); + TreeWidgetItem *item; + for(int rr=0; rrtopLevelItemCount(); rr++) if((item = table->item(rr))->text("name")==cardId) { + item->setText("link", addr); goto end; } - table->setRowCount(cnt+1); - table->setData(cnt, "type", enum_xixun_async)->setText(tr("异步卡"));//added by alahover 20230822 - table->setText(cnt, "name", cardId); - table->setText(cnt, "link", addr); + item = new TreeWidgetItem(table); + item->setText("type", tr("异步卡"), enum_xixun_async); + item->setText("name", cardId); + item->setText("link", addr); } else { auto bytes = gram.data(); auto packet = (UDPPacket *)bytes.data(); - for(int rr=0; rrtext(rr, "name")==packet->serialCode) { - table->setText(rr, "link", addr); + TreeWidgetItem *item; + for(int rr=0; rrtopLevelItemCount(); rr++) if((item = table->item(rr))->text("name")==packet->serialCode) { + item->setText("link", addr); goto end; } - table->setRowCount(cnt+1); - table->setData(cnt, "type", enum_xixun_async)->setText(tr("异步卡")); - table->setText(cnt, "name", packet->serialCode); - table->setText(cnt, "link", addr); + item = new TreeWidgetItem(table); + item->setText("type", tr("异步卡"), enum_xixun_async); + item->setText("name", packet->serialCode); + item->setText("link", addr); } end:; } }); reThd->addMultiCallback(0x105B14, [=](int, const QByteArray data) { - auto rr = table->rowCount(); unsigned short ver = *(quint16_be *)(data.data()+headMap_zrf.protcolFlag); unsigned char pkgType = *(quint8 *)(data.data()+headMap_zrf.pkgType); if(ver!=0x105B || pkgType != 0x14) return; auto strDeviceName = QString(QLatin1String(data.data()+headMap_zrf.paramStart+st_zrf_rb_param.deviceName, 9)); - for(int i=0;itext(i,1)==strDeviceName) { - rr = i; - goto end; - } - table->setRowCount(rr+1); + TreeWidgetItem *item; + for(int i=0; itopLevelItemCount(); i++) if((item = table->item(i))->text("name")==strDeviceName) goto end; + item = new TreeWidgetItem(table); end: - char cDevicaNameVer[8]; - memcpy(cDevicaNameVer,(char *)data.data()+headMap_zrf.paramStart+st_zrf_rb_param.deviceVer,8); - QString strDeviceVer = QString(QLatin1String(cDevicaNameVer)); - strDeviceVer=strDeviceVer.left(8); - - int virtualVCM = *(quint8*)(data.data()+headMap_zrf.netPort)+1; - int rcvIdex = *(quint8*)(data.data()+headMap_zrf.rcvIndex)+1; + int virtualVCM = *(quint8*)(data.data()+headMap_zrf.netPort) + 1; + int rcvIdex = *(quint8*)(data.data()+headMap_zrf.rcvIndex) + 1; if(rcvIdex > maxNetPort_zrf) maxNetPort_zrf = rcvIdex; - table->setData(rr, "type", enum_zrf)->setText(tr("PC虚拟卡V1.0")); - table->setText(rr, "name", strDeviceName); - table->setText(rr, "link", "千兆网直连"); - table->setText(rr, "vcsNum", QString::number(maxNetPort_zrf)); - table->setText(rr, "netPorts", "P:"+QString::number(virtualVCM)); - table->setText(rr, "info", "版本: "+strDeviceVer+" [备注:可直接配屏,无需发送卡]"); - if(rr==0) table->selectRow(0); + item->setText("type", tr("PC虚拟卡V1.0"), enum_zrf); + item->setText("name", strDeviceName); + item->setText("link", "千兆网直连"); + item->setText("vcsNum", QString::number(maxNetPort_zrf)); + item->setText("netPorts", "P: "+QString::number(virtualVCM)); + item->setText("info", "版本: "+QLatin1String(data.data()+headMap_zrf.paramStart+st_zrf_rb_param.deviceVer, 8)+" [备注:可直接配屏,无需发送卡]"); + if(table->selectedItem()==0) item->setSelected(true); }); getCard(); } @@ -270,22 +268,22 @@ MainWin::~MainWin() { } void MainWin::getCard() { - table->setRowCount(0); + table->clear(); auto msg = QByteArray::fromHex("5555 01 0D 0008 FFFFFFFF 0000ABCD A0000000 0000 38CB847E 00000000 0000ABCD CD040446"); auto res = sendMsg(msg, 0x1E0, 10000, [=](int, const QByteArray data) { if(*(quint32_be*)(data.data()+headMap.ptr) != 0xA0000000) return; - auto rr = table->rowCount(); - table->setRowCount(rr+1); + auto item = new TreeWidgetItem(table); int virtualVCM = *(quint16_be*)(data.data()+headMap.srcAddr); //modified by alahover -s 20230822 auto ver = *(byte*)(data.data()+headMap.ver); - if(ver==0x01) table->setData(rr, "type", enum_xixun_sync)->setText(tr("PC虚拟卡V0.0")); - else if(ver==0x58) table->setData(rr, "type", enum_zrf)->setText(tr("PC虚拟卡V1.0")); - table->setText(rr, "name", tr("网口:")+QString::number(virtualVCM)); - table->setText(rr, "link", "千兆网直连"); - table->setText(rr, "vcsNum", QString::number(*(quint32_be*)(data.data()+headMap.body))); - table->setText(rr, "netPorts", "P:"+QString::number(virtualVCM)); - table->setText(rr, "info", "备注:可直接配屏,无需发送卡"); + if(ver==0x01) item->setText("type", tr("PC虚拟卡V0.0"), enum_xixun_sync); + else if(ver==0x58) item->setText("type", tr("PC虚拟卡V1.0"), enum_zrf); + item->setText("name", QString::number(virtualVCM)+" (网口)"); + item->setText("link", "千兆网直连"); + item->setText("vcsNum", QString::number(*(quint32_be*)(data.data()+headMap.body))); + item->setText("netPorts", "P: "+QString::number(virtualVCM)); + item->setText("info", "备注: 可直接配屏,无需发送卡"); + if(table->selectedItem()==0) item->setSelected(true); }); if(res) { QString err = pcap_geterr(pcapSend); diff --git a/ledset/mainwin.h b/ledset/mainwin.h index afc020c..cbd71c4 100644 --- a/ledset/mainwin.h +++ b/ledset/mainwin.h @@ -12,7 +12,7 @@ public: ~MainWin(); QWidget *win{0}; QByteArray net_name; - Table *table{0}; + TreeWidget *table; QUdpSocket mUdpSocket; int maxNetPort_zrf = 0; diff --git a/ledset/screenunit.h b/ledset/screenunit.h deleted file mode 100644 index 5fbc2de..0000000 --- a/ledset/screenunit.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef SCREENUNIT_H -#define SCREENUNIT_H - -#include -#include -#include - -#define m_handleLen 10 -class ExpertWin; -class ScreenUnit : public QWidget { - Q_OBJECT -public: - explicit ScreenUnit(ExpertWin *, const QString &name, int x, int y, int w, int h, QWidget *parent = nullptr); - - ExpertWin *expertWin{0}; - QString name; - int mX, mY, mW, mH; -protected: - void paintEvent(QPaintEvent *) override; - void mousePressEvent(QMouseEvent *) override; - void mouseReleaseEvent(QMouseEvent *) override; - void mouseMoveEvent(QMouseEvent *) override; - void leaveEvent(QEvent *) override; - - void setFrmSec(const QPoint &); - void setFrmSecIfNeed(Qt::WindowFrameSection frmSec, Qt::CursorShape cursor); - void clearSnap(); - QPen mSidePen{Qt::white}; - - QPoint mPressRel{INT_MIN, INT_MIN}; - Qt::WindowFrameSection mFrmSec{Qt::NoSection}; - char mLRSnap{0}, mTBSnap{0}; - QList mOtherEles; - -}; - -#endif // SCREENUNIT_H