From: asl Date: Thu, 12 Oct 2017 15:57:08 +0000 (+0300) Subject: refs #1328: debug of the overview on rotated plane X-Git-Tag: v2.1~67^2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d06c225c454bad0b15b69995bd74b559199eed36;p=modules%2Fhydro.git refs #1328: debug of the overview on rotated plane --- diff --git a/src/HYDROGUI/HYDROGUI_Overview.cxx b/src/HYDROGUI/HYDROGUI_Overview.cxx index 2077f91f..88ba1438 100644 --- a/src/HYDROGUI/HYDROGUI_Overview.cxx +++ b/src/HYDROGUI/HYDROGUI_Overview.cxx @@ -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(); } } diff --git a/src/HYDRO_tests/reference_data/overview_empty.png b/src/HYDRO_tests/reference_data/overview_empty.png index fa9022f6..49120672 100644 Binary files a/src/HYDRO_tests/reference_data/overview_empty.png and b/src/HYDRO_tests/reference_data/overview_empty.png differ diff --git a/src/HYDRO_tests/reference_data/overview_rotated_1.png b/src/HYDRO_tests/reference_data/overview_rotated_1.png index bc6b07ab..703c3602 100644 Binary files a/src/HYDRO_tests/reference_data/overview_rotated_1.png and b/src/HYDRO_tests/reference_data/overview_rotated_1.png differ diff --git a/src/HYDRO_tests/reference_data/overview_zoomed_1.png b/src/HYDRO_tests/reference_data/overview_zoomed_1.png index e8a13399..50051a2c 100644 Binary files a/src/HYDRO_tests/reference_data/overview_zoomed_1.png and b/src/HYDRO_tests/reference_data/overview_zoomed_1.png differ diff --git a/src/HYDRO_tests/test_Overview.cxx b/src/HYDRO_tests/test_Overview.cxx index 3850853d..3bba27d4 100644 --- a/src/HYDRO_tests/test_Overview.cxx +++ b/src/HYDRO_tests/test_Overview.cxx @@ -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();