#include <QPainter>
#include <QTimer>
#include <QFileDialog>
+#include <QStyleOptionToolBar>
#include <TopoDS_Shape.hxx>
#include <BRep_Tool.hxx>
"................................", "................................",
"................................", "................................" };
-//**************************************************************************
-void ViewerToolbar::repaintBackground()
+
+void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
{
+ // Paint background
+ QPainter aPainter(this);
QRect aRect = rect();
QRect aVPRect = myVPort->rect();
QPoint aGlobPnt = mapToGlobal(aRect.topLeft());
QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(),
aRect.width(), aRect.height()));
- QPainter(this).drawImage(aRect, myVPort->dumpView(aImgRect, false));
-}
+ aPainter.drawImage(aRect, myVPort->dumpView(aImgRect, false));
-void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
-{
- repaintBackground();
- //QToolBar::paintEvent(theEvent);
+ // Paint foreground
+ QStyle *style = this->style();
+ QStyleOptionToolBar aOpt;
+ initStyleOption(&aOpt);
+
+ aOpt.rect = style->subElementRect(QStyle::SE_ToolBarHandle, &aOpt, this);
+ if (aOpt.rect.isValid())
+ style->drawPrimitive(QStyle::PE_IndicatorToolBarHandle, &aOpt, &aPainter, this);
}
//**************************************************************************
myWindowBar->addAction(aBtn);
connect(aBtn, SIGNAL(triggered()), SLOT(onClose()));
- myViewBar->hide();
- myWindowBar->hide();
- myGripWgt->hide();
+ //myViewBar->hide();
+ //myWindowBar->hide();
+ //myGripWgt->hide();
//Support copy of background on updating of viewer
connect(myViewPort, SIGNAL(vpTransformed()), this, SLOT(updateToolBar()));
if (theEvent->type() == QEvent::WindowStateChange) {
if (isMinimized()) {
- myViewBar->hide();
- myGripWgt->hide();
- myWindowBar->hide();
- myViewPort->hide();
+ myViewBar->hide();
+ myGripWgt->hide();
+ myWindowBar->hide();
+ myViewPort->hide();
myPicture->show();
} else {
myPicture->hide();
- myViewPort->show();
+ myViewPort->show();
if (isMaximized()) {
myMinimizeBtn->setIcon(MinimizeIco);
myMaximizeBtn->setIcon(RestoreIco);
}
+ myViewBar->setVisible(isActiveWindow());
+ myWindowBar->setVisible(isActiveWindow());
+ myGripWgt->setVisible(isActiveWindow() && (!isMaximized()));
}
} else
QWidget::changeEvent(theEvent);
}
+
+void XGUI_ViewWindow::windowActivated()
+{
+ myViewBar->show();
+ myWindowBar->show();
+ myGripWgt->setVisible(!(isMaximized() || isMinimized()));
+}
+
+void XGUI_ViewWindow::windowDeactivated()
+{
+ myViewBar->hide();
+ myWindowBar->hide();
+ myGripWgt->hide();
+}
+
+
//****************************************************************
void XGUI_ViewWindow::onClose()
{
}
//****************************************************************
-void XGUI_ViewWindow::enterEvent(QEvent* theEvent)
+/*void XGUI_ViewWindow::enterEvent(QEvent* theEvent)
{
if (!isMinimized()) {
myViewBar->show();
myViewBar->hide();
myGripWgt->hide();
myWindowBar->hide();
-}
+}*/
//****************************************************************
void XGUI_ViewWindow::onMinimize()
//! Reset point of view
void reset();
+ void windowActivated();
+
+ void windowDeactivated();
protected:
virtual void resizeEvent(QResizeEvent* theEvent);
virtual void changeEvent(QEvent* theEvent);
- virtual void enterEvent(QEvent* theEvent);
- virtual void leaveEvent(QEvent* theEvent);
+ //virtual void enterEvent(QEvent* theEvent);
+ //virtual void leaveEvent(QEvent* theEvent);
virtual bool eventFilter(QObject *theObj, QEvent *theEvent);
setAttribute(Qt::WA_PaintOnScreen);
}
- void repaintBackground();
-
protected:
virtual void paintEvent(QPaintEvent* theEvent);
}
// set zooming style to standard
//myZoomingStyle = 0;
+
+ QMdiArea* aMDI = myMainWindow->mdiArea();
+ connect(aMDI, SIGNAL(subWindowActivated(QMdiSubWindow*)), this, SLOT(onWindowActivated(QMdiSubWindow*)));
+
}
XGUI_Viewer::~XGUI_Viewer(void)
*/
void XGUI_Viewer::onWindowActivated(QMdiSubWindow* view)
{
+ if (view && (view != myActiveView)) {
myActiveView = view;
+ ((XGUI_ViewWindow*)myActiveView->widget())->windowActivated();
+ QList<QMdiSubWindow*>::iterator aIt;
+ for (aIt = myViews.begin(); aIt != myViews.end(); ++aIt)
+ if ((*aIt) != myActiveView)
+ ((XGUI_ViewWindow*)(*aIt)->widget())->windowDeactivated();
+ }
}