10 changed files with 501 additions and 82 deletions
-
1Projects/QT-Gui-App/Win32-QT-gui-application_2019.vcxproj
-
3Projects/QT-Gui-App/Win32-QT-gui-application_2019.vcxproj.filters
-
89lib/components/object/objectEventReport.cpp
-
4lib/components/object/objectLGS.cpp
-
219lib/gui/controls/ReportRecordWidget.cpp
-
38lib/gui/controls/ReportRecordWidget.h
-
55lib/gui/dialogs/OnvifVideoSourceFinderDialog.cpp
-
125lib/gui/dialogs/ReportsManagerDialog.cpp
-
29lib/gui/dialogs/ReportsManagerDialog.h
-
20lib/gui/dialogs/guiReportsManagerDialog.ui
@ -0,0 +1,219 @@ |
|||||
|
#include "ReportRecordWidget.h"
|
||||
|
|
||||
|
reportRecordWidget::reportRecordWidget(QWidget *parent):QWidget(parent){ |
||||
|
memset( m_pErrorMsg, 0, CTEXT ); |
||||
|
m_bErrorMode = false; |
||||
|
m_bUpdateIsPending = false; |
||||
|
//setFixedSize(240, 180);
|
||||
|
setMouseTracking(true); |
||||
|
//m_eStreamAspectRatio = FAR_UNKNOWN;
|
||||
|
//m_eWidgetAspectRatio = detectAspectRatio(width(), height());
|
||||
|
//setGeometry(m_nPosX, m_nPosY, m_nWidth+1, m_nHeight+1);
|
||||
|
//setMinimumSize(QSize(320, 240));
|
||||
|
//setSizeIncrement(QSize(20, 20));
|
||||
|
//m_backingStore = new QBackingStore( );
|
||||
|
//setBackgroundRole(QPalette::Window);
|
||||
|
setAutoFillBackground(false); |
||||
|
setAttribute(Qt::WA_OpaquePaintEvent); |
||||
|
setCursor(QCursor(Qt::PointingHandCursor)); |
||||
|
//create();
|
||||
|
|
||||
|
m_pPixmap = NULL; |
||||
|
m_pOverlayPixmap = NULL; |
||||
|
//m_pGraber = NULL;
|
||||
|
//m_mFrame = NULL;
|
||||
|
m_mOutput = NULL; |
||||
|
m_pTimer = NULL; |
||||
|
//m_bMouseActive = false;
|
||||
|
//m_bSelected = false;
|
||||
|
m_bErrorMode = false; |
||||
|
//m_pErrorMsg = NULL;
|
||||
|
//m_nMouseX = 0;
|
||||
|
//m_nMouseY = 0;
|
||||
|
//m_pPropertiesProtectorMutex = new basicMutex();
|
||||
|
//m_pWidgetProtectorMutex = new basicMutex();
|
||||
|
//m_pPropertiesProtectorMutex->lock();
|
||||
|
//m_pWidgetProtectorMutex->lock();
|
||||
|
videoIn = NULL; |
||||
|
}; |
||||
|
|
||||
|
reportRecordWidget::~reportRecordWidget(){ |
||||
|
if (m_pTimer) { |
||||
|
m_pTimer->stop(); |
||||
|
delete(m_pTimer); |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
|
bool reportRecordWidget::setReport( REPORT_RECORD *ptr ){ |
||||
|
if (ptr != NULL) { |
||||
|
if (ptr->media_count) { |
||||
|
if (videoIn != NULL) { |
||||
|
delete(videoIn); |
||||
|
}; |
||||
|
videoIn = new videoAVLIBSource(); |
||||
|
videoIn->attachDestination(this); |
||||
|
videoIn->_open(ptr->media_names[0]); |
||||
|
videoIn->init(); |
||||
|
setError(false, ""); |
||||
|
} else { |
||||
|
setError(true, "No Media Data"); |
||||
|
}; |
||||
|
} else { |
||||
|
setError(true, "No Report Data"); |
||||
|
}; |
||||
|
return true; |
||||
|
}; |
||||
|
|
||||
|
void reportRecordWidget::setError(bool AAA, CSTR Message){ |
||||
|
m_bErrorMode = AAA; |
||||
|
memcpy( m_pErrorMsg, Message, CTEXT ); |
||||
|
m_pErrorMsg[CTEXT - 1] = (char)0; |
||||
|
//if (AAA) LOG("ERROR TRUE"); else LOG("ERROR FALSE");
|
||||
|
}; |
||||
|
|
||||
|
void reportRecordWidget::render(QPainter* painter) { |
||||
|
if (painter != NULL) { |
||||
|
try { |
||||
|
//char buffer[64];
|
||||
|
//sprintf(buffer, "Coords: %dx%d %d %d ? %d %d", pos().x(), pos().y(), width(), height(), m_nMouseX, m_nMouseY);
|
||||
|
painter->save(); |
||||
|
//painter->fillRect(QRect(0, 0, width(), height()), Qt::green);
|
||||
|
QPen BgPen(Qt::SolidPattern, 3); |
||||
|
BgPen.setColor(Qt::black); |
||||
|
if (m_bErrorMode && m_pOverlayPixmap != NULL) { |
||||
|
painter->drawPixmap(QRect(0, 0, width(), height()), *m_pOverlayPixmap); |
||||
|
if (m_pErrorMsg != NULL) { |
||||
|
QPen FgPen(Qt::SolidPattern, 0); |
||||
|
FgPen.setColor(Qt::yellow); |
||||
|
painter->setPen(BgPen); |
||||
|
painter->drawText(QRect(0, 0, width(), height()), Qt::AlignHCenter | Qt::AlignBaseline, m_pErrorMsg); |
||||
|
painter->setPen(FgPen); |
||||
|
painter->drawText(QRect(0, 0, width(), height()), Qt::AlignHCenter | Qt::AlignBaseline, m_pErrorMsg); |
||||
|
}; |
||||
|
} else { |
||||
|
painter->drawPixmap(QRect(0, 0, width(), height()), *m_pPixmap); |
||||
|
}; |
||||
|
//if (m_bSelected) {
|
||||
|
// BgPen.setColor(Qt::blue);
|
||||
|
// painter->setPen(BgPen);
|
||||
|
// painter->drawRect(QRect(2, 2, width() - 4, height() - 4));
|
||||
|
//};
|
||||
|
//if (m_bMouseActive){
|
||||
|
// if (m_pOverlayPixmap != NULL){
|
||||
|
// painter->drawPixmap(QRect(0, 0, width(), height()), *m_pOverlayPixmap);
|
||||
|
// };
|
||||
|
//};
|
||||
|
painter->restore(); |
||||
|
} catch (std::exception& e) { |
||||
|
//LOG_ERROR("Render exception!");
|
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
|
bool reportRecordWidget::init(void) { |
||||
|
//LOG("init.");
|
||||
|
m_pPixmap = new QPixmap(width(), height()); //, QImage::Format_RGB888 );
|
||||
|
if (m_pPixmap == NULL) return false; |
||||
|
m_pOverlayPixmap = new QPixmap(":pictures/43a.png", "PNG"); |
||||
|
m_pTimer = new QTimer(); |
||||
|
if (m_pTimer != NULL) { |
||||
|
QObject::connect(m_pTimer, SIGNAL(timeout()), this, SLOT(update())); |
||||
|
m_pTimer->start(100); |
||||
|
}; |
||||
|
m_pPixmap->fill(Qt::black); |
||||
|
//m_pPropertiesProtectorMutex->unlock();
|
||||
|
//m_pWidgetProtectorMutex->unlock();
|
||||
|
return false; |
||||
|
}; |
||||
|
|
||||
|
void reportRecordWidget::pushFrame(cv::Mat* Frame, void* src) { |
||||
|
if (Frame != NULL && m_pPixmap != NULL) { |
||||
|
m_mOutput = Frame; |
||||
|
try { |
||||
|
assert(m_mOutput->isContinuous()); |
||||
|
//m_pWidgetProtectorMutex->lock();
|
||||
|
assert(m_pPixmap); |
||||
|
QPainter dbPainter(m_pPixmap); |
||||
|
if ( 0 ) { //m_eStreamAspectRatio != m_eWidgetAspectRatio) {
|
||||
|
/* int tOffset;
|
||||
|
if (m_eStreamAspectRatio > m_eWidgetAspectRatio) { |
||||
|
int tHeight; |
||||
|
tHeight = (int)((float)m_pPixmap->width() / m_eStreamAspectRatio); |
||||
|
tOffset = (m_pPixmap->height() - tHeight) >> 1; |
||||
|
dbPainter.drawImage(QRect(0, tOffset, width(), tHeight), |
||||
|
QImage((unsigned char*)m_mOutput->data, m_mOutput->cols, m_mOutput->rows, QImage::Format_RGB888), |
||||
|
QRect(0, 0, m_mOutput->cols, m_mOutput->rows)); |
||||
|
} else { |
||||
|
int tWidth; |
||||
|
tWidth = (int)((float)m_pPixmap->height() * m_eStreamAspectRatio); |
||||
|
tOffset = (m_pPixmap->width() - tWidth) >> 1; |
||||
|
dbPainter.drawImage(QRect(tOffset, 0, tWidth, height()), |
||||
|
QImage((unsigned char*)m_mOutput->data, m_mOutput->cols, m_mOutput->rows, QImage::Format_RGB888), |
||||
|
QRect(0, 0, m_mOutput->cols, m_mOutput->rows)); |
||||
|
};*/ |
||||
|
} else { |
||||
|
dbPainter.drawImage(QRect(0, 0, width(), height()), QImage((unsigned char*)m_mOutput->data, m_mOutput->cols, m_mOutput->rows, QImage::Format_RGB888), QRect(0, 0, m_mOutput->cols, m_mOutput->rows)); |
||||
|
}; |
||||
|
//m_pWidgetProtectorMutex->unlock();
|
||||
|
} catch (std::exception& e) { |
||||
|
//LOG_ERROR("Exception catched:");
|
||||
|
//LOG_ERROR(e.what());
|
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
|
||||
|
void reportRecordWidget::renderLater() { |
||||
|
if (!m_bUpdateIsPending) { |
||||
|
m_bUpdateIsPending = true; |
||||
|
QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest)); |
||||
|
//LOG("Delayed Rendering Request");
|
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
void reportRecordWidget::paintEvent(QPaintEvent* evt) { |
||||
|
renderNow(); |
||||
|
} |
||||
|
|
||||
|
void reportRecordWidget::renderNow() { |
||||
|
//m_pWidgetProtectorMutex->lock();
|
||||
|
try { |
||||
|
//if (m_nMenuActivityCounter)m_nMenuActivityCounter--;
|
||||
|
//else if (m_bMouseActive)m_bMouseActive = false;
|
||||
|
|
||||
|
QPainter painter(this); |
||||
|
painter.setRenderHint(QPainter::Antialiasing); |
||||
|
//painter.begin(this);
|
||||
|
render(&painter); |
||||
|
//painter.end();
|
||||
|
} catch (std::exception& e) { |
||||
|
//LOG_ERROR("RenderNow exception!");
|
||||
|
}; |
||||
|
//m_pWidgetProtectorMutex->unlock();
|
||||
|
}; |
||||
|
|
||||
|
bool reportRecordWidget::event(QEvent* event) { |
||||
|
if (event->type() == QEvent::UpdateRequest) { |
||||
|
m_bUpdateIsPending = false; |
||||
|
renderNow(); |
||||
|
return true; |
||||
|
} |
||||
|
if (event->type() == QEvent::MouseButtonRelease) { |
||||
|
//m_bSelected = (m_bSelected) ? false : true;
|
||||
|
//if (((QMouseEvent*)event)->button() == Qt::RightButton) {
|
||||
|
// ShowContextMenu(QPoint(((QMouseEvent*)event)->x(), ((QMouseEvent*)event)->y()));
|
||||
|
//} else selected(m_pSignalParameter);
|
||||
|
return true; |
||||
|
} |
||||
|
if (event->type() == QEvent::MouseButtonDblClick) { |
||||
|
//m_bEnhanced = (m_bEnhanced) ? false : true;
|
||||
|
renderLater(); |
||||
|
return true; |
||||
|
} |
||||
|
if (event->type() == QEvent::MouseMove) { |
||||
|
//m_nMouseX = ((QMouseEvent*)event)->x();
|
||||
|
//m_nMouseY = ((QMouseEvent*)event)->y();
|
||||
|
//m_bMouseActive = true;
|
||||
|
//m_nMenuActivityCounter = 75;// 3 Sec
|
||||
|
}; |
||||
|
return QWidget::event(event); |
||||
|
}; |
||||
@ -0,0 +1,38 @@ |
|||||
|
#ifndef __REPORT_RECORD_WIDGET__ |
||||
|
#define __REPORT_RECORD_WIDGET__ |
||||
|
|
||||
|
#include "../gui.h" |
||||
|
#include <opencv2/opencv.hpp> |
||||
|
#include "../../components/base/basicLIBAV.h" |
||||
|
#include "../../components/base/basicMediaDestination.h" |
||||
|
#include "../../components/object/objectEventReport.h" |
||||
|
|
||||
|
class reportRecordWidget: public QWidget, public basicMediaDestination{ |
||||
|
private: |
||||
|
char m_pErrorMsg[CTEXT]; |
||||
|
bool m_bErrorMode; |
||||
|
bool m_bUpdateIsPending; |
||||
|
cv::Mat * m_mOutput; |
||||
|
protected: |
||||
|
QPixmap * m_pPixmap; |
||||
|
QPixmap * m_pOverlayPixmap; |
||||
|
videoAVLIBSource * videoIn; |
||||
|
QTimer * m_pTimer; |
||||
|
private: |
||||
|
void setError(bool AAA, CSTR Message = NULL); |
||||
|
public: |
||||
|
explicit reportRecordWidget(QWidget* parent = NULL); |
||||
|
~reportRecordWidget(); |
||||
|
virtual void render(QPainter* painter); |
||||
|
bool init(void); |
||||
|
virtual void pushFrame(cv::Mat* Frame, void* src = NULL); |
||||
|
bool setReport(REPORT_RECORD *ptr); |
||||
|
public slots: |
||||
|
void renderLater(); |
||||
|
void renderNow(); |
||||
|
protected: |
||||
|
void paintEvent(QPaintEvent* evt); |
||||
|
bool event(QEvent* event); |
||||
|
}; |
||||
|
|
||||
|
#endif |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue