#endif
#include <cppunit/TestAssert.h>
+#include <QApplication>
OCCViewer_ViewManager* TestViewer::myViewManager = 0;
OCCViewer_ViewFrame* TestViewer::myViewWindow = 0;
GS->Erase();
}
}
+ viewer()->setTrihedronShown( false );
+ qApp->processEvents();
}
void TestViewer::show( const Handle(AIS_InteractiveObject)& theObject,
void test_GraphicsView::test_wheel_zoom()
{
+ TestViewer::eraseAll( true, true );
+
GraphicsView_ViewManager* aViewManager = new GraphicsView_ViewManager( 0, 0 );
GraphicsView_Viewer* aViewer = new GraphicsView_Viewer( "test", 0 );
TestObject* obj = new TestObject();
aViewPort->addItem( obj );
aViewPort->fitAll();
+ qApp->processEvents();
CPPUNIT_ASSERT_VIEW( "gv_fitall" );
// 2. Mouse wheel zoom
QWheelEvent we1( QPoint( 10, 10 ), 120*10, Qt::NoButton, Qt::NoModifier );
qApp->sendEvent( aViewPort->viewport(), &we1 );
+ qApp->processEvents();
CPPUNIT_ASSERT_VIEW( "gv_zoomed_1" );
//QTest::qWait( 50000 );
qApp->sendEvent( aViewPort->viewport(), &we2 );
CPPUNIT_ASSERT_VIEW( "gv_zoomed_2" );
+ aWindow->setVisible(false);
+ aWindow->deleteLater();
+ qApp->processEvents();
+
//QTest::qWait( 50000 );
}
CppUnit::TestFactoryRegistry::getRegistry();
// Add the top suite to the test runner
TestLib_Runner runner;
+#ifdef WIN32
QString aPath = qgetenv( "HYDRO_SRC_DIR" ) + "/src/tests.cfg";
+#else
+ QString aPath = "/tmp/hydro/tests.cfg";
+#endif
runner.Load( aPath.toStdString() );
runner.addTest( registry.makeTest() );
try
void test_HYDROData_Stream::test_dialog()
{
+ TestViewer::eraseAll( true, true );
+
HYDROGUI_StreamDlg* aDlg = new HYDROGUI_StreamDlg( 0, "stream" );
aDlg->show();
qApp->processEvents();
void test_HYDROData_Stream::test_alt_object()
{
+ TestViewer::eraseAll( true, true );
+
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
Handle(HYDROData_Stream) aStream =
void test_HYDROData_Stream::test_params_sync()
{
+ TestViewer::eraseAll( true, true );
+
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
Handle(HYDROData_Stream) aStream =
void test_HYDROData_Stream::test_dump()
{
+ TestViewer::eraseAll( true, true );
+
// Case 1. Without hydraulic axis
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
void test_HYDROData_Stream::test_presentation()
{
+ TestViewer::eraseAll( true, true );
+
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
TCollection_AsciiString fname = REF_DATA_PATH.toLatin1().data();
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 );
//QTest::qWait( 50000 );
aDoc->Close();
- TestViewer::eraseAll( true );
+ TestViewer::eraseAll( true, true );
}
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 );
//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 );
//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 );
//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 );
//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 );
//QTest::qWait( 50000 );
aDoc->Close();
- TestViewer::eraseAll( true );
+ TestViewer::eraseAll( true, true );
}
void test_HYDROGUI_BathymetryPrs::test_fit_on_selected()
{
- TestViewer::eraseAll( true );
+ TestViewer::eraseAll( true, true );
Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(1);
importTestBath( aDoc );
//QTest::qWait( 50000 );
aDoc->Close();
- TestViewer::eraseAll( true );
+ TestViewer::eraseAll( true, true );
}
#include <HYDROGUI_Overview.h>
#include <OCCViewer_ViewFrame.h>
+#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewPort3d.h>
#include <V3d_View.hxx>
painter.drawRect( WIDTH, WIDTH, w2, h2 );
painter.drawRect( w2+WIDTH, WIDTH, w1, h1 );
+ //static int q = 0;
+ //q++;
+ //anOverview.save( QString( "/tmp/hydro/overview_" ) + QString::number( q ) + ".png" );
+ //aMain.save( QString( "/tmp/hydro/main_" ) + QString::number( q ) + ".png" );
+
painter.drawImage( WIDTH, WIDTH, anOverview );
painter.drawImage( w2+WIDTH, WIDTH, aMain );
- return pix.toImage();
+ QImage res = pix.toImage();
+ //res.save( QString( "/tmp/hydro/result_" ) + QString::number( q ) + ".png" );
+
+ return res;
}
void test_Overview::create()
{
- static bool isPassed = false;
- if( isPassed )
- return;
+ TestViewer::eraseAll( true, true );
+
+ // Initialization of the empty viewer
- // default mouse position
- QTest::mouseMove( TestViewer::viewWindow(), QPoint( 0, 0 ) );
+ static bool isCreated = false;
+ if( !isCreated )
+ {
+ myOverview = new HYDROGUI_Overview( "Test overview" );
+ myOverview->show();
- // Initialization of the empty viewer
- myOverview = new HYDROGUI_Overview( "Test overview" );
- myOverview->show();
+ // default mouse position
+ QTest::mouseMove( TestViewer::viewWindow(), QPoint( 0, 0 ) );
+
+ isCreated = true;
+ }
myOverview->setMainView( TestViewer::viewWindow() );
TestViewer::viewWindow()->setGeometry( 400, 100, 800, 800 );
TestViewer::viewWindow()->onTopView();
myOverview->setGeometry( 100, 100, 200, 200 );
-
- isPassed = true;
}
void test_Overview::showShape()
{
- static bool isPassed = false;
- if( isPassed )
- return;
-
// Show loaded shape in the viewer
BRep_Builder B;
TopoDS_Shape shape;
qApp->processEvents();
myOverview->setTopView(); //TODO: automatic fit all on show???*/
-
- isPassed = true;
}
void fitAllWithRestore( OCCViewer_ViewPort3d* vp )
create();
showShape();
TestViewer::viewWindow()->onTopView();
-
- // 1. selection in main view
- QTest::mouseMove( TestViewer::viewWindow() );
- CPPUNIT_ASSERT_OVERVIEW( "overview_selection" );
+ qApp->processEvents();
OCCViewer_ViewWindow* aMain = TestViewer::viewWindow()->getView( OCCViewer_ViewFrame::MAIN_VIEW );
OCCViewer_ViewPort3d* vp = aMain->getViewPort();
+ // 1. selection in main view
+ QTest::mouseMove( vp, QPoint(150,150) );
+ TestViewer::context()->MoveTo(150, 150, vp->getView(), Standard_True );
+ TestViewer::context()->Select( Standard_True );
+ qApp->processEvents();
+ //QTest::qWait( 50000 );
+ //aMain->dumpView().save("/tmp/hydro/dump.png");
+ //aMain->dumpView().rgbSwapped().save("/tmp/hydro/dump2.png");
+ CPPUNIT_ASSERT_OVERVIEW( "overview_selection" );
+
// 2. mouse wheel zoom
QWheelEvent we( QPoint( 243, 416 ), 120*20, Qt::NoButton, Qt::NoModifier );
qApp->sendEvent( vp, &we );
create();
showShape();
TestViewer::viewWindow()->onTopView();
- QTest::mouseMove( TestViewer::viewWindow() );
+
+ OCCViewer_ViewWindow* aMain = TestViewer::viewWindow()->getView( OCCViewer_ViewFrame::MAIN_VIEW );
+ OCCViewer_ViewPort3d* vp = aMain->getViewPort();
+
+ QTest::mouseMove( vp, QPoint(150,150) );
+ TestViewer::context()->MoveTo(150, 150, vp->getView(), Standard_True );
+ TestViewer::context()->Select( Standard_True );
+ qApp->processEvents();
//QTest::qWait( 20000 );
CPPUNIT_ASSERT_OVERVIEW( "overview_selection" );
create();
showShape();
TestViewer::viewWindow()->onTopView();
- QTest::mouseMove( TestViewer::viewWindow() );
OCCViewer_ViewWindow* aMain = TestViewer::viewWindow()->getView( OCCViewer_ViewFrame::MAIN_VIEW );
OCCViewer_ViewPort3d* vp = aMain->getViewPort();
+ QTest::mouseMove( vp, QPoint(150,150) );
+ TestViewer::context()->MoveTo(150, 150, vp->getView(), Standard_True );
+ TestViewer::context()->Select( Standard_True );
+ qApp->processEvents();
+
QWheelEvent we( QPoint( 243, 416 ), 120*20, Qt::NoButton, Qt::NoModifier );
qApp->sendEvent( vp, &we );
qApp->processEvents();