]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Cleaning
authorCHEMIN Sebastien <sc236498@is245491.intra.cea.fr>
Fri, 1 Mar 2024 13:46:32 +0000 (14:46 +0100)
committerCHEMIN Sebastien <sc236498@is245491.intra.cea.fr>
Fri, 1 Mar 2024 13:46:32 +0000 (14:46 +0100)
src/GraphicsView/GraphicsView_ViewPort.cxx
src/GraphicsView/GraphicsView_ViewPort.h
src/GraphicsView/GraphicsView_ViewTransformer.cxx

index 93f46d7b6f60624d83c45ba55a36819918223721..7876bd42e2a1e07e67319a96acafc1bfb791346c 100644 (file)
@@ -68,12 +68,6 @@ void GraphicsView_ViewPort::fitAll()
 
 void GraphicsView_ViewPort::updateSceneRect(const QRectF &rect)
 {
-//  double aGap = myFitAllGap;
-//  QRectF aRect = rect;
-//  aRect.adjusted(-aGap, -aGap, aGap, aGap);
- // std::cout << "Update Scene Rect" << std::endl;
-//  scene()->setSceneRect(aRect);
-//  QGraphicsView::updateSceneRect(rect);
 }
 
 void GraphicsView_ViewPort::fitSelect() 
@@ -86,43 +80,7 @@ void GraphicsView_ViewPort::fitSelect()
     selectionRect = selectionRect.united(item->sceneBoundingRect());
 
   if(!selectionRect.isNull())
-    fitInView(selectionRect, Qt::KeepAspectRatio);
-/*
-  QRectF visibleSceneRect = mapToScene(viewport()->rect()).boundingRect();
-
-  double vw = visibleSceneRect.width(); 
-  double vh = visibleSceneRect.height(); 
-
-  double sw = selectionRect.width(); 
-  double sh = selectionRect.height(); 
-
-  double vx = visibleSceneRect.center().x(); 
-  double vy = visibleSceneRect.center().y(); 
-
-  double sx = selectionRect.center().x(); 
-  double sy = selectionRect.center().y(); 
-
-  double dx = vx-sx;
-  double dy = sy-vy;
-
-  std::cout << dx << " " << dy << std::endl;
-
-  QGraphicsRectItem *sceneRectItem = new QGraphicsRectItem(selectionRect);
-  sceneRectItem->setPen(QPen(QColor("blue"),4));
-  addItem(sceneRectItem);
-
-
-  selectionRect.translate(dx,0.);
-  
-  fitInView(selectionRect, Qt::KeepAspectRatio);
-
-  QGraphicsRectItem *sceneRectItem = new QGraphicsRectItem(selectionRect);
-  sceneRectItem->setPen(QPen(QColor("green"),4));
-  addItem(sceneRectItem);
-*/
-//  std::cout << "visibleSceneRect : " << visibleSceneRect.width() << " x " << visibleSceneRect.height() << std::endl; 
-//  std::cout << "selectionRect    : " << selectionRect.width() << " x " << selectionRect.height() << std::endl; 
+    fitInView(selectionRect.adjusted(-myFitAllGap, -myFitAllGap, myFitAllGap, myFitAllGap), Qt::KeepAspectRatio); 
 }
 
 void GraphicsView_ViewPort::fitRect(const QRectF& theRect)
@@ -156,7 +114,6 @@ void GraphicsView_ViewPort::finishSelectByRect()
   QRectF selectionRect = mapToScene(myRectBand->geometry()).boundingRect();
 //  fitInView(selectionRect, Qt::KeepAspectRatio);
 
-
   QList<QGraphicsItem *> selectedItems = scene()->items(selectionRect, Qt::IntersectsItemShape);
   for (QGraphicsItem *item : selectedItems) 
     item->setSelected(true);
@@ -192,62 +149,4 @@ void GraphicsView_ViewPort::mouseReleaseEvent(QMouseEvent *event)
 void GraphicsView_ViewPort::resizeEvent(QResizeEvent *event)
 {
    QGraphicsView::resizeEvent(event);
-
-/*
-    // Get the current visible scene rectangle
-    QRectF visibleSceneRect = mapToScene(viewport()->rect()).boundingRect();
-
-    // Calculate the scaling factors for both width and height
-    qreal widthScaleFactor = event->size().width() / event->oldSize().width();
-    qreal heightScaleFactor = event->size().height() / event->oldSize().height();
-
-    // Apply the scaling factors to the visible scene rectangle
-    visibleSceneRect.setWidth(visibleSceneRect.width() * widthScaleFactor);
-    visibleSceneRect.setHeight(visibleSceneRect.height() * heightScaleFactor);
-
-    // Map the adjusted visible scene rectangle back to viewport coordinates
-    QRectF viewportRect = mapFromScene(visibleSceneRect).boundingRect();
-
-    // Ensure that the viewport rectangle stays within the scene boundaries
-
-    if (viewportRect.width() > sceneRect().width()) {
-        viewportRect.setWidth(sceneRect().width());
-    }
-    if (viewportRect.height() > sceneRect().height()) {
-        viewportRect.setHeight(sceneRect().height());
-    }
-
-    // Update the viewport
-    fitInView(, Qt::KeepAspectRatio);
-*/
-}
-void GraphicsView_ViewPort::fitWidth()
-{
-  double aGap = myFitAllGap;
-
-  QRectF aRect;
-  foreach (QGraphicsItem *item, scene()->selectedItems()) 
-    aRect = aRect.united(item->sceneBoundingRect());
-
-  QRectF aRect1 = aRect;
-
-  double aTop = aRect1.top();
-  double aLeft = aRect1.left();
-  double w = aRect1.width();
-  double h = aRect1.height();
-
-  double aMargin = 10;
-
-  aRect.setY( aRect.center().y() );
-  aRect.setX( aRect.center().x() );
-  aRect.setHeight( aMargin );
-  aRect.setWidth( aMargin );
-
-
-  addItem(new QGraphicsRectItem(aRect));
-
-  fitInView( aRect.adjusted( -aGap, -aGap, aGap, aGap ), Qt::KeepAspectRatio );
-  ensureVisible( aLeft, aTop, aMargin, aMargin, 0, aGap );
-//  ensureVisible(aRect1);
-
 }
index 4929f4fada77c61d5043f7a78b07742950679aeb..977e81b44e1f074814b1ba3b240472d99a2af062 100644 (file)
@@ -47,7 +47,6 @@ public:
   void fitAll();
   void fitSelect();
   void fitRect(const QRectF& theRect);
-  void fitWidth();
 
   // rectangle selection
   void startSelectByRect( int x, int y );
index 4a4746e2398f04f732792130a752580957b1ac74..ac3ef73d8d72ae93048c0f2ec6c9f4d8559faf45 100644 (file)
@@ -140,12 +140,7 @@ void GraphicsView_ViewTransformer::exec()
       aViewPort->fitSelect();
       onTransform( Finished );
       break;
-/*
-    case GraphicsView_Viewer::FitWidth:
-      aViewPort->fitWidth();
-      onTransform( Finished );
-      break;
-*/
+
     default: break;
   }