FaceAccess/Linguist/interface/View.cpp

636 lines
12 KiB
C++
Raw Normal View History

2024-07-11 11:27:12 +08:00
/********************************************************************
* Name : View.cpp
* Param :
* Return :
* Describ :
* Author :
* Date :
********************************************************************/
#include "View.h"
#include "rw_zlog.h"
#include "param_manage.h"
#include "timer/timer.h"
#include "AsyncEvent.h"
#include "recoUiCallConsole.h"
View * View::m_this = nullptr;
View::View( )
{
m_ui = nullptr;
m_backstage = nullptr;
}
View* View::getInstance()
{
if( nullptr == m_this )
{
m_this = new View;
}
return m_this;
}
int View::viewInitBackstage( void* pParaMng, void* pObjs, bool needSetupWizard)
{
m_backstage = new Backstage(pParaMng, pObjs);
m_backstage->stopIdentyState();
m_needSetupWizard = needSetupWizard;
return 0;
}
int View::viewCreateUi(int languageType, bool showCursor)
{
LOGD("language type: %d", languageType);
if(languageType < 0){
return -1;
}
m_ui = new mainUi(languageType, m_needSetupWizard);
if(nullptr == m_backstage){
LOGE("backstage not ready!!!");
return -2;
}
showCursorSwitch(showCursor);
m_ui->setBackstageUiinterface(m_backstage);
LOGI("ui version:%lld", m_ui->getUiVersion());
return 0;
}
int View::viewCreateSettingUi()
{
int ret = -1;
if(m_ui){
m_ui->createSettingUi();
ret = 0;
}
return ret;
}
void View::showRecoMsgReco()
{
if (m_ui)
{
m_ui->showRecoMsgReco();
}
}
void View::showUnauthorizedPage()
{
if (m_ui)
{
m_ui->showUnauthorizedPage();
}
}
void View::showScreenSaverPage()
{
if (m_ui)
{
m_ui->showScreenSaverPage();
}
}
void View::showErrorDisplayPage(enErrCode errCode)
{
}
void View::notifyFaceInfo(const bool faceAvailable)
{
if(m_ui)
{
m_ui->notifyFaceInfo(faceAvailable);
}
}
void View::showRecoMsgRetry()
{
if (m_ui)
{
m_ui->showRecoMsgRetry();
}
}
void View::showRecoMsgFail(int failType)//未经许可人员
{
if (m_ui)
{
m_ui->showRecoMsgFail(failType);
}
}
void View::showRecoSuccess(const char *name)
{
if (m_ui)
{
m_ui->showRecoSuccess(name);
}
}
void View::showFaceImg(const unsigned char *imgData, const int imgLen)
{
if (m_ui)
{
m_ui->showFaceImg(imgData, imgLen);
}
}
void View::showRecoMsgIDFail()//身份证核验失败
{
if (m_ui)
{
m_ui->showRecoMsgIDFail();
}
}
void View::updatePlatformConnectionStatus(UiInterfaceForBackstage::PLATFORM_CONNECTION_STATUS_E state)
{
//LOGD("m_ui===%p", m_ui);
if (m_ui)
{
m_ui->updatePlatformConnectionStatus(state);
}
}
void View::showRecoMsgMoveForehead() //移动到额头区
{
if (m_ui)
{
m_ui->showRecoMsgMoveForehead();
}
}
void View::showRecoMsgForeheadNormalTemp(const float temp, const bool isC) //显示正常温度
{
//LOGD("view show temp: %f", temp);
if (m_ui)
{
m_ui->showRecoMsgForeheadNormalTemp(temp, isC);
}
}
void View::showRecoMsgForeheadAbnormalTemp(const float temp, const bool isHigh, const bool isC) //显示异常温度
{
//LOGD("view show temp: %f", temp);
if (m_ui)
{
m_ui->showRecoMsgForeheadAbnormalTemp(temp, isHigh, isC);
}
}
void View::showRecoMsgReadTempFailed() //体温检测失败
{
if (m_ui)
{
m_ui->showRecoMsgReadTempFailed();
}
}
void View::showRecoMsgNoMaskWarn() //请戴口罩
{
if (m_ui)
{
m_ui->showRecoMsgNoMaskWarn();
}
}
void View::showRecoMsgMaskOk() //口罩检测成功
{
if (m_ui)
{
m_ui->showRecoMsgMaskOk();
}
}
void View::showRecoMsgNoEntry(const bool noEntry) //禁止通行
{
if (m_ui)
{
m_ui->showRecoMsgNoEntry(noEntry);
}
}
void View::showRecoMsgMaskWarn()
{
m_ui->showRecoMsgMaskWarn();
}
void View::turnOffScanLine() //关闭扫描线
{
if (m_ui)
{
m_ui->turnOffScanLine();
}
}
void View::updateLogo(int logo)
{
if (m_ui)
{
LOGD("logo=======%d", logo);
m_ui->updateLogo((enLogo)logo);
}
}
void View::showQRCodeResult(int result)
{
if (m_ui)
{
if(result)LOGD("result=======%d", result);
m_ui->showQRCodeMsg(static_cast<UiInterfaceForBackstage::QRCode_Msg_E>(result));
}
}
void View::showQRCodeReco()
{
LOGD("m_ui==%p", m_ui);
if (m_ui)
{
m_ui->showQRCodeReco();
}
}
void View::showFaceReco()
{
if (m_ui)
{
m_ui->showFaceReco();
}
}
void View::updateRecoUiIp()
{
if (m_ui)
{
m_ui->updateRecoUiIp();
}
}
void View::showFeatureUpdateProgress(const unsigned current, const unsigned all)
{
if (m_ui){
m_ui->showFeatureUpdateProgress(current, all);
}
}
void View::closeFeatureUpdateProgress()
{
if (m_ui){
m_ui->closeFeatureUpdateProgress();
}
}
void View::showCalibrationBox()
{
if (m_ui)
{
m_ui->showRecoUiMask((int)View::enRecoUiMaskType::enRecoUiMaskTempCalibra);
}
}
void View::closeCalibrationBox()
{
if (m_ui)
{
m_ui->showRecoUiMask((int)View::enRecoUiMaskType::enRecoUiMaskLight);
}
}
void View::showNotiMsg(const char *msg, int color, double displayTime)
{
if (m_ui && msg){
m_ui->showNotiMsg(msg, color);
if(strlen(msg)){
rw_timer_del(m_ullNotiMsgShowTmr);
rw_timer_add(&m_ullNotiMsgShowTmr, displayTime, 1, msgShowOvertimeCloseCB, (void*)0);
}
}
}
void View::switchLightOrDarkRecoUi(bool isDark)
{
if (m_ui)
{
View::enRecoUiMaskType type = View::enRecoUiMaskType::enRecoUiMaskLight;
if(isDark){
type = View::enRecoUiMaskType::enRecoUiMaskDark;
}
m_ui->showRecoUiMask((int)type);
}
}
void View::updateScreenSaver()
{
if (m_ui)
{
m_ui->updateScreenSaver();
}
}
void View::grabScreen(const char* picName, int rotate)
{
if (m_ui)
{
m_ui->grabScreen(picName, rotate);
}
}
void View::switchToRecoUi()
{
if (m_ui)
{
m_ui->switchToRecoUi();
}
}
void View::showCenterMsg(const char* msg, double displayTime, int type)
{
if (m_ui && msg){
LOGI("showCenterMsg:%s", msg);
m_ui->showCenterMsg(msg, type);
rw_timer_del(m_ullCenterMsgShowTmr);
if(strlen(msg)){
LOGI("enable timer...");
rw_timer_add(&m_ullCenterMsgShowTmr, displayTime, 1, msgShowOvertimeCloseCB, (void*)1);
}
}
}
void View::closeCenterMsgWin()
{
LOGI("close center msg window");
m_ui->showCenterMsg("", 0);
rw_timer_del(m_ullCenterMsgShowTmr);
}
void View::showDrawPage()
{
if (m_ui){
m_ui->showDrawPage();
}
}
void View::showCursorSwitch(bool sw)
{
if (m_ui){
m_ui->showCursorSwitch(sw);
}
}
void View::setPwdButton(bool visible)
{
if (m_ui){
m_ui->setPwdButton(visible);
}
}
void View::showPwdUiPersonName(const char* name)
{
if (m_ui){
m_ui->showPwdUiPersonName(name);
}
}
View::~View()
{
delete m_ui;
delete m_backstage;
}
int View::msgShowOvertimeCloseCB(void *data)
{
if(0 == (int)data){
View::getInstance()->showNotiMsg("", 0);
}else if(1 == (int)data){
View::getInstance()->showCenterMsg("");
}
return 0;
}
int View::setNetWire(const stNetWire& wireCfg)
{
return m_backstage->setNetWireCfg(wireCfg);
}
int View::setServerAddr(const char *addr, bool byQrcode)
{
return m_backstage->setServerAddr((char*)addr, byQrcode);
}
void View::showUserPwd(const char* name)
{
if (m_ui){
m_ui->showUserPwd(name);
}
}
void View::showUserPwdError(int type, int color)
{
if (m_ui){
m_ui->showUserPwdError(type, color);
}
}
void View::showUserCandidate(const char** opns, int opnsNum)
{
if (m_ui){
m_ui->showUserCandidate("请选择项目", opns, opnsNum);
}
}
void View::showDevTestPage(const char* devCfgMsg)
{
if (m_ui){
m_ui->showDevTestPage(devCfgMsg);
UiConfig::GetInstance()->setDevTestStatus(true);
}
}
void View::setDevTestMesAddrAndProdNoText(const char* text)
{
if (m_ui){
m_ui->setDevTestMesAddrAndProdNoText(text);
}
}
void View::setDevTestPcbSeqText(const char* text)
{
if (m_ui){
m_ui->setDevTestPcbSeqText(text);
}
}
#if 0
void View::setDevTestConfigInfo(const char* text)
{
m_ui->setDevTestConfigInfo(text);
}
#endif
void View::showOrHideFaceFrame(bool show)
{
if (m_ui){
m_ui->showOrHideFaceFrame(show);
}
}
void View::showPassResult(bool pass)
{
if (m_ui){
m_ui->showPassResult(pass);
}
}
void View::showRecoUiColorFaceSnapshot(const char* path)
{
m_ui->showRecoUiColorFaceSnapshot(path);
}
void View::showRecoUiColorFaceSnapshot(const unsigned char* jpgDate, int len)
{
m_ui->showRecoUiColorFaceSnapshot(jpgDate, len);
}
void View::recoUiswitchToType(int type)
{
m_ui->recoUiswitchToType(type);
}
void View::qrcodeFastCfgResult(bool isSuccessed)
{
m_ui->qrcodeFastCfgResult(isSuccessed);
}
void View::icCardResult(const char *icCardNum)
{
m_ui->icCardResult(icCardNum);
}
bool View::isInSettingUi()
{
return m_ui->isInSettingUi();
}
void View::updateAdScreen()
{
return m_ui->updateAdScreen();
}
void View::showHealthMsg(int type, float temp, const char* msg, bool pass,
const unsigned char* jpgDate, int jpgLen, const char* tripCity, const char* failReason, int bgColor, int displayTime)
{
m_ui->showHealthMsg(type, temp, msg, pass, jpgDate, jpgLen, tripCity, failReason, bgColor, displayTime);
}
/*
0
1
2
3
4
*/
void View::showHealthCodeAuthStatus(int status)
{
m_ui->showHealthCodeAuthStatus(status);
}
void View::showAntiDismantleDetect(bool upload)
{
m_ui->showAntiDismantleDetect(upload);
}
void View::showSceneResult(int result, const char* resultText, const char* businessInfo, int displayTime)
{
m_ui->showSceneResult(result, resultText, businessInfo, displayTime);
}
void View::updatePersonNumAccessed(int personAccess, int personAll)
{
m_ui->updatePersonNumAccessed(personAccess, personAll);
}
bool View::isScenePassing()
{
return m_ui->isScenePassing();
}
void View::setSceneUiPersonCountType(int type)
{
return m_ui->setSceneUiPersonCountType(type);
}
void View::updateSceneUiPersonCount(int count)
{
m_ui->updateSceneUiPersonCount(count);
}
void View::showCallBtn(bool callButton, bool videoButton) {
auto event = new AsyncEvent([=]() {
emit m_ui->signalShowCallBtn(callButton, videoButton);
});
QCoreApplication::postEvent(m_ui, event);
}
void View::showCallDialPage()
{
m_ui->showCallDialPage();
}
void View::showCallReceiverCallIn(const char* callerName, bool videoEnable)
{
m_ui->setCallConsoleStatus(videoEnable ? 51 : 50, callerName);
}
void View::showCallInitiatorConnected(bool videoEnable)
{
m_ui->setCallConsoleStatus(videoEnable ? 1 : 0, "");
}
void View::exitCall()
{
m_ui->setCallConsoleStatus(100, "");
}
void View::showCallPlatformCallIn(const char *callerName) {
m_ui->setCallConsoleStatus(recoUiCallConsole::PlatformCallIn, callerName);
}
void View::showCallVideoPlayer(bool show) {
m_ui->setCallConsoleStatus(show ? recoUiCallConsole::ShowVideo : recoUiCallConsole::HideVideo, "");
}
void View::setDndMode(bool enabled, const std::chrono::system_clock::time_point &time) {
auto event = new AsyncEvent([=]() { m_ui->setDndMode(enabled, time); });
QCoreApplication::postEvent(m_ui, event);
}
void View::showRecoUiDevIdAndVer(bool show)
{
m_ui->showRecoUiDevIdAndVer(show);
}
void View::showUserItemChoose(const std::vector<std::string>& items)
{
m_ui->showUserItemChoose(items);
}
#include <QImage>
#include <QMatrix>
void rotateRgbImage(const unsigned char* inputImage, int width, int height, unsigned char* outptuImg, double angle)
{
QImage inputImg((const uchar*)inputImage, width, height, QImage::Format_RGB888);
QMatrix matrix;
matrix.rotate(angle);
memcpy(outptuImg, inputImg.transformed(matrix).bits(), width * height * 3);
}