#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 )
#include <QAction>
#include <QToolBar>
#include <QMenu>
-#include <QWorkspace>
+#include <QMdiArea>
#include <QList>
public:
enum { FileNewId, FilePrefUseVBOId, FileCloseId, FilePreferencesId, FileQuitId, ViewToolId, ViewStatusId, HelpAboutId };
enum { ToolWireframeId, ToolShadingId, ToolColorId, ToolMaterialId, ToolTransparencyId, ToolDeleteId };
- enum { ToolShadowsId, ToolReflectionsId, ToolAntialiasingId };
ApplicationCommonWindow();
~ApplicationCommonWindow();
- static QWorkspace* getWorkspace();
+ static QMdiArea* getWorkspace();
static ApplicationCommonWindow* getApplication();
static QString getResourceDir();
public slots:
DocumentCommon* onNewDoc();
- DocumentCommon* onNewDocRT();
void onCloseWindow();
void onUseVBO();
virtual void onCloseDocument( DocumentCommon* theDoc );
void onViewToolBar();
void onViewStatusBar();
void onToolAction();
-#ifdef HAVE_OPENCL
- void onRaytraceAction();
-#endif
void onCreateNewView();
-#ifdef HAVE_OPENCL
- void onCreateNewViewRT();
-#endif
void onWindowActivated ( QWidget * w );
void windowsMenuAboutToShow();
void windowsMenuActivated( bool checked/*int id*/ );
QList<QAction*> myStdActions;
QList<QAction*> myToolActions;
- QList<QAction*> myRaytraceActions;
QList<QAction*> myMaterialActions;
- QList<DocumentCommon*> myDocuments;
+ //QList<DocumentCommon*> myDocuments;
QToolBar* myStdToolBar;
QToolBar* myCasCadeBar;
- QToolBar* myRaytraceBar;
QMenu* myFilePopup;
QMenu* myWindowPopup;
QAction* myFileSeparator;
+
+protected:
+ QList<DocumentCommon*> myDocuments;
};
#endif
<source>ICON_NEW</source>
<translation>new.png</translation>
</message>
- <message>
- <source>ICON_NEW_GL</source>
- <translation>newGL.png</translation>
- </message>
- <message>
- <source>ICON_NEW_RT</source>
- <translation>newRT.png</translation>
- </message>
<message>
<source>ICON_VIEW_RIGHT</source>
<translation>view_right.png</translation>
<source>ICON_SAMPLE</source>
<translation>lamp.png</translation>
</message>
+ <message>
+ <source>ICON_TOOL_RAYTRACING</source>
+ <translation>raytracing.png</translation>
+ </message>
<message>
<source>ICON_TOOL_SHADOWS</source>
<translation>shadows.png</translation>
</message>
+ <message>
+ <source>ICON_TOOL_RAYTRACING</source>
+ <translation>shadows.png</translation>
+ </message>
<message>
<source>ICON_TOOL_REFLECTIONS</source>
<translation>reflections.png</translation>
<source>MNU_TOOL_SHADOWS</source>
<translation>&Shadows</translation>
</message>
+ <message>
+ <source>MNU_TOOL_RAYTRACING</source>
+ <translation>&Ray-tracing</translation>
+ </message>
<message>
<source>MNU_TOOL_REFLECTIONS</source>
<translation>&Reflections</translation>
</message>
<message>
<source>MNU_TOOL_ANTIALIASING</source>
- <translation>&Antialiasing</translation>
+ <translation>&Anti-aliasing</translation>
</message>
<message>
<source>BTN_BRASS</source>
<source>TBR_TOOL_MATER</source>
<translation>Material</translation>
</message>
+ <message>
+ <source>TBR_TOOL_RAYTRACING</source>
+ <translation>Enable Ray-tracing</translation>
+ </message>
+ <message>
+ <source>TBR_TOOL_SHADOWS</source>
+ <translation>Enable Shadows</translation>
+ </message>
+ <message>
+ <source>TBR_TOOL_REFLECTIONS</source>
+ <translation>Enable Reflections</translation>
+ </message>
+ <message>
+ <source>TBR_TOOL_ANTIALIASING</source>
+ <translation>Enable Anti-aliasing</translation>
+ </message>
<message>
<source>TBR_TOOL_BAR</source>
<translation>Toolbar</translation>
<translation>New 3D View</translation>
</message>
<message>
- <source>TBR_WINDOW_NEW3D_GL</source>
- <translation>New GL 3D View</translation>
- </message>
- <message>
- <source>MNU_WINDOW_NEW3D_GL</source>
- <translation>New GL 3D View</translation>
- </message>
- <message>
- <source>TBR_WINDOW_NEW3D_RT</source>
- <translation>&New RT 3D View</translation>
- </message>
- <message>
- <source>MNU_WINDOW_NEW3D_RT</source>
- <translation>&New RT 3D View</translation>
+ <source>MNU_WINDOW_NEW3D</source>
+ <translation>New 3D View</translation>
</message>
<message>
<source>MNU_STATUS_BAR</source>
#include <OpenGl_GraphicDriver.hxx>
#include <TCollection_AsciiString.hxx>
-Handle(V3d_Viewer) DocumentCommon::Viewer( const Standard_CString aDisplay,
+Handle(V3d_Viewer) DocumentCommon::Viewer( const Standard_CString /*aDisplay*/,
const Standard_ExtString aName,
const Standard_CString aDomain,
const Standard_Real ViewSize,
myIndex( theIndex ),
myNbViews( 0 )
{
- TCollection_ExtendedString a3DName("Visu3D");
- myViewer = Viewer( getenv("DISPLAY"), a3DName.ToExtString(), "", 1000.0,
- V3d_XposYnegZpos, Standard_True, Standard_True );
+ TCollection_ExtendedString a3DName ("Visu3D");
+ myViewer = Viewer (qgetenv ("DISPLAY").constData(),
+ a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Standard_True, Standard_True);
myViewer->SetDefaultLights();
myViewer->SetLightOn();
- myContext =new AIS_InteractiveContext(myViewer);
+ myContext = new AIS_InteractiveContext (myViewer);
}
DocumentCommon::~DocumentCommon()
return myApp;
}
-MDIWindow* DocumentCommon::createNewMDIWindow( bool theRT )
+MDIWindow* DocumentCommon::createNewMDIWindow()
{
- QWorkspace* ws = myApp->getWorkspace();
- return new MDIWindow( this, ws, 0, theRT );
+ QMdiArea* ws = myApp->getWorkspace();
+ return new MDIWindow (this, ws, 0);
}
-void DocumentCommon::onCreateNewView( bool theRT )
+void DocumentCommon::onCreateNewView()
{
- QWorkspace* ws = myApp->getWorkspace();
- MDIWindow* w = createNewMDIWindow( theRT );
+ QMdiArea* ws = myApp->getWorkspace();
+ MDIWindow* w = createNewMDIWindow();
- if( !w )
+ if (!w)
return;
- ws->addWindow( w );
- myViews.append(w);
+ ws->addSubWindow (w);
+ myViews.append (w);
connect( w, SIGNAL( selectionChanged() ),
this, SIGNAL( selectionChanged() ) );
w->setWindowIcon( QPixmap( dir + QObject::tr("ICON_DOC") ) );
- if ( ws->windowList().isEmpty() )
+ if ( ws->subWindowList().isEmpty() )
{
// Due to strange Qt4.2.3 feature the child window icon is not drawn
// in the main menu if showMaximized() is called for a non-visible child window
void DocumentCommon::removeViews()
{
while( myViews.count() )
- removeView( (MDIWindow*)myViews.first() );
+ {
+ removeView( myViews.first() );
+ }
}
int DocumentCommon::countOfWindow()
myContext->ClearSelected();
getApplication()->onSelectionChanged();
}
-
-#ifdef HAVE_OPENCL
-
-void DocumentCommon::onShadows( int state )
-{
- QWorkspace* ws = ApplicationCommonWindow::getWorkspace();
-
- MDIWindow* window = qobject_cast< MDIWindow* >( ws->activeWindow() );
-
- if( window == NULL )
- return;
-
- window->setRaytracedShadows( state );
-
- myContext->UpdateCurrentViewer();
-}
-
-void DocumentCommon::onReflections( int state )
-{
- QWorkspace* ws = ApplicationCommonWindow::getWorkspace();
-
- MDIWindow* window = qobject_cast< MDIWindow* >( ws->activeWindow() );
-
- if( window == NULL )
- return;
-
- window->setRaytracedReflections( state );
-
- myContext->UpdateCurrentViewer();
-}
-
-void DocumentCommon::onAntialiasing( int state )
-{
- QWorkspace* ws = ApplicationCommonWindow::getWorkspace();
-
- MDIWindow* window = qobject_cast< MDIWindow* >( ws->activeWindow() );
-
- if( window == NULL )
- return;
-
- window->setRaytracedAntialiasing( state );
-
- myContext->UpdateCurrentViewer();
-}
-
-#endif
void fitAll();
protected:
- virtual MDIWindow* createNewMDIWindow( bool theRT = false );
+ virtual MDIWindow* createNewMDIWindow();
signals:
void selectionChanged();
public slots:
virtual void onCloseView( MDIWindow* );
- virtual void onCreateNewView( bool theRT = false );
+ virtual void onCreateNewView();
virtual void onMaterial();
virtual void onMaterial( int );
virtual void onDelete();
-#ifdef HAVE_OPENCL
- virtual void onShadows( int state );
- virtual void onReflections( int state );
- virtual void onAntialiasing( int state );
-#endif
-
void onWireframe();
void onShading();
void onColor();
Qt::WindowFlags wflags )
: QMainWindow( parent, wflags )
{
-
myView = aView;
myDocument = aDocument;
-
-#ifdef HAVE_OPENCL
-
- myShadowsEnabled = true;
- myReflectionsEnabled = true;
- myAntialiasingEnabled = false;
-
-#endif
}
-MDIWindow::MDIWindow( DocumentCommon* aDocument, QWidget* parent, Qt::WindowFlags wflags, bool theRT )
+MDIWindow::MDIWindow( DocumentCommon* aDocument, QWidget* parent, Qt::WindowFlags wflags)
: QMainWindow( parent, wflags )
{
QFrame *vb = new QFrame( this );
setCentralWidget( vb );
myDocument = aDocument;
- myView = new View( myDocument->getContext(), vb, theRT );
- layout->addWidget( myView );
+ myView = new View (myDocument->getContext(), vb);
+ layout->addWidget (myView);
connect( myView, SIGNAL( selectionChanged() ),
this, SIGNAL( selectionChanged() ) );
- createViewActions();
+
+ createViewActions();
+ createRaytraceActions();
resize( sizeHint() );
setFocusPolicy( Qt::StrongFocus );
-
-#ifdef HAVE_OPENCL
-
- myShadowsEnabled = true;
- myReflectionsEnabled = true;
- myAntialiasingEnabled = false;
-
-#endif
}
MDIWindow::~MDIWindow()
aList->at(View::ViewHlrOffId)->setChecked( true );
}
+void MDIWindow::createRaytraceActions()
+{
+ // populate a tool bar with some actions
+ QToolBar* aToolBar = addToolBar( tr( "Ray-tracing Options" ) );
+
+ QList<QAction*>* aList = myView->getRaytraceActions();
+ aToolBar->addActions( *aList );
+
+ aToolBar->toggleViewAction()->setVisible (true);
+ aList->at (View::ToolRaytracingId)->setChecked (false);
+ aList->at (View::ToolShadowsId)->setChecked (true);
+ aList->at (View::ToolReflectionsId)->setChecked (true);
+ aList->at (View::ToolAntialiasingId)->setChecked (false);
+}
+
void MDIWindow::onWindowActivated ()
{
getDocument()->getApplication()->onSelectionChanged();
}
-
void MDIWindow::dump()
{
-
- QString datadir = (QString(getenv("CASROOT")) + "/../data/images");
+ QString datadir = (QString(qgetenv ("CASROOT").constData()) + "/../data/images");
static QString filter;
filter = "Images Files (*.bmp *.ppm *.png *.jpg *.tiff *.tga *.gif *.exr *.ps *.eps *.tex *.pdf *.svg *.pgf)";
QFileDialog fd ( 0 );
fd.setModal( true );
- fd.setFilter( filter );
+ fd.setNameFilter ( filter );
fd.setWindowTitle( QObject::tr("INF_APP_EXPORT") );
fd.setFileMode( QFileDialog::AnyFile );
int ret = fd.exec();
QApplication::setOverrideCursor( Qt::WaitCursor );
if ( !QFileInfo( file ).completeSuffix().length() )
file += QString( ".bmp" );
+
bool res = myView->dump( (Standard_CString)file.toLatin1().constData() );
QApplication::restoreOverrideCursor();
if ( !res )
{
return QSize( 450, 300 );
}
-
-#ifdef HAVE_OPENCL
-
-void MDIWindow::setRaytracedShadows( int state )
-{
- myView->setRaytracedShadows( state );
- myShadowsEnabled = state;
-}
-
-void MDIWindow::setRaytracedReflections( int state )
-{
- myView->setRaytracedReflections( state );
- myReflectionsEnabled = state;
-}
-
-void MDIWindow::setRaytracedAntialiasing( int state )
-{
- myView->setRaytracedAntialiasing( state );
- myAntialiasingEnabled = state;
-}
-
-#endif
-
-
Q_OBJECT
public:
- MDIWindow( DocumentCommon* aDocument, QWidget* parent, Qt::WindowFlags wflags, bool theRT = false );
+ MDIWindow( DocumentCommon* aDocument, QWidget* parent, Qt::WindowFlags wflags );
MDIWindow( View* aView, DocumentCommon* aDocument, QWidget* parent, Qt::WindowFlags wflags );
~MDIWindow();
void fitAll();
virtual QSize sizeHint() const;
-#ifdef HAVE_OPENCL
-
- void setRaytracedShadows( int state );
- void setRaytracedReflections( int state );
- void setRaytracedAntialiasing( int state );
-
- bool ShadowsEnabled() { return myShadowsEnabled; }
- bool ReflectionsEnabled() { return myReflectionsEnabled; }
- bool AntialiasingEnabled() { return myAntialiasingEnabled; }
-
-#endif
-
signals:
void selectionChanged();
void message(const QString&, int );
protected:
void createViewActions();
+ void createRaytraceActions();
protected:
DocumentCommon* myDocument;
View* myView;
-
-#ifdef HAVE_OPENCL
-
- bool myShadowsEnabled;
- bool myReflectionsEnabled;
- bool myAntialiasingEnabled;
-
-#endif
};
-#endif
-
+#endif
\ No newline at end of file
#include <QFileDialog>
#include <QMouseEvent>
#include <QRubberBand>
+#include <QMdiSubWindow>
+#include <QStyleFactory>
#include <Visual3d_View.hxx>
#include <Graphic3d_ExportFormat.hxx>
#include <Graphic3d_GraphicDriver.hxx>
#include <Graphic3d_TextureEnv.hxx>
-#include <QWindowsStyle>
#if defined(_WIN32) || defined(__WIN32__)
#include <WNT_Window.hxx>
static QCursor* zoomCursor = NULL;
static QCursor* rotCursor = NULL;
-View::View( Handle(AIS_InteractiveContext) theContext, QWidget* parent, bool theRT )
+View::View( Handle(AIS_InteractiveContext) theContext, QWidget* parent )
: QWidget( parent ),
-myIsRT( theRT ),
+myIsRaytracing( false ),
+myIsShadowsEnabled (true),
+myIsReflectionsEnabled (true),
+myIsAntialiasingEnabled (false),
myViewActions( 0 ),
+myRaytraceActions( 0 ),
myBackMenu( NULL )
{
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
myCurZoom = 0;
myRectBand = 0;
- setAttribute(Qt::WA_PaintOnScreen);
+ setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
myCurrentMode = CurAction3d_Nothing;
myHlrModeIsOn = Standard_False;
setMouseTracking( true );
-
+
+ if( myFirst )
+ {
+ init();
+ myFirst = false;
+ }
initViewActions();
initCursors();
void View::init()
{
- if (myView.IsNull())
- myView = myContext->CurrentViewer()->CreateView();
+ if ( myView.IsNull() )
+ myView = myContext->CurrentViewer()->CreateView();
+
#if defined(_WIN32) || defined(__WIN32__)
Aspect_Handle aWindowHandle = (Aspect_Handle )winId();
Handle(WNT_Window) hWnd = new WNT_Window (aWindowHandle);
Handle(Aspect_DisplayConnection) aDispConnection = myContext->CurrentViewer()->Driver()->GetDisplayConnection();
Handle(Xw_Window) hWnd = new Xw_Window (aDispConnection, aWindowHandle);
#endif // WNT
+
myView->SetWindow (hWnd);
- if (!hWnd->IsMapped())
+ if ( !hWnd->IsMapped() )
{
hWnd->Map();
}
myView->SetBackgroundColor (Quantity_NOC_BLACK);
myView->MustBeResized();
- if (myIsRT)
+ if (myIsRaytracing)
myView->SetRaytracingMode();
}
QApplication::restoreOverrideCursor();
}
-void View::setRaytracedShadows( int state )
+void View::SetRaytracedShadows (bool theState)
{
- if ( state )
+ if (theState)
myView->EnableRaytracedShadows();
else
myView->DisableRaytracedShadows();
+
+ myIsShadowsEnabled = theState;
+
+ myContext->UpdateCurrentViewer();
}
-void View::setRaytracedReflections( int state )
+void View::SetRaytracedReflections (bool theState)
{
- if ( state )
+ if (theState)
myView->EnableRaytracedReflections();
else
myView->DisableRaytracedReflections();
+
+ myIsReflectionsEnabled = theState;
+
+ myContext->UpdateCurrentViewer();
}
-void View::setRaytracedAntialiasing( int state )
+void View::onRaytraceAction()
{
- if ( state )
+ QAction* aSentBy = (QAction*)sender();
+
+ if (aSentBy == myRaytraceActions->at (ToolRaytracingId))
+ {
+ bool aState = myRaytraceActions->at (ToolRaytracingId)->isChecked();
+
+ QApplication::setOverrideCursor (Qt::WaitCursor);
+ if (aState)
+ EnableRaytracing();
+ else
+ DisableRaytracing();
+ QApplication::restoreOverrideCursor();
+ }
+
+ if (aSentBy == myRaytraceActions->at (ToolShadowsId))
+ {
+ bool aState = myRaytraceActions->at (ToolShadowsId)->isChecked();
+ SetRaytracedShadows (aState);
+ }
+
+ if (aSentBy == myRaytraceActions->at (ToolReflectionsId))
+ {
+ bool aState = myRaytraceActions->at (ToolReflectionsId)->isChecked();
+ SetRaytracedReflections (aState);
+ }
+
+ if (aSentBy == myRaytraceActions->at (ToolAntialiasingId))
+ {
+ bool aState = myRaytraceActions->at (ToolAntialiasingId)->isChecked();
+ SetRaytracedAntialiasing (aState);
+ }
+}
+
+void View::SetRaytracedAntialiasing (bool theState)
+{
+ if (theState)
myView->EnableRaytracedAntialiasing();
else
myView->DisableRaytracedAntialiasing();
+
+ myIsAntialiasingEnabled = theState;
+
+ myContext->UpdateCurrentViewer();
+}
+
+void View::EnableRaytracing()
+{
+ if (!myIsRaytracing)
+ myView->SetRaytracingMode();
+
+ myIsRaytracing = true;
+
+ myContext->UpdateCurrentViewer();
+}
+
+void View::DisableRaytracing()
+{
+ if (myIsRaytracing)
+ myView->SetRasterizationMode();
+
+ myIsRaytracing = false;
+
+ myContext->UpdateCurrentViewer();
}
void View::updateToggled( bool isOn )
return myViewActions;
}
+QList<QAction*>* View::getRaytraceActions()
+{
+ initRaytraceActions();
+ return myRaytraceActions;
+}
+
/*!
Get paint engine for the OpenGL viewer. [ virtual public ]
*/
myViewActions->insert( ViewHlrOnId, a );
}
+void View::initRaytraceActions()
+{
+ if ( myRaytraceActions )
+ return;
+
+ myRaytraceActions = new QList<QAction*>();
+ QString dir = ApplicationCommonWindow::getResourceDir() + QString( "/" );
+ QAction* a;
+
+ a = new QAction( QPixmap( dir+QObject::tr("ICON_TOOL_RAYTRACING") ), QObject::tr("MNU_TOOL_RAYTRACING"), this );
+ a->setToolTip( QObject::tr("TBR_TOOL_RAYTRACING") );
+ a->setStatusTip( QObject::tr("TBR_TOOL_RAYTRACING") );
+ a->setCheckable( true );
+ a->setChecked( false );
+ connect( a, SIGNAL( activated() ) , this, SLOT( onRaytraceAction() ) );
+ myRaytraceActions->insert( ToolRaytracingId, a );
+
+ 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 );
+
+ 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 );
+
+ 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 );
+}
+
void View::mousePressEvent( QMouseEvent* e )
{
if ( e->button() == Qt::LeftButton )
void View::Popup( const int /*x*/, const int /*y*/ )
{
ApplicationCommonWindow* stApp = ApplicationCommonWindow::getApplication();
- QWorkspace* ws = ApplicationCommonWindow::getWorkspace();
- QWidget* w = ws->activeWindow();
+ QMdiArea* ws = ApplicationCommonWindow::getWorkspace();
+ QMdiSubWindow* w = ws->activeSubWindow();
if ( myContext->NbSelected() )
{
QList<QAction*>* aList = stApp->getToolActions();
if ( !myRectBand )
{
myRectBand = new QRubberBand( QRubberBand::Rectangle, this );
- myRectBand->setStyle(new QWindowsStyle);
+ myRectBand->setStyle( QStyleFactory::create("windows") );
myRectBand->setGeometry( aRect );
myRectBand->show();
QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"), "",
tr("All Image Files (*.bmp *.gif *.jpg *.jpeg *.png *.tga)"));
- Handle(Graphic3d_TextureEnv) aTexture = new Graphic3d_TextureEnv( fileName.toAscii().data() );
+ Handle(Graphic3d_TextureEnv) aTexture = new Graphic3d_TextureEnv( fileName.toLatin1().data() );
myView->SetTextureEnv (aTexture);
myView->SetSurfaceDetail (V3d_TEX_ENVIRONMENT);
enum ViewAction { ViewFitAllId, ViewFitAreaId, ViewZoomId, ViewPanId, ViewGlobalPanId,
ViewFrontId, ViewBackId, ViewTopId, ViewBottomId, ViewLeftId, ViewRightId,
ViewAxoId, ViewRotationId, ViewResetId, ViewHlrOffId, ViewHlrOnId };
+ enum RaytraceAction { ToolRaytracingId, ToolShadowsId, ToolReflectionsId, ToolAntialiasingId };
- View( Handle(AIS_InteractiveContext) theContext,
- QWidget* parent,
- bool theRT = false );
+ View( Handle(AIS_InteractiveContext) theContext, QWidget* parent );
~View();
virtual void init();
bool dump( Standard_CString theFile );
QList<QAction*>* getViewActions();
+ QList<QAction*>* getRaytraceActions();
void noActiveActions();
bool isShadingMode();
- void setRaytracedShadows( int state );
- void setRaytracedReflections( int state );
- void setRaytracedAntialiasing( int state );
+ void EnableRaytracing();
+ void DisableRaytracing();
+
+ void SetRaytracedShadows (bool theState);
+ void SetRaytracedReflections (bool theState);
+ void SetRaytracedAntialiasing (bool theState);
+
+ bool IsRaytracingMode() const { return myIsRaytracing; }
+ bool IsShadowsEnabled() const { return myIsShadowsEnabled; }
+ bool IsReflectionsEnabled() const { return myIsReflectionsEnabled; }
+ bool IsAntialiasingEnabled() const { return myIsAntialiasingEnabled; }
static QString GetMessages( int type,TopAbs_ShapeEnum aSubShapeType,
TopAbs_ShapeEnum aShapeType );
void updateToggled( bool );
void onBackground();
void onEnvironmentMap();
+ void onRaytraceAction();
protected:
virtual void paintEvent( QPaintEvent* );
private:
void initCursors();
void initViewActions();
+ void initRaytraceActions();
void DragEvent( const int x, const int y, const int TheState );
void InputEvent( const int x, const int y );
void MoveEvent( const int x, const int y );
const int MaxX, const int MaxY, const bool Draw );
private:
- bool myIsRT;
+ bool myIsRaytracing;
+ bool myIsShadowsEnabled;
+ bool myIsReflectionsEnabled;
+ bool myIsAntialiasingEnabled;
+
bool myFirst;
bool myDrawRect; // set when a rect is used for selection or magnify
Handle(V3d_View) myView;
Quantity_Factor myCurZoom;
Standard_Boolean myHlrModeIsOn;
QList<QAction*>* myViewActions;
+ QList<QAction*>* myRaytraceActions;
QMenu* myBackMenu;
QRubberBand* myRectBand; //!< selection rectangle rubber band
};
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IESample", "IESample.vcxproj", "{7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IESample", "IESample.vcxproj", "{7972FDD8-9612-3401-827F-C8DF8E2689B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}.Debug|Win32.ActiveCfg = Debug|Win32
- {7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}.Debug|Win32.Build.0 = Debug|Win32
- {7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}.Release|Win32.ActiveCfg = Release|Win32
- {7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}.Release|Win32.Build.0 = Release|Win32
+ {7972FDD8-9612-3401-827F-C8DF8E2689B5}.Debug|Win32.ActiveCfg = Debug|Win32
+ {7972FDD8-9612-3401-827F-C8DF8E2689B5}.Debug|Win32.Build.0 = Debug|Win32
+ {7972FDD8-9612-3401-827F-C8DF8E2689B5}.Release|Win32.ActiveCfg = Release|Win32
+ {7972FDD8-9612-3401-827F-C8DF8E2689B5}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
-EndGlobal
\ No newline at end of file
+EndGlobal
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IESample", "IESample.vcproj", "{7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IESample", "IESample.vcproj", "{AD4DADCB-F15E-37FD-B3AA-88504FAAF4FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}.Debug|Win32.ActiveCfg = Debug|Win32
- {7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}.Debug|Win32.Build.0 = Debug|Win32
- {7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}.Release|Win32.ActiveCfg = Release|Win32
- {7FD0453F-8AC0-3EE3-9C11-DD413EF20A44}.Release|Win32.Build.0 = Release|Win32
+ {AD4DADCB-F15E-37FD-B3AA-88504FAAF4FD}.Debug|Win32.ActiveCfg = Debug|Win32
+ {AD4DADCB-F15E-37FD-B3AA-88504FAAF4FD}.Debug|Win32.Build.0 = Debug|Win32
+ {AD4DADCB-F15E-37FD-B3AA-88504FAAF4FD}.Release|Win32.ActiveCfg = Release|Win32
+ {AD4DADCB-F15E-37FD-B3AA-88504FAAF4FD}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
TARGET = IESample
-SAMPLESROOT = $$(CASROOT)/samples/qt
+SAMPLESROOT = $$(SAMPLESROOT)
-HEADERS = src/*.h \
- $${SAMPLESROOT}/Common/src/*.h \
+HEADERS = $${SAMPLESROOT}/Common/src/*.h \
$${SAMPLESROOT}/Interface/src/*.h
SOURCES = src/*.cxx \
INCLUDEPATH += $$quote($${SAMPLESROOT}/Common/src)
INCLUDEPATH += $$quote($${SAMPLESROOT}/Interface/src)
-DEFINES = CSFDB
+OCCT_DEFINES = $$(CSF_DEFINES)
+
+DEFINES = CSFDB $$split(OCCT_DEFINES, ;)
unix {
UNAME = $$system(uname -s)
CONFIG(debug, debug|release) {
DESTDIR = ./$$UNAME/bind
OBJECTS_DIR = ./$$UNAME/objd
- MOC_DIR = ./$$UNAME/srcd
+ MOC_DIR = ./$$UNAME/mocd
} else {
DESTDIR = ./$$UNAME/bin
OBJECTS_DIR = ./$$UNAME/obj
- MOC_DIR = ./$$UNAME/src
+ MOC_DIR = ./$$UNAME/moc
}
MACOSX_USE_GLX = $$(MACOSX_USE_GLX)
CONFIG(debug, debug|release) {
DEFINES += _DEBUG
+ DESTDIR = ./win$(ARCH)/$(VCVER)/bind
+ OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/objd
+ MOC_DIR = ./win$(ARCH)/$(VCVER)/mocd
!contains(QMAKE_HOST.arch, x86_64) {
- LIBS = -L$(CSF_OPT_LIB32D)
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1310) {
- DESTDIR = ./win32/vc7/bind
- OBJECTS_DIR = ./win32/vc7/objd
- MOC_DIR = ./win32/vc7/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) {
- DESTDIR = ./win32/vc8/bind
- OBJECTS_DIR = ./win32/vc8/objd
- MOC_DIR = ./win32/vc8/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) {
- DESTDIR = ./win32/vc9/bind
- OBJECTS_DIR = ./win32/vc9/objd
- MOC_DIR = ./win32/vc9/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) {
- DESTDIR = ./win32/vc10/bind
- OBJECTS_DIR = ./win32/vc10/objd
- MOC_DIR = ./win32/vc10/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) {
- DESTDIR = ./win32/vc11/bind
- OBJECTS_DIR = ./win32/vc11/objd
- MOC_DIR = ./win32/vc11/srcd
- }
+ LIBS = -L$(CSF_OPT_LIB32D)
} else {
- LIBS = -L$(CSF_OPT_LIB64D)
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) {
- DESTDIR = ./win64/vc8/bind
- OBJECTS_DIR = ./win64/vc8/objd
- MOC_DIR = ./win64/vc8/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) {
- DESTDIR = ./win64/vc9/bind
- OBJECTS_DIR = ./win64/vc9/objd
- MOC_DIR = ./win64/vc9/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) {
- DESTDIR = ./win64/vc10/bind
- OBJECTS_DIR = ./win64/vc10/objd
- MOC_DIR = ./win64/vc10/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) {
- DESTDIR = ./win64/vc11/bind
- OBJECTS_DIR = ./win64/vc11/objd
- MOC_DIR = ./win64/vc11/srcd
- }
+ LIBS = -L$(CSF_OPT_LIB64D)
}
} else {
DEFINES += NDEBUG
+ DESTDIR = ./win$(ARCH)/$(VCVER)/bin
+ OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/obj
+ MOC_DIR = ./win$(ARCH)/$(VCVER)/moc
!contains(QMAKE_HOST.arch, x86_64) {
- LIBS = -L$(CSF_OPT_LIB32)
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1310) {
- DESTDIR = ./win32/vc7/bin
- OBJECTS_DIR = ./win32/vc7/obj
- MOC_DIR = ./win32/vc7/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) {
- DESTDIR = ./win32/vc8/bin
- OBJECTS_DIR = ./win32/vc8/obj
- MOC_DIR = ./win32/vc8/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) {
- DESTDIR = ./win32/vc9/bin
- OBJECTS_DIR = ./win32/vc9/obj
- MOC_DIR = ./win32/vc9/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) {
- DESTDIR = ./win32/vc10/bin
- OBJECTS_DIR = ./win32/vc10/obj
- MOC_DIR = ./win32/vc10/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) {
- DESTDIR = ./win32/vc11/bin
- OBJECTS_DIR = ./win32/vc11/obj
- MOC_DIR = ./win32/vc11/src
- }
+ LIBS = -L$(CSF_OPT_LIB32)
} else {
- LIBS = -L$(CSF_OPT_LIB64)
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) {
- DESTDIR = ./win64/vc8/bin
- OBJECTS_DIR = ./win64/vc8/obj
- MOC_DIR = ./win64/vc8/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) {
- DESTDIR = ./win64/vc9/bin
- OBJECTS_DIR = ./win64/vc9/obj
- MOC_DIR = ./win64/vc9/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) {
- DESTDIR = ./win64/vc10/bin
- OBJECTS_DIR = ./win64/vc10/obj
- MOC_DIR = ./win64/vc10/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) {
- DESTDIR = ./win64/vc11/bin
- OBJECTS_DIR = ./win64/vc11/obj
- MOC_DIR = ./win64/vc11/src
- }
+ LIBS = -L$(CSF_OPT_LIB64)
}
}
DEFINES +=WNT WIN32 NO_COMMONSAMPLE_EXPORTS NO_IESAMPLE_EXPORTS
win32: copy_res.commands = type ${QMAKE_FILE_IN} > $${RES_DIR}/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
unix: copy_res.commands = cp -f ${QMAKE_FILE_IN} $${RES_DIR}
QMAKE_EXTRA_COMPILERS += copy_res
+#QMAKE_CXXFLAGS += /wd4996
+
+greaterThan(QT_MAJOR_VERSION, 4) {
+ QT += widgets
+}
call "%~dp0..\..\..\env.bat" %1 %2 %3
+SET "SAMPLESROOT=%~dp0.."
SET "RES_DIR=%~dp0win%ARCH%\%VCVER%\res"
SET "CSF_ResourcesDefaults=%RES_DIR%"
SET "CSF_IEResourcesDefaults=%RES_DIR%"
call "%~dp0env.bat" %1 %2 %3
+set EXT=vcproj
+
if not "%1" == "" (
if /I "%1" == "vc8" (
set VCVER=vc8
set "VCVARS=%VS90COMNTOOLS%..\..\VC\vcvarsall.bat"
) else if /I "%1" == "vc10" (
set VCVER=vc10
+ set EXT=vcxproj
set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
) else if /I "%1" == "vc11" (
set VCVER=vc11
+ set EXT=vcxproj
set "VCVARS=%VS110COMNTOOLS%..\..\VC\vcvarsall.bat"
) else (
echo Error: first argument ^(%1^) should specify supported version of Visual C++,
call "%VCVARS%" %VCARCH%
-qmake -tp vc -r IESample.pro
+qmake -tp vc -o IESample.%EXT% IESample.pro
#include <QMessageBox>
#include <stdlib.h>
+#include <QMdiSubWindow>
ApplicationWindow::ApplicationWindow()
: ApplicationCommonWindow( ),
void ApplicationWindow::updateFileActions()
{
- if ( getWorkspace()->windowList().isEmpty() )
+ if ( myDocuments.isEmpty() )
{
if ( !isDocument() )
{
bool stat = translate( type, true );
if ( stat )
{
- DocumentCommon* doc = ((MDIWindow*) getWorkspace()->activeWindow())->getDocument();
+ DocumentCommon* doc = qobject_cast<MDIWindow*>( getWorkspace()->activeSubWindow()->widget() )->getDocument();
doc->fitAll();
}
}
if ( type < 0 )
return;
- bool stat = translate( type, false );
+ translate( type, false );
}
int ApplicationWindow::translationFormat( const QAction* a )
bool ApplicationWindow::translate( const int format, const bool import )
{
static Translate* anTrans = createTranslator();
- DocumentCommon* doc = ((MDIWindow*) getWorkspace()->activeWindow())->getDocument();
+ DocumentCommon* doc = qobject_cast<MDIWindow*>( getWorkspace()->activeSubWindow()->widget() )->getDocument();
Handle(AIS_InteractiveContext) context = doc->getContext();
bool status;
if ( import )
{
ApplicationCommonWindow::onSelectionChanged();
- QWorkspace* ws = getWorkspace();
- DocumentCommon* doc = ((MDIWindow*)ws->activeWindow())->getDocument();
+ QMdiArea* ws = getWorkspace();
+ DocumentCommon* doc = qobject_cast<MDIWindow*>( ws->activeSubWindow()->widget() )->getDocument();
Handle(AIS_InteractiveContext) context = doc->getContext();
int numSel = context->NbSelected();
QString ApplicationWindow::getIEResourceDir()
{
- static QString resDir( ::getenv( "CSF_IEResourcesDefaults" ) );
- return resDir;
+ static QString aResourceDir =
+ QString::fromUtf8 (qgetenv ("CSF_IEResourcesDefaults").constData());
+
+ return aResourceDir;
}
void ApplicationWindow::onExportImage()
{
- MDIWindow* w = (MDIWindow*)getWorkspace()->activeWindow();
+ MDIWindow* w = qobject_cast<MDIWindow*>( getWorkspace()->activeSubWindow()->widget() );
if ( w )
w->dump();
}
#include <QFileDialog>
#include <QApplication>
#include <QWidget>
+#include <QStyleFactory>
#include <AIS_Shape.hxx>
#include <AIS_InteractiveObject.hxx>
TranslateDlg::TranslateDlg( QWidget* parent, Qt::WindowFlags flags, bool modal )
: QFileDialog( parent, flags )
{
+ setOption( QFileDialog::DontUseNativeDialog );
setModal( modal );
+
QGridLayout* grid = ::qobject_cast<QGridLayout*>( layout() );
if( grid )
if ( !QFileInfo( file ).completeSuffix().length() )
{
- QString selFilter = theDlg->selectedFilter();
+ QString selFilter = theDlg->selectedNameFilter();
int idx = selFilter.indexOf( "(*." );
if ( idx != -1 )
{
cout << filter.toLatin1().constData() << endl;
QStringList filters = filter.split( "\t" );
- myDlg->setFilters( filters );
+ myDlg->setNameFilters ( filters );
if ( import )
{
((QFileDialog*)myDlg)->setFileMode( QFileDialog::AnyFile );
}
- QString datadir = (QString(getenv("CASROOT")) + QObject::tr( QString("INF_PATH_%1").arg( format ).toLatin1().constData() ) );
+ QString datadir = (QString (qgetenv ("CASROOT").constData()) + QObject::tr( QString("INF_PATH_%1").arg( format ).toLatin1().constData() ) );
myDlg->clear();
{
bool ok = aReader.TransferRoot( n );
int nbs = aReader.NbShapes();
- if ( nbs > 0 )
+ if ( ok == true && nbs > 0 )
{
aSequence = new TopTools_HSequenceOfShape();
for ( int i = 1; i <= nbs; i++ )
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tutorial", "Tutorial.vcxproj", "{59DEDC8A-A5ED-31E8-8F2B-8D996E3A41D6}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tutorial", "Tutorial.vcxproj", "{E417B143-8CB4-3EF0-8247-DA6F67FA3FCE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {59DEDC8A-A5ED-31E8-8F2B-8D996E3A41D6}.Debug|Win32.ActiveCfg = Debug|Win32
- {59DEDC8A-A5ED-31E8-8F2B-8D996E3A41D6}.Debug|Win32.Build.0 = Debug|Win32
- {59DEDC8A-A5ED-31E8-8F2B-8D996E3A41D6}.Release|Win32.ActiveCfg = Release|Win32
- {59DEDC8A-A5ED-31E8-8F2B-8D996E3A41D6}.Release|Win32.Build.0 = Release|Win32
+ {E417B143-8CB4-3EF0-8247-DA6F67FA3FCE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E417B143-8CB4-3EF0-8247-DA6F67FA3FCE}.Debug|Win32.Build.0 = Debug|Win32
+ {E417B143-8CB4-3EF0-8247-DA6F67FA3FCE}.Release|Win32.ActiveCfg = Release|Win32
+ {E417B143-8CB4-3EF0-8247-DA6F67FA3FCE}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
TARGET = Tutorial
-SAMPLESROOT = $$(CASROOT)/samples/qt
+SAMPLESROOT = $$(SAMPLESROOT)
HEADERS = src/*.h \
$${SAMPLESROOT}/Common/src/*.h \
INCLUDEPATH += $$quote($${SAMPLESROOT}/Common/src)
INCLUDEPATH += $$quote($${SAMPLESROOT}/Interface/src)
-DEFINES = CSFDB
+OCCT_DEFINES = $$(CSF_DEFINES)
+
+DEFINES = CSFDB $$split(OCCT_DEFINES, ;)
unix {
UNAME = $$system(uname -s)
CONFIG(debug, debug|release) {
DESTDIR = ./$$UNAME/bind
OBJECTS_DIR = ./$$UNAME/objd
- MOC_DIR = ./$$UNAME/srcd
+ MOC_DIR = ./$$UNAME/mocd
} else {
DESTDIR = ./$$UNAME/bin
OBJECTS_DIR = ./$$UNAME/obj
- MOC_DIR = ./$$UNAME/src
+ MOC_DIR = ./$$UNAME/moc
}
MACOSX_USE_GLX = $$(MACOSX_USE_GLX)
CONFIG(debug, debug|release) {
DEFINES += _DEBUG
+ DESTDIR = ./win$(ARCH)/$(VCVER)/bind
+ OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/objd
+ MOC_DIR = ./win$(ARCH)/$(VCVER)/mocd
!contains(QMAKE_HOST.arch, x86_64) {
- LIBS = -L$(CSF_OPT_LIB32D)
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1310) {
- DESTDIR = ./win32/vc7/bind
- OBJECTS_DIR = ./win32/vc7/objd
- MOC_DIR = ./win32/vc7/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) {
- DESTDIR = ./win32/vc8/bind
- OBJECTS_DIR = ./win32/vc8/objd
- MOC_DIR = ./win32/vc8/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) {
- DESTDIR = ./win32/vc9/bind
- OBJECTS_DIR = ./win32/vc9/objd
- MOC_DIR = ./win32/vc9/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) {
- DESTDIR = ./win32/vc10/bind
- OBJECTS_DIR = ./win32/vc10/objd
- MOC_DIR = ./win32/vc10/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) {
- DESTDIR = ./win32/vc11/bind
- OBJECTS_DIR = ./win32/vc11/objd
- MOC_DIR = ./win32/vc11/srcd
- }
+ LIBS = -L$(CSF_OPT_LIB32D)
} else {
- LIBS = -L$(CSF_OPT_LIB64D)
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) {
- DESTDIR = ./win64/vc8/bind
- OBJECTS_DIR = ./win64/vc8/objd
- MOC_DIR = ./win64/vc8/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) {
- DESTDIR = ./win64/vc9/bind
- OBJECTS_DIR = ./win64/vc9/objd
- MOC_DIR = ./win64/vc9/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) {
- DESTDIR = ./win64/vc10/bind
- OBJECTS_DIR = ./win64/vc10/objd
- MOC_DIR = ./win64/vc10/srcd
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) {
- DESTDIR = ./win64/vc11/bind
- OBJECTS_DIR = ./win64/vc11/objd
- MOC_DIR = ./win64/vc11/srcd
- }
+ LIBS = -L$(CSF_OPT_LIB64D)
}
} else {
DEFINES += NDEBUG
+ DESTDIR = ./win$(ARCH)/$(VCVER)/bin
+ OBJECTS_DIR = ./win$(ARCH)/$(VCVER)/obj
+ MOC_DIR = ./win$(ARCH)/$(VCVER)/moc
!contains(QMAKE_HOST.arch, x86_64) {
- LIBS = -L$(CSF_OPT_LIB32)
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1310) {
- DESTDIR = ./win32/vc7/bin
- OBJECTS_DIR = ./win32/vc7/obj
- MOC_DIR = ./win32/vc7/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) {
- DESTDIR = ./win32/vc8/bin
- OBJECTS_DIR = ./win32/vc8/obj
- MOC_DIR = ./win32/vc8/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) {
- DESTDIR = ./win32/vc9/bin
- OBJECTS_DIR = ./win32/vc9/obj
- MOC_DIR = ./win32/vc9/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) {
- DESTDIR = ./win32/vc10/bin
- OBJECTS_DIR = ./win32/vc10/obj
- MOC_DIR = ./win32/vc10/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) {
- DESTDIR = ./win32/vc11/bin
- OBJECTS_DIR = ./win32/vc11/obj
- MOC_DIR = ./win32/vc11/src
- }
+ LIBS = -L$(CSF_OPT_LIB32)
} else {
- LIBS = -L$(CSF_OPT_LIB64)
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1400) {
- DESTDIR = ./win64/vc8/bin
- OBJECTS_DIR = ./win64/vc8/obj
- MOC_DIR = ./win64/vc8/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1500) {
- DESTDIR = ./win64/vc9/bin
- OBJECTS_DIR = ./win64/vc9/obj
- MOC_DIR = ./win64/vc9/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1600) {
- DESTDIR = ./win64/vc10/bin
- OBJECTS_DIR = ./win64/vc10/obj
- MOC_DIR = ./win64/vc10/src
- }
- contains(QMAKE_COMPILER_DEFINES, _MSC_VER=1700) {
- DESTDIR = ./win64/vc11/bin
- OBJECTS_DIR = ./win64/vc11/obj
- MOC_DIR = ./win64/vc11/src
- }
+ LIBS = -L$(CSF_OPT_LIB64)
}
}
DEFINES +=WNT WIN32 NO_COMMONSAMPLE_EXPORTS NO_IESAMPLE_EXPORTS
win32: copy_res.commands = type ${QMAKE_FILE_IN} > $${RES_DIR}/${QMAKE_FILE_BASE}${QMAKE_FILE_EXT}
unix: copy_res.commands = cp -f ${QMAKE_FILE_IN} $${RES_DIR}
QMAKE_EXTRA_COMPILERS += copy_res
+#QMAKE_CXXFLAGS += /wd4996
+greaterThan(QT_MAJOR_VERSION, 4) {
+ QT += widgets
+}
\ No newline at end of file
call "%~dp0..\..\..\env.bat" %1 %2 %3
+SET "SAMPLESROOT=%~dp0.."
SET "RES_DIR=%~dp0win%ARCH%\%VCVER%\res"
SET "CSF_ResourcesDefaults=%RES_DIR%"
SET "CSF_TutorialResourcesDefaults=%RES_DIR%"
-
call "%~dp0env.bat" %1 %2 %3
+set EXT=vcproj
+
if not "%1" == "" (
if /I "%1" == "vc8" (
set VCVER=vc8
set "VCVARS=%VS90COMNTOOLS%..\..\VC\vcvarsall.bat"
) else if /I "%1" == "vc10" (
set VCVER=vc10
+ set EXT=vcxproj
set "VCVARS=%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"
) else if /I "%1" == "vc11" (
set VCVER=vc11
+ set EXT=vcxproj
set "VCVARS=%VS110COMNTOOLS%..\..\VC\vcvarsall.bat"
) else (
echo Error: first argument ^(%1^) should specify supported version of Visual C++,
call "%VCVARS%" %VCARCH%
-qmake -tp vc -r Tutorial.pro
+qmake -tp vc -o Tutorial.%EXT% Tutorial.pro
#include <QFileDialog>
#include <QStatusBar>
+#include <QMdiSubWindow>
ApplicationTut::ApplicationTut()
: ApplicationCommonWindow( )
void ApplicationTut::updateFileActions()
{
- if ( getWorkspace()->windowList().isEmpty() )
+ if ( getWorkspace()->subWindowList().isEmpty() )
{
if ( !isDocument() )
{
void ApplicationTut::onMakeBottleAction()
{
- QWorkspace* ws = ApplicationCommonWindow::getWorkspace();
- DocumentTut* doc = (DocumentTut*)((MDIWindow*)ws->activeWindow())->getDocument();
+ QMdiArea* ws = ApplicationCommonWindow::getWorkspace();
+ DocumentTut* doc = (DocumentTut*)( qobject_cast<MDIWindow*>( ws->activeSubWindow()->widget() )->getDocument() );
statusBar()->showMessage( QObject::tr("INF_MAKE_BOTTLE"), 5000 );
doc->onMakeBottle();
statusBar()->showMessage(QObject::tr("INF_DONE"));
QString ApplicationTut::getTutResourceDir()
{
- static QString resDir( ::getenv( "CSF_TutorialResourcesDefaults" ) );
- return resDir;
+ static QString resDir (qgetenv ("CSF_TutorialResourcesDefaults").constData());
+ return resDir;
}