From: mpa Date: Thu, 15 May 2014 11:28:50 +0000 (+0400) Subject: 0022379: EDF 2276 GEOM: Show the ascendants and descendants of a GEOM object in a... X-Git-Tag: V7_5_0a1~40^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ff4799c486f298bc8d87190148b6adc52139ace0;p=modules%2Fgui.git 0022379: EDF 2276 GEOM: Show the ascendants and descendants of a GEOM object in a family tree --- diff --git a/src/GraphicsView/GraphicsView_Object.cxx b/src/GraphicsView/GraphicsView_Object.cxx index 52447dcb5..3456d4240 100644 --- a/src/GraphicsView/GraphicsView_Object.cxx +++ b/src/GraphicsView/GraphicsView_Object.cxx @@ -32,7 +32,8 @@ GraphicsView_Object::GraphicsView_Object( QGraphicsItem* theParent ) myIsOnTop( false ), myIsHighlighted( false ), myIsSelected( false ), - myIsMoving( false ) + myIsMoving( false ), + myIsMovable( true ) { } @@ -156,6 +157,9 @@ void GraphicsView_Object::unselect() //================================================================ void GraphicsView_Object::move( double theDX, double theDY, bool theIsAtOnce ) { + if( !myIsMovable ) + return; + if( theIsAtOnce ) { finishMove( true ); diff --git a/src/GraphicsView/GraphicsView_Object.h b/src/GraphicsView/GraphicsView_Object.h index 2ead5a27b..09cd76af2 100644 --- a/src/GraphicsView/GraphicsView_Object.h +++ b/src/GraphicsView/GraphicsView_Object.h @@ -54,7 +54,9 @@ public: virtual bool hasSpecificZValue() const { return false; } virtual bool isSelectable() const { return true; } - virtual bool isMovable() const { return true; } + + virtual bool isMovable() const { return myIsMovable; } + virtual bool setMovable( bool theMovable ) { myIsMovable = theMovable; } virtual QRectF getRect() const; @@ -103,6 +105,7 @@ protected: bool myIsSelected; bool myIsMoving; + bool myIsMovable; QTransform myViewTransform; }; diff --git a/src/GraphicsView/GraphicsView_ViewFrame.cxx b/src/GraphicsView/GraphicsView_ViewFrame.cxx index 9e84bb227..6f5f47dcf 100644 --- a/src/GraphicsView/GraphicsView_ViewFrame.cxx +++ b/src/GraphicsView/GraphicsView_ViewFrame.cxx @@ -47,7 +47,7 @@ // Name : GraphicsView_ViewFrame // Purpose : Constructor //======================================================================= -GraphicsView_ViewFrame::GraphicsView_ViewFrame( SUIT_Desktop* d, GraphicsView_Viewer* vw ) +GraphicsView_ViewFrame::GraphicsView_ViewFrame( SUIT_Desktop* d, GraphicsView_Viewer* vw, QWidget* w ) : SUIT_ViewWindow( d ), myViewer( vw ) { @@ -58,7 +58,11 @@ GraphicsView_ViewFrame::GraphicsView_ViewFrame( SUIT_Desktop* d, GraphicsView_Vi aLayout->setMargin( 0 ); aLayout->setSpacing( 0 ); - myViewPort = new GraphicsView_ViewPort( aFrame ); + if( w ) + myViewPort = dynamic_cast(w); + else + myViewPort = new GraphicsView_ViewPort( aFrame ); + aLayout->addWidget( myViewPort ); createActions(); @@ -187,6 +191,15 @@ int GraphicsView_ViewFrame::createToolBar() return tid; } +//================================================================ +// Function : getToolBarId +// Purpose : +//================================================================ +int GraphicsView_ViewFrame::getToolBarId() +{ + return myToolBarId; +} + //================================================================ // Function : dumpView // Purpose : diff --git a/src/GraphicsView/GraphicsView_ViewFrame.h b/src/GraphicsView/GraphicsView_ViewFrame.h index 1335e93df..088bdffc4 100644 --- a/src/GraphicsView/GraphicsView_ViewFrame.h +++ b/src/GraphicsView/GraphicsView_ViewFrame.h @@ -47,7 +47,7 @@ public: enum { DumpId, FitAllId, FitRectId, FitSelectId, ZoomId, PanId, GlobalPanId, ResetId }; public: - GraphicsView_ViewFrame( SUIT_Desktop*, GraphicsView_Viewer* ); + GraphicsView_ViewFrame( SUIT_Desktop*, GraphicsView_Viewer*, QWidget* w = NULL ); ~GraphicsView_ViewFrame(); public: @@ -60,6 +60,7 @@ public: virtual void setVisualParameters( const QString& theParameters ); void expandToolBarActions(); + int getToolBarId(); protected slots: void onViewPan(); diff --git a/src/GraphicsView/GraphicsView_ViewPort.cxx b/src/GraphicsView/GraphicsView_ViewPort.cxx index 033bef87c..9f79d180a 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.cxx +++ b/src/GraphicsView/GraphicsView_ViewPort.cxx @@ -271,6 +271,26 @@ void GraphicsView_ViewPort::addItem( QGraphicsItem* theItem ) onBoundingRectChanged(); } +//================================================================ +// Function : isItemAdded +// Purpose : +//================================================================ +bool GraphicsView_ViewPort::isItemAdded( QGraphicsItem* theItem ) +{ + if( GraphicsView_Object* anObject = dynamic_cast( theItem ) ) + { + for( GraphicsView_ObjectList::iterator anIter = myObjects.begin(); anIter != myObjects.end(); anIter++ ) + if( theItem == *anIter ) + return true; + } + else { + for( int i = 0; i < myScene->items().size(); i++ ) + if( theItem == myScene->items().at(i) ) + return true; + } + return false; +} + //================================================================ // Function : removeItem // Purpose : diff --git a/src/GraphicsView/GraphicsView_ViewPort.h b/src/GraphicsView/GraphicsView_ViewPort.h index 2a011d169..518598dd4 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.h +++ b/src/GraphicsView/GraphicsView_ViewPort.h @@ -82,6 +82,7 @@ public: public: GraphicsView_Scene* getScene() { return myScene; } void addItem( QGraphicsItem* theItem ); + bool isItemAdded( QGraphicsItem* theItem ); void removeItem( QGraphicsItem* theItem ); enum SortType { NoSorting, SelectedFirst, SortByZLevel }; diff --git a/src/GraphicsView/GraphicsView_Viewer.cxx b/src/GraphicsView/GraphicsView_Viewer.cxx index 0573ebb5e..5fb5eb082 100644 --- a/src/GraphicsView/GraphicsView_Viewer.cxx +++ b/src/GraphicsView/GraphicsView_Viewer.cxx @@ -48,10 +48,11 @@ // Name : GraphicsView_Viewer // Purpose : Constructor //======================================================================= -GraphicsView_Viewer::GraphicsView_Viewer( const QString& title ) +GraphicsView_Viewer::GraphicsView_Viewer( const QString& title, QWidget* widget ) : SUIT_ViewModel(), mySelector( 0 ), myTransformer( 0 ), + myWidget( widget ), myIsInitialized( false ) { } @@ -71,7 +72,7 @@ GraphicsView_Viewer::~GraphicsView_Viewer() //================================================================ SUIT_ViewWindow* GraphicsView_Viewer::createView( SUIT_Desktop* theDesktop ) { - GraphicsView_ViewFrame* aViewFrame = new GraphicsView_ViewFrame( theDesktop, this ); + GraphicsView_ViewFrame* aViewFrame = new GraphicsView_ViewFrame( theDesktop, this, myWidget ); connect( aViewFrame, SIGNAL( keyPressed( QKeyEvent* ) ), this, SLOT( onKeyEvent( QKeyEvent* ) ) ); diff --git a/src/GraphicsView/GraphicsView_Viewer.h b/src/GraphicsView/GraphicsView_Viewer.h index 9c864b8df..8b69d464c 100644 --- a/src/GraphicsView/GraphicsView_Viewer.h +++ b/src/GraphicsView/GraphicsView_Viewer.h @@ -52,7 +52,7 @@ public: enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect, Zoom, PanGlobal, Pan, FitWidth, UserTransform = 100 }; public: - GraphicsView_Viewer( const QString& title ); + GraphicsView_Viewer( const QString& title, QWidget* widget = NULL ); ~GraphicsView_Viewer(); public: @@ -126,6 +126,7 @@ private: protected: GraphicsView_Selector* mySelector; GraphicsView_ViewTransformer* myTransformer; + QWidget* myWidget; bool myIsInitialized; }; diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 2640effb9..0e2d4108c 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1617,6 +1617,31 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType return vm; } +SUIT_ViewManager* LightApp_Application::createViewManager( SUIT_ViewModel* theModel ) +{ + SUIT_ResourceMgr* resMgr = resourceMgr(); + + SUIT_ViewManager* vm = new SUIT_ViewManager( activeStudy(), + desktop(), + theModel ); + + QString vmType = vm->getType(); + + vm->setTitle( QString( "%1: %M - viewer %V" ).arg( vmType ) ); + + addViewManager( vm ); + SUIT_ViewWindow* vw = vm->createViewWindow(); + if ( vw && desktop() ) { + vw->resize( (int)( desktop()->width() * 0.6 ), (int)( desktop()->height() * 0.6 ) ); + vw->setDropDownButtons( resMgr->booleanValue( "viewers", "drop_down_buttons", true ) ); + } + + if ( !vmType.isEmpty() && !myUserWmTypes.contains( vmType ) ) + myUserWmTypes << vmType; + + return vm; +} + /*! SLOT: Removes view manager from application */ diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 93b325c8a..598371345 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -132,6 +132,7 @@ public: virtual void removeViewManager( SUIT_ViewManager* ); virtual SUIT_ViewManager* createViewManager( const QString& vmType ); virtual SUIT_ViewManager* createViewManager( const QString& vmType, QWidget* w ); + virtual SUIT_ViewManager* createViewManager( SUIT_ViewModel* ); QWidget* getWindow( const int, const int = -1 ); QWidget* dockWindow( const int ) const;