#include <QVBoxLayout>
#include <QMenuBar>
#include <QStatusBar>
-#include <QWorkspace>
+#include <QMdiArea>
+#include <QMdiSubWindow>
#include <QMessageBox>
#include <QApplication>
#include <QSignalMapper>
#include <stdlib.h>
-static ApplicationCommonWindow* stApp;
-static QWorkspace* stWs;
+static ApplicationCommonWindow* stApp = 0;
+static QMdiArea* stWs = 0;
ApplicationCommonWindow::ApplicationCommonWindow()
: QMainWindow( 0 ),
layout->setMargin( 0 );
vb->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
- stWs = new QWorkspace( vb );
+ stWs = new QMdiArea( vb );
layout->addWidget( stWs );
setCentralWidget( vb );
QMenu* aPrefMenu = new QMenu( QObject::tr("MNU_PREFERENCES") );
aPrefMenu->addAction( filePrefUseVBOAction );
- // popuplate a menu with all actions
+ // populate a menu with all actions
myFilePopup = new QMenu( this );
myFilePopup = menuBar()->addMenu( QObject::tr("MNU_FILE") );
myFilePopup->addAction( fileNewAction );
a = new QAction( QPixmap( dir+QObject::tr("ICON_TOOL_DEL") ), QObject::tr("MNU_TOOL_DEL"), this );
a->setToolTip( QObject::tr("TBR_TOOL_DEL") );
a->setStatusTip( QObject::tr("TBR_TOOL_DEL") );
- connect( a, SIGNAL( activated() ) , this, SLOT( onToolAction() ) );
+ connect( a, SIGNAL( triggered() ) , this, SLOT( onToolAction() ) );
myToolActions.insert( ToolDeleteId, a );
-#ifdef HAVE_OPENCL
-
- // populate a tool bar with some actions
- myRaytraceBar = addToolBar( tr( "Ray-trace options" ) );
-
- a = new QAction( QPixmap( dir+QObject::tr("ICON_TOOL_SHADOWS") ), QObject::tr("MNU_TOOL_SHADOWS"), this );
- a->setToolTip( QObject::tr("TBR_TOOL_SHADOWS") );
- a->setStatusTip( QObject::tr("TBR_TOOL_SHADOWS") );
- a->setCheckable( true );
- a->setChecked( true );
- connect( a, SIGNAL( activated() ) , this, SLOT( onRaytraceAction() ) );
- myRaytraceActions.insert( ToolShadowsId, a );
- myRaytraceBar->addAction( a );
-
- a = new QAction( QPixmap( dir+QObject::tr("ICON_TOOL_REFLECTIONS") ), QObject::tr("MNU_TOOL_REFLECTIONS"), this );
- a->setToolTip( QObject::tr("TBR_TOOL_REFLECTIONS") );
- a->setStatusTip( QObject::tr("TBR_TOOL_REFLECTIONS") );
- a->setCheckable( true );
- a->setChecked( true );
- connect( a, SIGNAL( activated() ) , this, SLOT( onRaytraceAction() ) );
- myRaytraceActions.insert( ToolReflectionsId, a );
- myRaytraceBar->addAction( a );
-
- a = new QAction( QPixmap( dir+QObject::tr("ICON_TOOL_ANTIALIASING") ), QObject::tr("MNU_TOOL_ANTIALIASING"), this );
- a->setToolTip( QObject::tr("TBR_TOOL_ANTIALIASING") );
- a->setStatusTip( QObject::tr("TBR_TOOL_ANTIALIASING") );
- a->setCheckable( true );
- a->setChecked( false );
- connect( a, SIGNAL( activated() ) , this, SLOT( onRaytraceAction() ) );
- myRaytraceActions.insert( ToolAntialiasingId, a );
- myRaytraceBar->addAction( a );
-
-#endif
-
QSignalMapper* sm = new QSignalMapper( this );
connect( sm, SIGNAL( mapped( int ) ), this, SLOT( onSetMaterial( int ) ) );
QString dir = getResourceDir() + QString( "/" );
- a = new QAction( QPixmap( dir + QObject::tr( "ICON_WINDOW_NEW3D" ) ), QObject::tr( "MNU_WINDOW_NEW3D_GL" ), this );
- a->setToolTip( QObject::tr( "TBR_WINDOW_NEW3D_GL" ) );
- a->setStatusTip( QObject::tr( "TBR_WINDOW_NEW3D_GL" ) );
+ a = new QAction( QPixmap( dir + QObject::tr( "ICON_WINDOW_NEW3D" ) ), QObject::tr( "MNU_WINDOW_NEW3D" ), this );
+ a->setToolTip( QObject::tr( "TBR_WINDOW_NEW3D" ) );
+ a->setStatusTip( QObject::tr( "TBR_WINDOW_NEW3D" ) );
connect( a, SIGNAL( triggered() ), this, SLOT( onCreateNewView() ) );
myWindowPopup->addAction( a );
-#ifdef HAVE_OPENCL
-
- a = new QAction( QPixmap( dir + QObject::tr( "ICON_WINDOW_NEW3D" ) ), QObject::tr( "MNU_WINDOW_NEW3D_RT" ), this );
- a->setToolTip( QObject::tr( "TBR_WINDOW_NEW3D_RT" ) );
- a->setStatusTip( QObject::tr( "TBR_WINDOW_NEW3D_RT" ) );
- connect( a, SIGNAL( activated() ), this, SLOT( onCreateNewViewRT() ) );
- myWindowPopup->addAction( a );
-
-#endif
-
a = new QAction( QPixmap( dir + QObject::tr( "ICON_WINDOW_CASCADE" ) ), QObject::tr( "MNU_WINDOW_CASCADE" ), this );
a->setToolTip( QObject::tr( "TBR_WINDOW_CASCADE" ) );
a->setStatusTip( QObject::tr( "TBR_WINDOW_CASCADE" ) );
myWindowPopup->addAction( a );
myWindowPopup->addSeparator();
- QWidgetList windows = stWs->windowList();
- for ( uint i = 0; i < windows.count(); ++i )
+ QList<QMdiSubWindow *> windows = stWs->subWindowList();
+ for (int i = 0; i < windows.count(); ++i)
{
-
- QAction* aAction = new QAction( windows.at(i)->windowTitle(), this );
+ QAction* aAction = new QAction( windows.at(i)->windowTitle(), this );
aAction->setCheckable( true );
aAction->setData( i );
myWindowPopup->addAction( aAction );
connect( aAction, SIGNAL( toggled( bool ) ), this, SLOT( windowsMenuActivated( bool ) ) );
- aAction->setChecked( stWs->activeWindow() == windows.at(i) );
+ aAction->setChecked( stWs->activeSubWindow() == windows.at(i) );
}
}
QAction* aSender = qobject_cast<QAction*>( sender() );
if ( !aSender )
return;
- QWidget* w = stWs->windowList().at( aSender->data().toInt() );
+ QWidget * w = stWs->subWindowList().at( aSender->data().toInt() );
if ( w && checked )
w->setFocus();
}
-QWorkspace * ApplicationCommonWindow::getWorkspace()
+QMdiArea * ApplicationCommonWindow::getWorkspace()
{
return stWs;
}
void ApplicationCommonWindow::updateFileActions()
{
- if ( stWs->windowList().isEmpty() )
+ if ( myDocuments.isEmpty() )
{
if ( !myIsDocuments )
{
DocumentCommon* ApplicationCommonWindow::onNewDoc()
{
- updateFileActions();
- DocumentCommon* aDoc = createNewDocument();
- aDoc->onCreateNewView();
- onSelectionChanged();
- connect( aDoc, SIGNAL( sendCloseDocument( DocumentCommon* ) ),
- this, SLOT( onCloseDocument( DocumentCommon* ) ) );
- connect( stWs, SIGNAL( windowActivated( QWidget* ) ),
- this, SLOT( onWindowActivated( QWidget* ) ) );
- connect( aDoc, SIGNAL( selectionChanged() ),
- this, SLOT( onSelectionChanged() ) );
- myDocuments.append( aDoc );
- myStdActions.at( FileCloseId )->setEnabled( myDocuments.count() > 0 );
- return aDoc;
-}
-
-DocumentCommon* ApplicationCommonWindow::onNewDocRT()
-{
- updateFileActions();
- DocumentCommon* aDoc = createNewDocument();
- aDoc->onCreateNewView(true);
- onSelectionChanged();
- connect( aDoc, SIGNAL( sendCloseDocument( DocumentCommon* ) ),
- this, SLOT( onCloseDocument( DocumentCommon* ) ) );
- connect( stWs, SIGNAL( windowActivated( QWidget* ) ),
- this, SLOT( onWindowActivated( QWidget* ) ) );
- connect( aDoc, SIGNAL( selectionChanged() ),
- this, SLOT( onSelectionChanged() ) );
- myDocuments.append( aDoc );
- myStdActions.at( FileCloseId )->setEnabled( myDocuments.count() > 0 );
- return aDoc;
+ updateFileActions();
+
+ DocumentCommon* aDoc = createNewDocument();
+ aDoc->onCreateNewView();
+ onSelectionChanged();
+
+ connect (aDoc, SIGNAL (sendCloseDocument (DocumentCommon*) ),
+ this, SLOT (onCloseDocument (DocumentCommon*)));
+ connect (stWs, SIGNAL (windowActivated (QWidget*)),
+ this, SLOT (onWindowActivated (QWidget*)));
+ connect (aDoc, SIGNAL (selectionChanged()),
+ this, SLOT (onSelectionChanged()));
+
+ myDocuments.append (aDoc);
+ myStdActions.at (FileCloseId)->setEnabled (myDocuments.count() > 0);
+
+ return aDoc;
}
void ApplicationCommonWindow::onCloseWindow()
{
- MDIWindow* m = (MDIWindow*)stWs->activeWindow();
- if ( m )
- {
- DocumentCommon* doc = m->getDocument();
- onCloseDocument( doc );
- }
+ stWs->activeSubWindow()->close();
}
void ApplicationCommonWindow::onUseVBO()
{
- MDIWindow* w = ( MDIWindow* ) stWs->activeWindow();
+ MDIWindow* aWindow = qobject_cast<MDIWindow*> (stWs->activeSubWindow()->widget());
- if ( NULL == w )
- return;
+ if (NULL == aWindow)
+ return;
- Handle(AIS_InteractiveContext) aContextAIS = w->getDocument()->getContext();
+ Handle(AIS_InteractiveContext) aContextAIS = aWindow->getDocument()->getContext();
- if (aContextAIS.IsNull())
- return;
+ if (aContextAIS.IsNull())
+ return;
- Handle(OpenGl_GraphicDriver) aDriver =
- Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
+ Handle(OpenGl_GraphicDriver) aDriver =
+ Handle(OpenGl_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Driver());
- if (!aDriver.IsNull())
- {
- aDriver->ChangeOptions().vboDisable = Standard_True;
- }
+ if (!aDriver.IsNull())
+ {
+ aDriver->ChangeOptions().vboDisable = Standard_True;
+ }
}
void ApplicationCommonWindow::onCloseDocument(DocumentCommon* theDoc)
void ApplicationCommonWindow::onCreateNewView()
{
- MDIWindow* window = qobject_cast< MDIWindow* >( stWs->activeWindow() );
- window->getDocument()->onCreateNewView( false );
+ MDIWindow* window = qobject_cast< MDIWindow* >( stWs->activeSubWindow()->widget() );
+ window->getDocument()->onCreateNewView();
}
-#ifdef HAVE_OPENCL
-
-void ApplicationCommonWindow::onCreateNewViewRT()
-{
- MDIWindow* window = qobject_cast< MDIWindow* >( stWs->activeWindow() );
- window->getDocument()->onCreateNewView( true );
-}
-
-#endif
-
void ApplicationCommonWindow::onWindowActivated ( QWidget * w )
{
if (w == NULL)
MDIWindow* window = qobject_cast< MDIWindow* >(w);
window->onWindowActivated();
-
-#ifdef HAVE_OPENCL
-
- myRaytraceActions.at( ToolShadowsId )->setChecked (window->ShadowsEnabled());
- myRaytraceActions.at( ToolReflectionsId )->setChecked (window->ReflectionsEnabled());
- myRaytraceActions.at( ToolAntialiasingId )->setChecked (window->AntialiasingEnabled());
-
-#endif
}
void ApplicationCommonWindow::onToolAction()
{
QAction* sentBy = (QAction*) sender();
- QWorkspace* ws = ApplicationCommonWindow::getWorkspace();
- DocumentCommon* doc = ((MDIWindow*)ws->activeWindow())->getDocument();
+ QMdiArea* ws = ApplicationCommonWindow::getWorkspace();
+ DocumentCommon* doc = qobject_cast<MDIWindow*>( ws->activeSubWindow()->widget() )->getDocument();
if( sentBy == myToolActions.at( ToolWireframeId ) )
doc->onWireframe();
doc->onDelete();
}
-#ifdef HAVE_OPENCL
-
-void ApplicationCommonWindow::onRaytraceAction()
-{
- QAction* sentBy = (QAction*) sender();
-
- DocumentCommon* doc = qobject_cast< MDIWindow* >(
- ApplicationCommonWindow::getWorkspace()->activeWindow())->getDocument();
-
- if( sentBy == myRaytraceActions.at( ToolShadowsId ) )
- {
- bool flag = myRaytraceActions.at( ToolShadowsId )->isChecked();
- doc->onShadows( flag );
- }
-
- if( sentBy == myRaytraceActions.at( ToolReflectionsId ) )
- {
- bool flag = myRaytraceActions.at( ToolReflectionsId )->isChecked();
- doc->onReflections( flag );
- }
-
- if( sentBy == myRaytraceActions.at( ToolAntialiasingId ) )
- {
- bool flag = myRaytraceActions.at( ToolAntialiasingId )->isChecked();
- doc->onAntialiasing( flag );
- }
-}
-
-#endif
-
void ApplicationCommonWindow::onSelectionChanged()
{
- QWorkspace* ws = ApplicationCommonWindow::getWorkspace();
+ QMdiArea* ws = ApplicationCommonWindow::getWorkspace();
DocumentCommon* doc;
- if( !qobject_cast<MDIWindow*>( ws->activeWindow() ) )
+ if( !qobject_cast<MDIWindow*>( ws->activeSubWindow()->widget() ) )
return;
- doc = ((MDIWindow*)ws->activeWindow())->getDocument();
- Handle(AIS_InteractiveContext) context = doc->getContext();
+
+ doc = ( qobject_cast<MDIWindow*>( ws->activeSubWindow()->widget() ) )->getDocument();
+ Handle(AIS_InteractiveContext) context = doc->getContext();
- bool OneOrMoreInShading = false;
- bool OneOrMoreInWireframe = false;
- int numSel = context->NbSelected();
- if ( numSel )
- {
- for ( context->InitCurrent(); context->MoreCurrent(); context->NextCurrent() )
- {
- if ( context->IsDisplayed( context->Current(), 1 ) )
- OneOrMoreInShading = true;
- if ( context->IsDisplayed( context->Current(), 0 ) )
- OneOrMoreInWireframe = true;
- }
- myToolActions.at( ToolWireframeId )->setEnabled( OneOrMoreInShading );
- myToolActions.at( ToolShadingId )->setEnabled( OneOrMoreInWireframe );
- myToolActions.at( ToolColorId )->setEnabled( true );
- myToolActions.at( ToolMaterialId )->setEnabled( true );
- myToolActions.at( ToolTransparencyId )->setEnabled( OneOrMoreInShading );
- myToolActions.at( ToolDeleteId )->setEnabled( true );
- }
- else
+ bool OneOrMoreInShading = false;
+ bool OneOrMoreInWireframe = false;
+ int numSel = context->NbSelected();
+ if ( numSel )
+ {
+ for ( context->InitCurrent(); context->MoreCurrent(); context->NextCurrent() )
{
- myToolActions.at( ToolWireframeId )->setEnabled( false );
- myToolActions.at( ToolShadingId )->setEnabled( false );
- myToolActions.at( ToolColorId )->setEnabled( false );
- myToolActions.at( ToolMaterialId )->setEnabled( false );
- myToolActions.at( ToolTransparencyId )->setEnabled( false );
- myToolActions.at( ToolDeleteId )->setEnabled( false );
+ if ( context->IsDisplayed( context->Current(), 1 ) )
+ OneOrMoreInShading = true;
+ if ( context->IsDisplayed( context->Current(), 0 ) )
+ OneOrMoreInWireframe = true;
}
+ myToolActions.at( ToolWireframeId )->setEnabled( OneOrMoreInShading );
+ myToolActions.at( ToolShadingId )->setEnabled( OneOrMoreInWireframe );
+ myToolActions.at( ToolColorId )->setEnabled( true );
+ myToolActions.at( ToolMaterialId )->setEnabled( true );
+ myToolActions.at( ToolTransparencyId )->setEnabled( OneOrMoreInShading );
+ myToolActions.at( ToolDeleteId )->setEnabled( true );
+ }
+ else
+ {
+ myToolActions.at( ToolWireframeId )->setEnabled( false );
+ myToolActions.at( ToolShadingId )->setEnabled( false );
+ myToolActions.at( ToolColorId )->setEnabled( false );
+ myToolActions.at( ToolMaterialId )->setEnabled( false );
+ myToolActions.at( ToolTransparencyId )->setEnabled( false );
+ myToolActions.at( ToolDeleteId )->setEnabled( false );
+ }
}
void ApplicationCommonWindow::onSetMaterial( int theMaterial )
{
- QWorkspace* ws = getWorkspace();
- DocumentCommon* doc = ((MDIWindow*)ws->activeWindow())->getDocument();
+ QMdiArea* ws = getWorkspace();
+ DocumentCommon* doc = qobject_cast<MDIWindow*>( ws->activeSubWindow()->widget() )->getDocument();
doc->onMaterial( theMaterial );
}
QString ApplicationCommonWindow::getResourceDir()
{
- static QString resDir( ::getenv( "CSF_ResourcesDefaults" ) );
- return resDir;
+ static QString aResourceDir =
+ QString::fromUtf8 (qgetenv ("CSF_ResourcesDefaults").constData());
+
+ return aResourceDir;
}
void ApplicationCommonWindow::resizeEvent( QResizeEvent* e )