test_HYDROData_Profile.h
test_HYDROData_StricklerTable.h
test_HYDROGUI_ListModel.h
+
+ TestViewer.h
)
set(PROJECT_SOURCES
test_HYDROGUI_ListModel.cxx
${EXTERNAL_FILES}
+
+ TestViewer.cxx
)
add_definitions(
SET( GUI_INCLUDES $ENV{GUI_ROOT_DIR}/include/salome )
link_directories( $ENV{CAS_ROOT_DIR}/win32/libd ) #TODO: more correct for release, linux etc
-SET( CAS_LIBRARIES TKernel TKLCAF TKCAF TKCDF TKMath TKG2d TKG3d TKBRep TKGeomBase TKTopAlgo TKGeomAlgo TKBool TKShHealing TKXSBase TKOffset TKHLR TKBO )
+SET( CAS_LIBRARIES TKernel TKLCAF TKCAF TKCDF TKMath TKG2d TKG3d TKBRep TKGeomBase TKTopAlgo TKGeomAlgo TKBool TKShHealing TKXSBase TKOffset TKHLR TKBO TKV3d )
link_directories( $ENV{QT_ROOT_DIR}/lib )
SET( QT_LIBRARIES QtCored4 QtGuid4 )
SET( CPPUNIT_LIBRARIES cppunitd )
link_directories( $ENV{GUI_ROOT_DIR}/lib/salome )
-SET( GUI_LIBRARIES ImageComposer Qtx SUIT LightApp CAM )
+SET( GUI_LIBRARIES ImageComposer Qtx SUIT LightApp CAM OCCViewer )
include_directories(
${BOOST_INCLUDES}
--- /dev/null
+
+#include <TestViewer.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewWindow.h>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_Shape.hxx>
+#include <QDir>
+
+OCCViewer_ViewManager* TestViewer::myViewManager = 0;
+OCCViewer_ViewWindow* TestViewer::myViewWindow = 0;
+
+OCCViewer_ViewManager* TestViewer::viewManager()
+{
+ if( myViewManager )
+ return myViewManager;
+
+ myViewManager = new OCCViewer_ViewManager( 0, 0 );
+ OCCViewer_Viewer* aViewer = new OCCViewer_Viewer( true );
+
+ aViewer->setTrihedronSize( 100, true );
+ aViewer->setInteractionStyle( 0 );
+ aViewer->setZoomingStyle( 1 );
+
+ myViewManager->setViewModel( aViewer );
+ myViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( myViewManager->createViewWindow() );
+
+ return myViewManager;
+}
+
+OCCViewer_Viewer* TestViewer::viewer()
+{
+ return dynamic_cast<OCCViewer_Viewer*>( viewManager()->getViewModel() );
+}
+
+OCCViewer_ViewWindow* TestViewer::viewWindow()
+{
+ viewManager(); //to create the view if it was not created earlier
+ return myViewWindow;
+}
+
+Handle(AIS_InteractiveContext) context()
+{
+ return TestViewer::viewer()->getAISContext();
+}
+
+void TestViewer::show( const TopoDS_Shape& theShape, bool isFitAll )
+{
+ context()->EraseAll();
+ Handle(AIS_Shape) aShape = new AIS_Shape( theShape );
+ context()->Display( aShape, AIS_Shaded, 0, Standard_False );
+
+ viewWindow()->onTopView();
+ viewWindow()->onFitAll();
+}
+
+void TestViewer::dump( const TopoDS_Shape& theShape, const QString& theName )
+{
+ show( theShape );
+ QImage anImage = viewWindow()->dumpView();
+
+ QString aPath = QDir::tempPath() + "/" + theName + ".png";
+ anImage.save( aPath );
+}
--- /dev/null
+
+#pragma once
+
+class OCCViewer_ViewManager;
+class OCCViewer_Viewer;
+class OCCViewer_ViewWindow;
+class TopoDS_Shape;
+class QString;
+
+class TestViewer
+{
+public:
+ static OCCViewer_ViewManager* viewManager();
+ static OCCViewer_Viewer* viewer();
+ static OCCViewer_ViewWindow* viewWindow();
+
+ static void show( const TopoDS_Shape& theShape, bool isFitAll = true );
+ static void dump( const TopoDS_Shape& theShape, const QString& theName );
+
+private:
+ static OCCViewer_ViewManager* myViewManager;
+ static OCCViewer_ViewWindow* myViewWindow;
+};
#include <cppunit/TestRunner.h>
#include <cppunit/TextTestProgressListener.h>
#include <stdexcept>
+#include <TestViewer.h>
+#include <OCCViewer_ViewWindow.h>
+#include <SUIT_Session.h>
#include <QApplication>
#include <QColor>
int main( int argc, char* argv[] )
{
QApplication anApp( argc, argv );
+ SUIT_Session aSession;
+
+ OCCViewer_ViewWindow* aWindow = TestViewer::viewWindow();
+ aWindow->setGeometry( 200, 200, 800, 600 );
+ aWindow->show();
std::string testPath = (argc > 1) ? std::string(argv[1]) : "";
return 0;
}
+ //anApp.exec();
return result.wasSuccessful() ? 0 : 1;
}