Skip to content
Snippets Groups Projects
Commit 2ed38386 authored by even's avatar even
Browse files

Large images processed

parent a45c9be0
No related branches found
No related tags found
No related merge requests found
......@@ -52,6 +52,14 @@ BSDetectionWidget::BSDetectionWidget (QWidget *parent)
bsPointsVisible = true;
boundColor = Qt::green;
boundHighColor = Qt::magenta;
maxWidth = 768;
maxHeight = 512;
xMaxShift = 0;
yMaxShift = 0;
xShift = 0;
yShift = 0;
zoom = 1;
}
......@@ -83,7 +91,13 @@ QSize BSDetectionWidget::openImage (const QString &fileName, int type)
if (profileview != NULL) profileview->setImage (&loadedImage, gMap);
if (strucview != NULL) strucview->setGradientImage (&gradImage);
return newSize.boundedTo (QSize (768, 512));
xMaxShift = (width > maxWidth ? maxWidth - width : 0);
yMaxShift = (height > maxHeight ? maxHeight - height : 0);
xShift = xMaxShift / 2;
if (xShift > 0) xShift = 0;
yShift = yMaxShift / 2;
if (yShift > 0) yShift = 0;
return newSize.boundedTo (QSize (maxWidth, maxHeight));
}
......@@ -178,7 +192,8 @@ void BSDetectionWidget::buildGradientImage (int dir)
void BSDetectionWidget::paintEvent (QPaintEvent *)
{
QPainter painter (this);
painter.drawImage (QPoint (0, 0), augmentedImage);
QImage zoomImage = augmentedImage.scaled (width / zoom, height / zoom);
painter.drawImage (QPoint (xShift, yShift), zoomImage);
}
......@@ -326,7 +341,9 @@ void BSDetectionWidget::mousePressEvent (QMouseEvent *event)
oldp1.set (p1);
oldp2.set (p2);
oldudef = udef;
p1 = Pt2i (event->pos().x (), height - 1 - event->pos().y());
int ex = zoom * (event->pos().x () - xShift);
int ey = zoom * (event->pos().y () - yShift);
p1 = Pt2i (ex, height - 1 - ey);
if (p1.manhattan (p2) < 10) p1.set (oldp1);
else if (p1.manhattan (oldp1) < 10) p1.set (p2);
udef = true;
......@@ -335,7 +352,9 @@ void BSDetectionWidget::mousePressEvent (QMouseEvent *event)
void BSDetectionWidget::mouseReleaseEvent (QMouseEvent *event)
{
p2 = Pt2i (event->pos().x (), height - 1 - event->pos().y());
int ex = zoom * (event->pos().x () - xShift);
int ey = zoom * (event->pos().y () - yShift);
p2 = Pt2i (ex, height - 1 - ey);
if (p1.equals (p2))
{
p1.set (oldp1);
......@@ -354,7 +373,9 @@ void BSDetectionWidget::mouseReleaseEvent (QMouseEvent *event)
void BSDetectionWidget::mouseMoveEvent (QMouseEvent *event)
{
p2 = Pt2i (event->pos().x (), height - 1 - event->pos().y ());
int ex = zoom * (event->pos().x () - xShift);
int ey = zoom * (event->pos().y () - yShift);
p2 = Pt2i (ex, height - 1 - ey);
if (verbose) cerr << "(" << p1.x () << ", " << p1.y () << ") ("
<< p2.x () << ", " << p2.y () << ")" << endl;
if (p1.manhattan (p2) > 5
......@@ -808,6 +829,58 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event)
writeTest ();
break;
case Qt::Key_Plus :
if (zoom > 1)
{
zoom /= 2;
xShift = xShift * 2 - maxWidth / 2;
yShift = yShift * 2 - maxHeight / 2;
displayDetectionResult ();
}
break;
case Qt::Key_Minus :
if (width / zoom > maxWidth || height / zoom > maxHeight)
{
zoom *= 2;
xShift = xShift / 2 + maxWidth / 4;
if (xShift > 0) xShift = 0;
if ((maxWidth - xShift) * zoom > width)
xShift = maxWidth - width / zoom;
yShift = yShift / 2 + maxHeight / 4;
if (yShift > 0) yShift = 0;
if ((maxHeight - yShift) * zoom > height)
yShift = maxHeight - height / zoom;
displayDetectionResult ();
}
break;
case Qt::Key_Left :
xShift += 50;
if (xShift > 0) xShift = 0;
displayDetectionResult ();
break;
case Qt::Key_Right :
xShift -= 50;
if ((maxWidth - xShift) * zoom > width)
xShift = maxWidth - width / zoom;
displayDetectionResult ();
break;
case Qt::Key_Up :
yShift += 50;
if (yShift > 0) yShift = 0;
displayDetectionResult ();
break;
case Qt::Key_Down :
yShift -= 50;
if ((maxHeight - yShift) * zoom > height)
yShift = maxHeight - height / zoom;
displayDetectionResult ();
break;
case Qt::Key_1 :
switchPixelAnalyzer ();
break;
......
......@@ -263,6 +263,21 @@ private:
/** Height of the present image. */
int height;
/** Maximal window width. */
int maxWidth;
/** Maximal window height. */
int maxHeight;
/** Maximal value of x-scroll shift. */
int xMaxShift;
/** Maximal value of y-scroll shift. */
int yMaxShift;
/** X-scroll shift. */
int xShift;
/** Y-scroll shift. */
int yShift;
/** Window zoom. */
int zoom;
/** Blurred segment detector. */
BSDetector detector;
/** Initial detection graphics view. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment