Salome HOME
updated copyright message
[modules/gui.git] / src / GraphicsView / GraphicsView_ViewPort.cxx
index aa60c1f63dcefaabf280d8b692c3c681b285a953..2d0cbc40c56871d6854f3ff3a1d947d0d391cade 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2013-2023  CEA, EDF, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -285,7 +285,7 @@ void GraphicsView_ViewPort::addItem( QGraphicsItem* theItem )
 //================================================================
 bool GraphicsView_ViewPort::isItemAdded( QGraphicsItem* theItem )
 {
-  if( GraphicsView_Object* anObject = dynamic_cast<GraphicsView_Object*>( theItem ) )
+  if( dynamic_cast<GraphicsView_Object*>( theItem ) )
   {
     for( GraphicsView_ObjectList::iterator anIter = myObjects.begin(); anIter != myObjects.end(); anIter++ )
       if( theItem == *anIter )
@@ -480,7 +480,7 @@ bool GraphicsView_ViewPort::dumpViewToFormat(const QString& fileName, const QStr
     return false;
 
   QPrinter printer(QPrinter::ScreenResolution);
-  printer.setOutputFormat(QPrinter::PostScriptFormat);
+  printer.setOutputFormat(QPrinter::PdfFormat);
   printer.setOutputFileName(fileName);
   QPainter painter;  
   if (!painter.begin(&printer))
@@ -915,6 +915,11 @@ void GraphicsView_ViewPort::zoom( double theX1, double theY1, double theX2, doub
   aTransform.scale( aZoom, aZoom );
   double aM11 = aTransform.m11();
   double aM22 = aTransform.m22();
+
+
+  QGraphicsView::ViewportAnchor old_anchor = transformationAnchor();
+  setTransformationAnchor( QGraphicsView::AnchorUnderMouse );
+
   // increasing of diagonal coefficients (>300) leads to a crash sometimes
   // at the values of 100 some primitives are drawn incorrectly
   if( myZoomCoeff < 0 || qMax( aM11, aM22 ) < myZoomCoeff )
@@ -923,6 +928,8 @@ void GraphicsView_ViewPort::zoom( double theX1, double theY1, double theX2, doub
   myIsTransforming = false;
 
   applyTransform();
+
+  setTransformationAnchor( old_anchor );
 }
 
 //================================================================
@@ -1046,6 +1053,9 @@ void GraphicsView_ViewPort::setZoomCoeff( const int& theZoomCoeff )
 //================================================================
 void GraphicsView_ViewPort::setUnlimitedPanning( const bool& theValue )
 {
+  if ( myUnlimitedPanning == theValue )
+    return;
+
   myUnlimitedPanning = theValue;
 
   if( myUnlimitedPanning )
@@ -1094,7 +1104,6 @@ void GraphicsView_ViewPort::highlight( double theX, double theY )
   bool anIsHighlighted = false;
   bool anIsOnObject = false;
 
-  GraphicsView_Object* aPreviousHighlightedObject = myHighlightedObject;
   GraphicsView_Object* aHighlightedObject = 0;
 
   QCursor aCursor;
@@ -1245,7 +1254,6 @@ int GraphicsView_ViewPort::select( const QRectF& theRect, bool theIsAppend )
   {
     aStatus = GVSS_NoChanged;
 
-    bool updateAll = false;
     if( !theIsAppend )
     {
       if( !mySelectedObjects.isEmpty() )
@@ -1595,8 +1603,8 @@ void GraphicsView_ViewPort::dragObjects( QGraphicsSceneMouseEvent* e )
     else
       anObjectsToMove.append( anObject );
   }
-  else if( ( hasInteractionFlag( DraggingByMiddleButton ) && ( e->buttons() & Qt::MidButton ) ||
-             isDraggingSelectedByLeftButton() && ( e->buttons() & Qt::LeftButton ) ) &&
+  else if( ( ( hasInteractionFlag( DraggingByMiddleButton ) && ( e->buttons() & Qt::MidButton ) ) ||
+             ( isDraggingSelectedByLeftButton() && ( e->buttons() & Qt::LeftButton ) ) ) &&
            nbSelected() )
   {
     for( initSelected(); moreSelected(); nextSelected() )
@@ -1792,8 +1800,8 @@ void GraphicsView_ViewPort::onMouseEvent( QGraphicsSceneMouseEvent* e )
         if( ( getHighlightedObject() &&
               getHighlightedObject()->isMovable() &&
               !( anAccel || e->button() != Qt::LeftButton ) ) ||
-            ( ( hasInteractionFlag( DraggingByMiddleButton ) && e->button() == Qt::MidButton ||
-                isDraggingSelectedByLeftButton() && e->button() == Qt::LeftButton ) &&
+            ( ( ( hasInteractionFlag( DraggingByMiddleButton ) && e->button() == Qt::MidButton ) ||
+                ( isDraggingSelectedByLeftButton() && e->button() == Qt::LeftButton ) ) &&
               nbSelected() && !anAccel ) )
         {
           myIsDragging = true;