X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FOCCViewer%2FOCCViewer_SetRotationPointDlg.cxx;h=bd63d0a64152187f78ad3046f98ffa089f8b2248;hb=f52f29e2784cc9ab3e4d7910354edaa4fa75a6db;hp=0aed2c230fd9a64bd963ae236085d65edb686f6b;hpb=f830c97c748d8f8a6a7eccc8e3a58e19066a1181;p=modules%2Fgui.git diff --git a/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx b/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx index 0aed2c230..bd63d0a64 100644 --- a/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx +++ b/src/OCCViewer/OCCViewer_SetRotationPointDlg.cxx @@ -1,11 +1,14 @@ -// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License. // -// This library is distributed in the hope that it will be useful +// This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. @@ -16,22 +19,21 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + #include "OCCViewer_SetRotationPointDlg.h" #include #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 +43,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, const char* name, bool modal, Qt::WindowFlags fl ) +: QDialog( view, 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 +59,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; - 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 +102,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 +111,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 +133,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 +143,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 +181,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,38 +198,38 @@ 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(); } else myView->activateSetRotationSelected(myX->text().toDouble(), - myY->text().toDouble(), - myZ->text().toDouble()); + myY->text().toDouble(), + myZ->text().toDouble()); } void OCCViewer_SetRotationPointDlg ::onToOrigin() { - if ( mySelectPoint->state() == QButton::On ) + if ( mySelectPoint->isChecked() ) mySelectPoint->toggle(); setCoords(); myView->activateSetRotationSelected(myX->text().toDouble(), - myY->text().toDouble(), - myZ->text().toDouble()); + myY->text().toDouble(), + myZ->text().toDouble()); } void OCCViewer_SetRotationPointDlg ::onSelectPoint() { - if ( mySelectPoint->state() == QButton::On ) + if ( mySelectPoint->isChecked() ) myView->activateStartPointSelection(); else mySelectPoint->toggle(); @@ -225,13 +241,13 @@ OCCViewer_SetRotationPointDlg { if ( !myIsBBCenter->isChecked() ) { - if ( mySelectPoint->state() == QButton::On - && - ( myX->hasFocus() || myY->hasFocus() || myZ->hasFocus() ) ) + if ( mySelectPoint->isChecked() + && + ( myX->hasFocus() || myY->hasFocus() || myZ->hasFocus() ) ) mySelectPoint->toggle(); myView->activateSetRotationSelected(myX->text().toDouble(), - myY->text().toDouble(), - myZ->text().toDouble()); + myY->text().toDouble(), + myZ->text().toDouble()); } } @@ -256,7 +272,7 @@ void OCCViewer_SetRotationPointDlg ::onClickClose() { - myAction->setOn( false ); + myAction->setChecked( false ); reject(); } @@ -264,7 +280,7 @@ void OCCViewer_SetRotationPointDlg ::onViewShow() { - if(myAction->isOn()) + if(myAction->isChecked()) show(); else hide(); @@ -276,3 +292,14 @@ OCCViewer_SetRotationPointDlg { hide(); } + +/*! + Custom handling of close event: toggle action +*/ +void +OCCViewer_SetRotationPointDlg +::closeEvent( QCloseEvent* e ) +{ + myAction->setChecked( false ); + QDialog::closeEvent( e ); +}