Salome HOME
0022379: EDF 2276 GEOM: Show the ascendants and descendants of a GEOM object in a...
authormpa <mpa@opencascade.com>
Thu, 15 May 2014 11:28:50 +0000 (15:28 +0400)
committermpa <mpa@opencascade.com>
Thu, 15 May 2014 11:28:50 +0000 (15:28 +0400)
src/GraphicsView/GraphicsView_Object.cxx
src/GraphicsView/GraphicsView_Object.h
src/GraphicsView/GraphicsView_ViewFrame.cxx
src/GraphicsView/GraphicsView_ViewFrame.h
src/GraphicsView/GraphicsView_ViewPort.cxx
src/GraphicsView/GraphicsView_ViewPort.h
src/GraphicsView/GraphicsView_Viewer.cxx
src/GraphicsView/GraphicsView_Viewer.h
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h

index 52447dcb53f372a8a4f9569840d436dd4229d2e1..3456d42403b6ca500feb6295f826cc8cebe000e3 100644 (file)
@@ -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 );
index 2ead5a27b0cf5bc7b219e7e5d447222d78fe5a42..09cd76af2371c28a8ed0195c6639db467c2e0d83 100644 (file)
@@ -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;
 };
index 9e84bb2276a023685095fda8594f8e884fc8c0e8..6f5f47dcf4a301dc0fdd20416bffa23bc919d60e 100644 (file)
@@ -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<GraphicsView_ViewPort*>(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  : 
index 1335e93df9f8cf97d8e96de5b66ed9323851e861..088bdffc4a29abeb0ba8e57c3eb5438665a19768 100644 (file)
@@ -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();
index 033bef87cef7db714101da317ab3e3d24d86e73f..9f79d180aafc60147456effcdc53e72fa0fd3cf8 100644 (file)
@@ -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<GraphicsView_Object*>( 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  : 
index 2a011d1692fd2ddc139db38005f6083e5ee2340e..518598dd4f2f8b7ea117003d9818c85887257076 100644 (file)
@@ -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 };
index 0573ebb5e9c8b5b6a05676cc4feb543372a50cfa..5fb5eb0825e37e0fc6e9effec082b8115bac35d8 100644 (file)
 // 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* ) ) );
index 9c864b8dfe1c9d6514b9a95f75a6289196dc4bb0..8b69d464cb87e00bab9975e87fefeb6e323490eb 100644 (file)
@@ -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;
 };
index 2640effb99ec3c32e32fc75c8a33035a1a0491ee..0e2d4108cbdca48586e86ac10ed4123390c6485c 100644 (file)
@@ -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
 */
index 93b325c8a7e60d20989efbe6fedf476b371128bb..59837134589b750e26fab198d2cb2e99ed056466 100644 (file)
@@ -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;