00001 #include <qvbox.h>
00002 #include <qlabel.h>
00003 #include <qscrollview.h>
00004 #include <qlayout.h>
00005 #include "image-dialog.h"
00006
00007 ImageLabel::ImageLabel(QWidget * parent, const char * name, WFlags f ) :
00008 QLabel(parent,name,f)
00009 {
00010 }
00011
00012 void ImageLabel::mousePressEvent(QMouseEvent *e)
00013 {
00014 emit pointSelected(e->x(),e->y(),e->button()==RightButton);
00015 }
00016
00017 ImagePicker::ImagePicker(ImageValue * i) : QDialog(NULL,"image-picker",TRUE)
00018 {
00019 image = i;
00020 QGridLayout *tot = new QGridLayout( this, 1, 1, 11, 6, "layout");
00021
00022 QScrollView* sv = new QScrollView(this);
00023 tot->addWidget(sv,0,0);
00024 QVBox* big_box = new QVBox(sv->viewport());
00025 sv->addChild(big_box);
00026 ImageLabel* child1 = new ImageLabel(big_box);
00027 const QPixmap pm(i->getQImage(false));
00028 size_x = image->width_direct();
00029 size_y = image->height_direct();
00030 child1->setPixmap(pm);
00031 connect(child1,SIGNAL(pointSelected(int,int,bool)),this, SLOT(pointSelected(int,int,bool)));
00032 }
00033
00034 void ImagePicker::pointSelected(int x, int y, bool right)
00035 {
00036 if (x>=size_x ||
00037 x<0 ||
00038 y>=size_y ||
00039 y <0)
00040 return;
00041 PointValue point = image->dcsToOcs(DirectPoint(x,y));
00042 nextPoint(point,right);
00043 }