From 7085ad3cdb4d3b953050cec877930c93a733e19a Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 19 Jun 2008 15:49:10 +0000 Subject: [PATCH] Selection Preferences dialog --- src/VISUGUI/Makefile.am | 2 + src/VISUGUI/VISU_msg_en.ts | 63 ++-- .../VisuGUI_GaussPointsSelectionPane.cxx | 116 +------ .../VisuGUI_GaussPointsSelectionPane.h | 13 - src/VISUGUI/VisuGUI_SelectionPanel.cxx | 149 ++------- src/VISUGUI/VisuGUI_SelectionPanel.h | 23 +- src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx | 300 ++++++++++++++++++ src/VISUGUI/VisuGUI_SelectionPrefDlg.h | 79 +++++ 8 files changed, 445 insertions(+), 300 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx create mode 100644 src/VISUGUI/VisuGUI_SelectionPrefDlg.h diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 6fd19625..c61d27af 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -43,6 +43,7 @@ dist_libVISU_la_SOURCES= \ VisuGUI_InputPanel.cxx \ VisuGUI_BasePanel.cxx \ VisuGUI_SelectionPanel.cxx \ + VisuGUI_SelectionPrefDlg.cxx \ VisuGUI_GaussPointsSelectionPane.cxx \ VisuGUI_Tools.cxx \ VisuGUI_ViewTools.cxx \ @@ -85,6 +86,7 @@ MOC_FILES= \ VisuGUI_InputPanel_moc.cxx \ VisuGUI_BasePanel_moc.cxx \ VisuGUI_SelectionPanel_moc.cxx \ + VisuGUI_SelectionPrefDlg_moc.cxx \ VisuGUI_GaussPointsSelectionPane_moc.cxx \ VisuGUI_NameDlg_moc.cxx \ VisuGUI_FileDlg_moc.cxx \ diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 306fb924..a8b14e80 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -1926,42 +1926,14 @@ Please, provide non-empty resulting presentation. VisuGUI_GaussPointsSelectionPane - - CURSOR_SIZE - Size of the cursor: - - - CURSOR_TITLE - Cursor - DISPLAY_PARENT_MESH Display parent mesh element - - PARENT_MESH_TITLE - Parent mesh element - PICKING_DLG_TITLE Picking - - POINT_TOLERANCE - Point tolerance: - - - PYRAMID_HEIGHT - Height of the pyramids: - - - SELECTION_COLOR - Selection cursor color: - - - TOLERANCE_TITLE - Tolerance - DATA_POSITION Position @@ -3253,6 +3225,17 @@ Please, refer to the documentation. ACTOR_DATA_SIZE_TITLE Size + + SELECTION_PREFERENCES + Selection preferences... + + + + VisuGUI_SelectionPrefDlg + + TLT_SELECTION_PREFERENCES + Selection preferences + BELOW_POINT Centered @@ -3261,14 +3244,34 @@ Please, refer to the documentation. CAMERA_TITLE Movement of the camera + + CURSOR_SIZE + Size of the cursor: + + + CURSOR_TITLE + Cursor + INFO_WINDOW_TITLE Information window + + POINT_TOLERANCE + Point tolerance: + POSITION Position: + + PYRAMID_HEIGHT + Height of the pyramids: + + + SELECTION_COLOR + Selection cursor color: + STEP_NUMBER Number of steps: @@ -3277,6 +3280,10 @@ Please, refer to the documentation. STEP_NUMBER_TIP Number of steps between two positions + + TOLERANCE_TITLE + Tolerance + TOP_LEFT_CORNER Top-left corner diff --git a/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx b/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx index cb99ebef..6b258d2c 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx @@ -63,11 +63,7 @@ #include #include #include - -#include "QtxAction.h" -#include "QtxDoubleSpinBox.h" -#include "QtxIntSpinBox.h" -#include "QtxColorButton.h" +#include #include "LightApp_Application.h" @@ -269,59 +265,6 @@ VisuGUI_GaussPointsSelectionPane::VisuGUI_GaussPointsSelectionPane( const Salome BoxLayout->setMargin(0); BoxLayout->setSpacing(6); - // Cursor - QGroupBox* CursorGroup = new QGroupBox( tr( "CURSOR_TITLE" ), aBox ); - QGridLayout* CursorGroupLayout = new QGridLayout (CursorGroup); - CursorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); - CursorGroupLayout->setSpacing(6); - CursorGroupLayout->setMargin(11); - - QLabel* CursorSizeLabel = new QLabel( tr( "CURSOR_SIZE" ), CursorGroup ); - myCursorSizeSpinBox = new QtxDoubleSpinBox( 0, 1, 0.1, CursorGroup ); - myCursorSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - QLabel* PyramidHeightLabel = new QLabel( tr( "PYRAMID_HEIGHT" ), CursorGroup ); - double aHeightMin=1.e-7; - double aHeightMax=10.; - double aHeightStep=0.1; - myPyramidHeightSpinBox = new QtxDoubleSpinBox(aHeightMin, aHeightMax, aHeightStep, CursorGroup ); - myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - QLabel* SelectionColorLabel = new QLabel( tr( "SELECTION_COLOR" ), CursorGroup ); - mySelectionColorButton = new QtxColorButton( CursorGroup ); - mySelectionColorButton->setColor( Qt::blue ); - - CursorGroupLayout->addWidget( CursorSizeLabel, 0, 0 ); - CursorGroupLayout->addWidget( myCursorSizeSpinBox, 0, 1 ); - CursorGroupLayout->addWidget( PyramidHeightLabel, 1, 0 ); - CursorGroupLayout->addWidget( myPyramidHeightSpinBox, 1, 1 ); - CursorGroupLayout->addWidget( SelectionColorLabel, 2, 0 ); - CursorGroupLayout->addWidget( mySelectionColorButton, 2, 1 ); - - BoxLayout->addWidget( CursorGroup ); - - connect( myCursorSizeSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onApplyCursorSize( double ) ) ); - connect( myPyramidHeightSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onApplyPyramidHeight( double ) ) ); - connect( mySelectionColorButton, SIGNAL( changed( QColor )), this, SLOT( onApplySelectionColor( QColor ) ) ); - - // Tolerance - QGroupBox* ToleranceGroup = new QGroupBox( tr( "TOLERANCE_TITLE" ), aBox ); - QGridLayout* ToleranceGroupLayout = new QGridLayout (ToleranceGroup); - ToleranceGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); - ToleranceGroupLayout->setSpacing(6); - ToleranceGroupLayout->setMargin(11); - - QLabel* PointToleranceLabel = new QLabel( tr( "POINT_TOLERANCE" ), ToleranceGroup ); - myPointToleranceSpinBox = new QtxDoubleSpinBox( 0.001, 10.0, 0.01, ToleranceGroup ); - myPointToleranceSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - ToleranceGroupLayout->addWidget( PointToleranceLabel, 0, 0 ); - ToleranceGroupLayout->addWidget( myPointToleranceSpinBox, 0, 1 ); - - BoxLayout->addWidget( ToleranceGroup ); - - connect( myPointToleranceSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onApplyPointTolerance( double ) ) ); - // Display parent mesh element QGroupBox* PositionGroup = new QGroupBox( tr( "DATA_POSITION" ), aBox ); QGridLayout* PositionGroupLayout = new QGridLayout (PositionGroup); @@ -378,18 +321,9 @@ VisuGUI_GaussPointsSelectionPane::~VisuGUI_GaussPointsSelectionPane() void VisuGUI_GaussPointsSelectionPane::Update() { - //printf( "VisuGUI_GaussPointsSelectionPane::Update()\n" ); VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - myCursorSizeSpinBox->setValue( aPickingSettings->GetCursorSize() ); - myPyramidHeightSpinBox->setValue( aPickingSettings->GetPyramidHeight() ); - myPointToleranceSpinBox->setValue( aPickingSettings->GetPointTolerance() ); myDisplayParentMeshCheckBox->setChecked( aPickingSettings->GetDisplayParentMesh() ); - - vtkFloatingPointType* aColor = aPickingSettings->GetColor(); - mySelectionColorButton->setColor( QColor( ( int )( aColor[0] * 255.0 ), - ( int )( aColor[1] * 255.0 ), - ( int )( aColor[2] * 255.0 ) ) ); } void VisuGUI_GaussPointsSelectionPane::SetInteractor( SVTK_RenderWindowInteractor* theInteractor ) @@ -515,57 +449,9 @@ void VisuGUI_GaussPointsSelectionPane::ClearIDControls() void VisuGUI_GaussPointsSelectionPane::Apply() { - /* - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetCursorSize( myCursorSizeSpinBox->value() ); - aPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); - aPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() ); - aPickingSettings->SetDisplayParentMesh( myDisplayParentMeshCheckBox->isChecked() ); - - QColor aButtonColor = mySelectionColorButton->color(); - vtkFloatingPointType aColor[3]; - aColor[0] = aButtonColor.red() / 255.0; - aColor[1] = aButtonColor.green() / 255.0; - aColor[2] = aButtonColor.blue() / 255.0; - aPickingSettings->SetColor( aColor ); - - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); - */ onSelectionApply(); } -void VisuGUI_GaussPointsSelectionPane::onApplyCursorSize( double theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetCursorSize( theValue ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - -void VisuGUI_GaussPointsSelectionPane::onApplyPyramidHeight( double theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetPyramidHeight( theValue ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - -void VisuGUI_GaussPointsSelectionPane::onApplySelectionColor( QColor theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - vtkFloatingPointType aColor[3]; - aColor[0] = theValue.red() / 255.0; - aColor[1] = theValue.green() / 255.0; - aColor[2] = theValue.blue() / 255.0; - aPickingSettings->SetColor( aColor ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - -void VisuGUI_GaussPointsSelectionPane::onApplyPointTolerance( double theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetPointTolerance( theValue ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - void VisuGUI_GaussPointsSelectionPane::onApplyDisplayParentMesh( bool theValue ) { VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); diff --git a/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h b/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h index a8b31a9e..245c12f6 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h +++ b/src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h @@ -43,9 +43,6 @@ class QCheckBox; class QPushButton; class QtxAction; -class QtxDoubleSpinBox; -class QtxIntSpinBox; -class QtxColorButton; class VISU_GaussPtsAct; class VISU_PickingSettings; @@ -84,10 +81,6 @@ protected slots: void onSelectionApply(); private slots: - void onApplyCursorSize( double ); - void onApplyPyramidHeight( double ); - void onApplySelectionColor( QColor ); - void onApplyPointTolerance( double ); void onApplyDisplayParentMesh( bool ); private: @@ -105,14 +98,8 @@ private: private: const SalomeApp_Module* myModule; - QtxDoubleSpinBox* myCursorSizeSpinBox; - QtxDoubleSpinBox* myPyramidHeightSpinBox; - QtxColorButton* mySelectionColorButton; - QtxDoubleSpinBox* myPointToleranceSpinBox; QCheckBox* myDisplayParentMeshCheckBox; - QtxAction* myAction; - VisuGUI_ValidatedLineEdit* myParentElementLineEdit; VisuGUI_ValidatedLineEdit* myLocalPointLineEdit; diff --git a/src/VISUGUI/VisuGUI_SelectionPanel.cxx b/src/VISUGUI/VisuGUI_SelectionPanel.cxx index 1983764e..863ba91a 100644 --- a/src/VISUGUI/VisuGUI_SelectionPanel.cxx +++ b/src/VISUGUI/VisuGUI_SelectionPanel.cxx @@ -31,6 +31,7 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" +#include "VisuGUI_SelectionPrefDlg.h" #include "VisuGUI_GaussPointsSelectionPane.h" #include "VISU_Event.h" @@ -63,9 +64,6 @@ #include "SVTK_Selector.h" #include "SVTK_RenderWindowInteractor.h" -#include "QtxDoubleSpinBox.h" -#include "QtxIntSpinBox.h" - #include "utilities.h" // OCCT Includes @@ -111,7 +109,8 @@ using namespace std; VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModule, QWidget* theParent ) : VisuGUI_BasePanel( tr("WINDOW_TITLE" ), theParent, /*ApplyBtn | */CloseBtn | HelpBtn ), myModule( theModule ), - mySelectionMgr( 0 ) + mySelectionMgr( 0 ), + myPreferencesDlg( 0 ) { QVBoxLayout* TopLayout = new QVBoxLayout ( mainFrame() ); //TopLayout->setSpacing(6); @@ -295,87 +294,23 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModul aVBoxLayout->addStretch(); // Gauss Points Pane - QScrollArea* aGaussPointsScrollArea = new QScrollArea( mainFrame() ); - myGaussPointsPane = new VisuGUI_GaussPointsSelectionPane( myModule, aGaussPointsScrollArea ); - - aGaussPointsScrollArea->setWidget( myGaussPointsPane ); - aGaussPointsScrollArea->setAlignment( Qt::AlignCenter ); - aGaussPointsScrollArea->setWidgetResizable( true ); - aGaussPointsScrollArea->setMinimumWidth( myGaussPointsPane->sizeHint().width() + MARGIN_SIZE ); + myGaussPointsPane = new VisuGUI_GaussPointsSelectionPane( myModule, mainFrame() ); // Add panes to tab widget myTabWidget->addTab(myActorsPane, tr("MODE_ACTOR")); myTabWidget->addTab(myCellsPane, tr("MODE_CELL")); myTabWidget->addTab(myPointsPane, tr("MODE_POINT")); - myTabWidget->addTab(aGaussPointsScrollArea, tr("MODE_GAUSS_POINT")); - - connect(myTabWidget, SIGNAL(currentChanged(int)), this, SLOT(onSelectionModeChanged(int))); - - TopLayout->addWidget(myTabWidget); - - // Information window - myInfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), mainFrame() ); - myInfoWindowGroup->setCheckable( true ); - - QGridLayout* InfoWindowGroupLayout = new QGridLayout (myInfoWindowGroup); - InfoWindowGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); - //InfoWindowGroupLayout->setSpacing(6); - //InfoWindowGroupLayout->setMargin(11); - - QLabel* TransparencyLabel = new QLabel( tr( "TRANSPARENCY" ), myInfoWindowGroup ); - myTransparencySpinBox = new QtxIntSpinBox( 0, 100, 10, myInfoWindowGroup ); - //myTransparencySpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); - InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); - - QLabel* PositionLabel = new QLabel( tr( "POSITION" ), myInfoWindowGroup ); - myPositionComboBox = new QComboBox( myInfoWindowGroup ); - //myPositionComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - myPositionComboBox->addItem( tr( "BELOW_POINT" ) ); - myPositionComboBox->addItem( tr( "TOP_LEFT_CORNER" ) ); - - InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); - InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); - InfoWindowGroupLayout->addWidget( PositionLabel, 1, 0 ); - InfoWindowGroupLayout->addWidget( myPositionComboBox, 1, 1 ); - - TopLayout->addWidget( myInfoWindowGroup ); - - connect( myInfoWindowGroup, SIGNAL( toggled( bool ) ), this, SLOT( onApplyInfoWindow( bool ) ) ); - connect( myTransparencySpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onApplyTransparency( int ) ) ); - connect( myPositionComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onApplyPosition( int ) ) ); - - // Movement of the camera - myCameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), mainFrame() ); - myCameraGroup->setCheckable( true ); - - QGridLayout* CameraGroupLayout = new QGridLayout (myCameraGroup); - CameraGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); - //CameraGroupLayout->setSpacing(6); - //CameraGroupLayout->setMargin(11); - - QLabel* ZoomFactorLabel = new QLabel( tr( "ZOOM_FACTOR" ), myCameraGroup ); - myZoomFactorSpinBox = new QtxDoubleSpinBox( 0.1, 10.0, 0.1, myCameraGroup ); - //myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER" ), myCameraGroup ); - StepNumberLabel->setToolTip( tr( "STEP_NUMBER_TIP" ) ); - myStepNumberSpinBox = new QtxIntSpinBox( 1, 100, 1, myCameraGroup ); - //myStepNumberSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myTabWidget->addTab(myGaussPointsPane, tr("MODE_GAUSS_POINT")); - CameraGroupLayout->addWidget( ZoomFactorLabel, 0, 0 ); - CameraGroupLayout->addWidget( myZoomFactorSpinBox, 0, 1 ); - CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 ); - CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 ); + connect( myTabWidget, SIGNAL( currentChanged( int ) ), this, SLOT( onSelectionModeChanged( int ) ) ); - TopLayout->addWidget( myCameraGroup ); + TopLayout->addWidget( myTabWidget ); - connect( myCameraGroup, SIGNAL( toggled( bool ) ), this, SLOT( onApplyCamera( bool ) ) ); - connect( myZoomFactorSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( onApplyZoomFactor( double ) ) ); - connect( myStepNumberSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onApplyStepNumber( int ) ) ); + // Preferences button + QPushButton* aPrefBtn = new QPushButton( tr( "SELECTION_PREFERENCES" ), mainFrame() ); + connect( aPrefBtn, SIGNAL( clicked() ), this, SLOT( onPreferences() ) ); + TopLayout->addWidget( aPrefBtn ); SalomeApp_Application* anApp = dynamic_cast (SUIT_Session::session()->activeApplication()); @@ -395,18 +330,19 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModul VisuGUI_SelectionPanel::~VisuGUI_SelectionPanel() { + if( myPreferencesDlg ) + { + delete myPreferencesDlg; + myPreferencesDlg = 0; + } } -void VisuGUI_SelectionPanel::update() +VisuGUI_SelectionPrefDlg* VisuGUI_SelectionPanel::preferencesDlg() { - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - - myInfoWindowGroup->setChecked( aPickingSettings->GetInfoWindowEnabled() ); - myTransparencySpinBox->setValue( int(aPickingSettings->GetInfoWindowTransparency() * 100.0) ); - myPositionComboBox->setCurrentIndex( aPickingSettings->GetInfoWindowPosition() ); - myCameraGroup->setChecked( aPickingSettings->GetCameraMovementEnabled() ); - myZoomFactorSpinBox->setValue( aPickingSettings->GetZoomFactor() ); - myStepNumberSpinBox->setValue( aPickingSettings->GetStepNumber() ); + if( !myPreferencesDlg ) + myPreferencesDlg = new VisuGUI_SelectionPrefDlg(); + myPreferencesDlg->update(); + return myPreferencesDlg; } void VisuGUI_SelectionPanel::setSelectionMode( int theId ) @@ -436,7 +372,7 @@ void VisuGUI_SelectionPanel::onSelectionModeChanged( int theId ) break; case 3: // Gauss Points aViewWindow->SetSelectionMode(GaussPointSelection); - myGaussPointsPane->Update(); + myGaussPointsPane->update(); onSelectionEvent(); break; } @@ -796,46 +732,9 @@ void VisuGUI_SelectionPanel::onCellIdEdit () clearFields(); } -void VisuGUI_SelectionPanel::onApplyInfoWindow( bool theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetInfoWindowEnabled( theValue ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - -void VisuGUI_SelectionPanel::onApplyTransparency( int theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetInfoWindowTransparency( theValue / 100.0 ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - -void VisuGUI_SelectionPanel::onApplyPosition( int theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetInfoWindowPosition( theValue ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - -void VisuGUI_SelectionPanel::onApplyCamera( bool theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetCameraMovementEnabled( theValue ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - -void VisuGUI_SelectionPanel::onApplyZoomFactor( double theValue ) -{ - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetZoomFactor( theValue ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); -} - -void VisuGUI_SelectionPanel::onApplyStepNumber( int theValue ) +void VisuGUI_SelectionPanel::onPreferences() { - VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); - aPickingSettings->SetStepNumber( theValue ); - aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); + preferencesDlg()->exec(); } void VisuGUI_SelectionPanel::onApply() diff --git a/src/VISUGUI/VisuGUI_SelectionPanel.h b/src/VISUGUI/VisuGUI_SelectionPanel.h index 12cdbffd..d85c7dd2 100644 --- a/src/VISUGUI/VisuGUI_SelectionPanel.h +++ b/src/VISUGUI/VisuGUI_SelectionPanel.h @@ -34,21 +34,18 @@ #include class QComboBox; -class QGroupBox; class QLabel; class QLineEdit; class QTableWidget; class QTabWidget; -class QtxDoubleSpinBox; -class QtxIntSpinBox; - class LightApp_SelectionMgr; class SalomeApp_Application; class SalomeApp_Module; class SVTK_RenderWindowInteractor; class VisuGUI_GaussPointsSelectionPane; +class VisuGUI_SelectionPrefDlg; class VisuGUI_SelectionPanel: public VisuGUI_BasePanel { @@ -59,8 +56,6 @@ public: virtual ~VisuGUI_SelectionPanel (); public: - void update(); - void setSelectionMode( int theId ); private: @@ -75,12 +70,7 @@ private slots: virtual void onClose(); virtual void onHelp(); - void onApplyInfoWindow( bool ); - void onApplyTransparency( int ); - void onApplyPosition( int ); - void onApplyCamera( bool ); - void onApplyZoomFactor( double ); - void onApplyStepNumber( int ); + void onPreferences(); void onSelectionModeChanged( int theId ); void onSelectionEvent(); @@ -91,6 +81,7 @@ signals: void selectionModeChanged( int ); private: + VisuGUI_SelectionPrefDlg* preferencesDlg(); void clearFields(); private: @@ -128,13 +119,7 @@ private: VisuGUI_GaussPointsSelectionPane* myGaussPointsPane; - QGroupBox* myInfoWindowGroup; - QtxIntSpinBox* myTransparencySpinBox; - QComboBox* myPositionComboBox; - - QGroupBox* myCameraGroup; - QtxDoubleSpinBox* myZoomFactorSpinBox; - QtxIntSpinBox* myStepNumberSpinBox; + VisuGUI_SelectionPrefDlg* myPreferencesDlg; const SalomeApp_Module* myModule; LightApp_SelectionMgr* mySelectionMgr; diff --git a/src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx b/src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx new file mode 100644 index 00000000..0027b492 --- /dev/null +++ b/src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx @@ -0,0 +1,300 @@ +// Copyright (C) 2003 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, +// 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. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_SelectionPrefDlg.cxx +// Author : Oleg UVAROV +// Module : SALOME + +#include "VisuGUI_SelectionPrefDlg.h" +#include "VisuGUI.h" + +#include "VISU_PickingSettings.h" + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +/*! + Constructor +*/ +VisuGUI_SelectionPrefDlg::VisuGUI_SelectionPrefDlg( QWidget* parent ) + : QDialog( parent ? parent : SUIT_Session::session()->activeApplication()->desktop(), + Qt::WindowTitleHint | Qt::WindowSystemMenuHint ) +{ + setWindowTitle( tr("TLT_SELECTION_PREFERENCES") ); + setSizeGripEnabled( TRUE ); + setModal( true ); + + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); + + // Cursor (gauss points) + QGroupBox* CursorGroup = new QGroupBox( tr( "CURSOR_TITLE" ), this ); + QGridLayout* CursorGroupLayout = new QGridLayout (CursorGroup); + CursorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + CursorGroupLayout->setSpacing(6); + CursorGroupLayout->setMargin(11); + + QLabel* CursorSizeLabel = new QLabel( tr( "CURSOR_SIZE" ), CursorGroup ); + myCursorSizeSpinBox = new QtxDoubleSpinBox( 0, 1, 0.1, CursorGroup ); + myCursorSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QLabel* PyramidHeightLabel = new QLabel( tr( "PYRAMID_HEIGHT" ), CursorGroup ); + double aHeightMin=1.e-7; + double aHeightMax=10.; + double aHeightStep=0.1; + myPyramidHeightSpinBox = new QtxDoubleSpinBox(aHeightMin, aHeightMax, aHeightStep, CursorGroup ); + myPyramidHeightSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QLabel* SelectionColorLabel = new QLabel( tr( "SELECTION_COLOR" ), CursorGroup ); + mySelectionColorButton = new QtxColorButton( CursorGroup ); + mySelectionColorButton->setColor( Qt::blue ); + + CursorGroupLayout->addWidget( CursorSizeLabel, 0, 0 ); + CursorGroupLayout->addWidget( myCursorSizeSpinBox, 0, 1 ); + CursorGroupLayout->addWidget( PyramidHeightLabel, 1, 0 ); + CursorGroupLayout->addWidget( myPyramidHeightSpinBox, 1, 1 ); + CursorGroupLayout->addWidget( SelectionColorLabel, 2, 0 ); + CursorGroupLayout->addWidget( mySelectionColorButton, 2, 1 ); + + topLayout->addWidget( CursorGroup ); + + // Tolerance (gauss points) + QGroupBox* ToleranceGroup = new QGroupBox( tr( "TOLERANCE_TITLE" ), this ); + QGridLayout* ToleranceGroupLayout = new QGridLayout (ToleranceGroup); + ToleranceGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + ToleranceGroupLayout->setSpacing(6); + ToleranceGroupLayout->setMargin(11); + + QLabel* PointToleranceLabel = new QLabel( tr( "POINT_TOLERANCE" ), ToleranceGroup ); + myPointToleranceSpinBox = new QtxDoubleSpinBox( 0.001, 10.0, 0.01, ToleranceGroup ); + myPointToleranceSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + ToleranceGroupLayout->addWidget( PointToleranceLabel, 0, 0 ); + ToleranceGroupLayout->addWidget( myPointToleranceSpinBox, 0, 1 ); + + topLayout->addWidget( ToleranceGroup ); + + // Information window + myInfoWindowGroup = new QGroupBox( tr( "INFO_WINDOW_TITLE" ), this ); + myInfoWindowGroup->setCheckable( true ); + + QGridLayout* InfoWindowGroupLayout = new QGridLayout (myInfoWindowGroup); + InfoWindowGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + + QLabel* TransparencyLabel = new QLabel( tr( "TRANSPARENCY" ), myInfoWindowGroup ); + myTransparencySpinBox = new QtxIntSpinBox( 0, 100, 10, myInfoWindowGroup ); + myTransparencySpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); + InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); + + QLabel* PositionLabel = new QLabel( tr( "POSITION" ), myInfoWindowGroup ); + myPositionComboBox = new QComboBox( myInfoWindowGroup ); + myPositionComboBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myPositionComboBox->addItem( tr( "BELOW_POINT" ) ); + myPositionComboBox->addItem( tr( "TOP_LEFT_CORNER" ) ); + + InfoWindowGroupLayout->addWidget( TransparencyLabel, 0, 0 ); + InfoWindowGroupLayout->addWidget( myTransparencySpinBox, 0, 1 ); + InfoWindowGroupLayout->addWidget( PositionLabel, 1, 0 ); + InfoWindowGroupLayout->addWidget( myPositionComboBox, 1, 1 ); + + topLayout->addWidget( myInfoWindowGroup ); + + // Movement of the camera + myCameraGroup = new QGroupBox( tr( "CAMERA_TITLE" ), this ); + myCameraGroup->setCheckable( true ); + + QGridLayout* CameraGroupLayout = new QGridLayout (myCameraGroup); + CameraGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + + QLabel* ZoomFactorLabel = new QLabel( tr( "ZOOM_FACTOR" ), myCameraGroup ); + myZoomFactorSpinBox = new QtxDoubleSpinBox( 0.1, 10.0, 0.1, myCameraGroup ); + myZoomFactorSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + QLabel* StepNumberLabel = new QLabel( tr( "STEP_NUMBER" ), myCameraGroup ); + StepNumberLabel->setToolTip( tr( "STEP_NUMBER_TIP" ) ); + myStepNumberSpinBox = new QtxIntSpinBox( 1, 100, 1, myCameraGroup ); + myStepNumberSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + CameraGroupLayout->addWidget( ZoomFactorLabel, 0, 0 ); + CameraGroupLayout->addWidget( myZoomFactorSpinBox, 0, 1 ); + CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 ); + CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 ); + + topLayout->addWidget( myCameraGroup ); + + // Common buttons + QGroupBox* GroupButtons = new QGroupBox( this ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 ); + + myButtonOk = new QPushButton( GroupButtons ); + myButtonOk->setText( tr( "BUT_OK" ) ); + myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonOk ); + + myButtonApply = new QPushButton( GroupButtons ); + myButtonApply->setText( tr( "BUT_APPLY" ) ); + myButtonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonApply ); + + GroupButtonsLayout->addStretch(); + + myButtonCancel = new QPushButton( GroupButtons ); + myButtonCancel->setText( tr( "BUT_CANCEL" ) ); + myButtonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonCancel ); + + myButtonHelp = new QPushButton( GroupButtons ); + myButtonHelp->setText( tr( "BUT_HELP" ) ); + myButtonHelp->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonHelp ); + /***************************************************************/ + + //topLayout->addWidget( GroupC1 ); + topLayout->addWidget( GroupButtons ); + + // signals and slots connections + connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myButtonApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); + connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( myButtonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); + + /* Move widget on the botton right corner of main widget */ + SUIT_Tools::centerWidget( this, parent ); +} + +/*! + Destructor +*/ +VisuGUI_SelectionPrefDlg::~VisuGUI_SelectionPrefDlg() +{ +} + +void VisuGUI_SelectionPrefDlg::update() +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + + myCursorSizeSpinBox->setValue( aPickingSettings->GetCursorSize() ); + myPyramidHeightSpinBox->setValue( aPickingSettings->GetPyramidHeight() ); + myPointToleranceSpinBox->setValue( aPickingSettings->GetPointTolerance() ); + + vtkFloatingPointType* aColor = aPickingSettings->GetColor(); + mySelectionColorButton->setColor( QColor( ( int )( aColor[0] * 255.0 ), + ( int )( aColor[1] * 255.0 ), + ( int )( aColor[2] * 255.0 ) ) ); + + myInfoWindowGroup->setChecked( aPickingSettings->GetInfoWindowEnabled() ); + myTransparencySpinBox->setValue( int(aPickingSettings->GetInfoWindowTransparency() * 100.0) ); + myPositionComboBox->setCurrentIndex( aPickingSettings->GetInfoWindowPosition() ); + myCameraGroup->setChecked( aPickingSettings->GetCameraMovementEnabled() ); + myZoomFactorSpinBox->setValue( aPickingSettings->GetZoomFactor() ); + myStepNumberSpinBox->setValue( aPickingSettings->GetStepNumber() ); +} + +void VisuGUI_SelectionPrefDlg::accept() +{ + onApply(); + + QDialog::accept(); +} + +void VisuGUI_SelectionPrefDlg::onApply() +{ + VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get(); + + aPickingSettings->SetCursorSize( myCursorSizeSpinBox->value() ); + aPickingSettings->SetPyramidHeight( myPyramidHeightSpinBox->value() ); + aPickingSettings->SetPointTolerance( myPointToleranceSpinBox->value() ); + + QColor aButtonColor = mySelectionColorButton->color(); + vtkFloatingPointType aColor[3]; + aColor[0] = aButtonColor.red() / 255.0; + aColor[1] = aButtonColor.green() / 255.0; + aColor[2] = aButtonColor.blue() / 255.0; + aPickingSettings->SetColor( aColor ); + + aPickingSettings->SetInfoWindowEnabled( myInfoWindowGroup->isChecked() ); + aPickingSettings->SetInfoWindowTransparency( myTransparencySpinBox->value() / 100.0 ); + aPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentIndex() ); + aPickingSettings->SetCameraMovementEnabled( myCameraGroup->isChecked() ); + aPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() ); + aPickingSettings->SetStepNumber( myStepNumberSpinBox->value() ); + + aPickingSettings->InvokeEvent( VISU::UpdatePickingSettingsEvent,NULL ); +} + +void VisuGUI_SelectionPrefDlg::onHelp() +{ + QString aHelpFileName = "selection_preferences_page.html"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) { + VisuGUI* aVisuGUI = dynamic_cast( app->activeModule() ); + app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName); + } + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) ); + } +} + +void VisuGUI_SelectionPrefDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) + { + e->accept(); + onHelp(); + } +} diff --git a/src/VISUGUI/VisuGUI_SelectionPrefDlg.h b/src/VISUGUI/VisuGUI_SelectionPrefDlg.h new file mode 100644 index 00000000..878710dd --- /dev/null +++ b/src/VISUGUI/VisuGUI_SelectionPrefDlg.h @@ -0,0 +1,79 @@ +// Copyright (C) 2003 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, +// 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. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_SelectionPrefDlg.cxx +// Author : Oleg UVAROV +// Module : SALOME + +#ifndef VisuGUI_SELECTIONPREFDLG_H +#define VisuGUI_SELECTIONPREFDLG_H + +#include + +class QComboBox; +class QGroupBox; +class QPushButton; + +class QtxColorButton; +class QtxDoubleSpinBox; +class QtxIntSpinBox; + +class VisuGUI_SelectionPrefDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_SelectionPrefDlg( QWidget* parent = 0 ); + ~VisuGUI_SelectionPrefDlg(); + +public: + void update(); + +private: + void keyPressEvent( QKeyEvent* e ); + +protected slots: + void accept(); + + void onApply(); + void onHelp(); + +private: + QtxDoubleSpinBox* myCursorSizeSpinBox; + QtxDoubleSpinBox* myPyramidHeightSpinBox; + QtxColorButton* mySelectionColorButton; + QtxDoubleSpinBox* myPointToleranceSpinBox; + + QGroupBox* myInfoWindowGroup; + QtxIntSpinBox* myTransparencySpinBox; + QComboBox* myPositionComboBox; + + QGroupBox* myCameraGroup; + QtxDoubleSpinBox* myZoomFactorSpinBox; + QtxIntSpinBox* myStepNumberSpinBox; + + QPushButton* myButtonOk; + QPushButton* myButtonApply; + QPushButton* myButtonCancel; + QPushButton* myButtonHelp; +}; + +#endif // VisuGUI_SELECTIONPREFDLG_H -- 2.39.2