From 8fd8ff446b2014a37063e7e5448ec7973ff42c85 Mon Sep 17 00:00:00 2001 From: gangphon Date: Fri, 7 Jan 2022 18:22:58 +0800 Subject: [PATCH] =?UTF-8?q?ledok=E5=A2=9E=E5=8A=A0=E8=BE=B9=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LedOK/LedOK.pro | 12 +- LedOK/LoQClass/loqgraphicsobject.cpp | 578 ----------------- LedOK/LoQClass/loqgraphicsobject.h | 117 ---- LedOK/LoQClass/loqheaderviewcheckbox.cpp | 4 - LedOK/images.qrc | 74 +++ LedOK/res/borders/M1_0.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M1_1.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M1_2.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M1_3.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M1_4.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M1_5.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M1_6.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M1_7.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M1_8.bmp | Bin 0 -> 248 bytes LedOK/res/borders/M2_0.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M2_1.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M2_2.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M2_3.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M2_4.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M2_5.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M2_6.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M2_7.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M2_8.bmp | Bin 0 -> 440 bytes LedOK/res/borders/M3_0.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M3_1.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M3_2.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M3_3.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M3_4.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M3_5.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M3_6.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M3_7.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M3_8.bmp | Bin 0 -> 632 bytes LedOK/res/borders/M4_0.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M4_1.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M4_2.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M4_3.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M4_4.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M4_5.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M4_6.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M4_7.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M4_8.bmp | Bin 0 -> 824 bytes LedOK/res/borders/M5_0.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M5_1.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M5_2.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M5_3.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M5_4.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M5_5.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M5_6.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M5_7.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M5_8.bmp | Bin 0 -> 1016 bytes LedOK/res/borders/M6_0.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_1.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_2.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_3.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_4.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_5.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_6.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_7.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_8.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M6_9.bmp | Bin 0 -> 1208 bytes LedOK/res/borders/M7_0.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M7_1.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M7_2.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M7_3.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M7_4.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M7_5.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M7_6.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M7_7.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M7_8.bmp | Bin 0 -> 1400 bytes LedOK/res/borders/M8_0.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M8_1.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M8_2.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M8_3.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M8_4.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M8_5.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M8_6.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M8_7.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M8_8.bmp | Bin 0 -> 1592 bytes LedOK/res/borders/M9_0.bmp | Bin 0 -> 1784 bytes LedOK/wDevicesManager/wdevicesitem.cpp | 5 +- .../wEditProgram/wElement/eobject.cpp | 604 ++++++++++++++++-- .../wEditProgram/wElement/eobject.h | 121 +++- .../wEditProgram/wElement/eobjectattr.cpp | 60 +- .../wEditProgram/wElement/eobjectattr.h | 12 +- .../wEditProgram/wElement/eobjectattr.ui | 8 +- .../wEditProgram/wElement/ephoto.cpp | 2 +- .../wEditProgram/wElement/etext.cpp | 2 +- .../wEditProgram/wdrawingboard.cpp | 6 +- .../wEditProgram/wpageitem.cpp | 4 +- 89 files changed, 787 insertions(+), 822 deletions(-) delete mode 100644 LedOK/LoQClass/loqgraphicsobject.cpp delete mode 100644 LedOK/LoQClass/loqgraphicsobject.h create mode 100644 LedOK/res/borders/M1_0.bmp create mode 100644 LedOK/res/borders/M1_1.bmp create mode 100644 LedOK/res/borders/M1_2.bmp create mode 100644 LedOK/res/borders/M1_3.bmp create mode 100644 LedOK/res/borders/M1_4.bmp create mode 100644 LedOK/res/borders/M1_5.bmp create mode 100644 LedOK/res/borders/M1_6.bmp create mode 100644 LedOK/res/borders/M1_7.bmp create mode 100644 LedOK/res/borders/M1_8.bmp create mode 100644 LedOK/res/borders/M2_0.bmp create mode 100644 LedOK/res/borders/M2_1.bmp create mode 100644 LedOK/res/borders/M2_2.bmp create mode 100644 LedOK/res/borders/M2_3.bmp create mode 100644 LedOK/res/borders/M2_4.bmp create mode 100644 LedOK/res/borders/M2_5.bmp create mode 100644 LedOK/res/borders/M2_6.bmp create mode 100644 LedOK/res/borders/M2_7.bmp create mode 100644 LedOK/res/borders/M2_8.bmp create mode 100644 LedOK/res/borders/M3_0.bmp create mode 100644 LedOK/res/borders/M3_1.bmp create mode 100644 LedOK/res/borders/M3_2.bmp create mode 100644 LedOK/res/borders/M3_3.bmp create mode 100644 LedOK/res/borders/M3_4.bmp create mode 100644 LedOK/res/borders/M3_5.bmp create mode 100644 LedOK/res/borders/M3_6.bmp create mode 100644 LedOK/res/borders/M3_7.bmp create mode 100644 LedOK/res/borders/M3_8.bmp create mode 100644 LedOK/res/borders/M4_0.bmp create mode 100644 LedOK/res/borders/M4_1.bmp create mode 100644 LedOK/res/borders/M4_2.bmp create mode 100644 LedOK/res/borders/M4_3.bmp create mode 100644 LedOK/res/borders/M4_4.bmp create mode 100644 LedOK/res/borders/M4_5.bmp create mode 100644 LedOK/res/borders/M4_6.bmp create mode 100644 LedOK/res/borders/M4_7.bmp create mode 100644 LedOK/res/borders/M4_8.bmp create mode 100644 LedOK/res/borders/M5_0.bmp create mode 100644 LedOK/res/borders/M5_1.bmp create mode 100644 LedOK/res/borders/M5_2.bmp create mode 100644 LedOK/res/borders/M5_3.bmp create mode 100644 LedOK/res/borders/M5_4.bmp create mode 100644 LedOK/res/borders/M5_5.bmp create mode 100644 LedOK/res/borders/M5_6.bmp create mode 100644 LedOK/res/borders/M5_7.bmp create mode 100644 LedOK/res/borders/M5_8.bmp create mode 100644 LedOK/res/borders/M6_0.bmp create mode 100644 LedOK/res/borders/M6_1.bmp create mode 100644 LedOK/res/borders/M6_2.bmp create mode 100644 LedOK/res/borders/M6_3.bmp create mode 100644 LedOK/res/borders/M6_4.bmp create mode 100644 LedOK/res/borders/M6_5.bmp create mode 100644 LedOK/res/borders/M6_6.bmp create mode 100644 LedOK/res/borders/M6_7.bmp create mode 100644 LedOK/res/borders/M6_8.bmp create mode 100644 LedOK/res/borders/M6_9.bmp create mode 100644 LedOK/res/borders/M7_0.bmp create mode 100644 LedOK/res/borders/M7_1.bmp create mode 100644 LedOK/res/borders/M7_2.bmp create mode 100644 LedOK/res/borders/M7_3.bmp create mode 100644 LedOK/res/borders/M7_4.bmp create mode 100644 LedOK/res/borders/M7_5.bmp create mode 100644 LedOK/res/borders/M7_6.bmp create mode 100644 LedOK/res/borders/M7_7.bmp create mode 100644 LedOK/res/borders/M7_8.bmp create mode 100644 LedOK/res/borders/M8_0.bmp create mode 100644 LedOK/res/borders/M8_1.bmp create mode 100644 LedOK/res/borders/M8_2.bmp create mode 100644 LedOK/res/borders/M8_3.bmp create mode 100644 LedOK/res/borders/M8_4.bmp create mode 100644 LedOK/res/borders/M8_5.bmp create mode 100644 LedOK/res/borders/M8_6.bmp create mode 100644 LedOK/res/borders/M8_7.bmp create mode 100644 LedOK/res/borders/M8_8.bmp create mode 100644 LedOK/res/borders/M9_0.bmp diff --git a/LedOK/LedOK.pro b/LedOK/LedOK.pro index b4ff174..af729a2 100644 --- a/LedOK/LedOK.pro +++ b/LedOK/LedOK.pro @@ -42,7 +42,6 @@ SOURCES += \ LoQClass/locolorselector.cpp \ LoQClass/lodateselector.cpp \ LoQClass/loglwindow.cpp \ - LoQClass/loqgraphicsobject.cpp \ LoQClass/loqgraphicsvideoitem.cpp \ LoQClass/loqgraphicsview.cpp \ LoQClass/loqheaderviewcheckbox.cpp \ @@ -187,7 +186,6 @@ HEADERS += \ LoQClass/locolorselector.h \ LoQClass/lodateselector.h \ LoQClass/loglwindow.h \ - LoQClass/loqgraphicsobject.h \ LoQClass/loqgraphicsvideoitem.h \ LoQClass/loqgraphicsview.h \ LoQClass/loqheaderviewcheckbox.h \ @@ -401,6 +399,16 @@ else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ + qss/00_Common.css \ + qss/01_Global.css \ + qss/10_MainWindow.css \ + qss/11_MainWindowTab.css \ + qss/20_DeviceManager.css \ + qss/21_DeviceSetting.css \ + qss/30_ProgramManager.css \ + qss/31_EditProgram.css \ + qss/32_PageAttr.css \ + qss/33_EWindow.css \ qss/MainWnd.css \ qss/MainTab.css \ qss/TabDeviceManager.css \ diff --git a/LedOK/LoQClass/loqgraphicsobject.cpp b/LedOK/LoQClass/loqgraphicsobject.cpp deleted file mode 100644 index be42b09..0000000 --- a/LedOK/LoQClass/loqgraphicsobject.cpp +++ /dev/null @@ -1,578 +0,0 @@ -#include "loqgraphicsobject.h" -#include "QCoreApplication" -LoQGraphicsObject::LoQGraphicsObject(InteractiveType type, QGraphicsItem *parent) : - QGraphicsObject(parent), - m_interactiveType(type), - m_movable(false), - m_handleLen(10), - m_rLimit(INVALID_RECT) -{ - setGeometry(0, 0, 100, 100); - init(); -} - -LoQGraphicsObject::LoQGraphicsObject(QRectF rect, InteractiveType type, QGraphicsItem *parent) : - QGraphicsObject(parent), - m_interactiveType(type), - m_movable(false), - m_handleLen(10), - m_rLimit(INVALID_RECT) -{ - setGeometry(rect); - init(); -} - -LoQGraphicsObject::LoQGraphicsObject(qreal x, qreal y, qreal w, qreal h, InteractiveType type, QGraphicsItem *parent) : - QGraphicsObject(parent), - m_interactiveType(type), - m_movable(false), - m_handleLen(10), - m_rLimit(INVALID_RECT) -{ - setGeometry(x, y, w, h); - init(); -} - -void LoQGraphicsObject::setInteractiveType(InteractiveType type) -{ - m_interactiveType = type; - GraphicsItemFlags flag = flags(); - if(Dynamic == m_interactiveType) { - flag |= ItemIsMovable; - flag |= ItemIsSelectable; - flag &= ~ItemIsFocusable; - } else { - flag &= ~ItemIsMovable; - flag &= ~ItemIsSelectable; - flag &= ~ItemIsFocusable; - } - setFlags(flag); -} - -void LoQGraphicsObject::init() -{ - setInteractiveType(m_interactiveType); - - m_handlePen.setBrush(QBrush(QColor::fromRgb(0, 255, 0))); - m_handlePen.setWidth(1); - - QVector dashes; - qreal space = 2; - qreal solid = 2; - dashes << solid << space << solid <save(); -//绘制边框 - QPen pen; // creates a default pen - -// pen.setStyle(Qt::DashDotLine); -// QLinearGradient svGradient(0, 0, 2, 0); -// svGradient.setColorAt(1, QColor("#00ff00")); -// svGradient.setColorAt(0, QColor("#ffffff")); -// QBrush myBrush(svGradient); - - QString qexeFullPath = QCoreApplication::applicationDirPath(); - QString qtBordImage=qexeFullPath+"/m/"+"M8_8.bmp"; - QPixmap aa(qtBordImage); - int iBordWidth=aa.height(); - pen.setWidth(iBordWidth); - QBrush myBrush(aa); - //myBrush.setTexture(aa); - pen.setBrush(myBrush); - pen.setCapStyle(Qt::RoundCap); - pen.setJoinStyle(Qt::RoundJoin); - - - QPainterPath path; - - path.moveTo(iBordWidth/2,iBordWidth/2); - path.lineTo(rect().right()-iBordWidth/2,iBordWidth/2); - path.lineTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2); - path.lineTo(iBordWidth/2,rect().bottom()-iBordWidth/2); - path.lineTo(iBordWidth/2,iBordWidth/2); - painter->setPen(pen); - painter->drawPath(path); - - QMatrix matrix2; - matrix2.rotate(90); - QBrush myBrush2; - QPixmap bb=aa.transformed(matrix2, Qt::SmoothTransformation); - myBrush2.setTexture(bb); - QPen pen2; - pen2.setBrush(myBrush2); - QPainterPath path2; - path2.moveTo(rect().right()-iBordWidth/2,iBordWidth/2); - path2.lineTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2); - painter->setPen(pen2); - painter->drawPath(path2); - - //QMatrix matrix3; - //matrix3.rotate(0); -// QBrush myBrush3; -// QPainterPath path3; -//// myBrush3.setTexture(aa); -//// pen.setBrush(myBrush); -//// painter->setPen(pen); -// path3.moveTo(rect().right()-iBordWidth/2,rect().bottom()-iBordWidth/2); -// path3.lineTo(iBordWidth/2,rect().bottom()-iBordWidth/2); -// painter->drawPath(path3); - -// QMatrix matrix4; -// matrix4.rotate(270); -// QBrush myBrush4; -// QPainterPath path4; -// myBrush4.setTexture(aa.transformed(matrix4, Qt::SmoothTransformation)); -// pen.setBrush(myBrush4); -// path4.moveTo(iBordWidth/2,rect().bottom()-iBordWidth/2); -// path4.lineTo(iBordWidth/2,iBordWidth/2); -// painter->drawPath(path4); - - if(isSelected()) { - QPainterPath pRect; - pRect.addRect(rect()); - m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 255, 0))); - painter->setPen(m_borderPen); - painter->drawPath(pRect); - QPainterPath pHandle; - pHandle.addRect(m_rLT); - pHandle.addRect(m_rT); - pHandle.addRect(m_rRT); - pHandle.addRect(m_rL); - pHandle.addRect(m_rR); - pHandle.addRect(m_rLB); - pHandle.addRect(m_rB); - pHandle.addRect(m_rRB); - painter->setPen(m_handlePen); - painter->drawPath(pHandle); - } - else { - - m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 125, 0))); - - QPainterPath pRect; - pRect.addRect(rect()); - painter->setPen(m_borderPen); - painter->drawPath(pRect); - - } - - //磁条吸附时两化吸附的边 - QPen CitiePen=QPen(QColor::fromRgb(0, 255, 0),1,Qt::SolidLine); - painter->setPen(CitiePen); - //if(bMousePress) - { - if (bLeftCitie) { - painter->setPen(CitiePen); - //painter->drawLine(QPointF(rect().x(),rect().y()-100),QPointF(rect().x(),rect().bottom()+100)); - painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().bottomLeft())); - } - if (bTopCitie) { - painter->setPen(CitiePen); - painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().topRight())); - } - if (bRightCitie) { - painter->setPen(CitiePen); - painter->drawLine(QPointF(rect().topRight()),QPointF(rect().bottomRight())); - } - if (bBottomCitie) { - painter->setPen(CitiePen); - painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight())); - } - - } - -// QPen(const QBrush &brush, -// qreal width, -// Qt::PenStyle style = Qt::SolidLine, -// Qt::PenCapStyle cap = Qt::SquareCap, -// Qt::PenJoinStyle join = Qt::BevelJoin); -// QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin); - - - //painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight())); - painter->restore(); -} -void LoQGraphicsObject::setBrightBianLeft(bool b) -{ - //if(bMousePress) -// { -// bLeftCitie=b; - -// } -// else { -// bLeftCitie=false; -// } - bLeftCitie=b; - updateGeometry(); - -} -void LoQGraphicsObject::setBrightBianRight(bool b) -{ -// if(bMousePress) -// { -// bRightCitie=b; - -// } -// else { -// bRightCitie=false; -// } - bRightCitie=b; - updateGeometry(); - -} -void LoQGraphicsObject::setBrightBianTop(bool b) -{ -// if(bMousePress) -// { -// bTopCitie=b; - -// } -// else { -// bTopCitie=false; -// } - bTopCitie=b; - updateGeometry(); - -} -void LoQGraphicsObject::setBrightBianbottom(bool b) -{ -// if(bMousePress) -// { -// bBottomCitie=b; - -// } -// else { -// bBottomCitie=false; -// } - bBottomCitie=b; - updateGeometry(); - -} -void LoQGraphicsObject::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - // return; - if(false == m_movable) return; - - qreal cx, cy, cw, ch; - qreal mx, my, mw, mh; - QPointF ePos = pointToParent(event->pos()); - QPointF absoluteOfs = ePos - m_pOrg; - - mx = m_rOrg.x(); - my = m_rOrg.y(); - mw = m_w; - mh = m_h; - - if(m_hDir != NONE) { - prepareGeometryChange(); - - switch(m_hDir) { - case LT: - cx = m_rOrg.x() + absoluteOfs.x(); - cy = m_rOrg.y() + absoluteOfs.y(); - if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen; - if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen; - mx = cx; - my = cy; - if(m_rLimit != INVALID_RECT) { - if(mx < 0) mx = 0; - if(my < 0) my = 0; - } - mw = m_rOrg.right() - mx; - mh = m_rOrg.bottom() - my; - break; - - case T: - cy = m_rOrg.y() + absoluteOfs.y(); - if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen; - my = cy; - if(m_rLimit != INVALID_RECT) { - if(my < 0) my = 0; - } - mh = m_rOrg.bottom() - my; - break; - - case RT: - cy = m_rOrg.y() + absoluteOfs.y(); - cw = m_rOrg.width() + absoluteOfs.x(); - if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen; - if(cw < m_handleLen) cw = m_handleLen; - my = cy; - mw = cw; - if(m_rLimit != INVALID_RECT) { - if(my < 0) my = 0; - if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx; - } - mh = m_rOrg.bottom() - my; - break; - - case L: - cx = m_rOrg.x() + absoluteOfs.x(); - if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen; - mx = cx; - if(m_rLimit != INVALID_RECT) { - if(mx < 0) mx = 0; - } - mw = m_rOrg.right() - mx; - break; - - case R: - cw = m_rOrg.width() + absoluteOfs.x(); - if(cw < m_handleLen) cw = m_handleLen; - mw = cw; - if(m_rLimit != INVALID_RECT) { - if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx; - } - break; - - case LB: - cx = m_rOrg.x() + absoluteOfs.x(); - ch = m_rOrg.height() + absoluteOfs.y(); - if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen; - if(ch < m_handleLen) ch = m_handleLen; - mx = cx; - if(m_rLimit != INVALID_RECT) { - if(mx < 0) mx = 0; - } - mw = m_rOrg.right() - mx; - mh = ch; - if(m_rLimit != INVALID_RECT) { - if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my; - } - break; - - case B: - ch = m_rOrg.height() + absoluteOfs.y(); - if(ch < m_handleLen) ch = m_handleLen; - mh = ch; - if(m_rLimit != INVALID_RECT) { - if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my; - } - break; - - case RB: - cw = m_rOrg.width() + absoluteOfs.x(); - ch = m_rOrg.height() + absoluteOfs.y(); - if(cw < m_handleLen) cw = m_handleLen; - if(ch < m_handleLen) ch = m_handleLen; - mw = cw; - mh = ch; - if(m_rLimit != INVALID_RECT) { - if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx; - if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my; - } - break; - - default: - break; - } - - setPos(mx, my); - m_w = mw; - m_h = mh; - adjustHandle(); - updateGeometry(m_rOrg); - rectChanged(rect()); - } else { - mx = m_rOrg.x() + absoluteOfs.x(); - my = m_rOrg.y() + absoluteOfs.y(); - if(m_rLimit != INVALID_RECT) { - if(mx < 0) mx = 0; - if(my < 0) my = 0; - if(mx + mw > m_rLimit.width()) mx = m_rLimit.width() - mw; - if(my + mh > m_rLimit.height()) my = m_rLimit.height() - mh; - } - setPos(mx, my); - } - - geometryChanged(geometry()); - if(bMousePress) - { - - emit sigCiTie(true,m_hDir); - - } -} - -void LoQGraphicsObject::setRLimit(const QRectF &r) -{ - if(m_rLimit != INVALID_RECT) { - qreal mx, my, mw, mh; - qreal scale_w = r.width() / m_rLimit.width(); - qreal scale_h = r.height() / m_rLimit.height(); - mx = std::round(x() * scale_w); - my = std::round(y() * scale_h); - mw = std::round(m_w * scale_w); - mh = std::round(m_h * scale_h); - setPos(mx, my); - m_w = mw; - m_h = mh; - adjustHandle(); - geometryChanged(geometry()); - } - m_rLimit = r; -} - -void LoQGraphicsObject::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - if(Qt::LeftButton == event->button()) { - - m_hDir = handleDir(event->pos()); - m_pOrg = pointToParent(event->pos()); - m_rOrg = geometry(); - m_movable = true; - bMousePress=true; - - } - QGraphicsItem::mousePressEvent(event); -} - -void LoQGraphicsObject::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - bMousePress=false; - - if(Qt::LeftButton == event->button()) { - m_hDir = NONE; - m_movable = false; - bLeftCitie=false; - bRightCitie=false; - bTopCitie=false; - bBottomCitie=false; - m_keyPressId++; - emit sigCiTie(false,m_keyPressId); - - } - QGraphicsItem::mouseReleaseEvent(event); -} - -void LoQGraphicsObject::setGeometry(const QRectF &r) -{ - if(r != geometry()) { - prepareGeometryChange(); - setPos(r.x(), r.y()); - m_w = r.width(); - m_h = r.height(); - adjustHandle(); - emit rectChanged(rect()); - } -} - -void LoQGraphicsObject::updateGeometry() -{ - QRectF r = geometry(); - qreal x, y, w, h; - x = r.x() - m_handleLen; - y = r.y() - m_handleLen; - w = r.width() + m_handleLen * 2; - h = r.height() + m_handleLen * 2; - r = QRectF(x, y, w, h); - if(nullptr != scene()) { - scene()->update(r); - } - emit requestUpdate(r); -} - -void LoQGraphicsObject::updateGeometry(const QRectF &gC, const QRectF &gL) -{ - qreal x, y, w, h; - QRectF gCur, gLast; - x = gC.x() - m_handleLen; - y = gC.y() - m_handleLen; - w = gC.width() + m_handleLen * 2; - h = gC.height() + m_handleLen * 2; - gCur = QRectF(x, y, w, h); - x = gL.x() - m_handleLen; - y = gL.y() - m_handleLen; - w = gL.width() + m_handleLen * 2; - h = gL.height() + m_handleLen * 2; - gLast = QRectF(x, y, w, h); - qreal l = (gCur.left() < gLast.left()) ? gCur.left() : gLast.left(); - qreal t = (gCur.top() < gLast.top()) ? gCur.top() : gLast.top(); - qreal r = (gCur.right() > gLast.right()) ? gCur.right() : gLast.right(); - qreal b = (gCur.bottom() > gLast.bottom()) ? gCur.bottom() : gLast.bottom(); - QRectF gFlash = QRectF(QPointF(l, t), QPointF(r, b)); - if(nullptr != scene()) { - scene()->update(gFlash); - } - emit requestUpdate(gFlash); -} - -QPointF LoQGraphicsObject::pointToParent(const QPointF &p) -{ - qreal px, py; - px = p.x() + x(); - py = p.y() + y(); - return QPointF(px, py); -} - -LoQGraphicsObject::HANDLE_DIR LoQGraphicsObject::handleDir(const QPointF &p) -{ - HANDLE_DIR hDir = NONE; - if(isSelected()) { - if(m_rLT.contains(p)) hDir = LT; - else if(m_rT.contains(p)) hDir = T; - else if(m_rRT.contains(p)) hDir = RT; - else if(m_rL.contains(p)) hDir = L; - else if(m_rR.contains(p)) hDir = R; - else if(m_rLB.contains(p)) hDir = LB; - else if(m_rB.contains(p)) hDir = B; - else if(m_rRB.contains(p)) hDir = RB; - } - return hDir; -} -//拖拽的虚线矩形 -void LoQGraphicsObject::adjustHandle() -{ - const QRectF &r = rect(); - //左上角 - m_rLT = QRectF(r.left() - m_handleLen/2, - r.top() - m_handleLen/2, - m_handleLen, m_handleLen); - //上中 - m_rT = QRectF(r.center().x() - m_handleLen / 2, - r.top() - m_handleLen/2, - m_handleLen, m_handleLen); - //右上角 - m_rRT = QRectF(r.right()-m_handleLen/2, - r.top() - m_handleLen/2, - m_handleLen, m_handleLen); - //左中 - m_rL = QRectF(r.left() - m_handleLen/2, - r.center().y() - m_handleLen / 2, - m_handleLen, m_handleLen); - //右中 - m_rR = QRectF(r.right()-m_handleLen/2, - r.center().y() - m_handleLen / 2, - m_handleLen, m_handleLen); - //左下角 - m_rLB = QRectF(r.left() - m_handleLen/2, - r.bottom()-m_handleLen / 2, - m_handleLen, m_handleLen); - //中下 - m_rB = QRectF(r.center().x() - m_handleLen / 2, - r.bottom()-m_handleLen / 2, - m_handleLen, m_handleLen); - //右下角 - m_rRB = QRectF(r.right()-m_handleLen / 2, - r.bottom()-m_handleLen / 2, - m_handleLen, m_handleLen); -} diff --git a/LedOK/LoQClass/loqgraphicsobject.h b/LedOK/LoQClass/loqgraphicsobject.h deleted file mode 100644 index b78431a..0000000 --- a/LedOK/LoQClass/loqgraphicsobject.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef LOQGRAPHICSOBJECT_H -#define LOQGRAPHICSOBJECT_H - -#include -#include -#include -#include -#include -#include -#include - -#define INVALID_RECT QRect(-1, -5, -6, -8) - -class LoQGraphicsObject : public QGraphicsObject -{ - Q_OBJECT - - typedef enum { - NONE = 0, - LT, - T, - RT, - L, - R, - LB, - B, - RB - } HANDLE_DIR; - -public: - enum InteractiveType { - Dynamic = 0, - Static, - Custom - }; - -public: - explicit LoQGraphicsObject(InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr); - LoQGraphicsObject(QRectF rect, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr); - LoQGraphicsObject(qreal x, qreal y, qreal w, qreal h, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr); - -private: - void init(); - -public: - virtual QRectF boundingRect() const override; - virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; - virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; - virtual void setInteractiveType(InteractiveType type = Dynamic); - -public: - InteractiveType interactiveType() const { return m_interactiveType; } - QRectF rect() const { return QRectF(0, 0, m_w, m_h); } - QRectF geometry() const { return QRectF(x(), y(), m_w, m_h); } - -public: - void setRLimit(const QRectF &r); - QRectF rLimit() const { return m_rLimit; } - -signals: - void requestUpdate(const QRectF &); - void geometryChanged(const QRectF &); - void rectChanged(const QRectF &); - - void sigCiTie(bool,int); -public slots: - void setGeometry (qreal x, qreal y, qreal w, qreal h) { setGeometry(QRectF(x, y, w, h)); } - void setGeometry (const QRectF &r); - void updateGeometry(); - void updateGeometry(const QRectF &gLast) { updateGeometry(geometry(), gLast); } - void updateGeometry(const QRectF &gCur, const QRectF &gLast); - void setBrightBianLeft(bool); - void setBrightBianTop(bool); - void setBrightBianRight(bool); - void setBrightBianbottom(bool); - -protected: - int handleLen() const { return m_handleLen; } - QPointF pointToParent(const QPointF &p); - HANDLE_DIR handleDir(const QPointF &p); - void adjustHandle(); - -private: - InteractiveType m_interactiveType; - bool m_movable; - int m_handleLen; - QPen m_handlePen; - QPen m_borderPen; - -private: - qreal m_w; - qreal m_h; - QRectF m_rLT; - QRectF m_rT; - - QRectF m_rRT; - QRectF m_rL; - QRectF m_rR; - QRectF m_rLB; - QRectF m_rB; - QRectF m_rRB; - QRectF m_rOrg; - QPointF m_pOrg; - HANDLE_DIR m_hDir; - QRectF m_rLimit; - bool bMousePress=false; - bool bLeftCitie=false; - bool bRightCitie=false; - bool bTopCitie=false; - bool bBottomCitie=false; - int m_keyPressId=0; - -}; - -#endif // LOQGRAPHICSOBJECT_H diff --git a/LedOK/LoQClass/loqheaderviewcheckbox.cpp b/LedOK/LoQClass/loqheaderviewcheckbox.cpp index 0a2ff5b..4bfad7c 100644 --- a/LedOK/LoQClass/loqheaderviewcheckbox.cpp +++ b/LedOK/LoQClass/loqheaderviewcheckbox.cpp @@ -23,19 +23,15 @@ void LoQHeaderViewCheckBox::HideHeaderCheckBox(bool b) } void LoQHeaderViewCheckBox::paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const { - qDebug() <<"paintSection -s"; QHeaderView::paintSection(painter, rect, logicalIndex); if (logicalIndex == 0) { m_checkBox->setGeometry(rect); } - qDebug() <<"paintSection -o"; } void LoQHeaderViewCheckBox::onAllChecked(bool f) { - qDebug() <<"onAllChecked -s"; m_checkBox->blockSignals(true); m_checkBox->setChecked(f); m_checkBox->blockSignals(false); - qDebug() <<"onAllChecked -o"; } diff --git a/LedOK/images.qrc b/LedOK/images.qrc index 303e99e..9e29767 100644 --- a/LedOK/images.qrc +++ b/LedOK/images.qrc @@ -1,5 +1,79 @@ res/splash.png + res/borders/M1_0.bmp + res/borders/M1_1.bmp + res/borders/M1_2.bmp + res/borders/M1_3.bmp + res/borders/M1_4.bmp + res/borders/M1_5.bmp + res/borders/M1_6.bmp + res/borders/M1_7.bmp + res/borders/M1_8.bmp + res/borders/M2_0.bmp + res/borders/M2_1.bmp + res/borders/M2_2.bmp + res/borders/M2_3.bmp + res/borders/M2_4.bmp + res/borders/M2_5.bmp + res/borders/M2_6.bmp + res/borders/M2_7.bmp + res/borders/M2_8.bmp + res/borders/M3_0.bmp + res/borders/M3_1.bmp + res/borders/M3_2.bmp + res/borders/M3_3.bmp + res/borders/M3_4.bmp + res/borders/M3_5.bmp + res/borders/M3_6.bmp + res/borders/M3_7.bmp + res/borders/M3_8.bmp + res/borders/M4_0.bmp + res/borders/M4_1.bmp + res/borders/M4_2.bmp + res/borders/M4_3.bmp + res/borders/M4_4.bmp + res/borders/M4_5.bmp + res/borders/M4_6.bmp + res/borders/M4_7.bmp + res/borders/M4_8.bmp + res/borders/M5_0.bmp + res/borders/M5_1.bmp + res/borders/M5_2.bmp + res/borders/M5_3.bmp + res/borders/M5_4.bmp + res/borders/M5_5.bmp + res/borders/M5_6.bmp + res/borders/M5_7.bmp + res/borders/M5_8.bmp + res/borders/M6_0.bmp + res/borders/M6_1.bmp + res/borders/M6_2.bmp + res/borders/M6_3.bmp + res/borders/M6_4.bmp + res/borders/M6_5.bmp + res/borders/M6_6.bmp + res/borders/M6_7.bmp + res/borders/M6_8.bmp + res/borders/M6_9.bmp + res/borders/M7_0.bmp + res/borders/M7_1.bmp + res/borders/M7_2.bmp + res/borders/M7_3.bmp + res/borders/M7_4.bmp + res/borders/M7_5.bmp + res/borders/M7_6.bmp + res/borders/M7_7.bmp + res/borders/M7_8.bmp + res/borders/M8_0.bmp + res/borders/M8_1.bmp + res/borders/M8_2.bmp + res/borders/M8_3.bmp + res/borders/M8_4.bmp + res/borders/M8_5.bmp + res/borders/M8_6.bmp + res/borders/M8_7.bmp + res/borders/M8_8.bmp + res/borders/M9_0.bmp diff --git a/LedOK/res/borders/M1_0.bmp b/LedOK/res/borders/M1_0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..5b563c3213f1698799cf528bf33f05c44a4b35f8 GIT binary patch literal 248 zcmZ?r{lNeMWfe?W}Tre6E;tT+Mq*Ckv literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M1_4.bmp b/LedOK/res/borders/M1_4.bmp new file mode 100644 index 0000000000000000000000000000000000000000..d00bdd0d7234cb008a235b6c49e4433855a6f550 GIT binary patch literal 248 zcmZ?r{lNeMWY9(f*|q#2!t$-OT&Pf0{}BO BFAx9# literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M1_7.bmp b/LedOK/res/borders/M1_7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..ef8a8867707842489c99661e2cee802a1b580310 GIT binary patch literal 248 zcmZ?r{lNeMWULCl_3};YWV-30S`hL3ulpN GJ_7*HwlxX> literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M2_0.bmp b/LedOK/res/borders/M2_0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..bb9aecb155a8ee2d0fd03b99d86b1c6ecd892c1f GIT binary patch literal 440 zcmZ?r-NDEJ24+A~1Be}fmO|7!u+` M!jZ7h#S+L205vp%KL7v# literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M3_0.bmp b/LedOK/res/borders/M3_0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..cb7aa6ae2c5e699a85968af685b6b960c3193ef5 GIT binary patch literal 632 zcmZ?rtzcpR12Z700mKeK%nZbg3=%++fx!tVFT@SOU;!lJKZ1?KWMDwzATbA%IM7-D b!OjGeARdf6G{hkRj}*8_%)u1SxZDW% J{2$7Q0RXU{>sSB) literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M3_5.bmp b/LedOK/res/borders/M3_5.bmp new file mode 100644 index 0000000000000000000000000000000000000000..6cc9f6ca2dfba95ef1bd72c04fc31bc61b2afa2e GIT binary patch literal 632 zcmZ?rtzcpR12Z700mKeK%nZbg3=%++fx!tVFT@SOU;z;E|3459VRA@29vJvTKKucI C%ONoU literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M3_6.bmp b/LedOK/res/borders/M3_6.bmp new file mode 100644 index 0000000000000000000000000000000000000000..aa83e044ea272427f255ce5d3e5ba33851d94e3c GIT binary patch literal 632 zcmZ?rtzcpR12Z700mKeK%nZbg3=%++fx!tVFT@SOU;!xc|34BBiH*c$7_@4D4uc?& eAAl}~AQ%nt!k|_IbSg?fBjN%@7=<&K)BpfK5^vN1 literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M3_7.bmp b/LedOK/res/borders/M3_7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..25f97ffb2a19a945ffaf6adb80658b9d4980cf50 GIT binary patch literal 632 zcmZ?rtzcpR12Z700mKeK%nZbg3=%++fx!tVFT@SOU;z;E9|<9I{{LryBe>#0s2=Vl as3Rf%0dpYkhl(RnNJ?OyA5~9w_y7P?c7ehG literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M3_8.bmp b/LedOK/res/borders/M3_8.bmp new file mode 100644 index 0000000000000000000000000000000000000000..adb17c46367b50416eaf484f0aad899d0d7f99a1 GIT binary patch literal 632 zcmZ?rtzcpR12Z700mKeK%nZbg3=%++fx!tVFT@SOU;z;E|37xb@E<6L1z{5dDZ~Y6 sZ9d!!5C=f4gE|J{R;UEnFJLwfVW=id3fW9#HZ*)FGoRMsLu>OH06xH>q5uE@ literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M4_0.bmp b/LedOK/res/borders/M4_0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3b9d912f4764cb92e368b5ff440804a78598ef23 GIT binary patch literal 824 zcmZ?rwP0od12Z700mKeK%mT!W3=%++fq@AqFT@SOU;z;E|37xb@E<6L1z{5dDZ~Y6 tZ9d!!5C=f4gE|J{R;UEnFJLwfVW=id3fW9#HZ*)jw)wPhhiGzFr hb3cfNxgW*^d2m!56dF_y2S|be2RYDeg!w~4902}G@YMhS literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M4_2.bmp b/LedOK/res/borders/M4_2.bmp new file mode 100644 index 0000000000000000000000000000000000000000..f9b41fd9ca48fb3b73415191e8307624326e7830 GIT binary patch literal 824 zcmZ?rwP0od12Z700mKeK%mT!W3=%++fq@AqFT@SOU;z;E|391w4yOT DjbNcA literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M4_3.bmp b/LedOK/res/borders/M4_3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..4eba06f9c46f7855af8463fb2693a331114688be GIT binary patch literal 824 zcmZ?rwP0od12Z700mKeK%mT!W3=%++fq@AqFT@SOU;!}kAIAL8fW&0@597cYP<1eI zplT%Mz^Mm13+N7*Q;?V-C!sqY;s+!}NX$|7h?GD=c)~&+s0E3M2zm4 literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M4_4.bmp b/LedOK/res/borders/M4_4.bmp new file mode 100644 index 0000000000000000000000000000000000000000..c3fa2f7f50b2ce312451530bee0e8fcc0b2e31ff GIT binary patch literal 824 zcmd5&ISzm@3=7A`#>5kN0b)e#{Qo({N`li4*+8OdqS~$Fr02B{qH9B55eH&Kbh03e z^thiV3ne_28i)`Up7cS$mZu=0C4?W;fvIg9f)J**ohRgrR*=wMgd;@RM3B&V9s84K e3drk4J2v3Av}pwi9qzB!p`$fM$j+Vr?f>6-0mlCT literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M4_5.bmp b/LedOK/res/borders/M4_5.bmp new file mode 100644 index 0000000000000000000000000000000000000000..e5d0b0a32da62461b610c1a4b81be58f1f73bfb5 GIT binary patch literal 824 zcmcJNF%H5o3`GrPV`Jh7Jpp1w?A-r2=_lV#zFi~+L=-3f&a3UVdA{z8^>M?x!XB^_ z>|j@{W=EV~&a@urOEcqSsL08=*P3xUp5+er+{o&Dt`=e0O9Mp;=x(GYSb~t+E#+j! zv*CQ;olbcKPw_V!XV}A4?^hnL<3kF};QoCF-v1QU$N^ct&uCiGf9qdS`dT0w@Y4Ch Mu)6l2@&DhS4K9C$K>z>% literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M4_6.bmp b/LedOK/res/borders/M4_6.bmp new file mode 100644 index 0000000000000000000000000000000000000000..82b4070b8312a112c99d793bdeb7d8072e54b512 GIT binary patch literal 824 zcmZ?rwP0od12Z700mKeK%mT!W3=%++fq@AqFT@SOU;$L(KLY~{{r}H^KnUSMtRCia cpcfD>2eL;U4~#UVP@sO`(A02RJ05600Iv!F)Bpeg literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M4_7.bmp b/LedOK/res/borders/M4_7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..00461c40d1e8226c5648a093dbce42d871c2c85e GIT binary patch literal 824 zcmcIgNe+N82*l;)&67{?1;(TC?*E@tN0tyV>pR3DI;I*uH7Cl3g_h%kk8G0 l84-}HGQKO}Q%TPB|1>4KtnBOJMV76g_|512lcGU@yaSE$i9G-S literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M4_8.bmp b/LedOK/res/borders/M4_8.bmp new file mode 100644 index 0000000000000000000000000000000000000000..e98c4a93f5c8e42ffcacfc674e83ad45b4e25c21 GIT binary patch literal 824 zcmZ?rwP0od12Z700mKeK%mT!W3=%++fq@AqFT@SOU;z;E|38=sCWj(>7ZW3hdUCQ)?w685oZ7ZK2KWi literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M5_1.bmp b/LedOK/res/borders/M5_1.bmp new file mode 100644 index 0000000000000000000000000000000000000000..4374e49339d36ae7232845136cf882f462a1ea27 GIT binary patch literal 1016 zcmZ?r{lUxt24+A~1Be}fm=%Z_86QU^6yByBI z@W`N24|gV<0SbHshvEN!5P}0Z6V4b|^+1OKU4n27+@W9w+~sh_AXJa)WON={_@hf> I@ae4{0IU6C<^TWy literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M5_3.bmp b/LedOK/res/borders/M5_3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8cbed7f1179d14114f132c94c0ebe798d4fd0349 GIT binary patch literal 1016 zcmd5)F%Ez*2*emCHz%Lq3!II+pY~O5^#BhUI#-(lSGa`p;(lDc*jbSm#D*9Uoy^E0 zC+5@WVGX82fJ%%?_)JR?Ts?U}j7s%{O6 odgp1RO@F3l1AeSk5I>Kqsq2Zhg2w#38`uOUx2#i@WaKaTH+FBLrT_o{ literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M5_4.bmp b/LedOK/res/borders/M5_4.bmp new file mode 100644 index 0000000000000000000000000000000000000000..bdbd88c096fcaeb853c341caade19ee9b7b90f60 GIT binary patch literal 1016 zcmZ?r{lUxt24+A~1Be}fm=%Z_864t|k0kW}KLZ4TRDs2j zB*7wsO+B)AU~Hfl-~fq<;#0T+AY&la!@?8dPL%KmI}zRegGxOl5K){662cjtgGN2n Pg^<8RazC!{A1vwtXE>^! literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M5_5.bmp b/LedOK/res/borders/M5_5.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3169cfd546c29f1443ebca32fa033539764c5e60 GIT binary patch literal 1016 zcmZ?r{lUxt24+A~1Be}fm=%Z_86cgh`_mU#^4u6cHvND sLxLLFap%e-cmmhPy_fP--mdfD1qw4$V=@{^OUvWi*ZbqO7n3XW1^b45 zz~0FjTI31;>Bwz>s%5vP(26XL&w%S6F-pM?EnA( literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M6_2.bmp b/LedOK/res/borders/M6_2.bmp new file mode 100644 index 0000000000000000000000000000000000000000..7244b663308ca72a59f0e41c1ee9ceecbac1451f GIT binary patch literal 1208 zcmd5(NeX~442&RNym|5ozQD71_fx*g-_^-Ndyz5-7E3aebTV1GA6GASR^S5P-~+sq z87Ok%eHz^@ppa4+8%fA9D+#qo1AU)@L~UNFETVs<)5t43v%!A6gbf_C)FPPFtt1c; uTTx9mtK|z*D3ia`N830IMmxr*KH3r(W#_!p_be#5g~-#!@{?YEvi}=ArVq*h literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M6_3.bmp b/LedOK/res/borders/M6_3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..66510b15b6dc5e1452a8b1e580194d07fa7ce28c GIT binary patch literal 1208 zcmd5&F%Ezr46KQ9adYwszQEbI`zc@L@9=CX)R1mQXlOaE2W{Dpt0%S;=xrMY8~6;D%^nOk@LxSTliIceZr7pP)29*gFGp0& nqzWhD&^of-PWv}{ydo>T%fO*kT-2_k=c=Ko9f?p()|&nXeGQ61 literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M6_4.bmp b/LedOK/res/borders/M6_4.bmp new file mode 100644 index 0000000000000000000000000000000000000000..61f93a1409002d0ab4ab41d6c3453ac2d551af32 GIT binary patch literal 1208 zcmZ?r-NC{D24+A~1Be}fm<@;-86kJ=#zWQ8oG zMHQLBH#Jj%y{s{OzZ#0h5x|Xcu)L^Of4eLC;WE_=;sVxLoE>zZ9w#$+t@Y=Fj$-rk s1$~;fcJvm0iRY9Eti!*chX)3H9sFbj*$j@`GU5R}@1%3<|MGrh18jZi;Q#;t literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M6_7.bmp b/LedOK/res/borders/M6_7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..72a5c8359b58184a465eb54d6e469d622b626461 GIT binary patch literal 1208 zcmZ?r-NC{D24+A~1Be}fm<@;-86d7Knmi1s270l y20I-_gWNyJr655+_}z)eg+o0G@OW+TOF;r3l8PXSA0z_h!xBG|&|s4SxfB4FrWwEh literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M6_8.bmp b/LedOK/res/borders/M6_8.bmp new file mode 100644 index 0000000000000000000000000000000000000000..1110c0003c3f0bc091a352c05f03d1e2c27430a6 GIT binary patch literal 1208 zcmZ?r-NC{D24+A~1Be}fm<@;-86Y;}JXZR09$gu$CfCS;zgQI6qsYf^l5_oVgz#I?p65I=e oQ9aDf$Zi8V8}4RgFM!kxCiTD+0dY1Y=OVLlNg%61W)F;d04m@yr~m)} literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M6_9.bmp b/LedOK/res/borders/M6_9.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8762b36d75c29d96bb66f866857f05a04435ff43 GIT binary patch literal 1208 zcmb_aK@I{j2*kvA@#e`V_yW(yyPxt^{%)lVrBG<%CT>C(hMA$;?(_9Il00`_ZyXPf z6UTwByb`^+e>o!rn3rvv5!6e(rW5_iXV+Yii^&3ID`jQ@kc6v$#^n$aOuP7gd%?;T zzi`6Iue2U_H|Sv9e7^m_=~}-rm4sL4@qZzDZ=yXwxdDE{S3XKid>l)$&**Q2$!Fl; z_YWF#kXap*NzQ5@k=0BUSu|EYFf>n7tE1H1H8}>2Szf?7N=uqc)2e?@1a91lE@;&# Fe7<}co-F_X literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M7_0.bmp b/LedOK/res/borders/M7_0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..59213c3a2e730d1dfe3924cee21983f9b27fa4d9 GIT binary patch literal 1400 zcmZ?rtzcyU12Z700mKeK%nrni3=%++fx!tVFT@SOU;!}kA4Gx)hW`)>A~#gTVXhzb e0z4uIASi}90^P;C|(#U;$U|JLmtKPu#`VE#9>|-s_7pV+7KF@1V#*2Fc`!E DS1|!w literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M7_2.bmp b/LedOK/res/borders/M7_2.bmp new file mode 100644 index 0000000000000000000000000000000000000000..f568820c12cf26069c1b5a3fc66e84c320a425d2 GIT binary patch literal 1400 zcmZ?rtzcyU12Z700mKeK%nrni3=%++fx!tVFT@SOU;z;EAI1VQh9Vo}h5sM~0Yi>G fbX^V!`Jo>ELo(6BQajY~Lp19`e1Ytjp~waRb5KDW literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M7_3.bmp b/LedOK/res/borders/M7_3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..08f5c2a9d20fab407bf6f1edca1b84f75064ae96 GIT binary patch literal 1400 zcmdT@F%m#P42;4kbSh8q0=3cmkKeP|m2>oF;wFj9W|_U@tlQoi*Niy97kCG6Y(z9$ zQ6G9a0T0Jj zqc+}ur}3}J!q`US!R`D=)X d4O`k$6%FD5DN(1OR{3VEX_7 literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M7_7.bmp b/LedOK/res/borders/M7_7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..06e0b7d617cb1a263169b57e0b4ea22316f63876 GIT binary patch literal 1400 zcmdUvu?>JQ3heWwmr(Fm9S>^TH{{I8bZZm0R_yDZk&)YJg#p|F10D3#rxjJPJJ{MR0gj4>tEN_l$u9sdIGB%dl tgTGEas7ftl`5pD?NXU^g(vK@})E8RF!^=eFZoyNpb8a8A7GDx~{Ry-T5Y7Mq literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M8_2.bmp b/LedOK/res/borders/M8_2.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8ba72bf763f062f0da1fffa1daf3b26ba9481820 GIT binary patch literal 1592 zcmZ?rwP0fa12Z700mKeK%mKuV3=%++fq@AqFT@SOU;!}kAHhVhunIz?u}WbTq?dX$ z%RyW;A%w?3QfQKcLH&Q2n}7^r+%p)}gI!L7`$yFyCrdaR7A%m2NOHQyCa z2-8PY+Sh!nB`aPffu{LIfbdJd(%|h(0OFEw`%C=;0fz%8 literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M8_5.bmp b/LedOK/res/borders/M8_5.bmp new file mode 100644 index 0000000000000000000000000000000000000000..ab22dd4c5861b70003985cf41c1d8d12dc68299d GIT binary patch literal 1592 zcmd6iu?~PB3`DDgF>!P96Z`_>Xx#n(&(RAFf}fyNz#;_$$SFyIazD&jx~!(9$!z}-J84haDoh66ae WBBzrfmVY76g{2u#%0UK$UmO7R>p!gk literal 0 HcmV?d00001 diff --git a/LedOK/res/borders/M8_7.bmp b/LedOK/res/borders/M8_7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..10394a69f3b1b45a1c466e809488e652163a7f35 GIT binary patch literal 1592 zcmd5)F%AMT3=0ehiH(UT@B+k$*!ll+dQO~%G#p| z+{p!1WRL#8)n`?i|2)is%(SBUFm2>&?(jp&<@- zJkT>h$0Gok4G|dB;vjc}Ts;Jwip!la*N=Ju9+C783S3b$B*ce=BXK42A?n5`G%Mpr5a_b@(7p7?~O9W zzSl;X`k4cdCpf@i&}B9a#eR%yfjnyb>G@B_dnp*uj|hQ zFB7f{bQN*`&Cek%x1G5WXqov^hPqw8QFcyw_lYTQ(M{ -eObject::eObject(InteractiveType type, QGraphicsItem *parent) : - LoQGraphicsObject(type, parent) -{ +eObject::eObject(InteractiveType type, QGraphicsItem *parent) : QGraphicsObject(parent), + m_interactiveType(type), + m_movable(false), + m_handleLen(10), + m_rLimit(INVALID_RECT) { + setGeometry(0, 0, 100, 100); init(); } -eObject::eObject(QRectF rect, InteractiveType type, QGraphicsItem *parent) : - LoQGraphicsObject(rect, type, parent) -{ +eObject::eObject(QRectF rect, InteractiveType type, QGraphicsItem *parent) : QGraphicsObject(parent), + m_interactiveType(type), + m_movable(false), + m_handleLen(10), + m_rLimit(INVALID_RECT) { setGeometry(rect); init(); } -eObject::eObject(const QJsonObject &json, InteractiveType type, QGraphicsItem *parent) : - LoQGraphicsObject(type, parent) -{ - setZValue(json["order"].toInt());//toDouble()); - // setGeometry(QRectF(json["x"].toDouble(), json["y"].toDouble(), - // json["w"].toDouble(), json["h"].toDouble())); +eObject::eObject(const QJsonObject &json, InteractiveType type, QGraphicsItem *parent) : QGraphicsObject(parent), + m_interactiveType(type), + m_movable(false), + m_handleLen(10), + m_rLimit(INVALID_RECT) { + setZValue(json["order"].toInt()); setGeometry(QRectF(json["x"].toInt(), json["y"].toInt(), json["w"].toInt(), json["h"].toInt())); init(); } -void eObject::init() -{ +void eObject::init(){ + qDebug()<<"eObject::init()"; + setInteractiveType(m_interactiveType); + + m_handlePen.setBrush(QBrush(QColor::fromRgb(0, 255, 0))); + m_handlePen.setWidth(1); + + QVector dashes; + qreal space = 2; + qreal solid = 2; + dashes << solid << space << solid <borderFd, currentIndexChanged, this, [this](int idx){ + //m_wAttr->borderFd->itemIcon(idx).data_ptr().; + }); + return m_wAttr; } -QJsonObject eObject::elementJson() const -{ +QJsonObject eObject::elementJson() const { + qDebug()<<"eObject::elementJson()"; QJsonObject oRoot; QRectF r = geometry(); oRoot["order"] = zValue(); @@ -58,39 +91,496 @@ QJsonObject eObject::elementJson() const return oRoot; } -void eObject::setRLimit(const QRectF r) -{ - if(isSelected()) - m_wAttr->setRLimit(r); - LoQGraphicsObject::setRLimit(r); +void eObject::setRLimit(const QRectF &r) { + qDebug()<<"eObject::setRLimit(QRectF)"; + if(isSelected()) m_wAttr->setRLimit(r); + + if(m_rLimit != INVALID_RECT) { + qreal mx, my, mw, mh; + qreal scale_w = r.width() / m_rLimit.width(); + qreal scale_h = r.height() / m_rLimit.height(); + mx = std::round(x() * scale_w); + my = std::round(y() * scale_h); + mw = std::round(m_w * scale_w); + mh = std::round(m_h * scale_h); + setPos(mx, my); + m_w = mw; + m_h = mh; + adjustHandle(); + geometryChanged(geometry()); + } + m_rLimit = r; } -void eObject::onAttrChanged(const eObject::Data &data) -{ - setGeometry(data.x, data.y, data.w, data.h); +void eObject::onAttrChanged(const QRectF &rect){ + qDebug()<<"eObject::onAttrChanged(QRectF)"; + setGeometry(rect); } -void eObject::onAttrSetting(const QRectF &r) -{ - eObject::Data data; - data.x = r.x(); - data.y = r.y(); - data.w = r.width(); - data.h = r.height(); - emit sAttrSetting(data); + +QRectF eObject::boundingRect() const { + int m2 = m_handleLen * 2; + return QRectF(-m_handleLen, -m_handleLen, m_w+m2, m_h+m2); } -//QString eObject::getFileMd5(QString filePath) -//{ -// QFile theFile(filePath); -// theFile.open(QIODevice::ReadOnly); -// QByteArray ba = QCryptographicHash::hash(theFile.readAll(), QCryptographicHash::Md5); -// theFile.close(); -// QString strRes=""; -// strRes.append(ba.toHex()); -// return strRes; -//} -QString eObject::getFileMd5(QString filePath) -{ +//绘制选中和未选中的区域边框 +void eObject::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){ + //qDebug()<<"eObject::paint(QPainter, QStyleOptionGraphicsItem)"; + Q_UNUSED(option); + Q_UNUSED(widget); + painter->save(); + //绘制边框 + QPixmap img("borders/M8_8.bmp"); + int borderWidth = img.height(); + QBrush brush(img); + + QPainterPath path(QPointF(0, 0)); + path.lineTo(m_w, 0); + path.lineTo(m_w - borderWidth, borderWidth); + path.lineTo(borderWidth, borderWidth); + path.closeSubpath(); + painter->fillPath(path, brush); + + QTransform transform; + transform.rotate(90); + brush.setTransform(transform); + path = QPainterPath(QPointF(m_w, 0)); + path.lineTo(m_w, m_h); + path.lineTo(m_w - borderWidth, m_h - borderWidth); + path.lineTo(m_w - borderWidth, borderWidth); + path.closeSubpath(); + painter->fillPath(path, brush); + + transform.rotate(90); + brush.setTransform(transform); + path = QPainterPath(QPointF(m_w, m_h)); + path.lineTo(0, m_h); + path.lineTo(borderWidth, m_h - borderWidth); + path.lineTo(m_w - borderWidth, m_h - borderWidth); + path.closeSubpath(); + painter->fillPath(path, brush); + + transform.rotate(90); + brush.setTransform(transform); + path = QPainterPath(QPointF(0, m_h)); + path.lineTo(0, 0); + path.lineTo(borderWidth, borderWidth); + path.lineTo(borderWidth, m_h - borderWidth); + path.closeSubpath(); + painter->fillPath(path, brush); + + + if(isSelected()) { + QPainterPath pRect; + pRect.addRect(rect()); + m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 255, 0))); + painter->setPen(m_borderPen); + painter->drawPath(pRect); + QPainterPath pHandle; + pHandle.addRect(m_rLT); + pHandle.addRect(m_rT); + pHandle.addRect(m_rRT); + pHandle.addRect(m_rL); + pHandle.addRect(m_rR); + pHandle.addRect(m_rLB); + pHandle.addRect(m_rB); + pHandle.addRect(m_rRB); + painter->setPen(m_handlePen); + painter->drawPath(pHandle); + } else { + m_borderPen.setBrush(QBrush(QColor::fromRgb(0, 125, 0))); + QPainterPath pRect; + pRect.addRect(rect()); + painter->setPen(m_borderPen); + painter->drawPath(pRect); + } + + //磁条吸附时两化吸附的边 + QPen CitiePen=QPen(QColor::fromRgb(0, 255, 0),1,Qt::SolidLine); + painter->setPen(CitiePen); + //if(bMousePress) + { + if (bLeftCitie) { + painter->setPen(CitiePen); + //painter->drawLine(QPointF(rect().x(),rect().y()-100),QPointF(rect().x(),rect().bottom()+100)); + painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().bottomLeft())); + } + if (bTopCitie) { + painter->setPen(CitiePen); + painter->drawLine(QPointF(rect().topLeft()),QPointF(rect().topRight())); + } + if (bRightCitie) { + painter->setPen(CitiePen); + painter->drawLine(QPointF(rect().topRight()),QPointF(rect().bottomRight())); + } + if (bBottomCitie) { + painter->setPen(CitiePen); + painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight())); + } + } +// QPen(const QBrush &brush, +// qreal width, +// Qt::PenStyle style = Qt::SolidLine, +// Qt::PenCapStyle cap = Qt::SquareCap, +// Qt::PenJoinStyle join = Qt::BevelJoin); +// QPen pen(Qt::green, 3, Qt::DashDotLine, Qt::RoundCap, Qt::RoundJoin); + + + //painter->drawLine(QPointF(rect().bottomLeft()),QPointF(rect().bottomRight())); + painter->restore(); +} + +void eObject::mousePressEvent(QGraphicsSceneMouseEvent *event){ + if(Qt::LeftButton == event->button()) { + + m_hDir = handleDir(event->pos()); + m_pOrg = pointToParent(event->pos()); + m_rOrg = geometry(); + m_movable = true; + bMousePress=true; + + } + QGraphicsItem::mousePressEvent(event); +} + +void eObject::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ + bMousePress=false; + + if(Qt::LeftButton == event->button()) { + m_hDir = NONE; + m_movable = false; + bLeftCitie=false; + bRightCitie=false; + bTopCitie=false; + bBottomCitie=false; + m_keyPressId++; + emit sigCiTie(false,m_keyPressId); + + } + QGraphicsItem::mouseReleaseEvent(event); +} + +void eObject::mouseMoveEvent(QGraphicsSceneMouseEvent *event){ + if(false == m_movable) return; + + qreal cx, cy, cw, ch; + qreal mx, my, mw, mh; + QPointF ePos = pointToParent(event->pos()); + QPointF absoluteOfs = ePos - m_pOrg; + + mx = m_rOrg.x(); + my = m_rOrg.y(); + mw = m_w; + mh = m_h; + + if(m_hDir != NONE) { + prepareGeometryChange(); + + switch(m_hDir) { + case LT: + cx = m_rOrg.x() + absoluteOfs.x(); + cy = m_rOrg.y() + absoluteOfs.y(); + if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen; + if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen; + mx = cx; + my = cy; + if(m_rLimit != INVALID_RECT) { + if(mx < 0) mx = 0; + if(my < 0) my = 0; + } + mw = m_rOrg.right() - mx; + mh = m_rOrg.bottom() - my; + break; + + case T: + cy = m_rOrg.y() + absoluteOfs.y(); + if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen; + my = cy; + if(m_rLimit != INVALID_RECT) { + if(my < 0) my = 0; + } + mh = m_rOrg.bottom() - my; + break; + + case RT: + cy = m_rOrg.y() + absoluteOfs.y(); + cw = m_rOrg.width() + absoluteOfs.x(); + if(m_rOrg.bottom() - cy < m_handleLen) cy = m_rOrg.bottom() - m_handleLen; + if(cw < m_handleLen) cw = m_handleLen; + my = cy; + mw = cw; + if(m_rLimit != INVALID_RECT) { + if(my < 0) my = 0; + if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx; + } + mh = m_rOrg.bottom() - my; + break; + + case L: + cx = m_rOrg.x() + absoluteOfs.x(); + if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen; + mx = cx; + if(m_rLimit != INVALID_RECT) { + if(mx < 0) mx = 0; + } + mw = m_rOrg.right() - mx; + break; + + case R: + cw = m_rOrg.width() + absoluteOfs.x(); + if(cw < m_handleLen) cw = m_handleLen; + mw = cw; + if(m_rLimit != INVALID_RECT) { + if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx; + } + break; + + case LB: + cx = m_rOrg.x() + absoluteOfs.x(); + ch = m_rOrg.height() + absoluteOfs.y(); + if(m_rOrg.right() - cx < m_handleLen) cx = m_rOrg.right() - m_handleLen; + if(ch < m_handleLen) ch = m_handleLen; + mx = cx; + if(m_rLimit != INVALID_RECT) { + if(mx < 0) mx = 0; + } + mw = m_rOrg.right() - mx; + mh = ch; + if(m_rLimit != INVALID_RECT) { + if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my; + } + break; + + case B: + ch = m_rOrg.height() + absoluteOfs.y(); + if(ch < m_handleLen) ch = m_handleLen; + mh = ch; + if(m_rLimit != INVALID_RECT) { + if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my; + } + break; + + case RB: + cw = m_rOrg.width() + absoluteOfs.x(); + ch = m_rOrg.height() + absoluteOfs.y(); + if(cw < m_handleLen) cw = m_handleLen; + if(ch < m_handleLen) ch = m_handleLen; + mw = cw; + mh = ch; + if(m_rLimit != INVALID_RECT) { + if(mx + mw > m_rLimit.width()) mw = m_rLimit.width() - mx; + if(my + mh > m_rLimit.height()) mh = m_rLimit.height() - my; + } + break; + + default: + break; + } + + setPos(mx, my); + m_w = mw; + m_h = mh; + adjustHandle(); + updateGeometry(m_rOrg); + rectChanged(rect()); + } else { + mx = m_rOrg.x() + absoluteOfs.x(); + my = m_rOrg.y() + absoluteOfs.y(); + if(m_rLimit != INVALID_RECT) { + if(mx < 0) mx = 0; + if(my < 0) my = 0; + if(mx + mw > m_rLimit.width()) mx = m_rLimit.width() - mw; + if(my + mh > m_rLimit.height()) my = m_rLimit.height() - mh; + } + setPos(mx, my); + } + + geometryChanged(geometry()); + if(bMousePress) + { + + emit sigCiTie(true,m_hDir); + + } +} + +void eObject::setBrightBianLeft(bool b){ +qDebug()<<"eObject::setBrightBianLeft(bool)"; + //if(bMousePress) +// { +// bLeftCitie=b; + +// } +// else { +// bLeftCitie=false; +// } + bLeftCitie=b; + updateGeometry(); + +} +void eObject::setBrightBianRight(bool b){ +qDebug()<<"eObject::setBrightBianRight(bool)"; +// if(bMousePress) +// { +// bRightCitie=b; + +// } +// else { +// bRightCitie=false; +// } + bRightCitie=b; + updateGeometry(); + +} +void eObject::setBrightBianTop(bool b){ +qDebug()<<"eObject::setBrightBianTop(bool)"; +// if(bMousePress) +// { +// bTopCitie=b; + +// } +// else { +// bTopCitie=false; +// } + bTopCitie=b; + updateGeometry(); + +} +void eObject::setBrightBianbottom(bool b){ +qDebug()<<"eObject::setBrightBianbottom(bool)"; +// if(bMousePress) +// { +// bBottomCitie=b; + +// } +// else { +// bBottomCitie=false; +// } + bBottomCitie=b; + updateGeometry(); + +} + + + + + + +void eObject::setGeometry(const QRectF &r){ + qDebug()<<"eObject::setGeometry(QRectF)"; + if(r != geometry()) { + prepareGeometryChange(); + setPos(r.x(), r.y()); + m_w = r.width(); + m_h = r.height(); + adjustHandle(); + emit rectChanged(rect()); + } +} + +void eObject::updateGeometry(){ + qDebug()<<"eObject::updateGeometry()"; + QRectF r = geometry(); + qreal x, y, w, h; + x = r.x() - m_handleLen; + y = r.y() - m_handleLen; + w = r.width() + m_handleLen * 2; + h = r.height() + m_handleLen * 2; + r = QRectF(x, y, w, h); + if(nullptr != scene()) { + scene()->update(r); + } + emit requestUpdate(r); +} + +void eObject::updateGeometry(const QRectF &gC, const QRectF &gL){ + qDebug()<<"eObject::updateGeometry(QRectF,QRectF)"; + qreal x, y, w, h; + QRectF gCur, gLast; + x = gC.x() - m_handleLen; + y = gC.y() - m_handleLen; + w = gC.width() + m_handleLen * 2; + h = gC.height() + m_handleLen * 2; + gCur = QRectF(x, y, w, h); + x = gL.x() - m_handleLen; + y = gL.y() - m_handleLen; + w = gL.width() + m_handleLen * 2; + h = gL.height() + m_handleLen * 2; + gLast = QRectF(x, y, w, h); + qreal l = (gCur.left() < gLast.left()) ? gCur.left() : gLast.left(); + qreal t = (gCur.top() < gLast.top()) ? gCur.top() : gLast.top(); + qreal r = (gCur.right() > gLast.right()) ? gCur.right() : gLast.right(); + qreal b = (gCur.bottom() > gLast.bottom()) ? gCur.bottom() : gLast.bottom(); + QRectF gFlash = QRectF(QPointF(l, t), QPointF(r, b)); + if(nullptr != scene()) { + scene()->update(gFlash); + } + emit requestUpdate(gFlash); +} + +QPointF eObject::pointToParent(const QPointF &p){ + qDebug()<<"eObject::pointToParent(QPointF)"; + qreal px, py; + px = p.x() + x(); + py = p.y() + y(); + return QPointF(px, py); +} + +eObject::HANDLE_DIR eObject::handleDir(const QPointF &p){ + qDebug()<<"eObject::handleDir(QPointF)"; + HANDLE_DIR hDir = NONE; + if(isSelected()) { + if(m_rLT.contains(p)) hDir = LT; + else if(m_rT.contains(p)) hDir = T; + else if(m_rRT.contains(p)) hDir = RT; + else if(m_rL.contains(p)) hDir = L; + else if(m_rR.contains(p)) hDir = R; + else if(m_rLB.contains(p)) hDir = LB; + else if(m_rB.contains(p)) hDir = B; + else if(m_rRB.contains(p)) hDir = RB; + } + return hDir; +} +//拖拽的虚线矩形 +void eObject::adjustHandle(){ + qDebug()<<"eObject::adjustHandle()"; + const QRectF &r = rect(); + //左上角 + m_rLT = QRectF(r.left() - m_handleLen/2, + r.top() - m_handleLen/2, + m_handleLen, m_handleLen); + //上中 + m_rT = QRectF(r.center().x() - m_handleLen / 2, + r.top() - m_handleLen/2, + m_handleLen, m_handleLen); + //右上角 + m_rRT = QRectF(r.right()-m_handleLen/2, + r.top() - m_handleLen/2, + m_handleLen, m_handleLen); + //左中 + m_rL = QRectF(r.left() - m_handleLen/2, + r.center().y() - m_handleLen / 2, + m_handleLen, m_handleLen); + //右中 + m_rR = QRectF(r.right()-m_handleLen/2, + r.center().y() - m_handleLen / 2, + m_handleLen, m_handleLen); + //左下角 + m_rLB = QRectF(r.left() - m_handleLen/2, + r.bottom()-m_handleLen / 2, + m_handleLen, m_handleLen); + //中下 + m_rB = QRectF(r.center().x() - m_handleLen / 2, + r.bottom()-m_handleLen / 2, + m_handleLen, m_handleLen); + //右下角 + m_rRB = QRectF(r.right()-m_handleLen / 2, + r.bottom()-m_handleLen / 2, + m_handleLen, m_handleLen); +} + + +QString eObject::getFileMd5(QString filePath){ + qDebug()<<"eObject::getFileMd5(QString)"; QFile localFile(filePath); if (!localFile.open(QFile::ReadOnly)) diff --git a/LedOK/wProgramManager/wEditProgram/wElement/eobject.h b/LedOK/wProgramManager/wEditProgram/wElement/eobject.h index 15cd0d9..7f300be 100644 --- a/LedOK/wProgramManager/wEditProgram/wElement/eobject.h +++ b/LedOK/wProgramManager/wEditProgram/wElement/eobject.h @@ -1,9 +1,13 @@ #ifndef EOBJECT_H #define EOBJECT_H - +#include "loappconfig.h" +#include "loapptools.h" +#include "globaldefine.h" #include +#include +#include + #include -#include #include #include #include @@ -16,17 +20,32 @@ #include #include #include -#include "loappconfig.h" -#include "loapptools.h" -#include "globaldefine.h" #define MACRO_DEFAULT_PLAYDURATION 10 +#define INVALID_RECT QRect(-1, -5, -6, -8) class eObjectAttr; -class eObject : public LoQGraphicsObject -{ +class eObject : public QGraphicsObject { Q_OBJECT public: + typedef enum { + NONE = 0, + LT, + T, + RT, + L, + R, + LB, + B, + RB + } HANDLE_DIR; + + enum InteractiveType { + Dynamic = 0, + Static, + Custom + }; + enum ElementType { Text = QGraphicsItem::UserType + 1, Photo, @@ -44,51 +63,95 @@ public: Window }; - struct Data { - qreal x; - qreal y; - qreal w; - qreal h; - }; - -public: explicit eObject(InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr); explicit eObject(QRectF rect, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr); explicit eObject(const QJsonObject &json, InteractiveType type = Dynamic, QGraphicsItem *parent = nullptr); int m_iType=-1; -private: - void init(); - -public: - virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override { Q_UNUSED(event); } - -public: + virtual QRectF boundingRect() const override; + virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; + virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; + virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; + virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *) override{}; + virtual void setInteractiveType(InteractiveType type = Dynamic); virtual QJsonObject save(const QString &pRoot) = 0; virtual QWidget* wAttrElement() = 0; -public: virtual QWidget* wAttr(); virtual QStringList filesList() const { return QStringList(); } virtual QJsonObject elementJson() const; -public: - void setRLimit(const QRectF r); + void setRLimit(const QRectF &r); + QRectF rLimit() const { return m_rLimit; } + InteractiveType interactiveType() const { return m_interactiveType; } + QRectF rect() const { return QRectF(0, 0, m_w, m_h); } + QRectF geometry() const { return QRectF(x(), y(), m_w, m_h); } + + QString getFileMd5(QString filePath); signals: // Qt::BlockingQueuedConnection + void requestUpdate(const QRectF &); + void geometryChanged(const QRectF &); + void rectChanged(const QRectF &); + void sigCiTie(bool,int); + void sPlayBQ(); void sStopBQ(); - void sAttrSetting(const eObject::Data &); public slots: + void setGeometry (qreal x, qreal y, qreal w, qreal h) { setGeometry(QRectF(x, y, w, h)); } + void setGeometry (const QRectF &r); + void updateGeometry(); + void updateGeometry(const QRectF &gLast) { updateGeometry(geometry(), gLast); } + void updateGeometry(const QRectF &gCur, const QRectF &gLast); + void setBrightBianLeft(bool); + void setBrightBianTop(bool); + void setBrightBianRight(bool); + void setBrightBianbottom(bool); + virtual void playElectment() {} virtual void stopElectment() {} - void onAttrChanged(const eObject::Data &data); - void onAttrSetting(const QRectF &r); + void onAttrChanged(const QRectF &); + + +protected: + int handleLen() const { return m_handleLen; } + QPointF pointToParent(const QPointF &p); + HANDLE_DIR handleDir(const QPointF &p); + void adjustHandle(); + + InteractiveType m_interactiveType; + bool m_movable; + int m_handleLen; + QPen m_handlePen; + QPen m_borderPen; + + qreal m_w; + qreal m_h; + QRectF m_rLT; + QRectF m_rT; + + QRectF m_rRT; + QRectF m_rL; + QRectF m_rR; + QRectF m_rLB; + QRectF m_rB; + QRectF m_rRB; + QRectF m_rOrg; + QPointF m_pOrg; + HANDLE_DIR m_hDir; + QRectF m_rLimit; + bool bMousePress=false; + bool bLeftCitie=false; + bool bRightCitie=false; + bool bTopCitie=false; + bool bBottomCitie=false; + int m_keyPressId=0; -private: eObjectAttr *m_wAttr; + void init(); }; #endif // EOBJECT_H diff --git a/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.cpp b/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.cpp index 036ed74..29888e6 100644 --- a/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.cpp +++ b/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.cpp @@ -1,7 +1,8 @@ #include "eobjectattr.h" #include "ui_eobjectattr.h" +#include -eObjectAttr::eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidget *parent) : +eObjectAttr::eObjectAttr(const QRectF &data, const QRectF &rLimit, QWidget *parent) : QGroupBox(parent), ui(new Ui::eObjectAttr) { @@ -11,10 +12,10 @@ eObjectAttr::eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidge m_rLimit.setHeight(rLimit.height()); ui->setupUi(this); - ui->wX->setValue(static_cast(data.x)); - ui->wY->setValue(static_cast(data.y)); - ui->wW->setValue(static_cast(data.w)); - ui->wH->setValue(static_cast(data.h)); + ui->wX->setValue(static_cast(data.x())); + ui->wY->setValue(static_cast(data.y())); + ui->wW->setValue(static_cast(data.width())); + ui->wH->setValue(static_cast(data.height())); connect(ui->wX, SIGNAL(valueChanged(int)), this, SLOT(onXChanged(int))); connect(ui->wY, SIGNAL(valueChanged(int)), this, SLOT(onYChanged(int))); connect(ui->wW, SIGNAL(valueChanged(int)), this, SLOT(onWChanged(int))); @@ -23,6 +24,31 @@ eObjectAttr::eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidge QHBoxLayout *hBox = new QHBoxLayout(); ui->verticalLayout->addLayout(hBox); hBox->addWidget(new QLabel("边框:")); + borderFd = new QComboBox(); + borderFd->setStyleSheet("QComboBox{padding-left:4px; padding-right:4px;}"); + hBox->addWidget(borderFd); + QDirIterator it(":res/borders/", QDirIterator::Subdirectories); + int maxImgWidth = 0; + while(it.hasNext()) { + QString path = it.next(); + QPixmap img(path); + if(img.width()>maxImgWidth) maxImgWidth = img.width(); + borderFd->addItem(QIcon(img), QString::number(img.height())); + } + borderFd->setIconSize(QSize(maxImgWidth, 24)); + connect(borderFd, SIGNAL(currentIndexChanged(int)), this, SLOT(onHChanged(int))); + + hBox->addWidget(new QLabel("特效:")); + borderEffFd = new QComboBox(); + borderEffFd->setStyleSheet("QComboBox{padding-left:4px; padding-right:4px}"); + borderEffFd->addItem("静止"); + borderEffFd->addItem("旋转"); + borderEffFd->addItem("闪烁"); + hBox->addWidget(borderEffFd); + + hBox->addStretch(); + ui->verticalLayout->addStretch(); + } eObjectAttr::~eObjectAttr() @@ -32,6 +58,7 @@ eObjectAttr::~eObjectAttr() void eObjectAttr::onXChanged(int n) { + qDebug()<<"eObjectAttr::onXChanged(int)"; if(m_rLimit != INVALID_RECT) { int mx = n; int mw = ui->wW->value(); @@ -47,6 +74,7 @@ void eObjectAttr::onXChanged(int n) void eObjectAttr::onYChanged(int n) { + qDebug()<<"eObjectAttr::onYChanged(int)"; if(m_rLimit != INVALID_RECT) { int my = n; int mh = ui->wH->value(); @@ -62,6 +90,7 @@ void eObjectAttr::onYChanged(int n) void eObjectAttr::onWChanged(int n) { + qDebug()<<"eObjectAttr::onWChanged(int)"; if(m_rLimit != INVALID_RECT) { int mx = ui->wX->value(); int mw = n; @@ -77,6 +106,7 @@ void eObjectAttr::onWChanged(int n) void eObjectAttr::onHChanged(int n) { + qDebug()<<"eObjectAttr::onHChanged(int)"; if(m_rLimit != INVALID_RECT) { int my = ui->wY->value(); int mh = n; @@ -92,18 +122,16 @@ void eObjectAttr::onHChanged(int n) void eObjectAttr::onAttrChanged() { - eObject::Data data; - data.x = ui->wX->value(); - data.y = ui->wY->value(); - data.w = ui->wW->value(); - data.h = ui->wH->value(); - emit sAttrChanged(data); + qDebug()<<"eObjectAttr::onAttrChanged()"; + QRectF rect(ui->wX->value(), ui->wY->value(), ui->wW->value(), ui->wH->value()); + emit sAttrChanged(rect); } -void eObjectAttr::onAttrSetting(const eObject::Data &data) +void eObjectAttr::onAttrSetting(const QRectF &rect) { - ui->wX->setValue(static_cast(data.x)); - ui->wY->setValue(static_cast(data.y)); - ui->wW->setValue(static_cast(data.w)); - ui->wH->setValue(static_cast(data.h)); + qDebug()<<"eObjectAttr::onAttrSetting(QRectF)"; + ui->wX->setValue(static_cast(rect.x())); + ui->wY->setValue(static_cast(rect.y())); + ui->wW->setValue(static_cast(rect.width())); + ui->wH->setValue(static_cast(rect.height())); } diff --git a/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.h b/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.h index 102ae04..12852a9 100644 --- a/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.h +++ b/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.h @@ -1,10 +1,11 @@ #ifndef EOBJECTATTR_H #define EOBJECTATTR_H +#include "eobject.h" #include #include #include -#include "eobject.h" +#include namespace Ui { class eObjectAttr; @@ -14,9 +15,12 @@ class eObjectAttr : public QGroupBox { Q_OBJECT public: - explicit eObjectAttr(const eObject::Data &data, const QRectF &rLimit, QWidget *parent = nullptr); + explicit eObjectAttr(const QRectF &, const QRectF &, QWidget *parent = nullptr); ~eObjectAttr(); + QComboBox* borderFd; + QComboBox* borderEffFd; + public: void setRLimit(const QRectF r) { @@ -28,11 +32,11 @@ public: } signals: - void sAttrChanged(const eObject::Data &); + void sAttrChanged(const QRectF &); public slots: void onAttrChanged(); - void onAttrSetting(const eObject::Data &); + void onAttrSetting(const QRectF &); protected slots: void onXChanged(int n); diff --git a/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.ui b/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.ui index 96e1b4b..4d3f80b 100644 --- a/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.ui +++ b/LedOK/wProgramManager/wEditProgram/wElement/eobjectattr.ui @@ -6,20 +6,20 @@ 0 0 - 302 - 90 + 249 + 110 0 - 90 + 110 16777215 - 90 + 120 diff --git a/LedOK/wProgramManager/wEditProgram/wElement/ephoto.cpp b/LedOK/wProgramManager/wEditProgram/wElement/ephoto.cpp index ed1c1b0..9898192 100644 --- a/LedOK/wProgramManager/wEditProgram/wElement/ephoto.cpp +++ b/LedOK/wProgramManager/wEditProgram/wElement/ephoto.cpp @@ -124,7 +124,7 @@ void ePhoto::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW painter->save(); painter->drawImage(rect(), m_photo); painter->restore(); - LoQGraphicsObject::paint(painter, option, widget); + eObject::paint(painter, option, widget); } void ePhoto:: deleteContent() { diff --git a/LedOK/wProgramManager/wEditProgram/wElement/etext.cpp b/LedOK/wProgramManager/wEditProgram/wElement/etext.cpp index 1cb4b32..4aba95f 100644 --- a/LedOK/wProgramManager/wEditProgram/wElement/etext.cpp +++ b/LedOK/wProgramManager/wEditProgram/wElement/etext.cpp @@ -358,7 +358,7 @@ void eText::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi painter->restore(); - LoQGraphicsObject::paint(painter, option, widget); + eObject::paint(painter, option, widget); } //void eText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) diff --git a/LedOK/wProgramManager/wEditProgram/wdrawingboard.cpp b/LedOK/wProgramManager/wEditProgram/wdrawingboard.cpp index 60e4f41..d4d1448 100644 --- a/LedOK/wProgramManager/wEditProgram/wdrawingboard.cpp +++ b/LedOK/wProgramManager/wEditProgram/wdrawingboard.cpp @@ -287,7 +287,7 @@ void wDrawingBoard::onCreatElement(int type) } if(nullptr != element1) { - connect(static_cast(element1),SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int))); + connect(element1,SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int))); } } @@ -339,7 +339,7 @@ void wDrawingBoard::onCreatElement(int type) } if(nullptr != element1) { - connect(static_cast(element1),SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int))); + connect(element1,SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int))); } } @@ -444,7 +444,7 @@ void wDrawingBoard::onCreatElement(int type) } if(nullptr != element) { - connect(static_cast(element),SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int))); + connect(element,SIGNAL(sigCiTie(bool,int)),this,SLOT(OnCiTieProcess(bool,int))); } } diff --git a/LedOK/wProgramManager/wEditProgram/wpageitem.cpp b/LedOK/wProgramManager/wEditProgram/wpageitem.cpp index 79cba57..e059e4f 100644 --- a/LedOK/wProgramManager/wEditProgram/wpageitem.cpp +++ b/LedOK/wProgramManager/wEditProgram/wpageitem.cpp @@ -160,7 +160,7 @@ void wPageItem::connectCiTieSignal(wDrawingBoard *drawingboard) eObject *element = static_cast(item); if(element!=nullptr) { - connect(static_cast(element),SIGNAL(sigCiTie(bool,int)),drawingboard,SLOT(OnCiTieProcess(bool,int))); + connect(element,SIGNAL(sigCiTie(bool,int)),drawingboard,SLOT(OnCiTieProcess(bool,int))); } } } @@ -175,7 +175,7 @@ void wPageItem::disconnectCiTieSignal(wDrawingBoard *drawingboard) eObject *element = static_cast(item); if(element!=nullptr) { - disconnect(static_cast(element),SIGNAL(sigCiTie(bool,int)),drawingboard,SLOT(OnCiTieProcess(bool,int))); + disconnect(element,SIGNAL(sigCiTie(bool,int)),drawingboard,SLOT(OnCiTieProcess(bool,int))); } } }