#include <QMdiArea>
#include <QMdiSubWindow>
#include <QPainter>
-#include <QTime>
+#include <QTimer>
+#include <QFileDialog>
+#include <QStyleOptionToolBar>
#include <TopoDS_Shape.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
+#include <Visual3d_View.hxx>
#define BORDER_SIZE 2
"................................", "................................",
"................................", "................................" };
-//**************************************************************************
+
+ViewerToolbar::ViewerToolbar(QWidget* theParent, XGUI_ViewPort* thePort)
+ : QToolBar(theParent), myVPort(thePort), myResize(false)
+{
+ connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized()));
+}
+
void ViewerToolbar::paintEvent(QPaintEvent* theEvent)
{
- //QTime aTime;
- //aTime.start();
+ //QToolBar::paintEvent(theEvent);
+ // Paint background
+ QPainter aPainter(this);
QRect aRect = rect();
QRect aVPRect = myVPort->rect();
QPoint aGlobPnt = mapToGlobal(aRect.topLeft());
QPoint aPnt = myVPort->mapFromGlobal(aGlobPnt);
- QRect aImgRect(
- QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height()));
- QPainter(this).drawImage(aRect, myVPort->dumpView(aImgRect, false));
- //QString aMsg = QString("### Painted in %1").arg(aTime.elapsed());
- //qDebug(qPrintable(aMsg));
+ QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(),
+ aRect.width(), aRect.height()));
+ QImage aImg = myVPort->dumpView(aImgRect, myResize);
+ if (!aImg.isNull())
+ aPainter.drawImage(aRect, aImg);
+ myResize = false;
+
+ // 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);
}
//**************************************************************************
+ViewerLabel::ViewerLabel(QWidget* theParent, XGUI_ViewPort* thePort)
+ : QLabel(theParent), myVPort(thePort), myResize(false)
+{
+ connect(myVPort, SIGNAL(resized()), this, SLOT(onViewPortResized()));
+}
+
void ViewerLabel::paintEvent(QPaintEvent* theEvent)
{
QRect aRect = rect();
QPoint aGlobPnt = mapToGlobal(aRect.topLeft());
QPoint aPnt = myVPort->mapFromGlobal(aGlobPnt);
- QRect aImgRect(
- QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(), aRect.width(), aRect.height()));
- QPainter(this).drawImage(aRect, myVPort->dumpView(aImgRect, false));
+ QRect aImgRect(QRect(aPnt.x(), aPnt.y() + aVPRect.height() - aRect.height(),
+ aRect.width(), aRect.height()));
+ QImage aImg = myVPort->dumpView(aImgRect, myResize);
+ if (!aImg.isNull())
+ QPainter(this).drawImage(aRect, aImg);
QLabel::paintEvent(theEvent);
}
//**************************************************************************
//**************************************************************************
XGUI_ViewWindow::XGUI_ViewWindow(XGUI_Viewer* theViewer, V3d_TypeOfView theType)
- : QFrame(), myViewer(theViewer), myMoving(false), MinimizeIco(":pictures/wnd_minimize.png"), MaximizeIco(
- ":pictures/wnd_maximize.png"), CloseIco(":pictures/wnd_close.png"), RestoreIco(
- ":pictures/wnd_restore.png"), myInteractionStyle(XGUI::STANDARD), myRectBand(0), myIsKeyFree(
- false), my2dMode(XGUI::No2dMode), myCurrPointType(XGUI::GRAVITY), myPrevPointType(
- XGUI::GRAVITY), myRotationPointSelection(false)
+ : QFrame(),
+ myViewer(theViewer),
+ myMoving(false),
+ MinimizeIco(":pictures/wnd_minimize.png"),
+ MaximizeIco(":pictures/wnd_maximize.png"),
+ CloseIco(":pictures/wnd_close.png"),
+ RestoreIco(":pictures/wnd_restore.png"),
+ myInteractionStyle(XGUI::STANDARD),
+ myRectBand(0),
+ myIsKeyFree(false),
+ my2dMode(XGUI::No2dMode),
+ myCurrPointType(XGUI::GRAVITY),
+ myPrevPointType(XGUI::GRAVITY),
+ myRotationPointSelection(false),
+ myClosable(true),
+ myStartX(0), myStartY(0), myCurrX(0), myCurrY(0), myCurScale(0.0), myCurSketch(0),
+ myDrawRect(false), myEnableDrawMode(true), myCursorIsHand(false), myEventStarted(false),
+ myIsActive(false),
+ myLastState(WindowNormalState), myOperation(NOTHING)
{
mySelectedPoint = gp_Pnt(0., 0., 0.);
setFrameStyle(QFrame::Raised);
aLay->setContentsMargins(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE);
myViewPort = new XGUI_ViewPort(this, myViewer->v3dViewer(), theType);
myViewPort->installEventFilter(this);
+ myViewPort->setCursor(Qt::ArrowCursor);
aLay->addWidget(myViewPort);
- myPicture = new QLabel();
+ myPicture = new QLabel(this);
myPicture->setFrameStyle(QFrame::Sunken);
myPicture->setFrameShape(QFrame::Panel);
myPicture->setMouseTracking(true);
myPicture->installEventFilter(this);
+ aLay->addWidget(myPicture);
myPicture->hide();
- QStringList aPictures;
- aPictures << ":pictures/occ_view_camera_dump.png" << ":pictures/occ_view_style_switch.png";
- aPictures << ":pictures/occ_view_triedre.png" << ":pictures/occ_view_fitall.png";
- aPictures << ":pictures/occ_view_fitarea.png" << ":pictures/occ_view_zoom.png";
- aPictures << ":pictures/occ_view_pan.png" << ":pictures/occ_view_glpan.png";
- aPictures << ":pictures/occ_view_rotate.png" << ":pictures/occ_view_front.png";
- aPictures << ":pictures/occ_view_back.png" << ":pictures/occ_view_left.png";
- aPictures << ":pictures/occ_view_right.png" << ":pictures/occ_view_top.png";
- aPictures << ":pictures/occ_view_bottom.png" << ":pictures/occ_view_clone.png";
-
- QStringList aTitles;
- aTitles << "Dump view" << "Mouse style switch" << "Show trihedron" << "Fit all";
- aTitles << "Fit area" << "Zoom" << "Panning" << "Global panning" << "Rotate";
- aTitles << "Front" << "Back" << "Left" << "Right" << "Top" << "Bottom" << "Clone view";
+ QVBoxLayout* aVPLay = new QVBoxLayout(myViewPort);
+ aVPLay->setMargin(0);
+ aVPLay->setSpacing(0);
+ aVPLay->setContentsMargins(0,0,0,0);
+
+ QHBoxLayout* aToolLay = new QHBoxLayout();
+ aToolLay->setMargin(0);
+ aToolLay->setSpacing(0);
+ aToolLay->setContentsMargins(0,0,0,0);
+ aVPLay->addLayout(aToolLay);
+ aVPLay->addStretch();
myGripWgt = new ViewerLabel(this, myViewPort);
myGripWgt->setPixmap(QPixmap(":pictures/wnd_grip.png"));
- myGripWgt->setGeometry(BORDER_SIZE + 2, BORDER_SIZE + 2, 19, 32);
myGripWgt->setMouseTracking(true);
myGripWgt->installEventFilter(this);
- connect(myViewPort, SIGNAL(vpTransformed()), myGripWgt, SLOT(update()));
- connect(myViewPort, SIGNAL(vpUpdated()), myGripWgt, SLOT(update()));
+ myGripWgt->setCursor(Qt::OpenHandCursor);
+ aToolLay->addWidget(myGripWgt);
+ // Create Viewer management buttons
myViewBar = new ViewerToolbar(this, myViewPort);
+ myViewBar->setCursor(Qt::PointingHandCursor);
+ aToolLay->addWidget(myViewBar);
+ aToolLay->addStretch();
QAction* aBtn;
- for(int i = 0; i < aTitles.length(); i++) {
- aBtn = new QAction(QIcon(aPictures.at(i)), aTitles.at(i), myViewBar);
- myViewBar->addAction(aBtn);
- }
- connect(myViewPort, SIGNAL(vpTransformed()), myViewBar, SLOT(update()));
- connect(myViewPort, SIGNAL(vpUpdated()), myViewBar, SLOT(update()));
+ // Dump view
+ aBtn = new QAction(QIcon(":pictures/occ_view_camera_dump.png"), tr("Dump view"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(dumpView()));
+ myViewBar->addAction(aBtn);
+ // Fit all
+ aBtn = new QAction(QIcon(":pictures/occ_view_fitall.png"), tr("Fit all"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(fitAll()));
+ myViewBar->addAction(aBtn);
+ // Fit area
+ aBtn = new QAction(QIcon(":pictures/occ_view_fitarea.png"), tr("Fit area"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(activateWindowFit()));
+ myViewBar->addAction(aBtn);
+ // Zoom
+ aBtn = new QAction(QIcon(":pictures/occ_view_zoom.png"), tr("Zoom"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(activateZoom()));
+ myViewBar->addAction(aBtn);
+ // Pan
+ aBtn = new QAction(QIcon(":pictures/occ_view_pan.png"), tr("Panning"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(activatePanning()));
+ myViewBar->addAction(aBtn);
+ // Global Panning
+ aBtn = new QAction(QIcon(":pictures/occ_view_glpan.png"), tr("Global panning"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(activateGlobalPanning()));
+ myViewBar->addAction(aBtn);
+ // Rotation
+ aBtn = new QAction(QIcon(":pictures/occ_view_rotate.png"), tr("Rotate"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(activateRotation()));
+ myViewBar->addAction(aBtn);
+ // Reset
+ aBtn = new QAction(QIcon(":pictures/occ_view_reset.png"), tr("Reset"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(reset()));
+ myViewBar->addAction(aBtn);
+ // Front view
+ aBtn = new QAction(QIcon(":pictures/occ_view_front.png"), tr("Front"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(frontView()));
+ myViewBar->addAction(aBtn);
+ // Back view
+ aBtn = new QAction(QIcon(":pictures/occ_view_back.png"), tr("Back"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(backView()));
+ myViewBar->addAction(aBtn);
+ // Top view
+ aBtn = new QAction(QIcon(":pictures/occ_view_top.png"), tr("Top"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(topView()));
+ myViewBar->addAction(aBtn);
+ // Bottom view
+ aBtn = new QAction(QIcon(":pictures/occ_view_bottom.png"), tr("Bottom"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(bottomView()));
+ myViewBar->addAction(aBtn);
+ // Left view
+ aBtn = new QAction(QIcon(":pictures/occ_view_left.png"), tr("Left"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(leftView()));
+ myViewBar->addAction(aBtn);
+ // Right view
+ aBtn = new QAction(QIcon(":pictures/occ_view_right.png"), tr("Right"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(rightView()));
+ myViewBar->addAction(aBtn);
+ // Clone view
+ aBtn = new QAction(QIcon(":pictures/occ_view_clone.png"), tr("Clone"), myViewBar);
+ connect(aBtn, SIGNAL(triggered()), SLOT(cloneView()));
+ myViewBar->addAction(aBtn);
+
+ // Create Window management buttons
myWindowBar = new ViewerToolbar(this, myViewPort);
- connect(myViewPort, SIGNAL(vpTransformed()), myWindowBar, SLOT(update()));
- connect(myViewPort, SIGNAL(vpUpdated()), myWindowBar, SLOT(update()));
+ myWindowBar->setCursor(Qt::PointingHandCursor);
+ aToolLay->addWidget(myWindowBar);
myMinimizeBtn = new QAction(myWindowBar);
myMinimizeBtn->setIcon(MinimizeIco);
myWindowBar->addAction(aBtn);
connect(aBtn, SIGNAL(triggered()), SLOT(onClose()));
- myViewBar->hide();
- myWindowBar->hide();
- myGripWgt->hide();
+ //Support copy of background on updating of viewer
+ connect(myViewPort, SIGNAL(vpTransformed()), this, SLOT(updateToolBar()));
+ connect(myViewPort, SIGNAL(vpUpdated()), this, SLOT(updateToolBar()));
+ connect(this, SIGNAL(vpTransformationFinished(XGUI_ViewWindow::OperationType)),
+ this, SLOT(updateToolBar()));
+
}
//****************************************************************
{
}
+
//****************************************************************
-void XGUI_ViewWindow::resizeEvent(QResizeEvent* theEvent)
+void XGUI_ViewWindow::showEvent(QShowEvent* theEvent)
{
- QSize aSize = theEvent->size();
- QSize aWndBarSize = myWindowBar->sizeHint();
- QSize myViewBarSize = myViewBar->sizeHint();
-
- myWindowBar->move(aSize.width() - aWndBarSize.width() - BORDER_SIZE - 4,
- BORDER_SIZE + 2);
- int aViewBarWidth = aSize.width() - aWndBarSize.width() - myGripWgt->width() - 8;
- if (aViewBarWidth > myViewBarSize.width())
- aViewBarWidth = myViewBarSize.width();
- myViewBar->setGeometry(BORDER_SIZE + 18, BORDER_SIZE + 2, aViewBarWidth, myViewBarSize.height());
+ QFrame::showEvent(theEvent);
+ myWindowBar->setFixedSize(myWindowBar->sizeHint());
}
//****************************************************************
if (theEvent->type() == QEvent::WindowStateChange) {
if (isMinimized()) {
- if (!myPicture->parentWidget()) {
- QMdiSubWindow* aParent = static_cast<QMdiSubWindow*>(parentWidget());
- QMdiArea* aMDIArea = aParent->mdiArea();
- myPicture->setParent(aMDIArea);
+ if (myPicture->isHidden()) {
+ myViewBar->hide();
+ myGripWgt->hide();
+ myWindowBar->hide();
+ myViewPort->hide();
+ myPicture->show();
}
- myPicture->move(parentWidget()->x(), parentWidget()->y());
- myPicture->show();
} else {
- myPicture->hide();
+ if (myPicture->isVisible()) {
+ myPicture->hide();
+ myViewPort->show();
+ }
if (isMaximized()) {
myMinimizeBtn->setIcon(MinimizeIco);
myMaximizeBtn->setIcon(RestoreIco);
}
+ myViewBar->setVisible(myIsActive);
+ myWindowBar->setVisible(myIsActive);
+ myGripWgt->setVisible(myIsActive && (!isMaximized()));
}
} else
QWidget::changeEvent(theEvent);
}
+
+
//****************************************************************
-void XGUI_ViewWindow::onClose()
+void XGUI_ViewWindow::windowActivated()
{
- if (parentWidget())
- parentWidget()->close();
-
+ if (!(isMinimized() || parentWidget()->isMinimized())) {
+ myIsActive = true;
+ if (isMaximized() || parentWidget()->isMaximized()) {
+ myMaximizeBtn->setIcon(RestoreIco);
+ } else {
+ myMaximizeBtn->setIcon(MaximizeIco);
+ }
+ myViewBar->show();
+ myWindowBar->show();
+ myGripWgt->setVisible(!(isMaximized() || isMinimized() ||
+ parentWidget()->isMaximized() || parentWidget()->isMinimized()));
+ } else
+ myIsActive = false;
}
//****************************************************************
-void XGUI_ViewWindow::enterEvent(QEvent* theEvent)
+void XGUI_ViewWindow::windowDeactivated()
{
- if (!isMinimized()) {
- myViewBar->show();
- if (!isMaximized())
- myGripWgt->show();
+ myIsActive = false;
+ if (!(isMinimized() || parentWidget()->isMinimized())) {
+ if (isMaximized() || parentWidget()->isMaximized()) {
+ myMaximizeBtn->setIcon(RestoreIco);
+ } else {
+ myMaximizeBtn->setIcon(MaximizeIco);
+ }
+ myViewBar->hide();
+ myWindowBar->hide();
+ myGripWgt->hide();
}
- myWindowBar->show();
}
+
//****************************************************************
-void XGUI_ViewWindow::leaveEvent(QEvent* theEvent)
+void XGUI_ViewWindow::onClose()
{
- myViewBar->hide();
- myGripWgt->hide();
- myWindowBar->hide();
+ if (parentWidget()) {
+ emit tryClosing(this);
+ if (closable()) {
+ emit closed(static_cast<QMdiSubWindow*>(parentWidget()));
+ parentWidget()->close();
+ }
+ }
}
//****************************************************************
int aW = width();
int aH = height();
double aR = aW / 100.;
- myPicture->setPixmap(aPMap.scaled(100, int(aH / aR)));
+ int aNewH = int(aH / aR);
+ myPicture->setPixmap(aPMap.scaled(100, aNewH));
- myLastState = isMaximized() ? MaximizedState : NormalState;
+ myLastState = (isMaximized() || parentWidget()->isMaximized()) ? MaximizedState : WindowNormalState;
showMinimized();
+ parentWidget()->showMinimized();
+ parentWidget()->setGeometry(parentWidget()->x(), parentWidget()->y(), 100, aNewH);
+ parentWidget()->lower();
+ windowDeactivated();
+ myViewer->onWindowMinimized((QMdiSubWindow*)parentWidget());
}
//****************************************************************
void XGUI_ViewWindow::onMaximize()
{
- if (isMaximized()) {
+ if (isMaximized() || parentWidget()->isMaximized()) {
myMaximizeBtn->setIcon(MaximizeIco);
myGripWgt->show();
showNormal();
+ parentWidget()->showNormal();
} else {
myMaximizeBtn->setIcon(RestoreIco);
myGripWgt->hide();
showMaximized();
+ parentWidget()->showMaximized();
}
+ parentWidget()->activateWindow();
myMinimizeBtn->setIcon(MinimizeIco);
+
+ // In order to avoid frosen background in toolbars when it shown as a second view
+ QTimer::singleShot(50, parentWidget(), SLOT(setFocus()));
}
//****************************************************************
bool XGUI_ViewWindow::processWindowControls(QObject *theObj, QEvent *theEvent)
{
- QWidget* aWgt = (theObj == myPicture) ? myPicture : static_cast<QWidget*>(parentWidget());
switch(theEvent->type()) {
case QEvent::MouseButtonPress: {
QMouseEvent* aEvent = static_cast<QMouseEvent*>(theEvent);
QPoint aPnt = aEvent->globalPos();
QPoint aMDIPnt = aMDIArea->mapFromGlobal(aPnt);
if (aMDIArea->rect().contains(aMDIPnt)) {
- int aX = aWgt->x() + (aPnt.x() - myMousePnt.x());
- int aY = aWgt->y() + (aPnt.y() - myMousePnt.y());
- aWgt->move(aX, aY);
+ int aX = aParent->x() + (aPnt.x() - myMousePnt.x());
+ int aY = aParent->y() + (aPnt.y() - myMousePnt.y());
+ aParent->move(aX, aY);
myMousePnt = aPnt;
}
return true;
case QEvent::MouseButtonDblClick:
if (theObj == myPicture) {
myMoving = false;
- if (myLastState == MaximizedState)
+ if (myLastState == MaximizedState) {
showMaximized();
- else
+ } else {
showNormal();
+ }
+ myViewer->onWindowActivated((QMdiSubWindow*)parentWidget());
+
+ // In order to avoid frosen background in toolbars when it shown as a second view
+ QTimer::singleShot(20, parentWidget(), SLOT(setFocus()));
+
return true;
}
}
case QEvent::MouseButtonDblClick:
emit mouseDoubleClicked(this, (QMouseEvent*) theEvent);
return true;
+ case QEvent::Wheel:
+ {
+ QWheelEvent* aEvent = (QWheelEvent*) theEvent;
+ myViewPort->startZoomAtPoint( aEvent->x(), aEvent->y() );
+ double aDelta = (double)( aEvent->delta() ) / ( 15 * 8 );
+ int x = aEvent->x();
+ int y = aEvent->y();
+ int x1 = (int)( aEvent->x() + width()*aDelta/100 );
+ int y1 = (int)( aEvent->y() + height()*aDelta/100 );
+ myViewPort->zoom( x, y, x1, y1 );
+ }
+ return true;
}
return false;
}
if (processWindowControls(theObj, theEvent))
return true;
} else if (theObj == myViewPort) {
- if (processViewPort(theEvent))
+ if (processViewPort(theEvent)) {
+ return true;
+ }
+ if (theEvent->type() == QEvent::KeyRelease) {
+ emit keyReleased(this, (QKeyEvent*) theEvent);
return true;
+ }
}
return QFrame::eventFilter(theObj, theEvent);
}
}
}
+/*!
+ \brief Start global panning operation
+
+ Sets the corresponding cursor for the widget.
+*/
+void XGUI_ViewWindow::activateGlobalPanning()
+{
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() ) {
+ QPixmap globalPanPixmap (imageCrossCursor);
+ QCursor glPanCursor (globalPanPixmap);
+ myCurScale = aView3d->Scale();
+ aView3d->FitAll(0.01, false);
+ myCursor = cursor(); // save old cursor
+ myViewPort->fitAll(); // fits view before selecting a new scene center
+ if( setTransformRequested( PANGLOBAL ) )
+ myViewPort->setCursor( glPanCursor );
+ }
+}
+
/*!
\brief Start rotation operation
void XGUI_ViewWindow::setBackground(const XGUI_ViewBackground& theBackground)
{
- if (myViewPort)
- myViewPort->setBackground(theBackground);
+ if (myViewPort)
+ myViewPort->setBackground( theBackground );
+}
+
+/*!
+ \brief Create one more window with same content.
+*/
+void XGUI_ViewWindow::cloneView()
+{
+ QMdiSubWindow* vw = myViewer->createView();
+ XGUI_ViewWindow* aNewWnd = static_cast<XGUI_ViewWindow*>(vw->widget());
+ aNewWnd->viewPort()->syncronizeWith(myViewPort);
+
+ emit viewCloned( vw );
+
+ // In order to avoid frosen background in toolbars when it shown as a second view
+ QTimer::singleShot(20, vw, SLOT(setFocus()));
}
+
+void XGUI_ViewWindow::dumpView()
+{
+ QString aFilter(tr("Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps)"));
+ QString aSelectedFilter;
+ QString aFileName = QFileDialog::getSaveFileName(this, "Save picture", QString(), aFilter, &aSelectedFilter);
+ if (!aFileName.isNull()) {
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ QImage aPicture = myViewPort->dumpView();
+
+ QString aFmt = extension(aFileName).toUpper();
+ if( aFmt.isEmpty() )
+ aFmt = QString( "BMP" ); // default format
+ else if( aFmt == "JPG" )
+ aFmt = "JPEG";
+
+ Handle(Visual3d_View) a3dView = myViewPort->getView()->View();
+ if (aFmt == "PS")
+ a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_PostScript);
+ else if (aFmt == "EPS")
+ a3dView->Export(strdup(qPrintable(aFileName)), Graphic3d_EF_EnhPostScript);
+ else
+ aPicture.save( aFileName, aFmt.toLatin1() );
+ QApplication::restoreOverrideCursor();
+ }
+}
+
+void XGUI_ViewWindow::fitAll()
+{
+ emit vpTransformationStarted( FITALLVIEW );
+ myViewPort->fitAll();
+ emit vpTransformationFinished( FITALLVIEW );
+}
+
+/*!
+ \brief Starts fit operation.
+
+ Sets the corresponding cursor for the widget.
+*/
+void XGUI_ViewWindow::activateWindowFit()
+{
+ if ( !transformRequested() && !myCursorIsHand )
+ myCursor = cursor(); /* save old cursor */
+
+ if ( myOperation != WINDOWFIT ) {
+ QCursor handCursor (Qt::PointingHandCursor);
+ if( setTransformRequested ( WINDOWFIT ) ) {
+ myViewPort->setCursor ( handCursor );
+ myCursorIsHand = true;
+ }
+ }
+}
+
+
+/*!
+ \brief Perform "front view" transformation.
+*/
+void XGUI_ViewWindow::frontView()
+{
+ emit vpTransformationStarted ( FRONTVIEW );
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Xpos);
+ myViewPort->fitAll();
+ emit vpTransformationFinished ( FRONTVIEW );
+}
+
+/*!
+ \brief Perform "back view" transformation.
+*/
+void XGUI_ViewWindow::backView()
+{
+ emit vpTransformationStarted ( BACKVIEW );
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Xneg);
+ myViewPort->fitAll();
+ emit vpTransformationFinished ( BACKVIEW );
+}
+
+/*!
+ \brief Perform "top view" transformation.
+*/
+void XGUI_ViewWindow::topView()
+{
+ emit vpTransformationStarted ( TOPVIEW );
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Zpos);
+ myViewPort->fitAll();
+ emit vpTransformationFinished ( TOPVIEW );
+}
+
+/*!
+ \brief Perform "bottom view" transformation.
+*/
+void XGUI_ViewWindow::bottomView()
+{
+ emit vpTransformationStarted ( BOTTOMVIEW );
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Zneg);
+ myViewPort->fitAll();
+ emit vpTransformationFinished ( BOTTOMVIEW );
+}
+
+/*!
+ \brief Perform "left view" transformation.
+*/
+void XGUI_ViewWindow::leftView()
+{
+ emit vpTransformationStarted ( LEFTVIEW );
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Yneg);
+ myViewPort->fitAll();
+ emit vpTransformationFinished ( LEFTVIEW );
+}
+
+/*!
+ \brief Perform "right view" transformation.
+*/
+void XGUI_ViewWindow::rightView()
+{
+ emit vpTransformationStarted ( RIGHTVIEW );
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Ypos);
+ myViewPort->fitAll();
+ emit vpTransformationFinished ( RIGHTVIEW );
+}
+
+void XGUI_ViewWindow::reset()
+{
+ emit vpTransformationStarted( RESETVIEW );
+ bool upd = myViewPort->getView()->SetImmediateUpdate( false );
+ myViewPort->getView()->Reset( false );
+ myViewPort->fitAll( false, true, false );
+ myViewPort->getView()->SetImmediateUpdate( upd );
+ myViewPort->getView()->Update();
+ emit vpTransformationFinished( RESETVIEW );
+}
+
+
+void XGUI_ViewWindow::updateToolBar()
+{
+ myGripWgt->update();
+ myViewBar->update();
+ myWindowBar->update();
+}
+