]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Fixed Bug GVIEW10325 : Functionality ?Display Parent mesh element? isn?t implemented...
authorouv <ouv@opencascade.com>
Tue, 18 Oct 2005 11:49:14 +0000 (11:49 +0000)
committerouv <ouv@opencascade.com>
Tue, 18 Oct 2005 11:49:14 +0000 (11:49 +0000)
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsSettings.cxx
src/OBJECT/VISU_GaussPtsSettings.h
src/VISUGUI/VISUM_msg_en.po
src/VISUGUI/VisuGUI_Module.cxx
src/VVTK/VVTK_InteractorStyle.cxx
src/VVTK/VVTK_MainWindow.cxx
src/VVTK/VVTK_PickingDlg.cxx
src/VVTK/VVTK_PickingDlg.h

index cb5470a11aad81a42d0e45c59b6b59a67e715af8..edb96a155ca0bef0facc414eb874bd4ba161cd53 100644 (file)
@@ -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();
index 3150ed052c0cc9de95d3a7f5f020d3ecc4751741..f60ae626b7f99f9403853182ab0ff592c8cd6dde 100644 (file)
@@ -64,6 +64,7 @@ VISU_PickingSettings::VISU_PickingSettings()
   this->InfoWindowPosition     = -1;
   this->ZoomFactor             = -1;
   this->StepNumber             = -1;
+  this->DisplayParentMesh      = false;
 }
 
 VISU_PickingSettings::~VISU_PickingSettings()
index a8cc2b309c33035768402ba74f1e6ea649efaf34..e7618d793b0a5510b839c6b1feba7bac7bbd7000 100644 (file)
@@ -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;
 };
 
 
index ace512ebd4e0e3ceb6ac4331b0f30fecb1948385..303fb4c17fb1a0eca5e76291dc5e78f679eefbda 100644 (file)
@@ -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
index 79c6d7ceabe6a3891343a4a2b8dc58efa7434da7..b89749894e45777e3569a35a5c23bb36767d05b5 100644 (file)
@@ -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<QVariant> 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" );
 }
 
 
index 2dcb871a0a25a8682d2faf881ac868573d5dfb7b..36f89c885c988c254e5e92aefa2ea83cc25aa840 100644 (file)
@@ -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);
   }
 }
 
index bb7f00180dd2001b2cfd3ae3350e42f9c54b0797..c0b4e76a521f4a6fb7570531908eb2dfb2633368 100644 (file)
@@ -180,7 +180,9 @@ VVTK_MainWindow1
 {
   myRenderer = theRenderer;
   VVTK_MainWindow::Initialize(theInteractor);
+
   mySegmentationCursorDlg->SetWidget( theRenderer->GetImplicitFunctionWidget() );
+  myPickingDlg->SetInteractor( GetInteractor() );
 }
 
 VVTK_MainWindow1
index 9a8ed193d64cbc3c9324c7c0488c36ad610d6fbe..ca0d7f09e3ccb3329c36f108ff0510b13ec2d43e 100644 (file)
 #include "SUIT_ResourceMgr.h"
 #include "SUIT_Session.h"
 
+#include "SVTK_RenderWindowInteractor.h"
+
 #include <vtkActorCollection.h>
 #include <vtkCallbackCommand.h>
 #include <vtkObjectFactory.h>
 #include <vtkRenderer.h>
-#include <vtkRenderWindowInteractor.h>
+#include <vtkGenericRenderWindowInteractor.h>
 #include <vtkSmartPointer.h>
 
 #include "utilities.h"
 
+#include <qcheckbox.h>
 #include <qcombobox.h>
 #include <qgroupbox.h>
 #include <qlabel.h>
@@ -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<VVTK_PickingDlg*>(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);
 }
index 17ff30f3ea9d46c68886aa0cc24295153377e469..5f4fb2d9d024320cc62502ba75eda45a09f4954d 100644 (file)
@@ -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<VISU_PickingSettings> myPickingSettings;
+
+  SVTK_RenderWindowInteractor* myInteractor;
+
+  float            myPriority;
+  vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
 };
 
 #endif