From 47d24a887027b952fc79029265c1555b0aeed990 Mon Sep 17 00:00:00 2001 From: mkr Date: Tue, 29 May 2007 08:33:19 +0000 Subject: [PATCH] Porting to Qt4. --- src/Makefile.am | 2 +- src/OCCViewer/OCCViewer.pro | 61 +++++ src/OCCViewer/OCCViewer_AISSelector.h | 2 +- src/OCCViewer/OCCViewer_ClippingDlg.cxx | 115 ++++++---- src/OCCViewer/OCCViewer_ClippingDlg.h | 4 +- .../OCCViewer_CreateRestoreViewDlg.cxx | 65 +++--- .../OCCViewer_CreateRestoreViewDlg.h | 24 +- .../OCCViewer_SetRotationPointDlg.cxx | 90 ++++---- src/OCCViewer/OCCViewer_SetRotationPointDlg.h | 7 +- src/OCCViewer/OCCViewer_ViewManager.cxx | 2 +- src/OCCViewer/OCCViewer_ViewManager.h | 2 +- src/OCCViewer/OCCViewer_ViewModel.cxx | 36 +-- src/OCCViewer/OCCViewer_ViewModel.h | 35 ++- src/OCCViewer/OCCViewer_ViewPort.cxx | 214 +++++++++--------- src/OCCViewer/OCCViewer_ViewPort.h | 64 +++--- src/OCCViewer/OCCViewer_ViewPort3d.cxx | 9 +- src/OCCViewer/OCCViewer_ViewPort3d.h | 58 ++--- src/OCCViewer/OCCViewer_ViewWindow.cxx | 80 +++---- src/OCCViewer/OCCViewer_ViewWindow.h | 3 +- src/Qtx/QtxListBox.h | 18 +- src/src.pro | 1 + 21 files changed, 502 insertions(+), 390 deletions(-) create mode 100644 src/OCCViewer/OCCViewer.pro diff --git a/src/Makefile.am b/src/Makefile.am index cba9f1f8d..687fde263 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -56,7 +56,7 @@ if ENABLE_OCCVIEWER # VSR: this is the original packages list # SUBDIRS += OCCViewer # VSR: already migrated to Qt4 packages - SUBDIRS += + SUBDIRS += OCCViewer if ENABLE_SALOMEOBJECT # VSR: this is the original packages list # SUBDIRS += SOCC diff --git a/src/OCCViewer/OCCViewer.pro b/src/OCCViewer/OCCViewer.pro new file mode 100644 index 000000000..319c23b01 --- /dev/null +++ b/src/OCCViewer/OCCViewer.pro @@ -0,0 +1,61 @@ +TEMPLATE = lib +TARGET = OCCViewer +DESTDIR = ../../lib +MOC_DIR = ../../moc +OBJECTS_DIR = ../../obj/$$TARGET + +OGL_INCLUDES = + +OGL_LIBS = -lGL -L/usr/X11R6/lib -lGLU + +CASROOT = $$(CASROOT) +CAS_CPPFLAGS = $${CASROOT}/inc + +CAS_KERNEL = -L$${CASROOT}/Linux/lib -lTKernel + +CAS_VIEWER = -L$${CASROOT}/Linux/lib -lTKV3d -lTKService + +INCLUDEPATH += ../../include $${OGL_INCLUDES} $${CAS_CPPFLAGS} ../Qtx ../SUIT +LIBS += -L../../lib -lsuit $${OGL_LIBS} $${CAS_KERNEL} $${CAS_VIEWER} + +CONFIG -= debug release debug_and_release +CONFIG += qt thread debug dll shared + +win32:DEFINES += WIN32 +DEFINES += OCCVIEWER_EXPORTS OCC_VERSION_MAJOR=6 OCC_VERSION_MINOR=1 OCC_VERSION_MAINTENANCE=1 LIN LINTEL CSFDB No_exception HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS + +HEADERS = OCCViewer_AISSelector.h +HEADERS += OCCViewer_ViewManager.h +HEADERS += OCCViewer_ViewModel.h +HEADERS += OCCViewer_ViewPort3d.h +HEADERS += OCCViewer_ViewPort.h +HEADERS += OCCViewer_ViewWindow.h +HEADERS += OCCViewer_VService.h +HEADERS += OCCViewer_CreateRestoreViewDlg.h +HEADERS += OCCViewer.h +HEADERS += OCCViewer_ClippingDlg.h +HEADERS += OCCViewer_SetRotationPointDlg.h + +SOURCES = OCCViewer_AISSelector.cxx +SOURCES += OCCViewer_ViewManager.cxx +SOURCES += OCCViewer_ViewModel.cxx +SOURCES += OCCViewer_ViewPort3d.cxx +SOURCES += OCCViewer_ViewPort.cxx +SOURCES += OCCViewer_ViewWindow.cxx +SOURCES += OCCViewer_VService.cxx +SOURCES += OCCViewer_CreateRestoreViewDlg.cxx +SOURCES += OCCViewer_SetRotationPointDlg.cxx +SOURCES += OCCViewer_ClippingDlg.cxx + +TRANSLATIONS = resources/OCCViewer_images.ts \ + resources/OCCViewer_msg_en.ts + +ICONS = resources/*.png + +includes.files = $$HEADERS +includes.path = ../../include + +resources.files = $$ICONS resources/*.qm +resources.path = ../../resources + +INSTALLS += includes resources diff --git a/src/OCCViewer/OCCViewer_AISSelector.h b/src/OCCViewer/OCCViewer_AISSelector.h index 740c8f013..66267f938 100755 --- a/src/OCCViewer/OCCViewer_AISSelector.h +++ b/src/OCCViewer/OCCViewer_AISSelector.h @@ -20,7 +20,7 @@ #define OCCVIEWER_AISSELECTOR_H #include "OCCViewer.h" -#include +#include #include #include diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx index 106e28b8f..ed96b68df 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.cxx +++ b/src/OCCViewer/OCCViewer_ClippingDlg.cxx @@ -23,11 +23,11 @@ #include "SUIT_Session.h" #include "SUIT_ViewWindow.h" +#include "SUIT_ViewManager.h" #include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewPort3d.h" #include -//#include #include #include #include @@ -39,13 +39,15 @@ #include // QT Includes -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /*! Constructor @@ -55,22 +57,23 @@ \param modal - is this dialog modal \param fl - flags */ -OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, WFlags fl ) -: QDialog( parent, "OCCViewer_ClippingDlg", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), +OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl ) +: QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), myView( view ) { - setCaption( tr( "Clipping" ) ); + setObjectName( "OCCViewer_ClippingDlg" ); + setModal( modal ); + + setWindowTitle( tr( "Clipping" ) ); QVBoxLayout* topLayout = new QVBoxLayout( this ); topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); /***************************************************************/ - GroupPoint = new QGroupBox( this, "GroupPoint" ); + GroupPoint = new QGroupBox( this ); + GroupPoint->setObjectName( "GroupPoint" ); GroupPoint->setTitle( tr("Base point") ); - GroupPoint->setColumnLayout(0, Qt::Vertical ); - GroupPoint->layout()->setSpacing( 0 ); - GroupPoint->layout()->setMargin( 0 ); - QGridLayout* GroupPointLayout = new QGridLayout( GroupPoint->layout() ); + QGridLayout* GroupPointLayout = new QGridLayout( GroupPoint ); GroupPointLayout->setAlignment( Qt::AlignTop ); GroupPointLayout->setSpacing( 6 ); GroupPointLayout->setMargin( 11 ); @@ -82,7 +85,8 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge const int precision = -6; // PAL12789. Minus is for using 'g' double->string conversion specifier, // see QtxDblSpinBox::mapValueToText( double v ) - TextLabelX = new QLabel( GroupPoint, "TextLabelX" ); + TextLabelX = new QLabel( GroupPoint ); + TextLabelX->setObjectName( "TextLabelX" ); TextLabelX->setText( tr("X:") ); GroupPointLayout->addWidget( TextLabelX, 0, 0 ); @@ -90,7 +94,8 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge SpinBox_X->setPrecision( precision ); GroupPointLayout->addWidget( SpinBox_X, 0, 1 ); - TextLabelY = new QLabel( GroupPoint, "TextLabelY" ); + TextLabelY = new QLabel( GroupPoint ); + TextLabelY->setObjectName( "TextLabelY" ); TextLabelY->setText( tr("Y:") ); GroupPointLayout->addWidget( TextLabelY, 0, 2 ); @@ -98,7 +103,8 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge SpinBox_Y->setPrecision( precision ); GroupPointLayout->addWidget( SpinBox_Y, 0, 3 ); - TextLabelZ = new QLabel( GroupPoint, "TextLabelZ" ); + TextLabelZ = new QLabel( GroupPoint ); + TextLabelZ->setObjectName( "TextLabelZ" ); TextLabelZ->setText( tr("Z:") ); GroupPointLayout->addWidget( TextLabelZ, 0, 4 ); @@ -106,23 +112,25 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge SpinBox_Z->setPrecision( precision ); GroupPointLayout->addWidget( SpinBox_Z, 0, 5 ); - resetButton = new QPushButton( GroupPoint, "resetButton" ); + resetButton = new QPushButton( GroupPoint ); + resetButton->setObjectName( "resetButton" ); resetButton->setText( tr( "Reset" ) ); GroupPointLayout->addWidget( resetButton, 0, 6 ); + GroupPoint->setLayout(GroupPointLayout); + /***************************************************************/ - GroupDirection = new QGroupBox( this, "GroupDirection" ); + GroupDirection = new QGroupBox( this ); + GroupDirection->setObjectName( "GroupDirection" ); GroupDirection->setTitle( tr("Direction") ); - GroupDirection->setColumnLayout(0, Qt::Vertical ); - GroupDirection->layout()->setSpacing( 0 ); - GroupDirection->layout()->setMargin( 0 ); - QGridLayout* GroupDirectionLayout = new QGridLayout( GroupDirection->layout() ); + QGridLayout* GroupDirectionLayout = new QGridLayout( GroupDirection ); GroupDirectionLayout->setAlignment( Qt::AlignTop ); GroupDirectionLayout->setSpacing( 6 ); GroupDirectionLayout->setMargin( 11 ); // Controls - TextLabelDx = new QLabel( GroupDirection, "TextLabelDx" ); + TextLabelDx = new QLabel( GroupDirection ); + TextLabelDx->setObjectName( "TextLabelDx" ); TextLabelDx->setText( tr("Dx:") ); GroupDirectionLayout->addWidget( TextLabelDx, 0, 0 ); @@ -130,7 +138,8 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge SpinBox_Dx->setPrecision( precision ); GroupDirectionLayout->addWidget( SpinBox_Dx, 0, 1 ); - TextLabelDy = new QLabel( GroupDirection, "TextLabelDy" ); + TextLabelDy = new QLabel( GroupDirection ); + TextLabelDy->setObjectName( "TextLabelDy" ); TextLabelDy->setText( tr("Dy:") ); GroupDirectionLayout->addWidget( TextLabelDy, 0, 2 ); @@ -138,7 +147,8 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge SpinBox_Dy->setPrecision( precision ); GroupDirectionLayout->addWidget( SpinBox_Dy, 0, 3 ); - TextLabelDz = new QLabel( GroupDirection, "TextLabelDz" ); + TextLabelDz = new QLabel( GroupDirection ); + TextLabelDz->setObjectName( "TextLabelDz" ); TextLabelDz->setText( tr("Dz:") ); GroupDirectionLayout->addWidget( TextLabelDz, 0, 4 ); @@ -146,31 +156,36 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge SpinBox_Dz->setPrecision( precision ); GroupDirectionLayout->addWidget( SpinBox_Dz, 0, 5 ); - invertButton = new QPushButton( GroupDirection, "invertButton" ); + invertButton = new QPushButton( GroupDirection ); + invertButton->setObjectName( "invertButton" ); invertButton->setText( tr( "Invert" ) ); GroupDirectionLayout->addWidget( invertButton, 0, 6 ); - DirectionCB = new QComboBox( GroupDirection, "DirectionCB" ); - DirectionCB->insertItem(tr("CUSTOM")); - DirectionCB->insertItem(tr("||X-Y")); - DirectionCB->insertItem(tr("||Y-Z")); - DirectionCB->insertItem(tr("||Z-X")); - GroupDirectionLayout->addMultiCellWidget( DirectionCB, 1, 1, 0, 5 ); + DirectionCB = new QComboBox( GroupDirection ); + DirectionCB->setObjectName( "DirectionCB" ); + DirectionCB->insertItem(DirectionCB->count(),tr("CUSTOM")); + DirectionCB->insertItem(DirectionCB->count(),tr("||X-Y")); + DirectionCB->insertItem(DirectionCB->count(),tr("||Y-Z")); + DirectionCB->insertItem(DirectionCB->count(),tr("||Z-X")); + GroupDirectionLayout->addWidget( DirectionCB, 1, 0, 1, 6 ); + GroupDirection->setLayout(GroupDirectionLayout); + /***************************************************************/ - PreviewChB = new QCheckBox( tr("Preview") ,this, "PreviewChB" ); + PreviewChB = new QCheckBox( tr("Preview") ,this ); + PreviewChB->setObjectName( "PreviewChB" ); PreviewChB->setChecked( true ); /***************************************************************/ - QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 ); - QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + QGroupBox* GroupButtons = new QGroupBox( this ); + GroupButtons->setObjectName( "GroupButtons" ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); GroupButtonsLayout->setAlignment( Qt::AlignTop ); GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply = new QPushButton( GroupButtons ); + buttonApply->setObjectName( "buttonApply" ); buttonApply->setText( tr( "BUT_APPLY" ) ); buttonApply->setAutoDefault( TRUE ); buttonApply->setDefault( TRUE ); @@ -178,10 +193,14 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge GroupButtonsLayout->addStretch(); - buttonClose = new QPushButton( GroupButtons, "buttonClose" ); + buttonClose = new QPushButton( GroupButtons ); + buttonClose->setObjectName( "buttonClose" ); buttonClose->setText( tr( "BUT_CLOSE" ) ); buttonClose->setAutoDefault( TRUE ); GroupButtonsLayout->addWidget( buttonClose ); + + GroupButtons->setLayout(GroupButtonsLayout); + /***************************************************************/ topLayout->addWidget( GroupPoint ); @@ -248,7 +267,7 @@ void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e ) aView3d->SetPlaneOn( myClippingPlane ); if (!myView->isCuttingPlane()) - myAction->setOn( false ); + myAction->setChecked( false ); QDialog::closeEvent( e ); } @@ -289,7 +308,7 @@ void OCCViewer_ClippingDlg::ClickOnClose() aView3d->SetPlaneOn( myClippingPlane ); if (!myView->isCuttingPlane()) - myAction->setOn( false ); + myAction->setChecked( false ); reject(); } @@ -451,9 +470,9 @@ void OCCViewer_ClippingDlg::displayPreview() isFound = true; double xmin, ymin, zmin, xmax, ymax, zmax; aPrs->MinMaxValues( xmin, ymin, zmin, xmax, ymax, zmax ); - aXMin = QMIN( aXMin, xmin ); aXMax = QMAX( aXMax, xmax ); - aYMin = QMIN( aYMin, ymin ); aYMax = QMAX( aYMax, ymax ); - aZMin = QMIN( aZMin, zmin ); aZMax = QMAX( aZMax, zmax ); + aXMin = qMin( aXMin, xmin ); aXMax = qMax( aXMax, xmax ); + aYMin = qMin( aYMin, ymin ); aYMax = qMax( aYMax, ymax ); + aZMin = qMin( aZMin, zmin ); aZMax = qMax( aZMax, zmax ); } } } @@ -565,7 +584,7 @@ void OCCViewer_ClippingDlg::ReserveClippingPlane() void OCCViewer_ClippingDlg::onViewShow() { - if(myAction->isOn()) + if(myAction->isChecked()) show(); else hide(); diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.h b/src/OCCViewer/OCCViewer_ClippingDlg.h index bed795811..00fe9c5be 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.h +++ b/src/OCCViewer/OCCViewer_ClippingDlg.h @@ -21,7 +21,7 @@ #include "OCCViewer.h" -#include +#include #include #include @@ -46,7 +46,7 @@ class OCCViewer_ClippingDlg : public QDialog Q_OBJECT public: - OCCViewer_ClippingDlg(OCCViewer_ViewWindow* , QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0); + OCCViewer_ClippingDlg(OCCViewer_ViewWindow* , QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WindowFlags fl = 0); ~OCCViewer_ClippingDlg(); void SetAction( QtxAction* theAction ) { myAction = theAction; } diff --git a/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx b/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx index e97cde8b9..b7e09b343 100755 --- a/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx +++ b/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx @@ -20,10 +20,12 @@ #include "OCCViewer_ViewModel.h" #include "OCCViewer_ViewPort3d.h" -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /*! Constructor @@ -31,7 +33,7 @@ OCCViewer_CreateRestoreViewDlg::OCCViewer_CreateRestoreViewDlg( QWidget* aWin, OCCViewer_Viewer* curModel ) : QDialog( aWin ) { - setCaption( tr( "CAPTION" ) ); + setWindowTitle( tr( "CAPTION" ) ); myParametersMap = curModel->getViewAspects(); @@ -41,7 +43,9 @@ OCCViewer_CreateRestoreViewDlg::OCCViewer_CreateRestoreViewDlg( QWidget* aWin, O setFixedSize( 400, 300 ); - QGridLayout* aGrid = new QGridLayout( this, 2, 1, 5, 10 ); + QGridLayout* aGrid = new QGridLayout( this ); + aGrid->setMargin( 5 ); + aGrid->setSpacing( 10 ); QWidget* aWidget1 = new QWidget( this ); QWidget* aWidget2 = new QWidget( this ); @@ -60,14 +64,14 @@ OCCViewer_CreateRestoreViewDlg::OCCViewer_CreateRestoreViewDlg( QWidget* aWin, O { myListBox->clear(); for( int i = 0; i < aQuantityOfItems; i++ ) - myListBox->insertItem( myParametersMap[ i ].name ); + myListBox->insertItem( i, myParametersMap[ i ].name ); changeImage( myListBox->item( 0 ) ); } else { myListBox->clear(); - myListBox->insertItem( "No Items", 0 ); + myListBox->insertItem( 0, "No Items" ); myListBox->setEditEnabled( 0 ); } @@ -77,7 +81,9 @@ OCCViewer_CreateRestoreViewDlg::OCCViewer_CreateRestoreViewDlg( QWidget* aWin, O aLayout->addWidget( myListBox ); aLayout->addWidget( myCurViewPort, 30 ); - QHBoxLayout* aButtonLayout = new QHBoxLayout( aWidget2, 0, 5 ); + QHBoxLayout* aButtonLayout = new QHBoxLayout( aWidget2 ); + aButtonLayout->setMargin( 0 ); + aButtonLayout->setSpacing( 5 ); QPushButton* theOk = new QPushButton( tr( "Ok" ), aWidget2 ); theOk->setAutoDefault( false ); QPushButton* theCancel = new QPushButton( tr( "Cancel" ), aWidget2 ); theCancel->setAutoDefault( false ); @@ -109,18 +115,18 @@ OCCViewer_CreateRestoreViewDlg::~OCCViewer_CreateRestoreViewDlg() Changes image in accordance with item \param curItem - item contains info about view parameters */ -void OCCViewer_CreateRestoreViewDlg::changeImage( QListBoxItem* curItem ) +void OCCViewer_CreateRestoreViewDlg::changeImage( QListWidgetItem* curItem ) { if( curItem && myListBox->isEditEnabled() ) { int lowLevel = -1; int highLevel = -1; - int index = curItem->listBox()->index( curItem ); + int index = curItem->listWidget()->row( curItem ); if( myKeyFlag == 2 ) { - for( int i = 0; i < (int)myListBox->count(); i++ ) + for( int i = 0; i < (int)myListBox->count(); i++ ) { - if( myListBox->isSelected( i ) && i != index ) + if( myListBox->item( i )->isSelected() && i != index ) { myListBox->clearSelection(); if( i > index ) @@ -134,11 +140,11 @@ void OCCViewer_CreateRestoreViewDlg::changeImage( QListBoxItem* curItem ) highLevel = index; } for( int j = lowLevel; j <= highLevel; j++ ) - myListBox->setSelected( j, TRUE ); + myListBox->item( j )->setSelected( TRUE ); break; } - if( myListBox->isSelected( i ) && i == index ) - myListBox->setSelected( i, TRUE ); + if( myListBox->item( i )->isSelected() && i == index ) + myListBox->item( i )->setSelected( TRUE ); } } @@ -173,14 +179,15 @@ void OCCViewer_CreateRestoreViewDlg::deleteSelectedItems() { int curIndex = -1; for( int i = 0; i < (int)myListBox->count(); i++ ) - if( myListBox->isSelected( i ) ) + if( myListBox->item( i )->isSelected() ) { - myListBox->removeItem( i ); + QListWidgetItem* anItemToDelete = myListBox->takeItem( i ); + delete anItemToDelete; for( int j = i; j < (int)myParametersMap.count(); j++ ) if( j != myParametersMap.count() - 1 ) myParametersMap[ j ] = myParametersMap[ j + 1 ]; else - myParametersMap.remove( myParametersMap.at(j) ); + myParametersMap.removeAt( j ); if( i != myListBox->count() ) curIndex = i; else @@ -189,14 +196,14 @@ void OCCViewer_CreateRestoreViewDlg::deleteSelectedItems() } if( curIndex >= 0 ) { - myListBox->setCurrentItem( curIndex ); + myListBox->setCurrentItem( myListBox->item( curIndex ) ); changeImage( myListBox->item( curIndex ) ); } } if( !myListBox->count() ) { myListBox->clear(); - myListBox->insertItem( "No Items", 0 ); + myListBox->insertItem( 0, "No Items" ); myListBox->setEditEnabled( 0 ); } } @@ -207,7 +214,7 @@ void OCCViewer_CreateRestoreViewDlg::deleteSelectedItems() void OCCViewer_CreateRestoreViewDlg::clearList() { myListBox->clear(); - myListBox->insertItem( "No Items", 0 ); + myListBox->insertItem( 0, "No Items" ); myListBox->setEditEnabled( 0 ); myParametersMap.clear(); @@ -225,10 +232,10 @@ const viewAspectList& OCCViewer_CreateRestoreViewDlg::parameters() const Renames key of view aspect map in accordance with item name \param anItem - item */ -void OCCViewer_CreateRestoreViewDlg::editItemText( QListBoxItem* anItem ) +void OCCViewer_CreateRestoreViewDlg::editItemText( QListWidgetItem* anItem ) { - int index = anItem->listBox()->index( anItem ); - myParametersMap[ index ].name = anItem->text().latin1(); + int index = anItem->listWidget()->row( anItem ); + myParametersMap[ index ].name = anItem->text().toLatin1(); } /*! @@ -242,15 +249,15 @@ bool OCCViewer_CreateRestoreViewDlg::eventFilter( QObject* anObj, QEvent* anEv ) if( aKeyEv->key() == Qt::Key_Control ) { myKeyFlag = 1; - myListBox->setSelectionMode( QListBox::Multi ); + myListBox->setSelectionMode( QAbstractItemView::MultiSelection ); } else if( aKeyEv->key() == Qt::Key_Shift ) { myKeyFlag = 2; - myListBox->setSelectionMode( QListBox::Multi ); + myListBox->setSelectionMode( QAbstractItemView::MultiSelection ); } else - myListBox->setSelectionMode( QListBox::Single ); + myListBox->setSelectionMode( QAbstractItemView::SingleSelection ); } if( anEv->type() == QEvent::KeyRelease ) myKeyFlag = 0; @@ -258,7 +265,7 @@ bool OCCViewer_CreateRestoreViewDlg::eventFilter( QObject* anObj, QEvent* anEv ) if( !myKeyFlag ) { if( anEv->type() == QEvent::KeyPress || anEv->type() == QEvent::MouseButtonPress ) - myListBox->setSelectionMode( QListBox::Single ); + myListBox->setSelectionMode( QAbstractItemView::SingleSelection ); } return QWidget::eventFilter( anObj, anEv ); } diff --git a/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.h b/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.h index fc1579ae6..2fabd6649 100755 --- a/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.h +++ b/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.h @@ -28,14 +28,12 @@ #include #include -#include -#include -#include -#include -#include +#include class OCCViewer_ViewPort3d; +class QListWidgetItem; + #ifdef WIN32 #pragma warning( disable:4251 ) #endif @@ -48,15 +46,15 @@ public: OCCViewer_CreateRestoreViewDlg( QWidget*, OCCViewer_Viewer* ); virtual ~OCCViewer_CreateRestoreViewDlg(); - const viewAspectList& parameters() const; - viewAspect currentItem() const; - virtual bool eventFilter( QObject*, QEvent* ); + const viewAspectList& parameters() const; + viewAspect currentItem() const; + virtual bool eventFilter( QObject*, QEvent* ); public slots: void OKpressed(); void clearList(); - void editItemText( QListBoxItem* ); - void changeImage( QListBoxItem* ); + void editItemText( QListWidgetItem* ); + void changeImage( QListWidgetItem* ); void deleteSelectedItems(); signals: @@ -64,10 +62,10 @@ signals: private: int myKeyFlag; - QtxListBox* myListBox; + QtxListBox* myListBox; OCCViewer_ViewPort3d* myCurViewPort; - viewAspect myCurrentItem; - viewAspectList myParametersMap; + viewAspect myCurrentItem; + viewAspectList myParametersMap; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx b/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx index 0aed2c230..c102afdb4 100644 --- a/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx +++ b/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx @@ -22,16 +22,14 @@ #include "OCCViewer_ViewWindow.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include /*! Constructor @@ -41,11 +39,14 @@ \param modal - is this dialog modal \param fl - flags */ -OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, WFlags fl ) -: QDialog( parent, "OCCViewer_SetRotationPointDlg", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), +OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl ) +: QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), myView( view ) { - setCaption(tr("CAPTION")); + setObjectName( "OCCViewer_SetRotationPointDlg" ); + setModal( modal ); + + setWindowTitle(tr("CAPTION")); setSizeGripEnabled(TRUE); // Create layout for this dialog @@ -54,35 +55,42 @@ OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWind layoutDlg->setMargin(11); // Create check box "Use Bounding Box Center" - QHBox* aCheckBox = new QHBox(this); + QHBoxLayout* aCheckBox = new QHBoxLayout(this); - myIsBBCenter = new QCheckBox(tr("USE_BBCENTER"), aCheckBox); + myIsBBCenter = new QCheckBox(tr("USE_BBCENTER")); myIsBBCenter->setChecked(true); + aCheckBox->addWidget(myIsBBCenter); connect(myIsBBCenter, SIGNAL(stateChanged(int)), SLOT(onBBCenterChecked())); // Create croup button with radio buttons - myGroupSelButton = new QButtonGroup(2,Qt::Vertical,"",this); - myGroupSelButton->setMargin(11); + myGroupBoxSel = new QGroupBox( "", this ); + QVBoxLayout *vbox = new QVBoxLayout; + vbox->setMargin(11); + vbox->addStretch(1); // Create "Set to Origin" button - myToOrigin = new QPushButton(myGroupSelButton); - myToOrigin->setText(tr("LBL_TOORIGIN")); + myToOrigin = new QPushButton(tr("LBL_TOORIGIN")); + vbox->addWidget(myToOrigin); connect(myToOrigin, SIGNAL(clicked()), this, SLOT(onToOrigin())); // Create "Select Point from View" button - mySelectPoint = new QPushButton(myGroupSelButton); - mySelectPoint->setText(tr("LBL_SELECTPOINT")); - mySelectPoint->setToggleButton(true); + mySelectPoint = new QPushButton(tr("LBL_SELECTPOINT")); + mySelectPoint->setCheckable(true); + vbox->addWidget(mySelectPoint); connect(mySelectPoint, SIGNAL(clicked()), this, SLOT(onSelectPoint())); + myGroupBoxSel->setLayout(vbox); + // Create croup box with grid layout - myGroupBoxCoord = new QGroupBox(this, "GroupBox"); + myGroupBoxCoord = new QGroupBox(this); + myGroupBoxCoord->setObjectName("GroupBox"); QHBoxLayout* aHBoxLayout = new QHBoxLayout(myGroupBoxCoord); aHBoxLayout->setMargin(11); aHBoxLayout->setSpacing(6); // "X" coordinate - QLabel* TextLabelX = new QLabel (tr("LBL_X"), myGroupBoxCoord, "TextLabelX"); + QLabel* TextLabelX = new QLabel (tr("LBL_X"), myGroupBoxCoord ); + TextLabelX->setObjectName("TextLabelX"); TextLabelX->setFixedWidth(15); myX = new QLineEdit(myGroupBoxCoord); myX->setValidator(new QDoubleValidator(myX)); @@ -90,7 +98,8 @@ OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWind connect(myX, SIGNAL(textChanged(const QString&)), this, SLOT(onCoordChanged())); // "Y" coordinate - QLabel* TextLabelY = new QLabel (tr("LBL_Y"), myGroupBoxCoord, "TextLabelY"); + QLabel* TextLabelY = new QLabel (tr("LBL_Y"), myGroupBoxCoord ); + TextLabelY->setObjectName("TextLabelY"); TextLabelY->setFixedWidth(15); myY = new QLineEdit(myGroupBoxCoord); myY->setValidator(new QDoubleValidator(myY)); @@ -98,7 +107,8 @@ OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWind connect(myY, SIGNAL(textChanged(const QString&)), this, SLOT(onCoordChanged())); // "Z" coordinate - QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), myGroupBoxCoord, "TextLabelZ"); + QLabel* TextLabelZ = new QLabel (tr("LBL_Z"), myGroupBoxCoord ); + TextLabelZ->setObjectName("TextLabelZ"); TextLabelZ->setFixedWidth(15); myZ = new QLineEdit(myGroupBoxCoord); myZ->setValidator(new QDoubleValidator(myZ)); @@ -119,7 +129,8 @@ OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWind aHBoxLayout2->setMargin(11); aHBoxLayout2->setSpacing(6); - QPushButton* m_bClose = new QPushButton(tr("&Close"), aGroupBox, "m_bClose"); + QPushButton* m_bClose = new QPushButton(tr("&Close"), aGroupBox ); + m_bClose->setObjectName("m_bClose"); m_bClose->setAutoDefault(TRUE); m_bClose->setFixedSize(m_bClose->sizeHint()); connect(m_bClose, SIGNAL(clicked()), this, SLOT(onClickClose())); @@ -128,12 +139,12 @@ OCCViewer_SetRotationPointDlg::OCCViewer_SetRotationPointDlg( OCCViewer_ViewWind aHBoxLayout2->addWidget(m_bClose); // Layout top level widgets - layoutDlg->addWidget(aCheckBox,0,0); - layoutDlg->addWidget(myGroupSelButton,1,0); + layoutDlg->addLayout(aCheckBox,0,0); + layoutDlg->addWidget(myGroupBoxSel,1,0); layoutDlg->addWidget(myGroupBoxCoord,2,0); layoutDlg->addWidget(aGroupBox,3,0); - setEnabled(myGroupSelButton,!myIsBBCenter->isChecked()); + setEnabled(myGroupBoxSel,!myIsBBCenter->isChecked()); setEnabled(myGroupBoxCoord,!myIsBBCenter->isChecked()); this->resize(400, this->sizeHint().height()); @@ -166,10 +177,11 @@ void OCCViewer_SetRotationPointDlg ::setEnabled(QGroupBox* theGrp, const bool theState) { - QObjectList aChildren(*theGrp->children()); + QObjectList aChildren(theGrp->children()); QObject* anObj; - for(anObj = aChildren.first(); anObj !=0; anObj = aChildren.next()) + for(int i = 0; i < aChildren.size(); i++) { + anObj = aChildren.at(i); if (anObj !=0 && anObj->inherits("QLineEdit")) ((QLineEdit*)anObj)->setReadOnly(!theState); if (anObj !=0 && anObj->inherits("QPushButton")) @@ -182,12 +194,12 @@ void OCCViewer_SetRotationPointDlg ::onBBCenterChecked() { - setEnabled(myGroupSelButton,!myIsBBCenter->isChecked()); + setEnabled(myGroupBoxSel,!myIsBBCenter->isChecked()); setEnabled(myGroupBoxCoord,!myIsBBCenter->isChecked()); if ( myIsBBCenter->isChecked() ) { - if ( mySelectPoint->state() == QButton::On ) + if ( mySelectPoint->isChecked() ) mySelectPoint->toggle(); myView->activateSetRotationGravity(); } @@ -201,7 +213,7 @@ void OCCViewer_SetRotationPointDlg ::onToOrigin() { - if ( mySelectPoint->state() == QButton::On ) + if ( mySelectPoint->isChecked() ) mySelectPoint->toggle(); setCoords(); myView->activateSetRotationSelected(myX->text().toDouble(), @@ -213,7 +225,7 @@ void OCCViewer_SetRotationPointDlg ::onSelectPoint() { - if ( mySelectPoint->state() == QButton::On ) + if ( mySelectPoint->isChecked() ) myView->activateStartPointSelection(); else mySelectPoint->toggle(); @@ -225,7 +237,7 @@ OCCViewer_SetRotationPointDlg { if ( !myIsBBCenter->isChecked() ) { - if ( mySelectPoint->state() == QButton::On + if ( mySelectPoint->isChecked() && ( myX->hasFocus() || myY->hasFocus() || myZ->hasFocus() ) ) mySelectPoint->toggle(); @@ -256,7 +268,7 @@ void OCCViewer_SetRotationPointDlg ::onClickClose() { - myAction->setOn( false ); + myAction->setChecked( false ); reject(); } @@ -264,7 +276,7 @@ void OCCViewer_SetRotationPointDlg ::onViewShow() { - if(myAction->isOn()) + if(myAction->isChecked()) show(); else hide(); diff --git a/src/OCCViewer/OCCViewer_SetRotationPointDlg.h b/src/OCCViewer/OCCViewer_SetRotationPointDlg.h index 18c1f654e..2e3a465f8 100644 --- a/src/OCCViewer/OCCViewer_SetRotationPointDlg.h +++ b/src/OCCViewer/OCCViewer_SetRotationPointDlg.h @@ -21,14 +21,13 @@ #include "OCCViewer.h" -#include +#include class QtxAction; class QLineEdit; class QPushButton; class QGroupBox; -class QButtonGroup; class QCheckBox; class OCCViewer_ViewWindow; @@ -39,7 +38,7 @@ class OCCVIEWER_EXPORT OCCViewer_SetRotationPointDlg : public QDialog public: OCCViewer_SetRotationPointDlg(OCCViewer_ViewWindow* , QWidget* parent = 0, - const char* name = 0, bool modal = FALSE, WFlags fl = 0); + const char* name = 0, bool modal = FALSE, Qt::WindowFlags fl = 0); ~OCCViewer_SetRotationPointDlg(); void SetAction( QtxAction* theAction ) { myAction = theAction; } @@ -54,7 +53,7 @@ protected: QCheckBox* myIsBBCenter; - QButtonGroup* myGroupSelButton; + QGroupBox * myGroupBoxSel; QPushButton* myToOrigin; QPushButton* mySelectPoint; diff --git a/src/OCCViewer/OCCViewer_ViewManager.cxx b/src/OCCViewer/OCCViewer_ViewManager.cxx index 3d799109f..39c740c5d 100755 --- a/src/OCCViewer/OCCViewer_ViewManager.cxx +++ b/src/OCCViewer/OCCViewer_ViewManager.cxx @@ -40,7 +40,7 @@ OCCViewer_ViewManager::~OCCViewer_ViewManager() Fills popup menu with custom actions \param popup - popup menu to be filled with */ -void OCCViewer_ViewManager::contextMenuPopup( QPopupMenu* popup ) +void OCCViewer_ViewManager::contextMenuPopup( QMenu* popup ) { SUIT_ViewManager::contextMenuPopup( popup ); // if it is necessary invoke method CreatePopup of ViewPort diff --git a/src/OCCViewer/OCCViewer_ViewManager.h b/src/OCCViewer/OCCViewer_ViewManager.h index ea88d3577..c39e43cf8 100755 --- a/src/OCCViewer/OCCViewer_ViewManager.h +++ b/src/OCCViewer/OCCViewer_ViewManager.h @@ -35,7 +35,7 @@ public: OCCViewer_Viewer* getOCCViewer() { return (OCCViewer_Viewer*) myViewModel; } - virtual void contextMenuPopup( QPopupMenu* ); + virtual void contextMenuPopup( QMenu* ); }; #endif diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index a58e95624..235ce3983 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -23,17 +23,21 @@ #include "OCCViewer_ViewPort3d.h" #include "SUIT_ViewWindow.h" +#include "SUIT_ViewManager.h" #include "SUIT_Desktop.h" #include "SUIT_Session.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include +#include #include #include @@ -156,7 +160,7 @@ void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager) SUIT_ViewModel::setViewManager(theViewManager); if (theViewManager) { connect(theViewManager, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)), - this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); + this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*))); connect(theViewManager, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)), this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*))); @@ -200,7 +204,7 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y()); OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow; - bool aHasShift = (theEvent->state() & Qt::ShiftButton); + bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); if (!aHasShift) emit deselection(); @@ -251,10 +255,10 @@ void OCCViewer_Viewer::enableSelection(bool isEnabled) if ( !myViewManager ) return; - QPtrVector wins = myViewManager->getViews(); + QVector wins = myViewManager->getViews(); for ( int i = 0; i < (int)wins.count(); i++ ) { - OCCViewer_ViewWindow* win = ::qt_cast( wins.at( i ) ); + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); if ( win ) win->updateEnabledDrawMode(); } @@ -271,10 +275,10 @@ void OCCViewer_Viewer::enableMultiselection(bool isEnable) if ( !myViewManager ) return; - QPtrVector wins = myViewManager->getViews(); + QVector wins = myViewManager->getViews(); for ( int i = 0; i < (int)wins.count(); i++ ) { - OCCViewer_ViewWindow* win = ::qt_cast( wins.at( i ) ); + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); if ( win ) win->updateEnabledDrawMode(); } @@ -283,16 +287,16 @@ void OCCViewer_Viewer::enableMultiselection(bool isEnable) /*! Builds popup for occ viewer */ -void OCCViewer_Viewer::contextMenuPopup(QPopupMenu* thePopup) +void OCCViewer_Viewer::contextMenuPopup(QMenu* thePopup) { - thePopup->insertItem( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); - thePopup->insertItem( tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); + thePopup->addAction( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); + thePopup->addAction( tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); - thePopup->insertSeparator(); + thePopup->addSeparator(); OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); if ( aView && !aView->getToolBar()->isVisible() ) - thePopup->insertItem( tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); + thePopup->addAction( tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); } /*! diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 654dec238..b21b1660c 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -19,8 +19,8 @@ #ifndef OCCVIEWER_VIEWMODEL_H #define OCCVIEWER_VIEWMODEL_H -#include -#include +#include +#include #include "OCCViewer.h" @@ -28,13 +28,16 @@ #include #include -#include #include +class QMouseEvent; + class SUIT_ViewWindow; class SUIT_Desktop; class OCCViewer_ViewWindow; +class AIS_ListOfInteractive; + struct viewAspect { public: @@ -54,7 +57,7 @@ public: QString name; }; -typedef QValueList viewAspectList; +typedef QList viewAspectList; #ifdef WIN32 #pragma warning( disable:4251 ) @@ -72,17 +75,16 @@ public: void update(); - virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); - - virtual void setViewManager(SUIT_ViewManager* theViewManager); + virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); + + virtual void setViewManager(SUIT_ViewManager* theViewManager); virtual QString getType() const { return Type(); } - virtual void contextMenuPopup(QPopupMenu*); + virtual void contextMenuPopup(QMenu*); void getSelectedObjects(AIS_ListOfInteractive& theList); void setObjectsSelected(const AIS_ListOfInteractive& theList); - void setSelected(const Handle(AIS_InteractiveObject)& theIO) - { myAISContext->SetSelected(theIO);} + void setSelected(const Handle(AIS_InteractiveObject)& theIO) { myAISContext->SetSelected(theIO);} void performSelectionChanged(); // emit signal selectionChanged @@ -115,19 +117,16 @@ public: Handle(AIS_Trihedron) getTrihedron() const { return myTrihedron; } void enableSelection(bool isEnabled); - bool isSelectionEnabled() const - { return mySelectionEnabled; } + bool isSelectionEnabled() const { return mySelectionEnabled; } void enableMultiselection(bool isEnable); - bool isMultiSelectionEnabled() const - { return myMultiSelectionEnabled; } + bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; } - int getSelectionCount() const - { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; } + int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; } /* Selection management */ - bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true ); - bool unHighlightAll( bool=true ); + bool highlight( const Handle(AIS_InteractiveObject)&, bool, bool=true ); + bool unHighlightAll( bool=true ); bool isInViewer( const Handle(AIS_InteractiveObject)&, bool=false ); bool isVisible( const Handle(AIS_InteractiveObject)& ); diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx index ff4ef0551..510e9b575 100755 --- a/src/OCCViewer/OCCViewer_ViewPort.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -25,13 +25,16 @@ #include "SUIT_Session.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -70,104 +73,106 @@ CMapEntry::CMapEntry() CMapEntry::~CMapEntry() { if ( alloc ) - XFreeColormap( QPaintDevice::x11AppDisplay(), cmap ); + XFreeColormap( QX11Info::display(), cmap ); } -static QIntDict *cmap_dict = 0; +static QMultiHash *cmap_dict = 0; static bool mesa_gl = false; static void cleanup_cmaps() { if ( !cmap_dict ) return; - cmap_dict->setAutoDelete( true ); + //while (!cmap_dict->isEmpty()) + // cmap_dict->erase(cmap_dict->begin()); + cmap_dict->clear(); delete cmap_dict; cmap_dict = 0; } static Colormap choose_cmap( Display *dpy, XVisualInfo *vi ) { - if ( !cmap_dict ) - { - cmap_dict = new QIntDict; - const char *v = glXQueryServerString( dpy, vi->screen, GLX_VERSION ); - mesa_gl = strstr( v,"Mesa" ) != 0; - qAddPostRoutine( cleanup_cmaps ); - } - - CMapEntry *x = cmap_dict->find( (long)vi->visualid ); - if ( x ) // found colormap for visual - return x->cmap; - - x = new CMapEntry(); - - XStandardColormap *c; - int n, i; + if ( !cmap_dict ) + { + cmap_dict = new QMultiHash; + const char *v = glXQueryServerString( dpy, vi->screen, GLX_VERSION ); + mesa_gl = strstr( v,"Mesa" ) != 0; + qAddPostRoutine( cleanup_cmaps ); + } + + QHash::iterator itH = cmap_dict->find( (long)vi->visualid ); + if ( itH != cmap_dict->end() ) // found colormap for visual + return itH.value().cmap; + + CMapEntry x; + + XStandardColormap *c; + int n, i; - //#ifdef DEBUG - //cout << "Choosing cmap for vID = " << vi->visualid << endl; - //#endif + //#ifdef DEBUG + //cout << "Choosing cmap for vID = " << vi->visualid << endl; + //#endif - if ( vi->visualid == XVisualIDFromVisual( (Visual*)QPaintDevice::x11AppVisual() ) ) - { + if ( vi->visualid == XVisualIDFromVisual( (Visual*)QX11Info::appVisual() ) ) + { #ifdef DEBUG - cout << "Using x11AppColormap" << endl; + cout << "Using x11AppColormap" << endl; #endif - return QPaintDevice::x11AppColormap(); - } + return QX11Info::appColormap(); + } - if ( mesa_gl ) + if ( mesa_gl ) + { + Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true ); + if ( hp_cmaps && vi->visual->c_class == TrueColor && vi->depth == 8 ) + { + if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, hp_cmaps ) ) + { + i = 0; + while ( i < n && x.cmap == 0 ) { - Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true ); - if ( hp_cmaps && vi->visual->c_class == TrueColor && vi->depth == 8 ) - { - if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, hp_cmaps ) ) - { - i = 0; - while ( i < n && x->cmap == 0 ) - { - if ( c[i].visualid == vi->visual->visualid ) - { - x->cmap = c[i].colormap; - x->scmap = c[i]; - } - i++; - } - XFree( (char*)c ); - } - } + if ( c[i].visualid == vi->visual->visualid ) + { + x.cmap = c[i].colormap; + x.scmap = c[i]; + } + i++; } + XFree( (char*)c ); + } + } + } #if !defined( _OS_SOLARIS_ ) - if ( !x->cmap ) + if ( !x.cmap ) + { + if ( XmuLookupStandardColormap( dpy, vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP, false, true ) ) { - if ( XmuLookupStandardColormap( dpy, vi->screen, vi->visualid, vi->depth, XA_RGB_DEFAULT_MAP, false, true ) ) - { - if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, XA_RGB_DEFAULT_MAP ) ) - { - i = 0; - while ( i < n && x->cmap == 0 ) - { - if ( c[i].visualid == vi->visualid ) - { - x->cmap = c[i].colormap; - x->scmap = c[i]; - } - i++; - } - XFree( (char *)c ); - } - } - } -#endif - if ( !x->cmap ) + if ( XGetRGBColormaps( dpy, RootWindow( dpy, vi->screen ), &c, &n, XA_RGB_DEFAULT_MAP ) ) + { + i = 0; + while ( i < n && x.cmap == 0 ) { - // no shared cmap found - x->cmap = XCreateColormap( dpy, RootWindow( dpy, vi->screen ), vi->visual, AllocNone ); - x->alloc = true; + if ( c[i].visualid == vi->visualid ) + { + x.cmap = c[i].colormap; + x.scmap = c[i]; + } + i++; } - - cmap_dict->insert( (long)vi->visualid, x ); // associate cmap with visualid - return x->cmap; + XFree( (char *)c ); + } + } + } +#endif + if ( !x.cmap ) + { + // no shared cmap found + x.cmap = XCreateColormap( dpy, RootWindow( dpy, vi->screen ), vi->visual, AllocNone ); + x.alloc = true; + } + + cmap_dict->insert( (long)vi->visualid, x ); // associate cmap with visualid + return x.cmap; } #endif @@ -176,7 +181,7 @@ static Colormap choose_cmap( Display *dpy, XVisualInfo *vi ) Constructor */ OCCViewer_ViewPort::OCCViewer_ViewPort( QWidget* parent ) -: QWidget( parent, 0, WRepaintNoErase | WResizeNoErase ) +: QWidget( parent ) { initialize(); } @@ -194,15 +199,14 @@ OCCViewer_ViewPort::~OCCViewer_ViewPort() */ void OCCViewer_ViewPort::initialize() { - myPopupActions.setAutoDelete( true ); myPaintersRedrawing = false; myEnableSketching = false; myEnableTransform = true; setMouseTracking( true ); - setBackgroundMode( NoBackground ); + setBackgroundRole( QPalette::NoRole );//NoBackground ); // set focus policy to threat QContextMenuEvent from keyboard - setFocusPolicy( StrongFocus ); + setFocusPolicy( Qt::StrongFocus ); } /*! @@ -219,57 +223,57 @@ void OCCViewer_ViewPort::selectVisualId() { #if !defined WNT XVisualInfo* pVisualInfo; - if ( x11Display() ) + if ( QX11Info::display() ) { /* Initialization with the default VisualID */ - Visual *v = DefaultVisual( x11Display(), DefaultScreen( x11Display() ) ); + Visual *v = DefaultVisual( QX11Info::display(), DefaultScreen( QX11Info::display() ) ); int visualID = XVisualIDFromVisual( v ); /* 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 }; - pVisualInfo = ::glXChooseVisual( x11Display(), DefaultScreen( x11Display() ), visualAttr ); + pVisualInfo = ::glXChooseVisual( QX11Info::display(), DefaultScreen( QX11Info::display() ), visualAttr ); if ( isVisible() ) - hide(); + hide(); XSetWindowAttributes a; - a.colormap = choose_cmap( x11Display(), pVisualInfo ); /* find best colormap */ - a.background_pixel = backgroundColor().pixel(); - a.border_pixel = black.pixel(); - Window p = RootWindow( x11Display(), DefaultScreen( x11Display() ) ); + a.colormap = choose_cmap( QX11Info::display(), pVisualInfo ); /* find best colormap */ + a.background_pixel = QColormap::instance().pixel( backgroundColor() ); + a.border_pixel = QColormap::instance().pixel( Qt::black ); + Window p = RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ); if ( parentWidget() ) - p = parentWidget()->winId(); + p = parentWidget()->winId(); - Window w; + Window w; /* if ( type == Type2D ) // creating simple X window for 2d { unsigned long xbackground = - BlackPixel( x11Display(), DefaultScreen( x11Display() ) ); + BlackPixel( QX11Info::display(), DefaultScreen( QX11Info::display() ) ); unsigned long xforeground = - WhitePixel( x11Display(), DefaultScreen( x11Display() ) ); + WhitePixel( QX11Info::display(), DefaultScreen( QX11Info::display() ) ); - w = XCreateSimpleWindow ( x11Display(), p, x(), y(), width(), + w = XCreateSimpleWindow ( QX11Info::display(), p, x(), y(), width(), height(), 0, xforeground, xbackground ); } else if ( type == Type3D ) { - w = XCreateWindow( x11Display(), p, x(), y(), width(), height(), + w = XCreateWindow( QX11Info::display(), p, x(), y(), width(), height(), 0, pVisualInfo->depth, InputOutput, pVisualInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &a ); } else return;*/ - w = XCreateWindow( x11Display(), p, x(), y(), width(), height(), + w = XCreateWindow( QX11Info::display(), p, x(), y(), width(), height(), 0, pVisualInfo->depth, InputOutput, pVisualInfo->visual, CWBackPixel | CWBorderPixel | CWColormap, &a ); Window *cmw; Window *cmwret; int count; - if ( XGetWMColormapWindows( x11Display(), topLevelWidget()->winId(), &cmwret, &count ) ) + if ( XGetWMColormapWindows( QX11Info::display(), topLevelWidget()->winId(), &cmwret, &count ) ) { cmw = new Window[count+1]; memcpy( (char*)cmw, (char*)cmwret, sizeof(Window) * count ); @@ -297,7 +301,7 @@ void OCCViewer_ViewPort::selectVisualId() /* Creating new window (with good VisualID) for this widget */ create(w); - XSetWMColormapWindows( x11Display(), topLevelWidget()->winId(), cmw, count ); + XSetWMColormapWindows( QX11Info::display(), topLevelWidget()->winId(), cmw, count ); delete[] cmw; if ( isVisible() ) @@ -307,7 +311,7 @@ void OCCViewer_ViewPort::selectVisualId() { XFree( (char *)pVisualInfo ); } - XFlush( x11Display() ); + XFlush( QX11Info::display() ); } #endif } @@ -318,7 +322,7 @@ void OCCViewer_ViewPort::selectVisualId() void OCCViewer_ViewPort::setBackgroundColor( const QColor& color ) { QPalette pal = palette(); - pal.setColor( QColorGroup::Background, color ); + pal.setColor( QPalette::Background, color ); setPalette( pal ); repaint(); emit vpChangeBGColor( color ); @@ -329,7 +333,7 @@ void OCCViewer_ViewPort::setBackgroundColor( const QColor& color ) */ QColor OCCViewer_ViewPort::backgroundColor() const { - return palette().active().background(); + return palette().color( QPalette::Active, QPalette::Background ); } /*! @@ -466,6 +470,8 @@ void OCCViewer_ViewPort::onUpdate() { for ( QtxAction* a = myPopupActions.first(); a; a = myPopupActions.next() ) a->removeFrom( popup ); + //while (!myPopupActions.isEmpty()) + // delete myPopupActions.takeFirst(); myPopupActions.clear(); } }*/ diff --git a/src/OCCViewer/OCCViewer_ViewPort.h b/src/OCCViewer/OCCViewer_ViewPort.h index b4742b293..49fcc855f 100755 --- a/src/OCCViewer/OCCViewer_ViewPort.h +++ b/src/OCCViewer/OCCViewer_ViewPort.h @@ -23,17 +23,15 @@ #include "QtxAction.h" -#include -#include -#include +#include +#include #include +class QColor; class QRect; -class QCursor; class QPainter; class OCCViewer_ViewSketcher; -class OCCViewer_ViewTransformer; #ifdef WIN32 #pragma warning ( disable:4251 ) @@ -45,74 +43,74 @@ class OCCViewer_ViewTransformer; */ class OCCVIEWER_EXPORT OCCViewer_ViewPort : public QWidget { - Q_OBJECT + Q_OBJECT friend class OCCViewer_ViewSketcher; public: OCCViewer_ViewPort( QWidget* parent ); - virtual ~OCCViewer_ViewPort(); + virtual ~OCCViewer_ViewPort(); public: - void setSketchingEnabled( bool ); + void setSketchingEnabled( bool ); bool isSketchingEnabled() const; void setTransformEnabled( bool ); bool isTransformEnabled() const; - virtual QColor backgroundColor() const; - virtual void setBackgroundColor( const QColor& ); + virtual QColor backgroundColor() const; + virtual void setBackgroundColor( const QColor& ); void redrawPainters(); - virtual void onUpdate(); + virtual void onUpdate(); protected: // enum ViewType { Type2D, Type3D }; - void selectVisualId(); + void selectVisualId(); // EVENTS - virtual void paintEvent( QPaintEvent *); - virtual void mouseMoveEvent( QMouseEvent *); - virtual void mouseReleaseEvent( QMouseEvent *); - virtual void mousePressEvent( QMouseEvent *); - virtual void mouseDoubleClickEvent( QMouseEvent *); - virtual void keyPressEvent( QKeyEvent *); - virtual void keyReleaseEvent( QKeyEvent *); + virtual void paintEvent( QPaintEvent *); + virtual void mouseMoveEvent( QMouseEvent *); + virtual void mouseReleaseEvent( QMouseEvent *); + virtual void mousePressEvent( QMouseEvent *); + virtual void mouseDoubleClickEvent( QMouseEvent *); + virtual void keyPressEvent( QKeyEvent *); + virtual void keyReleaseEvent( QKeyEvent *); // TO BE REDEFINED virtual void reset() = 0; virtual void pan( int, int ) = 0; - virtual void setCenter( int, int ) = 0; - virtual void fitRect( const QRect& ) = 0; + virtual void setCenter( int, int ) = 0; + virtual void fitRect( const QRect& ) = 0; virtual void zoom( int, int, int, int ) = 0; virtual void fitAll( bool keepScale = false, bool withZ = true, bool upd = true ) = 0; // POPUP // void onCreatePopup( QPopupMenu* ); -// void onDestroyPopup( QPopupMenu* ); +// void onDestroyPopup( QPopupMenu* ); protected slots: virtual void onChangeBgColor(); signals: - void vpKeyEvent( QKeyEvent* ); - void vpMouseEvent( QMouseEvent* ); - void vpDrawExternal( QPainter* ); + void vpKeyEvent( QKeyEvent* ); + void vpMouseEvent( QMouseEvent* ); + void vpDrawExternal( QPainter* ); void vpChangeBGColor( QColor ); private: - void initialize(); - void cleanup(); + void initialize(); + void cleanup(); protected: - Handle(Aspect_Window) myWindow; - bool myEnableSketching; - bool myEnableTransform; - bool myPaintersRedrawing; /* set to draw externally */ - QPtrList myPopupActions; + Handle(Aspect_Window) myWindow; + bool myEnableSketching; + bool myEnableTransform; + bool myPaintersRedrawing; /* set to draw externally */ + QList myPopupActions; private: - static int nCounter; /* objects counter */ + static int nCounter; /* objects counter */ }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index cbeb3ce9c..0c5471704 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -22,11 +22,14 @@ #include "OCCViewer_VService.h" #include "OCCViewer_ViewWindow.h" -#include -#include -#include +#include +#include +#include +#include +#include #include +#include #include #include diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h index 4f840bd02..1eb9689f9 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.h +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -21,35 +21,35 @@ #include "OCCViewer_ViewPort.h" -#include - #include -#include +class QColor; class QRect; +class Handle(V3d_Viewer); + #ifdef WIN32 #pragma warning ( disable:4251 ) #endif class OCCVIEWER_EXPORT OCCViewer_ViewPort3d: public OCCViewer_ViewPort { - Q_OBJECT + Q_OBJECT friend class OCCViewer_ViewTransformer; public: - OCCViewer_ViewPort3d( QWidget*, const Handle(V3d_Viewer)&, V3d_TypeOfView = V3d_ORTHOGRAPHIC ); - virtual ~OCCViewer_ViewPort3d(); + OCCViewer_ViewPort3d( QWidget*, const Handle(V3d_Viewer)&, V3d_TypeOfView = V3d_ORTHOGRAPHIC ); + virtual ~OCCViewer_ViewPort3d(); public: - Handle(V3d_View) getView() const; - Handle(V3d_View) setView( const Handle(V3d_View)& ); - Handle(V3d_Viewer) getViewer() const; + Handle(V3d_View) getView() const; + Handle(V3d_View) setView( const Handle(V3d_View)& ); + Handle(V3d_Viewer) getViewer() const; void setAnimationMode(bool theDegenerated); - virtual void setBackgroundColor( const QColor& color); + virtual void setBackgroundColor( const QColor& color); virtual QColor backgroundColor() const; // void setActive( V3d_TypeOfView ); @@ -63,34 +63,34 @@ public: // TRANSFORMATIONS virtual void reset(); virtual void pan( int , int ); - virtual void setCenter( int , int ); - virtual void fitRect( const QRect& ); - virtual void zoom( int, int, int, int ); + virtual void setCenter( int , int ); + virtual void fitRect( const QRect& ); + virtual void zoom( int, int, int, int ); virtual void fitAll( bool keepScale = false, bool withZ = true, bool upd = true ); - void startRotation( int, int, int, const gp_Pnt& ); - void rotate( int, int, int, const gp_Pnt& ); - void endRotation(); + void startRotation( int, int, int, const gp_Pnt& ); + void rotate( int, int, int, const gp_Pnt& ); + void endRotation(); protected: // EVENTS - virtual void paintEvent( QPaintEvent* ); - virtual void resizeEvent( QResizeEvent* ); + virtual void paintEvent( QPaintEvent* ); + virtual void resizeEvent( QResizeEvent* ); private: - Handle(V3d_View) activeView() const; - Handle(V3d_View) inactiveView() const; - bool mapView( const Handle(V3d_View)& ); - bool setWindow( const Handle(V3d_View)& ); - bool mapped( const Handle(V3d_View)& ) const; + Handle(V3d_View) activeView() const; + Handle(V3d_View) inactiveView() const; + bool mapView( const Handle(V3d_View)& ); + bool setWindow( const Handle(V3d_View)& ); + bool mapped( const Handle(V3d_View)& ) const; private: - Handle(V3d_View) myOrthoView; - Handle(V3d_View) myPerspView; - Handle(V3d_View) myActiveView; - bool myDegenerated; - bool myAnimate; - double myScale; + Handle(V3d_View) myOrthoView; + Handle(V3d_View) myPerspView; + Handle(V3d_View) myActiveView; + bool myDegenerated; + bool myAnimate; + double myScale; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 0ec1a641d..935d4dc78 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -29,24 +29,24 @@ #include "SUIT_Desktop.h" #include "SUIT_Session.h" #include "SUIT_ToolButton.h" +#include "SUIT_ViewManager.h" #include "SUIT_Tools.h" #include "SUIT_ResourceMgr.h" #include "SUIT_MessageBox.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include #include @@ -197,7 +197,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_V void OCCViewer_ViewWindow::initLayout() { myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC ); - myViewPort->setBackgroundColor(black); + myViewPort->setBackgroundColor(Qt::black); myViewPort->installEventFilter(this); setCentralWidget(myViewPort); myOperation = NOTHING; @@ -211,8 +211,8 @@ void OCCViewer_ViewWindow::initLayout() setTransformInProcess ( false ); myToolBar = new QToolBar(this); - myToolBar->setCloseMode(QDockWindow::Undocked); - myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL")); + //myToolBar->setCloseMode(QDockWindow::Undocked); // toolbar has "Close" (X) button only if it's undocked, but there is no such functionality in Qt4 + myToolBar->setWindowTitle(tr("LBL_TOOLBAR_LABEL")); createActions(); createToolBar(); @@ -225,13 +225,13 @@ void OCCViewer_ViewWindow::initLayout() OCCViewer_ViewWindow::OperationType OCCViewer_ViewWindow::getButtonState(QMouseEvent* theEvent) { OperationType aOp = NOTHING; - if( (theEvent->state() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::ZOOM]) && + if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::ZOOM]) && (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::ZOOM]) ) aOp = ZOOMVIEW; - else if( (theEvent->state() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::PAN]) && + else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::PAN]) && (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::PAN]) ) aOp = PANVIEW; - else if( (theEvent->state() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::ROTATE]) && + else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::ROTATE]) && (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::ROTATE]) ) aOp = ROTATE; @@ -534,7 +534,7 @@ void OCCViewer_ViewWindow::activateSetRotationGravity() */ void OCCViewer_ViewWindow::updateGravityCoords() { - if ( mySetRotationPointDlg && mySetRotationPointDlg->isShown() && myCurrPointType == GRAVITY ) + if ( mySetRotationPointDlg && mySetRotationPointDlg->isVisible() && myCurrPointType == GRAVITY ) { Standard_Real Xcenter, Ycenter, Zcenter; if ( computeGravityCenter( Xcenter, Ycenter, Zcenter ) ) @@ -680,10 +680,10 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent) emit mouseMoving( this, theEvent ); else { - int aState = theEvent->state(); - //int aButton = theEvent->button(); - if ( aState == Qt::LeftButton || - aState == ( Qt::LeftButton | Qt::ShiftButton) ) { + int aState = theEvent->modifiers(); + int aButton = theEvent->button(); + if ( aButton == Qt::LeftButton || + ( aButton == Qt::LeftButton && aState == Qt::ShiftModifier ) ) { myDrawRect = myEnableDrawMode; if ( myDrawRect ) { drawRect(); @@ -711,11 +711,10 @@ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) case NOTHING: { emit mouseReleased(this, theEvent); - if(theEvent->button() == RightButton) + if(theEvent->button() == Qt::RightButton) { QContextMenuEvent aEvent( QContextMenuEvent::Mouse, - theEvent->pos(), theEvent->globalPos(), - theEvent->state() ); + theEvent->pos(), theEvent->globalPos() ); emit contextMenuRequested( &aEvent ); } } @@ -739,7 +738,7 @@ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) break; case WINDOWFIT: - if ( theEvent->state() == Qt::LeftButton ) { + if ( theEvent->button() == Qt::LeftButton ) { myCurrX = theEvent->x(); myCurrY = theEvent->y(); QRect rect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); @@ -797,14 +796,17 @@ void OCCViewer_ViewWindow::resetState() */ void OCCViewer_ViewWindow::drawRect() { - QPainter aPainter(myViewPort); - aPainter.setRasterOp(Qt::XorROP); - aPainter.setPen(Qt::white); + QRubberBand* aRB = new QRubberBand( QRubberBand::Rectangle, myViewPort ); QRect aRect = SUIT_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); - if ( !myRect.isEmpty() ) - aPainter.drawRect( myRect ); - aPainter.drawRect(aRect); + if ( !myRect.isEmpty() ) { + aRB->setGeometry( myRect ); + aRB->setVisible( myRect.isValid() ); + } + aRB->setGeometry( aRect ); + aRB->setVisible( aRect.isValid() ); myRect = aRect; + + delete aRB; } /*! @@ -864,7 +866,7 @@ void OCCViewer_ViewWindow::createActions() mySetRotationPointAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_ROTATION_POINT" ) ), tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this); mySetRotationPointAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW")); - mySetRotationPointAction->setToggleAction( true ); + mySetRotationPointAction->setCheckable( true ); connect(mySetRotationPointAction, SIGNAL(toggled( bool )), this, SLOT(onSetRotationPoint( bool ))); myActionsMap[ ChangeRotationPointId ] = mySetRotationPointAction; @@ -929,7 +931,7 @@ void OCCViewer_ViewWindow::createActions() myClippingAction = new QtxAction(tr("MNU_CLIPPING"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ) ), tr( "MNU_CLIPPING" ), 0, this); myClippingAction->setStatusTip(tr("DSC_CLIPPING")); - myClippingAction->setToggleAction( true ); + myClippingAction->setCheckable( true ); connect(myClippingAction, SIGNAL(toggled( bool )), this, SLOT(onClipping( bool ))); myActionsMap[ ClippingId ] = myClippingAction; @@ -1106,7 +1108,7 @@ void OCCViewer_ViewWindow::onSetRotationPoint( bool on ) mySetRotationPointDlg->SetAction( mySetRotationPointAction ); } - if ( !mySetRotationPointDlg->isShown() ) + if ( !mySetRotationPointDlg->isVisible() ) { if ( mySetRotationPointDlg->IsFirstShown() ) { @@ -1119,7 +1121,7 @@ void OCCViewer_ViewWindow::onSetRotationPoint( bool on ) } else { - if ( mySetRotationPointDlg->isShown() ) + if ( mySetRotationPointDlg->isVisible() ) mySetRotationPointDlg->hide(); } } @@ -1140,9 +1142,9 @@ void OCCViewer_ViewWindow::onClipping( bool on ) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); if ( on ) - myActionsMap[ ClippingId ]->setIconSet(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING_PRESSED" ))); + myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING_PRESSED" ))); else - myActionsMap[ ClippingId ]->setIconSet(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ))); + myActionsMap[ ClippingId ]->setIcon(aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_CLIPPING" ))); if ( on ) { @@ -1152,12 +1154,12 @@ void OCCViewer_ViewWindow::onClipping( bool on ) myClippingDlg->SetAction( myClippingAction ); } - if ( !myClippingDlg->isShown() ) + if ( !myClippingDlg->isVisible() ) myClippingDlg->show(); } else { - if ( myClippingDlg->isShown() ) + if ( myClippingDlg->isVisible() ) myClippingDlg->hide(); setCuttingPlane(false); } @@ -1225,7 +1227,7 @@ void OCCViewer_ViewWindow::onTrihedronShow() QImage OCCViewer_ViewWindow::dumpView() { QPixmap px = QPixmap::grabWindow( myViewPort->winId() ); - return px.convertToImage(); + return px.toImage(); } /*! @@ -1337,7 +1339,7 @@ QString OCCViewer_ViewWindow::getVisualParameters() */ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) { - QStringList paramsLst = QStringList::split( '*', parameters, true ); + QStringList paramsLst = parameters.split( '*' ); if ( paramsLst.size() == 13 ) { viewAspect params; params.scale = paramsLst[0].toDouble(); diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index 9c3841412..2d3d2aa37 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -25,8 +25,7 @@ #include "QtxAction.h" -#include -#include +#include class SUIT_Desktop; class OCCViewer_ViewPort3d; diff --git a/src/Qtx/QtxListBox.h b/src/Qtx/QtxListBox.h index 180d2cafb..e2e9076b4 100755 --- a/src/Qtx/QtxListBox.h +++ b/src/Qtx/QtxListBox.h @@ -24,7 +24,11 @@ #include "Qtx.h" -#include +// This file isn't yet ported to Qt4 => there are some corrections for OCCViewer porting --> +//#include +#include +#include +// <-- #ifdef WIN32 #pragma warning( disable:4251 ) @@ -33,27 +37,27 @@ class QLineEdit; class QValidator; -class QTX_EXPORT QtxListBox : public QListBox +class QTX_EXPORT QtxListBox : public QListWidget//QListBox // This file isn't yet ported to Qt4 => there are some corrections for OCCViewer porting { Q_OBJECT public: - QtxListBox( QWidget* = 0, const char* = 0, WFlags = 0 ); + QtxListBox( QWidget* = 0, const char* = 0, Qt::WindowFlags = 0 ); virtual ~QtxListBox(); bool isEditEnabled() const; bool defaultEditAction() const; bool isModificationEnabled() const; - QListBoxItem* editedItem() const; + QListWidgetItem* editedItem() const; int editedIndex() const; void startEdition( const int ); - void startEdition( const QListBoxItem* ); + void startEdition( const QListWidgetItem* ); void endEdition( const bool ); void ensureItemVisible( const int ); - void ensureItemVisible( const QListBoxItem* ); + void ensureItemVisible( const QListWidgetItem* ); virtual bool eventFilter( QObject*, QEvent* ); @@ -68,7 +72,7 @@ public: signals: void itemEdited( int ); - void itemEdited( QListBoxItem* ); + void itemEdited( QListWidgetItem* ); void itemMoved( int, int ); public slots: diff --git a/src/src.pro b/src/src.pro index 04c513cfa..a610dcbcc 100644 --- a/src/src.pro +++ b/src/src.pro @@ -14,5 +14,6 @@ SUBDIRS += PyInterp SUBDIRS += PyConsole SUBDIRS += Prs SUBDIRS += OBJECT +SUBDIRS += OCCViewer SUBDIRS += Event -- 2.39.2