38 setCursor(Qt::CrossCursor);
58 QPainter painter(
this);
59 painter.fillRect(rect(), Qt::lightGray );
68 painter.drawPixmap(destination, pixmap, source);
88 static int counter = 0;
104 cout <<
"*** ERROR in MapBox::updateImage(): layerName_h "<< qPrintable(layerName_h) <<
" not found "<< endl;
118 cout <<
"*** ERROR in MapBox::switchToLayer(): layerName_h "<< qPrintable(layerName_h) <<
" not found "<< endl;
130 cout <<
"*** ERROR in MapBox:getLayerIndex(): layerName_h "<< qPrintable(layerName_h) <<
" not found "<< endl;
136 static int counter = 0;
137 QImage newlayer = QImage(this->width(), this->height(), QImage::Format_RGB32);
138 newlayer.fill(qRgb(255, 255, 255));
150 switch (event->key()) {
170 QWidget::keyPressEvent(event);
176 int numDegrees =
event->delta() / 8;
177 double numSteps = numDegrees / 15.0f;
183 if (event->button() == Qt::LeftButton){
186 else if (event->button() == Qt::RightButton){
193 double cx = ((double) click.x());
194 double cy = ((double) click.y());
199 if (cx>
dx2 || cx<dx1 || cy>
dy2 || cy<
dy1)
return;
210 if (event->buttons() & Qt::LeftButton) {
220 double tempXScale = ( (double) this->width()) / ((
double)pixmap.width());
221 double tempYScale = ( (double) this->height())/ ((
double)pixmap.height());
225 sx2 = pixmap.width();
226 sy2 = pixmap.height();
230 if ( tempXScale >= tempYScale){
231 dx2 = ((double)pixmap.width())*tempYScale;
232 dy2 = this->height();
235 dy2 = ((double)pixmap.height())*tempXScale;
242 double dx1new, dx2new, dy1new, dy2new;
243 dx1new =
dx2- (
dx2-
dx1)* ( 1+ (zoomFactor-1)/2 );
244 dx2new =
dx1+ (
dx2-
dx1)* ( 1+ (zoomFactor-1)/2 );
245 dy1new =
dy2- (
dy2-
dy1)* ( 1+ (zoomFactor-1)/2 );
246 dy2new =
dy1+ (
dy2-
dy1)* ( 1+ (zoomFactor-1)/2 );
256 dx1 += ((double) deltaX);
257 dx2 += ((double) deltaX);
258 dy1 += ((double) deltaY);
259 dy2 += ((double) deltaY);
int getLayerIndex(QString layerName_h="")
Return the index of the specified layer (null to ask for the current one)
void mouseMoveEvent(QMouseEvent *event)
MapBox(QWidget *parent=0)
void wheelEvent(QWheelEvent *event)
const double ZoomInFactor
void switchToLayer(QString layerName_h)
Change the layer that currentLayer and currentLayerName points.
vector< QImage > layersVector
Vector of QImages.
void addLayer(QString layerName_h)
void keyPressEvent(QKeyEvent *event)
void queryRequestOnPx(int px_ID, int currentLayerIndex, bool newRequest)
void paintEvent(QPaintEvent *event)
Reimplementation of the standard paintEvent method.
void prepareQueryEvent(QPoint click)
double dy2
coordinates of corner pixels of destination - widget - rectangle
double sy2
coordinates of corner pixels of source - pixmap - rectangle
void updatePixel(QString layerName_h, int x_h, int y_h, QColor color_h)
void scroll(int deltaX, int deltaY)
void zoom(double zoomFactor)
void mousePressEvent(QMouseEvent *event)
void updateImage(QString layerName_h, const QImage &image_h)
const double ZoomOutFactor
vector< QString > layersNameVector
Vector of layer names.