]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
refs #1328: debug of the overview on rotated plane
authorasl <asl@opencascade.com>
Thu, 12 Oct 2017 15:57:08 +0000 (18:57 +0300)
committerasl <asl@opencascade.com>
Thu, 12 Oct 2017 15:57:08 +0000 (18:57 +0300)
src/HYDROGUI/HYDROGUI_Overview.cxx
src/HYDRO_tests/reference_data/overview_empty.png
src/HYDRO_tests/reference_data/overview_rotated_1.png
src/HYDRO_tests/reference_data/overview_zoomed_1.png
src/HYDRO_tests/test_Overview.cxx

index 2077f91f27d1f52f504c4fba4b20f6b63791d65f..88ba1438ab4603e76315061b57d17c9ba3d9927f 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();
   }
 }
index fa9022f66b5b823322458a5a169ab2b587c1a086..49120672f71aa3bcd788ff6aad2018776b847827 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/overview_empty.png and b/src/HYDRO_tests/reference_data/overview_empty.png differ
index bc6b07abeaf839d2667eb86be4bd6ef549270475..703c3602bd5db41a78256e33f233861bdc11f907 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/overview_rotated_1.png and b/src/HYDRO_tests/reference_data/overview_rotated_1.png differ
index e8a1339909f0b2b45adaeefbf47f4f6fc8e1584f..50051a2cd533b433c733bea8aed11f7c77927171 100644 (file)
Binary files a/src/HYDRO_tests/reference_data/overview_zoomed_1.png and b/src/HYDRO_tests/reference_data/overview_zoomed_1.png differ
index 3850853de1bc2589651be036e7b2e34e0c313afe..3bba27d48f7bf412ac3e9a7eeb03238f8625226e 100644 (file)
@@ -37,7 +37,7 @@ HYDROGUI_Overview* test_Overview::myOverview = 0;
   {                                                                      \
     QString aMessage;                                                    \
     QImage aDump = dumpViews();                                          \
-    if( !TestViewer::AssertImages( aMessage, &aDump, theCase ) )         \
+    if( !TestViewer::AssertImages( aMessage, &aDump, theCase, false ) )  \
     {                                                                    \
       TestViewer::showColorScale( false );                               \
       std::string aMessageStl = aMessage.toStdString();                  \
@@ -57,7 +57,7 @@ QImage test_Overview::dumpViews()
   QImage aMain = TestViewer::viewWindow()->getView(OCCViewer_ViewFrame::MAIN_VIEW)->dumpView();
   QImage anOverview = myOverview->dump();
 
-  aMain = aMain.rgbSwapped();            //PATCH for image came from OCCT dump
+  aMain = aMain.rgbSwapped();              //PATCH for image came from OCCT dump
   //anOverview = anOverview.rgbSwapped();  //overview dump already normalizes the image, the line is not necessary!!!
 
   int w1 = aMain.width();
@@ -96,6 +96,7 @@ void test_Overview::create()
   myOverview->show();
   myOverview->setMainView( TestViewer::viewWindow() );
   TestViewer::viewWindow()->setGeometry( 400, 100, 800, 800 );
+  TestViewer::viewWindow()->onTopView();
   myOverview->setGeometry( 100, 100, 200, 200 );
 
   isPassed = true;
@@ -138,6 +139,7 @@ void fitAllWithRestore( OCCViewer_ViewPort3d* vp )
 void test_Overview::test_default()
 {
   create();
+  //QTest::qWait( 50000 );
   CPPUNIT_ASSERT_OVERVIEW( "overview_empty" );
 }
 
@@ -155,6 +157,7 @@ void test_Overview::test_actions_in_main()
 {
   create();
   showShape();
+  TestViewer::viewWindow()->onTopView();
 
   OCCViewer_ViewWindow* aMain = TestViewer::viewWindow()->getView( OCCViewer_ViewFrame::MAIN_VIEW );
   OCCViewer_ViewPort3d* vp = aMain->getViewPort();