From: dbp Date: Fri, 23 May 2014 13:23:16 +0000 (+0400) Subject: 0024951: Qt samples - fix compilation after changes in Raytracing API X-Git-Tag: V6_8_0_beta~279 X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=2ad228f691a9310a51bd5c60d61758702c18ea5a;p=occt-copy.git 0024951: Qt samples - fix compilation after changes in Raytracing API Compilation errors in qt samples were fixed. --- diff --git a/samples/qt/Common/src/ApplicationCommon.cxx b/samples/qt/Common/src/ApplicationCommon.cxx index c30912ebd9..e5b93cd067 100755 --- a/samples/qt/Common/src/ApplicationCommon.cxx +++ b/samples/qt/Common/src/ApplicationCommon.cxx @@ -42,7 +42,7 @@ myStdToolBar( 0 ) stWs = new QMdiArea( vb ); layout->addWidget( stWs ); setCentralWidget( vb ); - + createStandardOperations(); createCasCadeOperations(); @@ -122,7 +122,7 @@ void ApplicationCommonWindow::createStandardOperations() // create preferences menu QMenu* aPrefMenu = new QMenu( QObject::tr("MNU_PREFERENCES") ); aPrefMenu->addAction( filePrefUseVBOAction ); - + // populate a menu with all actions myFilePopup = new QMenu( this ); myFilePopup = menuBar()->addMenu( QObject::tr("MNU_FILE") ); @@ -132,25 +132,25 @@ void ApplicationCommonWindow::createStandardOperations() myFilePopup->addMenu( aPrefMenu ); myFileSeparator = myFilePopup->addSeparator(); myFilePopup->addAction( fileQuitAction ); - - // add a view menu + + // add a view menu QMenu * view = new QMenu( this ); - + view = menuBar()->addMenu( QObject::tr("MNU_VIEW") ); view->addAction( viewToolAction ); view->addAction( viewStatusAction ); - - // add a help menu + + // add a help menu QMenu * help = new QMenu( this ); menuBar()->addSeparator(); help = menuBar()->addMenu( QObject::tr("MNU_HELP") ); help->addAction( helpAboutAction ); - // populate a tool bar with some actions + // populate a tool bar with some actions myStdToolBar = addToolBar( tr( "File Operations" ) ); myStdToolBar->addAction( fileNewAction ); myStdToolBar->addAction( helpAboutAction ); - + myStdActions.at(FileCloseId)->setEnabled(myDocuments.count() > 0); myStdActions.at(FilePrefUseVBOId)->setEnabled( true ); @@ -281,8 +281,8 @@ void ApplicationCommonWindow::createWindowPopup() if ( !myWindowPopup ) { myWindowPopup = new QMenu( QObject::tr( "MNU_WINDOW" ), this ); - connect( myWindowPopup, SIGNAL( aboutToShow() ), - this, SLOT( windowsMenuAboutToShow() ) ); + connect( myWindowPopup, SIGNAL( aboutToShow() ), + this, SLOT( windowsMenuAboutToShow() ) ); } } @@ -315,7 +315,7 @@ void ApplicationCommonWindow::windowsMenuAboutToShow() QList 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 ); @@ -328,7 +328,7 @@ void ApplicationCommonWindow::windowsMenuActivated( bool checked ) { QAction* aSender = qobject_cast( sender() ); if ( !aSender ) - return; + return; QWidget * w = stWs->subWindowList().at( aSender->data().toInt() ); if ( w && checked ) w->setFocus(); @@ -351,29 +351,29 @@ void ApplicationCommonWindow::updateFileActions() if ( !myIsDocuments ) { QAction *fileQuitAction, *windowAction; - QList aListActions = myFilePopup->actions(); - for ( int i = 0; i < aListActions.size(); i++ ) + QList aListActions = myFilePopup->actions(); + for ( int i = 0; i < aListActions.size(); i++ ) { if( aListActions.at( i )->text() == QObject::tr("MNU_QUIT") ) { - fileQuitAction = aListActions.at( i ); - break; + fileQuitAction = aListActions.at( i ); + break; } } - - if( !fileQuitAction ) + + if( !fileQuitAction ) return; myIsDocuments = true; myCasCadeBar->show(); - QList aListMenuActions = menuBar()->actions(); - for ( int i = 0; i < aListMenuActions.size(); i++ ) + QList aListMenuActions = menuBar()->actions(); + for ( int i = 0; i < aListMenuActions.size(); i++ ) { if( aListMenuActions.at( i )->text() == QObject::tr("MNU_HELP") ) { - windowAction= aListMenuActions.at( i ); - break; + windowAction= aListMenuActions.at( i ); + break; } } @@ -384,9 +384,9 @@ void ApplicationCommonWindow::updateFileActions() } else { - myIsDocuments = false; - myCasCadeBar->hide(); - menuBar()->removeAction( myWindowPopup->menuAction() ); + myIsDocuments = false; + myCasCadeBar->hide(); + menuBar()->removeAction( myWindowPopup->menuAction() ); } } } @@ -459,30 +459,30 @@ void ApplicationCommonWindow::onCloseDocument(DocumentCommon* theDoc) void ApplicationCommonWindow::onViewToolBar() { - bool show = myStdActions.at( ViewToolId )->isChecked(); - if ( show == myStdToolBar->isVisible() ) - return; - if ( show ) - myStdToolBar->show(); - else - myStdToolBar->hide(); + bool show = myStdActions.at( ViewToolId )->isChecked(); + if ( show == myStdToolBar->isVisible() ) + return; + if ( show ) + myStdToolBar->show(); + else + myStdToolBar->hide(); } void ApplicationCommonWindow::onViewStatusBar() { - bool show = myStdActions.at( ViewStatusId )->isChecked(); - if ( show == statusBar()->isVisible() ) - return; - if ( show ) - statusBar()->show(); - else - statusBar()->hide(); + bool show = myStdActions.at( ViewStatusId )->isChecked(); + if ( show == statusBar()->isVisible() ) + return; + if ( show ) + statusBar()->show(); + else + statusBar()->hide(); } void ApplicationCommonWindow::onAbout() { - QMessageBox::information( this, QObject::tr( "TIT_ABOUT" ), QObject::tr( "INF_ABOUT" ), QObject::tr("BTN_OK" ), - QString::null, QString::null, 0, 0 ); + QMessageBox::information( this, QObject::tr( "TIT_ABOUT" ), QObject::tr( "INF_ABOUT" ), QObject::tr("BTN_OK" ), + QString::null, QString::null, 0, 0 ); } void ApplicationCommonWindow::onCreateNewView() @@ -505,37 +505,37 @@ void ApplicationCommonWindow::onWindowActivated ( QWidget * w ) void ApplicationCommonWindow::onToolAction() { - QAction* sentBy = (QAction*) sender(); - QMdiArea* ws = ApplicationCommonWindow::getWorkspace(); - DocumentCommon* doc = qobject_cast( ws->activeSubWindow()->widget() )->getDocument(); + QAction* sentBy = (QAction*) sender(); + QMdiArea* ws = ApplicationCommonWindow::getWorkspace(); + DocumentCommon* doc = qobject_cast( ws->activeSubWindow()->widget() )->getDocument(); - if( sentBy == myToolActions.at( ToolWireframeId ) ) - doc->onWireframe(); + if( sentBy == myToolActions.at( ToolWireframeId ) ) + doc->onWireframe(); - if( sentBy == myToolActions.at( ToolShadingId ) ) - doc->onShading(); + if( sentBy == myToolActions.at( ToolShadingId ) ) + doc->onShading(); - if( sentBy == myToolActions.at( ToolColorId ) ) - doc->onColor(); + if( sentBy == myToolActions.at( ToolColorId ) ) + doc->onColor(); - if( sentBy == myToolActions.at( ToolMaterialId ) ) - doc->onMaterial(); + if( sentBy == myToolActions.at( ToolMaterialId ) ) + doc->onMaterial(); - if( sentBy == myToolActions.at( ToolTransparencyId ) ) - doc->onTransparency(); + if( sentBy == myToolActions.at( ToolTransparencyId ) ) + doc->onTransparency(); - if( sentBy == myToolActions.at( ToolDeleteId ) ) - doc->onDelete(); + if( sentBy == myToolActions.at( ToolDeleteId ) ) + doc->onDelete(); } void ApplicationCommonWindow::onSelectionChanged() { QMdiArea* ws = ApplicationCommonWindow::getWorkspace(); - DocumentCommon* doc; + DocumentCommon* doc; if( !qobject_cast( ws->activeSubWindow()->widget() ) ) - return; - + return; + doc = ( qobject_cast( ws->activeSubWindow()->widget() ) )->getDocument(); Handle(AIS_InteractiveContext) context = doc->getContext(); @@ -609,5 +609,3 @@ QToolBar* ApplicationCommonWindow::getCasCadeBar() { return myCasCadeBar; } - - diff --git a/samples/qt/Common/src/DocumentCommon.cxx b/samples/qt/Common/src/DocumentCommon.cxx index 66737667ed..134846e6c0 100755 --- a/samples/qt/Common/src/DocumentCommon.cxx +++ b/samples/qt/Common/src/DocumentCommon.cxx @@ -74,7 +74,7 @@ DocumentCommon::~DocumentCommon() ApplicationCommonWindow* DocumentCommon::getApplication() { - return myApp; + return myApp; } MDIWindow* DocumentCommon::createNewMDIWindow() @@ -87,9 +87,9 @@ void DocumentCommon::onCreateNewView() { QMdiArea* ws = myApp->getWorkspace(); MDIWindow* w = createNewMDIWindow(); - - if (!w) - return; + + if (!w) + return; ws->addSubWindow (w); myViews.append (w); @@ -97,14 +97,14 @@ void DocumentCommon::onCreateNewView() connect( w, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); connect( w, SIGNAL( message( const QString&, int ) ), - myApp->statusBar(), SLOT( showMessage( const QString&, int ) ) ); + myApp->statusBar(), SLOT( showMessage( const QString&, int ) ) ); connect( w, SIGNAL( sendCloseView( MDIWindow* ) ), - this, SLOT( onCloseView( MDIWindow* ) ) ); + this, SLOT( onCloseView( MDIWindow* ) ) ); - QString aName; - w->setWindowTitle( aName.sprintf( "Document %d:%d", myIndex, ++myNbViews ) ); + QString aName; + w->setWindowTitle( aName.sprintf( "Document %d:%d", myIndex, ++myNbViews ) ); QString dir = ApplicationCommonWindow::getResourceDir() + QString( "/" ); - + w->setWindowIcon( QPixmap( dir + QObject::tr("ICON_DOC") ) ); if ( ws->subWindowList().isEmpty() ) @@ -113,10 +113,10 @@ void DocumentCommon::onCreateNewView() // in the main menu if showMaximized() is called for a non-visible child window // Therefore calling show() first... w->show(); - w->showMaximized(); + w->showMaximized(); } else - w->show(); + w->show(); w->setFocus(); @@ -134,9 +134,9 @@ void DocumentCommon::removeView(MDIWindow* theView) { if ( myViews.count( theView ) ) { - myViews.removeAll(theView); - delete theView; - } + myViews.removeAll(theView); + delete theView; + } } void DocumentCommon::removeViews() { @@ -148,19 +148,19 @@ void DocumentCommon::removeViews() int DocumentCommon::countOfWindow() { - return myViews.count(); + return myViews.count(); } Handle(AIS_InteractiveContext) DocumentCommon::getContext() { - return myContext; + return myContext; } void DocumentCommon::fitAll() { - QList::iterator i; - for ( i = myViews.begin(); i != myViews.end(); i++ ) - (*i)->fitAll(); + QList::iterator i; + for ( i = myViews.begin(); i != myViews.end(); i++ ) + (*i)->fitAll(); } void DocumentCommon::onWireframe() @@ -201,7 +201,7 @@ void DocumentCommon::onColor() if ( aRetColor.isValid() ) { Quantity_Color color( aRetColor.red() / 255., aRetColor.green() / 255., - aRetColor.blue() / 255., Quantity_TOC_RGB ); + aRetColor.blue() / 255., Quantity_TOC_RGB ); for (; myContext->MoreCurrent(); myContext->NextCurrent() ) myContext->SetColor( myContext->Current(), color.Name() ); } diff --git a/samples/qt/Common/src/MDIWindow.cxx b/samples/qt/Common/src/MDIWindow.cxx index bf803a2730..a5d6571be7 100755 --- a/samples/qt/Common/src/MDIWindow.cxx +++ b/samples/qt/Common/src/MDIWindow.cxx @@ -22,28 +22,28 @@ MDIWindow::MDIWindow(View* aView, : QMainWindow( parent, wflags ) { myView = aView; - myDocument = aDocument; -} - + myDocument = aDocument; +} + MDIWindow::MDIWindow( DocumentCommon* aDocument, QWidget* parent, Qt::WindowFlags wflags) : QMainWindow( parent, wflags ) { - QFrame *vb = new QFrame( this ); + QFrame *vb = new QFrame( this ); - QVBoxLayout *layout = new QVBoxLayout( vb ); - layout->setMargin( 0 ); + QVBoxLayout *layout = new QVBoxLayout( vb ); + layout->setMargin( 0 ); vb->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken ); - setCentralWidget( vb ); + setCentralWidget( vb ); - myDocument = aDocument; - myView = new View (myDocument->getContext(), vb); - layout->addWidget (myView); + myDocument = aDocument; + myView = new View (myDocument->getContext(), vb); + layout->addWidget (myView); connect( myView, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) ); - + createViewActions(); createRaytraceActions(); @@ -58,26 +58,26 @@ MDIWindow::~MDIWindow() DocumentCommon* MDIWindow::getDocument() { - return myDocument; + return myDocument; } void MDIWindow::closeEvent(QCloseEvent* ) { - emit sendCloseView(this); + emit sendCloseView(this); } void MDIWindow::fitAll() { - myView->fitAll(); + myView->fitAll(); } void MDIWindow::createViewActions() { // populate a tool bar with some actions - QToolBar* aToolBar = addToolBar( tr( "View Operations" ) ); - + QToolBar* aToolBar = addToolBar( tr( "View Operations" ) ); + QList* aList = myView->getViewActions(); - aToolBar->addActions( *aList ); + aToolBar->addActions( *aList ); aToolBar->toggleViewAction()->setVisible(false); aList->at(View::ViewHlrOffId)->setChecked( true ); @@ -86,15 +86,15 @@ void MDIWindow::createViewActions() void MDIWindow::createRaytraceActions() { // populate a tool bar with some actions - QToolBar* aToolBar = addToolBar( tr( "Ray-tracing Options" ) ); - + QToolBar* aToolBar = addToolBar( tr( "Ray-tracing Options" ) ); + QList* aList = myView->getRaytraceActions(); - aToolBar->addActions( *aList ); + 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::ToolReflectionsId)->setChecked (false); aList->at (View::ToolAntialiasingId)->setChecked (false); } @@ -106,48 +106,48 @@ void MDIWindow::onWindowActivated () void MDIWindow::dump() { QString datadir = (QString(qgetenv ("CASROOT").constData()) + "/../data/images"); - static QString filter; + 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.setNameFilter ( filter ); - fd.setWindowTitle( QObject::tr("INF_APP_EXPORT") ); - fd.setFileMode( QFileDialog::AnyFile ); - int ret = fd.exec(); + QFileDialog fd ( 0 ); + fd.setModal( true ); + fd.setNameFilter ( filter ); + fd.setWindowTitle( QObject::tr("INF_APP_EXPORT") ); + fd.setFileMode( QFileDialog::AnyFile ); + int ret = fd.exec(); - /* update the desktop after the dialog is closed */ - qApp->processEvents(); + /* update the desktop after the dialog is closed */ + qApp->processEvents(); - QStringList fileNames; - fileNames = fd.selectedFiles(); + QStringList fileNames; + fileNames = fd.selectedFiles(); - QString file ( (ret == QDialog::Accepted && !fileNames.isEmpty() )? fileNames[0] : QString::null); + QString file ( (ret == QDialog::Accepted && !fileNames.isEmpty() )? fileNames[0] : QString::null); if ( !file.isNull() ) { - QApplication::setOverrideCursor( Qt::WaitCursor ); - if ( !QFileInfo( file ).completeSuffix().length() ) + 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 ) { - QWidgetList list = qApp->allWidgets(); - QWidget* mainWidget; + QWidgetList list = qApp->allWidgets(); + QWidget* mainWidget; for( int i = 0; i < list.size(); ++i ) - { - if( qobject_cast( list.at( i ) ) ) + { + if( qobject_cast( list.at( i ) ) ) mainWidget = qobject_cast( list.at( i ) ); - } + } - QMessageBox::information ( mainWidget, QObject::tr("TIT_ERROR"), QObject::tr("INF_ERROR"), QObject::tr("BTN_OK"), - QString::null, QString::null, 0, 0 ); - qApp->processEvents(); + QMessageBox::information ( mainWidget, QObject::tr("TIT_ERROR"), QObject::tr("INF_ERROR"), QObject::tr("BTN_OK"), + QString::null, QString::null, 0, 0 ); + qApp->processEvents(); } - } + } } QSize MDIWindow::sizeHint() const { - return QSize( 450, 300 ); + return QSize( 450, 300 ); } diff --git a/samples/qt/Common/src/View.cxx b/samples/qt/Common/src/View.cxx index 77f51b8671..4c45d0ba7b 100755 --- a/samples/qt/Common/src/View.cxx +++ b/samples/qt/Common/src/View.cxx @@ -57,33 +57,31 @@ static QCursor* rotCursor = NULL; View::View( Handle(AIS_InteractiveContext) theContext, QWidget* parent ) : QWidget( parent ), -myIsRaytracing( false ), -myIsShadowsEnabled (true), -myIsReflectionsEnabled (true), -myIsAntialiasingEnabled (false), -myViewActions( 0 ), -myRaytraceActions( 0 ), -myBackMenu( NULL ) + myIsRaytracing( false ), + myIsShadowsEnabled (true), + myIsReflectionsEnabled (false), + myIsAntialiasingEnabled (false), + myViewActions( 0 ), + myRaytraceActions( 0 ), + myBackMenu( NULL ) { #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) //XSynchronize( x11Display(),true ); // it is possible to use QApplication::syncX(); XSynchronize( x11Info().display(),true ); // it is possible to use QApplication::syncX(); #endif - myFirst = true; - myContext = theContext; - //if (theRT) - // myContext->SetDisplayMode( AIS_DisplayMode::AIS_Shaded, 1 ); + myFirst = true; + myContext = theContext; - myXmin = 0; - myYmin = 0; - myXmax = 0; - myYmax = 0; - myCurZoom = 0; - myRectBand = 0; + myXmin = 0; + myYmin = 0; + myXmax = 0; + myYmax = 0; + myCurZoom = 0; + myRectBand = 0; - setAttribute(Qt::WA_PaintOnScreen); - setAttribute(Qt::WA_NoSystemBackground); + setAttribute(Qt::WA_PaintOnScreen); + setAttribute(Qt::WA_NoSystemBackground); #if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX)) XVisualInfo* pVisualInfo; @@ -95,7 +93,7 @@ myBackMenu( NULL ) /* Here we use the settings from Optimizer_ViewInfo::TxglCreateWindow() */ int visualAttr[] = { GLX_RGBA, GLX_DEPTH_SIZE, 1, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, - GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, None }; + GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, None }; pVisualInfo = ::glXChooseVisual( x11Info().display(), DefaultScreen( x11Info().display() ), visualAttr ); if ( isVisible() ) @@ -106,8 +104,8 @@ myBackMenu( NULL ) Window p = RootWindow( x11Info().display(), DefaultScreen( x11Info().display() ) ); a.colormap = XCreateColormap( x11Info().display(), RootWindow( x11Info().display(), pVisualInfo->screen ), pVisualInfo->visual, AllocNone ); - - QColor color = palette().color( backgroundRole() ); + + QColor color = palette().color( backgroundRole() ); QColormap colmap = QColormap::instance(); a.background_pixel = colmap.pixel( color ); a.border_pixel = colmap.pixel( Qt::black ); @@ -115,8 +113,8 @@ myBackMenu( NULL ) p = parentWidget()->winId(); Window w = XCreateWindow( x11Info().display(), p, x(), y(), width(), height(), - 0, pVisualInfo->depth, InputOutput, pVisualInfo->visual, - CWBackPixel | CWBorderPixel | CWColormap, &a ); + 0, pVisualInfo->depth, InputOutput, pVisualInfo->visual, + CWBackPixel | CWBorderPixel | CWColormap, &a ); Window *cmw; Window *cmwret; int count; @@ -128,14 +126,14 @@ myBackMenu( NULL ) int i; for ( i = 0; i < count; i++ ) { - if ( cmw[i] == winId() ) /* replace old window */ - { - cmw[i] = w; - break; - } + if ( cmw[i] == winId() ) /* replace old window */ + { + cmw[i] = w; + break; + } } - if ( i >= count ) /* append new window */ - cmw[count++] = w; + if ( i >= count ) /* append new window */ + cmw[count++] = w; } else { @@ -155,23 +153,24 @@ myBackMenu( NULL ) XFlush( x11Info().display() ); } #endif - myCurrentMode = CurAction3d_Nothing; - myHlrModeIsOn = Standard_False; - setMouseTracking( true ); + + myCurrentMode = CurAction3d_Nothing; + myHlrModeIsOn = Standard_False; + setMouseTracking( true ); - if( myFirst ) - { - init(); - myFirst = false; - } - initViewActions(); - initCursors(); + if( myFirst ) + { + init(); + myFirst = false; + } + initViewActions(); + initCursors(); - setBackgroundRole( QPalette::NoRole );//NoBackground ); - // set focus policy to threat QContextMenuEvent from keyboard - setFocusPolicy( Qt::StrongFocus ); - setAttribute( Qt::WA_PaintOnScreen ); - setAttribute( Qt::WA_NoSystemBackground ); + setBackgroundRole( QPalette::NoRole );//NoBackground ); + // set focus policy to threat QContextMenuEvent from keyboard + setFocusPolicy( Qt::StrongFocus ); + setAttribute( Qt::WA_PaintOnScreen ); + setAttribute( Qt::WA_NoSystemBackground ); } @@ -206,128 +205,125 @@ void View::init() myView->MustBeResized(); if (myIsRaytracing) - myView->SetRaytracingMode(); + myView->ChangeRenderingParams().Method = Graphic3d_RM_RAYTRACING; } void View::paintEvent( QPaintEvent * ) { // QApplication::syncX(); - if( myFirst ) - { - init(); - myFirst = false; - } - myView->Redraw(); + if( myFirst ) + { + init(); + myFirst = false; + } + myView->Redraw(); } void View::resizeEvent( QResizeEvent * ) { // QApplication::syncX(); - if( !myView.IsNull() ) - { - myView->MustBeResized(); - } + if( !myView.IsNull() ) + { + myView->MustBeResized(); + } } void View::fitAll() { - myView->FitAll(); - myView->ZFitAll(); - myView->Redraw(); + myView->FitAll(); + myView->ZFitAll(); + myView->Redraw(); } void View::fitArea() { - myCurrentMode = CurAction3d_WindowZooming; + myCurrentMode = CurAction3d_WindowZooming; } void View::zoom() { - myCurrentMode = CurAction3d_DynamicZooming; + myCurrentMode = CurAction3d_DynamicZooming; } void View::pan() { - myCurrentMode = CurAction3d_DynamicPanning; + myCurrentMode = CurAction3d_DynamicPanning; } void View::rotation() { - myCurrentMode = CurAction3d_DynamicRotation; + myCurrentMode = CurAction3d_DynamicRotation; } void View::globalPan() { - // save the current zoom value - myCurZoom = myView->Scale(); - // Do a Global Zoom - myView->FitAll(); - // Set the mode - myCurrentMode = CurAction3d_GlobalPanning; + // save the current zoom value + myCurZoom = myView->Scale(); + // Do a Global Zoom + myView->FitAll(); + // Set the mode + myCurrentMode = CurAction3d_GlobalPanning; } void View::front() { - myView->SetProj( V3d_Xpos ); + myView->SetProj( V3d_Xpos ); } void View::back() { - myView->SetProj( V3d_Xneg ); + myView->SetProj( V3d_Xneg ); } void View::top() { - myView->SetProj( V3d_Zpos ); + myView->SetProj( V3d_Zpos ); } void View::bottom() { - myView->SetProj( V3d_Zneg ); + myView->SetProj( V3d_Zneg ); } void View::left() { - myView->SetProj( V3d_Ypos ); + myView->SetProj( V3d_Ypos ); } void View::right() { - myView->SetProj( V3d_Yneg ); + myView->SetProj( V3d_Yneg ); } void View::axo() { - myView->SetProj( V3d_XposYnegZpos ); + myView->SetProj( V3d_XposYnegZpos ); } void View::reset() { - myView->Reset(); + myView->Reset(); } void View::hlrOff() { - QApplication::setOverrideCursor( Qt::WaitCursor ); - myHlrModeIsOn = Standard_False; - myView->SetComputedMode (myHlrModeIsOn); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor( Qt::WaitCursor ); + myHlrModeIsOn = Standard_False; + myView->SetComputedMode (myHlrModeIsOn); + QApplication::restoreOverrideCursor(); } void View::hlrOn() { - QApplication::setOverrideCursor( Qt::WaitCursor ); - myHlrModeIsOn = Standard_True; - myView->SetComputedMode (myHlrModeIsOn); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor( Qt::WaitCursor ); + myHlrModeIsOn = Standard_True; + myView->SetComputedMode (myHlrModeIsOn); + QApplication::restoreOverrideCursor(); } void View::SetRaytracedShadows (bool theState) { - if (theState) - myView->EnableRaytracedShadows(); - else - myView->DisableRaytracedShadows(); + myView->ChangeRenderingParams().IsShadowEnabled = theState; myIsShadowsEnabled = theState; @@ -336,10 +332,7 @@ void View::SetRaytracedShadows (bool theState) void View::SetRaytracedReflections (bool theState) { - if (theState) - myView->EnableRaytracedReflections(); - else - myView->DisableRaytracedReflections(); + myView->ChangeRenderingParams().IsReflectionEnabled = theState; myIsReflectionsEnabled = theState; @@ -383,10 +376,7 @@ void View::onRaytraceAction() void View::SetRaytracedAntialiasing (bool theState) { - if (theState) - myView->EnableRaytracedAntialiasing(); - else - myView->DisableRaytracedAntialiasing(); + myView->ChangeRenderingParams().IsAntialiasingEnabled = theState; myIsAntialiasingEnabled = theState; @@ -396,7 +386,7 @@ void View::SetRaytracedAntialiasing (bool theState) void View::EnableRaytracing() { if (!myIsRaytracing) - myView->SetRaytracingMode(); + myView->ChangeRenderingParams().Method = Graphic3d_RM_RAYTRACING; myIsRaytracing = true; @@ -406,7 +396,7 @@ void View::EnableRaytracing() void View::DisableRaytracing() { if (myIsRaytracing) - myView->SetRasterizationMode(); + myView->ChangeRenderingParams().Method = Graphic3d_RM_RASTERIZATION; myIsRaytracing = false; @@ -415,72 +405,73 @@ void View::DisableRaytracing() void View::updateToggled( bool isOn ) { - QAction* sentBy = (QAction*)sender(); + QAction* sentBy = (QAction*)sender(); - if( !isOn ) - return; + if( !isOn ) + return; - for ( int i = ViewFitAllId; i < ViewHlrOffId; i++ ) + for ( int i = ViewFitAllId; i < ViewHlrOffId; i++ ) + { + QAction* anAction = myViewActions->at( i ); + + if ( ( anAction == myViewActions->at( ViewFitAreaId ) ) || + ( anAction == myViewActions->at( ViewZoomId ) ) || + ( anAction == myViewActions->at( ViewPanId ) ) || + ( anAction == myViewActions->at( ViewGlobalPanId ) ) || + ( anAction == myViewActions->at( ViewRotationId ) ) ) { - QAction* anAction = myViewActions->at( i ); - if ( ( anAction == myViewActions->at( ViewFitAreaId ) ) || - ( anAction == myViewActions->at( ViewZoomId ) ) || - ( anAction == myViewActions->at( ViewPanId ) ) || - ( anAction == myViewActions->at( ViewGlobalPanId ) ) || - ( anAction == myViewActions->at( ViewRotationId ) ) ) - { - if ( anAction && ( anAction != sentBy ) ) - { - anAction->setCheckable( true ); - anAction->setChecked( false ); - } - else - { - if ( sentBy == myViewActions->at( ViewFitAreaId ) ) - setCursor( *handCursor ); - else if ( sentBy == myViewActions->at( ViewZoomId ) ) - setCursor( *zoomCursor ); - else if ( sentBy == myViewActions->at( ViewPanId ) ) - setCursor( *panCursor ); - else if ( sentBy == myViewActions->at( ViewGlobalPanId ) ) - setCursor( *globPanCursor ); - else if ( sentBy == myViewActions->at( ViewRotationId ) ) - setCursor( *rotCursor ); - else - setCursor( *defCursor ); - - sentBy->setCheckable( false ); - } - } + if ( anAction && ( anAction != sentBy ) ) + { + anAction->setCheckable( true ); + anAction->setChecked( false ); + } + else + { + if ( sentBy == myViewActions->at( ViewFitAreaId ) ) + setCursor( *handCursor ); + else if ( sentBy == myViewActions->at( ViewZoomId ) ) + setCursor( *zoomCursor ); + else if ( sentBy == myViewActions->at( ViewPanId ) ) + setCursor( *panCursor ); + else if ( sentBy == myViewActions->at( ViewGlobalPanId ) ) + setCursor( *globPanCursor ); + else if ( sentBy == myViewActions->at( ViewRotationId ) ) + setCursor( *rotCursor ); + else + setCursor( *defCursor ); + + sentBy->setCheckable( false ); + } } + } } void View::initCursors() { - if ( !defCursor ) - defCursor = new QCursor( Qt::ArrowCursor ); - if ( !handCursor ) - handCursor = new QCursor( Qt::PointingHandCursor ); - if ( !panCursor ) - panCursor = new QCursor( Qt::SizeAllCursor ); - if ( !globPanCursor ) - globPanCursor = new QCursor( Qt::CrossCursor ); - if ( !zoomCursor ) - zoomCursor = new QCursor( QPixmap( ApplicationCommonWindow::getResourceDir() + QString( "/" ) + QObject::tr( "ICON_CURSOR_ZOOM" ) ) ); - if ( !rotCursor ) - rotCursor = new QCursor( QPixmap( ApplicationCommonWindow::getResourceDir() + QString( "/" ) + QObject::tr( "ICON_CURSOR_ROTATE" ) ) ); + if ( !defCursor ) + defCursor = new QCursor( Qt::ArrowCursor ); + if ( !handCursor ) + handCursor = new QCursor( Qt::PointingHandCursor ); + if ( !panCursor ) + panCursor = new QCursor( Qt::SizeAllCursor ); + if ( !globPanCursor ) + globPanCursor = new QCursor( Qt::CrossCursor ); + if ( !zoomCursor ) + zoomCursor = new QCursor( QPixmap( ApplicationCommonWindow::getResourceDir() + QString( "/" ) + QObject::tr( "ICON_CURSOR_ZOOM" ) ) ); + if ( !rotCursor ) + rotCursor = new QCursor( QPixmap( ApplicationCommonWindow::getResourceDir() + QString( "/" ) + QObject::tr( "ICON_CURSOR_ROTATE" ) ) ); } QList* View::getViewActions() { - initViewActions(); - return myViewActions; + initViewActions(); + return myViewActions; } QList* View::getRaytraceActions() { - initRaytraceActions(); - return myRaytraceActions; + initRaytraceActions(); + return myRaytraceActions; } /*! @@ -647,7 +638,7 @@ void View::initRaytraceActions() a->setToolTip( QObject::tr("TBR_TOOL_REFLECTIONS") ); a->setStatusTip( QObject::tr("TBR_TOOL_REFLECTIONS") ); a->setCheckable( true ); - a->setChecked( true ); + a->setChecked( false ); connect( a, SIGNAL( activated() ) , this, SLOT( onRaytraceAction() ) ); myRaytraceActions->insert( ToolReflectionsId, a ); @@ -690,24 +681,24 @@ void View::activateCursor( const CurrentAction3d mode ) switch( mode ) { case CurAction3d_DynamicPanning: - setCursor( *panCursor ); - break; + setCursor( *panCursor ); + break; case CurAction3d_DynamicZooming: - setCursor( *zoomCursor ); - break; + setCursor( *zoomCursor ); + break; case CurAction3d_DynamicRotation: - setCursor( *rotCursor ); - break; + setCursor( *rotCursor ); + break; case CurAction3d_GlobalPanning: - setCursor( *globPanCursor ); - break; + setCursor( *globPanCursor ); + break; case CurAction3d_WindowZooming: - setCursor( *handCursor ); - break; + setCursor( *handCursor ); + break; case CurAction3d_Nothing: default: - setCursor( *defCursor ); - break; + setCursor( *defCursor ); + break; } } @@ -729,9 +720,9 @@ void View::onLButtonDown( const int/*Qt::MouseButtons*/ nFlags, const QPoint poi { case CurAction3d_Nothing: if ( nFlags & MULTISELECTIONKEY ) - MultiDragEvent( myXmax, myYmax, -1 ); + MultiDragEvent( myXmax, myYmax, -1 ); else - DragEvent( myXmax, myYmax, -1 ); + DragEvent( myXmax, myYmax, -1 ); break; case CurAction3d_DynamicZooming: break; @@ -744,12 +735,12 @@ void View::onLButtonDown( const int/*Qt::MouseButtons*/ nFlags, const QPoint poi case CurAction3d_DynamicRotation: if (myHlrModeIsOn) { - myView->SetComputedMode (Standard_False); + myView->SetComputedMode (Standard_False); } myView->StartRotation( point.x(), point.y() ); break; default: - Standard_Failure::Raise( "incompatible Current Mode" ); + Standard_Failure::Raise( "incompatible Current Mode" ); break; } } @@ -788,23 +779,23 @@ void View::onLButtonUp( Qt::MouseButtons nFlags, const QPoint point ) case CurAction3d_Nothing: if ( point.x() == myXmin && point.y() == myYmin ) { - // no offset between down and up --> selectEvent - myXmax = point.x(); - myYmax = point.y(); - if ( nFlags & MULTISELECTIONKEY ) - MultiInputEvent( point.x(), point.y() ); + // no offset between down and up --> selectEvent + myXmax = point.x(); + myYmax = point.y(); + if ( nFlags & MULTISELECTIONKEY ) + MultiInputEvent( point.x(), point.y() ); else - InputEvent( point.x(), point.y() ); + InputEvent( point.x(), point.y() ); } else { - DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False ); - myXmax = point.x(); - myYmax = point.y(); - if ( nFlags & MULTISELECTIONKEY ) - MultiDragEvent( point.x(), point.y(), 1 ); + DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False ); + myXmax = point.x(); + myYmax = point.y(); + if ( nFlags & MULTISELECTIONKEY ) + MultiDragEvent( point.x(), point.y(), 1 ); else - DragEvent( point.x(), point.y(), 1 ); + DragEvent( point.x(), point.y(), 1 ); } break; case CurAction3d_DynamicZooming: @@ -817,7 +808,7 @@ void View::onLButtonUp( Qt::MouseButtons nFlags, const QPoint point ) myYmax = point.y(); if ( (abs( myXmin - myXmax ) > ValZWMin ) || (abs( myYmin - myYmax ) > ValZWMin ) ) - myView->WindowFitAll( myXmin, myYmin, myXmax, myYmax ); + myView->WindowFitAll( myXmin, myYmin, myXmax, myYmax ); myCurrentMode = CurAction3d_Nothing; noActiveActions(); break; @@ -835,7 +826,7 @@ void View::onLButtonUp( Qt::MouseButtons nFlags, const QPoint point ) noActiveActions(); break; default: - Standard_Failure::Raise(" incompatible Current Mode "); + Standard_Failure::Raise(" incompatible Current Mode "); break; } activateCursor( myCurrentMode ); @@ -871,39 +862,39 @@ void View::onMouseMove( Qt::MouseButtons nFlags, const QPoint point ) switch ( myCurrentMode ) { case CurAction3d_Nothing: - myXmax = point.x(); - myYmax = point.y(); - DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False ); - if ( nFlags & MULTISELECTIONKEY ) - MultiDragEvent( myXmax, myYmax, 0 ); + myXmax = point.x(); + myYmax = point.y(); + DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False ); + if ( nFlags & MULTISELECTIONKEY ) + MultiDragEvent( myXmax, myYmax, 0 ); else - DragEvent( myXmax, myYmax, 0 ); - DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_True ); + DragEvent( myXmax, myYmax, 0 ); + DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_True ); break; case CurAction3d_DynamicZooming: - myView->Zoom( myXmax, myYmax, point.x(), point.y() ); + myView->Zoom( myXmax, myYmax, point.x(), point.y() ); myXmax = point.x(); myYmax = point.y(); - break; + break; case CurAction3d_WindowZooming: - myXmax = point.x(); + myXmax = point.x(); myYmax = point.y(); - DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False ); - DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_True ); - break; + DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_False ); + DrawRectangle( myXmin, myYmin, myXmax, myYmax, Standard_True ); + break; case CurAction3d_DynamicPanning: - myView->Pan( point.x() - myXmax, myYmax - point.y() ); - myXmax = point.x(); - myYmax = point.y(); - break; + myView->Pan( point.x() - myXmax, myYmax - point.y() ); + myXmax = point.x(); + myYmax = point.y(); + break; case CurAction3d_GlobalPanning: break; case CurAction3d_DynamicRotation: - myView->Rotation( point.x(), point.y() ); - myView->Redraw(); + myView->Rotation( point.x(), point.y() ); + myView->Redraw(); break; default: - Standard_Failure::Raise( "incompatible Current Mode" ); + Standard_Failure::Raise( "incompatible Current Mode" ); break; } } @@ -911,10 +902,10 @@ void View::onMouseMove( Qt::MouseButtons nFlags, const QPoint point ) { myXmax = point.x(); myYmax = point.y(); - if ( nFlags & MULTISELECTIONKEY ) - MultiMoveEvent( point.x(), point.y() ); + if ( nFlags & MULTISELECTIONKEY ) + MultiMoveEvent( point.x(), point.y() ); else - MoveEvent( point.x(), point.y() ); + MoveEvent( point.x(), point.y() ); } } @@ -988,23 +979,23 @@ void View::Popup( const int /*x*/, const int /*y*/ ) { QList* aList = stApp->getToolActions(); QMenu* myToolMenu = new QMenu( 0 ); - myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolWireframeId ) ); - myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolShadingId ) ); - myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolColorId ) ); + myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolWireframeId ) ); + myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolShadingId ) ); + myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolColorId ) ); QMenu* myMaterMenu = new QMenu( myToolMenu ); QList* aMeterActions = ApplicationCommonWindow::getApplication()->getMaterialActions(); QString dir = ApplicationCommonWindow::getResourceDir() + QString( "/" ); - myMaterMenu = myToolMenu->addMenu( QPixmap( dir+QObject::tr("ICON_TOOL_MATER")), QObject::tr("MNU_MATER") ); + myMaterMenu = myToolMenu->addMenu( QPixmap( dir+QObject::tr("ICON_TOOL_MATER")), QObject::tr("MNU_MATER") ); for ( int i = 0; i < aMeterActions->size(); i++ ) - myMaterMenu->addAction( aMeterActions->at( i ) ); + myMaterMenu->addAction( aMeterActions->at( i ) ); myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolTransparencyId ) ); - myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolDeleteId ) ); + myToolMenu->addAction( aList->at( ApplicationCommonWindow::ToolDeleteId ) ); addItemInPopup(myToolMenu); - myToolMenu->exec( QCursor::pos() ); + myToolMenu->exec( QCursor::pos() ); delete myToolMenu; } else @@ -1013,18 +1004,18 @@ void View::Popup( const int /*x*/, const int /*y*/ ) { myBackMenu = new QMenu( 0 ); - QAction* a = new QAction( QObject::tr("MNU_CH_BACK"), this ); - a->setToolTip( QObject::tr("TBR_CH_BACK") ); + QAction* a = new QAction( QObject::tr("MNU_CH_BACK"), this ); + a->setToolTip( QObject::tr("TBR_CH_BACK") ); connect( a, SIGNAL( activated() ), this, SLOT( onBackground() ) ); - myBackMenu->addAction( a ); + myBackMenu->addAction( a ); addItemInPopup(myBackMenu); a = new QAction( QObject::tr("MNU_CH_ENV_MAP"), this ); - a->setToolTip( QObject::tr("TBR_CH_ENV_MAP") ); + a->setToolTip( QObject::tr("TBR_CH_ENV_MAP") ); connect( a, SIGNAL( activated() ), this, SLOT( onEnvironmentMap() ) ); a->setCheckable( true ); a->setChecked( false ); - myBackMenu->addAction( a ); + myBackMenu->addAction( a ); addItemInPopup(myBackMenu); } @@ -1039,7 +1030,7 @@ void View::addItemInPopup( QMenu* /*theMenu*/) } void View::DrawRectangle(const int MinX, const int MinY, - const int MaxX, const int MaxY, const bool Draw) + const int MaxX, const int MaxY, const bool Draw) { static Standard_Integer StoredMinX, StoredMaxX, StoredMinY, StoredMaxY; static Standard_Boolean m_IsVisible; @@ -1093,8 +1084,8 @@ void View::noActiveActions() ( anAction == myViewActions->at( ViewRotationId ) ) ) { setCursor( *defCursor ); - anAction->setCheckable( true ); - anAction->setChecked( false ); + anAction->setCheckable( true ); + anAction->setChecked( false ); } } }