]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PRECOS issue 0000966: External: Topology preview is too small
authorouv <ouv@opencascade.com>
Tue, 6 Mar 2012 11:19:42 +0000 (11:19 +0000)
committerouv <ouv@opencascade.com>
Tue, 6 Mar 2012 11:19:42 +0000 (11:19 +0000)
src/GraphicsView/GraphicsView_ViewPort.cxx
src/GraphicsView/GraphicsView_ViewPort.h
src/GraphicsView/GraphicsView_ViewTransformer.cxx
src/GraphicsView/GraphicsView_Viewer.h

index ac08bd0e16374d04afbf087822d602d616124e65..be6e03b849adb1c4d1e23783ff920aa807f96611 100644 (file)
@@ -829,6 +829,30 @@ void GraphicsView_ViewPort::fitAll( bool theKeepScale )
   myIsTransforming = false;
 }
 
+//================================================================
+// Function : fitWidth
+// Purpose  : 
+//================================================================
+void GraphicsView_ViewPort::fitWidth()
+{
+  myIsTransforming = true;
+
+  double aGap = myFitAllGap;
+  QRectF aRect = objectsBoundingRect( true );
+
+  double aTop = aRect.top();
+  double aLeft = aRect.left();
+  double aMargin = 10;
+
+  aRect.setY( aRect.center().y() );
+  aRect.setHeight( aMargin );
+
+  fitInView( aRect.adjusted( -aGap, -aGap, aGap, aGap ), Qt::KeepAspectRatio );
+  ensureVisible( aLeft, aTop, aMargin, aMargin, 0, aGap );
+
+  myIsTransforming = false;
+}
+
 //================================================================
 // Function : currentBlock
 // Purpose  : 
index c94154bf1568b143339d310efb094e8377a35afd..93b606d8af64759d1990d1681a2b09720639ad25 100644 (file)
@@ -144,6 +144,7 @@ public:
   void                             fitRect( const QRectF& theRect );
   void                             fitSelect();
   void                             fitAll( bool theKeepScale = false );
+  void                             fitWidth();
 
   bool                             isTransforming() const { return myIsTransforming; }
 
index 0f86a85fa6e52259f1f0471bacbcec767f5e5d74..06e794a2f6b6c7b90d49573abfca9febfdf70875 100644 (file)
@@ -138,6 +138,10 @@ void GraphicsView_ViewTransformer::exec()
       aViewPort->fitSelect();
       onTransform( Finished );
       break;
+    case GraphicsView_Viewer::FitWidth:
+      aViewPort->fitWidth();
+      onTransform( Finished );
+      break;
     default: break;
   }
 }
index 1008820000df671c0ef720958f6b638dec3c093c..477d40c501f987c32dcdfe0d3a367ff7f5250f65 100644 (file)
@@ -51,7 +51,7 @@ class GRAPHICSVIEW_API GraphicsView_Viewer: public SUIT_ViewModel
 
 public:
   enum TransformType { NoTransform, Reset, FitAll, FitRect, FitSelect,
-                       Zoom, PanGlobal, Pan, UserTransform = 100 };
+                       Zoom, PanGlobal, Pan, FitWidth, UserTransform = 100 };
 public:
   GraphicsView_Viewer( const QString& title );
   ~GraphicsView_Viewer();