Salome HOME
Copyright update 2022
[modules/gui.git] / src / GraphicsView / GraphicsView_Object.cxx
index 52447dcb53f372a8a4f9569840d436dd4229d2e1..9c45d6d3b99457a9c07ea8c296d6d7e7f5f3b08a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2013-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -32,7 +32,8 @@ GraphicsView_Object::GraphicsView_Object( QGraphicsItem* theParent )
   myIsOnTop( false ),
   myIsHighlighted( false ),
   myIsSelected( false ),
-  myIsMoving( false )
+  myIsMoving( false ),
+  myIsMovable( true )
 {
 }
 
@@ -42,7 +43,7 @@ GraphicsView_Object::GraphicsView_Object( QGraphicsItem* theParent )
 //=======================================================================
 GraphicsView_Object::~GraphicsView_Object()
 {
-  QListIterator<QGraphicsItem*> aChildIter( children() );
+  QListIterator<QGraphicsItem*> aChildIter( childItems() );
   while( aChildIter.hasNext() )
   {
     if( QGraphicsItem* aChild = aChildIter.next() )
@@ -98,7 +99,7 @@ QRectF GraphicsView_Object::getRect() const
 // Function : checkHighlight
 // Purpose  : 
 //================================================================
-bool GraphicsView_Object::checkHighlight( double theX, double theY, QCursor& theCursor ) const
+bool GraphicsView_Object::checkHighlight( double theX, double theY, QCursor& /*theCursor*/ ) const
 {
   return !getRect().isNull() && getRect().contains( theX, theY );
 }
@@ -110,7 +111,7 @@ bool GraphicsView_Object::checkHighlight( double theX, double theY, QCursor& the
 bool GraphicsView_Object::highlight( double theX, double theY )
 {
   QCursor aCursor;
-  if( myIsHighlighted = isVisible() )
+  if( (myIsHighlighted = isVisible()) )
     myIsHighlighted = checkHighlight( theX, theY, aCursor );
   return myIsHighlighted;
 }
@@ -131,7 +132,7 @@ void GraphicsView_Object::unhighlight()
 bool GraphicsView_Object::select( double theX, double theY, const QRectF& theRect )
 {
   QCursor aCursor;
-  if( myIsSelected = isVisible() )
+  if( (myIsSelected = isVisible()) )
   {
     if( !theRect.isNull() )
       myIsSelected = theRect.contains( getRect() );
@@ -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 );