*/
void OCCViewer_ViewPort3d::fitRect( const QRect& rect )
{
- if ( !activeView().IsNull() )
+ if ( !activeView().IsNull() ) {
activeView()->WindowFit( rect.left(), rect.top(), rect.right(), rect.bottom() );
+ emit vpTransformed( this );
+ }
}
/*!
else
#endif
activeView()->Zoom( x0 + y0, 0, x + y, 0 );
+ emit vpTransformed( this );
}
}
*/
void OCCViewer_ViewPort3d::setCenter( int x, int y )
{
- if ( !activeView().IsNull() )
+ if ( !activeView().IsNull() ) {
activeView()->Place( x, y, myScale );
+ emit vpTransformed( this );
+ }
}
/*!
*/
void OCCViewer_ViewPort3d::pan( int dx, int dy )
{
- if ( !activeView().IsNull() )
+ if ( !activeView().IsNull() ) {
activeView()->Pan( dx, dy, 1.0 );
+ emit vpTransformed( this );
+ }
}
/*!
default:
break;
}
+ emit vpTransformed( this );
}
// setZSize( getZSize() );
}
activeView()->ZFitAll(1.);
activeView()->SetZSize(0.);
activeView()->Update();
+ emit vpTransformed( this );
}
}
Standard_Real margin = 0.01;
activeView()->FitAll( margin, withZ, upd );
activeView()->SetZSize(0.);
+ emit vpTransformed( this );
}
/*!
void OCCViewer_ViewPort3d::reset()
{
// double zsize = getZSize();
- if ( !activeView().IsNull() )
+ if ( !activeView().IsNull() ) {
activeView()->Reset();
+ emit vpTransformed( this );
// setZSize( zsize );
+ }
}
/*!
double X, Y, Z;
activeView()->Convert( x, y, X, Y, Z );
activeView()->Rotate( 0, 0, degrees * Standard_PI180, X, Y, Z );
+ emit vpTransformed( this );
}
/*!
{
return ( !view.IsNull() && view->View()->IsDefined() );
}
+
+/*!
+ Performs synchronization of view parameters with the specified view.
+ Returns \c true if synchronization is done successfully or \c false otherwise.
+ Default implementation does nothing (return \c false)
+*/
+bool OCCViewer_ViewPort3d::synchronize( OCCViewer_ViewPort* view )
+{
+ bool ok = false;
+ OCCViewer_ViewPort3d* vp3d = qobject_cast<OCCViewer_ViewPort3d*>( view );
+ if ( vp3d ) ok = syncronize( vp3d );
+ return ok;
+}
+
tr( "MNU_SYNCHRONIZE_VIEW" ), 0, this );
aAction->setStatusTip(tr("DSC_SYNCHRONIZE_VIEW"));
aAction->setMenu( new QMenu( this ) );
+ aAction->setCheckable(true);
connect(aAction->menu(), SIGNAL(aboutToShow()), this, SLOT(updateSyncViews()));
- connect(aAction, SIGNAL(triggered()), this, SLOT(onSynchronizeView()));
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSynchronizeView(bool)));
toolMgr()->registerAction( aAction, SynchronizeId );
}
myViewAspects = aViewList;
}
+void OCCViewer_ViewWindow::synchronizeView( OCCViewer_ViewWindow* viewWindow, int id )
+{
+ OCCViewer_ViewWindow* otherViewWindow = 0;
+ QList<OCCViewer_ViewWindow*> compatibleViews;
+
+ bool isSync = viewWindow->toolMgr()->action( SynchronizeId )->isChecked();
+
+ int vwid = viewWindow->getId();
+
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( !app ) return;
+
+ QList<SUIT_ViewManager*> wmlist;
+ app->viewManagers( viewWindow->getViewManager()->getType(), wmlist );
+
+ foreach( SUIT_ViewManager* wm, wmlist ) {
+ QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
+
+ foreach( SUIT_ViewWindow* vw, vwlist ) {
+ OCCViewer_ViewWindow* occVW = dynamic_cast<OCCViewer_ViewWindow*>( vw );
+ if ( !occVW ) continue;
+
+ // check only compatible types
+ occVW = occVW->getView( viewWindow->get2dMode() );
+ if ( occVW ) {
+ if ( occVW->getId() == id )
+ otherViewWindow = occVW;
+ else if ( occVW != viewWindow )
+ compatibleViews.append( occVW );
+ }
+ }
+ }
+
+ if ( isSync && id ) {
+ // remove all possible disconnections
+ foreach( OCCViewer_ViewWindow* vw, compatibleViews ) {
+ // disconnect target view
+ vw->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), vw->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ if ( otherViewWindow ) {
+ // disconnect source view
+ vw->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), vw->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ }
+ QAction* a = vw->toolMgr()->action( SynchronizeId );
+ if ( a ) {
+ int anid = a->data().toInt();
+ if ( a->isChecked() && ( anid == id || anid == vwid ) ) {
+ bool blocked = a->blockSignals( true );
+ a->setChecked( false );
+ a->blockSignals( blocked );
+ }
+ }
+ }
+ if ( otherViewWindow ) {
+ // reconnect source and target view
+ otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ otherViewWindow->getViewPort()->connect( viewWindow->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->connect( otherViewWindow->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ // synchronize target view with source view
+ viewWindow->getViewPort()->synchronize( otherViewWindow->getViewPort() );
+ viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setData( viewWindow->getId() );
+ if ( !otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
+ bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
+ }
+ }
+ }
+ else if ( otherViewWindow ) {
+ // reconnect source and target view
+ otherViewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), viewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->disconnect( SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ), otherViewWindow->getViewPort(), SLOT( synchronize( OCCViewer_ViewPort* ) ) );
+ viewWindow->getViewPort()->synchronize( otherViewWindow->getViewPort() );
+ viewWindow->toolMgr()->action( SynchronizeId )->setData( otherViewWindow->getId() );
+ if ( otherViewWindow->toolMgr()->action( SynchronizeId )->data().toInt() == viewWindow->getId() && otherViewWindow->toolMgr()->action( SynchronizeId )->isChecked() ) {
+ bool blocked = otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( true );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->setChecked( false );
+ otherViewWindow->toolMgr()->action( SynchronizeId )->blockSignals( blocked );
+ }
+ }
+}
+
/*!
"Synchronize View" action slot.
*/
-void OCCViewer_ViewWindow::onSynchronizeView()
+void OCCViewer_ViewWindow::onSynchronizeView(bool checked)
{
QAction* a = qobject_cast<QAction*>( sender() );
if ( a ) {
- int id = a->data().toInt();
- if ( id != 0 ) {
- SUIT_Application* app = SUIT_Session::session()->activeApplication();
- if ( !app ) return;
- QList<SUIT_ViewManager*> wmlist;
- app->viewManagers( getViewManager()->getType(), wmlist );
- foreach( SUIT_ViewManager* wm, wmlist ) {
- QVector<SUIT_ViewWindow*> vwlist = wm->getViews();
- foreach ( SUIT_ViewWindow* vw, vwlist ) {
- OCCViewer_ViewWindow* occVW = dynamic_cast<OCCViewer_ViewWindow*>( vw );
- if ( !occVW ) continue;
- // list only compatible types
- OCCViewer_ViewWindow* subWindow = occVW->getView( get2dMode() );
- if ( subWindow && subWindow->getId() == id && subWindow != this ) {
- // perform synchronization
- performRestoring( subWindow->getViewParams(), true );
- }
- }
- }
-
- if ( a != toolMgr()->action( SynchronizeId ) )
- toolMgr()->action( SynchronizeId )->setData( id );
- }
+ synchronizeView( this, a->data().toInt() );
}
}
{
QAction* anAction = toolMgr()->action( SynchronizeId );
if ( anAction && anAction->menu() ) {
+ int currentId = anAction->data().toInt();
anAction->menu()->clear();
SUIT_Application* app = SUIT_Session::session()->activeApplication();
if ( app ) {
OCCViewer_ViewWindow* subWindow = occVW->getView( get2dMode() );
if ( subWindow && subWindow != this ) {
QAction* a = anAction->menu()->addAction( occVW->windowTitle() );
+ if ( subWindow->getId() == currentId ) {
+ QFont f = a->font();
+ f.setBold( true );
+ a->setFont( f );
+ }
a->setData( subWindow->getId() );
- connect( a, SIGNAL( triggered() ), this, SLOT( onSynchronizeView() ) );
+ connect( a, SIGNAL( triggered(bool) ), this, SLOT( onSynchronizeView(bool) ) );
}
}
}
}
if ( anAction->menu()->actions().isEmpty() ) {
+ anAction->setData( 0 );
anAction->menu()->addAction( tr( "MNU_SYNC_NO_VIEW" ) );
}
}