Salome HOME
Merge branch 'BR_H2018_3' into BR_2018_V8_5
[modules/hydro.git] / src / HYDRO_tests / test_HYDROGUI_BathymetryPrs.cxx
index 47f4cec2cd5ae06bf9ce9b46f54a024eb99f3fc7..4eec4f63173378f981a88b2a0eba9f1427932e45 100644 (file)
@@ -21,6 +21,7 @@
 #include <TestViewer.h>
 #include <AIS_ColorScale.hxx>
 #include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewFrame.h>
 #include <OCCViewer_ViewPort3d.h>
 #include <QTest>
 
@@ -42,7 +43,7 @@ void test_HYDROGUI_BathymetryPrs::createBathPrs()
 {
   myBathPrs = new HYDROGUI_ShapeBathymetry( 0, TestViewer::context(), myBath );
   myBathPrs->Build();
-  myBathPrs->getAISObject()->SetAutoHilight( Standard_False );
+  myBathPrs->getAISObjects()[0]->SetAutoHilight( Standard_False );
 
   double min, max;
   myBathPrs->GetRange( min, max );
@@ -59,10 +60,9 @@ void test_HYDROGUI_BathymetryPrs::updateColors()
   myBathPrs->UpdateWithColorScale( TestViewer::colorScale() );
 }
 
-
 void test_HYDROGUI_BathymetryPrs::test_presentation()
 {
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
   
   importTestBath( aDoc );
@@ -71,7 +71,7 @@ void test_HYDROGUI_BathymetryPrs::test_presentation()
   createBathPrs();
   updateColors();
 
-  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObject();
+  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObjects()[0];
   CPPUNIT_ASSERT( !bprs.IsNull() );
 
   TestViewer::show( bprs, 0, 0, true, "bathy_prs" );
@@ -79,7 +79,7 @@ void test_HYDROGUI_BathymetryPrs::test_presentation()
   //QTest::qWait( 50000 );
 
   aDoc->Close();
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
 }
 
 void select( int x1, int y1, int x2, int y2 )
@@ -94,7 +94,7 @@ void select( int x1, int y1, int x2, int y2 )
 
 void test_HYDROGUI_BathymetryPrs::test_selection()
 {
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 
   importTestBath( aDoc );
@@ -103,7 +103,7 @@ void test_HYDROGUI_BathymetryPrs::test_selection()
   createBathPrs();
   updateColors();
 
-  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObject();
+  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObjects()[0];
   CPPUNIT_ASSERT( !bprs.IsNull() );
 
   TestViewer::show( bprs, 0, 1, true, "bathy_prs" );
@@ -120,12 +120,12 @@ void test_HYDROGUI_BathymetryPrs::test_selection()
   //QTest::qWait( 50000 );
 
   aDoc->Close();
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
 }
 
 void test_HYDROGUI_BathymetryPrs::test_rescale_by_selection()
 {
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 
   importTestBath( aDoc );
@@ -134,7 +134,7 @@ void test_HYDROGUI_BathymetryPrs::test_rescale_by_selection()
   createBathPrs();
   updateColors();
 
-  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObject();
+  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObjects()[0];
   CPPUNIT_ASSERT( !bprs.IsNull() );
 
   TestViewer::show( bprs, 0, 1, true, "bathy_prs" );
@@ -179,12 +179,12 @@ void test_HYDROGUI_BathymetryPrs::test_rescale_by_selection()
   //QTest::qWait( 50000 );
 
   aDoc->Close();
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
 }
 
 void test_HYDROGUI_BathymetryPrs::test_rescale_by_visible()
 {
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 
   importTestBath( aDoc );
@@ -193,7 +193,7 @@ void test_HYDROGUI_BathymetryPrs::test_rescale_by_visible()
   createBathPrs();
   updateColors();
 
-  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObject();
+  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObjects()[0];
   CPPUNIT_ASSERT( !bprs.IsNull() );
 
   TestViewer::show( bprs, 0, 1, true, "bathy_prs" );
@@ -226,12 +226,12 @@ void test_HYDROGUI_BathymetryPrs::test_rescale_by_visible()
 
   //QTest::qWait( 50000 );
   aDoc->Close();
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
 }
 
 void test_HYDROGUI_BathymetryPrs::test_text_presentation()
 {
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 
   importTestBath( aDoc );
@@ -240,7 +240,7 @@ void test_HYDROGUI_BathymetryPrs::test_text_presentation()
   createBathPrs();
   updateColors();
 
-  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObject();
+  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObjects()[0];
   CPPUNIT_ASSERT( !bprs.IsNull() );
 
   TestViewer::show( bprs, 0, 1, true, "bathy_prs" );
@@ -277,12 +277,12 @@ void test_HYDROGUI_BathymetryPrs::test_text_presentation()
   //QTest::qWait( 50000 );
 
   aDoc->Close();
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
 }
 
 void test_HYDROGUI_BathymetryPrs::test_rescale_default()
 {
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
   Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
 
   importTestBath( aDoc );
@@ -291,7 +291,7 @@ void test_HYDROGUI_BathymetryPrs::test_rescale_default()
   createBathPrs();
   updateColors();
 
-  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObject();
+  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObjects()[0];
   CPPUNIT_ASSERT( !bprs.IsNull() );
 
   TestViewer::show( bprs, 0, 1, true, "bathy_prs" );
@@ -334,5 +334,35 @@ void test_HYDROGUI_BathymetryPrs::test_rescale_default()
   //QTest::qWait( 50000 );
 
   aDoc->Close();
-  TestViewer::eraseAll( true );
+  TestViewer::eraseAll( true, true );
+}
+
+void test_HYDROGUI_BathymetryPrs::test_fit_on_selected()
+{
+  TestViewer::eraseAll( true, true );
+  Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
+
+  importTestBath( aDoc );
+  TestViewer::showColorScale( false );
+
+  createBathPrs();
+  updateColors();
+
+  Handle(AIS_InteractiveObject) bprs = myBathPrs->getAISObjects()[0];
+  CPPUNIT_ASSERT( !bprs.IsNull() );
+
+  TestViewer::show( bprs, 0, 1, true, "bathy_prs" );
+  CPPUNIT_ASSERT_IMAGES;
+
+  // Fit selected points on bathymetry
+  int x1 = 100, y1 = 50, x2 = 250, y2 = 200;
+  select( x1, y1, x2, y2 );
+  TestViewer::viewWindow()->onFitSelection();
+  TestViewer::setKey( "bathy_prs_fit_selected" );
+  CPPUNIT_ASSERT_IMAGES;
+
+  //QTest::qWait( 50000 );
+
+  aDoc->Close();
+  TestViewer::eraseAll( true, true );
 }