From 5e92f3050993862edf41261db59fa4ccaf5745f0 Mon Sep 17 00:00:00 2001 From: mzn Date: Wed, 18 Dec 2013 13:09:55 +0000 Subject: [PATCH] Feature #228: Import of polylines from GEOM. Implementation of GUI part. --- ...acleDlg.cxx => HYDROGUI_GeomObjectDlg.cxx} | 115 +++++++++--------- ...ObstacleDlg.h => HYDROGUI_GeomObjectDlg.h} | 29 ++--- 2 files changed, 73 insertions(+), 71 deletions(-) rename src/HYDROGUI/{HYDROGUI_ObstacleDlg.cxx => HYDROGUI_GeomObjectDlg.cxx} (59%) rename src/HYDROGUI/{HYDROGUI_ObstacleDlg.h => HYDROGUI_GeomObjectDlg.h} (69%) diff --git a/src/HYDROGUI/HYDROGUI_ObstacleDlg.cxx b/src/HYDROGUI/HYDROGUI_GeomObjectDlg.cxx similarity index 59% rename from src/HYDROGUI/HYDROGUI_ObstacleDlg.cxx rename to src/HYDROGUI/HYDROGUI_GeomObjectDlg.cxx index 2697c8d3..f3275eb3 100644 --- a/src/HYDROGUI/HYDROGUI_ObstacleDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_GeomObjectDlg.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include "HYDROGUI_ObstacleDlg.h" +#include "HYDROGUI_GeomObjectDlg.h" #include "HYDROGUI_Tool.h" @@ -39,11 +39,12 @@ static QString lastUsedFilter; -HYDROGUI_ObstacleDlg::HYDROGUI_ObstacleDlg( HYDROGUI_Module* theModule, const QString& theTitle, - const bool theIsToEnableFileSelection ) +HYDROGUI_GeomObjectDlg::HYDROGUI_GeomObjectDlg( HYDROGUI_Module* theModule, const QString& theTitle, + const QString& theObjectTypeName, + const bool theIsToEnableFileSelection ) : HYDROGUI_InputPanel( theModule, theTitle ), - myFileSelectionEnabled ( theIsToEnableFileSelection ), - myDefaultName( tr("DEFAULT_OBSTACLE_NAME") ) + myFileSelectionEnabled( theIsToEnableFileSelection ), + myDefaultName( theObjectTypeName ) { // Get resource manager SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -73,110 +74,110 @@ HYDROGUI_ObstacleDlg::HYDROGUI_ObstacleDlg( HYDROGUI_Module* theModule, const QS } // Obstacle name - myObstacleNameGroup = new QGroupBox( tr( "OBSTACLE_NAME" ), this ); + myNameGroup = new QGroupBox( tr( "OBJECT_NAME" ).arg( theObjectTypeName ), this ); - QLabel* anObstacleNameLabel = new QLabel( tr( "NAME" ), myObstacleNameGroup ); - myObstacleName = new QLineEdit( myObstacleNameGroup ); + QLabel* aNameLabel = new QLabel( tr( "NAME" ), myNameGroup ); + myObjectName = new QLineEdit( myNameGroup ); - QBoxLayout* anObstacleNameLayout = new QHBoxLayout( myObstacleNameGroup ); - anObstacleNameLayout->setMargin( 5 ); - anObstacleNameLayout->setSpacing( 5 ); - anObstacleNameLayout->addWidget( anObstacleNameLabel ); - anObstacleNameLayout->addWidget( myObstacleName ); + QBoxLayout* anNameLayout = new QHBoxLayout( myNameGroup ); + anNameLayout->setMargin( 5 ); + anNameLayout->setSpacing( 5 ); + anNameLayout->addWidget( aNameLabel ); + anNameLayout->addWidget( myObjectName ); // Mode selector (create/edit) myModeGroup = new QGroupBox( tr( "MODE" ), this ); - QRadioButton* aNewObstacleRB = new QRadioButton( tr( "CREATE_NEW_OBSTACLE" ), mainFrame() ); - QRadioButton* aModifyObstacleRB = new QRadioButton( tr( "MODIFY_OBSTACLE" ), mainFrame() ); + QRadioButton* aNewRB = new QRadioButton( tr( "CREATE_NEW" ), mainFrame() ); + QRadioButton* aModifyRB = new QRadioButton( tr( "MODIFY" ), mainFrame() ); myModeButtons = new QButtonGroup( mainFrame() ); - myModeButtons->addButton( aNewObstacleRB, CreateNewId ); - myModeButtons->addButton( aModifyObstacleRB, ModifyExistentId ); + myModeButtons->addButton( aNewRB, CreateNewId ); + myModeButtons->addButton( aModifyRB, ModifyExistentId ); QBoxLayout* aModeSelectorLayout = new QHBoxLayout( myModeGroup ); aModeSelectorLayout->setMargin( 5 ); aModeSelectorLayout->setSpacing( 5 ); - aModeSelectorLayout->addWidget( aNewObstacleRB ); - aModeSelectorLayout->addWidget( aModifyObstacleRB ); + aModeSelectorLayout->addWidget( aNewRB ); + aModeSelectorLayout->addWidget( aModifyRB ); // Existing obstacles selector - myObstaclesGroup = new QGroupBox( tr( "OBSTACLE_TO_EDIT" ), this ); + myObjectsGroup = new QGroupBox( tr( "OBJECT_TO_EDIT" ).arg( theObjectTypeName ), this ); - QLabel* anObstacleLabel = new QLabel( tr( "OBSTACLE" ), myObstaclesGroup ); + QLabel* anObjectLabel = new QLabel( theObjectTypeName, myObjectsGroup ); - myObstacles = new QComboBox( mainFrame() ); - myObstacles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myObjects = new QComboBox( mainFrame() ); + myObjects->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - QBoxLayout* anObstaclesSelectorLayout = new QHBoxLayout( myObstaclesGroup ); - anObstaclesSelectorLayout->setMargin( 5 ); - anObstaclesSelectorLayout->setSpacing( 5 ); - anObstaclesSelectorLayout->addWidget( anObstacleLabel ); - anObstaclesSelectorLayout->addWidget( myObstacles ); + QBoxLayout* anObjectsSelectorLayout = new QHBoxLayout( myObjectsGroup ); + anObjectsSelectorLayout->setMargin( 5 ); + anObjectsSelectorLayout->setSpacing( 5 ); + anObjectsSelectorLayout->addWidget( anObjectLabel ); + anObjectsSelectorLayout->addWidget( myObjects ); // Layout if ( aFileNameGroup ) { addWidget( aFileNameGroup ); } - addWidget( myObstacleNameGroup ); + addWidget( myNameGroup ); addWidget( myModeGroup ); - addWidget( myObstaclesGroup ); + addWidget( myObjectsGroup ); addStretch(); // Connect signals and slots connect( myModeButtons, SIGNAL( buttonClicked( int ) ), this, SLOT( onModeActivated( int ) ) ); - connect( myObstacles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onObstacleSelectionChanged( ) ) ); + connect( myObjects, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onObjectSelectionChanged( ) ) ); } -HYDROGUI_ObstacleDlg::~HYDROGUI_ObstacleDlg() +HYDROGUI_GeomObjectDlg::~HYDROGUI_GeomObjectDlg() { } -void HYDROGUI_ObstacleDlg::setObstacleNames( const QStringList& theObstacles ) +void HYDROGUI_GeomObjectDlg::setObjectNames( const QStringList& theNames ) { - myObstacles->clear(); - myObstacles->addItems( theObstacles ); + myObjects->clear(); + myObjects->addItems( theNames ); updateControls(); } -void HYDROGUI_ObstacleDlg::onModeActivated( int theMode ) +void HYDROGUI_GeomObjectDlg::onModeActivated( int theMode ) { updateControls(); updateObjectName(); } -QString HYDROGUI_ObstacleDlg::getObstacleName() const +QString HYDROGUI_GeomObjectDlg::getObjectName() const { - return myObstacleName->text(); + return myObjectName->text(); QString aName; if ( myModeButtons->checkedId() == ModifyExistentId ) { - aName = myObstacles->currentText(); + aName = myObjects->currentText(); } return aName; } -QString HYDROGUI_ObstacleDlg::getEditedObstacleName() const +QString HYDROGUI_GeomObjectDlg::getEditedObjectName() const { QString aName; if ( myModeButtons->checkedId() == ModifyExistentId ) { - aName = myObstacles->currentText(); + aName = myObjects->currentText(); } return aName; } -QString HYDROGUI_ObstacleDlg::getFileName() const +QString HYDROGUI_GeomObjectDlg::getFileName() const { return myFileName->text(); } -void HYDROGUI_ObstacleDlg::onBrowse() +void HYDROGUI_GeomObjectDlg::onBrowse() { SUIT_FileDlg* aFileDlg = new SUIT_FileDlg( this, true ); aFileDlg->setWindowTitle( tr("IMPORT_OBSTACLE_FROM_FILE") ); @@ -198,12 +199,12 @@ void HYDROGUI_ObstacleDlg::onBrowse() } } -void HYDROGUI_ObstacleDlg::reset() +void HYDROGUI_GeomObjectDlg::reset() { if ( myFileSelectionEnabled ) { myFileName->clear(); } - myObstacleName->clear(); + myObjectName->clear(); // Activate the creation mode myModeButtons->button( CreateNewId )->setChecked( true ); @@ -212,21 +213,21 @@ void HYDROGUI_ObstacleDlg::reset() updateControls(); } -void HYDROGUI_ObstacleDlg::onObstacleSelectionChanged() +void HYDROGUI_GeomObjectDlg::onObjectSelectionChanged() { updateObjectName(); } -void HYDROGUI_ObstacleDlg::updateControls() +void HYDROGUI_GeomObjectDlg::updateControls() { - myObstacleNameGroup->setEnabled( !myFileSelectionEnabled || - !myFileName->text().isEmpty() ); - myModeGroup->setEnabled( myObstacleNameGroup->isEnabled() && - myObstacles->count() > 0 ); - myObstaclesGroup->setEnabled( myModeButtons->checkedId() == ModifyExistentId ); + myNameGroup->setEnabled( !myFileSelectionEnabled || + !myFileName->text().isEmpty() ); + myModeGroup->setEnabled( myNameGroup->isEnabled() && + myObjects->count() > 0 ); + myObjectsGroup->setEnabled( myModeButtons->checkedId() == ModifyExistentId ); } -void HYDROGUI_ObstacleDlg::updateObjectName() +void HYDROGUI_GeomObjectDlg::updateObjectName() { QString aName; @@ -245,20 +246,20 @@ void HYDROGUI_ObstacleDlg::updateObjectName() module(), getDefaultName(), QStringList(), true ); } } else if ( aMode == ModifyExistentId ) { - aName = getEditedObstacleName(); + aName = getEditedObjectName(); } - myObstacleName->setText( aName ); + myObjectName->setText( aName ); } -void HYDROGUI_ObstacleDlg::setDefaultName( const QString& theName ) +void HYDROGUI_GeomObjectDlg::setDefaultName( const QString& theName ) { myDefaultName = theName; updateObjectName(); } -QString HYDROGUI_ObstacleDlg::getDefaultName() +QString HYDROGUI_GeomObjectDlg::getDefaultName() { return myDefaultName; } \ No newline at end of file diff --git a/src/HYDROGUI/HYDROGUI_ObstacleDlg.h b/src/HYDROGUI/HYDROGUI_GeomObjectDlg.h similarity index 69% rename from src/HYDROGUI/HYDROGUI_ObstacleDlg.h rename to src/HYDROGUI/HYDROGUI_GeomObjectDlg.h index 60d2acbb..0c8f480f 100644 --- a/src/HYDROGUI/HYDROGUI_ObstacleDlg.h +++ b/src/HYDROGUI/HYDROGUI_GeomObjectDlg.h @@ -20,8 +20,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#ifndef HYDROGUI_ObstacleDlg_H -#define HYDROGUI_ObstacleDlg_H +#ifndef HYDROGUI_GeomObjectDlg_H +#define HYDROGUI_GeomObjectDlg_H #include "HYDROGUI_InputPanel.h" @@ -30,23 +30,24 @@ class QGroupBox; class QComboBox; class QButtonGroup; -class HYDROGUI_ObstacleDlg : public HYDROGUI_InputPanel +class HYDROGUI_GeomObjectDlg : public HYDROGUI_InputPanel { Q_OBJECT enum CreationMode { CreateNewId, ModifyExistentId }; public: - HYDROGUI_ObstacleDlg( HYDROGUI_Module* theModule, const QString& theTitle, - const bool theIsToEnableFileSelection = false ); - virtual ~HYDROGUI_ObstacleDlg(); + HYDROGUI_GeomObjectDlg( HYDROGUI_Module* theModule, const QString& theTitle, + const QString& theObjectTypeName, + const bool theIsToEnableFileSelection = false ); + virtual ~HYDROGUI_GeomObjectDlg(); void reset(); - QString getObstacleName() const; + QString getObjectName() const; - void setObstacleNames( const QStringList& theObstacles ); - QString getEditedObstacleName() const; + void setObjectNames( const QStringList& theObstacles ); + QString getEditedObjectName() const; QString getFileName() const; @@ -55,7 +56,7 @@ public: protected slots: void onModeActivated( int ); - void onObstacleSelectionChanged(); + void onObjectSelectionChanged(); void onBrowse(); private: @@ -65,14 +66,14 @@ private: private: QLineEdit* myFileName; - QGroupBox* myObstacleNameGroup; - QLineEdit* myObstacleName; + QGroupBox* myNameGroup; + QLineEdit* myObjectName; QGroupBox* myModeGroup; QButtonGroup* myModeButtons; - QGroupBox* myObstaclesGroup; - QComboBox* myObstacles; + QGroupBox* myObjectsGroup; + QComboBox* myObjects; bool myFileSelectionEnabled; QString myDefaultName; -- 2.39.2