qt 3.3.3 calibrate 소스를 qt4로 변경했습니다. 근데 동작을 안하네요..ㅠㅠ

falhed의 이미지

qte-3.3.3 에서 실행되던 calibrate 소스를 qt로 컴파일 하면서 변경했습니다.
초기 calibrate 실행을 시키니 240 320 화면을 인식하더라구요...

십자가 모양의 커서가 떠서 눌렀는데,
디바이스 드라이버 커널쪽에서는 반응을 하는데 calibrate 응용 프로그램에서는 반응이 없네요...휴~~~~~
제가 변경한 소스가 맞는지 고수님들 확인 부탁드리겠습니다..

#include

//#ifdef WS_QWS

#include
#include
#include

class QTimer;

class Calibrate : public QWidget
{
Q_OBJECT
public:
Calibrate(QWidget* parent=0, /*const char * name=0,*/ Qt::WindowFlags=0);
~Calibrate();

private:
QPoint fromDevice( const QPoint &p );
bool sanityCheck();
void moveCrosshair( QPoint pt );
void paintEvent( QPaintEvent * );
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );

private slots:
void timeout();

private:
QWSPointerCalibrationData cd;
QWSPointerCalibrationData::Location location;
QPoint crossPos;
QPoint penPos;
QPixmap saveUnder;
QTimer *timer;
int dx;
int dy;
};

//#endif // WS_QWS

#include //#ifdef WS_QWS #include #include #include #include #include //#include //#include #include #include "calibrate.h"

//const Qt::WFlags m_flag = (Qt::Tool | Qt::WindowStaysOnTopHint | Qt::WA_DeleteOnClose);
Calibrate::Calibrate(QWidget* parent, /*const char * name,*/ Qt::WindowFlags wf) :
QWidget( parent, 0/*name,*/ /*Qt::Tool | Qt::FramelessWindowHint | Qt::WA_DeleteOnClose*/)
{
const int offset = 30;
QRect desk = qApp->desktop()->screenGeometry();
setGeometry( 0, 0, desk.width(), desk.height() );
qDebug("%d %d", desk.width(), desk.height() );
// setBackgroundColor(Qt::white);

cd.screenPoints[QWSPointerCalibrationData::TopLeft] = QPoint( offset, offset );
cd.screenPoints[QWSPointerCalibrationData::BottomLeft] = QPoint( offset, qt_screen->deviceHeight() - offset );
cd.screenPoints[QWSPointerCalibrationData::BottomRight] = QPoint( qt_screen->deviceWidth() - offset, qt_screen->deviceHeight() - offset );
cd.screenPoints[QWSPointerCalibrationData::TopRight] = QPoint( qt_screen->deviceWidth() - offset, offset );
cd.screenPoints[QWSPointerCalibrationData::Center] = QPoint( qt_screen->deviceWidth()/2, qt_screen->deviceHeight()/2 );

crossPos = fromDevice( cd.screenPoints[QWSPointerCalibrationData::TopLeft] );
location = QWSPointerCalibrationData::TopLeft;

timer = new QTimer( this );
connect( timer, SIGNAL(timeout()), this, SLOT(timeout()) );

QWSServer::mouseHandler()->clearCalibration();
grabMouse();
}

Calibrate::~Calibrate()
{
}

QPoint Calibrate::fromDevice( const QPoint &p )
{
return qt_screen->mapFromDevice( p,
QSize(qt_screen->deviceWidth(), qt_screen->deviceHeight()) );
}

bool Calibrate::sanityCheck()
{
QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft];
QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight];
QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft];
QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight];

qDebug("tl-x : %d, tl-y : %d, tr-x : %d, tr-y : %d", tl.x(), tl.y(),
tr.x(), tr.y());
qDebug("bl-x : %d, bl-y : %d, br-x : %d, br-y : %d", bl.x(), bl.y(),
br.x(), br.y());

