//=======================================================================
GraphicsView_ViewFrame::GraphicsView_ViewFrame( SUIT_Desktop* d, GraphicsView_Viewer* vw, QWidget* w )
: SUIT_ViewWindow( d ),
- myViewer( vw )
+ myViewer( vw ), myToolBarId( -1 )
{
QFrame* aFrame = new QFrame( this );
setCentralWidget( aFrame );
aLayout->addWidget( myViewPort );
- createActions();
- myToolBarId = createToolBar();
-
connect( myViewPort, SIGNAL( vpKeyEvent( QKeyEvent* ) ),
this, SLOT( keyEvent( QKeyEvent* ) ) );
connect( myViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
false ); // disable floatable toolbar
toolMgr()->append( DumpId, tid );
- myScaleAction = new QtxMultiAction( this );
- myScaleAction->insertAction( toolMgr()->action( FitAllId ) );
- myScaleAction->insertAction( toolMgr()->action( FitRectId ) );
- myScaleAction->insertAction( toolMgr()->action( FitSelectId ) );
- myScaleAction->insertAction( toolMgr()->action( ZoomId ) );
- toolMgr()->append( myScaleAction, tid );
+ QtxMultiAction* aScaleAction = new QtxMultiAction( this );
+ aScaleAction->insertAction( toolMgr()->action( FitAllId ) );
+ aScaleAction->insertAction( toolMgr()->action( FitRectId ) );
+ aScaleAction->insertAction( toolMgr()->action( FitSelectId ) );
+ aScaleAction->insertAction( toolMgr()->action( ZoomId ) );
+ toolMgr()->append( aScaleAction, tid );
+ myScaleAction = aScaleAction;
- myPanAction = new QtxMultiAction( this );
- myPanAction->insertAction( toolMgr()->action( PanId ) );
- myPanAction->insertAction( toolMgr()->action( GlobalPanId ) );
- toolMgr()->append( myPanAction, tid );
+ QtxMultiAction* aPanAction = new QtxMultiAction( this );
+ aPanAction->insertAction( toolMgr()->action( PanId ) );
+ aPanAction->insertAction( toolMgr()->action( GlobalPanId ) );
+ toolMgr()->append( aPanAction, tid );
+ myPanAction = aPanAction;
toolMgr()->append( toolMgr()->action( ResetId ), tid );
//================================================================
void GraphicsView_ViewFrame::expandToolBarActions()
{
- QList<QtxMultiAction*> anExpandableActions;
+ QList<QAction*> anExpandableActions;
anExpandableActions.append( myScaleAction );
anExpandableActions.append( myPanAction );
- QListIterator<QtxMultiAction*> anIter( anExpandableActions );
+ QListIterator<QAction*> anIter( anExpandableActions );
while( anIter.hasNext() )
{
- if( QtxMultiAction* aMultiAction = anIter.next() )
+ QtxMultiAction* aMultiAction = dynamic_cast<QtxMultiAction*>( anIter.next() );
+ if( aMultiAction )
{
QList<QAction*> aLocalActions = aMultiAction->actions();
QListIterator<QAction*> aLocalIter( aLocalActions );
*/
void GraphicsView_ViewFrame::showEvent( QShowEvent* theEvent )
{
+ if( myToolBarId < 0 )
+ {
+ createActions();
+ myToolBarId = createToolBar();
+ }
+
emit Show( theEvent );
}
class QGraphicsSceneMouseEvent;
class QGraphicsSceneWheelEvent;
-class QtxMultiAction;
+class QAction;
class SUIT_Desktop;
public:
GraphicsView_ViewFrame( SUIT_Desktop*, GraphicsView_Viewer*, QWidget* w = NULL );
- ~GraphicsView_ViewFrame();
+ virtual ~GraphicsView_ViewFrame();
GraphicsView_Viewer* getViewer() const { return myViewer; }
GraphicsView_ViewPort* getViewPort() const { return myViewPort; }
GraphicsView_ViewPort* myViewPort;
int myToolBarId;
- QtxMultiAction* myScaleAction;
- QtxMultiAction* myPanAction;
+ QAction* myScaleAction;
+ QAction* myPanAction;
};
#endif
// Purpose : Constructor
//=======================================================================
GraphicsView_ViewManager::GraphicsView_ViewManager( SUIT_Study* theStudy,
- SUIT_Desktop* theDesktop )
-: SUIT_ViewManager( theStudy, theDesktop, new GraphicsView_Viewer( "GraphicsView" ) )
+ SUIT_Desktop* theDesktop,
+ SUIT_ViewModel* theModel )
+: SUIT_ViewManager( theStudy, theDesktop,
+ theModel ? theModel : new GraphicsView_Viewer( "GraphicsView" ) )
{
setTitle( tr( "GRAPHICS_VIEW_TITLE" ) );
}
delete mySelector;
}
+GraphicsView_ViewFrame* GraphicsView_Viewer::createViewFrame( SUIT_Desktop* theDesktop, QWidget* theWidget )
+{
+ return new GraphicsView_ViewFrame( theDesktop, this, theWidget );
+}
+
//================================================================
// Function : createView
// Purpose :
//================================================================
SUIT_ViewWindow* GraphicsView_Viewer::createView( SUIT_Desktop* theDesktop )
{
- GraphicsView_ViewFrame* aViewFrame = new GraphicsView_ViewFrame( theDesktop, this, myWidget );
+ GraphicsView_ViewFrame* aViewFrame = createViewFrame( theDesktop, myWidget );
connect( aViewFrame, SIGNAL( keyPressed( QKeyEvent* ) ),
this, SLOT( onKeyEvent( QKeyEvent* ) ) );