"................................", "................................" };
-static int aAA = 0;
+ViewerToolbar::ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
+ : QToolBar(theParent), myVPort(thePort), myResize(false)
+{
+ setBackgroundRole(QPalette::NoRole);
+ setAttribute(Qt::WA_NoSystemBackground);
+ //setAttribute(Qt::WA_PaintOnScreen);
+ setAutoFillBackground(false);
+ connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized()));
+}
+
void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
{
// Paint background
QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(),
aRect.width(), aRect.height()));
- aPainter.drawImage(aRect, myVPort->dumpView(aImgRect, false));
+ QImage aImg = myVPort->dumpView(aImgRect, myResize);
+ if (!aImg.isNull())
+ aPainter.drawImage(aRect, aImg);
+ myResize = false;
// Paint foreground
QStyle *style = this->style();
}
//**************************************************************************
-void ViewerLabel::repaintBackground()
+ViewerLabel::ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
+ : QLabel(theParent), myVPort(thePort), myResize(false)
+{
+ setBackgroundRole(QPalette::NoRole);
+ setAttribute(Qt::WA_NoSystemBackground);
+ //setAttribute(Qt::WA_PaintOnScreen);
+ setAutoFillBackground(false);
+ connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized()));
+}
+
+void ViewerLabel::paintEvent(QPaintEvent* theEvent)
{
QRect aRect = rect();
QRect aVPRect = myVPort->rect();
QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(),
aRect.width(), aRect.height()));
- QPainter(this).drawImage(aRect, myVPort->dumpView(aImgRect, false));
-}
-
-void ViewerLabel::paintEvent(QPaintEvent* theEvent)
-{
- repaintBackground();
+ QImage aImg = myVPort->dumpView(aImgRect, myResize);
+ if (!aImg.isNull())
+ QPainter(this).drawImage(aRect, aImg);
QLabel::paintEvent(theEvent);
}
{
Q_OBJECT
public:
- ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
- : QToolBar(theParent), myVPort(thePort)
- {
- setBackgroundRole(QPalette::NoRole);
- setAttribute(Qt::WA_NoSystemBackground);
- //setAttribute(Qt::WA_PaintOnScreen);
- setAutoFillBackground(false);
- }
+ ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort);
+
+protected slots:
+ void onViewPortResized() { myResize = true; }
protected:
virtual void paintEvent(QPaintEvent* theEvent);
+
+
private:
XGUI_ViewPort* myVPort;
+ bool myResize;
};
//******************************************************
{
Q_OBJECT
public:
- ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
- : QLabel(theParent), myVPort(thePort)
- {
- setBackgroundRole(QPalette::NoRole);
- setAttribute(Qt::WA_NoSystemBackground);
- //setAttribute(Qt::WA_PaintOnScreen);
- setAutoFillBackground(false);
- }
+ ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort);
- void repaintBackground();
+protected slots:
+ void onViewPortResized() { myResize = true; }
protected:
virtual void paintEvent(QPaintEvent* theEvent);
private:
XGUI_ViewPort* myVPort;
+ bool myResize;
};
#endif