#include "HYDROGUI_SetColorOp.h"
#include "HYDROGUI_ImportGeomObjectOp.h"
#include "HYDROGUI_ShowHideOp.h"
+#include "HYDROGUI_Overview.h"
#include <HYDROData_Tool.h>
#include <HYDROData_Image.h>
: LightApp_Module( "HYDRO" ),
myDisplayer( 0 ),
myOCCDisplayer( 0 ),
- myIsUpdateEnabled( true )
+ myIsUpdateEnabled( true ),
+ myOverview( 0 )
{
}
ViewManagerList anOCCViewManagers;
anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
- foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
+
+ foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers )
+ {
connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
- foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() ) {
+ connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
+ this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
+
+ foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() )
+ {
OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
- if ( aViewFrame && aViewFrame->getViewPort() ) {
+ if ( aViewFrame && aViewFrame->getViewPort() )
+ {
aViewFrame->getViewPort()->installEventFilter( this );
}
}
void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
{
+ static bool inWindows = false;
+ if( inWindows )
+ return;
+
theMap.clear();
theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
#ifndef DISABLE_PYCONSOLE
theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
#endif
theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
+ theMap.insert( OverviewWindow, Qt::LeftDockWidgetArea );
+
+ inWindows = true;
+ LightApp_Application* app = getApp();
+ if( app && app->getWindow( OverviewWindow )==0 )
+ {
+ const_cast<HYDROGUI_Module*>( this )->myOverview =
+ new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() );
+ myOverview->setGeometry( 0, 0, 320, 240 );
+ app->insertDockWindow( OverviewWindow, myOverview );
+ }
+ inWindows = false;
}
void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+ connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
+ this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
}
else if( theViewManager->getType() == SVTK_Viewer::Type() )
{
}
}
}
+
+void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
+{
+ if( !theMgr )
+ return;
+
+ SUIT_ViewWindow* wnd = theMgr->getActiveView();
+ OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
+ if( !occwnd )
+ return;
+
+ myOverview->setMainView( occwnd );
+}
#endif
#include <LightApp_Module.h>
+#include <LightApp_Application.h>
#include <QEvent>
#include <QStack>
class HYDROGUI_Shape;
class HYDROGUI_VTKPrs;
class HYDROGUI_Operation;
+class HYDROGUI_Overview;
/**\class HYDROGUI_Module
*\brief The class representing the HYDROGUI module
Q_OBJECT
enum CustomEvent { NewViewEvent = QEvent::User + 100 };
+ enum CustomWindows { OverviewWindow = LightApp_Application::WT_User + 100 };
enum CursorType
{
virtual void onViewManagerRemoved( SUIT_ViewManager* );
virtual void onViewCreated( SUIT_ViewWindow* );
+ void onViewActivated( SUIT_ViewManager* );
+
void onViewPortMouseEvent( QGraphicsSceneMouseEvent* );
void onMouseMove( SUIT_ViewWindow*, QMouseEvent* );
QStringList myGeomObjectsToImport; ///< entries of GEOM objects to be imported
ViewId2StricklerTable myLandCoverColoringMap;
+
+ HYDROGUI_Overview* myOverview;
};
#endif
#include <QApplication>
#include <QPainter>
#include <QMouseEvent>
+#include <QLayout>
class HYDROGUI_OverviewBand : public QtxPolyRubberBand
{
int h = main->height();
QPolygon poly;
- poly.append( myOverview->fromMain( 0, 0 ) );
- poly.append( myOverview->fromMain( w, 0 ) );
- poly.append( myOverview->fromMain( w, h ) );
- poly.append( myOverview->fromMain( 0, h ) );
- poly.append( myOverview->fromMain( 0, 0 ) );
+ QPoint p1 = myOverview->fromMain( 0, 0 );
+ QPoint p2 = myOverview->fromMain( w, 0 );
+ QPoint p3 = myOverview->fromMain( w, h );
+ QPoint p4 = myOverview->fromMain( 0, h );
+ poly.append( p1 );
+ poly.append( p2 );
+ poly.append( p3 );
+ poly.append( p4 );
+ poly.append( p1 );
initGeometry( poly );
}
else
HYDROGUI_Overview::HYDROGUI_Overview( const QString& theTitle, int theMargin, QWidget* theParent )
- : QDockWidget( theParent ), myMargin( theMargin ),
+ : QFrame( theParent ), myMargin( theMargin ),
myMainView( 0 ), myViewPort( 0 ), myBand( 0 )
{
setWindowTitle( theTitle );
+ myLayout = new QGridLayout( this );
+ myLayout->setMargin( 0 );
+ myLayout->setSpacing( 0 );
+ myLayout->setRowStretch( 0, 1 );
+ myLayout->setColumnStretch( 0, 1 );
}
HYDROGUI_Overview::~HYDROGUI_Overview()
connect( aMainView->getViewPort(), SIGNAL( vpTransformed( OCCViewer_ViewPort* ) ),
this, SLOT( OnTransformation() ) );
- myViewPort = new OCCViewer_ViewPort3d( this, myMainView->getViewPort()->getViewer(), V3d_ORTHOGRAPHIC );
- myViewPort->setBackgroundColor( Qt::white );
+ if( !myViewPort )
+ {
+ myViewPort = new OCCViewer_ViewPort3d( this, myMainView->getViewPort()->getViewer(), V3d_ORTHOGRAPHIC );
+ //myViewPort->setBackgroundColor( Qt::white );
- connect( myViewPort, SIGNAL( vpMouseEvent( QMouseEvent* ) ),
- this, SLOT( OnMouseEvent( QMouseEvent* ) ) );
- connect( myViewPort, SIGNAL( vpResizeEvent( QResizeEvent* ) ),
- this, SLOT( OnResizeEvent( QResizeEvent* ) ) );
+ connect( myViewPort, SIGNAL( vpMouseEvent( QMouseEvent* ) ),
+ this, SLOT( OnMouseEvent( QMouseEvent* ) ) );
+ connect( myViewPort, SIGNAL( vpResizeEvent( QResizeEvent* ) ),
+ this, SLOT( OnResizeEvent( QResizeEvent* ) ) );
+
+ myLayout->addWidget( myViewPort, 0, 0 );
+ }
#if defined(TEST_MODE) || defined(_DEBUG)
//qApp->installEventFilter( this );
#endif
- setWidget( myViewPort );
+ qApp->processEvents();
+
setTopView();
qApp->processEvents();
- myBand = new HYDROGUI_OverviewBand( this );
+
+ if( !myBand )
+ myBand = new HYDROGUI_OverviewBand( this );
+
myBand->update( true );
}
myViewPort->fitAll();
// Apply margins for internal area in the view port
- QRect aRect( -myMargin, -myMargin, myViewPort->width()+2*myMargin, myViewPort->height()+2*myMargin );
- myViewPort->fitRect( aRect );
+ if( myMargin>0 )
+ {
+ QRect aRect( -myMargin, -myMargin, myViewPort->width()+2*myMargin, myViewPort->height()+2*myMargin );
+ myViewPort->fitRect( aRect );
+ }
if( myBand )
myBand->update( true );
void HYDROGUI_Overview::OnTransformation()
{
- myBand->update( true );
+ if( myBand )
+ myBand->update( true );
}
QPoint HYDROGUI_Overview::fromMain( int xp, int yp ) const
break;
}*/
#endif
- return QDockWidget::eventFilter( theObject, theEvent );
+ return QFrame::eventFilter( theObject, theEvent );
}
void HYDROGUI_Overview::OnResizeEvent( QResizeEvent* )
#ifndef HYDROGUI_OVERVIEW_H
#define HYDROGUI_OVERVIEW_H
-#include <QDockWidget>
+#include <QFrame>
class OCCViewer_ViewPort3d;
class OCCViewer_ViewFrame;
class HYDROGUI_OverviewBand;
+class QGridLayout;
-class HYDROGUI_Overview : public QDockWidget
+class HYDROGUI_Overview : public QFrame
{
Q_OBJECT
void OnResizeEvent( QResizeEvent* );
private:
+ QGridLayout* myLayout;
int myMargin;
OCCViewer_ViewFrame* myMainView;
OCCViewer_ViewPort3d* myViewPort;
<source>LAND_COVER_POLYLINES</source>
<translation>Polylines</translation>
</message>
+ <message>
+ <source>OVERVIEW</source>
+ <translation>Overview</translation>
+ </message>
</context>
<context>
//QTest::qWait( 50000 );
}
+void test_Overview::test_set_mainview_2_times()
+{
+ create();
+ showShape();
+ TestViewer::viewWindow()->onTopView();
+ QTest::mouseMove( TestViewer::viewWindow() );
+
+ //QTest::qWait( 20000 );
+ CPPUNIT_ASSERT_OVERVIEW( "overview_selection" );
+
+ myOverview->setMainView( TestViewer::viewWindow() );
+ qApp->processEvents();
+
+ CPPUNIT_ASSERT_OVERVIEW( "overview_selection" );
+}
+
void test_Overview::test_actions_in_overview()
{
+ //TODO
}
CPPUNIT_TEST( test_presentation );
CPPUNIT_TEST( test_actions_in_main );
CPPUNIT_TEST( test_actions_in_overview );
+ CPPUNIT_TEST( test_set_mainview_2_times );
CPPUNIT_TEST_SUITE_END();
public:
void test_presentation();
void test_actions_in_main();
void test_actions_in_overview();
+ void test_set_mainview_2_times();
private:
static HYDROGUI_Overview* overView();