FaceAccess/Linguist/recoUi/recoUiRecognize.h

572 lines
17 KiB
C
Raw Normal View History

2024-07-11 11:27:12 +08:00
#ifndef RECOUIRECOGNIZE_H
#define RECOUIRECOGNIZE_H
#include <QHBoxLayout>
#include <QLabel>
#include <QPropertyAnimation>
#include <QPushButton>
#include <QTime>
#include <QWidget>
#include "UiTools.h"
#include <QStackedWidget>
#include <QEvent>
#include "UiCommon.h"
#include "UiConfig.h"
#include "UiInterfaceForBackstage.h"
class SceneMsgWidget : public QWidget
{
Q_OBJECT
public:
static const int DATE_TIME_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
SceneMsgWidget(QWidget *parent = nullptr);
void setPersonNum(int source, int personNum);
void setBgTransparent(bool set);
int setType(int type);
public slots:
void slotNewDay();
private:
DateTimeWidgetClassical *m_wgtDateTime = nullptr;
QLabel *m_labelPersonNum = nullptr;
int m_type = 0;
};
typedef enum
{
GLOBAL_RECO_END_OK = 0,
GLOBAL_RECO_END_NO,
GLOBAL_RECO_FACE_CARD_NOT_MATCH,
GLOBAL_RECO_SWIPE_CARD,
GLOBAL_RECO_FACE_CAMERA,
GLOBAL_RECO_NOT_PASS_TIME,
GLOBAL_RECO_NEED_RECHECK,
GLOBAL_RECO_PLATFORM_DISCONNECTED,
GLOBAL_RECO_SWIPE_CARD_HERE,
GLOBAL_RECO_HIDE_NAME_AREA,
GLOBAL_RECO_NOT_LIVING,
GLOBAL_RECO_UNAUTH_CARD,
GLOBAL_RECO_PLS_TAP_ID_CARD,
GLOBAL_RECO_PLS_CHECK_STATIC,
GLOBAL_RECO_STATIC_ABNORMAL,
GLOBAL_RECO_SWIPE_ID_OR_HEALEH_CODE,
GLOBAL_RECO_CHECKING,
GLOBAL_RECO_CHECK_FAILED,
GLOBAL_RECO_QRCODE_OVERDUE,
GLOBAL_RECO_NETWORK_ERROR,
GLOBAL_RECO_PLATFORM_ERROR,
GLOBAL_RECO_REQUEST_OVERTIME,
GLOBAL_RECO_SWIPE_TRIP_CARD,
GLOBAL_RECO_SHOW_HEALTH_CODE,
GLOBAL_RECO_RESWIPE_TRIP_CARD,
GLOBAL_RECO_SWIPE_ID_AND_TRIP_CARD,
GLOBAL_RECO_TRIP_CARD_CHECKING,
GLOBAL_RECO_SCAN_YUEJUMA,
GLOBAL_RECO_SCAN_YUEJUMA_OR_SWIPE_ID,
GLOBAL_RECO_PATROL_OK,
GLOBAL_RECO_PATROL_NOT_RIGHT_TIME,
GLOBAL_RECO_SHOW_QRCODE,
GLOBAL_RECO_ID_FAILED, //身份证核验失败
GLOBAL_RECO_IN, //close to recognize
GLOBAL_RECO_IN_SCANNER,
GLOBAL_RECO_CHECK, //靠近重试
GLOBAL_RECO_BEGIN_AUTH,
GLOBAL_RECO_TEMP_REQ, //请移动额头到测温区
GLOBAL_RECO_READ_TEMP_FAILED, //体温检测失败
GLOBAL_RECO_MASK_REQ, //请戴口罩
GLOBAL_RECO_MASK_OK, //口罩检测正常
GLOBAL_RECO_NO_ENTRY, //禁止通行
GLOBAL_RECO_CLEAR_NO_ENTRY, //清除禁止通行字样
GLOBAL_RECO_CLOSE_SCANLINE, //关闭扫描线
GLOBAL_RECO_SHOW_QRCODE_RECO, //显示识别二维码界面
GLOBAL_RECO_SHOW_FACE_RECO, //显示人脸识别界面,可能是从二维码界面切换过去的
GLOBAL_RECO_SHOW_NOTI_MSG, //显示通知信息
GLOBAL_RECO_SHOW_CENTER_MSG, //显示中央信息块
GLOBAL_RECO_SHOW_CENTER_MSG_BIG,//显示超大中央信息块
GLOBAL_RECO_SHOW_CENTER_MSG_BIG_RED,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_GREEN,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_YELLOW,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_RED,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_PURPLE,
GLOBAL_RECO_SHOW_CENTER_MSG_BG_BLACK,
GLOBAL_RECO_SHOW_CENTER_MSG_FIRE_ALARM,
GLOBAL_RECO_TAKE_OFF_MASK,
GLOBAL_RECO_OTHERS
}GLOBAL_RECO_STATE;
typedef enum
{
WIDGET_BG_COLOR_TRAN,
WIDGET_BG_COLOR_BLUE,
WIDGET_BG_COLOR_GREEN,
WIDGET_BG_COLOR_RED
}WIDGET_BG_COLOR_E;
class TmprWidget : public QWidget
{
Q_OBJECT //多语言需要
public:
static const QString TEMP_BG_GREEN_TOP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString TEMP_BG_RED_TOP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int TMPR_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int TMPR_FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit TmprWidget(QWidget *parent = nullptr);
~TmprWidget();
void showNormalTemp(const QString& msg, float temp, bool isC);
void showAbnormalTemp(const QString& msg, float temp, bool isHigh, bool isC);
void setBackgroundColor(WIDGET_BG_COLOR_E color);
private:
QLabel* m_label_tem;
//QLabel* m_label_msg;
//记录当前显示温度差值超分辨率0.1才刷新
float m_ForeheadTmpr;
};
class MsgWidget : public QWidget
{
Q_OBJECT
public:
#define STYLE_QUANTITY 2
static const QString NO_NETWORK_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NETWORK_CONNECTED_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NETWORK_LOGGED_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NET_ETH_IP_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NET_WIFI_IP_RES_FILE[STYLE_QUANTITY][UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString NET_4G_IP_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_BLUE_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_GREEN_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_RED_BOM_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int TIME_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MSG_WORD_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY]; //move to uiConfig if want to set font size for each language
static const int NOTI_MSG_WORD_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit MsgWidget(int timeType, int iconType, const QColor& textColor, QWidget *parent = nullptr);
~MsgWidget();
void setMsgTop(const QString&);
void setMsgBtm(const QString&, const bool setRedColor = false);
void setMsgNoti(const QString& msg, int color);
void setLogo(const QString&, const bool scale = false);
bool hasNoMsg();
void setNetworkStatus(const int);
void setBackgroundColor(const WIDGET_BG_COLOR_E color);
void updateIp(const QString& ip, int type = -1);
void showDevInfo(const QString& devId, const QString& ver);
void setStyle(int timeType, int iconType, const QColor& textColor);
void showRecoUiDevIdAndVer(bool show);
private:
//QLabel* m_label_msgTop;
QLabel* m_label_Icon;
QLabel* m_label_msgBtm;
QLabel* m_label_msgNoti;
QLabel* m_label_time = nullptr;
QLabel* m_label_networkStatus;
QLabel* m_label_ip;
QLabel* m_label_ipType; //eth wifi 4g
TimerUpdate* _timerUpdate = nullptr;
QLabel* m_labelDevId;
QLabel* m_labelVer;
int m_style = 0;
};
class DetectResultWidget : public QWidget
{
Q_OBJECT
public:
typedef enum
{
BG_COLOR_BLUE,
BG_COLOR_RED,
BG_COLOR_TRAN,
BG_COLOR_GREEN,
BG_COLOR_YELLOW
}BG_COLOR_E;
static const int DETECT_RESULT_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int DETECT_RESULT_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MASK_LOGO_SIZE_7INCH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_BLUE_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_GREEN_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_RED_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MASK_LOGO_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit DetectResultWidget(QWidget *parent = nullptr);
virtual ~DetectResultWidget();
void updateMsg(const QString& msg);
protected:
void showMsg(const QString& msg, int msgSize, BG_COLOR_E color, const QPixmap* icon = nullptr);
QLabel* m_label_msg;
private:
QLabel* m_label_Icon;
};
#if 1
class MaskWidget_o : public DetectResultWidget
{
Q_OBJECT
public:
explicit MaskWidget_o(QWidget *parent = nullptr);
MaskWidget_o();
void setMaskMsg(bool maskOk, const QString& msg);
void showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_E);
QString curMsg() const;
private:
bool m_lastMaskOk;
QPixmap m_iconMaskOk;
QPixmap m_iconMaskNull;
};
class PersonWidget_o : public DetectResultWidget
{
Q_OBJECT
public:
explicit PersonWidget_o(QWidget *parent = nullptr);
PersonWidget_o();
void setPersonMsg(RecoUiTextCfg::enTextType, const QString&, const BG_COLOR_E, const bool);
bool allowToShow();
private:
bool isShowingResultMsg;
};
#endif
class MaskWidget : public QWidget
{
Q_OBJECT
public:
explicit MaskWidget(QWidget *parent = nullptr);
QStackedWidget* m_wgts;
void setMaskMsg(bool maskOk, const QString& msg);
void showQRCodeMsg(UiInterfaceForBackstage::QRCode_Msg_E);
void hideSelf();
private:
bool m_lastMaskOk;
};
class PersonWidget : public QWidget
{
Q_OBJECT
public:
typedef enum
{
BG_COLOR_BLUE,
BG_COLOR_RED,
BG_COLOR_TRAN,
BG_COLOR_GREEN,
BG_COLOR_YELLOW
}BG_COLOR_E;
explicit PersonWidget(QWidget *parent = nullptr);
QStackedWidget* m_wgts;
void setPersonMsg(RecoUiTextCfg::enTextType, const QString&, const BG_COLOR_E, const bool);
bool allowToShow();
private:
bool isShowingResultMsg;
};
class CenterMsgWidget : public QWidget
{
Q_OBJECT
public:
static const int WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int FONT_SIZE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit CenterMsgWidget(QWidget *parent = nullptr);
virtual ~CenterMsgWidget();
void showMsg(const QString& msg, int type);
protected:
private:
QLabel* m_label_msg;
int m_centerMsgType = 0;
void paintEvent(QPaintEvent *event);
};
class FinalResultWidget : public QWidget
{
Q_OBJECT
public:
static const QString FINAL_RESULT_OK_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString FINAL_RESULT_FAIL_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int FINAL_RESULT_WIDGET_W_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
explicit FinalResultWidget(QWidget *parent = nullptr);
virtual ~FinalResultWidget();
void showResult(bool pass);
protected:
private:
};
class recoUiRecognize : public PageAcceptMouseAndTouch
{
Q_OBJECT
public:
static const QString BG_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int MSG_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SCANLINE_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString LOGO_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString TEMP_CALIBOX_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString DARK_FILL_LIGHT_RES_FILE[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString PWD_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString PWD_BTN_PRESSED[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int PWD_BTN_W_H[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int SWIP_CARD_WIDGET_WIDTH[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const int SWIP_CARD_WIDGET_HEIGHT[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SWIP_CARD_DAY_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString SWIP_CARD_NIGHT_MODE_WIDGET_BG[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
static const QString CALL_BTN[UiConfig::SUPPORT_SCREEN_SIZE_QUANTITY];
//扫描线运行一次时间,时间越短,运行越快
static const int SCAN_LINE_RUN_TIME = 800;
static constexpr float SCAN_LINE_START_POS_SCALE = 0.2f;
static constexpr float SCAN_LINE_RUN_DISTANCE_SCALE = 0.55f;
static const int SCAN_LINE_LOOP_INTERVAL = 500;
static const int clickNum = UiConfig::MOUSE_CLICK_TIMES_TO_SETTING;
static const int clickGrap = UiConfig::MOUSE_CLICK_INTERVAL_MAX;
static const int QRCODE_SCAN_LINE_RUN_TIME = 1000;
static const int QRCODE_SCAN_LINE_RUN_INTERVAL_TIME = QRCODE_SCAN_LINE_RUN_TIME + 200;
static const int QRCODE_FAILED_MSG_DISPLAY_TIME = 2000; //ms
static constexpr float HIGH_TEMP_VALUE = 42.0f;
static constexpr float LOW_TEMP_VALUE = 35.0f;
typedef enum
{
MSG_BG_COLOR_BOM_NULL,
MSG_BG_COLOR_BOM_BLUE,
MSG_BG_COLOR_BOM_GREEN,
MSG_BG_COLOR_BOM_TOP_GREEN,
MSG_BG_COLOR_BOM_RED,
MSG_BG_COLOR_BOM_TOP_RED,
MSG_BG_COLOR_QRCODE
}MSG_BG_COLOR_E;
typedef enum
{
SCAN_LINE_SWITCH_OFF,
SCAN_LINE_SWITCH_BLUE,
SCAN_LINE_SWITCH_RED
}SCAN_LINE_SWITCH_E;
public:
explicit recoUiRecognize(bool isNightMode, bool hasPwdBtn, bool hasCallBtn, QWidget *parent = nullptr);
~recoUiRecognize();
void setBackstageUiinterface(BackstageInterfaceForUi* interface);
void timerEvent(QTimerEvent *event);
int setScannerState(const SCAN_LINE_SWITCH_E);
void showRecoScanner();
void showRecoFail(GLOBAL_RECO_STATE failType);
void showRecoIDFail();
void showRetry();
void showNoMaskWarn(); //请戴口罩
void showMaskOk();
void showMaskWarn();
void showNoEntry();
void clearNoEntry();
void setPwdButton(bool visible);
int setCamVideoWind();
void setStyle(int style);
void setSceneUiReco(bool toReco);
void setTicketCheckCount(int source, int count);
void setScenePersonCountType(int type);
signals:
void signalChangePage();
void signalShowPwdPage(const QString& name);
void signalScreenTouch();
void callDialButtonClicked(); // 呼叫设备按钮
void callPlatformButtonClicked(const QString &name); // 呼叫管理处
public slots:
void slotsNoSuccessPage(const int nPage);
void slotsSuccessPage(const int nPage, const QString& name);
void slotsDrawScanner(const int nPage, const bool faceAvailable);
void handleRecoResShowTime();
void slotsInteractionChange(const INTERACION_OPTION& interaction, int nSelectRes);
void slotShowNormalTemp(const float temp, const bool isC);
void slotShowAbnormalTemp(const float temp, const bool isHigh, const bool isC);
void slotUpdateLogo(const int);
void slotUpdatePlatformConnectionStatus(const int);
void slotsResetRecoUi();
void slotShowQRCodeMsg(const int);
void slotChangeRecoUiMode(); //二维码开关时更新识别页面,人脸识别模式/二维码扫描模式
void slotTimerQRCodeScanline();
void slotQRCodeSwitchToStandbyStatusFromOvertimeStatus();
void slotUpdateRecoUiIpDisplay(const bool); //增加识别界面ip显示开关更新信号
void slotShowFeatureUpdateProgress(const unsigned current, const unsigned all);
void slotCloseFeatureUpdateProgress();
void slotShowRecoUiMask(int maskType);
void slotNotiMsg(const int nPage, const QString& msg, int color);
void slotLongPressShowSetting();
void slotCenterMsg(const int nPage, const QString& msg);
void slotPwdBtnClicked();
void slotSetUserPwdButton(bool visible);
void slotShowOrHideFaceFrame(bool show);
void slotShowFinalResult(bool pass);
void slotShowHealthCodeAuthStatus(int status);
void slotShowCallBtn(bool show);
void slotShowRecoUiDevIdAndVer(bool show);
private:
void closeRecoResTime();
private:
QLabel* m_label_back;
QWidget* m_wgtCardUnderScreen;
TmprWidget* m_widget_tmpr;
MaskWidget* m_widget_mask;
CenterMsgWidget* m_widget_cMsg;
PersonWidget* m_widget_person;
MsgWidget* m_widget_msg;
QLabel* _moveScanner;
QPropertyAnimation* _ScanCurorAnimation;
SCAN_LINE_SWITCH_E m_currentScanLine;
int m_clickCount;
QTime _preTime;
bool isTouched;
int _timerId; //扫描动画定时器
QTimer* _pShowResTimer;
QString m_name;
MSG_BG_COLOR_E m_currentBackColor; //当前背景颜色,用于显示“禁止通行”时决定字样的颜色
int m_tempRefresh; //温度刷新标志
int m_maskRefresh; //口罩刷新标志
int m_personRefresh; //人员信息刷新标志
int m_NotiMsgRefresh; //通知信息刷新标志
int m_NoEntryRefresh; //通行结果刷新标志
bool m_msgShowed; //是否有前面4个信息在显示中
bool m_faceAivaliable; //当前画面是否存在人脸
int m_showGreenColor;
int m_showRedColor;
int m_scanLineInterval;
bool runScanLine; //扫描线开关状态
int m_scanLinePos;
bool timerTimeoutOperation; //定时器超时后动作类型,就是超时时做什么事
QTimer* m_timer_QRCodeScanLine;
QLabel* m_label_QRCodeScanLine;
QPropertyAnimation* m_QRCodeAnimation;
QTimer* m_QRCodeTimer;
ProgressWidget* m_widget_progress;
QString m_notimsg;
int m_notiMsgColor;
QWidget* m_btnPwd;
bool m_showFaceFrameByUser = false;
bool m_isNightMode = false;
FinalResultWidget* m_resWgt;
QLabel* m_healthCodeAuthstatus;
QPixmap m_bgPm;
QPixmap m_bgSceneIdle;
SceneMsgWidget* m_wgtSceneMsg = nullptr;
RoundedWidget* m_wgtCallDialDev;
RoundedWidget* m_wgtCallMngCenter;
bool eventFilter(QObject *watched, QEvent *event);
void setBackgroundColor(const MSG_BG_COLOR_E index);
void runQRCodeScanLine();
void showQRCodeReco();
void showFaceReco();
bool showPersonWidgetMsg();
bool showNoEntryMsg();
bool showNotiMsg();
bool showTempMsg();
bool showMaskMsg();
bool event(QEvent *event);
bool multiPressToSettingPage();
bool longPressToSettingPage();
QString recoUiTextCfg(RecoUiTextCfg::enTextType type);
bool showCenterMsg(const QString& msg, int type);
void setCardReaderUnderScreenInstructions(bool isNightMode);
};
#endif // RECOUIRECOGNIZE_H