10 qRegisterMetaType<QImage>(
"QImage");
11 qRegisterMetaType<ROIRectList>(
"ROIRectList");
13 #if defined (INCLUDE_AJACC)
14 for (
unsigned ndx (0); ndx < 15; ndx++)
15 _captionStrings [ndx] = QString (32, QChar (32));
16 #endif // defined (INCLUDE_AJACC)
23 QPainter painter (
this);
25 const int offsetX (_pixmap.width() < width() ? (width() - _pixmap.width()) / 2 : 0);
26 const int offsetY (_pixmap.height() < height() ? (height() - _pixmap.height()) / 2 : 0);
28 painter.drawPixmap (offsetX, offsetY, _pixmap);
29 for (
int i (0); i < _roiList.size(); i++)
31 const ROIStruct & roiRectInfo (_roiList [i]);
33 const double hScale (
double (_pixmap.width()) / double (_unscaledImageSize.width()));
34 const double vScale (
double (_pixmap.height()) / double (_unscaledImageSize.height()));
39 currentPen.setWidth (4);
40 painter.setPen (currentPen);
42 currentRect.setLeft (
double(offsetX) + roiRectInfo.
roiRect.left() * hScale);
43 currentRect.setRight (
double(offsetX) + roiRectInfo.
roiRect.right() * hScale);
44 currentRect.setTop (
double(offsetY) + roiRectInfo.
roiRect.top() * vScale);
45 currentRect.setBottom (
double(offsetY) + roiRectInfo.
roiRect.bottom() * vScale);
47 painter.drawRect (currentRect);
54 f.setStyleStrategy(QFont::PreferOutline);
55 f.setLetterSpacing(QFont::PercentageSpacing, 110.0);
56 f.setWeight(QFont::Bold);
57 const QBrush whiteBrush(Qt::white);
58 const QPen blackPen(QBrush(Qt::darkGray), 2.0);
60 pp.addText(QPointF(30.0, 40.0), f, _statusString);
61 painter.fillPath(pp, whiteBrush);
62 painter.strokePath(pp, blackPen);
67 #if defined (INCLUDE_AJACC)
68 QFont captionFont (
"Courier");
69 captionFont.setPointSize (24);
70 QFontMetrics metrics (captionFont);
71 const int offX (width() / 2 - 32 * metrics.averageCharWidth() / 2);
72 const int offY (height() / 2 - 15 * (metrics.height() + metrics.leading()) / 2);
73 setFont (captionFont);
74 painter.setPen (qRgba (255, 255, 255, 0));
75 for (
unsigned ndx (0); ndx < 15; ndx++)
76 painter.drawText (offX, offY + ndx * (metrics.height() + metrics.leading()), _captionStrings [ndx]);
77 #endif // defined (INCLUDE_AJACC)
86 _unscaledImageSize.setHeight(image.height());
87 _unscaledImageSize.setWidth(image.width());
94 QMetaObject::invokeMethod(
this,
"renderFrame", Qt::QueuedConnection);
102 _statusString = statusString;
103 _unscaledImageSize.setHeight(image.height());
104 _unscaledImageSize.setWidth(image.width());
111 QMetaObject::invokeMethod(
this,
"renderFrame", Qt::QueuedConnection);
118 _unscaledImageSize.setHeight (image.height());
119 _unscaledImageSize.setWidth (image.width());
126 QMetaObject::invokeMethod(
this,
"renderFrame", Qt::QueuedConnection);
137 _statusString = statusString;
140 #if defined (INCLUDE_AJACC)
141 void AJAPreviewWidget::updateCaptionScreen (
const ushort * pInScreen)
143 const ushort * pCell (pInScreen);
146 _captionStrings [row-1].
replace (col-1, 1, QChar (*pCell++));
148 #endif // defined (INCLUDE_AJACC)
150 void AJAPreviewWidget::renderFrame ()
153 if (_image.width() > this->width())
154 _pixmap = QPixmap::fromImage(_image.scaledToWidth(this->width(), Qt::SmoothTransformation), Qt::ImageConversionFlags());
155 else if (_image.height() > this->height())
156 _pixmap = QPixmap::fromImage(_image.scaledToHeight(this->height(), Qt::SmoothTransformation), Qt::ImageConversionFlags());
158 _pixmap = QPixmap::fromImage(_image, Qt::ImageConversionFlags());
160 setAttribute(Qt::WA_OpaquePaintEvent, _clear ?
false :
true);
167 if (ev->mimeData()->hasFormat(
"text/uri-list"))
168 ev->acceptProposedAction();
170 ev->setAccepted(
false );
176 QList<QUrl> urls = ev->mimeData()->urls();
180 QString fileName = urls.first().toLocalFile();
181 if (fileName.isEmpty())
184 QImage imageFile(fileName);
185 if ( !imageFile.isNull())