VisuGUI_SelectionPanel.cxx \
VisuGUI_SelectionPrefDlg.cxx \
VisuGUI_GaussPointsSelectionPane.cxx \
+ VisuGUI_FindPane.cxx \
VisuGUI_Tools.cxx \
VisuGUI_ViewTools.cxx \
VisuGUI_Selection.cxx \
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 \
<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>
--- /dev/null
+// 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 );
+ }
+}
--- /dev/null
+// 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
State
validate ( QString & theInput, int & thePos ) const
{
+ if( theInput.isEmpty() )
+ return QValidator::Acceptable;
+
if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
return QValidator::Invalid;
State
validate ( QString & theInput, int & thePos ) const
{
+ if( theInput.isEmpty() )
+ return QValidator::Acceptable;
+
if ( GaussPtsIDValidator::validate( theInput, thePos ) == QValidator::Invalid)
return QValidator::Invalid;
{
}
-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);
myPriority);
}
-SVTK_RenderWindowInteractor* VisuGUI_GaussPointsSelectionPane::GetInteractor()
+SVTK_RenderWindowInteractor* VisuGUI_GaussPointsSelectionPane::getInteractor()
{
if( SVTK_ViewWindow* aViewWindow = VISU::GetActiveViewWindow<SVTK_ViewWindow>( myModule ) )
{
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();
void VisuGUI_GaussPointsSelectionPane::SelectionEvent()
{
//printf( "VisuGUI_GaussPointsSelectionPane::SelectionEvent()\n" );
- ClearIDControls();
+ clearIDControls();
SelectorHelper aHelper( myModule );
if( aHelper.get() )
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();
}
#ifndef VISUGUI_GAUSSPOINTSSELECTIONPANE_H
#define VISUGUI_GAUSSPOINTSSELECTIONPANE_H
-#include "VISU_IDMapper.hxx"
-
#include <vtkObject.h>
#include <vtkSmartPointer.h>
~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();
void SelectionEvent();
//void keyPressEvent( QKeyEvent* e );
- void ClearIDControls();
+ void clearIDControls();
private:
const SalomeApp_Module* myModule;
#include "VisuGUI_ViewTools.h"
#include "VisuGUI_SelectionPrefDlg.h"
#include "VisuGUI_GaussPointsSelectionPane.h"
+#include "VisuGUI_FindPane.h"
#include "VISU_Event.h"
#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 ),
{
QVBoxLayout* TopLayout = new QVBoxLayout ( mainFrame() );
//TopLayout->setSpacing(6);
- //TopLayout->setMargin(MARGIN_SIZE);
QWidget* aNamePane = new QWidget (mainFrame());
QGridLayout* aNameLay = new QGridLayout (aNamePane);
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()));
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() ) );
break;
}
+ myFindPane->setSelectionMode( aViewWindow->SelectionMode() );
+
emit selectionModeChanged( theId );
}
if(SVTK_MainWindow* aMainWindow = aViewWindow->getMainWindow())
{
SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
- myGaussPointsPane->SetInteractor(anInteractor);
+ myGaussPointsPane->setInteractor(anInteractor);
}
SVTK_Selector* aSelector = aViewWindow->GetSelector();
VISU_Actor* anVISUActor =
VISU::FindActor(VISU::GetAppStudy(myModule), aViewWindow, aSObject->GetID().c_str());
+ myFindPane->setActor( anVISUActor );
if (anVISUActor) {
vtkFloatingPointType aCoord[6];
anVISUActor->GetBounds(aCoord);
}
}
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() )
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();
#include <vtkSmartPointer.h>
-class QComboBox;
class QLabel;
class QLineEdit;
class QTableWidget;
class SVTK_RenderWindowInteractor;
class VisuGUI_GaussPointsSelectionPane;
+class VisuGUI_FindPane;
class VisuGUI_SelectionPrefDlg;
class VisuGUI_SelectionPanel: public VisuGUI_BasePanel
void onPointIdEdit();
void onCellIdEdit();
+ void onIdChanged( int theFirstId, int theSecondId );
+
signals:
void selectionModeChanged( int );
VisuGUI_GaussPointsSelectionPane* myGaussPointsPane;
+ VisuGUI_FindPane* myFindPane;
+
VisuGUI_SelectionPrefDlg* myPreferencesDlg;
const SalomeApp_Module* myModule;