]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
VISU 2008 - Evolution of the VISU selection functionality
authorouv <ouv@opencascade.com>
Thu, 26 Jun 2008 13:01:15 +0000 (13:01 +0000)
committerouv <ouv@opencascade.com>
Thu, 26 Jun 2008 13:01:15 +0000 (13:01 +0000)
src/VISUGUI/Makefile.am
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI_FindPane.cxx [new file with mode: 0644]
src/VISUGUI/VisuGUI_FindPane.h [new file with mode: 0644]
src/VISUGUI/VisuGUI_GaussPointsSelectionPane.cxx
src/VISUGUI/VisuGUI_GaussPointsSelectionPane.h
src/VISUGUI/VisuGUI_SelectionPanel.cxx
src/VISUGUI/VisuGUI_SelectionPanel.h

index c61d27aff19250d1a03d00883eb9b8431cc768ba..9132d0b254ed2d99f420a72e28adfc7b3678a45b 100644 (file)
@@ -45,6 +45,7 @@ dist_libVISU_la_SOURCES= \
        VisuGUI_SelectionPanel.cxx \
        VisuGUI_SelectionPrefDlg.cxx \
        VisuGUI_GaussPointsSelectionPane.cxx \
+       VisuGUI_FindPane.cxx \
        VisuGUI_Tools.cxx \
        VisuGUI_ViewTools.cxx \
        VisuGUI_Selection.cxx \
@@ -88,6 +89,7 @@ MOC_FILES= \
        VisuGUI_SelectionPanel_moc.cxx \
        VisuGUI_SelectionPrefDlg_moc.cxx \
        VisuGUI_GaussPointsSelectionPane_moc.cxx \
+       VisuGUI_FindPane_moc.cxx \
        VisuGUI_NameDlg_moc.cxx \
        VisuGUI_FileDlg_moc.cxx \
        VisuGUI_CursorDlg_moc.cxx \
index a8b14e80a904a035e918e53d6cc1cc7e91319200..28309a2f5d273d71aa304dce9e4dbfb20d7b6521 100644 (file)
@@ -1727,6 +1727,33 @@ Please, provide non-empty resulting presentation.</translation>
             <translation>Full loading for current file</translation>
         </message>
     </context>
+    <context>
+        <name>VisuGUI_FindPane</name>
+        <message>
+            <source>BETWEEN</source>
+            <translation>Between</translation>
+        </message>
+        <message>
+            <source>CONDITION</source>
+            <translation>Where scalar value is:</translation>
+        </message>
+        <message>
+            <source>FIND_TITLE</source>
+            <translation>Find</translation>
+        </message>
+        <message>
+            <source>INCORRECT_VALUES</source>
+            <translation>Input values are incorrect</translation>
+        </message>
+        <message>
+            <source>MAXIMUM</source>
+            <translation>Maximum</translation>
+        </message>
+        <message>
+            <source>MINIMUM</source>
+            <translation>Minimum</translation>
+        </message>
+    </context>
     <context>
         <name>VisuGUI_FontWg</name>
         <message>
