You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
550 lines
19 KiB
550 lines
19 KiB
#include "RangeMapWidget.h"
|
|
#include "../../components/base/basicCameraPTZ.h"
|
|
|
|
RangeMapWidget::RangeMapWidget(QWidget *parent) : QWidget(parent), targetDisplay(), m_mImageLock(){
|
|
m_dScaleFactor = 1.f;
|
|
//setStyleSheet(QString::fromUtf8("border: 1px;"));
|
|
setContentsMargins(0, 0, 0, 0);
|
|
m_pVerticalLayout = new QVBoxLayout(this);
|
|
m_pVerticalLayout->setSpacing(0);
|
|
setLayout(m_pVerticalLayout);
|
|
setMinimumSize(400, 325);
|
|
setMaximumSize(2304, 325);
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
setCursor(QCursor(Qt::CrossCursor));
|
|
|
|
|
|
m_pScrollArea = new QScrollArea(parent);
|
|
//m_pScrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
m_pScrollArea->setMinimumSize(400, 310);
|
|
m_pScrollArea->setMaximumSize(2304, 310);
|
|
m_pScrollArea->setBackgroundRole(QPalette::Dark);
|
|
m_pImageLabel = new QLabel();
|
|
m_pImageLabel->setBackgroundRole(QPalette::Base);
|
|
m_pImageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
|
m_pImageLabel->setGeometry(0, 0, 2304, 288);
|
|
m_pImageLabel->setScaledContents(true);
|
|
m_pScrollArea->setWidget(m_pImageLabel);
|
|
m_pScrollArea->viewport()->installEventFilter(this);
|
|
m_pScrollArea->setMouseTracking( true );
|
|
|
|
m_pVerticalLayout->addWidget(m_pScrollArea);
|
|
|
|
m_bShowMinimums = true;
|
|
m_pOpLabel = new QLabel(this);
|
|
m_pOpLabel->setText(QString::fromUtf8(""));
|
|
m_pOpLabel->setAutoFillBackground(false);
|
|
m_pOpLabel->setGeometry(QRect(250, 440, 220, 13));
|
|
|
|
m_pStatusTimer = new QTimer(this);
|
|
if (m_pStatusTimer != NULL){
|
|
connect(m_pStatusTimer, &QTimer::timeout, this, &RangeMapWidget::handleTimer);
|
|
m_pStatusTimer->start(300);
|
|
};
|
|
|
|
m_nCursorX = -1;
|
|
m_nCursorY = -1;
|
|
//setVisible(false);
|
|
//setMouseTracking( true );
|
|
//m_pScrollArea->grabMouse();
|
|
m_oImage = QImage(BASE_SCAN_COUNT*KERNEL_COUNT, Q_SCAN_COUNT+1, QImage::Format_RGB888 );
|
|
m_oImage.fill(QColor(255, 255, 255));
|
|
//m_oImage = QImage("rm_bgr.png");
|
|
//setImage( m_oImage );
|
|
m_pRanges = NULL;
|
|
m_nRangesCount = 0;
|
|
m_pDeviceControl = NULL;
|
|
m_fMaxRange = 300.f;
|
|
m_bCurrentMouseMode = 0; // No Mode;
|
|
//loadPolygons("polygons.ply");
|
|
//loadFromFile("test.raw");
|
|
//https://www.ebay.com/itm/KKMOON-16CH-960H-D1-CCTV-Network-Standalone-H-264-HD-DVR-Security-System-Z5Z4-/161965230971
|
|
//https://www.ebay.com/itm/KKmoon-1080P-PTZ-CCTV-Camera-IR-Day-Night-2MP-AHD-2-8-12mm-Auto-Focus-IP66-P1F5/112672024175
|
|
//https://www.ebay.com/itm/KKMOON-960P-AHD-CCTV-CAMERA-1-3MP-HD-ANALOG-OUTDOOR-SECURITY-BULLET-METAL-Z9M4/322419271266
|
|
m_pPoint = NULL;
|
|
//m_mImageLock.unlock();
|
|
updateBackStage();
|
|
updateDisplay();
|
|
};
|
|
|
|
RangeMapWidget::~RangeMapWidget(){
|
|
};
|
|
|
|
void RangeMapWidget::updateBackStage(void){
|
|
m_mImageLock.lock();
|
|
try {
|
|
int x, y, Range, mid, seg;
|
|
uint32_t color;
|
|
|
|
//QPainter painter;
|
|
if (1){//painter.begin(&m_oImage)){
|
|
m_oImage.fill(QColor(0, 0, 0));
|
|
for (int index = 0; index < m_nRangesCount; index++){
|
|
if (m_bShowMinimums){
|
|
Range = m_pRanges[index].values.min;
|
|
makeCoords(Range, index, x, y, mid, seg, true);
|
|
#ifdef MIRROR_DIFF_COLORS
|
|
switch( mid ){
|
|
case 0: color = interpolate(0xFFFFFF00, 0xFF000000, RangeA / 4095.f); break;
|
|
case 1: color = interpolate(0xFF00FFFF, 0xFF000000, RangeA / 4095.f); break;
|
|
case 2: color = interpolate(0xFFFF00FF, 0xFF000000, RangeA / 4095.f); break;
|
|
case 3: color = interpolate(0xFFFFFFFF, 0xFF000000, RangeA / 4095.f); break;
|
|
};
|
|
#else
|
|
if (m_pRanges[index].values.cnt){
|
|
color = interpolate(0xFFFFFFFF, 0xFF000000, ((float)(Range)) / 4096.f);
|
|
} else color = 0xFF0000FF;
|
|
#endif
|
|
m_oImage.setPixel(x, y, color);
|
|
//painter.drawPoint( x, y );
|
|
} else {
|
|
Range = m_pRanges[index].values.max;
|
|
makeCoords(Range, index, x, y, mid, seg, true);
|
|
#ifdef MIRROR_DIFF_COLORS
|
|
switch( mid ){
|
|
case 0: color = interpolate(0xFFFFFF00, 0xFF000000, RangeA / 4095.f); break;
|
|
case 1: color = interpolate(0xFF00FFFF, 0xFF000000, RangeA / 4095.f); break;
|
|
case 2: color = interpolate(0xFFFF00FF, 0xFF000000, RangeA / 4095.f); break;
|
|
case 3: color = interpolate(0xFFFFFFFF, 0xFF000000, RangeA / 4095.f); break;
|
|
};
|
|
#else
|
|
if (m_pRanges[index].values.cnt){
|
|
color = interpolate(0xFFFFFFFF, 0xFF000000, ((float)(Range)) / 4096.f);
|
|
} else color = 0xFF0000FF;
|
|
#endif
|
|
m_oImage.setPixel(x, y, color);
|
|
//painter.drawPoint( x, y );
|
|
};
|
|
};
|
|
//painter.end();
|
|
};
|
|
} catch ( exception e ){};
|
|
m_mImageLock.unlock();
|
|
};
|
|
|
|
void RangeMapWidget::updateDisplay( void ){
|
|
m_mImageLock.lock();
|
|
try{
|
|
m_oPixmap = QPixmap::fromImage(m_oImage);
|
|
char tBuf[64];
|
|
|
|
QPainter painter;
|
|
if (painter.begin(&m_oPixmap)){
|
|
painter.setRenderHint((QPainter::RenderHint)7);// QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing
|
|
|
|
QPen BgPen(Qt::SolidPattern, 2);
|
|
BgPen.setColor(QColor(255, 0, 255, 255));
|
|
painter.setPen(BgPen);
|
|
int Y1, Y2;
|
|
Y1 = Q_SCAN_COUNT - ((Q_SCAN_COUNT*Q_SHIFT_DOWN_FOV) / Q_DEGREE_FOV);
|
|
Y2 = Q_SCAN_COUNT - ((Q_SCAN_COUNT*(Q_SHIFT_DOWN_FOV + 90.f)) / Q_DEGREE_FOV);
|
|
painter.drawLine(0, Y1, 2304, Y1);
|
|
painter.drawLine(0, Y2, 2304, Y2);
|
|
float k = 2304.f / 36.f;
|
|
int cX;
|
|
for (int i = 0; i < 36; i++){
|
|
cX = k * i;
|
|
painter.drawLine(cX, 0, cX, 288);
|
|
sprintf(tBuf, "%d", 360 - (i * 10));
|
|
painter.drawText(QRect(cX + 5, Y1 + 1, cX + 15, Y1 + 6), Qt::AlignLeft | Qt::AlignBaseline, tBuf);
|
|
};
|
|
|
|
// Draw Targets
|
|
for (uint8_t index = 0; index < MAX_SIMUL_TARGETS; index++){
|
|
if (m_aTargets[index].status != 0){
|
|
painter.fillRect(m_aTargets[index].dX - 2, m_aTargets[index].dY - 2, 5, 5, m_aTargets[index].color);// QColor( 255, 0, 0 ) );
|
|
}
|
|
else break;
|
|
};
|
|
|
|
if (m_pDeviceControl != NULL){
|
|
if (m_vAllPoly.size()){
|
|
//BgPen.setColor(QColor( 0, 255, 0 ));
|
|
//painter.setBrush(QColor( 0, 128, 0, 180 ));
|
|
//painter.setPen( BgPen );
|
|
for (vectorMasking::iterator index = m_vAllPoly.begin(); index < m_vAllPoly.end(); index++){
|
|
BgPen.setColor(QColor((*index)->color[0] | 0x80, (*index)->color[1] | 0x80, (*index)->color[2] | 0x80));
|
|
painter.setBrush(QColor((*index)->color[0], (*index)->color[1], (*index)->color[2], 180));
|
|
//BgPen.setColor(QColor(0xFF, 0x00, 0xFF ));
|
|
//painter.setBrush(QColor(0x7F, 0x00, 0x7F, 0x7F ));
|
|
painter.setPen(BgPen);
|
|
painter.drawPolygon((*index)->points, (*index)->count);
|
|
};
|
|
};
|
|
// draw Edited Poly
|
|
if (m_bCurrentMouseMode == 1){
|
|
if (m_pNewPoly != NULL){
|
|
if (m_pNewPoly->count) {
|
|
BgPen.setColor(QColor(255, 0, 0));
|
|
painter.setBrush(QColor(180, 0, 0, 255));
|
|
painter.setPen(BgPen);
|
|
painter.drawPolyline((QPoint *)m_pNewPoly->points, m_pNewPoly->count);
|
|
};
|
|
};
|
|
};
|
|
};
|
|
painter.end();
|
|
};
|
|
m_pImageLabel->setPixmap(m_oPixmap);
|
|
} catch (exception e){};
|
|
m_mImageLock.unlock();
|
|
//m_pImageLabel->adjustSize();
|
|
//setVisible(true);
|
|
//update();
|
|
};
|
|
|
|
void RangeMapWidget::savePicture( QString fname ){
|
|
m_oImage.save( fname );
|
|
};
|
|
|
|
void RangeMapWidget::setMaximums( void ){
|
|
m_bShowMinimums = false;
|
|
if (m_nRangesCount > 0){
|
|
updateBackStage();
|
|
updateDisplay();
|
|
};
|
|
};
|
|
|
|
void RangeMapWidget::setMinimums( void ){
|
|
m_bShowMinimums = true;
|
|
if (m_nRangesCount > 0){
|
|
updateBackStage();
|
|
updateDisplay();
|
|
};
|
|
};
|
|
|
|
void RangeMapWidget::startGenerateWS( void ){
|
|
int x, y, Range, mid, seg;
|
|
int order, offset;
|
|
uint32_t color, cNodeID, sNodeID;
|
|
int cnt, cMax, cMin;
|
|
thresholdNode tTN;
|
|
m_oImage.fill( QColor(0,0,0));
|
|
order = 3;
|
|
offset = 32;
|
|
Range=0;
|
|
for( int index = 0; index < m_nRangesCount; index++ ){
|
|
sNodeID = index - ( TH_LINE_NODES + 1 ) * order;
|
|
tTN = m_pRanges[index];
|
|
if( tTN.values.cnt ){
|
|
cnt = 0;
|
|
cMax = 0;
|
|
cMin = 4095;
|
|
for( int i = 0; i < (( order << 1 ) + 1 ); i++ ){
|
|
cNodeID = sNodeID + ( i * TH_LINE_NODES );
|
|
for( int j = 0; j < (( order << 1 ) + 1 ); j++ ){
|
|
cNodeID ++;
|
|
if( cNodeID < 0 ) continue;
|
|
if( cNodeID < TH_SIZE_NODES ){
|
|
tTN = m_pRanges[cNodeID];
|
|
if( tTN.values.cnt != 0 ){
|
|
if( cMax < tTN.values.max ) cMax = tTN.values.max;
|
|
if( cMin > tTN.values.min ) cMin = tTN.values.min;
|
|
cnt++;
|
|
};
|
|
};
|
|
};
|
|
};
|
|
tTN.values.cnt = cnt;
|
|
if( cMin > offset ) tTN.values.min = cMin - offset; else tTN.values.min = 0;
|
|
if( cMax < ( 4095 - offset ) ) tTN.values.max = cMax + offset; else tTN.values.max = 4095;
|
|
} else {
|
|
// disable detection of that point
|
|
tTN.values.cnt = 0;
|
|
tTN.values.min = 0;
|
|
tTN.values.max = 4095;
|
|
};
|
|
if( m_bShowMinimums ){
|
|
Range = tTN.values.min;
|
|
makeCoords( Range, index, x, y, mid, seg, true );
|
|
#ifdef MIRROR_DIFF_COLORS
|
|
switch( mid ){
|
|
case 0: color = interpolate(0xFFFFFF00, 0xFF000000, RangeA / 4095.f); break;
|
|
case 1: color = interpolate(0xFF00FFFF, 0xFF000000, RangeA / 4095.f); break;
|
|
case 2: color = interpolate(0xFFFF00FF, 0xFF000000, RangeA / 4095.f); break;
|
|
case 3: color = interpolate(0xFFFFFFFF, 0xFF000000, RangeA / 4095.f); break;
|
|
};
|
|
#else
|
|
if( tTN.values.cnt )
|
|
color = interpolate(0xFF00FF00, 0xFF000000, ((float)( Range )) / 4096.f);
|
|
else
|
|
color = 0xFFFF0000;
|
|
#endif
|
|
m_oImage.setPixel(x, y, color);
|
|
} else {
|
|
Range = tTN.values.max;
|
|
makeCoords( Range, index, x, y, mid, seg, true );
|
|
#ifdef MIRROR_DIFF_COLORS
|
|
switch( mid ){
|
|
case 0: color = interpolate(0xFFFFFF00, 0xFF000000, RangeA / 4095.f); break;
|
|
case 1: color = interpolate(0xFF00FFFF, 0xFF000000, RangeA / 4095.f); break;
|
|
case 2: color = interpolate(0xFFFF00FF, 0xFF000000, RangeA / 4095.f); break;
|
|
case 3: color = interpolate(0xFFFFFFFF, 0xFF000000, RangeA / 4095.f); break;
|
|
};
|
|
#else
|
|
if( tTN.values.cnt )
|
|
color = interpolate(0xFF00FF00, 0xFF000000, ((float)( Range )) / 4096.f);
|
|
else
|
|
color = 0xFFFF0000;
|
|
#endif
|
|
m_oImage.setPixel(x, y, color);
|
|
};
|
|
};
|
|
updateDisplay();
|
|
};
|
|
|
|
/*
|
|
void RangeMapWidget::mouseMoveEvent(QMouseEvent* event) {
|
|
qDebug() << QString::number(event->pos().x());
|
|
qDebug() << QString::number(event->pos().y());
|
|
};
|
|
|
|
void RangeMapWidget::wheelEvent(QWheelEvent* event){
|
|
// your own custom stuff
|
|
// ...
|
|
// if you handle the event and don't want it to
|
|
// propagate any further, accept it:
|
|
event->accept();
|
|
};
|
|
|
|
*/
|
|
|
|
bool RangeMapWidget::eventFilter(QObject* ZZ/*obj*/, QEvent* evt ){
|
|
if( evt->type() == QEvent::MouseMove ){
|
|
if( m_bCurrentMouseMode == 0 ){ // Check Values
|
|
if( QApplication::mouseButtons()==Qt::LeftButton ){
|
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(evt);
|
|
//qDebug() << QString::number(m_pScrollArea->horizontalScrollBar()->value()+mouseEvent->pos().x());
|
|
//qDebug() << QString::number(m_pScrollArea->verticalScrollBar()->value()+mouseEvent->pos().y());
|
|
//statusBar()->showMessage(QString("Mouse move (%1,%2)").arg(mouseEvent->pos().x()).arg(mouseEvent->pos().y()));
|
|
m_nCursorX = m_pScrollArea->horizontalScrollBar()->value()+mouseEvent->pos().x();
|
|
m_nCursorY = m_pScrollArea->verticalScrollBar()->value()+mouseEvent->pos().y();
|
|
|
|
char tBuff[64];
|
|
float tVal;
|
|
int idx;
|
|
idx = makeIdx( m_nCursorX, m_nCursorY );
|
|
if (m_nRangesCount) {
|
|
if (idx > 0 && idx < (m_nRangesCount - 1)) {
|
|
tVal = m_fMaxRange * ((float)m_pRanges[idx].values.min) / 4096.f;
|
|
sprintf(tBuff, "%.2f m.", tVal);
|
|
//m_pStMiRaVal->setText(tBuff);
|
|
sprintf(tBuff, "%d dig.", m_pRanges[idx].values.min);
|
|
//m_pStMiSaVal->setText(tBuff);
|
|
tVal = m_fMaxRange * ((float)m_pRanges[idx].values.max) / 4096.f;
|
|
sprintf(tBuff, "%.2f m.", tVal);
|
|
//m_pStMaRaVal->setText(tBuff);
|
|
sprintf(tBuff, "%d dig.", m_pRanges[idx].values.max);
|
|
//m_pStMaSaVal->setText(tBuff);
|
|
|
|
|
|
//m_oPixmap = QPixmap::fromImage(m_oImage);
|
|
//drawCords();
|
|
};
|
|
};
|
|
//m_pImageLabel->setPixmap(m_oPixmap);
|
|
|
|
if (m_pPoint == NULL){
|
|
m_pPoint = new point2DWidget(m_pImageLabel);
|
|
};
|
|
m_pPoint->setMaxValues(BASE_SCAN_COUNT*KERNEL_COUNT, Q_SCAN_COUNT + 1);
|
|
m_pPoint->create(m_nCursorX, m_nCursorY, "LIBERMAN", "DA!!!!");
|
|
};
|
|
};
|
|
evt->ignore();
|
|
};
|
|
if( evt->type() == QEvent::MouseButtonPress ){
|
|
if( m_bCurrentMouseMode == 2 ){ // Delete Poly
|
|
|
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(evt);
|
|
m_nCursorX = m_pScrollArea->horizontalScrollBar()->value()+mouseEvent->pos().x();
|
|
m_nCursorY = m_pScrollArea->verticalScrollBar()->value()+mouseEvent->pos().y();
|
|
//Assign Polygones from Masking
|
|
vector<QPolygon *> tPV;
|
|
tPV.clear();
|
|
for( int i = 0; i < m_vAllPoly.size(); i++ ){
|
|
QPolygon *tPoly;
|
|
tPoly = new QPolygon();
|
|
if( tPoly != NULL ){
|
|
tPoly->clear();
|
|
for( int j = 0; j< m_vAllPoly.at( i )->count; j++ ){
|
|
QPoint tPoint;
|
|
tPoint.setX( m_vAllPoly.at( i )->points[j].x() );
|
|
tPoint.setY( m_vAllPoly.at( i )->points[j].y() );
|
|
tPoly->append(tPoint);
|
|
};
|
|
tPV.push_back( tPoly );
|
|
};
|
|
};
|
|
for( int i = 0; i < tPV.size(); i++ ){
|
|
if( tPV.at(i)->containsPoint( QPoint( m_nCursorX, m_nCursorY ), Qt::OddEvenFill) ){
|
|
//free( m_vAllPoly.at( i )->points );
|
|
//free( m_vAllPoly.at( i ) );
|
|
if( m_pDeviceControl != NULL ){
|
|
m_pDeviceControl->getMask()->deletePoly( i );
|
|
};
|
|
m_vAllPoly.erase( m_vAllPoly.begin() + i );
|
|
m_vAllPoly.shrink_to_fit();
|
|
m_bCurrentMouseMode = 0;
|
|
m_pScrollArea->viewport()->setProperty("cursor", QVariant(QCursor(Qt::ArrowCursor)));
|
|
updateDisplay();
|
|
break;
|
|
};
|
|
};
|
|
|
|
};
|
|
evt->ignore();
|
|
};
|
|
if( evt->type() == QEvent::MouseButtonRelease ){
|
|
if (m_bCurrentMouseMode == 0){
|
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(evt);
|
|
m_nCursorX = m_pScrollArea->horizontalScrollBar()->value() + mouseEvent->pos().x();
|
|
m_nCursorY = m_pScrollArea->verticalScrollBar()->value() + mouseEvent->pos().y();
|
|
char tBuff1[64];
|
|
char tBuff2[64];
|
|
char tBuff3[64];
|
|
float tVal;
|
|
int idx;
|
|
idx = makeIdx( m_nCursorX, m_nCursorY );
|
|
if( idx > 0 && idx < ( m_nRangesCount -1 ) ) {
|
|
if( m_nRangesCount > 0 && m_pRanges!= NULL ){
|
|
tVal = m_fMaxRange * ((float) m_pRanges[idx].values.min )/ 4096.f;
|
|
sprintf( tBuff1, "Min: %.2f m./ %d dig.", tVal, m_pRanges[idx].values.min );
|
|
tVal = m_fMaxRange * ((float) m_pRanges[idx].values.max )/ 4096.f;
|
|
sprintf( tBuff2, "Max: %.2f m./ %d dig.", tVal, m_pRanges[idx].values.max );
|
|
} else {
|
|
sprintf( tBuff1, "NO VALUES!");
|
|
sprintf( tBuff2, "NO VALUES!");
|
|
};
|
|
if (m_pPoint == NULL){
|
|
m_pPoint = new point2DWidget(m_pImageLabel);
|
|
m_pPoint->setMaxValues(BASE_SCAN_COUNT*KERNEL_COUNT, Q_SCAN_COUNT + 1);
|
|
m_pPoint->setAutoHide();
|
|
};
|
|
m_pPoint->create(m_nCursorX, m_nCursorY, tBuff1, tBuff2 );
|
|
};
|
|
};
|
|
if( m_bCurrentMouseMode == 1 ){ // Add Poly
|
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(evt);
|
|
m_nCursorX = m_pScrollArea->horizontalScrollBar()->value()+mouseEvent->pos().x();
|
|
m_nCursorY = m_pScrollArea->verticalScrollBar()->value()+mouseEvent->pos().y();
|
|
m_pNewPoly->points = (QPoint *) realloc( m_pNewPoly->points, ( m_pNewPoly->count+1 ) * sizeof(QPoint));
|
|
m_pNewPoly->points[m_pNewPoly->count].setX( m_nCursorX );
|
|
m_pNewPoly->points[m_pNewPoly->count].setY( m_nCursorY );
|
|
m_pNewPoly->count++;
|
|
updateDisplay();
|
|
};
|
|
evt->ignore();
|
|
};
|
|
if( evt->type() == QEvent::MouseButtonDblClick ){
|
|
if( m_bCurrentMouseMode == 1 ){ // Add Poly
|
|
m_vAllPoly.push_back( m_pNewPoly );
|
|
//ToDo: Transfer New Poly to Device!
|
|
if( m_pDeviceControl!= NULL ){
|
|
m_pDeviceControl->getMask()->addPoly( m_pNewPoly );
|
|
//for( int i = 0; i < m_pNewPoly->count; i++) m_pDeviceControl->getMask()->addVertex( m_vAllPoly.size(), m_pNewPoly->points[i] );
|
|
};
|
|
m_pNewPoly = NULL;
|
|
m_bCurrentMouseMode = 0;
|
|
m_pScrollArea->viewport()->setProperty("cursor", QVariant(QCursor(Qt::ArrowCursor)));
|
|
//m_pButton5->setEnabled( true );
|
|
//m_oPixmap = QPixmap::fromImage(m_oImage);
|
|
//drawCords();
|
|
//m_pImageLabel->setPixmap(m_oPixmap);
|
|
updateDisplay();
|
|
} else {
|
|
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(evt);
|
|
m_nCursorX = m_pScrollArea->horizontalScrollBar()->value()+mouseEvent->pos().x();
|
|
m_nCursorY = m_pScrollArea->verticalScrollBar()->value()+mouseEvent->pos().y();
|
|
basicEvent *pEvt = NULL;
|
|
basicCameraCommand *tData = NULL;
|
|
C3D_DECART *tParam = NULL;
|
|
tData = (basicCameraCommand*)malloc(sizeof(basicCameraCommand));
|
|
if(tData!=NULL){
|
|
tParam = (C3D_DECART*) malloc(sizeof(C3D_DECART));
|
|
if( tParam!= NULL ){
|
|
C3D_SPH_DEGREES tSph;
|
|
|
|
tSph.fi = B_DEGREE_FOV - ( B_DEGREE_FOV * (C3D_FLOAT)m_nCursorX / 2304.f );
|
|
tSph.tetta = 90.f - ((Q_DEGREE_FOV * (C3D_FLOAT)(288 - m_nCursorY)) / 288.f) + Q_SHIFT_DOWN_FOV;
|
|
|
|
|
|
if (tSph.tetta < 0.f /* || tSph.tetta > 180.f */){
|
|
tSph.tetta *= -1.f;
|
|
tSph.fi += 180.f;
|
|
} /* else if( tSph.tetta > 180.f ) tSph.fi += 180.f; */
|
|
tSph.r = 10.f;
|
|
if (m_pDeviceControl != NULL) {
|
|
// Move relative to Device
|
|
systemAnchor *SA = systemAnchor::getInstance();
|
|
SA->convertToSystem(m_pDeviceControl->getPosition(), tSph, *tParam);
|
|
} else {
|
|
// Move relative to System Anchore
|
|
spherical2decart(tSph, *tParam);
|
|
};
|
|
//char tBuffer[120];
|
|
//sprintf( tBuffer, "Az: %0.3f El: %0.3f", tSph.fi, tSph.tetta );
|
|
//QToolTip::showText( mouseEvent->globalPos(), QString(tBuffer) );
|
|
|
|
tData->m_cCode = CMD_CAMERA_SET_PTZ;
|
|
tData->m_pParam = tParam;
|
|
pEvt = createBasicEvent( 0, EVT_CLASS_IMAGE, EVT_COMMAND, "GoPosition By Operator", tData );
|
|
if( pEvt!= NULL){
|
|
basicEventHeap::getInstance()->broadcast(pEvt);
|
|
} else {
|
|
free(tData);
|
|
free(tParam);
|
|
};
|
|
} else {
|
|
free( tData );
|
|
};
|
|
};
|
|
};
|
|
evt->ignore();
|
|
};
|
|
if( evt->type() == QEvent::Wheel ){
|
|
// ignore the event (this effectively
|
|
// makes it "skip" one object)
|
|
evt->ignore();
|
|
};
|
|
// return false to continue event propagation
|
|
// for all events
|
|
return false;
|
|
};
|
|
|
|
void RangeMapWidget::setAddMaskMode( void ){
|
|
if( m_bCurrentMouseMode != 1 ){
|
|
m_pScrollArea->viewport()->setProperty("cursor", QVariant(QCursor(Qt::CrossCursor)));
|
|
m_pNewPoly = (simplePolygone *) malloc(sizeof(simplePolygone));
|
|
if( m_pNewPoly!= NULL ){
|
|
m_pNewPoly->count = 0;
|
|
m_pNewPoly->points = NULL;
|
|
m_bCurrentMouseMode = 1;
|
|
};
|
|
};
|
|
};
|
|
|
|
void RangeMapWidget::setDeleteMaskMode( void ){
|
|
if (m_vAllPoly.size()){
|
|
m_pScrollArea->viewport()->setProperty("cursor", QVariant(QCursor(Qt::CrossCursor)));
|
|
if (m_bCurrentMouseMode != 1) m_bCurrentMouseMode = 2; // Mode = Delete Poly
|
|
};
|
|
};
|
|
|
|
void RangeMapWidget::attachLGS(objectLGS *ptr){
|
|
m_pDeviceControl = ptr;
|
|
if( m_pDeviceControl != NULL ){
|
|
m_vAllPoly.clear();
|
|
if( m_pDeviceControl->areMasksLoadded() ){
|
|
if (m_pDeviceControl->getMask()->getMPoly(m_vAllPoly)){
|
|
|
|
};
|
|
};
|
|
updateBackStage();
|
|
updateDisplay();
|
|
};
|
|
};
|
|
|
|
void RangeMapWidget::handleTimer(void){
|
|
updateDisplay();
|
|
};
|