// imap_cal_cursor.h
#include <QGraphicsItem>
#include <QObject>
{
Q_OBJECT
public:
CImapCalCursor();
}
//imap_cal_cursor.cpp
#include "imap_cal_cursor.h"
#include <QGraphicsScene>
#include <QPainter>
#include <QStyleOption>
#include <QKeyEvent>
#include "syslog.h"
{
}
void CImapCalCursor
::keyPressEvent( QKeyEvent *event
) {
switch (event->key()) {
case Qt::Key_N:
syslog( LOG_DEBUG, "DEBUG: Received Key_N event" );
break;
}
}
// calibration_dialog.h
#include <QDialog>
#include <QDialogButtonBox>
#include "imap_cal_image.h"
#include "imap_cal_cursor.h"
class CCalibration
: public QDialog{
Q_OBJECT
public:
protected:
class CImapCalImage Image;
class CImapCalCursor cur;
int current_list_index;
public:
CCalibration
( QWidget * parent
= 0, PEZG_COMMBLK EZGSharedMemPtr
= NULL );
};
//calibration_dialog.cpp
#include <QtGui>
#include <QColor>
#include "calibration_dialog.h"
#include "syslog.h"
CCalibration
::CCalibration(QWidget * parent, PEZG_COMMBLK EZGSharedMemPtr
){
PIM_DIGBUFFER SourceImagePtr;
imageHeader *SourceImageHeaderPtr;
unsigned char *SourceImageDataPtr;
SourceImagePtr = &EZGSharedMemPtr->sImProcDigBuffer;
SourceImageHeaderPtr = &SourceImagePtr->Header;
SourceImageDataPtr = SourceImagePtr->image;
setObjectName
(QString::fromUtf8("Calibration_Dialog"));
buttonBox
->setObjectName
(QString::fromUtf8("buttonBox"));
buttonBox
->setGeometry
(QRect(400,
630,
161,
32));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox
->setStandardButtons
(QDialogButtonBox::Cancel|QDialogButtonBox
::NoButton|QDialogButtonBox
::Ok);
graphix_area
->setObjectName
(QString::fromUtf8("graphix_area"));
graphix_area
->setGeometry
(QRect(20,
40,
951,
571));
graphix_area
->setRenderHint
(QPainter::Antialiasing);
Image
= CImapCalImage
( SourceImageDataPtr, SourceImageHeaderPtr
->imWidth, SourceImageHeaderPtr
->imHeight,
QImage::Format_Indexed8 );
Image.GenerateColorMap();
pixmapItem
= Scene
->addPixmap
( QPixmap::fromImage( Image
) );
list = Image.ScanForPoints();
if( list.isEmpty() || list.size() == 0 ) {
syslog( LOG_ERR, "ERROR: ScanForPoints returned empty list" );
current_list_index = -1;
}
else {
current_list_index = 0;
Scene->addItem( &cur );
cur.setZValue( 10 );
cur.setPos( pixmapItem->mapToParent( list[ current_list_index ] ) );
}
graphix_area->setScene( Scene );
Scene->setFocusItem( &cur );
size = size.expandedTo(minimumSizeHint());
resize(size);
}
// imap_cal_cursor.h
#include <QGraphicsItem>
#include <QObject>
class CImapCalCursor : public QObject, public QGraphicsItem
{
Q_OBJECT
public:
CImapCalCursor();
void keyPressEvent( QKeyEvent *event );
}
//imap_cal_cursor.cpp
#include "imap_cal_cursor.h"
#include <QGraphicsScene>
#include <QPainter>
#include <QStyleOption>
#include <QKeyEvent>
#include "syslog.h"
CImapCalCursor::CImapCalCursor() : QObject(), QGraphicsItem()
{
}
void CImapCalCursor::keyPressEvent( QKeyEvent *event )
{
switch (event->key()) {
case Qt::Key_N:
syslog( LOG_DEBUG, "DEBUG: Received Key_N event" );
break;
}
}
// calibration_dialog.h
#include <QDialog>
#include <QDialogButtonBox>
#include "imap_cal_image.h"
#include "imap_cal_cursor.h"
class CCalibration : public QDialog
{
Q_OBJECT
public:
QDialogButtonBox *buttonBox;
QGraphicsView *graphix_area;
protected:
class CImapCalImage Image;
class CImapCalCursor cur;
QGraphicsScene *Scene;
QList< QPoint > list;
int current_list_index;
QGraphicsPixmapItem *pixmapItem;
public:
CCalibration( QWidget * parent = 0, PEZG_COMMBLK EZGSharedMemPtr = NULL );
};
//calibration_dialog.cpp
#include <QtGui>
#include <QColor>
#include "calibration_dialog.h"
#include "syslog.h"
CCalibration::CCalibration(QWidget * parent, PEZG_COMMBLK EZGSharedMemPtr )
: QDialog(parent)
{
PIM_DIGBUFFER SourceImagePtr;
imageHeader *SourceImageHeaderPtr;
unsigned char *SourceImageDataPtr;
SourceImagePtr = &EZGSharedMemPtr->sImProcDigBuffer;
SourceImageHeaderPtr = &SourceImagePtr->Header;
SourceImageDataPtr = SourceImagePtr->image;
setObjectName(QString::fromUtf8("Calibration_Dialog"));
buttonBox = new QDialogButtonBox( this );
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setGeometry(QRect(400, 630, 161, 32));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);
graphix_area = new QGraphicsView( this );
graphix_area->setObjectName(QString::fromUtf8("graphix_area"));
graphix_area->setGeometry(QRect(20, 40, 951, 571));
graphix_area->setCacheMode(QGraphicsView::CacheBackground);
graphix_area->setRenderHint(QPainter::Antialiasing);
Scene = new QGraphicsScene( this );
Image = CImapCalImage( SourceImageDataPtr, SourceImageHeaderPtr->imWidth, SourceImageHeaderPtr->imHeight, QImage::Format_Indexed8 );
Image.GenerateColorMap();
pixmapItem = Scene->addPixmap( QPixmap::fromImage( Image ) );
list = Image.ScanForPoints();
if( list.isEmpty() || list.size() == 0 ) {
syslog( LOG_ERR, "ERROR: ScanForPoints returned empty list" );
current_list_index = -1;
}
else {
current_list_index = 0;
Scene->addItem( &cur );
cur.setZValue( 10 );
cur.setPos( pixmapItem->mapToParent( list[ current_list_index ] ) );
cur.setFlag( QGraphicsItem::ItemIsFocusable );
}
graphix_area->setScene( Scene );
Scene->setFocusItem( &cur );
QSize size(988, 684);
size = size.expandedTo(minimumSizeHint());
resize(size);
}
To copy to clipboard, switch view to plain text mode
Bookmarks