diff --git a/src/VISUGUI/VisuGUI_FindPane.cxx b/src/VISUGUI/VisuGUI_FindPane.cxx
new file mode 100644 (file)
index 0000000..f9df959
--- /dev/null
@@ -0,0 +1,364 @@
+//  VISU VISUGUI : GUI of VISU component
+//
+//  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_FindPane.cxx
+//  Author : Oleg Uvarov
+//  Module : VISU
+
+#include "VisuGUI_FindPane.h"
+#include "VisuGUI_Tools.h"
+
+#include "VISU_Actor.h"
+#include "VISU_Event.h"
+#include "VISU_GaussPtsAct.h"
+
+#include "VISU_IDMapper.hxx"
+#include "VISU_GaussPointsPL.hxx"
+
+#include "SUIT_MessageBox.h"
+#include "SUIT_ResourceMgr.h"
+
+#include <QComboBox>
+#include <QLabel>
+#include <QLayout>
+#include <QListWidget>
+#include <QLineEdit>
+#include <QToolButton>
+
+#include <vtkCellData.h>
+#include <vtkDataArray.h>
+#include <vtkDataSet.h>
+#include <vtkMapper.h>
+#include <vtkPointData.h>
+
+#define PAGE_SIZE 10
+
+VisuGUI_FindPane::VisuGUI_FindPane( QWidget* theParent ) :
+  QGroupBox( theParent ),
+  myCurrentPage( 0 ),
+  myActor( 0 )
+{
+  setTitle( tr( "FIND_TITLE" ) );
+
+  QGridLayout* aTopLayout = new QGridLayout( this );
+
+  QLabel* aConditionLabel = new QLabel( tr( "CONDITION" ), this );
+
+  myConditionBox = new QComboBox( this );
+  myConditionBox->addItems( QStringList()
+                           << tr( "MINIMUM" )
+                           << tr( "MAXIMUM" )
+                           << "="
+                           << "<="
+                           << ">="
+                           << tr( "BETWEEN" ) );
+
+  connect( myConditionBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onConditionChanged( int ) ) );
+
+  QDoubleValidator* aDoubleValidator = new QDoubleValidator( this );
+
+  myLeftValue = new QLineEdit( this );
+  myLeftValue->setValidator( aDoubleValidator );
+
+  myDashLabel = new QLabel( "-", this );
+
+  myRightValue = new QLineEdit( this );
+  myRightValue->setValidator( aDoubleValidator );
+
+  QToolButton* anApplyBtn = new QToolButton( this );
+  anApplyBtn->setIcon( VISU::GetResourceMgr()->loadPixmap( "VISU", tr( "ICON_APPLY" ) ) );
+  connect( anApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) );
+
+
+  QWidget* anIdsWidget = new QWidget( this );
+  QGridLayout* anIdsLayout = new QGridLayout( anIdsWidget );
+  anIdsLayout->setMargin( 0 );
+
+  myIdsListWidget = new QListWidget( anIdsWidget );
+  myIdsListWidget->setFlow( QListView::LeftToRight );
+  myIdsListWidget->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
+  myIdsListWidget->setFixedHeight( 45 );
+
+  connect( myIdsListWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( onIdChanged() ) );
+
+  myPageLabel = new QLabel( anIdsWidget );
+  myPageLabel->setAlignment( Qt::AlignHCenter );
+
+  myPrevBtn = new QToolButton( anIdsWidget );
+  myPrevBtn->setIcon( VISU::GetResourceMgr()->loadPixmap( "VISU", tr( "ICON_SLIDER_PREVIOUS" ) ) );
+  connect( myPrevBtn, SIGNAL( clicked() ), this, SLOT( onPrevPage() ) );
+
+  myNextBtn = new QToolButton( anIdsWidget );
+  myNextBtn->setIcon( VISU::GetResourceMgr()->loadPixmap( "VISU", tr( "ICON_SLIDER_NEXT" ) ) );
+  connect( myNextBtn, SIGNAL( clicked() ), this, SLOT( onNextPage() ) );
+
+  anIdsLayout->addWidget( myIdsListWidget, 0, 0, 2, 1 );
+  anIdsLayout->addWidget( myPageLabel,     0, 1, 1, 2 );
+  anIdsLayout->addWidget( myPrevBtn,       1, 1 );
+  anIdsLayout->addWidget( myNextBtn,       1, 2 );
+
+
+  aTopLayout->addWidget( aConditionLabel, 0, 0, 1, 5 );
+  aTopLayout->addWidget( myConditionBox,  1, 0 );
+  aTopLayout->addWidget( myLeftValue,     1, 1 );
+  aTopLayout->addWidget( myDashLabel,     1, 2 );
+  aTopLayout->addWidget( myRightValue,    1, 3 );
+  aTopLayout->addWidget( anApplyBtn,      1, 4 );
+  aTopLayout->addWidget( anIdsWidget,     2, 0, 1, 5 );
+
+  onConditionChanged( 0 );
+
+  setSelectionMode( ActorSelection );
+}
+
+VisuGUI_FindPane::~VisuGUI_FindPane()
+{
+}
+
+void VisuGUI_FindPane::setSelectionMode( const Selection_Mode theSelectionMode )
+{
+  if( mySelectionMode != theSelectionMode )
+    clearIds();
+
+  mySelectionMode = theSelectionMode;
+  setEnabled( mySelectionMode != ActorSelection );
+}
+
+
+void VisuGUI_FindPane::setActor( VISU_Actor* theActor )
+{
+  if( myActor != theActor )
+    clearIds();
+
+  myActor = theActor;
+}
+
+void VisuGUI_FindPane::onConditionChanged( int theId )
+{
+  myLeftValue->setEnabled( theId >= 2 );
+  myDashLabel->setEnabled( theId == 5 );
+  myRightValue->setEnabled( theId == 5 );
+}
+
+void VisuGUI_FindPane::onApply()
+{
+  if( !isValid() )
+  {
+    SUIT_MessageBox::warning( this, tr( "WRN_VISU" ), tr( "INCORRECT_VALUES" ) );
+    return;
+  }
+
+  myIdsListWidget->clear();
+
+  if( !myActor )
+    return;
+
+  vtkDataSet* aDataSet = myActor->GetInput();
+
+  vtkDataArray* aScalars = 0;
+  if( mySelectionMode == NodeSelection )
+    aScalars = aDataSet->GetPointData()->GetScalars();
+  else if( mySelectionMode == CellSelection )
+    aScalars = aDataSet->GetCellData()->GetScalars();
+  else if( mySelectionMode == GaussPointSelection )
+  {
+    if( VISU_GaussPtsAct* aGaussPtsAct = dynamic_cast<VISU_GaussPtsAct*>( myActor ) )
+      aScalars = aGaussPtsAct->GetInput()->GetPointData()->GetScalars();
+  }
+
+
+  if( !aScalars )
+    return;
+
+  int aCondition = myConditionBox->currentIndex();
+  double aLeftValue = myLeftValue->text().toDouble();
+  double aRightValue = myRightValue->text().toDouble();
+
+  myIdsList.clear();
+
+  double eps = 1.0 / VTK_LARGE_FLOAT;
+
+  double anExtremum = 0;
+  if( aCondition == 0 )
+    anExtremum = VTK_LARGE_FLOAT;
+  else if( aCondition == 1 )
+    anExtremum = -VTK_LARGE_FLOAT;
+
+  for( int aVTKId = 0, aNbVal = aScalars->GetNumberOfTuples(); aVTKId < aNbVal; aVTKId++ )
+  {
+    double aValue = *aScalars->GetTuple( aVTKId );
+
+    TFindId anId( -1, -1 );
+    if( mySelectionMode == NodeSelection )
+      anId.first = myActor->GetNodeObjId( aVTKId );
+    else if( mySelectionMode == CellSelection )
+      anId.first = myActor->GetElemObjId( aVTKId );
+    else if( mySelectionMode == GaussPointSelection )
+    {
+      if( VISU_GaussPtsAct* aGaussPtsAct = dynamic_cast<VISU_GaussPtsAct*>( myActor ) )
+      {
+       VISU::TGaussPointID aGaussPointID = aGaussPtsAct->GetGaussPointsPL()->GetObjID( aVTKId + 1 );
+       anId.first = aGaussPointID.first;
+       anId.second = aGaussPointID.second;
+      }
+    }
+
+    if( anId.first < 0 ||
+       anId.second < 0 && mySelectionMode == GaussPointSelection )
+      continue;
+
+    bool ok = false;
+    switch( aCondition )
+    {
+    case 0: // Minimum
+      ok = ( aValue - anExtremum ) < eps;
+      break;
+    case 1: // Maximum
+      ok = ( aValue - anExtremum ) > -eps;
+      break;
+    case 2: // =
+      ok = fabs( aValue - aLeftValue ) < eps;
+      break;
+    case 3: // <=
+      ok = ( aValue - aLeftValue ) < eps;
+      break;
+    case 4: // >=
+      ok = ( aValue - aLeftValue ) > -eps;
+      break;
+    case 5: // Between
+      ok = ( aValue - aLeftValue ) > -eps && ( aValue - aRightValue ) < eps;
+      break;
+    default:
+      ok = true;
+      break;
+    }
+
+    if( ok )
+    {
+      if( aCondition <= 1 && fabs( aValue - anExtremum ) > eps )
+      {
+       anExtremum = aValue;
+       myIdsList.clear();
+      }
+      if( !myIdsList.contains( anId ) )
+        myIdsList.append( anId );
+    }
+  }
+
+  qSort( myIdsList );
+
+  myCurrentPage = 0;
+  displayIds();
+}
+
+void VisuGUI_FindPane::onIdChanged()
+{
+  int aFirstId = -1, aSecondId = -1;
+
+  QList<QListWidgetItem*> aSelectedItems = myIdsListWidget->selectedItems();
+  if( aSelectedItems.size() == 1 )
+  {
+    QString aStr = aSelectedItems.first()->text();
+
+    bool ok = false;
+    aFirstId = aStr.toInt( &ok );
+    if( !ok ) // try to parse the string as a pair of ids - "[aFirstId aSecondId]"
+    {
+      aStr.remove( '[' );
+      aStr.remove( ']' );
+      aFirstId = aStr.section( ' ', 0, 0 ).toInt( &ok );
+      if( !ok )
+       aFirstId = -1;
+      else
+      {
+       ok = false;
+       aSecondId = aStr.section( ' ', 1, 1 ).toInt( &ok );
+       if( !ok )
+         aSecondId = -1;
+      }
+    }
+  }
+
+  emit idChanged( aFirstId, aSecondId );
+}
+
+void VisuGUI_FindPane::onPrevPage()
+{
+  myCurrentPage--;
+  displayIds();
+}
+
+void VisuGUI_FindPane::onNextPage()
+{
+  myCurrentPage++;
+  displayIds();
+}
+
+bool VisuGUI_FindPane::isValid() const
+{
+  bool ok = false;;
+  double aLeftValue = myLeftValue->text().toDouble( &ok );
+  if( myLeftValue->isEnabled() && !ok )
+    return false;
+
+  ok = false;
+  double aRightValue = myRightValue->text().toDouble( &ok );
+  if( myRightValue->isEnabled() && ( !ok || aRightValue < aLeftValue ) )
+    return false;
+
+  return true;
+}
+
+void VisuGUI_FindPane::clearIds()
+{
+  myIdsList.clear();
+  myCurrentPage = 0;
+
+  displayIds();
+}
+
+void VisuGUI_FindPane::displayIds()
+{
+  myIdsListWidget->clear();
+
+  int aSize = myIdsList.size();
+
+  myPrevBtn->setEnabled( myCurrentPage != 0 );
+  myNextBtn->setEnabled( ( myCurrentPage + 1 ) * PAGE_SIZE < aSize );
+  myPageLabel->setText( QString( "Page %1/%2" )
+                       .arg( aSize > 0 ? myCurrentPage + 1 : 0 )
+                       .arg( aSize > 0 ? ( aSize - 1 ) / PAGE_SIZE + 1 : 0 ) );
+
+  int aFirstIndex = myCurrentPage * PAGE_SIZE;
+  int aLastIndex = aFirstIndex + PAGE_SIZE - 1;
+  if( aLastIndex >= aSize )
+    aLastIndex = aSize - 1;
+
+  for( int anIndex = aFirstIndex; anIndex <= aLastIndex; anIndex++ )
+  {
+    TFindId anId = myIdsList[ anIndex ];
+    int aFirstId = anId.first, aSecondId = anId.second;
+    QString aStr = aSecondId < 0 ?
+      QString( "%1" ).arg( aFirstId ) :
+      QString( "[%1 %2]" ).arg( aFirstId ).arg( aSecondId );
+    myIdsListWidget->addItem( aStr );
+  }
+}
diff --git a/src/VISUGUI/VisuGUI_FindPane.h b/src/VISUGUI/VisuGUI_FindPane.h
new file mode 100644 (file)
index 0000000..3e36a20
--- /dev/null
@@ -0,0 +1,94 @@
+//  VISU VISUGUI : GUI of VISU component
+//
+//  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_FindPane.h
+//  Author : Oleg Uvarov
+//  Module : VISU
+
+#ifndef VISUGUI_FINDPANE_H
+#define VISUGUI_FINDPANE_H
+
+#include <SVTK_Selection.h>
+
+#include <QGroupBox>
+
+class QComboBox;
+class QLabel;
+class QLineEdit;
+class QListWidget;
+class QToolButton;
+
+class VISU_Actor;
+
+typedef QPair<int,int> TFindId;
+typedef QList<TFindId> TListFindId;
+
+//! Find pane.
+/*!
+ * Used for filter and highlight mesh-elements by their scalar values.
+ */
+class VisuGUI_FindPane : public QGroupBox
+{
+  Q_OBJECT
+
+public:
+  VisuGUI_FindPane( QWidget* theParent );
+  ~VisuGUI_FindPane();
+
+public:
+  void             setSelectionMode( const Selection_Mode );
+  void             setActor( VISU_Actor* );
+
+protected slots:
+  void             onConditionChanged( int );
+  void             onApply();
+
+  void             onIdChanged();
+  void             onPrevPage();
+  void             onNextPage();
+
+private:
+  bool             isValid() const;
+  void             clearIds();
+  void             displayIds();
+
+signals:
+  void             idChanged( int, int );
+
+private:
+  QComboBox*       myConditionBox;
+  QLineEdit*       myLeftValue;
+  QLabel*          myDashLabel;
+  QLineEdit*       myRightValue;
+
+  QListWidget*     myIdsListWidget;
+  QLabel*          myPageLabel;
+  QToolButton*     myPrevBtn;
+  QToolButton*     myNextBtn;
+
+  int              myCurrentPage;
+  TListFindId      myIdsList;
+
+  Selection_Mode   mySelectionMode;
+  VISU_Actor*      myActor;
+};
+
+#endif
index e62a7906aaff4c58f3567050ab90d03f85405ef9..15d621e6d9b9a7d45d50af12404d9a990df5292e 100644 (file)
@@ -167,6 +167,9 @@ namespace
     State
     validate ( QString & theInput, int & thePos ) const
     {
+      if( theInput.isEmpty() )
+       return QValidator::Acceptable;
+
       if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
        return QValidator::Invalid;
 
@@ -198,6 +201,9 @@ namespace
     State
     validate ( QString & theInput, int & thePos ) const
     {
+      if( theInput.isEmpty() )
+       return QValidator::Acceptable;
+
       if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
        return QValidator::Invalid;
 
@@ -311,16 +317,22 @@ VisuGUI_GaussPointsSelectionPane::~VisuGUI_GaussPointsSelectionPane()
 {
 }
 
-void VisuGUI_GaussPointsSelectionPane::Update()
+void VisuGUI_GaussPointsSelectionPane::update()
 {
   VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
-
   myDisplayParentMeshCheckBox->setChecked( aPickingSettings->GetDisplayParentMesh() );
 }
 
-void VisuGUI_GaussPointsSelectionPane::SetInteractor( SVTK_RenderWindowInteractor* theInteractor )
+void VisuGUI_GaussPointsSelectionPane::setIds( const int theParentId, const int theLocalId )
 {
-  //printf( "VisuGUI_GaussPointsSelectionPane::SetInteractor( %p )\n", theInteractor );
+  myParentElementLineEdit->setText( theParentId < 0 ? "" : QString::number( theParentId ) );
+  myLocalPointLineEdit->setText( theLocalId < 0 ? "" : QString::number( theLocalId ) );
+  onSelectionApply();
+}
+
+void VisuGUI_GaussPointsSelectionPane::setInteractor( SVTK_RenderWindowInteractor* theInteractor )
+{
+  //printf( "VisuGUI_GaussPointsSelectionPane::setInteractor( %p )\n", theInteractor );
   vtkGenericRenderWindowInteractor* aDevice = theInteractor->GetDevice();
   if( aDevice->HasObserver(vtkCommand::KeyPressEvent) )
     aDevice->RemoveObservers(vtkCommand::KeyPressEvent);
@@ -339,7 +351,7 @@ void VisuGUI_GaussPointsSelectionPane::SetInteractor( SVTK_RenderWindowInteracto
                       myPriority);
 }
 
-SVTK_RenderWindowInteractor* VisuGUI_GaussPointsSelectionPane::GetInteractor()
+SVTK_RenderWindowInteractor* VisuGUI_GaussPointsSelectionPane::getInteractor()
 {
   if( SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( myModule ) )
   {
@@ -372,7 +384,7 @@ void VisuGUI_GaussPointsSelectionPane::ProcessEvents(vtkObject* vtkNotUsed(theOb
 void VisuGUI_GaussPointsSelectionPane::KeyPressed()
 {
   //printf( "VisuGUI_GaussPointsSelectionPane::KeyPressed()\n" );
-  if( GetInteractor()->GetDevice()->GetKeyCode() == 'P' )
+  if( getInteractor()->GetDevice()->GetKeyCode() == 'P' )
   {
     VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
 
@@ -387,7 +399,7 @@ void VisuGUI_GaussPointsSelectionPane::KeyPressed()
 void VisuGUI_GaussPointsSelectionPane::SelectionEvent()
 {
   //printf( "VisuGUI_GaussPointsSelectionPane::SelectionEvent()\n" );
-  ClearIDControls();
+  clearIDControls();
 
   SelectorHelper aHelper( myModule );
   if( aHelper.get() )
@@ -419,27 +431,42 @@ void VisuGUI_GaussPointsSelectionPane::onSelectionApply()
   if( !aHelper.get() )
     return;
 
-  VISU::TCellID aCellId = myParentElementLineEdit->text().toInt();
-  VISU::TLocalPntID aLocalPntId = myLocalPointLineEdit->text().toInt();
-  VISU::PGaussPtsIDMapper anIDMapper = aHelper.myPipeLine->GetGaussPtsIDMapper();
-  vtkIdType anObjVtkId = anIDMapper->GetVTKID( VISU::TGaussPointID( aCellId, aLocalPntId ) );
-  if( anObjVtkId < 0 )
-    return;
+  vtkIdType anObjVtkId = -1;
+  VISU::TCellID aCellId;
+  VISU::TLocalPntID aLocalPntId;
 
-  aHelper.myMapIndex.Clear();
-  aHelper.myMapIndex.Add( anObjVtkId );
-  aHelper.mySelector->AddOrRemoveIndex( aHelper.myIO, aHelper.myMapIndex, false );
+  bool ok = false;
+  aCellId = myParentElementLineEdit->text().toInt( &ok );
+  if( ok )
+  {
+    ok = false;
+    aLocalPntId = myLocalPointLineEdit->text().toInt( &ok );
+    if( ok )
+    {
+      VISU::PGaussPtsIDMapper anIDMapper = aHelper.myPipeLine->GetGaussPtsIDMapper();
+      anObjVtkId = anIDMapper->GetVTKID( VISU::TGaussPointID( aCellId, aLocalPntId ) );
+    }
+  }
+
+  if( anObjVtkId < 0 )
+    aHelper.mySelector->ClearIndex();
+  else
+  {
+    aHelper.myMapIndex.Clear();
+    aHelper.myMapIndex.Add( anObjVtkId );
+    aHelper.mySelector->AddOrRemoveIndex( aHelper.myIO, aHelper.myMapIndex, false );
+  }
   aHelper.myActor->Highlight( aHelper.myIO );
-  GetInteractor()->GetDevice()->CreateTimer( VTKI_TIMER_FIRST );
+  getInteractor()->GetDevice()->CreateTimer( VTKI_TIMER_FIRST );
 }
 
-void VisuGUI_GaussPointsSelectionPane::ClearIDControls()
+void VisuGUI_GaussPointsSelectionPane::clearIDControls()
 {
   myParentElementLineEdit->setText( "" );
   myLocalPointLineEdit->setText( "" );
 }
 
-void VisuGUI_GaussPointsSelectionPane::Apply()
+void VisuGUI_GaussPointsSelectionPane::apply()
 {
   onSelectionApply();
 }
index 245c12f6f4044aaf52f8f124d0117181bafcb7b9..a344063699b41fe6c3369c43e1a8eda5f0691d3d 100644 (file)
@@ -26,8 +26,6 @@
 #ifndef VISUGUI_GAUSSPOINTSSELECTIONPANE_H
 #define VISUGUI_GAUSSPOINTSSELECTIONPANE_H
 
-#include "VISU_IDMapper.hxx"
-
 #include <vtkObject.h>
 #include <vtkSmartPointer.h>
 
@@ -65,16 +63,18 @@ public:
 
   ~VisuGUI_GaussPointsSelectionPane();
 
-  //! Update dialog contents.
-  void                                  Update();
+  //! update dialog contents.
+  void                                  update();
+
+  void                                  setIds( const int, const int );
 
-  void                                  SetInteractor( SVTK_RenderWindowInteractor* );
+  void                                  setInteractor( SVTK_RenderWindowInteractor* );
 
-  void                                  Apply();
-  //void                                  Help();
+  void                                  apply();
+  //void                                  help();
 
 protected:
-  SVTK_RenderWindowInteractor*          GetInteractor();
+  SVTK_RenderWindowInteractor*          getInteractor();
 
 protected slots:
   void                                  onSelectionValidate();
@@ -93,7 +93,7 @@ private:
   void                                  SelectionEvent();
   //void                                  keyPressEvent( QKeyEvent* e );
 
-  void                                  ClearIDControls();
+  void                                  clearIDControls();
 
 private:
   const SalomeApp_Module*               myModule;
index 863ba91a63ff7331ec67eaec1dfde5020c6ed949..dd2d672ea57940d0ed5489fdc4e584534247e800 100644 (file)
@@ -33,6 +33,7 @@
 #include "VisuGUI_ViewTools.h"
 #include "VisuGUI_SelectionPrefDlg.h"
 #include "VisuGUI_GaussPointsSelectionPane.h"
+#include "VisuGUI_FindPane.h"
 
 #include "VISU_Event.h"
 
@@ -90,7 +91,6 @@
 #include <QHeaderView>
 #include <QTabWidget>
 #include <QScrollArea>
-#include <QComboBox>
 
 // VTK Includes
 #include <vtkDataSetMapper.h>
 
 using namespace std;
 
-#define MARGIN_SIZE 3
+class CustomIntValidator: public QIntValidator
+{
+public:
+  CustomIntValidator( QObject * theParent ):
+    QIntValidator( 0, VTK_LARGE_ID, theParent )
+  {}
+
+  virtual 
+  State
+  validate( QString& theInput, int& thePos ) const
+  {
+    if( theInput.isEmpty() )
+      return QValidator::Acceptable;
+
+    return QIntValidator::validate( theInput, thePos );
+  }
+};
 
 VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModule, QWidget* theParent ) :
   VisuGUI_BasePanel( tr("WINDOW_TITLE" ), theParent, /*ApplyBtn | */CloseBtn | HelpBtn ),
@@ -114,7 +130,6 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModul
 {
   QVBoxLayout* TopLayout = new QVBoxLayout ( mainFrame() );
   //TopLayout->setSpacing(6);
-  //TopLayout->setMargin(MARGIN_SIZE);
 
   QWidget* aNamePane = new QWidget (mainFrame());
   QGridLayout* aNameLay = new QGridLayout (aNamePane);
@@ -149,7 +164,7 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModul
   
   myIDValLbl = new QLineEdit ("", aDataGrp);
   aGridLay->addWidget( myIDValLbl, 0, 1 );
-  QIntValidator* aIntValidator = new QIntValidator (myIDValLbl);
+  CustomIntValidator* aIntValidator = new CustomIntValidator (myIDValLbl);
   aIntValidator->setBottom(0);
   myIDValLbl->setValidator(aIntValidator);
   connect(myIDValLbl, SIGNAL(returnPressed()), this, SLOT(onPointIdEdit()));
@@ -306,6 +321,13 @@ VisuGUI_SelectionPanel::VisuGUI_SelectionPanel( const SalomeApp_Module* theModul
 
   TopLayout->addWidget( myTabWidget );
 
+  // Find Pane
+  myFindPane = new VisuGUI_FindPane( mainFrame() );
+
+  connect( myFindPane, SIGNAL( idChanged( int, int ) ), this, SLOT( onIdChanged( int, int ) ) );
+
+  TopLayout->addWidget( myFindPane );
+
   // Preferences button
   QPushButton* aPrefBtn = new QPushButton( tr( "SELECTION_PREFERENCES" ),  mainFrame() );
   connect( aPrefBtn, SIGNAL( clicked() ), this, SLOT( onPreferences() ) );
@@ -377,6 +399,8 @@ void VisuGUI_SelectionPanel::onSelectionModeChanged( int theId )
     break;
   }
 
+  myFindPane->setSelectionMode( aViewWindow->SelectionMode() );
+
   emit selectionModeChanged( theId );
 }
 
@@ -435,7 +459,7 @@ void VisuGUI_SelectionPanel::onSelectionEvent() {
   if(SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow())
   {
     SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
-    myGaussPointsPane->SetInteractor(anInteractor);
+    myGaussPointsPane->setInteractor(anInteractor);
   }
 
   SVTK_Selector* aSelector = aViewWindow->GetSelector();
@@ -473,6 +497,7 @@ void VisuGUI_SelectionPanel::onSelectionEvent() {
 
     VISU_Actor* anVISUActor =
       VISU::FindActor(VISU::GetAppStudy(myModule), aViewWindow, aSObject->GetID().c_str());
+    myFindPane->setActor( anVISUActor );
     if (anVISUActor) {
       vtkFloatingPointType aCoord[6];
       anVISUActor->GetBounds(aCoord);
@@ -664,19 +689,29 @@ bool onIdEdit (const QString& theText,
     }
   }
   if (aPrs3d) {
-    int anObjId = theText.toInt();
+    bool ok = false;
+    int anObjId = theText.toInt( &ok );
+    if( !ok )
+      anObjId = -1;
+
     VISU_PipeLine* aPipeLine = aPrs3d->GetPipeLine();
 
     if( dynamic_cast<VISU_GaussPointsPL*>( aPipeLine ) )
       return false;
 
-    int aVTKId = (aPipeLine->*theMethod)(anObjId);
-    if(aVTKId < 0)
-      return false;
+    if( anObjId < 0 )
+      aSelector->ClearIndex();
+    else
+    {
+      int aVTKId = (aPipeLine->*theMethod)(anObjId);
+      if(aVTKId < 0)
+       return false;
+
+      TColStd_MapOfInteger newIndices;
+      newIndices.Add(anObjId);
+      aSelector->AddOrRemoveIndex(anIO, newIndices, false);
+    }
 
-    TColStd_MapOfInteger newIndices;
-    newIndices.Add(anObjId);
-    aSelector->AddOrRemoveIndex(anIO, newIndices, false);
     aViewWindow->highlight(anIO, true, true);
 
     if( SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow() )
@@ -732,6 +767,24 @@ void VisuGUI_SelectionPanel::onCellIdEdit ()
     clearFields();
 }
 
+void VisuGUI_SelectionPanel::onIdChanged( int theFirstId, int theSecondId )
+{
+  //printf( "VisuGUI_SelectionPanel::onIdChanged( %d, %d )\n", theFirstId, theSecondId );
+  int aType = myTabWidget->currentIndex();
+  if( aType == 1 )
+  {
+    myCellIDValLbl->setText( theFirstId < 0 ? "" : QString::number( theFirstId ) );
+    onCellIdEdit();
+  }
+  else if( aType == 2 )
+  {
+    myIDValLbl->setText( theFirstId < 0 ? "" : QString::number( theFirstId ) );
+    onPointIdEdit();
+  }
+  else if( aType == 3 )
+    myGaussPointsPane->setIds( theFirstId, theSecondId );
+}
+
 void VisuGUI_SelectionPanel::onPreferences()
 {
   preferencesDlg()->exec();
index d85c7dd2fe17f4fa866bf0f760841ee17c090681..3daa392a53162cbcc3ce398428d2a5d00ad5081c 100644 (file)
@@ -33,7 +33,6 @@
 
 #include <vtkSmartPointer.h>
 
-class QComboBox;
 class QLabel;
 class QLineEdit;
 class QTableWidget;
@@ -45,6 +44,7 @@ class SalomeApp_Module;
 class SVTK_RenderWindowInteractor;
 
 class VisuGUI_GaussPointsSelectionPane;
+class VisuGUI_FindPane;
 class VisuGUI_SelectionPrefDlg;
 
 class VisuGUI_SelectionPanel: public VisuGUI_BasePanel
@@ -77,6 +77,8 @@ private slots:
   void                      onPointIdEdit();
   void                      onCellIdEdit();
 
+  void                      onIdChanged( int theFirstId, int theSecondId );
+
 signals:
   void                      selectionModeChanged( int );
 
@@ -119,6 +121,8 @@ private:
 
   VisuGUI_GaussPointsSelectionPane* myGaussPointsPane;
 
+  VisuGUI_FindPane*         myFindPane;
+
   VisuGUI_SelectionPrefDlg* myPreferencesDlg;
 
   const SalomeApp_Module*   myModule;