+ if (myStartPnt == myEndPnt)
+ {
+ if (!aHasShift) {
+ myAISContext->ClearCurrents( false );
+ emit deselection();
+ }
+ if ( !isPreselectionEnabled() ) {
+ Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+ if ( !aView3d.IsNull() ) {
+ myAISContext->MoveTo( myEndPnt.x(), myEndPnt.y(), aView3d, Standard_True );
+ }
+ }
+
+ if (aHasShift && myMultiSelectionEnabled)
+ myAISContext->ShiftSelect( Standard_True );
+ else
+ myAISContext->Select( Standard_True );
+ emit selectionChanged();
+ }
+
+ //else
+ //{
+ // if (aHasShift && myMultiSelectionEnabled)
+ // myAISContext->ShiftSelect(myStartPnt.x(), myStartPnt.y(),
+ // myEndPnt.x(), myEndPnt.y(),
+ // aView->getViewPort()->getView(), Standard_False );
+ // else
+ // myAISContext->Select(myStartPnt.x(), myStartPnt.y(),
+ // myEndPnt.x(), myEndPnt.y(),
+ // aView->getViewPort()->getView(), Standard_False );
+
+ // int Nb = myAISContext->NbSelected();
+ // if( Nb>1 && !myMultiSelectionEnabled )
+ // {
+ // myAISContext->InitSelected();
+ // Handle( SelectMgr_EntityOwner ) anOwner = myAISContext->SelectedOwner();
+ // if( !anOwner.IsNull() )
+ // {
+ // myAISContext->ClearSelected( Standard_False );
+ // myAISContext->AddOrRemoveSelected( anOwner, Standard_False );
+ // }
+ // }
+
+ // myAISContext->UpdateCurrentViewer();
+ //}
+}
+
+/*!
+ SLOT: called on key press, processes selection in "key free" interaction style
+*/
+void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEvent)
+{
+ if (!mySelectionEnabled) return;
+
+ OCCViewer_ViewWindow* aView = qobject_cast<OCCViewer_ViewWindow*>( theWindow );
+ if ( !aView ) return;
+
+ bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
+
+ switch ( theEvent->key() ) {
+ case Qt::Key_S:
+ if (!aHasShift) {
+ myAISContext->ClearCurrents( false );
+ emit deselection();
+ }
+
+ if ( !isPreselectionEnabled() ) {
+ Handle(V3d_View) aView3d = aView->getViewPort()->getView();
+ if ( !aView3d.IsNull() ) {
+ myAISContext->MoveTo(myCurPnt.x(), myCurPnt.y(), aView3d, Standard_True );
+ }
+ }
+
+ if (aHasShift && myMultiSelectionEnabled)
+ myAISContext->ShiftSelect( Standard_True );
+ else
+ myAISContext->Select( Standard_True );
+
+ emit selectionChanged();
+
+ break;
+ case Qt::Key_N:
+ if ( isPreselectionEnabled() ) {
+#if OCC_VERSION_LARGE <= 0x07030000
+ if ( useLocalSelection() )
+#endif
+ getAISContext()->HilightNextDetected( aView->getViewPort()->getView() );
+ }
+ break;
+ case Qt::Key_P:
+ if ( isPreselectionEnabled() ) {
+#if OCC_VERSION_LARGE <= 0x07030000
+ if ( useLocalSelection() )
+#endif
+ getAISContext()->HilightPreviousDetected( aView->getViewPort()->getView() );
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void OCCViewer_Viewer::onViewClosed(OCCViewer_ViewPort3d*)
+{
+ 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);
+ }
+}
+
+void OCCViewer_Viewer::onViewMapped(OCCViewer_ViewPort3d* viewPort)
+{
+ setTrihedronShown( true );
+ bool showStaticTrihedron = true;
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ if ( resMgr ) showStaticTrihedron = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
+ viewPort->showStaticTrihedron( showStaticTrihedron );
+}
+
+int OCCViewer_Viewer::getTopLayerId()
+{
+ if ( myTopLayerId == 0 && !myAISContext->CurrentViewer().IsNull() )
+ myAISContext->CurrentViewer()->AddZLayer( myTopLayerId );
+
+ return myTopLayerId;
+}
+
+/*!
+ \return interaction style
+*/
+int OCCViewer_Viewer::interactionStyle() const
+{
+ return myInteractionStyle;
+}
+
+/*!
+ Sets interaction style: 0 - standard, 1 - keyboard free interaction
+ \param theStyle - new interaction style
+*/
+void OCCViewer_Viewer::setInteractionStyle( const int theStyle )
+{
+ myInteractionStyle = theStyle;
+ //!! To be done for view windows
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setInteractionStyle( theStyle );
+ }
+}
+
+/*!
+ \return projection type
+*/
+int OCCViewer_Viewer::projectionType() const
+{
+ return myProjectionType;
+}
+
+/*!
+ Sets projection type: 0 - orthographic, 1 - perspective
+ \param theType - new projection type
+*/
+void OCCViewer_Viewer::setProjectionType( const int theType )
+{
+ if ( myProjectionType != theType ) {
+ if ( theType != OCCViewer_ViewWindow::Stereo )
+ myProjectionType = theType;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setProjectionType( (OCCViewer_ViewWindow::ProjectionType)theType );
+ }
+ }
+}
+
+
+OCCViewer_ViewWindow::SelectionStyle OCCViewer_Viewer::selectionStyle() const
+{
+ return mySelectionStyle;
+}
+
+void OCCViewer_Viewer::setSelectionStyle(OCCViewer_ViewWindow::SelectionStyle theMode)
+{
+ if (mySelectionStyle != theMode) {
+ mySelectionStyle = theMode;
+ if (!myViewManager)
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for (int i = 0; i < (int)wins.count(); i++)
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>(wins.at(i));
+ if (win)
+ win->setSelectionStyle(theMode);
+ }
+ }
+}
+
+
+
+/*!
+ \return stereo type
+*/
+int OCCViewer_Viewer::stereoType() const
+{
+ return myStereoType;
+}
+
+/*!
+ Sets stereo type
+ \param theType - new stereo type
+*/
+void OCCViewer_Viewer::setStereoType( const int theType )
+{
+ myStereoType = theType;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setStereoType( (OCCViewer_ViewWindow::StereoType)theType );
+ }
+}
+
+/*!
+ \return stereographic focus type
+*/
+int OCCViewer_Viewer::stereographicFocusType() const
+{
+ return myStereographicFocusType;
+}
+
+/*!
+ \return stereographic focus value
+*/
+double OCCViewer_Viewer::stereographicFocusValue() const
+{
+ return myStereographicFocusValue;
+}
+
+/*!
+ Sets stereographic focus parameters
+ \param theType - new stereographic focus type
+ \param theValue - new stereographic focus value
+*/
+void OCCViewer_Viewer::setStereographicFocus( const int theType, const double theValue )
+{
+ myStereographicFocusType = theType;
+ myStereographicFocusValue = theValue;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setStereographicFocus( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
+ }
+}
+
+/*!
+ \return stereographic focus type
+*/
+int OCCViewer_Viewer::interocularDistanceType() const
+{
+ return myInterocularDistanceType;
+}
+
+/*!
+ \return stereographic focus value
+*/
+double OCCViewer_Viewer::interocularDistanceValue() const
+{
+ return myInterocularDistanceValue;
+}
+
+/*!
+ Sets interocular distance parameters
+ \param theType - new IOD type
+ \param theValue - new IOD value
+*/
+void OCCViewer_Viewer::setInterocularDistance( const int theType, const double theValue )
+{
+ myInterocularDistanceType = theType;
+ myInterocularDistanceValue = theValue;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setInterocularDistance( (OCCViewer_ViewWindow::FocusIODType)theType, theValue );
+ }
+}
+
+/*!
+ \return anaglyph filter
+*/
+int OCCViewer_Viewer::anaglyphFilter() const
+{
+ return myAnaglyphFilter;
+}
+
+/*!
+ Sets anaglyph filter
+ \param theType - new anaglyph filter
+*/
+void OCCViewer_Viewer::setAnaglyphFilter( const int theType )
+{
+ myAnaglyphFilter = theType;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setAnaglyphFilter( (OCCViewer_ViewWindow::AnaglyphFilter)theType );
+ }
+}
+
+/*!
+ \return reverse stereo
+*/
+bool OCCViewer_Viewer::isReverseStereo() const
+{
+ return myToReverseStereo;
+}
+
+/*!
+ Sets reverse stereo
+ \param theReverse - enable/disable reverse mode
+*/
+void OCCViewer_Viewer::setReverseStereo( const bool theReverse )
+{
+ myToReverseStereo = theReverse;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setReverseStereo( theReverse );
+ }
+}
+
+/*!
+ \return V-Sync mode
+*/
+bool OCCViewer_Viewer::isVSync() const
+{
+ return myVSyncMode;
+}
+
+/*!
+ Set V-Sync mode
+ \param theEnable - enable/disable V-Sync mode
+*/
+void OCCViewer_Viewer::setVSync( const bool theEnable )
+{
+ myVSyncMode = theEnable;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setVSync( theEnable );
+ }
+}
+
+/*!
+ \return support quad-buffered stereo
+*/
+bool OCCViewer_Viewer::isQuadBufferSupport() const
+{
+ return myQuadBufferSupport;
+}
+
+/*!
+ Set support quad-buffered stereo
+ \param theEnable - enable/disable support quad-buffered stereo
+*/
+void OCCViewer_Viewer::setQuadBufferSupport( const bool theEnable )
+{
+ myQuadBufferSupport = theEnable;
+
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setQuadBufferSupport( theEnable );
+ }
+}
+
+/*!
+ \return zooming style
+*/
+int OCCViewer_Viewer::zoomingStyle() const
+{
+ return myZoomingStyle;
+}
+
+/*!
+ Sets zooming style: 0 - standard, 1 - advanced (at cursor)
+ \param theStyle - new zooming style
+*/
+void OCCViewer_Viewer::setZoomingStyle( const int theStyle )
+{
+ myZoomingStyle = theStyle;
+ //!! To be done for view windows
+ if ( !myViewManager )
+ return;
+
+ QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+ for ( int i = 0; i < (int)wins.count(); i++ )
+ {
+ OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+ if ( win )
+ win->setZoomingStyle( theStyle );
+ }
+}
+
+/*!
+ \return true if preselection is enabled
+*/
+bool OCCViewer_Viewer::isPreselectionEnabled() const
+{
+ return myPreselectionEnabled;
+}
+
+/*!
+ Enables/disables preselection
+ \param isEnabled - new status
+*/
+void OCCViewer_Viewer::enablePreselection(bool isEnabled)
+{
+ myPreselectionEnabled = isEnabled;