int vl = qAbs( tl.y() - bl.y() );
int vr = qAbs( tr.y() - br.y() );
qDebug("vl(tl.y - bl.y): %d, vr(tr.y - br.y) : %d", vl, vr);
int diff = qAbs( vl - vr );
int avg = ( vl + vr ) / 2;
qDebug("diff(vl - vr) : %d, avg((vl+vr)/2) : %d", diff, avg);
if ( diff > avg / 20 ) { // 5% leeway
qDebug(" diff > avg / 20 : False");
return FALSE;
}
qDebug(" diff <= avg / 20 : OK");

int ht = qAbs( tl.x() - tr.x() );
int hb = qAbs( br.x() - bl.x() );
qDebug("ht(tl.x - tr.x): %d, hb(br.y - bl.y) : %d", ht, hb);
diff = qAbs( ht - hb );
avg = ( ht + hb ) / 2;
qDebug("diff(ht - hb) : %d, avg((ht+hb)/2) : %d", diff, avg);
if ( diff > avg / 20 ) { // 5% leeway
qDebug(" diff > avg / 20 : False");
return FALSE;
}
qDebug(" diff <= avg / 20 : OK");

return TRUE;
}

void Calibrate::moveCrosshair( QPoint pt )
{
QPainter p( this );
p.fillRect(rect(), QBrush(Qt::white));
p.drawRect( pt.x()-1, pt.y()-8, 2, 7 );
p.drawRect( pt.x()-1, pt.y()+1, 2, 7 );
p.drawRect( pt.x()-8, pt.y()-1, 7, 2 );
p.drawRect( pt.x()+1, pt.y()-1, 7, 2 );
crossPos = pt;
}

void Calibrate::paintEvent( QPaintEvent * )
{
QPainter p( this );

p.fillRect(rect(), QBrush(Qt::white));
moveCrosshair( crossPos );
}

void Calibrate::mousePressEvent( QMouseEvent *e )
{
// map to device coordinates
QPoint devPos = qt_screen->mapToDevice( e->pos(), QSize(qt_screen->width(), qt_screen->height()) );

if ( penPos.isNull() )
penPos = devPos;
else
penPos = QPoint( (penPos.x() + devPos.x())/2, (penPos.y() + devPos.y())/2 );

qDebug("mousePressEvent(%d, %d)", penPos.x(), penPos.y());
}

void Calibrate::mouseReleaseEvent( QMouseEvent * )
{
if ( timer->isActive() )
return;

bool doMove = TRUE;

cd.devPoints[location] = penPos;
if ( location < QWSPointerCalibrationData::LastLocation )
{
location = (QWSPointerCalibrationData::Location)((int)location + 1);
}
else
{
if ( sanityCheck() )
{
for(int i=0; i<5; i++)
{
qDebug("dev %4x:%4x, scr %4x:%4x \n", cd.devPoints[i].x(), cd.devPoints[i].y(), cd.screenPoints[i].x(), cd.screenPoints[i].y() );

}
QWSServer::mouseHandler()->calibrate( &cd );
releaseMouse();
hide();
close();
doMove = FALSE;
}
else
{
location = QWSPointerCalibrationData::TopLeft;
}
}

if ( doMove )
{
QPoint target = fromDevice( cd.screenPoints[location] );
dx = (target.x() - crossPos.x())/10;
dy = (target.y() - crossPos.y())/10;
timer->start( 30 );
}
}

void Calibrate::timeout()
{
QPoint target = fromDevice( cd.screenPoints[location] );

bool doneX = FALSE;
bool doneY = FALSE;
QPoint newPos( crossPos.x() + dx, crossPos.y() + dy );

if ( qAbs(crossPos.x() - target.x()) <= qAbs(dx) ) {
newPos.setX( target.x() );
doneX = TRUE;
}

if ( qAbs(crossPos.y() - target.y()) <= qAbs(dy) ) {
newPos.setY(target.y());
doneY = TRUE;
}

if ( doneX && doneY ) {
penPos = QPoint();
timer->stop();
}

moveCrosshair( newPos );
}

//#endif // WS_QWS

#include //#include //#include #include "calibrate.h"

int main( int argc, char ** argv )
{
QApplication a( argc, argv );

Calibrate c;
// a.setMainWidget(&c);
// a.setMainWidget( c );
c.show();

return a.exec();
}

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.