Originally Posted by
ChrisW67
Without seeing a small example that shows us exactly what you are doing, and how the image and the rectangle are related to each other, we can only guess.
//This CImageWidgetOverlay is derived from QGraphicsItem
{
if (this->isActive() && m_ShowOverlay)
{
if(m_ROIsList && !m_ROIsList->isEmpty())
{
for(int i = 0; i < m_ROIsList->count(); i++)
{
if (m_DisplayOverlayMask && (!m_OverlayMaskImage.isNull()) && (m_ROIsList->at(i)->getShape() == FA5_SHAPE_RECT_MASK))
{
double fScale = m_ROIsList->at(i)->getCurrentScale();
QRectF rect
= QRectF(m_OverlayOffsetCol
* fScale, m_OverlayOffsetRow
* fScale, m_OverlayMaskImage.
width() * fScale,
m_OverlayMaskImage.height() * fScale);
p->drawImage(rect , m_OverlayMaskImage, m_OverlayMaskImage.rect());
}
m_ROIsList->at(i)->drawROI(p);
}
QRectF roiBoundary
= m_ROIsList
->at
(0)->mappedRect
();
m_ResultBar->move(roiBoundary.right() + 10, roiBoundary.bottom() - m_ResultBar->rect().height());
m_ResultBar->drawResultBar(p);
}
}
}
//This CImageWidgetOverlay is derived from QGraphicsItem
void CImageWidgetOverlay::paint(QPainter * p, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
if (this->isActive() && m_ShowOverlay)
{
if(m_ROIsList && !m_ROIsList->isEmpty())
{
for(int i = 0; i < m_ROIsList->count(); i++)
{
if (m_DisplayOverlayMask && (!m_OverlayMaskImage.isNull()) && (m_ROIsList->at(i)->getShape() == FA5_SHAPE_RECT_MASK))
{
double fScale = m_ROIsList->at(i)->getCurrentScale();
QRectF rect = QRectF(m_OverlayOffsetCol * fScale, m_OverlayOffsetRow * fScale, m_OverlayMaskImage.width() * fScale,
m_OverlayMaskImage.height() * fScale);
p->drawImage(rect , m_OverlayMaskImage, m_OverlayMaskImage.rect());
}
m_ROIsList->at(i)->drawROI(p);
}
QRectF roiBoundary = m_ROIsList->at(0)->mappedRect();
m_ResultBar->move(roiBoundary.right() + 10, roiBoundary.bottom() - m_ResultBar->rect().height());
m_ResultBar->drawResultBar(p);
}
}
}
To copy to clipboard, switch view to plain text mode
void CGraphicsScene
::initImage(QImage* image
) {
m_CurrentImage = image;
if(m_CurrentImage)
{
m_Resolution = CResolution::getResolutionID(m_CurrentImage->size());
}
setDefaultImage(m_CurrentImage);
update(this->sceneRect());
}
void CGraphicsScene
::setDefaultImage(QImage* image
) {
m_widgetPixmap
->setPixmap
(QPixmap::fromImage(*image
));
setSceneRect(image->rect());
}
void CGraphicsScene::initImage(QImage* image)
{
m_CurrentImage = image;
if(m_CurrentImage)
{
m_Resolution = CResolution::getResolutionID(m_CurrentImage->size());
}
setDefaultImage(m_CurrentImage);
update(this->sceneRect());
}
void CGraphicsScene::setDefaultImage(QImage* image)
{
m_widgetPixmap->setPixmap(QPixmap::fromImage(*image));
setSceneRect(image->rect());
}
To copy to clipboard, switch view to plain text mode
Bookmarks