+ }
+}
+
+/*!
+ \brief Get current buttons mode
+ \return current buttons mode
+ \sa setDropDownButtons()
+*/
+bool SUIT_ViewWindow::dropDownButtons() const
+{
+ return myIsDropDown;
+}
+
+/*!
+ \return window unique identifier
+*/
+int SUIT_ViewWindow::getId() const
+{
+ return int(long(this));
+}
+
+/*!
+ Get camera properties for the view window.
+ \return shared pointer on camera properties. Base implementation
+ returns null properties.
+*/
+SUIT_CameraProperties SUIT_ViewWindow::cameraProperties()
+{
+ return SUIT_CameraProperties();
+}
+
+/*!
+ Synchronize this view window's camera properties with specified
+ view window.
+
+ This method is a part of general views synchronization mechanism.
+ It should be redefined in successors. Base imlementation does nothing.
+
+ \param otherWindow other view window
+*/
+void SUIT_ViewWindow::synchronize( SUIT_ViewWindow* /*otherWindow*/ )
+{
+ // base implementation does nothing
+}
+
+/*!
+ Get action for views syncronization.
+
+ This method is a part of general views synchronization mechanism.
+ It creates an action that can be inserted, for instance, to the toolbar.
+
+ \return action for views synchronization
+*/
+QAction* SUIT_ViewWindow::synchronizeAction()
+{
+ if ( !mySyncAction ) {
+ SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+ mySyncAction = new QtxAction( tr( "MNU_SYNCHRONIZE_VIEW" ),
+ resMgr->loadPixmap( "SUIT", tr( "ICON_VIEW_SYNC" ) ),
+ tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this );
+ mySyncAction->setStatusTip( tr( "DSC_SYNCHRONIZE_VIEW" ) );
+ mySyncAction->setMenu( new QMenu( this ) );
+ mySyncAction->setCheckable( true );
+ connect( mySyncAction->menu(), SIGNAL( aboutToShow() ), this, SLOT( updateSyncViews() ) );
+ connect( mySyncAction, SIGNAL( triggered( bool ) ), this, SLOT( onSynchronizeView( bool ) ) );
+ }
+ return mySyncAction;
+}
+
+/*!
+ Emit notification signal that the view is transformed.
+ Other views can use the signal for synchronization.
+*/
+void SUIT_ViewWindow::emitViewModified()
+{
+ emit viewModified( this );
+}
+
+/*!
+ Update list of available view for the "Synchronize View" action
+*/
+void SUIT_ViewWindow::updateSyncViews()
+{
+ SUIT_CameraProperties props = cameraProperties();
+ if ( !props.isValid() )
+ return;
+
+ QAction* anAction = synchronizeAction();
+ if ( anAction && anAction->menu() ) {
+ int currentId = anAction->data().toInt();
+ anAction->menu()->clear();
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( app ) {
+ SUIT_Desktop* d = app->desktop();
+ QList<SUIT_ViewWindow*> allViews = d->findChildren<SUIT_ViewWindow*>();
+ foreach( SUIT_ViewWindow* vw, allViews ) {
+ if ( !vw || vw == this ) continue; // skip invalid views and this one
+ SUIT_CameraProperties otherProps = vw->cameraProperties();
+ if ( otherProps.isCompatible( props ) ) {
+ QAction* a = anAction->menu()->addAction( vw->windowTitle() );
+ if ( vw->getId() == currentId ) {
+ QFont f = a->font();
+ f.setBold( true );
+ a->setFont( f );
+ }
+ a->setData( vw->getId() );
+ connect( a, SIGNAL( triggered( bool ) ), this, SLOT( onSynchronizeView( bool ) ) );
+ }
+ else if ( vw->getId() == currentId ) {
+ // other view, this one is being currently synchronized to, seems has become incompatible
+ // we have to break synchronization
+ vw->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), this, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ this->disconnect( SIGNAL( viewModified( SUIT_ViewWindow* ) ), vw, SLOT( synchronize( SUIT_ViewWindow* ) ) );
+ //
+ bool blocked = anAction->blockSignals( true );
+ anAction->setChecked( false );
+ anAction->blockSignals( blocked );
+ anAction->setData( 0 );
+ //
+ QAction* a = vw->synchronizeAction();
+ if ( a ) {
+ blocked = a->blockSignals( true );
+ a->setChecked( false );
+ a->blockSignals( blocked );
+ }
+ }
+ }
+ }
+ if ( anAction->menu()->actions().isEmpty() ) {
+ anAction->setData( 0 );
+ anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );