From: ouv Date: Tue, 18 Oct 2005 11:49:14 +0000 (+0000) Subject: Fixed Bug GVIEW10325 : Functionality ?Display Parent mesh element? isn?t implemented... X-Git-Tag: TG-D5-38-2003_D2005-20-12~144 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7ca87b624decd0b601a0d187afc520e9a058eeab;p=modules%2Fvisu.git Fixed Bug GVIEW10325 : Functionality ?Display Parent mesh element? isn?t implemented in ?Picking? --- diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index cb5470a1..edb96a15 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -704,7 +704,7 @@ void VISU_GaussPtsAct::highlight(bool theHighlight, myTextActor->SetVisibility(1); // // myCellActor - if(mySelectionMode==CellSelection){ + if(myPickingSettings->GetDisplayParentMesh()){ const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = myGaussPointsPL->GetGaussPtsIDMapper(); VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent(); diff --git a/src/OBJECT/VISU_GaussPtsSettings.cxx b/src/OBJECT/VISU_GaussPtsSettings.cxx index 3150ed05..f60ae626 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.cxx +++ b/src/OBJECT/VISU_GaussPtsSettings.cxx @@ -64,6 +64,7 @@ VISU_PickingSettings::VISU_PickingSettings() this->InfoWindowPosition = -1; this->ZoomFactor = -1; this->StepNumber = -1; + this->DisplayParentMesh = false; } VISU_PickingSettings::~VISU_PickingSettings() diff --git a/src/OBJECT/VISU_GaussPtsSettings.h b/src/OBJECT/VISU_GaussPtsSettings.h index a8cc2b30..e7618d79 100644 --- a/src/OBJECT/VISU_GaussPtsSettings.h +++ b/src/OBJECT/VISU_GaussPtsSettings.h @@ -117,6 +117,9 @@ class VISU_PickingSettings : public vtkObject vtkSetMacro( StepNumber, int ); vtkGetMacro( StepNumber, int ); + vtkSetMacro( DisplayParentMesh, bool ); + vtkGetMacro( DisplayParentMesh, bool ); + private: bool Initial; @@ -125,6 +128,7 @@ private: int InfoWindowPosition; float ZoomFactor; int StepNumber; + bool DisplayParentMesh; }; diff --git a/src/VISUGUI/VISUM_msg_en.po b/src/VISUGUI/VISUM_msg_en.po index ace512eb..303fb4c1 100644 --- a/src/VISUGUI/VISUM_msg_en.po +++ b/src/VISUGUI/VISUM_msg_en.po @@ -112,13 +112,13 @@ msgstr "Information window" msgid "VisuGUI_Module::VISU_PICKING_PREF_TRANSPARENCY" msgstr "Transparency" -msgid "VisuGUI_Module::VISU_GAUSS_PREF_POSITION" +msgid "VisuGUI_Module::VISU_PICKING_PREF_POSITION" msgstr "Position" -msgid "VisuGUI_Module::VISU_GAUSS_PREF_BELOW_POINT" +msgid "VisuGUI_Module::VISU_PICKING_PREF_BELOW_POINT" msgstr "Centered below the point" -msgid "VisuGUI_Module::VISU_GAUSS_PREF_TOP_LEFT_CORNER" +msgid "VisuGUI_Module::VISU_PICKING_PREF_TOP_LEFT_CORNER" msgstr "Top-left corner of the 3D view" msgid "VisuGUI_Module::VISU_PICKING_PREF_CAMERA_GROUP_TTL" @@ -130,6 +130,12 @@ msgstr "Zoom at first selected point (ratio)" msgid "VisuGUI_Module::VISU_PICKING_PREF_STEP_NUMBER" msgstr "Number of steps between two positions" +msgid "VisuGUI_Module::VISU_PICKING_PREF_PARENT_MESH_TTL" +msgstr "Parent mesh element" + +msgid "VisuGUI_Module::VISU_PICKING_PREF_DISPLAY_PARENT_MESH" +msgstr "Display parent mesh element" + msgid "VisuGUI_Module::VISU_MOUSE_PREF_TAB_TLT" msgstr "Spacemouse" @@ -499,3 +505,8 @@ msgstr "Zoom at first selected point (ratio) :" msgid "VVTK_PickingDlg::STEP_NUMBER" msgstr "Number of steps between two positions :" +msgid "VVTK_PickingDlg::PARENT_MESH_TITLE" +msgstr "Parent mesh element" + +msgid "VVTK_PickingDlg::DISPLAY_PARENT_MESH" +msgstr "Display parent mesh element" \ No newline at end of file diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index 79c6d7ce..b8974989 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -502,11 +502,11 @@ VisuGUI_Module setPreferenceProperty( transparencyPref, "max", 100 ); setPreferenceProperty( transparencyPref, "step", 10 ); - int positionPref = addPreference( tr( "VISU_GAUSS_PREF_POSITION" ), infoWindowGr, + int positionPref = addPreference( tr( "VISU_PICKING_PREF_POSITION" ), infoWindowGr, SalomeApp_Preferences::Selector, "VISU", "picking_position" ); QStringList values; - values.append( tr( "VISU_GAUSS_PREF_BELOW_POINT" ) ); - values.append( tr( "VISU_GAUSS_PREF_TOP_LEFT_CORNER" ) ); + values.append( tr( "VISU_PICKING_PREF_BELOW_POINT" ) ); + values.append( tr( "VISU_PICKING_PREF_TOP_LEFT_CORNER" ) ); QValueList indices; indices.append( 0 ); indices.append( 1 ); @@ -526,6 +526,12 @@ VisuGUI_Module SalomeApp_Preferences::IntSpin, "VISU", "picking_step_number" ); setPreferenceProperty( stepNumberPref, "min", 1 ); setPreferenceProperty( stepNumberPref, "max", 100 ); + + int parentMeshGr = addPreference( tr( "VISU_PICKING_PREF_PARENT_MESH_TTL" ), pickingTab ); + setPreferenceProperty( parentMeshGr, "columns", 1 ); + + addPreference( tr( "VISU_PICKING_PREF_DISPLAY_PARENT_MESH" ), parentMeshGr, + SalomeApp_Preferences::Bool, "VISU", "picking_display_parent_mesh" ); } diff --git a/src/VVTK/VVTK_InteractorStyle.cxx b/src/VVTK/VVTK_InteractorStyle.cxx index 2dcb871a..36f89c88 100644 --- a/src/VVTK/VVTK_InteractorStyle.cxx +++ b/src/VVTK/VVTK_InteractorStyle.cxx @@ -164,23 +164,14 @@ void VVTK_InteractorStyle ::OnKeyDown() { - SVTK_Selector* pSelector = GetSelector(); - - if( pSelector->SelectionMode() != NodeSelection ) + if( GetSelector()->SelectionMode() != NodeSelection ) return; char key = Interactor->GetKeyCode(); - if ( key == 'S' || key == 'P') { - int aSMWas, x, y; - // - aSMWas=pSelector->SelectionMode(); - // - pSelector->SetSelectionMode(NodeSelection); - if (key == 'P'){ - pSelector->SetSelectionMode(CellSelection); - } + if ( key == 'S' ) { // current mouse position (from last mouse move event or any other event) + int x, y; Interactor->GetEventPosition( x, y ); FindPokedRenderer( x, y ); // calls SetCurrentRenderer @@ -191,8 +182,6 @@ VVTK_InteractorStyle startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT); onFinishOperation(); startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); - // - pSelector->SetSelectionMode(aSMWas); } } diff --git a/src/VVTK/VVTK_MainWindow.cxx b/src/VVTK/VVTK_MainWindow.cxx index bb7f0018..c0b4e76a 100644 --- a/src/VVTK/VVTK_MainWindow.cxx +++ b/src/VVTK/VVTK_MainWindow.cxx @@ -180,7 +180,9 @@ VVTK_MainWindow1 { myRenderer = theRenderer; VVTK_MainWindow::Initialize(theInteractor); + mySegmentationCursorDlg->SetWidget( theRenderer->GetImplicitFunctionWidget() ); + myPickingDlg->SetInteractor( GetInteractor() ); } VVTK_MainWindow1 diff --git a/src/VVTK/VVTK_PickingDlg.cxx b/src/VVTK/VVTK_PickingDlg.cxx index 9a8ed193..ca0d7f09 100644 --- a/src/VVTK/VVTK_PickingDlg.cxx +++ b/src/VVTK/VVTK_PickingDlg.cxx @@ -16,15 +16,18 @@ #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" +#include "SVTK_RenderWindowInteractor.h" + #include #include #include #include -#include +#include #include #include "utilities.h" +#include #include #include #include @@ -40,8 +43,14 @@ using namespace std; VVTK_PickingDlg::VVTK_PickingDlg( QWidget* parent, const char* name ) :QDialog( parent, name, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myEventCallbackCommand( vtkCallbackCommand::New() ), myPickingSettings( VISU_PickingSettings::New() ) { + myPriority = 0.0; + myEventCallbackCommand->Delete(); + myEventCallbackCommand->SetClientData(this); + myEventCallbackCommand->SetCallback(VVTK_PickingDlg::ProcessEvents); + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); setCaption( tr( "PICKING_DLG_TITLE" ) ); @@ -127,6 +136,19 @@ VVTK_PickingDlg::VVTK_PickingDlg( QWidget* parent, const char* name ) CameraGroupLayout->addWidget( StepNumberLabel, 1, 0 ); CameraGroupLayout->addWidget( myStepNumberSpinBox, 1, 1 ); + // Display parent mesh element + QGroupBox* ParentMeshGroup = new QGroupBox( tr( "PARENT_MESH_TITLE" ), aBox, "ParentMeshGroup" ); + ParentMeshGroup->setColumnLayout(0, Qt::Vertical ); + ParentMeshGroup->layout()->setSpacing( 0 ); + ParentMeshGroup->layout()->setMargin( 0 ); + + QGridLayout* ParentMeshGroupLayout = new QGridLayout (ParentMeshGroup->layout()); + ParentMeshGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft); + ParentMeshGroupLayout->setSpacing(6); + ParentMeshGroupLayout->setMargin(11); + + myDisplayParentMeshCheckBox = new QCheckBox( tr( "DISPLAY_PARENT_MESH" ), ParentMeshGroup ); + ParentMeshGroupLayout->addWidget( myDisplayParentMeshCheckBox, 0, 0 ); // Common buttons =========================================================== QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); @@ -176,6 +198,7 @@ void VVTK_PickingDlg::Update() int anInfoWindowPosition = VISU_PickingSettings::BelowPoint; float aZoomFactor = 1.5; int aStepNumber = 10; + bool aDisplayParentMesh = false; if( !myPickingSettings->GetInitial() ) { @@ -184,6 +207,7 @@ void VVTK_PickingDlg::Update() myPositionComboBox->setCurrentItem( myPickingSettings->GetInfoWindowPosition() ); myZoomFactorSpinBox->setValue( myPickingSettings->GetZoomFactor() ); myStepNumberSpinBox->setValue( myPickingSettings->GetStepNumber() ); + myDisplayParentMeshCheckBox->setChecked( myPickingSettings->GetDisplayParentMesh() ); return; } @@ -205,6 +229,9 @@ void VVTK_PickingDlg::Update() aStepNumber = aResourceMgr->integerValue( "VISU", "picking_step_number", aStepNumber ); myStepNumberSpinBox->setValue( aStepNumber ); + aDisplayParentMesh = aResourceMgr->booleanValue( "VISU", "picking_display_parent_mesh", aDisplayParentMesh ); + myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh ); + onClickApply(); } @@ -216,6 +243,43 @@ VVTK_PickingDlg return myPickingSettings.GetPointer(); } +void VVTK_PickingDlg::SetInteractor( SVTK_RenderWindowInteractor* theInteractor ) +{ + myInteractor = theInteractor; + + theInteractor->GetDevice()->AddObserver(vtkCommand::KeyPressEvent, + myEventCallbackCommand.GetPointer(), + myPriority); +} + + +void VVTK_PickingDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject), + unsigned long theEvent, + void* theClientData, + void* vtkNotUsed(theCallData)) +{ + VVTK_PickingDlg* self = reinterpret_cast(theClientData); + + switch(theEvent){ + case vtkCommand::KeyPressEvent: + self->KeyPressed(); + break; + } +} + +void VVTK_PickingDlg::KeyPressed() +{ + if( myInteractor->GetDevice()->GetKeyCode() == 'P' ) + { + bool aDisplayParentMesh = !myPickingSettings->GetDisplayParentMesh(); + myPickingSettings->SetDisplayParentMesh( aDisplayParentMesh ); + + myDisplayParentMeshCheckBox->setChecked( aDisplayParentMesh ); + + myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL); + } +} + void VVTK_PickingDlg::onClickApply() { myPickingSettings->SetInitial( false ); @@ -225,6 +289,7 @@ void VVTK_PickingDlg::onClickApply() myPickingSettings->SetInfoWindowPosition( myPositionComboBox->currentItem() ); myPickingSettings->SetZoomFactor( myZoomFactorSpinBox->value() ); myPickingSettings->SetStepNumber( myStepNumberSpinBox->value() ); + myPickingSettings->SetDisplayParentMesh( myDisplayParentMeshCheckBox->isChecked() ); myPickingSettings->InvokeEvent(VISU::UpdatePickingSettingsEvent,NULL); } diff --git a/src/VVTK/VVTK_PickingDlg.h b/src/VVTK/VVTK_PickingDlg.h index 17ff30f3..5f4fb2d9 100644 --- a/src/VVTK/VVTK_PickingDlg.h +++ b/src/VVTK/VVTK_PickingDlg.h @@ -22,6 +22,7 @@ class vtkImageData; class QLabel; class QComboBox; +class QCheckBox; class QtxAction; class QtxDblSpinBox; @@ -30,6 +31,8 @@ class QtxIntSpinBox; class VISU_GaussPtsAct; class VISU_PickingSettings; +class SVTK_RenderWindowInteractor; + class VVTK_PickingDlg : public QDialog { Q_OBJECT @@ -47,21 +50,37 @@ public: VISU_PickingSettings* GetPickingSettings(); + void SetInteractor( SVTK_RenderWindowInteractor* ); + protected slots: virtual void done( int ); void onClickApply(); void onClickClose(); +private: + static void ProcessEvents(vtkObject* theObject, + unsigned long theEvent, + void* theClientData, + void* theCallData); + + void KeyPressed(); + private: QtxDblSpinBox* myPyramidHeightSpinBox; QtxIntSpinBox* myTransparencySpinBox; QComboBox* myPositionComboBox; QtxDblSpinBox* myZoomFactorSpinBox; QtxIntSpinBox* myStepNumberSpinBox; + QCheckBox* myDisplayParentMeshCheckBox; QtxAction* myAction; vtkSmartPointer myPickingSettings; + + SVTK_RenderWindowInteractor* myInteractor; + + float myPriority; + vtkSmartPointer myEventCallbackCommand; }; #endif