+ return fabs(theNewSize - theSize) > theSize * EPS || fabs(theNewSize - theSize) > theNewSize * EPS;
+}
+
+void XGUI_Viewer::onViewClosed(QMdiSubWindow* theView)
+{
+ if ( !theView )
+ return;
+
+ emit deleteView( static_cast<XGUI_ViewWindow*>(theView->widget()) );
+ removeView( theView );
+
+ // if this is last view
+ if (myViews.size() == 0) {
+ Standard_Integer aViewsNb = 0;
+ for ( myV3dViewer->InitActiveViews(); myV3dViewer->MoreActiveViews(); myV3dViewer->NextActiveViews())
+ ++aViewsNb;
+ if ( aViewsNb < 2 ) {
+ //clean up presentations before last view is closed
+ myAISContext->RemoveAll(Standard_False);
+ }
+ }
+}
+
+/*!Remove view window \a theView from view manager.
+ *And close the last view, if it has \a theView.
+*/
+void XGUI_Viewer::removeView( QMdiSubWindow* theView )
+{
+ XGUI_ViewWindow* aWindow = static_cast<XGUI_ViewWindow*>(theView->widget());
+
+ aWindow->disconnect( this );
+ myViews.removeAt( myViews.indexOf( theView ) );
+ if ( myActiveView == theView )
+ myActiveView = 0;
+ if ( myViews.size() == 0 )
+ emit lastViewClosed();
+}
+
+
+/*void XGUI_Viewer::onViewMapped()
+{
+ setTrihedronShown(true);
+}*/
+
+
+void XGUI_Viewer::addView(QMdiSubWindow* theView)
+{
+ XGUI_ViewWindow* aWindow = dynamic_cast<XGUI_ViewWindow*>(theView->widget());
+
+ connect(aWindow, SIGNAL(closed(QMdiSubWindow*)),
+ this, SLOT(onViewClosed(QMdiSubWindow*)));
+
+ connect(aWindow, SIGNAL(tryClosing(XGUI_ViewWindow*)),
+ this, SIGNAL(tryCloseView(XGUI_ViewWindow*)));
+
+ connect(aWindow, SIGNAL(mousePressed(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMousePressed(XGUI_ViewWindow*, QMouseEvent*)));
+
+ connect(aWindow, SIGNAL(mouseReleased(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)));
+
+ connect(aWindow, SIGNAL(mouseDoubleClicked(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)));
+
+ connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)));
+
+ connect(aWindow, SIGNAL(keyPressed(XGUI_ViewWindow*, QKeyEvent*)),
+ this, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*)));
+
+ connect(aWindow, SIGNAL(keyReleased(XGUI_ViewWindow*, QKeyEvent*)),
+ this, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)));
+
+// connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )),
+// this, SLOT (onContextMenuRequested( QContextMenuEvent* )));
+
+ connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*)));
+
+ connect(aWindow, SIGNAL(mouseReleased(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*)));
+
+ myViews.append(theView);