Salome HOME
size of image is limited by 7000 pixels
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Overview.cxx
index 8b53cfeb87a713e091175a169c44ec2f3c14e11d..f7185a2fa587e21e7bfc29fc0612b1cf77eef8aa 100644 (file)
@@ -190,11 +190,41 @@ void HYDROGUI_OverviewBand::update( bool isFromMain )
     QPoint c = center();
     double x1, y1, z1, x2, y2, z2;
     main->getView()->Convert( main->width()/2, main->height()/2, x1, y1, z1 );
+
+    // Patch for OCCT 6.9.1, on 7.0.0 the moving of point to plane XY is not necessary
+    gp_Dir dm = main->getView()->Camera()->Direction();
+    double t1 = -z1/dm.Z();
+    x1 += dm.X()*t1;
+    y1 += dm.Y()*t1;
+    z1 += dm.Z()*t1;
+
     overview->getView()->Convert( c.x(), c.y(), x2, y2, z2 );
+    gp_Dir dov = overview->getView()->Camera()->Direction();
+    double t2 = -z2/dov.Z();
+    x2 += dov.X()*t2;
+    y2 += dov.Y()*t2;
+    z2 += dov.Z()*t2;
 
     gp_Trsf aTrsf;
     aTrsf.SetTranslation( gp_Pnt( x1, y1, z1 ), gp_Pnt( x2, y2, z2 ) );
-    main->getView()->Camera()->Transform( aTrsf );
+
+    // Temporary patch for bug in OCCT 6.9.1
+    Handle(Graphic3d_Camera) cam = main->getView()->Camera();
+    gp_Dir u = cam->Up(), nu = u.Transformed (aTrsf);
+    gp_Pnt e = cam->Eye(), ne = e.Transformed (aTrsf);
+    gp_Pnt cen = cam->Center(), ncen = cen.Transformed (aTrsf);
+
+    if (!nu.IsEqual (u, 0.0))
+      cam->SetUp(nu);
+
+    if (!ne.IsEqual (e, 0.0))
+      cam->SetEye(ne);
+
+    if (!ncen.IsEqual(cen, 0.0))
+      cam->SetCenter (ncen);
+
+    //version for new OCCT:
+    //main->getView()->Camera()->Transform( aTrsf );
     main->repaint();
   }
 }
@@ -276,7 +306,7 @@ void HYDROGUI_Overview::setMainView( OCCViewer_ViewFrame* theMainView )
 
   OCCViewer_ViewWindow* aMainView = myMainView->getView( OCCViewer_ViewFrame::MAIN_VIEW );
   connect( aMainView, SIGNAL( vpTransformationFinished( OCCViewer_ViewWindow::OperationType ) ),
-           this,      SLOT( OnTransformation() ) );
+           this,      SLOT( OnTransformationAfterOp( OCCViewer_ViewWindow::OperationType ) ) );
   connect( aMainView->getViewPort(), SIGNAL( vpResizeEvent( QResizeEvent* ) ),
            this,       SLOT( OnResizeEvent( QResizeEvent* ) ) );
   connect( aMainView->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ),
@@ -285,7 +315,7 @@ void HYDROGUI_Overview::setMainView( OCCViewer_ViewFrame* theMainView )
   if( !myViewPort )
   {
     myViewPort = new OCCViewer_ViewPort3d( this, myMainView->getViewPort()->getViewer(), V3d_ORTHOGRAPHIC );
-    //myViewPort->setBackgroundColor( Qt::white );
+    myViewPort->setBackgroundColor( myMainView->getViewPort()->backgroundColor() );
 
     connect( myViewPort, SIGNAL( vpMouseEvent( QMouseEvent* ) ), 
             this,       SLOT( OnMouseEvent( QMouseEvent* ) ) );
@@ -329,6 +359,15 @@ void HYDROGUI_Overview::setTopView()
     myBand->update( true );
 }
 
+void HYDROGUI_Overview::OnTransformationAfterOp( OCCViewer_ViewWindow::OperationType theOp )
+{
+  if( theOp>=OCCViewer_ViewWindow::WINDOWFIT )
+  {
+    myViewPort->fitAll();
+  }
+  OnTransformation();
+}
+
 void HYDROGUI_Overview::OnTransformation()
 {
   if( myBand )