61 float containerWidth = this->width();
62 float containerHeight = this->height();
63 float aspectRatio = (float)w / (
float)h;
65 if(containerHeight * aspectRatio > containerWidth)
67 finalW = containerWidth;
68 finalH = containerWidth / aspectRatio;
72 finalW = containerHeight * aspectRatio;
73 finalH = containerHeight;
75 return std::pair<int,int>(finalW,finalH);
86 std::pair<int,int> newDims =
checkDimensions(img->width(),img->height());
95 scaled(newDims.first,newDims.second,
96 Qt::IgnoreAspectRatio,
97 Qt::SmoothTransformation)));
99 map->resize(newDims.first,newDims.second);
110 QPainter painter(img);
111 painter.setPen(QColor(100,100,100,150));
112 int pix = 1.0 / resolution;
113 for(
unsigned int i = 1 ; i <= img->width() / pix + 1 ; i++)
115 painter.drawLine(0, i * pix, img->width() - 1, i * pix);
117 for(
unsigned int i = 1 ; i <= img->height() / pix + 1 ; i++)
119 painter.drawLine(i * pix, 0, i * pix, img->height() - 1);
133 int prevZoom =
zoom_;
151 QPoint evOriginal = np;
153 float xmin,xmax,ymin,ymax;
154 float prevxmin, prevymin, prevWidth, prevHeight;
159 float xhit = evOriginal.x();
160 float yhit = evOriginal.y();
162 xmin = xhit - (xhit - prevxmin) * newWidth / prevWidth;
163 xmax = xmin + newWidth ;
164 ymin = yhit - (yhit - prevymin) * newHeight / prevHeight;
165 ymax = ymin + newHeight;
200 QPoint p(xcenter, ycenter);
207 p.setX(p.x() + move_by);
210 p.setX(p.x() - move_by);
213 p.setY(p.y() - move_by);
216 p.setY(p.y() + move_by);
237 QPoint evOriginal = p;
240 float xmin,xmax,ymin,ymax;
241 xmin = evOriginal.x() - newWidth / 2;
242 xmax = evOriginal.x() + newWidth / 2;
243 ymin = evOriginal.y() - newHeight / 2;
244 ymax = evOriginal.y() + newHeight / 2;
280 float currentWidth = map->width();
282 float climax = initialWidth / currentWidth;
283 newPoint.setX(x * climax);
284 newPoint.setY(y * climax);
323 map_max_ = QPoint(s.width(), s.height());
void updateCenter(QPoint p)
Updates the image center.
QPoint map_max_
The original image size.
QPoint map_min_
The lower right point of map visualization.
void drawGrid(QImage *img, float resolution)
Draws a grid in an image.
TFSIMD_FORCE_INLINE const tfScalar & y() const
QPoint getGlobalPoint(QPoint p)
Calculates the "real" point in the image.
CMapLoader(int argc, char **argv)
Default contructor.
void setInitialImageSize(QSize s)
Sets the initial image size.
void updateImage(QImage *img)
Updates the image.
int zoom_
Internal image used before a map is loaded.
TFSIMD_FORCE_INLINE const tfScalar & x() const
void updateZoom(QPoint p, bool zoomIn)
Updates the zoom of the image.
void resizeEvent(QResizeEvent *e)
Captures the resize event.
QImage * internal_img_
The upper left point of map visualization.
The main namespace for STDR GUI.
std::pair< int, int > checkDimensions(int w, int h)
Return the dimensions according to the container size.
void resetZoom(void)
Resets the zoom of the image.
void moveDirectionally(int key)
Updates the image center by moving directionally.
QSize initial_image_size_
QPoint pointUnscaled(QPoint p)
Unscales the input point.